diff options
author | marha <marha@users.sourceforge.net> | 2015-03-05 22:17:40 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2015-03-05 22:17:40 +0100 |
commit | 8574eba804031f6b19713f0b02952280730bf62e (patch) | |
tree | 9afa4d6fe299d43ab7e580dc08a5547120274561 | |
parent | eef70231353a6103f47fcae88a6e89e765e5cd47 (diff) | |
download | vcxsrv-8574eba804031f6b19713f0b02952280730bf62e.tar.gz vcxsrv-8574eba804031f6b19713f0b02952280730bf62e.tar.bz2 vcxsrv-8574eba804031f6b19713f0b02952280730bf62e.zip |
fontconfig mesa git update 5 Mar 2015
350 files changed, 3372 insertions, 6882 deletions
diff --git a/fontconfig/Makefile.am b/fontconfig/Makefile.am index 2b949e439..2b4a5b822 100644 --- a/fontconfig/Makefile.am +++ b/fontconfig/Makefile.am @@ -21,7 +21,7 @@ # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -SUBDIRS=fontconfig fc-case fc-lang fc-glyphname src \ +SUBDIRS=fontconfig fc-blanks fc-case fc-lang fc-glyphname src \ fc-cache fc-cat fc-list fc-match fc-pattern fc-query fc-scan \ fc-validate conf.d test if ENABLE_DOCS diff --git a/fontconfig/configure.ac b/fontconfig/configure.ac index 9011f37a3..8f0150ef5 100644 --- a/fontconfig/configure.ac +++ b/fontconfig/configure.ac @@ -53,6 +53,7 @@ m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], AC_SUBST([pkgconfigdir], ${libdir}/ AM_MISSING_PROG([GIT], [git]) AM_MISSING_PROG([GPERF], [gperf]) +AM_PATH_PYTHON AC_MSG_CHECKING([for RM macro]) _predefined_rm=`make -p -f /dev/null 2>/dev/null|grep '^RM ='|sed -e 's/^RM = //'` @@ -105,7 +106,6 @@ AM_CONDITIONAL(MS_LIB_AVAILABLE, test x$ms_librarian = xyes) AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) WARN_CFLAGS="" -WERROR_CFLAGS="-Werror" WARNING_CPP_DIRECTIVE="no" if test "x$GCC" = "xyes"; then WARN_CFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes \ @@ -114,8 +114,6 @@ if test "x$GCC" = "xyes"; then WARNING_CPP_DIRECTIVE="yes" elif test "x$SUNCC" = "xyes"; then WARN_CFLAGS="-v -fd" - WERROR_CFLAGS="-errtags \ - -errwarn=%all,no%E_OLD_STYLE_FUNC_DEF,no%E_STATEMENT_NOT_REACHED" WARNING_CPP_DIRECTIVE="yes" fi if test "x$WARNING_CPP_DIRECTIVE" = "xyes"; then @@ -167,38 +165,6 @@ dnl AC_CHECK_FUNCS doesn't check for header files. dnl posix_fadvise() may be not available in older libc. AC_CHECK_SYMBOL([posix_fadvise], [fcntl.h], [fc_func_posix_fadvise=1], [fc_func_posix_fadvise=0]) AC_DEFINE_UNQUOTED([HAVE_POSIX_FADVISE], [$fc_func_posix_fadvise], [Define to 1 if you have the 'posix_fadvise' function.]) -if test "$os_win32" = "no"; then - AC_MSG_CHECKING([for scandir]) - fc_saved_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $WARN_CFLAGS $WERROR_CFLAGS" - AC_TRY_COMPILE([ - #include <dirent.h> - int main(void); - ], [ - int (* comp) (const struct dirent **, const struct dirent **) = 0; - struct dirent **d; - return scandir(".", &d, 0, comp) >= 0; - ], [ - AC_MSG_RESULT([yes]) - AC_DEFINE([HAVE_SCANDIR], [1], [Define to 1 if you have the 'scandir' function.]) - ], [ - AC_TRY_COMPILE([ - #include <dirent.h> - int main(void); - ], [ - int (* comp) (const void *, const void *) = 0; - struct dirent **d; - return scandir(".", &d, 0, comp) >= 0; - ], [ - AC_MSG_RESULT([yes]) - AC_DEFINE([HAVE_SCANDIR_VOID_P], [1], [Define to 1 if you have the 'scandir' function with int (* compar)(const void *, const void *)]) - ],[ - AC_MSG_ERROR([ -*** No scandir function available.]) - ]) - ]) -fi -CFLAGS="$fc_saved_CFLAGS" # if test "x$ac_cv_func_fstatvfs" = "xyes"; then @@ -715,6 +681,7 @@ dnl Figure out what cache format suffix to use for this architecture AC_C_BIGENDIAN AC_CHECK_SIZEOF([void *]) AC_CHECK_ALIGNOF([double]) +AC_CHECK_ALIGNOF([void *]) dnl include the header file for workaround of miscalculating size on autoconf dnl particularly for fat binaries @@ -731,6 +698,7 @@ Makefile fontconfig/Makefile fc-lang/Makefile fc-glyphname/Makefile +fc-blanks/Makefile fc-case/Makefile src/Makefile conf.d/Makefile diff --git a/fontconfig/fc-blanks/Makefile.am b/fontconfig/fc-blanks/Makefile.am new file mode 100644 index 000000000..5b9700031 --- /dev/null +++ b/fontconfig/fc-blanks/Makefile.am @@ -0,0 +1,40 @@ +# -*- encoding: utf-8 -*- +# +# Copyright © 2003 Keith Packard +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of the author(s) not be used in +# advertising or publicity pertaining to distribution of the software without +# specific, written prior permission. The authors make no +# representations about the suitability of this software for any purpose. It +# is provided "as is" without express or implied warranty. +# +# THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +# EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +NULL = +BLANKSPY = fc-blanks.py +BLANKS_H = fcblanks.h +TMPL = fcblanks.tmpl.h +noinst_SCRIPTS = $(BLANKSPY) +noinst_HEADERS = $(BLANKS_H) + +$(BLANKS_H): $(TMPL) $(BLANKSPY) + $(AM_V_GEN) $(PYTHON) $(srcdir)/$(BLANKSPY) < $< > $(BLANKS_H).tmp && \ + mv $(BLANKS_H).tmp $(BLANKS_H) || ($(RM) $(BLANKS_H).tmp && false) + +EXTRA_DIST = \ + $(BLANKS_H) \ + $(TMPL) \ + $(NULL) +DISTCLEANFILES = $(BLANKS_H) + +-include $(top_srcdir)/git.mk diff --git a/fontconfig/fc-blanks/fc-blanks.py b/fontconfig/fc-blanks/fc-blanks.py new file mode 100644 index 000000000..a2f0b9502 --- /dev/null +++ b/fontconfig/fc-blanks/fc-blanks.py @@ -0,0 +1,132 @@ +#! /usr/bin/python + +import urllib2 +import sys +from lxml import html + +fp = urllib2.urlopen('http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[%3AGC%3DZs%3A][%3ADI%3A]&abb=on&ucd=on&esc=on&g') +data = fp.read() +fp.close() + +dom = html.fromstring(data) +x = dom.xpath('/html/body/form/p/text()') +p = x[1] +if p[0] == '[' and p[-1] == ']': + p = p.replace('[', '').replace(']', '') +else: + sys.exit(1) +fescape = False +funicode = False +frange = False +fprocess = False +v = 0 +vbegin = 0 +vend = 0 +n = 0 +l = [] + +def insert(db, begin, end): + db.append([begin, end]) + +for i in p: + if i == '\\': + if n > 0: + if frange == True and funicode == True: + vend = v + insert(l, vbegin, vend) + fprocess = True + elif funicode == True: + vbegin = v + vend = v + insert(l, vbegin, vend) + fprocess = True + funicode = False + fescape = True + elif i.lower() == 'u' and fescape == True: + funicode = True + fescape = False + elif i >= '0' and i <= '9' or i.lower() >= 'a' and i.lower() <= 'f': + if fescape == True: + raise RuntimeError, "Unexpected escape code" + if funicode == True: + v <<= 4 + v += int(i, 16) + else: + raise RuntimeError, "Unable to parse Unicode" + elif i == ' ': + if fescape == True: + funicode = True + fescape = False + v = 0x20 + if frange == True and funicode == True: + vend = v + insert(l, vbegin, vend) + fprocess = True + elif funicode == True: + vbegin = v + vend = v + insert(l, vbegin, vend) + fprocess = True + funicode = False + frange = False + elif i == '-': + if fescape == True: + raise RuntimeError, "Unexpected escape code" + vbegin = v + v = 0 + funicode = False + frange = True + else: + raise RuntimeError, "Unable to parse Unicode: %s" % i + + if fprocess == True: + vbegin = 0 + vend = 0 + v = 0 + fprocess = False + funicode = False + frange = False + n += 1 + +if frange == True and funicode == True: + vend = v + insert(l, vbegin, vend) +elif funicode == True: + vbegin = vend = v + insert(l, vbegin, vend) + +ncode = 0 +for i in l: + ncode += (i[1] - i[0] + 1) + +a = int(x[0].split(' ')[0].replace(',', '')) +if a != ncode: + sys.stderr.write("Unexpected the amount of code points: %d (expected %d)\n" % (ncode, a)) + sys.exit(1) + +# exception; BRAILLE PATTERN BLANK +insert(l, 0x2800, 0x2800) + +while True: + s = sys.stdin.readline().rstrip() + if s == "@@@": + break + print s + +print "static FcChar32 _fcBlanks[%s] = {" % (ncode + 1) +k = 0 +for i in sorted(l, key=lambda(a): a[0]): + for j in range(i[0], i[1] + 1): + if k != 0: + print "," + print " 0x%04x" % j, + k += 1 + +print "};" +print ''' +static FcBlanks fcBlanks = { + %s, + -1, + _fcBlanks +}; +''' % (ncode + 1) diff --git a/fontconfig/fc-blanks/fcblanks.tmpl.h b/fontconfig/fc-blanks/fcblanks.tmpl.h new file mode 100644 index 000000000..2bcaa21d6 --- /dev/null +++ b/fontconfig/fc-blanks/fcblanks.tmpl.h @@ -0,0 +1,25 @@ +/* + * fontconfig/fc-blanks/fcblanks.tmpl.h + * + * Copyright © 2003 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the author(s) not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors make no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +@@@ diff --git a/fontconfig/fonts.conf.in b/fontconfig/fonts.conf.in index f63ada1cd..7c16a7074 100644 --- a/fontconfig/fonts.conf.in +++ b/fontconfig/fonts.conf.in @@ -79,74 +79,6 @@ <config> <!-- - These are the default Unicode chars that are expected to be blank - in fonts. All other blank chars are assumed to be broken and - won't appear in the resulting charsets - --> - <blank> - <int>0x0020</int> <!-- SPACE --> - <int>0x00A0</int> <!-- NO-BREAK SPACE --> - <int>0x00AD</int> <!-- SOFT HYPHEN --> - <int>0x034F</int> <!-- COMBINING GRAPHEME JOINER --> - <int>0x061C</int> <!-- ARABIC LETTER MARK --> - <int>0x115F</int> <!-- HANGUL CHOSEONG FILLER --> - <int>0x1160</int> <!-- HANGUL JUNGSEONG FILLER --> - <int>0x1680</int> <!-- OGHAM SPACE MARK --> - <int>0x17B4</int> <!-- KHMER VOWEL INHERENT AQ --> - <int>0x17B5</int> <!-- KHMER VOWEL INHERENT AA --> - <int>0x180B</int> <!-- MONGOLIAN FREE VARIATION SELECTOR ONE --> - <int>0x180C</int> <!-- MONGOLIAN FREE VARIATION SELECTOR TWO --> - <int>0x180D</int> <!-- MONGOLIAN FREE VARIATION SELECTOR THREE --> - <int>0x180E</int> <!-- MONGOLIAN VOWEL SEPARATOR --> - <int>0x2000</int> <!-- EN QUAD --> - <int>0x2001</int> <!-- EM QUAD --> - <int>0x2002</int> <!-- EN SPACE --> - <int>0x2003</int> <!-- EM SPACE --> - <int>0x2004</int> <!-- THREE-PER-EM SPACE --> - <int>0x2005</int> <!-- FOUR-PER-EM SPACE --> - <int>0x2006</int> <!-- SIX-PER-EM SPACE --> - <int>0x2007</int> <!-- FIGURE SPACE --> - <int>0x2008</int> <!-- PUNCTUATION SPACE --> - <int>0x2009</int> <!-- THIN SPACE --> - <int>0x200A</int> <!-- HAIR SPACE --> - <int>0x200B</int> <!-- ZERO WIDTH SPACE --> - <int>0x200C</int> <!-- ZERO WIDTH NON-JOINER --> - <int>0x200D</int> <!-- ZERO WIDTH JOINER --> - <int>0x200E</int> <!-- LEFT-TO-RIGHT MARK --> - <int>0x200F</int> <!-- RIGHT-TO-LEFT MARK --> - <int>0x202A</int> <!-- LEFT-TO-RIGHT EMBEDDING --> - <int>0x202B</int> <!-- RIGHT-TO-LEFT EMBEDDING --> - <int>0x202C</int> <!-- POP DIRECTIONAL FORMATTING --> - <int>0x202D</int> <!-- LEFT-TO-RIGHT OVERRIDE --> - <int>0x202E</int> <!-- RIGHT-TO-LEFT OVERRIDE --> - <int>0x202F</int> <!-- NARROW NO-BREAK SPACE --> - <int>0x205F</int> <!-- MEDIUM MATHEMATICAL SPACE --> - <int>0x2060</int> <!-- WORD JOINER --> - <int>0x2061</int> <!-- FUNCTION APPLICATION --> - <int>0x2062</int> <!-- INVISIBLE TIMES --> - <int>0x2063</int> <!-- INVISIBLE SEPARATOR --> - <int>0x2064</int> <!-- INVISIBLE PLUS --> - <int>0x2066</int> <!-- LEFT-TO-RIGHT ISOLATE --> - <int>0x2067</int> <!-- RIGHT-TO-LEFT ISOLATE --> - <int>0x2068</int> <!-- FIRST STRONG ISOLATE --> - <int>0x2069</int> <!-- POP DIRECTIONAL ISOLATE --> - <int>0x206A</int> <!-- INHIBIT SYMMETRIC SWAPPING --> - <int>0x206B</int> <!-- ACTIVATE SYMMETRIC SWAPPING --> - <int>0x206C</int> <!-- INHIBIT ARABIC FORM SHAPING --> - <int>0x206D</int> <!-- ACTIVATE ARABIC FORM SHAPING --> - <int>0x206E</int> <!-- NATIONAL DIGIT SHAPES --> - <int>0x206F</int> <!-- NOMINAL DIGIT SHAPES --> - <int>0x2800</int> <!-- BRAILLE PATTERN BLANK --> - <int>0x3000</int> <!-- IDEOGRAPHIC SPACE --> - <int>0x3164</int> <!-- HANGUL FILLER --> - <int>0xFEFF</int> <!-- ZERO WIDTH NO-BREAK SPACE --> - <int>0xFFA0</int> <!-- HALFWIDTH HANGUL FILLER --> - <int>0x1BCA0</int> <!-- SHORTHAND FORMAT LETTER OVERLAP --> - <int>0x1BCA1</int> <!-- SHORTHAND FORMAT CONTINUING OVERLAP --> - <int>0x1BCA2</int> <!-- SHORTHAND FORMAT DOWN STEP --> - <int>0x1BCA3</int> <!-- SHORTHAND FORMAT UP STEP --> - </blank> -<!-- Rescan configuration every 30 seconds when FcFontSetList is called --> <rescan> diff --git a/fontconfig/src/fcarch.c b/fontconfig/src/fcarch.c index 398f4bbfc..4a921c062 100644 --- a/fontconfig/src/fcarch.c +++ b/fontconfig/src/fcarch.c @@ -21,10 +21,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#include <stdio.h> - #include "fcint.h" #include "fcarch.h" +#include <stdio.h> FC_ASSERT_STATIC (1 == sizeof (char)); FC_ASSERT_STATIC (2 == sizeof (FcChar16)); diff --git a/fontconfig/src/fcblanks.c b/fontconfig/src/fcblanks.c index 46698bcda..f163a8f40 100644 --- a/fontconfig/src/fcblanks.c +++ b/fontconfig/src/fcblanks.c @@ -41,6 +41,8 @@ FcBlanksCreate (void) void FcBlanksDestroy (FcBlanks *b) { + if (b->sblank == -1) + return; if (b->blanks) free (b->blanks); free (b); @@ -56,6 +58,11 @@ FcBlanksAdd (FcBlanks *b, FcChar32 ucs4) if (b->blanks[sblank] == ucs4) return FcTrue; + if (b->sblank == -1) + { + fprintf (stderr, "Unable to update the static FcBlanks: 0x%04x\n", ucs4); + return FcTrue; + } if (b->nblank == b->sblank) { sblank = b->sblank + 32; @@ -75,11 +82,26 @@ FcBlanksAdd (FcBlanks *b, FcChar32 ucs4) FcBool FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4) { - int i; + int lower = 0, higher = b->nblank, middle; - for (i = 0; i < b->nblank; i++) - if (b->blanks[i] == ucs4) + if (b->nblank == 0 || + b->blanks[0] > ucs4 || + b->blanks[b->nblank - 1] < ucs4) + return FcFalse; + while (1) + { + middle = (lower + higher) / 2; + if (b->blanks[middle] == ucs4) return FcTrue; + if (middle == lower || + middle == higher) + break; + if (b->blanks[middle] < ucs4) + lower = middle + 1; + else + higher = middle - 1; + } + return FcFalse; } #define __fcblanks__ diff --git a/fontconfig/src/fccfg.c b/fontconfig/src/fccfg.c index b27ab0b43..b92270b64 100644 --- a/fontconfig/src/fccfg.c +++ b/fontconfig/src/fccfg.c @@ -27,6 +27,7 @@ #include "fcint.h" #include <dirent.h> #include <sys/types.h> +#include "../fc-blanks/fcblanks.h" #if defined (_WIN32) && !defined (R_OK) #define R_OK 4 @@ -109,7 +110,7 @@ FcConfigCreate (void) if (!config->cacheDirs) goto bail8; - config->blanks = 0; + config->blanks = &fcBlanks; config->substPattern = 0; config->substFont = 0; @@ -1545,7 +1546,9 @@ FcConfigSubstituteWithPat (FcConfig *config, FcStrList *l = FcStrListCreate (strs); FcChar8 *lang; FcValue v; + FcLangSet *lsund = FcLangSetCreate (); + FcLangSetAdd (lsund, (const FcChar8 *)"und"); FcStrSetDestroy (strs); while (l && (lang = FcStrListNext (l))) { @@ -1569,10 +1572,16 @@ FcConfigSubstituteWithPat (FcConfig *config, FcLangSetDestroy (ls); if (b) goto bail_lang; + if (FcLangSetContains (vv.u.l, lsund)) + goto bail_lang; } else + { if (FcStrCmpIgnoreCase (vv.u.s, lang) == 0) goto bail_lang; + if (FcStrCmpIgnoreCase (vv.u.s, (const FcChar8 *)"und") == 0) + goto bail_lang; + } } } v.type = FcTypeString; @@ -1582,6 +1591,7 @@ FcConfigSubstituteWithPat (FcConfig *config, } bail_lang: FcStrListDone (l); + FcLangSetDestroy (lsund); } if (FcPatternObjectGet (p, FC_PRGNAME_OBJECT, 0, &v) == FcResultNoMatch) { diff --git a/fontconfig/src/fcfreetype.c b/fontconfig/src/fcfreetype.c index f42004be7..50ff3489c 100644 --- a/fontconfig/src/fcfreetype.c +++ b/fontconfig/src/fcfreetype.c @@ -1986,283 +1986,17 @@ bail: #warning "No FT_Get_Next_Char: Please install freetype version 2.1.0 or newer" #endif -typedef struct _FcCharEnt { - FcChar16 bmp; - unsigned char encode; -} FcCharEnt; - -struct _FcCharMap { - const FcCharEnt *ent; - int nent; +static const FT_Encoding fcFontEncodings[] = { + FT_ENCODING_UNICODE, + FT_ENCODING_MS_SYMBOL }; -typedef struct _FcFontDecode { - FT_Encoding encoding; - const FcCharMap *map; - FcChar32 max; -} FcFontDecode; - -static const FcCharEnt AdobeSymbolEnt[] = { - { 0x0020, 0x20 }, /* SPACE # space */ - { 0x0021, 0x21 }, /* EXCLAMATION MARK # exclam */ - { 0x0023, 0x23 }, /* NUMBER SIGN # numbersign */ - { 0x0025, 0x25 }, /* PERCENT SIGN # percent */ - { 0x0026, 0x26 }, /* AMPERSAND # ampersand */ - { 0x0028, 0x28 }, /* LEFT PARENTHESIS # parenleft */ - { 0x0029, 0x29 }, /* RIGHT PARENTHESIS # parenright */ - { 0x002B, 0x2B }, /* PLUS SIGN # plus */ - { 0x002C, 0x2C }, /* COMMA # comma */ - { 0x002E, 0x2E }, /* FULL STOP # period */ - { 0x002F, 0x2F }, /* SOLIDUS # slash */ - { 0x0030, 0x30 }, /* DIGIT ZERO # zero */ - { 0x0031, 0x31 }, /* DIGIT ONE # one */ - { 0x0032, 0x32 }, /* DIGIT TWO # two */ - { 0x0033, 0x33 }, /* DIGIT THREE # three */ - { 0x0034, 0x34 }, /* DIGIT FOUR # four */ - { 0x0035, 0x35 }, /* DIGIT FIVE # five */ - { 0x0036, 0x36 }, /* DIGIT SIX # six */ - { 0x0037, 0x37 }, /* DIGIT SEVEN # seven */ - { 0x0038, 0x38 }, /* DIGIT EIGHT # eight */ - { 0x0039, 0x39 }, /* DIGIT NINE # nine */ - { 0x003A, 0x3A }, /* COLON # colon */ - { 0x003B, 0x3B }, /* SEMICOLON # semicolon */ - { 0x003C, 0x3C }, /* LESS-THAN SIGN # less */ - { 0x003D, 0x3D }, /* EQUALS SIGN # equal */ - { 0x003E, 0x3E }, /* GREATER-THAN SIGN # greater */ - { 0x003F, 0x3F }, /* QUESTION MARK # question */ - { 0x005B, 0x5B }, /* LEFT SQUARE BRACKET # bracketleft */ - { 0x005D, 0x5D }, /* RIGHT SQUARE BRACKET # bracketright */ - { 0x005F, 0x5F }, /* LOW LINE # underscore */ - { 0x007B, 0x7B }, /* LEFT CURLY BRACKET # braceleft */ - { 0x007C, 0x7C }, /* VERTICAL LINE # bar */ - { 0x007D, 0x7D }, /* RIGHT CURLY BRACKET # braceright */ - { 0x00A0, 0x20 }, /* NO-BREAK SPACE # space */ - { 0x00AC, 0xD8 }, /* NOT SIGN # logicalnot */ - { 0x00B0, 0xB0 }, /* DEGREE SIGN # degree */ - { 0x00B1, 0xB1 }, /* PLUS-MINUS SIGN # plusminus */ - { 0x00B5, 0x6D }, /* MICRO SIGN # mu */ - { 0x00D7, 0xB4 }, /* MULTIPLICATION SIGN # multiply */ - { 0x00F7, 0xB8 }, /* DIVISION SIGN # divide */ - { 0x0192, 0xA6 }, /* LATIN SMALL LETTER F WITH HOOK # florin */ - { 0x0391, 0x41 }, /* GREEK CAPITAL LETTER ALPHA # Alpha */ - { 0x0392, 0x42 }, /* GREEK CAPITAL LETTER BETA # Beta */ - { 0x0393, 0x47 }, /* GREEK CAPITAL LETTER GAMMA # Gamma */ - { 0x0394, 0x44 }, /* GREEK CAPITAL LETTER DELTA # Delta */ - { 0x0395, 0x45 }, /* GREEK CAPITAL LETTER EPSILON # Epsilon */ - { 0x0396, 0x5A }, /* GREEK CAPITAL LETTER ZETA # Zeta */ - { 0x0397, 0x48 }, /* GREEK CAPITAL LETTER ETA # Eta */ - { 0x0398, 0x51 }, /* GREEK CAPITAL LETTER THETA # Theta */ - { 0x0399, 0x49 }, /* GREEK CAPITAL LETTER IOTA # Iota */ - { 0x039A, 0x4B }, /* GREEK CAPITAL LETTER KAPPA # Kappa */ - { 0x039B, 0x4C }, /* GREEK CAPITAL LETTER LAMDA # Lambda */ - { 0x039C, 0x4D }, /* GREEK CAPITAL LETTER MU # Mu */ - { 0x039D, 0x4E }, /* GREEK CAPITAL LETTER NU # Nu */ - { 0x039E, 0x58 }, /* GREEK CAPITAL LETTER XI # Xi */ - { 0x039F, 0x4F }, /* GREEK CAPITAL LETTER OMICRON # Omicron */ - { 0x03A0, 0x50 }, /* GREEK CAPITAL LETTER PI # Pi */ - { 0x03A1, 0x52 }, /* GREEK CAPITAL LETTER RHO # Rho */ - { 0x03A3, 0x53 }, /* GREEK CAPITAL LETTER SIGMA # Sigma */ - { 0x03A4, 0x54 }, /* GREEK CAPITAL LETTER TAU # Tau */ - { 0x03A5, 0x55 }, /* GREEK CAPITAL LETTER UPSILON # Upsilon */ - { 0x03A6, 0x46 }, /* GREEK CAPITAL LETTER PHI # Phi */ - { 0x03A7, 0x43 }, /* GREEK CAPITAL LETTER CHI # Chi */ - { 0x03A8, 0x59 }, /* GREEK CAPITAL LETTER PSI # Psi */ - { 0x03A9, 0x57 }, /* GREEK CAPITAL LETTER OMEGA # Omega */ - { 0x03B1, 0x61 }, /* GREEK SMALL LETTER ALPHA # alpha */ - { 0x03B2, 0x62 }, /* GREEK SMALL LETTER BETA # beta */ - { 0x03B3, 0x67 }, /* GREEK SMALL LETTER GAMMA # gamma */ - { 0x03B4, 0x64 }, /* GREEK SMALL LETTER DELTA # delta */ - { 0x03B5, 0x65 }, /* GREEK SMALL LETTER EPSILON # epsilon */ - { 0x03B6, 0x7A }, /* GREEK SMALL LETTER ZETA # zeta */ - { 0x03B7, 0x68 }, /* GREEK SMALL LETTER ETA # eta */ - { 0x03B8, 0x71 }, /* GREEK SMALL LETTER THETA # theta */ - { 0x03B9, 0x69 }, /* GREEK SMALL LETTER IOTA # iota */ - { 0x03BA, 0x6B }, /* GREEK SMALL LETTER KAPPA # kappa */ - { 0x03BB, 0x6C }, /* GREEK SMALL LETTER LAMDA # lambda */ - { 0x03BC, 0x6D }, /* GREEK SMALL LETTER MU # mu */ - { 0x03BD, 0x6E }, /* GREEK SMALL LETTER NU # nu */ - { 0x03BE, 0x78 }, /* GREEK SMALL LETTER XI # xi */ - { 0x03BF, 0x6F }, /* GREEK SMALL LETTER OMICRON # omicron */ - { 0x03C0, 0x70 }, /* GREEK SMALL LETTER PI # pi */ - { 0x03C1, 0x72 }, /* GREEK SMALL LETTER RHO # rho */ - { 0x03C2, 0x56 }, /* GREEK SMALL LETTER FINAL SIGMA # sigma1 */ - { 0x03C3, 0x73 }, /* GREEK SMALL LETTER SIGMA # sigma */ - { 0x03C4, 0x74 }, /* GREEK SMALL LETTER TAU # tau */ - { 0x03C5, 0x75 }, /* GREEK SMALL LETTER UPSILON # upsilon */ - { 0x03C6, 0x66 }, /* GREEK SMALL LETTER PHI # phi */ - { 0x03C7, 0x63 }, /* GREEK SMALL LETTER CHI # chi */ - { 0x03C8, 0x79 }, /* GREEK SMALL LETTER PSI # psi */ - { 0x03C9, 0x77 }, /* GREEK SMALL LETTER OMEGA # omega */ - { 0x03D1, 0x4A }, /* GREEK THETA SYMBOL # theta1 */ - { 0x03D2, 0xA1 }, /* GREEK UPSILON WITH HOOK SYMBOL # Upsilon1 */ - { 0x03D5, 0x6A }, /* GREEK PHI SYMBOL # phi1 */ - { 0x03D6, 0x76 }, /* GREEK PI SYMBOL # omega1 */ - { 0x2022, 0xB7 }, /* BULLET # bullet */ - { 0x2026, 0xBC }, /* HORIZONTAL ELLIPSIS # ellipsis */ - { 0x2032, 0xA2 }, /* PRIME # minute */ - { 0x2033, 0xB2 }, /* DOUBLE PRIME # second */ - { 0x2044, 0xA4 }, /* FRACTION SLASH # fraction */ - { 0x20AC, 0xA0 }, /* EURO SIGN # Euro */ - { 0x2111, 0xC1 }, /* BLACK-LETTER CAPITAL I # Ifraktur */ - { 0x2118, 0xC3 }, /* SCRIPT CAPITAL P # weierstrass */ - { 0x211C, 0xC2 }, /* BLACK-LETTER CAPITAL R # Rfraktur */ - { 0x2126, 0x57 }, /* OHM SIGN # Omega */ - { 0x2135, 0xC0 }, /* ALEF SYMBOL # aleph */ - { 0x2190, 0xAC }, /* LEFTWARDS ARROW # arrowleft */ - { 0x2191, 0xAD }, /* UPWARDS ARROW # arrowup */ - { 0x2192, 0xAE }, /* RIGHTWARDS ARROW # arrowright */ - { 0x2193, 0xAF }, /* DOWNWARDS ARROW # arrowdown */ - { 0x2194, 0xAB }, /* LEFT RIGHT ARROW # arrowboth */ - { 0x21B5, 0xBF }, /* DOWNWARDS ARROW WITH CORNER LEFTWARDS # carriagereturn */ - { 0x21D0, 0xDC }, /* LEFTWARDS DOUBLE ARROW # arrowdblleft */ - { 0x21D1, 0xDD }, /* UPWARDS DOUBLE ARROW # arrowdblup */ - { 0x21D2, 0xDE }, /* RIGHTWARDS DOUBLE ARROW # arrowdblright */ - { 0x21D3, 0xDF }, /* DOWNWARDS DOUBLE ARROW # arrowdbldown */ - { 0x21D4, 0xDB }, /* LEFT RIGHT DOUBLE ARROW # arrowdblboth */ - { 0x2200, 0x22 }, /* FOR ALL # universal */ - { 0x2202, 0xB6 }, /* PARTIAL DIFFERENTIAL # partialdiff */ - { 0x2203, 0x24 }, /* THERE EXISTS # existential */ - { 0x2205, 0xC6 }, /* EMPTY SET # emptyset */ - { 0x2206, 0x44 }, /* INCREMENT # Delta */ - { 0x2207, 0xD1 }, /* NABLA # gradient */ - { 0x2208, 0xCE }, /* ELEMENT OF # element */ - { 0x2209, 0xCF }, /* NOT AN ELEMENT OF # notelement */ - { 0x220B, 0x27 }, /* CONTAINS AS MEMBER # suchthat */ - { 0x220F, 0xD5 }, /* N-ARY PRODUCT # product */ - { 0x2211, 0xE5 }, /* N-ARY SUMMATION # summation */ - { 0x2212, 0x2D }, /* MINUS SIGN # minus */ - { 0x2215, 0xA4 }, /* DIVISION SLASH # fraction */ - { 0x2217, 0x2A }, /* ASTERISK OPERATOR # asteriskmath */ - { 0x221A, 0xD6 }, /* SQUARE ROOT # radical */ - { 0x221D, 0xB5 }, /* PROPORTIONAL TO # proportional */ - { 0x221E, 0xA5 }, /* INFINITY # infinity */ - { 0x2220, 0xD0 }, /* ANGLE # angle */ - { 0x2227, 0xD9 }, /* LOGICAL AND # logicaland */ - { 0x2228, 0xDA }, /* LOGICAL OR # logicalor */ - { 0x2229, 0xC7 }, /* INTERSECTION # intersection */ - { 0x222A, 0xC8 }, /* UNION # union */ - { 0x222B, 0xF2 }, /* INTEGRAL # integral */ - { 0x2234, 0x5C }, /* THEREFORE # therefore */ - { 0x223C, 0x7E }, /* TILDE OPERATOR # similar */ - { 0x2245, 0x40 }, /* APPROXIMATELY EQUAL TO # congruent */ - { 0x2248, 0xBB }, /* ALMOST EQUAL TO # approxequal */ - { 0x2260, 0xB9 }, /* NOT EQUAL TO # notequal */ - { 0x2261, 0xBA }, /* IDENTICAL TO # equivalence */ - { 0x2264, 0xA3 }, /* LESS-THAN OR EQUAL TO # lessequal */ - { 0x2265, 0xB3 }, /* GREATER-THAN OR EQUAL TO # greaterequal */ - { 0x2282, 0xCC }, /* SUBSET OF # propersubset */ - { 0x2283, 0xC9 }, /* SUPERSET OF # propersuperset */ - { 0x2284, 0xCB }, /* NOT A SUBSET OF # notsubset */ - { 0x2286, 0xCD }, /* SUBSET OF OR EQUAL TO # reflexsubset */ - { 0x2287, 0xCA }, /* SUPERSET OF OR EQUAL TO # reflexsuperset */ - { 0x2295, 0xC5 }, /* CIRCLED PLUS # circleplus */ - { 0x2297, 0xC4 }, /* CIRCLED TIMES # circlemultiply */ - { 0x22A5, 0x5E }, /* UP TACK # perpendicular */ - { 0x22C5, 0xD7 }, /* DOT OPERATOR # dotmath */ - { 0x2320, 0xF3 }, /* TOP HALF INTEGRAL # integraltp */ - { 0x2321, 0xF5 }, /* BOTTOM HALF INTEGRAL # integralbt */ - { 0x2329, 0xE1 }, /* LEFT-POINTING ANGLE BRACKET # angleleft */ - { 0x232A, 0xF1 }, /* RIGHT-POINTING ANGLE BRACKET # angleright */ - { 0x25CA, 0xE0 }, /* LOZENGE # lozenge */ - { 0x2660, 0xAA }, /* BLACK SPADE SUIT # spade */ - { 0x2663, 0xA7 }, /* BLACK CLUB SUIT # club */ - { 0x2665, 0xA9 }, /* BLACK HEART SUIT # heart */ - { 0x2666, 0xA8 }, /* BLACK DIAMOND SUIT # diamond */ - { 0xF6D9, 0xD3 }, /* COPYRIGHT SIGN SERIF # copyrightserif (CUS) */ - { 0xF6DA, 0xD2 }, /* REGISTERED SIGN SERIF # registerserif (CUS) */ - { 0xF6DB, 0xD4 }, /* TRADE MARK SIGN SERIF # trademarkserif (CUS) */ - { 0xF8E5, 0x60 }, /* RADICAL EXTENDER # radicalex (CUS) */ - { 0xF8E6, 0xBD }, /* VERTICAL ARROW EXTENDER # arrowvertex (CUS) */ - { 0xF8E7, 0xBE }, /* HORIZONTAL ARROW EXTENDER # arrowhorizex (CUS) */ - { 0xF8E8, 0xE2 }, /* REGISTERED SIGN SANS SERIF # registersans (CUS) */ - { 0xF8E9, 0xE3 }, /* COPYRIGHT SIGN SANS SERIF # copyrightsans (CUS) */ - { 0xF8EA, 0xE4 }, /* TRADE MARK SIGN SANS SERIF # trademarksans (CUS) */ - { 0xF8EB, 0xE6 }, /* LEFT PAREN TOP # parenlefttp (CUS) */ - { 0xF8EC, 0xE7 }, /* LEFT PAREN EXTENDER # parenleftex (CUS) */ - { 0xF8ED, 0xE8 }, /* LEFT PAREN BOTTOM # parenleftbt (CUS) */ - { 0xF8EE, 0xE9 }, /* LEFT SQUARE BRACKET TOP # bracketlefttp (CUS) */ - { 0xF8EF, 0xEA }, /* LEFT SQUARE BRACKET EXTENDER # bracketleftex (CUS) */ - { 0xF8F0, 0xEB }, /* LEFT SQUARE BRACKET BOTTOM # bracketleftbt (CUS) */ - { 0xF8F1, 0xEC }, /* LEFT CURLY BRACKET TOP # bracelefttp (CUS) */ - { 0xF8F2, 0xED }, /* LEFT CURLY BRACKET MID # braceleftmid (CUS) */ - { 0xF8F3, 0xEE }, /* LEFT CURLY BRACKET BOTTOM # braceleftbt (CUS) */ - { 0xF8F4, 0xEF }, /* CURLY BRACKET EXTENDER # braceex (CUS) */ - { 0xF8F5, 0xF4 }, /* INTEGRAL EXTENDER # integralex (CUS) */ - { 0xF8F6, 0xF6 }, /* RIGHT PAREN TOP # parenrighttp (CUS) */ - { 0xF8F7, 0xF7 }, /* RIGHT PAREN EXTENDER # parenrightex (CUS) */ - { 0xF8F8, 0xF8 }, /* RIGHT PAREN BOTTOM # parenrightbt (CUS) */ - { 0xF8F9, 0xF9 }, /* RIGHT SQUARE BRACKET TOP # bracketrighttp (CUS) */ - { 0xF8FA, 0xFA }, /* RIGHT SQUARE BRACKET EXTENDER # bracketrightex (CUS) */ - { 0xF8FB, 0xFB }, /* RIGHT SQUARE BRACKET BOTTOM # bracketrightbt (CUS) */ - { 0xF8FC, 0xFC }, /* RIGHT CURLY BRACKET TOP # bracerighttp (CUS) */ - { 0xF8FD, 0xFD }, /* RIGHT CURLY BRACKET MID # bracerightmid (CUS) */ - { 0xF8FE, 0xFE }, /* RIGHT CURLY BRACKET BOTTOM # bracerightbt (CUS) */ -}; - -static const FcCharMap AdobeSymbol = { - AdobeSymbolEnt, - sizeof (AdobeSymbolEnt) / sizeof (AdobeSymbolEnt[0]), -}; - -static const FcFontDecode fcFontDecoders[] = { - { ft_encoding_unicode, 0, (1 << 21) - 1 }, - { ft_encoding_symbol, 0, (1 << 16) - 1 }, -}; - -#define NUM_DECODE (int) (sizeof (fcFontDecoders) / sizeof (fcFontDecoders[0])) +#define NUM_DECODE (int) (sizeof (fcFontEncodings) / sizeof (fcFontEncodings[0])) static const FcChar32 prefer_unicode[] = { 0x20ac, /* EURO SIGN */ }; -#define NUM_PREFER_UNICODE (int) (sizeof (prefer_unicode) / sizeof (prefer_unicode[0])) - -FcChar32 -FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map) -{ - int low, high, mid; - FcChar16 bmp; - - low = 0; - high = map->nent - 1; - if (ucs4 < map->ent[low].bmp || map->ent[high].bmp < ucs4) - return ~0; - while (low <= high) - { - mid = (high + low) >> 1; - bmp = map->ent[mid].bmp; - if (ucs4 == bmp) - return (FT_ULong) map->ent[mid].encode; - if (ucs4 < bmp) - high = mid - 1; - else - low = mid + 1; - } - return ~0; -} - -FcChar32 -FcFreeTypePrivateToUcs4 (FcChar32 private, const FcCharMap *map) -{ - int i; - - for (i = 0; i < map->nent; i++) - if (map->ent[i].encode == private) - return (FcChar32) map->ent[i].bmp; - return ~0; -} - -const FcCharMap * -FcFreeTypeGetPrivateMap (FT_Encoding encoding) -{ - int i; - - for (i = 0; i < NUM_DECODE; i++) - if (fcFontDecoders[i].encoding == encoding) - return fcFontDecoders[i].map; - return 0; -} - #include "../fc-glyphname/fcglyphname.h" static FcChar32 @@ -2390,8 +2124,6 @@ FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4) { int initial, offset, decode; FT_UInt glyphindex; - FcChar32 charcode; - int p; initial = 0; @@ -2404,35 +2136,21 @@ FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4) if (face->charmap) { for (; initial < NUM_DECODE; initial++) - if (fcFontDecoders[initial].encoding == face->charmap->encoding) + if (fcFontEncodings[initial] == face->charmap->encoding) break; if (initial == NUM_DECODE) initial = 0; } - for (p = 0; p < NUM_PREFER_UNICODE; p++) - if (ucs4 == prefer_unicode[p]) - { - initial = 0; - break; - } /* * Check each encoding for the glyph, starting with the current one */ for (offset = 0; offset < NUM_DECODE; offset++) { decode = (initial + offset) % NUM_DECODE; - if (!face->charmap || face->charmap->encoding != fcFontDecoders[decode].encoding) - if (FT_Select_Charmap (face, fcFontDecoders[decode].encoding) != 0) - continue; - if (fcFontDecoders[decode].map) - { - charcode = FcFreeTypeUcs4ToPrivate (ucs4, fcFontDecoders[decode].map); - if (charcode == ~0U) + if (!face->charmap || face->charmap->encoding != fcFontEncodings[decode]) + if (FT_Select_Charmap (face, fcFontEncodings[decode]) != 0) continue; - } - else - charcode = ucs4; - glyphindex = FT_Get_Char_Index (face, (FT_ULong) charcode); + glyphindex = FT_Get_Char_Index (face, (FT_ULong) ucs4); if (glyphindex) return glyphindex; } @@ -2525,9 +2243,7 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face, FcBlanks *blanks, int *spacing #endif FcCharSet *fcs; FcCharLeaf *leaf; - const FcCharMap *map; int o; - int i; FT_UInt glyph; FT_Pos advance, advance_one = 0, advance_two = 0; FcBool has_advance = FcFalse, fixed_advance = FcTrue, dual_advance = FcFalse; @@ -2550,62 +2266,9 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face, FcBlanks *blanks, int *spacing #endif for (o = 0; o < NUM_DECODE; o++) { - if (FT_Select_Charmap (face, fcFontDecoders[o].encoding) != 0) + if (FT_Select_Charmap (face, fcFontEncodings[o]) != 0) continue; - map = fcFontDecoders[o].map; - if (map) - { - /* - * Non-Unicode tables are easy; there's a list of all possible - * characters - */ - for (i = 0; i < map->nent; i++) - { - ucs4 = map->ent[i].bmp; - glyph = FT_Get_Char_Index (face, map->ent[i].encode); - if (glyph && - FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance, using_strike)) - { - /* - * ignore glyphs with zero advance. They’re - * combining characters, and while their behaviour - * isn’t well defined for monospaced applications in - * Unicode, there are many fonts which include - * zero-width combining characters in otherwise - * monospaced fonts. - */ - if (advance) - { - if (!has_advance) - { - has_advance = FcTrue; - advance_one = advance; - } - else if (!APPROXIMATELY_EQUAL (advance, advance_one)) - { - if (fixed_advance) - { - dual_advance = FcTrue; - fixed_advance = FcFalse; - advance_two = advance; - } - else if (!APPROXIMATELY_EQUAL (advance, advance_two)) - dual_advance = FcFalse; - } - } - leaf = FcCharSetFindLeafCreate (fcs, ucs4); - if (!leaf) - goto bail1; - leaf->map[(ucs4 & 0xff) >> 5] |= (1 << (ucs4 & 0x1f)); -#ifdef CHECK - if (ucs4 > font_max) - font_max = ucs4; -#endif - } - } - } - else { page = ~0; leaf = NULL; diff --git a/fontconfig/src/fclist.c b/fontconfig/src/fclist.c index 6ad297ca4..d7e8fc091 100644 --- a/fontconfig/src/fclist.c +++ b/fontconfig/src/fclist.c @@ -270,7 +270,7 @@ FcListValueHash (FcValue *value) case FcTypeCharSet: return FcCharSetCount (v.u.c); case FcTypeFTFace: - return (long) v.u.f; + return (intptr_t) v.u.f; case FcTypeLangSet: return FcLangSetHash (v.u.l); case FcTypeRange: diff --git a/fontconfig/src/fcstat.c b/fontconfig/src/fcstat.c index bbae10216..1734fa423 100644 --- a/fontconfig/src/fcstat.c +++ b/fontconfig/src/fcstat.c @@ -42,6 +42,7 @@ #ifdef HAVE_SYS_MOUNT_H #include <sys/mount.h> #endif +#include <errno.h> #ifdef _WIN32 #ifdef __GNUC__ @@ -164,21 +165,86 @@ FcDirChecksumScandirFilter(const struct dirent *entry) } #endif -#ifdef HAVE_SCANDIR static int FcDirChecksumScandirSorter(const struct dirent **lhs, const struct dirent **rhs) { return strcmp((*lhs)->d_name, (*rhs)->d_name); } -#elif HAVE_SCANDIR_VOID_P -static int -FcDirChecksumScandirSorter(const void *a, const void *b) + +static void +free_dirent (struct dirent **p) { - const struct dirent *lhs = a, *rhs = b; + struct dirent **x; + + for (x = p; *x != NULL; x++) + free (*x); - return strcmp(lhs->d_name, rhs->d_name); + free (p); +} + +int +FcScandir (const char *dirp, + struct dirent ***namelist, + int (*filter) (const struct dirent *), + int (*compar) (const struct dirent **, const struct dirent **)); + +int +FcScandir (const char *dirp, + struct dirent ***namelist, + int (*filter) (const struct dirent *), + int (*compar) (const struct dirent **, const struct dirent **)) +{ + DIR *d; + struct dirent *dent, *p, **dlist, **dlp; + size_t lsize = 128, n = 0; + + d = opendir (dirp); + if (!d) + return -1; + + dlist = (struct dirent **) malloc (sizeof (struct dirent *) * lsize); + if (!dlist) + { + closedir (d); + errno = ENOMEM; + + return -1; + } + *dlist = NULL; + while ((dent = readdir (d))) + { + if (!filter || (filter) (dent)) + { + size_t dentlen = FcPtrToOffset (dent, dent->d_name) + strlen (dent->d_name) + 1; + dentlen = ((dentlen + ALIGNOF_VOID_P - 1) & ~(ALIGNOF_VOID_P - 1)); + p = (struct dirent *) malloc (dentlen); + memcpy (p, dent, dentlen); + if ((n + 1) >= lsize) + { + lsize += 128; + dlp = (struct dirent **) realloc (dlist, sizeof (struct dirent *) * lsize); + if (!dlp) + { + free_dirent (dlist); + closedir (d); + errno = ENOMEM; + + return -1; + } + dlist = dlp; + } + dlist[n++] = p; + dlist[n] = NULL; + } + } + closedir (d); + + qsort (dlist, n, sizeof (struct dirent *), (int (*) (const void *, const void *))compar); + + *namelist = dlist; + + return n; } -#endif static int FcDirChecksum (const FcChar8 *dir, time_t *checksum) @@ -191,7 +257,7 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum) Adler32Init (&ctx); - n = scandir ((const char *)dir, &files, + n = FcScandir ((const char *)dir, &files, #ifdef HAVE_STRUCT_DIRENT_D_TYPE &FcDirChecksumScandirFilter, #else diff --git a/fontconfig/src/fcxml.c b/fontconfig/src/fcxml.c index 29dd4d654..cdb14b67c 100644 --- a/fontconfig/src/fcxml.c +++ b/fontconfig/src/fcxml.c @@ -2249,7 +2249,9 @@ FcParseInclude (FcConfigParse *parse) FcChar8 *s; const FcChar8 *attr; FcBool ignore_missing = FcFalse; +#ifndef _WIN32 FcBool deprecated = FcFalse; +#endif FcChar8 *prefix = NULL, *p; static FcChar8 *userdir = NULL; static FcChar8 *userconf = NULL; @@ -2263,9 +2265,11 @@ FcParseInclude (FcConfigParse *parse) attr = FcConfigGetAttribute (parse, "ignore_missing"); if (attr && FcConfigLexBool (parse, (FcChar8 *) attr) == FcTrue) ignore_missing = FcTrue; +#ifndef _WIN32 attr = FcConfigGetAttribute (parse, "deprecated"); if (attr && FcConfigLexBool (parse, (FcChar8 *) attr) == FcTrue) deprecated = FcTrue; +#endif attr = FcConfigGetAttribute (parse, "prefix"); if (attr && FcStrCmp (attr, (const FcChar8 *)"xdg") == 0) { diff --git a/mesalib/configure.ac b/mesalib/configure.ac index 5fbb7bc31..ad64df012 100644 --- a/mesalib/configure.ac +++ b/mesalib/configure.ac @@ -263,6 +263,18 @@ if test "x$GCC" = xyes; then # gcc's builtin memcmp is slower than glibc's # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052 CFLAGS="$CFLAGS -fno-builtin-memcmp" + + # Flags to help ensure that certain portions of the code -- and only those + # portions -- can be built with MSVC: + # - src/util, src/gallium/auxiliary, and src/gallium/drivers/llvmpipe needs + # to build with Windows SDK 7.0.7600, which bundles MSVC 2008 + # - non-Linux/Posix OpenGL portions needs to build on MSVC 2013 (which + # supports most of C99) + # - the rest has no compiler compiler restrictions + MSVC2013_COMPAT_CFLAGS="-Werror=vla -Werror=pointer-arith" + MSVC2013_COMPAT_CXXFLAGS="-Werror=vla -Werror=pointer-arith" + MSVC2008_COMPAT_CFLAGS="$MSVC2013_COMPAT_CFLAGS -Werror=declaration-after-statement" + MSVC2008_COMPAT_CXXFLAGS="$MSVC2013_COMPAT_CXXFLAGS" fi if test "x$GXX" = xyes; then CXXFLAGS="$CXXFLAGS -Wall" @@ -288,6 +300,11 @@ if test "x$GXX" = xyes; then CXXFLAGS="$CXXFLAGS -fno-builtin-memcmp" fi +AC_SUBST([MSVC2013_COMPAT_CFLAGS]) +AC_SUBST([MSVC2013_COMPAT_CXXFLAGS]) +AC_SUBST([MSVC2008_COMPAT_CFLAGS]) +AC_SUBST([MSVC2008_COMPAT_CXXFLAGS]) + dnl even if the compiler appears to support it, using visibility attributes isn't dnl going to do anything useful currently on cygwin apart from emit lots of warnings case "$host_os" in @@ -675,11 +692,6 @@ AC_ARG_ENABLE([gles2], [enable support for OpenGL ES 2.x API @<:@default=disabled@:>@])], [enable_gles2="$enableval"], [enable_gles2=no]) -AC_ARG_ENABLE([openvg], - [AS_HELP_STRING([--enable-openvg], - [enable support for OpenVG API @<:@default=disabled@:>@])], - [enable_openvg="$enableval"], - [enable_openvg=no]) AC_ARG_ENABLE([dri], [AS_HELP_STRING([--enable-dri], @@ -810,7 +822,6 @@ if test "x$enable_opengl" = xno -a \ "x$enable_gles1" = xno -a \ "x$enable_gles2" = xno -a \ "x$enable_nine" = xno -a \ - "x$enable_openvg" = xno -a \ "x$enable_xa" = xno -a \ "x$enable_xvmc" = xno -a \ "x$enable_vdpau" = xno -a \ @@ -1531,29 +1542,6 @@ fi AM_CONDITIONAL(HAVE_ST_XA, test "x$enable_xa" = xyes) dnl -dnl OpenVG configuration -dnl -VG_LIB_DEPS="" - -if test "x$enable_openvg" = xyes; then - if test "x$enable_egl" = xno; then - AC_MSG_ERROR([cannot enable OpenVG without EGL]) - fi - if test -z "$with_gallium_drivers"; then - AC_MSG_ERROR([cannot enable OpenVG without Gallium]) - fi - - AC_MSG_ERROR([Cannot enable OpenVG, because egl_gallium has been removed and - OpenVG has not been integrated into standard libEGL yet]) - - EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(VG_LIB)' - VG_LIB_DEPS="$VG_LIB_DEPS $SELINUX_LIBS $PTHREAD_LIBS" - VG_PC_LIB_PRIV="-lm $CLOCK_LIB $PTHREAD_LIBS $DLOPEN_LIBS" - AC_SUBST([VG_PC_LIB_PRIV]) -fi -AM_CONDITIONAL(HAVE_OPENVG, test "x$enable_openvg" = xyes) - -dnl dnl Gallium G3DVL configuration dnl if test -n "$with_gallium_drivers" -a "x$with_gallium_drivers" != xswrast; then @@ -2361,7 +2349,6 @@ AC_CONFIG_FILES([Makefile src/gallium/drivers/freedreno/Makefile src/gallium/drivers/galahad/Makefile src/gallium/drivers/i915/Makefile - src/gallium/drivers/identity/Makefile src/gallium/drivers/ilo/Makefile src/gallium/drivers/llvmpipe/Makefile src/gallium/drivers/noop/Makefile @@ -2384,7 +2371,6 @@ AC_CONFIG_FILES([Makefile src/gallium/state_trackers/osmesa/Makefile src/gallium/state_trackers/va/Makefile src/gallium/state_trackers/vdpau/Makefile - src/gallium/state_trackers/vega/Makefile src/gallium/state_trackers/xa/Makefile src/gallium/state_trackers/xvmc/Makefile src/gallium/targets/d3dadapter9/Makefile @@ -2462,7 +2448,6 @@ echo " includedir: $includedir" dnl API info echo "" echo " OpenGL: $enable_opengl (ES1: $enable_gles1 ES2: $enable_gles2)" -echo " OpenVG: $enable_openvg" dnl Driver info echo "" diff --git a/mesalib/docs/GL3.txt b/mesalib/docs/GL3.txt index a5b817545..43bbf854e 100644 --- a/mesalib/docs/GL3.txt +++ b/mesalib/docs/GL3.txt @@ -95,7 +95,7 @@ GL 3.3, GLSL 3.30 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe, soft GL 4.0, GLSL 4.00: GL_ARB_draw_buffers_blend DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe) - GL_ARB_draw_indirect DONE (i965, nvc0, radeonsi, llvmpipe, softpipe) + GL_ARB_draw_indirect DONE (i965, nvc0, r600, radeonsi, llvmpipe, softpipe) GL_ARB_gpu_shader5 DONE (i965, nvc0) - 'precise' qualifier DONE - Dynamically uniform sampler array indices DONE (r600) @@ -159,7 +159,7 @@ GL 4.3, GLSL 4.30: GL_ARB_framebuffer_no_attachments not started GL_ARB_internalformat_query2 not started GL_ARB_invalidate_subdata DONE (all drivers) - GL_ARB_multi_draw_indirect DONE (i965, nvc0, radeonsi, llvmpipe, softpipe) + GL_ARB_multi_draw_indirect DONE (i965, nvc0, r600, radeonsi, llvmpipe, softpipe) GL_ARB_program_interface_query not started GL_ARB_robust_buffer_access_behavior not started GL_ARB_shader_image_size not started @@ -212,7 +212,7 @@ These are the extensions cherry-picked to make GLES 3.1 GLES3.1, GLSL ES 3.1 GL_ARB_arrays_of_arrays started (Timothy) GL_ARB_compute_shader in progress (jljusten) - GL_ARB_draw_indirect DONE (i965, nvc0, radeonsi, llvmpipe, softpipe) + GL_ARB_draw_indirect DONE (i965, nvc0, r600, radeonsi, llvmpipe, softpipe) GL_ARB_explicit_uniform_location DONE (all drivers that support GLSL) GL_ARB_framebuffer_no_attachments not started GL_ARB_program_interface_query not started diff --git a/mesalib/docs/README.WIN32 b/mesalib/docs/README.WIN32 index c8759f65b..e0e5b9b2d 100644 --- a/mesalib/docs/README.WIN32 +++ b/mesalib/docs/README.WIN32 @@ -11,9 +11,9 @@ no longer shipped or supported. Run - scons osmesa mesagdi + scons osmesa -to build classic mesa Windows GDI drivers; or +to build classic osmesa driver; or scons libgl-gdi diff --git a/mesalib/docs/contents.html b/mesalib/docs/contents.html index 50c0d5913..6612cbefa 100644 --- a/mesalib/docs/contents.html +++ b/mesalib/docs/contents.html @@ -61,7 +61,6 @@ <li><a href="shading.html" target="_parent">Shading Language</a> <li><a href="egl.html" target="_parent">EGL</a> <li><a href="opengles.html" target="_parent">OpenGL ES</a> -<li><a href="openvg.html" target="_parent">OpenVG / Vega</a> <li><a href="envvars.html" target="_parent">Environment Variables</a> <li><a href="osmesa.html" target="_parent">Off-Screen Rendering</a> <li><a href="debugging.html" target="_parent">Debugging Tips</a> diff --git a/mesalib/docs/egl.html b/mesalib/docs/egl.html index e77c2359d..a715a3ad3 100644 --- a/mesalib/docs/egl.html +++ b/mesalib/docs/egl.html @@ -112,13 +112,6 @@ is required if applications mix OpenGL and OpenGL ES.</p> </dd> -<dt><code>--enable-openvg</code></dt> -<dd> - -<p>OpenVG must be explicitly enabled by this option.</p> - -</dd> - </dl> <h2>Use EGL</h2> @@ -212,38 +205,15 @@ the X server directly using (XCB-)DRI2 protocol.</p> </dd> -<dt><code>egl_gallium</code></dt> -<dd> - -<p>This driver is based on Gallium3D. It supports all rendering APIs and -hardware supported by Gallium3D. It is the only driver that supports OpenVG. -The supported platforms are X11, DRM, FBDEV, and GDI.</p> - -<p>This driver comes with its own hardware drivers -(<code>pipe_<hw></code>) and client API modules -(<code>st_<api></code>).</p> - -</dd> - <h2>Packaging</h2> <p>The ABI between the main library and its drivers are not stable. Nor is -there a plan to stabilize it at the moment. Of the EGL drivers, -<code>egl_gallium</code> has its own hardware drivers and client API modules. -They are considered internal to <code>egl_gallium</code> and there is also no -stable ABI between them. These should be kept in mind when packaging for -distribution.</p> - -<p>Generally, <code>egl_dri2</code> is preferred over <code>egl_gallium</code> -when the system already has DRI drivers. As <code>egl_gallium</code> is loaded -before <code>egl_dri2</code> when both are available, <code>egl_gallium</code> -is disabled by default.</p> +there a plan to stabilize it at the moment.</p> <h2>Developers</h2> -<p>The sources of the main library and the classic drivers can be found at -<code>src/egl/</code>. The sources of the <code>egl</code> state tracker can -be found at <code>src/gallium/state_trackers/egl/</code>.</p> +<p>The sources of the main library and drivers can be found at +<code>src/egl/</code>.</p> <h3>Lifetime of Display Resources</h3> diff --git a/mesalib/docs/index.html b/mesalib/docs/index.html index 15306cebc..9b72bc1f2 100644 --- a/mesalib/docs/index.html +++ b/mesalib/docs/index.html @@ -16,6 +16,12 @@ <h1>News</h1> +<h2>February 21, 2015</h2> +<p> +<a href="relnotes/10.4.5.html">Mesa 10.4.5</a> is released. +This is a bug-fix release. +</p> + <h2>February 06, 2015</h2> <p> <a href="relnotes/10.4.4.html">Mesa 10.4.4</a> is released. diff --git a/mesalib/docs/install.html b/mesalib/docs/install.html index b12e1cb8c..9dbfce58b 100644 --- a/mesalib/docs/install.html +++ b/mesalib/docs/install.html @@ -127,14 +127,13 @@ by -debug for debug builds. To build Mesa with SCons for Windows on Linux using the MinGW crosscompiler toolchain do </p> <pre> - scons platform=windows toolchain=crossmingw machine=x86 mesagdi libgl-gdi + scons platform=windows toolchain=crossmingw machine=x86 libgl-gdi </pre> <p> This will create: </p> <ul> -<li>build/windows-x86-debug/mesa/drivers/windows/gdi/opengl32.dll — Mesa + swrast, binary compatible with Windows's opengl32.dll -<li>build/windows-x86-debug/gallium/targets/libgl-gdi/opengl32.dll — Mesa + Gallium + softpipe, binary compatible with Windows's opengl32.dll +<li>build/windows-x86-debug/gallium/targets/libgl-gdi/opengl32.dll — Mesa + Gallium + softpipe (or llvmpipe), binary compatible with Windows's opengl32.dll </ul> <p> Put them all in the same directory to test them. diff --git a/mesalib/docs/openvg.html b/mesalib/docs/openvg.html deleted file mode 100644 index 28ebb82e8..000000000 --- a/mesalib/docs/openvg.html +++ /dev/null @@ -1,59 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<html lang="en"> -<head> - <meta http-equiv="content-type" content="text/html; charset=utf-8"> - <title>OpenVG State Tracker</title> - <link rel="stylesheet" type="text/css" href="mesa.css"> -</head> -<body> - -<div class="header"> - <h1>The Mesa 3D Graphics Library</h1> -</div> - -<iframe src="contents.html"></iframe> -<div class="content"> - -<h1>OpenVG State Tracker</h1> - -<p> -The current version of the OpenVG state tracker implements OpenVG 1.1. -</p> -<p> -More information about OpenVG can be found at -<a href="http://www.khronos.org/openvg/"> -http://www.khronos.org/openvg/</a> . -</p> -<p> -The OpenVG state tracker depends on the Gallium architecture and a working EGL implementation. -Please refer to <a href="egl.html">Mesa EGL</a> for more information about EGL. -</p> - - -<h2>Building the library</h2> -<ol> -<li>Run <code>configure</code> with <code>--enable-openvg</code> and -<code>--enable-gallium-egl</code>. If you do not need OpenGL, you can add -<code>--disable-opengl</code> to save the compilation time.</li> - -<li>Build and install Mesa as usual.</li> -</ol> - -<h3>Sample build</h3> -A sample build looks as follows: -<pre> - $ ./configure --disable-opengl --enable-openvg --enable-gallium-egl - $ make - $ make install -</pre> - -<p>It will install <code>libOpenVG.so</code>, <code>libEGL.so</code>, and one -or more EGL drivers.</p> - -<h2>OpenVG Demos</h2> - -<p>OpenVG demos can be found in mesa/demos repository.</p> - -</div> -</body> -</html> diff --git a/mesalib/docs/relnotes.html b/mesalib/docs/relnotes.html index 005391974..d4ba11005 100644 --- a/mesalib/docs/relnotes.html +++ b/mesalib/docs/relnotes.html @@ -21,6 +21,7 @@ The release notes summarize what's new or changed in each Mesa release. </p> <ul> +<li><a href="relnotes/10.4.5.html">10.4.5 release notes</a> <li><a href="relnotes/10.4.4.html">10.4.4 release notes</a> <li><a href="relnotes/10.4.3.html">10.4.3 release notes</a> <li><a href="relnotes/10.4.2.html">10.4.2 release notes</a> diff --git a/mesalib/docs/relnotes/10.4.5.html b/mesalib/docs/relnotes/10.4.5.html new file mode 100644 index 000000000..0a0a22ba6 --- /dev/null +++ b/mesalib/docs/relnotes/10.4.5.html @@ -0,0 +1,114 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> +<head> + <meta http-equiv="content-type" content="text/html; charset=utf-8"> + <title>Mesa Release Notes</title> + <link rel="stylesheet" type="text/css" href="../mesa.css"> +</head> +<body> + +<div class="header"> + <h1>The Mesa 3D Graphics Library</h1> +</div> + +<iframe src="../contents.html"></iframe> +<div class="content"> + +<h1>Mesa 10.4.5 Release Notes / February 21, 2015</h1> + +<p> +Mesa 10.4.5 is a bug fix release which fixes bugs found since the 10.4.4 release. +</p> +<p> +Mesa 10.4.5 implements the OpenGL 3.3 API, but the version reported by +glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) / +glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used. +Some drivers don't support all the features required in OpenGL 3.3. OpenGL +3.3 is <strong>only</strong> available if requested at context creation +because compatibility contexts are not supported. +</p> + +<h2>SHA256 checksums</h2> +<pre> +e12bbdaee9a758617e8ebd0bb0e987f72addd11db2e4da25ba695e386cd63843 MesaLib-10.4.5.tar.gz +bf60000700a9d58e3aca2bfeee7e781053b0d839e61a95b1883e05a2dee247a0 MesaLib-10.4.5.tar.bz2 +3b926de8eee500bb67cf85332c51292f826cc539b8636382aadbb8e70c76527a MesaLib-10.4.5.zip +</pre> + +<h2>New features</h2> +<p>None</p> + +<h2>Bug fixes</h2> + +<p>This list is likely incomplete.</p> + +<ul> + +<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=82477">Bug 82477</a> - [softpipe] piglit fp-long-alu regression</li> + +<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=88658">Bug 88658</a> - (bisected) Slow video playback on Kabini</li> + +<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=89069">Bug 89069</a> - Lack of grass in The Talos Principle on radeonsi (native\wine\nine)</li> + +</ul> + + +<h2>Changes</h2> + +<p>Carl Worth (1):</p> +<ul> + <li>Revert use of Mesa IR optimizer for ARB_fragment_programs</li> +</ul> + +<p>Emil Velikov (3):</p> +<ul> + <li>docs: Add sha256 sums for the 10.4.4 release</li> + <li>get-pick-list.sh: Require explicit "10.4" for nominating stable patches</li> + <li>Update version to 10.4.5</li> +</ul> + +<p>Ilia Mirkin (3):</p> +<ul> + <li>nvc0: bail out of 2d blits with non-A8_UNORM alpha formats</li> + <li>st/mesa: treat resource-less xfb buffers as if they weren't there</li> + <li>nvc0: allow holes in xfb target lists</li> +</ul> + +<p>Jeremy Huddleston Sequoia (2):</p> +<ul> + <li>darwin: build fix</li> + <li>darwin: build fix</li> +</ul> + +<p>Kenneth Graunke (4):</p> +<ul> + <li>i965: Override swizzles for integer luminance formats.</li> + <li>i965: Use a gl_color_union for sampler border color.</li> + <li>i965: Fix integer border color on Haswell.</li> + <li>glsl: Reduce memory consumption of copy propagation passes.</li> +</ul> + +<p>Laura Ekstrand (1):</p> +<ul> + <li>main: Fixed _mesa_GetCompressedTexImage_sw to copy slices correctly.</li> +</ul> + +<p>Marek Olšák (5):</p> +<ul> + <li>r600g,radeonsi: don't append to streamout buffers that haven't been used yet</li> + <li>radeonsi: fix instanced arrays with non-zero start instance</li> + <li>radeonsi: small fix in SPI state</li> + <li>mesa: fix AtomicBuffer typo in _mesa_DeleteBuffers</li> + <li>radeonsi: fix a crash if a stencil ref state is set before a DSA state</li> +</ul> + +<p>Michel Dänzer (2):</p> +<ul> + <li>st/mesa: Don't use PIPE_USAGE_STREAM for GL_PIXEL_UNPACK_BUFFER_ARB</li> + <li>Revert "radeon/llvm: enable unsafe math for graphics shaders"</li> +</ul> + + +</div> +</body> +</html> diff --git a/mesalib/docs/relnotes/10.6.0.html b/mesalib/docs/relnotes/10.6.0.html index 056d3b00d..a396109bb 100644 --- a/mesalib/docs/relnotes/10.6.0.html +++ b/mesalib/docs/relnotes/10.6.0.html @@ -49,6 +49,7 @@ Note: some of the new features are only available with certain drivers. <li>GL_ARB_gpu_shader_fp64 on nvc0, softpipe</li> <li>GL_ARB_instanced_arrays on freedreno</li> <li>GL_ARB_pipeline_statistics_query on i965, nv50, nvc0, r600, radeonsi, softpipe</li> +<li>GL_ARB_draw_indirect, GL_ARB_multi_draw_indirect on r600</li> </ul> <h2>Bug fixes</h2> @@ -57,7 +58,11 @@ TBD. <h2>Changes</h2> -TBD. +<ul> +<li>Removed classic Windows software rasterizer.</li> +<li>Removed egl_gallium EGL driver.</li> +<li>Removed OpenVG support.</li> +</ul> </div> </body> diff --git a/mesalib/docs/relnotes/7.6.html b/mesalib/docs/relnotes/7.6.html index 86ad4a848..c6eba1d2e 100644 --- a/mesalib/docs/relnotes/7.6.html +++ b/mesalib/docs/relnotes/7.6.html @@ -48,7 +48,7 @@ c49c19c2bbef4f3b7f1389974dff25f4 MesaGLUT-7.6.zip <h2>New features</h2> <ul> -<li><a href="../openvg.html">OpenVG</a> front-end (state tracker for Gallium). +<li>OpenVG front-end (state tracker for Gallium). This was written by Zack Rusin at Tungsten Graphics. <li>GL_ARB_vertex_array_object and GL_APPLE_vertex_array_object extensions (supported in Gallium drivers, Intel DRI drivers, and software drivers)</li> diff --git a/mesalib/docs/sourcetree.html b/mesalib/docs/sourcetree.html index 4c93f6341..0765778f1 100644 --- a/mesalib/docs/sourcetree.html +++ b/mesalib/docs/sourcetree.html @@ -133,10 +133,8 @@ each directory. <ul> <li><b>clover</b> - OpenCL state tracker <li><b>dri</b> - Meta state tracker for DRI drivers - <li><b>egl</b> - Meta state tracker for EGL drivers <li><b>glx</b> - Meta state tracker for GLX <li><b>vdpau</b> - VDPAU state tracker - <li><b>vega</b> - OpenVG 1.x state tracker <li><b>wgl</b> - <li><b>xorg</b> - Meta state tracker for Xorg video drivers <li><b>xvmc</b> - XvMC state tracker diff --git a/mesalib/include/GL/wmesa.h b/mesalib/include/GL/wmesa.h deleted file mode 100644 index 03d2383d3..000000000 --- a/mesalib/include/GL/wmesa.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Mesa 3-D graphics library - * Copyright (C) 1995-1998 Brian Paul - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - - -/* - * Windows driver by: Mark E. Peterson (markp@ic.mankato.mn.us) - * Updated by Li Wei (liwei@aiar.xjtu.edu.cn) - * - * - *************************************************************** - * WMesa * - * version 2.3 * - * * - * By * - * Li Wei * - * Institute of Artificial Intelligence & Robotics * - * Xi'an Jiaotong University * - * Email: liwei@aiar.xjtu.edu.cn * - * Web page: http://sun.aiar.xjtu.edu.cn * - * * - * July 7th, 1997 * - *************************************************************** - */ - - -#ifndef WMESA_H -#define WMESA_H - - -#ifdef __cplusplus -extern "C" { -#endif - - -#include "GL/gl.h" - -#if defined(_MSV_VER) && !defined(__GNUC__) -# pragma warning (disable:4273) -# pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */ -# pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */ -# pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */ -# pragma warning( disable : 4013 ) /* 'function' undefined; assuming extern returning int */ -# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */ -# pragma warning( disable : 4273 ) /* 'identifier' : inconsistent DLL linkage. dllexport assumed */ -# if (MESA_WARNQUIET>1) -# pragma warning( disable : 4146 ) /* unary minus operator applied to unsigned type, result still unsigned */ -# endif -#endif - -/* - * This is the WMesa context 'handle': - */ -typedef struct wmesa_context *WMesaContext; - - - -/* - * Create a new WMesaContext for rendering into a window. You must - * have already created the window of correct visual type and with an - * appropriate colormap. - * - * Input: - * hDC - Windows device or memory context - * Pal - Palette to use - * rgb_flag - GL_TRUE = RGB mode, - * GL_FALSE = color index mode - * db_flag - GL_TRUE = double-buffered, - * GL_FALSE = single buffered - * alpha_flag - GL_TRUE = create software alpha buffer, - * GL_FALSE = no software alpha buffer - * - * Note: Indexed mode requires double buffering under Windows. - * - * Return: a WMesa_context or NULL if error. - */ -extern WMesaContext WMesaCreateContext(HDC hDC,HPALETTE* pPal, - GLboolean rgb_flag, - GLboolean db_flag, - GLboolean alpha_flag); - - -/* - * Destroy a rendering context as returned by WMesaCreateContext() - */ -extern void WMesaDestroyContext( WMesaContext ctx ); - - - -/* - * Make the specified context the current one. - */ -extern void WMesaMakeCurrent( WMesaContext ctx, HDC hdc ); - - -/* - * Return a handle to the current context. - */ -extern WMesaContext WMesaGetCurrentContext( void ); - - -/* - * Swap the front and back buffers for the current context. No action - * taken if the context is not double buffered. - */ -extern void WMesaSwapBuffers(HDC hdc); - - -/* - * In indexed color mode we need to know when the palette changes. - */ -extern void WMesaPaletteChange(HPALETTE Pal); - -extern void WMesaMove(void); - -void WMesaShareLists(WMesaContext ctx_to_share, WMesaContext ctx); - -#ifdef __cplusplus -} -#endif - - -#endif - diff --git a/mesalib/include/VG/openvg.h b/mesalib/include/VG/openvg.h deleted file mode 100644 index 86d54d6e0..000000000 --- a/mesalib/include/VG/openvg.h +++ /dev/null @@ -1,746 +0,0 @@ -/* $Revision: 9203 $ on $Date:: 2009-10-07 02:21:52 -0700 #$ */ - -/*------------------------------------------------------------------------ - * - * OpenVG 1.1 Reference Implementation - * ------------------------------------- - * - * Copyright (c) 2008 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and /or associated documentation files - * (the "Materials "), to deal in the Materials without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Materials, - * and to permit persons to whom the Materials are furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR - * THE USE OR OTHER DEALINGS IN THE MATERIALS. - * - *//** - * \file - * \brief OpenVG 1.1 API. - *//*-------------------------------------------------------------------*/ - -#ifndef _OPENVG_H -#define _OPENVG_H - -#include <VG/vgplatform.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define OPENVG_VERSION_1_0 1 -#define OPENVG_VERSION_1_0_1 1 -#define OPENVG_VERSION_1_1 2 - -#ifndef VG_MAXSHORT -#define VG_MAXSHORT 0x7FFF -#endif - -#ifndef VG_MAXINT -#define VG_MAXINT 0x7FFFFFFF -#endif - -#ifndef VG_MAX_ENUM -#define VG_MAX_ENUM 0x7FFFFFFF -#endif - -typedef VGuint VGHandle; - -typedef VGHandle VGPath; -typedef VGHandle VGImage; -typedef VGHandle VGMaskLayer; -typedef VGHandle VGFont; -typedef VGHandle VGPaint; - -#define VG_INVALID_HANDLE ((VGHandle)0) - -typedef enum { - VG_FALSE = 0, - VG_TRUE = 1, - - VG_BOOLEAN_FORCE_SIZE = VG_MAX_ENUM -} VGboolean; - -typedef enum { - VG_NO_ERROR = 0, - VG_BAD_HANDLE_ERROR = 0x1000, - VG_ILLEGAL_ARGUMENT_ERROR = 0x1001, - VG_OUT_OF_MEMORY_ERROR = 0x1002, - VG_PATH_CAPABILITY_ERROR = 0x1003, - VG_UNSUPPORTED_IMAGE_FORMAT_ERROR = 0x1004, - VG_UNSUPPORTED_PATH_FORMAT_ERROR = 0x1005, - VG_IMAGE_IN_USE_ERROR = 0x1006, - VG_NO_CONTEXT_ERROR = 0x1007, - - VG_ERROR_CODE_FORCE_SIZE = VG_MAX_ENUM -} VGErrorCode; - -typedef enum { - /* Mode settings */ - VG_MATRIX_MODE = 0x1100, - VG_FILL_RULE = 0x1101, - VG_IMAGE_QUALITY = 0x1102, - VG_RENDERING_QUALITY = 0x1103, - VG_BLEND_MODE = 0x1104, - VG_IMAGE_MODE = 0x1105, - - /* Scissoring rectangles */ - VG_SCISSOR_RECTS = 0x1106, - - /* Color Transformation */ - VG_COLOR_TRANSFORM = 0x1170, - VG_COLOR_TRANSFORM_VALUES = 0x1171, - - /* Stroke parameters */ - VG_STROKE_LINE_WIDTH = 0x1110, - VG_STROKE_CAP_STYLE = 0x1111, - VG_STROKE_JOIN_STYLE = 0x1112, - VG_STROKE_MITER_LIMIT = 0x1113, - VG_STROKE_DASH_PATTERN = 0x1114, - VG_STROKE_DASH_PHASE = 0x1115, - VG_STROKE_DASH_PHASE_RESET = 0x1116, - - /* Edge fill color for VG_TILE_FILL tiling mode */ - VG_TILE_FILL_COLOR = 0x1120, - - /* Color for vgClear */ - VG_CLEAR_COLOR = 0x1121, - - /* Glyph origin */ - VG_GLYPH_ORIGIN = 0x1122, - - /* Enable/disable alpha masking and scissoring */ - VG_MASKING = 0x1130, - VG_SCISSORING = 0x1131, - - /* Pixel layout information */ - VG_PIXEL_LAYOUT = 0x1140, - VG_SCREEN_LAYOUT = 0x1141, - - /* Source format selection for image filters */ - VG_FILTER_FORMAT_LINEAR = 0x1150, - VG_FILTER_FORMAT_PREMULTIPLIED = 0x1151, - - /* Destination write enable mask for image filters */ - VG_FILTER_CHANNEL_MASK = 0x1152, - - /* Implementation limits (read-only) */ - VG_MAX_SCISSOR_RECTS = 0x1160, - VG_MAX_DASH_COUNT = 0x1161, - VG_MAX_KERNEL_SIZE = 0x1162, - VG_MAX_SEPARABLE_KERNEL_SIZE = 0x1163, - VG_MAX_COLOR_RAMP_STOPS = 0x1164, - VG_MAX_IMAGE_WIDTH = 0x1165, - VG_MAX_IMAGE_HEIGHT = 0x1166, - VG_MAX_IMAGE_PIXELS = 0x1167, - VG_MAX_IMAGE_BYTES = 0x1168, - VG_MAX_FLOAT = 0x1169, - VG_MAX_GAUSSIAN_STD_DEVIATION = 0x116A, - - VG_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM -} VGParamType; - -typedef enum { - VG_RENDERING_QUALITY_NONANTIALIASED = 0x1200, - VG_RENDERING_QUALITY_FASTER = 0x1201, - VG_RENDERING_QUALITY_BETTER = 0x1202, /* Default */ - - VG_RENDERING_QUALITY_FORCE_SIZE = VG_MAX_ENUM -} VGRenderingQuality; - -typedef enum { - VG_PIXEL_LAYOUT_UNKNOWN = 0x1300, - VG_PIXEL_LAYOUT_RGB_VERTICAL = 0x1301, - VG_PIXEL_LAYOUT_BGR_VERTICAL = 0x1302, - VG_PIXEL_LAYOUT_RGB_HORIZONTAL = 0x1303, - VG_PIXEL_LAYOUT_BGR_HORIZONTAL = 0x1304, - - VG_PIXEL_LAYOUT_FORCE_SIZE = VG_MAX_ENUM -} VGPixelLayout; - -typedef enum { - VG_MATRIX_PATH_USER_TO_SURFACE = 0x1400, - VG_MATRIX_IMAGE_USER_TO_SURFACE = 0x1401, - VG_MATRIX_FILL_PAINT_TO_USER = 0x1402, - VG_MATRIX_STROKE_PAINT_TO_USER = 0x1403, - VG_MATRIX_GLYPH_USER_TO_SURFACE = 0x1404, - - VG_MATRIX_MODE_FORCE_SIZE = VG_MAX_ENUM -} VGMatrixMode; - -typedef enum { - VG_CLEAR_MASK = 0x1500, - VG_FILL_MASK = 0x1501, - VG_SET_MASK = 0x1502, - VG_UNION_MASK = 0x1503, - VG_INTERSECT_MASK = 0x1504, - VG_SUBTRACT_MASK = 0x1505, - - VG_MASK_OPERATION_FORCE_SIZE = VG_MAX_ENUM -} VGMaskOperation; - -#define VG_PATH_FORMAT_STANDARD 0 - -typedef enum { - VG_PATH_DATATYPE_S_8 = 0, - VG_PATH_DATATYPE_S_16 = 1, - VG_PATH_DATATYPE_S_32 = 2, - VG_PATH_DATATYPE_F = 3, - - VG_PATH_DATATYPE_FORCE_SIZE = VG_MAX_ENUM -} VGPathDatatype; - -typedef enum { - VG_ABSOLUTE = 0, - VG_RELATIVE = 1, - - VG_PATH_ABS_REL_FORCE_SIZE = VG_MAX_ENUM -} VGPathAbsRel; - -typedef enum { - VG_CLOSE_PATH = ( 0 << 1), - VG_MOVE_TO = ( 1 << 1), - VG_LINE_TO = ( 2 << 1), - VG_HLINE_TO = ( 3 << 1), - VG_VLINE_TO = ( 4 << 1), - VG_QUAD_TO = ( 5 << 1), - VG_CUBIC_TO = ( 6 << 1), - VG_SQUAD_TO = ( 7 << 1), - VG_SCUBIC_TO = ( 8 << 1), - VG_SCCWARC_TO = ( 9 << 1), - VG_SCWARC_TO = (10 << 1), - VG_LCCWARC_TO = (11 << 1), - VG_LCWARC_TO = (12 << 1), - - VG_PATH_SEGMENT_FORCE_SIZE = VG_MAX_ENUM -} VGPathSegment; - -typedef enum { - VG_MOVE_TO_ABS = VG_MOVE_TO | VG_ABSOLUTE, - VG_MOVE_TO_REL = VG_MOVE_TO | VG_RELATIVE, - VG_LINE_TO_ABS = VG_LINE_TO | VG_ABSOLUTE, - VG_LINE_TO_REL = VG_LINE_TO | VG_RELATIVE, - VG_HLINE_TO_ABS = VG_HLINE_TO | VG_ABSOLUTE, - VG_HLINE_TO_REL = VG_HLINE_TO | VG_RELATIVE, - VG_VLINE_TO_ABS = VG_VLINE_TO | VG_ABSOLUTE, - VG_VLINE_TO_REL = VG_VLINE_TO | VG_RELATIVE, - VG_QUAD_TO_ABS = VG_QUAD_TO | VG_ABSOLUTE, - VG_QUAD_TO_REL = VG_QUAD_TO | VG_RELATIVE, - VG_CUBIC_TO_ABS = VG_CUBIC_TO | VG_ABSOLUTE, - VG_CUBIC_TO_REL = VG_CUBIC_TO | VG_RELATIVE, - VG_SQUAD_TO_ABS = VG_SQUAD_TO | VG_ABSOLUTE, - VG_SQUAD_TO_REL = VG_SQUAD_TO | VG_RELATIVE, - VG_SCUBIC_TO_ABS = VG_SCUBIC_TO | VG_ABSOLUTE, - VG_SCUBIC_TO_REL = VG_SCUBIC_TO | VG_RELATIVE, - VG_SCCWARC_TO_ABS = VG_SCCWARC_TO | VG_ABSOLUTE, - VG_SCCWARC_TO_REL = VG_SCCWARC_TO | VG_RELATIVE, - VG_SCWARC_TO_ABS = VG_SCWARC_TO | VG_ABSOLUTE, - VG_SCWARC_TO_REL = VG_SCWARC_TO | VG_RELATIVE, - VG_LCCWARC_TO_ABS = VG_LCCWARC_TO | VG_ABSOLUTE, - VG_LCCWARC_TO_REL = VG_LCCWARC_TO | VG_RELATIVE, - VG_LCWARC_TO_ABS = VG_LCWARC_TO | VG_ABSOLUTE, - VG_LCWARC_TO_REL = VG_LCWARC_TO | VG_RELATIVE, - - VG_PATH_COMMAND_FORCE_SIZE = VG_MAX_ENUM -} VGPathCommand; - -typedef enum { - VG_PATH_CAPABILITY_APPEND_FROM = (1 << 0), - VG_PATH_CAPABILITY_APPEND_TO = (1 << 1), - VG_PATH_CAPABILITY_MODIFY = (1 << 2), - VG_PATH_CAPABILITY_TRANSFORM_FROM = (1 << 3), - VG_PATH_CAPABILITY_TRANSFORM_TO = (1 << 4), - VG_PATH_CAPABILITY_INTERPOLATE_FROM = (1 << 5), - VG_PATH_CAPABILITY_INTERPOLATE_TO = (1 << 6), - VG_PATH_CAPABILITY_PATH_LENGTH = (1 << 7), - VG_PATH_CAPABILITY_POINT_ALONG_PATH = (1 << 8), - VG_PATH_CAPABILITY_TANGENT_ALONG_PATH = (1 << 9), - VG_PATH_CAPABILITY_PATH_BOUNDS = (1 << 10), - VG_PATH_CAPABILITY_PATH_TRANSFORMED_BOUNDS = (1 << 11), - VG_PATH_CAPABILITY_ALL = (1 << 12) - 1, - - VG_PATH_CAPABILITIES_FORCE_SIZE = VG_MAX_ENUM -} VGPathCapabilities; - -typedef enum { - VG_PATH_FORMAT = 0x1600, - VG_PATH_DATATYPE = 0x1601, - VG_PATH_SCALE = 0x1602, - VG_PATH_BIAS = 0x1603, - VG_PATH_NUM_SEGMENTS = 0x1604, - VG_PATH_NUM_COORDS = 0x1605, - - VG_PATH_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM -} VGPathParamType; - -typedef enum { - VG_CAP_BUTT = 0x1700, - VG_CAP_ROUND = 0x1701, - VG_CAP_SQUARE = 0x1702, - - VG_CAP_STYLE_FORCE_SIZE = VG_MAX_ENUM -} VGCapStyle; - -typedef enum { - VG_JOIN_MITER = 0x1800, - VG_JOIN_ROUND = 0x1801, - VG_JOIN_BEVEL = 0x1802, - - VG_JOIN_STYLE_FORCE_SIZE = VG_MAX_ENUM -} VGJoinStyle; - -typedef enum { - VG_EVEN_ODD = 0x1900, - VG_NON_ZERO = 0x1901, - - VG_FILL_RULE_FORCE_SIZE = VG_MAX_ENUM -} VGFillRule; - -typedef enum { - VG_STROKE_PATH = (1 << 0), - VG_FILL_PATH = (1 << 1), - - VG_PAINT_MODE_FORCE_SIZE = VG_MAX_ENUM -} VGPaintMode; - -typedef enum { - /* Color paint parameters */ - VG_PAINT_TYPE = 0x1A00, - VG_PAINT_COLOR = 0x1A01, - VG_PAINT_COLOR_RAMP_SPREAD_MODE = 0x1A02, - VG_PAINT_COLOR_RAMP_PREMULTIPLIED = 0x1A07, - VG_PAINT_COLOR_RAMP_STOPS = 0x1A03, - - /* Linear gradient paint parameters */ - VG_PAINT_LINEAR_GRADIENT = 0x1A04, - - /* Radial gradient paint parameters */ - VG_PAINT_RADIAL_GRADIENT = 0x1A05, - - /* Pattern paint parameters */ - VG_PAINT_PATTERN_TILING_MODE = 0x1A06, - - VG_PAINT_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM -} VGPaintParamType; - -typedef enum { - VG_PAINT_TYPE_COLOR = 0x1B00, - VG_PAINT_TYPE_LINEAR_GRADIENT = 0x1B01, - VG_PAINT_TYPE_RADIAL_GRADIENT = 0x1B02, - VG_PAINT_TYPE_PATTERN = 0x1B03, - - VG_PAINT_TYPE_FORCE_SIZE = VG_MAX_ENUM -} VGPaintType; - -typedef enum { - VG_COLOR_RAMP_SPREAD_PAD = 0x1C00, - VG_COLOR_RAMP_SPREAD_REPEAT = 0x1C01, - VG_COLOR_RAMP_SPREAD_REFLECT = 0x1C02, - - VG_COLOR_RAMP_SPREAD_MODE_FORCE_SIZE = VG_MAX_ENUM -} VGColorRampSpreadMode; - -typedef enum { - VG_TILE_FILL = 0x1D00, - VG_TILE_PAD = 0x1D01, - VG_TILE_REPEAT = 0x1D02, - VG_TILE_REFLECT = 0x1D03, - - VG_TILING_MODE_FORCE_SIZE = VG_MAX_ENUM -} VGTilingMode; - -typedef enum { - /* RGB{A,X} channel ordering */ - VG_sRGBX_8888 = 0, - VG_sRGBA_8888 = 1, - VG_sRGBA_8888_PRE = 2, - VG_sRGB_565 = 3, - VG_sRGBA_5551 = 4, - VG_sRGBA_4444 = 5, - VG_sL_8 = 6, - VG_lRGBX_8888 = 7, - VG_lRGBA_8888 = 8, - VG_lRGBA_8888_PRE = 9, - VG_lL_8 = 10, - VG_A_8 = 11, - VG_BW_1 = 12, - VG_A_1 = 13, - VG_A_4 = 14, - - /* {A,X}RGB channel ordering */ - VG_sXRGB_8888 = 0 | (1 << 6), - VG_sARGB_8888 = 1 | (1 << 6), - VG_sARGB_8888_PRE = 2 | (1 << 6), - VG_sARGB_1555 = 4 | (1 << 6), - VG_sARGB_4444 = 5 | (1 << 6), - VG_lXRGB_8888 = 7 | (1 << 6), - VG_lARGB_8888 = 8 | (1 << 6), - VG_lARGB_8888_PRE = 9 | (1 << 6), - - /* BGR{A,X} channel ordering */ - VG_sBGRX_8888 = 0 | (1 << 7), - VG_sBGRA_8888 = 1 | (1 << 7), - VG_sBGRA_8888_PRE = 2 | (1 << 7), - VG_sBGR_565 = 3 | (1 << 7), - VG_sBGRA_5551 = 4 | (1 << 7), - VG_sBGRA_4444 = 5 | (1 << 7), - VG_lBGRX_8888 = 7 | (1 << 7), - VG_lBGRA_8888 = 8 | (1 << 7), - VG_lBGRA_8888_PRE = 9 | (1 << 7), - - /* {A,X}BGR channel ordering */ - VG_sXBGR_8888 = 0 | (1 << 6) | (1 << 7), - VG_sABGR_8888 = 1 | (1 << 6) | (1 << 7), - VG_sABGR_8888_PRE = 2 | (1 << 6) | (1 << 7), - VG_sABGR_1555 = 4 | (1 << 6) | (1 << 7), - VG_sABGR_4444 = 5 | (1 << 6) | (1 << 7), - VG_lXBGR_8888 = 7 | (1 << 6) | (1 << 7), - VG_lABGR_8888 = 8 | (1 << 6) | (1 << 7), - VG_lABGR_8888_PRE = 9 | (1 << 6) | (1 << 7), - - VG_IMAGE_FORMAT_FORCE_SIZE = VG_MAX_ENUM -} VGImageFormat; - -typedef enum { - VG_IMAGE_QUALITY_NONANTIALIASED = (1 << 0), - VG_IMAGE_QUALITY_FASTER = (1 << 1), - VG_IMAGE_QUALITY_BETTER = (1 << 2), - - VG_IMAGE_QUALITY_FORCE_SIZE = VG_MAX_ENUM -} VGImageQuality; - -typedef enum { - VG_IMAGE_FORMAT = 0x1E00, - VG_IMAGE_WIDTH = 0x1E01, - VG_IMAGE_HEIGHT = 0x1E02, - - VG_IMAGE_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM -} VGImageParamType; - -typedef enum { - VG_DRAW_IMAGE_NORMAL = 0x1F00, - VG_DRAW_IMAGE_MULTIPLY = 0x1F01, - VG_DRAW_IMAGE_STENCIL = 0x1F02, - - VG_IMAGE_MODE_FORCE_SIZE = VG_MAX_ENUM -} VGImageMode; - -typedef enum { - VG_RED = (1 << 3), - VG_GREEN = (1 << 2), - VG_BLUE = (1 << 1), - VG_ALPHA = (1 << 0), - - VG_IMAGE_CHANNEL_FORCE_SIZE = VG_MAX_ENUM -} VGImageChannel; - -typedef enum { - VG_BLEND_SRC = 0x2000, - VG_BLEND_SRC_OVER = 0x2001, - VG_BLEND_DST_OVER = 0x2002, - VG_BLEND_SRC_IN = 0x2003, - VG_BLEND_DST_IN = 0x2004, - VG_BLEND_MULTIPLY = 0x2005, - VG_BLEND_SCREEN = 0x2006, - VG_BLEND_DARKEN = 0x2007, - VG_BLEND_LIGHTEN = 0x2008, - VG_BLEND_ADDITIVE = 0x2009, - - VG_BLEND_MODE_FORCE_SIZE = VG_MAX_ENUM -} VGBlendMode; - -typedef enum { - VG_FONT_NUM_GLYPHS = 0x2F00, - - VG_FONT_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM -} VGFontParamType; - -typedef enum { - VG_IMAGE_FORMAT_QUERY = 0x2100, - VG_PATH_DATATYPE_QUERY = 0x2101, - - VG_HARDWARE_QUERY_TYPE_FORCE_SIZE = VG_MAX_ENUM -} VGHardwareQueryType; - -typedef enum { - VG_HARDWARE_ACCELERATED = 0x2200, - VG_HARDWARE_UNACCELERATED = 0x2201, - - VG_HARDWARE_QUERY_RESULT_FORCE_SIZE = VG_MAX_ENUM -} VGHardwareQueryResult; - -typedef enum { - VG_VENDOR = 0x2300, - VG_RENDERER = 0x2301, - VG_VERSION = 0x2302, - VG_EXTENSIONS = 0x2303, - - VG_STRING_ID_FORCE_SIZE = VG_MAX_ENUM -} VGStringID; - -/* Function Prototypes */ - -#ifndef VG_API_CALL -# error VG_API_CALL must be defined -#endif - -#ifndef VG_API_ENTRY -# error VG_API_ENTRY must be defined -#endif - -#ifndef VG_API_EXIT -# error VG_API_EXIT must be defined -#endif - -VG_API_CALL VGErrorCode VG_API_ENTRY vgGetError(void) VG_API_EXIT; - -VG_API_CALL void VG_API_ENTRY vgFlush(void) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgFinish(void) VG_API_EXIT; - -/* Getters and Setters */ -VG_API_CALL void VG_API_ENTRY vgSetf (VGParamType type, VGfloat value) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgSeti (VGParamType type, VGint value) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgSetfv(VGParamType type, VGint count, - const VGfloat * values) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgSetiv(VGParamType type, VGint count, - const VGint * values) VG_API_EXIT; - -VG_API_CALL VGfloat VG_API_ENTRY vgGetf(VGParamType type) VG_API_EXIT; -VG_API_CALL VGint VG_API_ENTRY vgGeti(VGParamType type) VG_API_EXIT; -VG_API_CALL VGint VG_API_ENTRY vgGetVectorSize(VGParamType type) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgGetfv(VGParamType type, VGint count, VGfloat * values) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgGetiv(VGParamType type, VGint count, VGint * values) VG_API_EXIT; - -VG_API_CALL void VG_API_ENTRY vgSetParameterf(VGHandle object, - VGint paramType, - VGfloat value) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgSetParameteri(VGHandle object, - VGint paramType, - VGint value) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgSetParameterfv(VGHandle object, - VGint paramType, - VGint count, const VGfloat * values) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgSetParameteriv(VGHandle object, - VGint paramType, - VGint count, const VGint * values) VG_API_EXIT; - -VG_API_CALL VGfloat VG_API_ENTRY vgGetParameterf(VGHandle object, - VGint paramType) VG_API_EXIT; -VG_API_CALL VGint VG_API_ENTRY vgGetParameteri(VGHandle object, - VGint paramType); -VG_API_CALL VGint VG_API_ENTRY vgGetParameterVectorSize(VGHandle object, - VGint paramType) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgGetParameterfv(VGHandle object, - VGint paramType, - VGint count, VGfloat * values) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgGetParameteriv(VGHandle object, - VGint paramType, - VGint count, VGint * values) VG_API_EXIT; - -/* Matrix Manipulation */ -VG_API_CALL void VG_API_ENTRY vgLoadIdentity(void) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgLoadMatrix(const VGfloat * m) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgGetMatrix(VGfloat * m) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgMultMatrix(const VGfloat * m) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgTranslate(VGfloat tx, VGfloat ty) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgScale(VGfloat sx, VGfloat sy) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgShear(VGfloat shx, VGfloat shy) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgRotate(VGfloat angle) VG_API_EXIT; - -/* Masking and Clearing */ -VG_API_CALL void VG_API_ENTRY vgMask(VGHandle mask, VGMaskOperation operation, - VGint x, VGint y, - VGint width, VGint height) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgRenderToMask(VGPath path, - VGbitfield paintModes, - VGMaskOperation operation) VG_API_EXIT; -VG_API_CALL VGMaskLayer VG_API_ENTRY vgCreateMaskLayer(VGint width, VGint height) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgDestroyMaskLayer(VGMaskLayer maskLayer) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgFillMaskLayer(VGMaskLayer maskLayer, - VGint x, VGint y, - VGint width, VGint height, - VGfloat value) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgCopyMask(VGMaskLayer maskLayer, - VGint dx, VGint dy, - VGint sx, VGint sy, - VGint width, VGint height) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgClear(VGint x, VGint y, VGint width, VGint height) VG_API_EXIT; - -/* Paths */ -VG_API_CALL VGPath VG_API_ENTRY vgCreatePath(VGint pathFormat, - VGPathDatatype datatype, - VGfloat scale, VGfloat bias, - VGint segmentCapacityHint, - VGint coordCapacityHint, - VGbitfield capabilities) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgClearPath(VGPath path, VGbitfield capabilities) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgDestroyPath(VGPath path) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgRemovePathCapabilities(VGPath path, - VGbitfield capabilities) VG_API_EXIT; -VG_API_CALL VGbitfield VG_API_ENTRY vgGetPathCapabilities(VGPath path) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgAppendPath(VGPath dstPath, VGPath srcPath) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgAppendPathData(VGPath dstPath, - VGint numSegments, - const VGubyte * pathSegments, - const void * pathData) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgModifyPathCoords(VGPath dstPath, VGint startIndex, - VGint numSegments, - const void * pathData) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgTransformPath(VGPath dstPath, VGPath srcPath) VG_API_EXIT; -VG_API_CALL VGboolean VG_API_ENTRY vgInterpolatePath(VGPath dstPath, - VGPath startPath, - VGPath endPath, - VGfloat amount) VG_API_EXIT; -VG_API_CALL VGfloat VG_API_ENTRY vgPathLength(VGPath path, - VGint startSegment, VGint numSegments) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgPointAlongPath(VGPath path, - VGint startSegment, VGint numSegments, - VGfloat distance, - VGfloat * x, VGfloat * y, - VGfloat * tangentX, VGfloat * tangentY) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgPathBounds(VGPath path, - VGfloat * minX, VGfloat * minY, - VGfloat * width, VGfloat * height) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgPathTransformedBounds(VGPath path, - VGfloat * minX, VGfloat * minY, - VGfloat * width, VGfloat * height) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgDrawPath(VGPath path, VGbitfield paintModes) VG_API_EXIT; - -/* Paint */ -VG_API_CALL VGPaint VG_API_ENTRY vgCreatePaint(void) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgDestroyPaint(VGPaint paint) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgSetPaint(VGPaint paint, VGbitfield paintModes) VG_API_EXIT; -VG_API_CALL VGPaint VG_API_ENTRY vgGetPaint(VGPaintMode paintMode) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgSetColor(VGPaint paint, VGuint rgba) VG_API_EXIT; -VG_API_CALL VGuint VG_API_ENTRY vgGetColor(VGPaint paint) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgPaintPattern(VGPaint paint, VGImage pattern) VG_API_EXIT; - -/* Images */ -VG_API_CALL VGImage VG_API_ENTRY vgCreateImage(VGImageFormat format, - VGint width, VGint height, - VGbitfield allowedQuality) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgDestroyImage(VGImage image) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgClearImage(VGImage image, - VGint x, VGint y, VGint width, VGint height) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgImageSubData(VGImage image, - const void * data, VGint dataStride, - VGImageFormat dataFormat, - VGint x, VGint y, VGint width, VGint height) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgGetImageSubData(VGImage image, - void * data, VGint dataStride, - VGImageFormat dataFormat, - VGint x, VGint y, - VGint width, VGint height) VG_API_EXIT; -VG_API_CALL VGImage VG_API_ENTRY vgChildImage(VGImage parent, - VGint x, VGint y, VGint width, VGint height) VG_API_EXIT; -VG_API_CALL VGImage VG_API_ENTRY vgGetParent(VGImage image) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgCopyImage(VGImage dst, VGint dx, VGint dy, - VGImage src, VGint sx, VGint sy, - VGint width, VGint height, - VGboolean dither) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgDrawImage(VGImage image) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgSetPixels(VGint dx, VGint dy, - VGImage src, VGint sx, VGint sy, - VGint width, VGint height) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgWritePixels(const void * data, VGint dataStride, - VGImageFormat dataFormat, - VGint dx, VGint dy, - VGint width, VGint height) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgGetPixels(VGImage dst, VGint dx, VGint dy, - VGint sx, VGint sy, - VGint width, VGint height) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgReadPixels(void * data, VGint dataStride, - VGImageFormat dataFormat, - VGint sx, VGint sy, - VGint width, VGint height) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgCopyPixels(VGint dx, VGint dy, - VGint sx, VGint sy, - VGint width, VGint height) VG_API_EXIT; - -/* Text */ -VG_API_CALL VGFont VG_API_ENTRY vgCreateFont(VGint glyphCapacityHint) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgDestroyFont(VGFont font) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgSetGlyphToPath(VGFont font, - VGuint glyphIndex, - VGPath path, - VGboolean isHinted, - const VGfloat glyphOrigin [2], - const VGfloat escapement[2]) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgSetGlyphToImage(VGFont font, - VGuint glyphIndex, - VGImage image, - const VGfloat glyphOrigin [2], - const VGfloat escapement[2]) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgClearGlyph(VGFont font,VGuint glyphIndex) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgDrawGlyph(VGFont font, - VGuint glyphIndex, - VGbitfield paintModes, - VGboolean allowAutoHinting) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgDrawGlyphs(VGFont font, - VGint glyphCount, - const VGuint *glyphIndices, - const VGfloat *adjustments_x, - const VGfloat *adjustments_y, - VGbitfield paintModes, - VGboolean allowAutoHinting) VG_API_EXIT; - -/* Image Filters */ -VG_API_CALL void VG_API_ENTRY vgColorMatrix(VGImage dst, VGImage src, - const VGfloat * matrix) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgConvolve(VGImage dst, VGImage src, - VGint kernelWidth, VGint kernelHeight, - VGint shiftX, VGint shiftY, - const VGshort * kernel, - VGfloat scale, - VGfloat bias, - VGTilingMode tilingMode) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgSeparableConvolve(VGImage dst, VGImage src, - VGint kernelWidth, - VGint kernelHeight, - VGint shiftX, VGint shiftY, - const VGshort * kernelX, - const VGshort * kernelY, - VGfloat scale, - VGfloat bias, - VGTilingMode tilingMode) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgGaussianBlur(VGImage dst, VGImage src, - VGfloat stdDeviationX, - VGfloat stdDeviationY, - VGTilingMode tilingMode) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgLookup(VGImage dst, VGImage src, - const VGubyte * redLUT, - const VGubyte * greenLUT, - const VGubyte * blueLUT, - const VGubyte * alphaLUT, - VGboolean outputLinear, - VGboolean outputPremultiplied) VG_API_EXIT; -VG_API_CALL void VG_API_ENTRY vgLookupSingle(VGImage dst, VGImage src, - const VGuint * lookupTable, - VGImageChannel sourceChannel, - VGboolean outputLinear, - VGboolean outputPremultiplied) VG_API_EXIT; - -/* Hardware Queries */ -VG_API_CALL VGHardwareQueryResult VG_API_ENTRY vgHardwareQuery(VGHardwareQueryType key, - VGint setting) VG_API_EXIT; - -/* Renderer and Extension Information */ -VG_API_CALL const VGubyte * VG_API_ENTRY vgGetString(VGStringID name) VG_API_EXIT; - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* _OPENVG_H */ diff --git a/mesalib/include/VG/vgext.h b/mesalib/include/VG/vgext.h deleted file mode 100644 index 9ff323448..000000000 --- a/mesalib/include/VG/vgext.h +++ /dev/null @@ -1,233 +0,0 @@ -/* $Revision: 6810 $ on $Date:: 2008-10-29 07:31:37 -0700 #$ */ - -/*------------------------------------------------------------------------ - * - * VG extensions Reference Implementation - * ------------------------------------- - * - * Copyright (c) 2008 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and /or associated documentation files - * (the "Materials "), to deal in the Materials without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Materials, - * and to permit persons to whom the Materials are furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR - * THE USE OR OTHER DEALINGS IN THE MATERIALS. - * - *//** - * \file - * \brief VG extensions - *//*-------------------------------------------------------------------*/ - - - -#ifndef _VGEXT_H -#define _VGEXT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <VG/openvg.h> -#include <VG/vgu.h> - -#ifndef VG_API_ENTRYP -# define VG_API_ENTRYP VG_API_ENTRY* -#endif - -#ifndef VGU_API_ENTRYP -# define VGU_API_ENTRYP VGU_API_ENTRY* -#endif - -/*------------------------------------------------------------------------------- - * KHR extensions - *------------------------------------------------------------------------------*/ - -typedef enum { - -#ifndef VG_KHR_iterative_average_blur - VG_MAX_AVERAGE_BLUR_DIMENSION_KHR = 0x116B, - VG_AVERAGE_BLUR_DIMENSION_RESOLUTION_KHR = 0x116C, - VG_MAX_AVERAGE_BLUR_ITERATIONS_KHR = 0x116D, -#endif - - VG_PARAM_TYPE_KHR_FORCE_SIZE = VG_MAX_ENUM -} VGParamTypeKHR; - -#ifndef VG_KHR_EGL_image -#define VG_KHR_EGL_image 1 -/* VGEGLImageKHR is an opaque handle to an EGLImage */ -typedef void* VGeglImageKHR; - -#ifdef VG_VGEXT_PROTOTYPES -VG_API_CALL VGImage VG_API_ENTRY vgCreateEGLImageTargetKHR(VGeglImageKHR image); -#endif -typedef VGImage (VG_API_ENTRYP PFNVGCREATEEGLIMAGETARGETKHRPROC) (VGeglImageKHR image); - -#endif - - -#ifndef VG_KHR_iterative_average_blur -#define VG_KHR_iterative_average_blur 1 - -#ifdef VG_VGEXT_PROTOTYPES -VG_API_CALL void vgIterativeAverageBlurKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGTilingMode tilingMode); -#endif -typedef void (VG_API_ENTRYP PFNVGITERATIVEAVERAGEBLURKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGTilingMode tilingMode); - -#endif - - -#ifndef VG_KHR_advanced_blending -#define VG_KHR_advanced_blending 1 - -typedef enum { - VG_BLEND_OVERLAY_KHR = 0x2010, - VG_BLEND_HARDLIGHT_KHR = 0x2011, - VG_BLEND_SOFTLIGHT_SVG_KHR = 0x2012, - VG_BLEND_SOFTLIGHT_KHR = 0x2013, - VG_BLEND_COLORDODGE_KHR = 0x2014, - VG_BLEND_COLORBURN_KHR = 0x2015, - VG_BLEND_DIFFERENCE_KHR = 0x2016, - VG_BLEND_SUBTRACT_KHR = 0x2017, - VG_BLEND_INVERT_KHR = 0x2018, - VG_BLEND_EXCLUSION_KHR = 0x2019, - VG_BLEND_LINEARDODGE_KHR = 0x201a, - VG_BLEND_LINEARBURN_KHR = 0x201b, - VG_BLEND_VIVIDLIGHT_KHR = 0x201c, - VG_BLEND_LINEARLIGHT_KHR = 0x201d, - VG_BLEND_PINLIGHT_KHR = 0x201e, - VG_BLEND_HARDMIX_KHR = 0x201f, - VG_BLEND_CLEAR_KHR = 0x2020, - VG_BLEND_DST_KHR = 0x2021, - VG_BLEND_SRC_OUT_KHR = 0x2022, - VG_BLEND_DST_OUT_KHR = 0x2023, - VG_BLEND_SRC_ATOP_KHR = 0x2024, - VG_BLEND_DST_ATOP_KHR = 0x2025, - VG_BLEND_XOR_KHR = 0x2026, - - VG_BLEND_MODE_KHR_FORCE_SIZE= VG_MAX_ENUM -} VGBlendModeKHR; -#endif - -#ifndef VG_KHR_parametric_filter -#define VG_KHR_parametric_filter 1 - -typedef enum { - VG_PF_OBJECT_VISIBLE_FLAG_KHR = (1 << 0), - VG_PF_KNOCKOUT_FLAG_KHR = (1 << 1), - VG_PF_OUTER_FLAG_KHR = (1 << 2), - VG_PF_INNER_FLAG_KHR = (1 << 3), - - VG_PF_TYPE_KHR_FORCE_SIZE = VG_MAX_ENUM -} VGPfTypeKHR; - -typedef enum { - VGU_IMAGE_IN_USE_ERROR = 0xF010, - - VGU_ERROR_CODE_KHR_FORCE_SIZE = VG_MAX_ENUM -} VGUErrorCodeKHR; - -#ifdef VG_VGEXT_PROTOTYPES -VG_API_CALL void VG_API_ENTRY vgParametricFilterKHR(VGImage dst,VGImage src,VGImage blur,VGfloat strength,VGfloat offsetX,VGfloat offsetY,VGbitfield filterFlags,VGPaint highlightPaint,VGPaint shadowPaint); -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguDropShadowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint shadowColorRGBA); -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGlowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint glowColorRGBA) ; -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguBevelKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint highlightColorRGBA,VGuint shadowColorRGBA); -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGradientGlowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* glowColorRampStops); -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGradientBevelKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* bevelColorRampStops); -#endif -typedef void (VG_API_ENTRYP PFNVGPARAMETRICFILTERKHRPROC) (VGImage dst,VGImage src,VGImage blur,VGfloat strength,VGfloat offsetX,VGfloat offsetY,VGbitfield filterFlags,VGPaint highlightPaint,VGPaint shadowPaint); -typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUDROPSHADOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint shadowColorRGBA); -typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGLOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint glowColorRGBA); -typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUBEVELKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint highlightColorRGBA,VGuint shadowColorRGBA); -typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGRADIENTGLOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* glowColorRampStops); -typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGRADIENTBEVELKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* bevelColorRampStops); - -#endif - - -/*------------------------------------------------------------------------------- - * NDS extensions - *------------------------------------------------------------------------------*/ - -#ifndef VG_NDS_paint_generation -#define VG_NDS_paint_generation 1 - -typedef enum { - VG_PAINT_COLOR_RAMP_LINEAR_NDS = 0x1A10, - VG_COLOR_MATRIX_NDS = 0x1A11, - VG_PAINT_COLOR_TRANSFORM_LINEAR_NDS = 0x1A12, - - VG_PAINT_PARAM_TYPE_NDS_FORCE_SIZE = VG_MAX_ENUM -} VGPaintParamTypeNds; - -typedef enum { - VG_DRAW_IMAGE_COLOR_MATRIX_NDS = 0x1F10, - - VG_IMAGE_MODE_NDS_FORCE_SIZE = VG_MAX_ENUM -} VGImageModeNds; -#endif - - -#ifndef VG_NDS_projective_geometry -#define VG_NDS_projective_geometry 1 - -typedef enum { - VG_CLIP_MODE_NDS = 0x1180, - VG_CLIP_LINES_NDS = 0x1181, - VG_MAX_CLIP_LINES_NDS = 0x1182, - - VG_PARAM_TYPE_NDS_FORCE_SIZE = VG_MAX_ENUM -} VGParamTypeNds; - -typedef enum { - VG_CLIPMODE_NONE_NDS = 0x3000, - VG_CLIPMODE_CLIP_CLOSED_NDS = 0x3001, - VG_CLIPMODE_CLIP_OPEN_NDS = 0x3002, - VG_CLIPMODE_CULL_NDS = 0x3003, - - VG_CLIPMODE_NDS_FORCE_SIZE = VG_MAX_ENUM -} VGClipModeNds; - -typedef enum { - VG_RQUAD_TO_NDS = ( 13 << 1 ), - VG_RCUBIC_TO_NDS = ( 14 << 1 ), - - VG_PATH_SEGMENT_NDS_FORCE_SIZE = VG_MAX_ENUM -} VGPathSegmentNds; - -typedef enum { - VG_RQUAD_TO_ABS_NDS = (VG_RQUAD_TO_NDS | VG_ABSOLUTE), - VG_RQUAD_TO_REL_NDS = (VG_RQUAD_TO_NDS | VG_RELATIVE), - VG_RCUBIC_TO_ABS_NDS = (VG_RCUBIC_TO_NDS | VG_ABSOLUTE), - VG_RCUBIC_TO_REL_NDS = (VG_RCUBIC_TO_NDS | VG_RELATIVE), - - VG_PATH_COMMAND_NDS_FORCE_SIZE = VG_MAX_ENUM -} VGPathCommandNds; - -#ifdef VG_VGEXT_PROTOTYPES -VG_API_CALL void VG_API_ENTRY vgProjectiveMatrixNDS(VGboolean enable) ; -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguTransformClipLineNDS(const VGfloat Ain,const VGfloat Bin,const VGfloat Cin,const VGfloat* matrix,const VGboolean inverse,VGfloat* Aout,VGfloat* Bout,VGfloat* Cout); -#endif -typedef void (VG_API_ENTRYP PFNVGPROJECTIVEMATRIXNDSPROC) (VGboolean enable) ; -typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUTRANSFORMCLIPLINENDSPROC) (const VGfloat Ain,const VGfloat Bin,const VGfloat Cin,const VGfloat* matrix,const VGboolean inverse,VGfloat* Aout,VGfloat* Bout,VGfloat* Cout); - -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* _VGEXT_H */ diff --git a/mesalib/include/VG/vgplatform.h b/mesalib/include/VG/vgplatform.h deleted file mode 100644 index aa1829f6c..000000000 --- a/mesalib/include/VG/vgplatform.h +++ /dev/null @@ -1,92 +0,0 @@ -/* $Revision: 6810 $ on $Date:: 2008-10-29 07:31:37 -0700 #$ */ - -/*------------------------------------------------------------------------ - * - * VG platform specific header Reference Implementation - * ---------------------------------------------------- - * - * Copyright (c) 2008 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and /or associated documentation files - * (the "Materials "), to deal in the Materials without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Materials, - * and to permit persons to whom the Materials are furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR - * THE USE OR OTHER DEALINGS IN THE MATERIALS. - * - *//** - * \file - * \brief VG platform specific header - *//*-------------------------------------------------------------------*/ - -#ifndef _VGPLATFORM_H -#define _VGPLATFORM_H - -#include <KHR/khrplatform.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef VG_API_CALL -#if defined(OPENVG_STATIC_LIBRARY) -# define VG_API_CALL -#else -# define VG_API_CALL KHRONOS_APICALL -#endif /* defined OPENVG_STATIC_LIBRARY */ -#endif /* ifndef VG_API_CALL */ - -#ifndef VGU_API_CALL -#if defined(OPENVG_STATIC_LIBRARY) -# define VGU_API_CALL -#else -# define VGU_API_CALL KHRONOS_APICALL -#endif /* defined OPENVG_STATIC_LIBRARY */ -#endif /* ifndef VGU_API_CALL */ - - -#ifndef VG_API_ENTRY -#define VG_API_ENTRY -#endif - -#ifndef VG_API_EXIT -#define VG_API_EXIT -#endif - -#ifndef VGU_API_ENTRY -#define VGU_API_ENTRY -#endif - -#ifndef VGU_API_EXIT -#define VGU_API_EXIT -#endif - -typedef float VGfloat; -typedef signed char VGbyte; -typedef unsigned char VGubyte; -typedef signed short VGshort; -typedef signed int VGint; -typedef unsigned int VGuint; -typedef unsigned int VGbitfield; - -#ifndef VG_VGEXT_PROTOTYPES -#define VG_VGEXT_PROTOTYPES -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* _VGPLATFORM_H */ diff --git a/mesalib/include/VG/vgu.h b/mesalib/include/VG/vgu.h deleted file mode 100644 index da81da938..000000000 --- a/mesalib/include/VG/vgu.h +++ /dev/null @@ -1,131 +0,0 @@ -/* $Revision: 6810 $ on $Date:: 2008-10-29 07:31:37 -0700 #$ */ - -/*------------------------------------------------------------------------ - * - * VGU 1.1 Reference Implementation - * ------------------------------------- - * - * Copyright (c) 2008 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and /or associated documentation files - * (the "Materials "), to deal in the Materials without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Materials, - * and to permit persons to whom the Materials are furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR - * THE USE OR OTHER DEALINGS IN THE MATERIALS. - * - *//** - * \file - * \brief VGU 1.1 API. - *//*-------------------------------------------------------------------*/ - -#ifndef _VGU_H -#define _VGU_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <VG/openvg.h> - -#define VGU_VERSION_1_0 1 -#define VGU_VERSION_1_1 2 - -#ifndef VGU_API_CALL -# error VGU_API_CALL must be defined -#endif - -#ifndef VGU_API_ENTRY -# error VGU_API_ENTRY must be defined -#endif - -#ifndef VGU_API_EXIT -# error VGU_API_EXIT must be defined -#endif - - -typedef enum { - VGU_NO_ERROR = 0, - VGU_BAD_HANDLE_ERROR = 0xF000, - VGU_ILLEGAL_ARGUMENT_ERROR = 0xF001, - VGU_OUT_OF_MEMORY_ERROR = 0xF002, - VGU_PATH_CAPABILITY_ERROR = 0xF003, - VGU_BAD_WARP_ERROR = 0xF004, - - VGU_ERROR_CODE_FORCE_SIZE = VG_MAX_ENUM -} VGUErrorCode; - -typedef enum { - VGU_ARC_OPEN = 0xF100, - VGU_ARC_CHORD = 0xF101, - VGU_ARC_PIE = 0xF102, - - VGU_ARC_TYPE_FORCE_SIZE = VG_MAX_ENUM -} VGUArcType; - -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguLine(VGPath path, - VGfloat x0, VGfloat y0, - VGfloat x1, VGfloat y1) VGU_API_EXIT; - -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguPolygon(VGPath path, - const VGfloat * points, VGint count, - VGboolean closed) VGU_API_EXIT; - -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguRect(VGPath path, - VGfloat x, VGfloat y, - VGfloat width, VGfloat height) VGU_API_EXIT; - -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguRoundRect(VGPath path, - VGfloat x, VGfloat y, - VGfloat width, VGfloat height, - VGfloat arcWidth, VGfloat arcHeight) VGU_API_EXIT; - -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguEllipse(VGPath path, - VGfloat cx, VGfloat cy, - VGfloat width, VGfloat height) VGU_API_EXIT; - -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguArc(VGPath path, - VGfloat x, VGfloat y, - VGfloat width, VGfloat height, - VGfloat startAngle, VGfloat angleExtent, - VGUArcType arcType) VGU_API_EXIT; - -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpQuadToSquare(VGfloat sx0, VGfloat sy0, - VGfloat sx1, VGfloat sy1, - VGfloat sx2, VGfloat sy2, - VGfloat sx3, VGfloat sy3, - VGfloat * matrix) VGU_API_EXIT; - -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpSquareToQuad(VGfloat dx0, VGfloat dy0, - VGfloat dx1, VGfloat dy1, - VGfloat dx2, VGfloat dy2, - VGfloat dx3, VGfloat dy3, - VGfloat * matrix) VGU_API_EXIT; - -VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpQuadToQuad(VGfloat dx0, VGfloat dy0, - VGfloat dx1, VGfloat dy1, - VGfloat dx2, VGfloat dy2, - VGfloat dx3, VGfloat dy3, - VGfloat sx0, VGfloat sy0, - VGfloat sx1, VGfloat sy1, - VGfloat sx2, VGfloat sy2, - VGfloat sx3, VGfloat sy3, - VGfloat * matrix) VGU_API_EXIT; - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* #ifndef _VGU_H */ diff --git a/mesalib/include/c99_alloca.h b/mesalib/include/c99_alloca.h new file mode 100644 index 000000000..ed66fda01 --- /dev/null +++ b/mesalib/include/c99_alloca.h @@ -0,0 +1,49 @@ +/************************************************************************** + * + * Copyright 2015 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef _C99_ALLOCA_H_ +#define _C99_ALLOCA_H_ + + +#if defined(_MSC_VER) + +# include <malloc.h> + +# define alloca _alloca + +#elif defined(__sun) + +# include <alloca.h> + +#else /* !defined(_MSC_VER) */ + +# include <stdlib.h> + +#endif /* !defined(_MSC_VER) */ + + +#endif diff --git a/mesalib/include/c99_compat.h b/mesalib/include/c99_compat.h index e5d0ae43a..f56f6f326 100644 --- a/mesalib/include/c99_compat.h +++ b/mesalib/include/c99_compat.h @@ -33,6 +33,11 @@ * MSVC hacks. */ #if defined(_MSC_VER) + +# if _MSC_VER < 1500 +# error "Microsoft Visual Studio 2008 or higher required" +# endif + /* * Visual Studio 2012 will complain if we define the `inline` keyword, but * actually it only supports the keyword on C++. @@ -116,11 +121,7 @@ # elif defined(__GNUC__) # define __func__ __FUNCTION__ # elif defined(_MSC_VER) -# if _MSC_VER >= 1300 -# define __func__ __FUNCTION__ -# else -# define __func__ "<unknown>" -# endif +# define __func__ __FUNCTION__ # else # define __func__ "<unknown>" # endif diff --git a/mesalib/include/c99_math.h b/mesalib/include/c99_math.h new file mode 100644 index 000000000..0a49950cf --- /dev/null +++ b/mesalib/include/c99_math.h @@ -0,0 +1,164 @@ +/************************************************************************** + * + * Copyright 2007-2015 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/** + * Wrapper for math.h which makes sure we have definitions of all the c99 + * functions. + */ + + +#ifndef _C99_MATH_H_ +#define _C99_MATH_H_ + +#include <math.h> +#include "c99_compat.h" + + +#if defined(_MSC_VER) + +/* This is to ensure that we get M_PI, etc. definitions */ +#if !defined(_USE_MATH_DEFINES) +#error _USE_MATH_DEFINES define required when building with MSVC +#endif + +#if _MSC_VER < 1800 +#define isfinite(x) _finite((double)(x)) +#define isnan(x) _isnan((double)(x)) +#endif /* _MSC_VER < 1800 */ + +#if _MSC_VER < 1800 +static inline double log2( double x ) +{ + const double invln2 = 1.442695041; + return log( x ) * invln2; +} + +static inline double +round(double x) +{ + return x >= 0.0 ? floor(x + 0.5) : ceil(x - 0.5); +} + +static inline float +roundf(float x) +{ + return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f); +} +#endif + +#ifndef INFINITY +#define INFINITY (DBL_MAX + DBL_MAX) +#endif + +#ifndef NAN +#define NAN (INFINITY - INFINITY) +#endif + +#endif /* _MSC_VER */ + + +#if __STDC_VERSION__ < 199901L && (!defined(__cplusplus) || defined(_MSC_VER)) +static inline long int +lrint(double d) +{ + long int rounded = (long int)(d + 0.5); + + if (d - floor(d) == 0.5) { + if (rounded % 2 != 0) + rounded += (d > 0) ? -1 : 1; + } + + return rounded; +} + +static inline long int +lrintf(float f) +{ + long int rounded = (long int)(f + 0.5f); + + if (f - floorf(f) == 0.5f) { + if (rounded % 2 != 0) + rounded += (f > 0) ? -1 : 1; + } + + return rounded; +} + +static inline long long int +llrint(double d) +{ + long long int rounded = (long long int)(d + 0.5); + + if (d - floor(d) == 0.5) { + if (rounded % 2 != 0) + rounded += (d > 0) ? -1 : 1; + } + + return rounded; +} + +static inline long long int +llrintf(float f) +{ + long long int rounded = (long long int)(f + 0.5f); + + if (f - floorf(f) == 0.5f) { + if (rounded % 2 != 0) + rounded += (f > 0) ? -1 : 1; + } + + return rounded; +} +#endif /* C99 */ + + +/* + * signbit() is a macro on Linux. Not available on Windows. + */ +#ifndef signbit +#define signbit(x) ((x) < 0.0f) +#endif + + +#ifndef M_PI +#define M_PI (3.14159265358979323846) +#endif + +#ifndef M_E +#define M_E (2.7182818284590452354) +#endif + +#ifndef M_LOG2E +#define M_LOG2E (1.4426950408889634074) +#endif + +#ifndef FLT_MAX_EXP +#define FLT_MAX_EXP 128 +#endif + + +#endif /* #define _C99_MATH_H_ */ diff --git a/mesalib/install-lib-links.mk b/mesalib/install-lib-links.mk index 3545b268e..5fe9141d3 100644 --- a/mesalib/install-lib-links.mk +++ b/mesalib/install-lib-links.mk @@ -19,6 +19,7 @@ clean-local: for f in $(notdir $(lib_LTLIBRARIES:%.la=.libs/%.$(LIB_EXT)*)); do \ $(RM) $(top_builddir)/$(LIB_DIR)/$$f; \ done; + $(RM) .install-mesa-links endif endif diff --git a/mesalib/scons/gallium.py b/mesalib/scons/gallium.py index 519550871..7533f0651 100644 --- a/mesalib/scons/gallium.py +++ b/mesalib/scons/gallium.py @@ -87,6 +87,25 @@ def createInstallMethods(env): env.AddMethod(install_shared_library, 'InstallSharedLibrary') +def msvc2013_compat(env): + if env['gcc']: + env.Append(CCFLAGS = [ + '-Werror=vla', + '-Werror=pointer-arith', + ]) + +def msvc2008_compat(env): + msvc2013_compat(env) + if env['gcc']: + env.Append(CFLAGS = [ + '-Werror=declaration-after-statement', + ]) + +def createMSVCCompatMethods(env): + env.AddMethod(msvc2013_compat, 'MSVC2013Compat') + env.AddMethod(msvc2008_compat, 'MSVC2008Compat') + + def num_jobs(): try: return int(os.environ['NUMBER_OF_PROCESSORS']) @@ -283,6 +302,7 @@ def generate(env): '_SVID_SOURCE', '_BSD_SOURCE', '_GNU_SOURCE', + '_DEFAULT_SOURCE', 'HAVE_PTHREAD', 'HAVE_POSIX_MEMALIGN', ] @@ -342,6 +362,25 @@ def generate(env): print 'warning: Floating-point textures enabled.' print 'warning: Please consult docs/patents.txt with your lawyer before building Mesa.' cppdefines += ['TEXTURE_FLOAT_ENABLED'] + if gcc_compat: + ccversion = env['CCVERSION'] + cppdefines += [ + 'HAVE___BUILTIN_EXPECT', + 'HAVE___BUILTIN_FFS', + 'HAVE___BUILTIN_FFSLL', + 'HAVE_FUNC_ATTRIBUTE_FLATTEN', + # GCC 3.0 + 'HAVE_FUNC_ATTRIBUTE_FORMAT', + 'HAVE_FUNC_ATTRIBUTE_PACKED', + # GCC 3.4 + 'HAVE___BUILTIN_CTZ', + 'HAVE___BUILTIN_POPCOUNT', + 'HAVE___BUILTIN_POPCOUNTLL', + 'HAVE___BUILTIN_CLZ', + 'HAVE___BUILTIN_CLZLL', + ] + if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.5'): + cppdefines += ['HAVE___BUILTIN_UNREACHABLE'] env.Append(CPPDEFINES = cppdefines) # C compiler options @@ -377,8 +416,7 @@ def generate(env): '-m32', #'-march=pentium4', ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2') \ - and platform != 'haiku': + if platform != 'haiku': # NOTE: We need to ensure stack is realigned given that we # produce shared objects, and have no control over the stack # alignment policy of the application. Therefore we need @@ -419,13 +457,6 @@ def generate(env): '-Wmissing-prototypes', '-std=gnu99', ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'): - ccflags += [ - '-Wpointer-arith', - ] - cflags += [ - '-Wdeclaration-after-statement', - ] if icc: cflags += [ '-std=gnu99', @@ -584,30 +615,6 @@ def generate(env): env.Append(CCFLAGS = ['-fopenmp']) env.Append(LIBS = ['gomp']) - if gcc_compat: - ccversion = env['CCVERSION'] - cppdefines += [ - 'HAVE___BUILTIN_EXPECT', - 'HAVE___BUILTIN_FFS', - 'HAVE___BUILTIN_FFSLL', - 'HAVE_FUNC_ATTRIBUTE_FLATTEN', - ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('3'): - cppdefines += [ - 'HAVE_FUNC_ATTRIBUTE_FORMAT', - 'HAVE_FUNC_ATTRIBUTE_PACKED', - ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('3.4'): - cppdefines += [ - 'HAVE___BUILTIN_CTZ', - 'HAVE___BUILTIN_POPCOUNT', - 'HAVE___BUILTIN_POPCOUNTLL', - 'HAVE___BUILTIN_CLZ', - 'HAVE___BUILTIN_CLZLL', - ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.5'): - cppdefines += ['HAVE___BUILTIN_UNREACHABLE'] - # Load tools env.Tool('lex') env.Tool('yacc') @@ -617,6 +624,7 @@ def generate(env): # Custom builders and methods env.Tool('custom') createInstallMethods(env) + createMSVCCompatMethods(env) env.PkgCheckModules('X11', ['x11', 'xext', 'xdamage', 'xfixes', 'glproto >= 1.4.13']) env.PkgCheckModules('XCB', ['x11-xcb', 'xcb-glx >= 1.8.1', 'xcb-dri2 >= 1.8']) diff --git a/mesalib/src/SConscript b/mesalib/src/SConscript index c25adc728..188ab08b6 100644 --- a/mesalib/src/SConscript +++ b/mesalib/src/SConscript @@ -27,8 +27,6 @@ if env['platform'] in ['haiku']: SConscript('mesa/SConscript') -SConscript('mapi/vgapi/SConscript') - if not env['embedded']: if env['platform'] not in ('cygwin', 'darwin', 'freebsd', 'haiku', 'windows'): SConscript('glx/SConscript') diff --git a/mesalib/src/gallium/Android.mk b/mesalib/src/gallium/Android.mk index bf99e4fb6..b2662ffca 100644 --- a/mesalib/src/gallium/Android.mk +++ b/mesalib/src/gallium/Android.mk @@ -79,10 +79,5 @@ ifneq ($(filter vmwgfx, $(MESA_GPU_DRIVERS)),) SUBDIRS += winsys/svga/drm drivers/svga endif -# -# Gallium state trackers and their users (targets) -# -SUBDIRS += state_trackers/egl targets/egl-static - mkfiles := $(patsubst %,$(GALLIUM_TOP)/%/Android.mk,$(SUBDIRS)) include $(mkfiles) diff --git a/mesalib/src/gallium/Makefile.am b/mesalib/src/gallium/Makefile.am index 6a2a86654..652cb1310 100644 --- a/mesalib/src/gallium/Makefile.am +++ b/mesalib/src/gallium/Makefile.am @@ -12,7 +12,6 @@ SUBDIRS += auxiliary SUBDIRS += \ drivers/galahad \ - drivers/identity \ drivers/noop \ drivers/trace \ drivers/rbug @@ -115,9 +114,7 @@ EXTRA_DIST = \ docs \ README.portability \ SConscript \ - state_trackers/egl \ state_trackers/gbm \ - targets/egl-static \ targets/gbm \ winsys/sw/gdi \ winsys/sw/hgl @@ -139,11 +136,6 @@ if HAVE_DRICOMMON SUBDIRS += state_trackers/dri targets/dri endif -## the egl target depends on vega -if HAVE_OPENVG -SUBDIRS += state_trackers/vega -endif - if HAVE_X11_DRIVER SUBDIRS += state_trackers/glx/xlib targets/libgl-xlib endif diff --git a/mesalib/src/gallium/SConscript b/mesalib/src/gallium/SConscript index 25d0af6f9..9b9011f7f 100644 --- a/mesalib/src/gallium/SConscript +++ b/mesalib/src/gallium/SConscript @@ -13,7 +13,6 @@ SConscript('auxiliary/SConscript') # These are common and work across all platforms SConscript([ 'drivers/galahad/SConscript', - 'drivers/identity/SConscript', 'drivers/llvmpipe/SConscript', 'drivers/rbug/SConscript', 'drivers/softpipe/SConscript', @@ -62,13 +61,6 @@ SConscript([ ]) if not env['embedded']: - SConscript('state_trackers/vega/SConscript') - if env['platform'] not in ('cygwin', 'darwin', 'freebsd', 'sunos'): - SConscript([ - 'state_trackers/egl/SConscript', - 'targets/egl-static/SConscript', - ]) - if env['x11']: SConscript([ 'state_trackers/glx/xlib/SConscript', diff --git a/mesalib/src/gallium/auxiliary/Makefile.am b/mesalib/src/gallium/auxiliary/Makefile.am index 4b6205797..27a8b3fe4 100644 --- a/mesalib/src/gallium/auxiliary/Makefile.am +++ b/mesalib/src/gallium/auxiliary/Makefile.am @@ -12,9 +12,12 @@ noinst_LTLIBRARIES = libgallium.la AM_CFLAGS = \ -I$(top_srcdir)/src/gallium/auxiliary/util \ $(GALLIUM_CFLAGS) \ - $(VISIBILITY_CFLAGS) + $(VISIBILITY_CFLAGS) \ + $(MSVC2008_COMPAT_CXXFLAGS) -AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS) +AM_CXXFLAGS = \ + $(VISIBILITY_CXXFLAGS) \ + $(MSVC2008_COMPAT_CXXFLAGS) libgallium_la_SOURCES = \ $(C_SOURCES) \ diff --git a/mesalib/src/gallium/auxiliary/SConscript b/mesalib/src/gallium/auxiliary/SConscript index 6cb6b8c65..d5fa880c7 100644 --- a/mesalib/src/gallium/auxiliary/SConscript +++ b/mesalib/src/gallium/auxiliary/SConscript @@ -8,6 +8,10 @@ env.Append(CPPPATH = [ 'util', ]) +env = env.Clone() + +env.MSVC2008Compat() + env.CodeGenerate( target = 'indices/u_indices_gen.c', script = 'indices/u_indices_gen.py', diff --git a/mesalib/src/gallium/auxiliary/util/u_debug.c b/mesalib/src/gallium/auxiliary/util/u_debug.c index d79f31ea9..2d2d049b2 100644 --- a/mesalib/src/gallium/auxiliary/util/u_debug.c +++ b/mesalib/src/gallium/auxiliary/util/u_debug.c @@ -402,31 +402,28 @@ void debug_print_format(const char *msg, unsigned fmt ) #endif - -static const struct debug_named_value pipe_prim_names[] = { -#ifdef DEBUG - DEBUG_NAMED_VALUE(PIPE_PRIM_POINTS), - DEBUG_NAMED_VALUE(PIPE_PRIM_LINES), - DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_LOOP), - DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_STRIP), - DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLES), - DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_STRIP), - DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_FAN), - DEBUG_NAMED_VALUE(PIPE_PRIM_QUADS), - DEBUG_NAMED_VALUE(PIPE_PRIM_QUAD_STRIP), - DEBUG_NAMED_VALUE(PIPE_PRIM_POLYGON), - DEBUG_NAMED_VALUE(PIPE_PRIM_LINES_ADJACENCY), - DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_STRIP_ADJACENCY), - DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLES_ADJACENCY), - DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY), -#endif - DEBUG_NAMED_VALUE_END -}; - - -const char *u_prim_name( unsigned prim ) +/** Return string name of given primitive type */ +const char * +u_prim_name(unsigned prim) { - return debug_dump_enum(pipe_prim_names, prim); + static const struct debug_named_value names[] = { + DEBUG_NAMED_VALUE(PIPE_PRIM_POINTS), + DEBUG_NAMED_VALUE(PIPE_PRIM_LINES), + DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_LOOP), + DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_STRIP), + DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLES), + DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_STRIP), + DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_FAN), + DEBUG_NAMED_VALUE(PIPE_PRIM_QUADS), + DEBUG_NAMED_VALUE(PIPE_PRIM_QUAD_STRIP), + DEBUG_NAMED_VALUE(PIPE_PRIM_POLYGON), + DEBUG_NAMED_VALUE(PIPE_PRIM_LINES_ADJACENCY), + DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_STRIP_ADJACENCY), + DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLES_ADJACENCY), + DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY), + DEBUG_NAMED_VALUE_END + }; + return debug_dump_enum(names, prim); } @@ -722,38 +719,75 @@ error1: void debug_print_transfer_flags(const char *msg, unsigned usage) { -#define FLAG(x) { x, #x } - static const struct { - unsigned bit; - const char *name; - } flags[] = { - FLAG(PIPE_TRANSFER_READ), - FLAG(PIPE_TRANSFER_WRITE), - FLAG(PIPE_TRANSFER_MAP_DIRECTLY), - FLAG(PIPE_TRANSFER_DISCARD_RANGE), - FLAG(PIPE_TRANSFER_DONTBLOCK), - FLAG(PIPE_TRANSFER_UNSYNCHRONIZED), - FLAG(PIPE_TRANSFER_FLUSH_EXPLICIT), - FLAG(PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) + static const struct debug_named_value names[] = { + DEBUG_NAMED_VALUE(PIPE_TRANSFER_READ), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_WRITE), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_MAP_DIRECTLY), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_DISCARD_RANGE), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_DONTBLOCK), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_UNSYNCHRONIZED), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_FLUSH_EXPLICIT), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_PERSISTENT), + DEBUG_NAMED_VALUE(PIPE_TRANSFER_COHERENT), + DEBUG_NAMED_VALUE_END }; - unsigned i; - debug_printf("%s ", msg); + debug_printf("%s: %s\n", msg, debug_dump_flags(names, usage)); +} - for (i = 0; i < Elements(flags); i++) { - if (usage & flags[i].bit) { - debug_printf("%s", flags[i].name); - usage &= ~flags[i].bit; - if (usage) { - debug_printf(" | "); - } - } - } - debug_printf("\n"); -#undef FLAG +/** + * Print PIPE_BIND_x flags with a message. + */ +void +debug_print_bind_flags(const char *msg, unsigned usage) +{ + static const struct debug_named_value names[] = { + DEBUG_NAMED_VALUE(PIPE_BIND_DEPTH_STENCIL), + DEBUG_NAMED_VALUE(PIPE_BIND_RENDER_TARGET), + DEBUG_NAMED_VALUE(PIPE_BIND_BLENDABLE), + DEBUG_NAMED_VALUE(PIPE_BIND_SAMPLER_VIEW), + DEBUG_NAMED_VALUE(PIPE_BIND_VERTEX_BUFFER), + DEBUG_NAMED_VALUE(PIPE_BIND_INDEX_BUFFER), + DEBUG_NAMED_VALUE(PIPE_BIND_CONSTANT_BUFFER), + DEBUG_NAMED_VALUE(PIPE_BIND_DISPLAY_TARGET), + DEBUG_NAMED_VALUE(PIPE_BIND_TRANSFER_WRITE), + DEBUG_NAMED_VALUE(PIPE_BIND_TRANSFER_READ), + DEBUG_NAMED_VALUE(PIPE_BIND_STREAM_OUTPUT), + DEBUG_NAMED_VALUE(PIPE_BIND_CURSOR), + DEBUG_NAMED_VALUE(PIPE_BIND_CUSTOM), + DEBUG_NAMED_VALUE(PIPE_BIND_GLOBAL), + DEBUG_NAMED_VALUE(PIPE_BIND_SHADER_RESOURCE), + DEBUG_NAMED_VALUE(PIPE_BIND_COMPUTE_RESOURCE), + DEBUG_NAMED_VALUE(PIPE_BIND_COMMAND_ARGS_BUFFER), + DEBUG_NAMED_VALUE(PIPE_BIND_SCANOUT), + DEBUG_NAMED_VALUE(PIPE_BIND_SHARED), + DEBUG_NAMED_VALUE(PIPE_BIND_LINEAR), + DEBUG_NAMED_VALUE_END + }; + + debug_printf("%s: %s\n", msg, debug_dump_flags(names, usage)); } +/** + * Print PIPE_USAGE_x enum values with a message. + */ +void +debug_print_usage_enum(const char *msg, unsigned usage) +{ + static const struct debug_named_value names[] = { + DEBUG_NAMED_VALUE(PIPE_USAGE_DEFAULT), + DEBUG_NAMED_VALUE(PIPE_USAGE_IMMUTABLE), + DEBUG_NAMED_VALUE(PIPE_USAGE_DYNAMIC), + DEBUG_NAMED_VALUE(PIPE_USAGE_STREAM), + DEBUG_NAMED_VALUE(PIPE_USAGE_STAGING), + DEBUG_NAMED_VALUE_END + }; + + debug_printf("%s: %s\n", msg, debug_dump_enum(names, usage)); +} + #endif diff --git a/mesalib/src/gallium/auxiliary/util/u_debug.h b/mesalib/src/gallium/auxiliary/util/u_debug.h index 4c22fdfb6..3b2255244 100644 --- a/mesalib/src/gallium/auxiliary/util/u_debug.h +++ b/mesalib/src/gallium/auxiliary/util/u_debug.h @@ -467,6 +467,12 @@ void debug_dump_float_rgba_bmp(const char *filename, void debug_print_transfer_flags(const char *msg, unsigned usage); +void +debug_print_bind_flags(const char *msg, unsigned usage); + +void +debug_print_usage_enum(const char *msg, unsigned usage); + #ifdef __cplusplus } diff --git a/mesalib/src/gallium/auxiliary/util/u_format_other.c b/mesalib/src/gallium/auxiliary/util/u_format_other.c index 85001c14f..20752d469 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_other.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_other.c @@ -42,10 +42,7 @@ util_format_r9g9b9e5_float_unpack_rgba_float(float *dst_row, unsigned dst_stride float *dst = dst_row; const uint8_t *src = src_row; for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*(const uint32_t *)src); rgb9e5_to_float3(value, dst); dst[3] = 1; /* a */ src += 4; @@ -66,10 +63,7 @@ util_format_r9g9b9e5_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride const float *src = src_row; uint8_t *dst = dst_row; for(x = 0; x < width; x += 1) { - uint32_t value = float3_to_rgb9e5(src); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(float3_to_rgb9e5(src)); *(uint32_t *)dst = value; src += 4; dst += 4; @@ -83,10 +77,7 @@ void util_format_r9g9b9e5_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*(const uint32_t *)src); rgb9e5_to_float3(value, dst); dst[3] = 1; /* a */ } @@ -103,10 +94,7 @@ util_format_r9g9b9e5_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_str uint8_t *dst = dst_row; const uint8_t *src = src_row; for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*(const uint32_t *)src); rgb9e5_to_float3(value, p); dst[0] = float_to_ubyte(p[0]); /* r */ dst[1] = float_to_ubyte(p[1]); /* g */ @@ -136,10 +124,7 @@ util_format_r9g9b9e5_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_strid p[0] = ubyte_to_float(src[0]); p[1] = ubyte_to_float(src[1]); p[2] = ubyte_to_float(src[2]); - value = float3_to_rgb9e5(p); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(float3_to_rgb9e5(p)); *(uint32_t *)dst = value; src += 4; dst += 4; @@ -160,10 +145,7 @@ util_format_r11g11b10_float_unpack_rgba_float(float *dst_row, unsigned dst_strid float *dst = dst_row; const uint8_t *src = src_row; for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*(const uint32_t *)src); r11g11b10f_to_float3(value, dst); dst[3] = 1; /* a */ src += 4; @@ -184,10 +166,7 @@ util_format_r11g11b10_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid const float *src = src_row; uint8_t *dst = dst_row; for(x = 0; x < width; x += 1) { - uint32_t value = float3_to_r11g11b10f(src); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(float3_to_r11g11b10f(src)); *(uint32_t *)dst = value; src += 4; dst += 4; @@ -201,10 +180,7 @@ void util_format_r11g11b10_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*(const uint32_t *)src); r11g11b10f_to_float3(value, dst); dst[3] = 1; /* a */ } @@ -221,10 +197,7 @@ util_format_r11g11b10_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st uint8_t *dst = dst_row; const uint8_t *src = src_row; for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*(const uint32_t *)src); r11g11b10f_to_float3(value, p); dst[0] = float_to_ubyte(p[0]); /* r */ dst[1] = float_to_ubyte(p[1]); /* g */ @@ -254,10 +227,7 @@ util_format_r11g11b10_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri p[0] = ubyte_to_float(src[0]); p[1] = ubyte_to_float(src[1]); p[2] = ubyte_to_float(src[2]); - value = float3_to_r11g11b10f(p); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(float3_to_r11g11b10f(p)); *(uint32_t *)dst = value; src += 4; dst += 4; @@ -338,13 +308,9 @@ util_format_r8g8bx_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, float *dst = dst_row; const uint16_t *src = (const uint16_t *)src_row; for(x = 0; x < width; x += 1) { - uint16_t value = *src++; + uint16_t value = util_cpu_to_le16(*src++); int16_t r, g; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - r = ((int16_t)(value << 8)) >> 8; g = ((int16_t)(value << 0)) >> 8; @@ -370,13 +336,9 @@ util_format_r8g8bx_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_strid uint8_t *dst = dst_row; const uint16_t *src = (const uint16_t *)src_row; for(x = 0; x < width; x += 1) { - uint16_t value = *src++; + uint16_t value = util_cpu_to_le16(*src++); int16_t r, g; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - r = ((int16_t)(value << 8)) >> 8; g = ((int16_t)(value << 0)) >> 8; @@ -407,11 +369,7 @@ util_format_r8g8bx_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= (uint16_t)(((int8_t)(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ; value |= (uint16_t)((((int8_t)(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - - *dst++ = value; + *dst++ = util_le16_to_cpu(value); src += 4; } @@ -437,11 +395,7 @@ util_format_r8g8bx_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= src[0] >> 1; value |= (src[1] >> 1) << 8; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - - *dst++ = value; + *dst++ = util_le16_to_cpu(value); src += 4; } @@ -455,13 +409,9 @@ void util_format_r8g8bx_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) { - uint16_t value = *(const uint16_t *)src; + uint16_t value = util_cpu_to_le16(*(const uint16_t *)src); int16_t r, g; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - r = ((int16_t)(value << 8)) >> 8; g = ((int16_t)(value << 0)) >> 8; diff --git a/mesalib/src/gallium/auxiliary/util/u_format_yuv.c b/mesalib/src/gallium/auxiliary/util/u_format_yuv.c index 891d99cf6..16ed8af7b 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_yuv.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_yuv.c @@ -52,11 +52,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid float r, g0, g1, b; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); r = ubyte_to_float((value >> 0) & 0xff); g0 = ubyte_to_float((value >> 8) & 0xff); @@ -77,11 +73,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); r = ubyte_to_float((value >> 0) & 0xff); g0 = ubyte_to_float((value >> 8) & 0xff); @@ -114,11 +106,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st uint8_t r, g0, g1, b; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); r = (value >> 0) & 0xff; g0 = (value >> 8) & 0xff; @@ -139,11 +127,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); r = (value >> 0) & 0xff; g0 = (value >> 8) & 0xff; @@ -186,11 +170,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid value |= float_to_ubyte(b) << 16; value |= float_to_ubyte(g1) << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -206,11 +186,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid value |= float_to_ubyte(b) << 16; value |= float_to_ubyte(g1) << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -243,11 +219,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri value |= b << 16; value |= g1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -263,11 +235,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri value |= b << 16; value |= g1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -304,11 +272,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid float r, g0, g1, b; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); g0 = ubyte_to_float((value >> 0) & 0xff); r = ubyte_to_float((value >> 8) & 0xff); @@ -329,11 +293,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); g0 = ubyte_to_float((value >> 0) & 0xff); r = ubyte_to_float((value >> 8) & 0xff); @@ -366,11 +326,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st uint8_t r, g0, g1, b; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); g0 = (value >> 0) & 0xff; r = (value >> 8) & 0xff; @@ -391,11 +347,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); g0 = (value >> 0) & 0xff; r = (value >> 8) & 0xff; @@ -438,11 +390,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid value |= float_to_ubyte(g1) << 16; value |= float_to_ubyte(b) << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -458,11 +406,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid value |= float_to_ubyte(g1) << 16; value |= float_to_ubyte(b) << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -495,11 +439,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri value |= g1 << 16; value |= b << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -515,11 +455,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri value |= g1 << 16; value |= b << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -556,11 +492,7 @@ util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride, uint8_t y0, y1, u, v; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); u = (value >> 0) & 0xff; y0 = (value >> 8) & 0xff; @@ -577,11 +509,7 @@ util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride, } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); u = (value >> 0) & 0xff; y0 = (value >> 8) & 0xff; @@ -612,11 +540,7 @@ util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, uint8_t y0, y1, u, v; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); u = (value >> 0) & 0xff; y0 = (value >> 8) & 0xff; @@ -633,11 +557,7 @@ util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); u = (value >> 0) & 0xff; y0 = (value >> 8) & 0xff; @@ -683,11 +603,7 @@ util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= v << 16; value |= y1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -702,11 +618,7 @@ util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= v << 16; value |= y1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -744,11 +656,7 @@ util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= v << 16; value |= y1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -763,11 +671,7 @@ util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= v << 16; value |= y1 << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -809,11 +713,7 @@ util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride, uint8_t y0, y1, u, v; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); y0 = (value >> 0) & 0xff; u = (value >> 8) & 0xff; @@ -830,11 +730,7 @@ util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride, } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); y0 = (value >> 0) & 0xff; u = (value >> 8) & 0xff; @@ -865,11 +761,7 @@ util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, uint8_t y0, y1, u, v; for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src++); y0 = (value >> 0) & 0xff; u = (value >> 8) & 0xff; @@ -886,11 +778,7 @@ util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, } if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + value = util_cpu_to_le32(*src); y0 = (value >> 0) & 0xff; u = (value >> 8) & 0xff; @@ -936,11 +824,7 @@ util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= y1 << 16; value |= v << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -955,11 +839,7 @@ util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= y1 << 16; value |= v << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); @@ -997,11 +877,7 @@ util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= y1 << 16; value |= v << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; + *dst++ = util_le32_to_cpu(value); src += 8; } @@ -1016,11 +892,7 @@ util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= y1 << 16; value |= v << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; + *dst = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); diff --git a/mesalib/src/gallium/auxiliary/util/u_format_zs.c b/mesalib/src/gallium/auxiliary/util/u_format_zs.c index ed45c52f9..f1ed32f1d 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_zs.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_zs.c @@ -147,10 +147,7 @@ util_format_z16_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, float *dst = dst_row; const uint16_t *src = (const uint16_t *)src_row; for(x = 0; x < width; ++x) { - uint16_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif + uint16_t value = util_cpu_to_le16(*src++); *dst++ = z16_unorm_to_z32_float(value); } src_row += src_stride/sizeof(*src_row); @@ -170,10 +167,7 @@ util_format_z16_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, for(x = 0; x < width; ++x) { uint16_t value; value = z32_float_to_z16_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - *dst++ = value; + *dst++ = util_le16_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -190,10 +184,7 @@ util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, uint32_t *dst = dst_row; const uint16_t *src = (const uint16_t *)src_row; for(x = 0; x < width; ++x) { - uint16_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif + uint16_t value = util_cpu_to_le16(*src++); *dst++ = z16_unorm_to_z32_unorm(value); } src_row += src_stride/sizeof(*src_row); @@ -213,10 +204,7 @@ util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, for(x = 0; x < width; ++x) { uint16_t value; value = z32_unorm_to_z16_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - *dst++ = value; + *dst++ = util_le16_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -233,10 +221,7 @@ util_format_z32_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, float *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z32_unorm_to_z32_float(value); } src_row += src_stride/sizeof(*src_row); @@ -256,10 +241,7 @@ util_format_z32_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, for(x = 0; x < width; ++x) { uint32_t value; value = z32_float_to_z32_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -362,10 +344,7 @@ util_format_z24_unorm_s8_uint_unpack_z_float(float *dst_row, unsigned dst_stride float *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_float(value & 0xffffff); } src_row += src_stride/sizeof(*src_row); @@ -383,16 +362,10 @@ util_format_z24_unorm_s8_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride const float *src = src_row; uint32_t *dst = (uint32_t *)dst_row; for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_le32_to_cpu(*dst); value &= 0xff000000; value |= z32_float_to_z24_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -409,10 +382,7 @@ util_format_z24_unorm_s8_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_s uint32_t *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_unorm(value & 0xffffff); } src_row += src_stride/sizeof(*src_row); @@ -430,16 +400,10 @@ util_format_z24_unorm_s8_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stri const uint32_t *src = src_row; uint32_t *dst = (uint32_t *)dst_row; for(x = 0; x < width; ++x) { - uint32_t value= *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_le32_to_cpu(*dst); value &= 0xff000000; value |= z32_unorm_to_z24_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -456,10 +420,7 @@ util_format_z24_unorm_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stri uint8_t *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = value >> 24; } src_row += src_stride/sizeof(*src_row); @@ -477,16 +438,10 @@ util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride const uint8_t *src = src_row; uint32_t *dst = (uint32_t *)dst_row; for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_le32_to_cpu(*dst); value &= 0x00ffffff; value |= *src++ << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -503,10 +458,7 @@ util_format_s8_uint_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride float *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_float(value >> 8); } src_row += src_stride/sizeof(*src_row); @@ -524,16 +476,10 @@ util_format_s8_uint_z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride const float *src = src_row; uint32_t *dst = (uint32_t *)dst_row; for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_le32_to_cpu(*dst); value &= 0x000000ff; value |= z32_float_to_z24_unorm(*src++) << 8; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -550,10 +496,7 @@ util_format_s8_uint_z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_s uint32_t *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_unorm(value >> 8); } src_row += src_stride/sizeof(*src_row); @@ -571,16 +514,10 @@ util_format_s8_uint_z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stri const uint32_t *src = src_row; uint32_t *dst = (uint32_t *)dst_row; for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_le32_to_cpu(*dst); value &= 0x000000ff; value |= *src++ & 0xffffff00; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -597,10 +534,7 @@ util_format_s8_uint_z24_unorm_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stri uint8_t *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = value & 0xff; } src_row += src_stride/sizeof(*src_row); @@ -618,16 +552,10 @@ util_format_s8_uint_z24_unorm_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride const uint8_t *src = src_row; uint32_t *dst = (uint32_t *)dst_row; for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_le32_to_cpu(*dst); value &= 0xffffff00; value |= *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -644,10 +572,7 @@ util_format_z24x8_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, float *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_float(value & 0xffffff); } src_row += src_stride/sizeof(*src_row); @@ -667,10 +592,7 @@ util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, for(x = 0; x < width; ++x) { uint32_t value; value = z32_float_to_z24_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_le32_to_cpu(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -687,10 +609,7 @@ util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, uint32_t *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_unorm(value & 0xffffff); } src_row += src_stride/sizeof(*src_row); @@ -710,10 +629,7 @@ util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, for(x = 0; x < width; ++x) { uint32_t value; value = z32_unorm_to_z24_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -730,10 +646,7 @@ util_format_x8z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, float *dst = dst_row; const uint32_t *src = (uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_float(value >> 8); } src_row += src_stride/sizeof(*src_row); @@ -753,10 +666,7 @@ util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, for(x = 0; x < width; ++x) { uint32_t value; value = z32_float_to_z24_unorm(*src++) << 8; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); @@ -773,10 +683,7 @@ util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, uint32_t *dst = dst_row; const uint32_t *src = (const uint32_t *)src_row; for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif + uint32_t value = util_cpu_to_le32(*src++); *dst++ = z24_unorm_to_z32_unorm(value >> 8); } src_row += src_stride/sizeof(*src_row); @@ -796,10 +703,7 @@ util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, for(x = 0; x < width; ++x) { uint32_t value; value = z32_unorm_to_z24_unorm(*src++) << 8; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; + *dst++ = util_cpu_to_le32(value); } dst_row += dst_stride/sizeof(*dst_row); src_row += src_stride/sizeof(*src_row); diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h index d6e83f962..8f62cac66 100644 --- a/mesalib/src/gallium/auxiliary/util/u_math.h +++ b/mesalib/src/gallium/auxiliary/util/u_math.h @@ -41,13 +41,7 @@ #include "pipe/p_compiler.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#include <math.h> +#include "c99_math.h" #include <float.h> #include <stdarg.h> @@ -56,153 +50,15 @@ extern "C" { #endif -#ifndef M_SQRT2 -#define M_SQRT2 1.41421356237309504880 -#endif - - -#if defined(_MSC_VER) - -#if _MSC_VER < 1400 && !defined(__cplusplus) - -static INLINE float cosf( float f ) -{ - return (float) cos( (double) f ); -} - -static INLINE float sinf( float f ) -{ - return (float) sin( (double) f ); -} - -static INLINE float ceilf( float f ) -{ - return (float) ceil( (double) f ); -} - -static INLINE float floorf( float f ) -{ - return (float) floor( (double) f ); -} - -static INLINE float powf( float f, float g ) -{ - return (float) pow( (double) f, (double) g ); -} - -static INLINE float sqrtf( float f ) -{ - return (float) sqrt( (double) f ); -} - -static INLINE float fabsf( float f ) -{ - return (float) fabs( (double) f ); -} - -static INLINE float logf( float f ) -{ - return (float) log( (double) f ); -} - -#else -/* Work-around an extra semi-colon in VS 2005 logf definition */ -#ifdef logf -#undef logf -#define logf(x) ((float)log((double)(x))) -#endif /* logf */ - -#if _MSC_VER < 1800 -#define isfinite(x) _finite((double)(x)) -#define isnan(x) _isnan((double)(x)) -#endif /* _MSC_VER < 1800 */ -#endif /* _MSC_VER < 1400 && !defined(__cplusplus) */ - -#if _MSC_VER < 1800 -static INLINE double log2( double x ) -{ - const double invln2 = 1.442695041; - return log( x ) * invln2; -} - -static INLINE double -round(double x) -{ - return x >= 0.0 ? floor(x + 0.5) : ceil(x - 0.5); -} - -static INLINE float -roundf(float x) -{ - return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f); -} +#ifdef __cplusplus +extern "C" { #endif -#ifndef INFINITY -#define INFINITY (DBL_MAX + DBL_MAX) -#endif -#ifndef NAN -#define NAN (INFINITY - INFINITY) +#ifndef M_SQRT2 +#define M_SQRT2 1.41421356237309504880 #endif -#endif /* _MSC_VER */ - - -#if __STDC_VERSION__ < 199901L && (!defined(__cplusplus) || defined(_MSC_VER)) -static INLINE long int -lrint(double d) -{ - long int rounded = (long int)(d + 0.5); - - if (d - floor(d) == 0.5) { - if (rounded % 2 != 0) - rounded += (d > 0) ? -1 : 1; - } - - return rounded; -} - -static INLINE long int -lrintf(float f) -{ - long int rounded = (long int)(f + 0.5f); - - if (f - floorf(f) == 0.5f) { - if (rounded % 2 != 0) - rounded += (f > 0) ? -1 : 1; - } - - return rounded; -} - -static INLINE long long int -llrint(double d) -{ - long long int rounded = (long long int)(d + 0.5); - - if (d - floor(d) == 0.5) { - if (rounded % 2 != 0) - rounded += (d > 0) ? -1 : 1; - } - - return rounded; -} - -static INLINE long long int -llrintf(float f) -{ - long long int rounded = (long long int)(f + 0.5f); - - if (f - floorf(f) == 0.5f) { - if (rounded % 2 != 0) - rounded += (f > 0) ? -1 : 1; - } - - return rounded; -} -#endif /* C99 */ - #define POW2_TABLE_SIZE_LOG2 9 #define POW2_TABLE_SIZE (1 << POW2_TABLE_SIZE_LOG2) #define POW2_TABLE_OFFSET (POW2_TABLE_SIZE/2) @@ -499,7 +355,7 @@ util_half_inf_sign(int16_t x) #ifndef FFS_DEFINED #define FFS_DEFINED 1 -#if defined(_MSC_VER) && _MSC_VER >= 1300 && (_M_IX86 || _M_AMD64 || _M_IA64) +#if defined(_MSC_VER) && (_M_IX86 || _M_AMD64 || _M_IA64) unsigned char _BitScanForward(unsigned long* Index, unsigned long Mask); #pragma intrinsic(_BitScanForward) static INLINE @@ -541,7 +397,7 @@ unsigned ffs( unsigned u ) static INLINE unsigned util_last_bit(unsigned u) { -#if defined(__GNUC__) +#if defined(HAVE___BUILTIN_CLZ) return u == 0 ? 0 : 32 - __builtin_clz(u); #else unsigned r = 0; @@ -663,7 +519,7 @@ float_to_byte_tex(float f) static INLINE unsigned util_logbase2(unsigned n) { -#if defined(PIPE_CC_GCC) +#if defined(HAVE___BUILTIN_CLZ) return ((sizeof(unsigned) * 8 - 1) - __builtin_clz(n | 1)); #else unsigned pos = 0; @@ -683,7 +539,7 @@ util_logbase2(unsigned n) static INLINE unsigned util_next_power_of_two(unsigned x) { -#if defined(PIPE_CC_GCC) +#if defined(HAVE___BUILTIN_CLZ) if (x <= 1) return 1; @@ -715,7 +571,7 @@ util_next_power_of_two(unsigned x) static INLINE unsigned util_bitcount(unsigned n) { -#if defined(PIPE_CC_GCC) +#if defined(HAVE___BUILTIN_POPCOUNT) return __builtin_popcount(n); #else /* K&R classic bitcount. @@ -724,8 +580,8 @@ util_bitcount(unsigned n) * Requires only one iteration per set bit, instead of * one iteration per bit less than highest set bit. */ - unsigned bits = 0; - for (bits; n; bits++) { + unsigned bits; + for (bits = 0; n; bits++) { n &= n - 1; } return bits; @@ -784,8 +640,7 @@ util_bitreverse(unsigned n) static INLINE uint32_t util_bswap32(uint32_t n) { -/* We need the gcc version checks for non-autoconf build system */ -#if defined(HAVE___BUILTIN_BSWAP32) || (defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 403)) +#if defined(HAVE___BUILTIN_BSWAP32) return __builtin_bswap32(n); #else return (n >> 24) | diff --git a/mesalib/src/gallium/auxiliary/util/u_sse.h b/mesalib/src/gallium/auxiliary/util/u_sse.h index 642f96eb7..d4f51912a 100644 --- a/mesalib/src/gallium/auxiliary/util/u_sse.h +++ b/mesalib/src/gallium/auxiliary/util/u_sse.h @@ -44,33 +44,6 @@ #include <emmintrin.h> -/* MSVC before VC8 does not support the _mm_castxxx_yyy */ -#if defined(_MSC_VER) && _MSC_VER < 1500 - -union __declspec(align(16)) m128_types { - __m128 m128; - __m128i m128i; - __m128d m128d; -}; - -static __inline __m128 -_mm_castsi128_ps(__m128i a) -{ - union m128_types u; - u.m128i = a; - return u.m128; -} - -static __inline __m128i -_mm_castps_si128(__m128 a) -{ - union m128_types u; - u.m128 = a; - return u.m128i; -} - -#endif /* defined(_MSC_VER) && _MSC_VER < 1500 */ - union m128i { __m128i m; ubyte ub[16]; diff --git a/mesalib/src/glsl/Makefile.am b/mesalib/src/glsl/Makefile.am index 5a0a643da..b466a3b5c 100644 --- a/mesalib/src/glsl/Makefile.am +++ b/mesalib/src/glsl/Makefile.am @@ -33,8 +33,12 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/gtest/include \ -I$(top_builddir)/src/glsl/nir \ $(DEFINES) -AM_CFLAGS = $(VISIBILITY_CFLAGS) -AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS) +AM_CFLAGS = \ + $(VISIBILITY_CFLAGS) \ + $(MSVC2013_COMPAT_CFLAGS) +AM_CXXFLAGS = \ + $(VISIBILITY_CXXFLAGS) \ + $(MSVC2013_COMPAT_CXXFLAGS) EXTRA_DIST = tests glcpp/tests README TODO glcpp/README \ glsl_lexer.ll \ diff --git a/mesalib/src/glsl/Makefile.sources b/mesalib/src/glsl/Makefile.sources index d0210d170..b876642e8 100644 --- a/mesalib/src/glsl/Makefile.sources +++ b/mesalib/src/glsl/Makefile.sources @@ -157,6 +157,7 @@ LIBGLSL_FILES = \ lower_ubo_reference.cpp \ opt_algebraic.cpp \ opt_array_splitting.cpp \ + opt_conditional_discard.cpp \ opt_constant_folding.cpp \ opt_constant_propagation.cpp \ opt_constant_variable.cpp \ diff --git a/mesalib/src/glsl/SConscript b/mesalib/src/glsl/SConscript index 21c8266a6..26de455f0 100644 --- a/mesalib/src/glsl/SConscript +++ b/mesalib/src/glsl/SConscript @@ -6,6 +6,8 @@ from sys import executable as python_cmd env = env.Clone() +env.MSVC2013Compat() + env.Prepend(CPPPATH = [ '#include', '#src', diff --git a/mesalib/src/glsl/ast_array_index.cpp b/mesalib/src/glsl/ast_array_index.cpp index ff0c7576d..ecef651f7 100644 --- a/mesalib/src/glsl/ast_array_index.cpp +++ b/mesalib/src/glsl/ast_array_index.cpp @@ -83,11 +83,9 @@ update_max_array_access(ir_rvalue *ir, int idx, YYLTYPE *loc, if (deref_var != NULL) { if (deref_var->var->is_interface_instance()) { - const glsl_type *interface_type = - deref_var->var->get_interface_type(); unsigned field_index = deref_record->record->type->field_index(deref_record->field); - assert(field_index < interface_type->length); + assert(field_index < deref_var->var->get_interface_type()->length); unsigned *const max_ifc_array_access = deref_var->var->get_max_ifc_array_access(); diff --git a/mesalib/src/glsl/builtin_functions.cpp b/mesalib/src/glsl/builtin_functions.cpp index b643927d0..84bbdc2a4 100644 --- a/mesalib/src/glsl/builtin_functions.cpp +++ b/mesalib/src/glsl/builtin_functions.cpp @@ -2549,7 +2549,7 @@ builtin_builder::add_image_function(const char *name, }; ir_function *f = new(mem_ctx) ir_function(name); - for (unsigned i = 0; i < Elements(types); ++i) { + for (unsigned i = 0; i < ARRAY_SIZE(types); ++i) { if (types[i]->sampler_type != GLSL_TYPE_FLOAT || (flags & IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE)) f->add_signature(_image(types[i], intrinsic_name, diff --git a/mesalib/src/glsl/builtin_variables.cpp b/mesalib/src/glsl/builtin_variables.cpp index 65e32ad73..21e7331c7 100644 --- a/mesalib/src/glsl/builtin_variables.cpp +++ b/mesalib/src/glsl/builtin_variables.cpp @@ -227,7 +227,7 @@ static const struct gl_builtin_uniform_element gl_NormalMatrix_elements[] = { #undef MATRIX -#define STATEVAR(name) {#name, name ## _elements, Elements(name ## _elements)} +#define STATEVAR(name) {#name, name ## _elements, ARRAY_SIZE(name ## _elements)} static const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = { STATEVAR(gl_NumSamples), diff --git a/mesalib/src/glsl/glcpp/pp.c b/mesalib/src/glsl/glcpp/pp.c index a54bcbe16..160c6662f 100644 --- a/mesalib/src/glsl/glcpp/pp.c +++ b/mesalib/src/glsl/glcpp/pp.c @@ -25,7 +25,6 @@ #include <string.h> #include <ctype.h> #include "glcpp.h" -#include "main/core.h" /* for isblank() on MSVC */ void glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy index ea3bd8a24..90c216ed9 100644 --- a/mesalib/src/glsl/glsl_parser.yy +++ b/mesalib/src/glsl/glsl_parser.yy @@ -1280,7 +1280,7 @@ layout_qualifier_id: { "triangles_adjacency", GL_TRIANGLES_ADJACENCY }, { "triangle_strip", GL_TRIANGLE_STRIP }, }; - for (unsigned i = 0; i < Elements(map); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(map); i++) { if (match_layout_qualifier($1, map[i].s, state) == 0) { $$.flags.q.prim_type = 1; $$.prim_type = map[i].e; @@ -1344,7 +1344,7 @@ layout_qualifier_id: { "r8_snorm", GL_R8_SNORM, GLSL_TYPE_FLOAT } }; - for (unsigned i = 0; i < Elements(map); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(map); i++) { if (match_layout_qualifier($1, map[i].name, state) == 0) { $$.flags.q.explicit_image_format = 1; $$.image_format = map[i].format; diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp index 9f7931380..79624bc26 100644 --- a/mesalib/src/glsl/glsl_parser_extras.cpp +++ b/mesalib/src/glsl/glsl_parser_extras.cpp @@ -119,9 +119,9 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, this->Const.MaxAtomicBufferBindings = ctx->Const.MaxAtomicBufferBindings; /* Compute shader constants */ - for (unsigned i = 0; i < Elements(this->Const.MaxComputeWorkGroupCount); i++) + for (unsigned i = 0; i < ARRAY_SIZE(this->Const.MaxComputeWorkGroupCount); i++) this->Const.MaxComputeWorkGroupCount[i] = ctx->Const.MaxComputeWorkGroupCount[i]; - for (unsigned i = 0; i < Elements(this->Const.MaxComputeWorkGroupSize); i++) + for (unsigned i = 0; i < ARRAY_SIZE(this->Const.MaxComputeWorkGroupSize); i++) this->Const.MaxComputeWorkGroupSize[i] = ctx->Const.MaxComputeWorkGroupSize[i]; this->Const.MaxImageUnits = ctx->Const.MaxImageUnits; @@ -636,7 +636,7 @@ void _mesa_glsl_extension::set_flags(_mesa_glsl_parse_state *state, */ static const _mesa_glsl_extension *find_extension(const char *name) { - for (unsigned i = 0; i < Elements(_mesa_glsl_supported_extensions); ++i) { + for (unsigned i = 0; i < ARRAY_SIZE(_mesa_glsl_supported_extensions); ++i) { if (strcmp(name, _mesa_glsl_supported_extensions[i].name) == 0) { return &_mesa_glsl_supported_extensions[i]; } @@ -674,7 +674,7 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, return false; } else { for (unsigned i = 0; - i < Elements(_mesa_glsl_supported_extensions); ++i) { + i < ARRAY_SIZE(_mesa_glsl_supported_extensions); ++i) { const _mesa_glsl_extension *extension = &_mesa_glsl_supported_extensions[i]; if (extension->compatible_with_state(state)) { @@ -1627,6 +1627,7 @@ do_common_optimization(exec_list *ir, bool linked, } progress = do_if_simplification(ir) || progress; progress = opt_flatten_nested_if_blocks(ir) || progress; + progress = opt_conditional_discard(ir) || progress; progress = do_copy_propagation(ir) || progress; progress = do_copy_propagation_elements(ir) || progress; diff --git a/mesalib/src/glsl/ir.cpp b/mesalib/src/glsl/ir.cpp index f4f92e9df..54656f899 100644 --- a/mesalib/src/glsl/ir.cpp +++ b/mesalib/src/glsl/ir.cpp @@ -618,8 +618,8 @@ static const char *const operator_strs[] = { const char *ir_expression::operator_string(ir_expression_operation op) { - assert((unsigned int) op < Elements(operator_strs)); - assert(Elements(operator_strs) == (ir_quadop_vector + 1)); + assert((unsigned int) op < ARRAY_SIZE(operator_strs)); + assert(ARRAY_SIZE(operator_strs) == (ir_quadop_vector + 1)); return operator_strs[op]; } @@ -1707,7 +1707,7 @@ const char *const ir_variable::warn_extension_table[] = { void ir_variable::enable_extension_warning(const char *extension) { - for (unsigned i = 0; i < Elements(warn_extension_table); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(warn_extension_table); i++) { if (strcmp(warn_extension_table[i], extension) == 0) { this->data.warn_extension_index = i; return; diff --git a/mesalib/src/glsl/ir_clone.cpp b/mesalib/src/glsl/ir_clone.cpp index 5c7279ca3..914e0e4d5 100644 --- a/mesalib/src/glsl/ir_clone.cpp +++ b/mesalib/src/glsl/ir_clone.cpp @@ -158,7 +158,7 @@ ir_call::clone(void *mem_ctx, struct hash_table *ht) const ir_expression * ir_expression::clone(void *mem_ctx, struct hash_table *ht) const { - ir_rvalue *op[Elements(this->operands)] = { NULL, }; + ir_rvalue *op[ARRAY_SIZE(this->operands)] = { NULL, }; unsigned int i; for (i = 0; i < get_num_operands(); i++) { diff --git a/mesalib/src/glsl/ir_constant_expression.cpp b/mesalib/src/glsl/ir_constant_expression.cpp index 07dd439d5..388c4c286 100644 --- a/mesalib/src/glsl/ir_constant_expression.cpp +++ b/mesalib/src/glsl/ir_constant_expression.cpp @@ -506,7 +506,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context) if (this->type->is_error()) return NULL; - ir_constant *op[Elements(this->operands)] = { NULL, }; + ir_constant *op[ARRAY_SIZE(this->operands)] = { NULL, }; ir_constant_data data; memset(&data, 0, sizeof(data)); diff --git a/mesalib/src/glsl/ir_optimization.h b/mesalib/src/glsl/ir_optimization.h index 7eb861ae5..e6939f3fe 100644 --- a/mesalib/src/glsl/ir_optimization.h +++ b/mesalib/src/glsl/ir_optimization.h @@ -77,6 +77,7 @@ bool do_common_optimization(exec_list *ir, bool linked, bool do_rebalance_tree(exec_list *instructions); bool do_algebraic(exec_list *instructions, bool native_integers, const struct gl_shader_compiler_options *options); +bool opt_conditional_discard(exec_list *instructions); bool do_constant_folding(exec_list *instructions); bool do_constant_variable(exec_list *instructions); bool do_constant_variable_unlinked(exec_list *instructions); diff --git a/mesalib/src/glsl/ir_rvalue_visitor.cpp b/mesalib/src/glsl/ir_rvalue_visitor.cpp index 34cdb1c98..2eee3da7b 100644 --- a/mesalib/src/glsl/ir_rvalue_visitor.cpp +++ b/mesalib/src/glsl/ir_rvalue_visitor.cpp @@ -135,6 +135,13 @@ ir_rvalue_base_visitor::rvalue_visit(ir_call *ir) } ir_visitor_status +ir_rvalue_base_visitor::rvalue_visit(ir_discard *ir) +{ + handle_rvalue(&ir->condition); + return visit_continue; +} + +ir_visitor_status ir_rvalue_base_visitor::rvalue_visit(ir_return *ir) { handle_rvalue(&ir->value);; @@ -205,6 +212,12 @@ ir_rvalue_visitor::visit_leave(ir_call *ir) } ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_discard *ir) +{ + return rvalue_visit(ir); +} + +ir_visitor_status ir_rvalue_visitor::visit_leave(ir_return *ir) { return rvalue_visit(ir); @@ -271,6 +284,12 @@ ir_rvalue_enter_visitor::visit_enter(ir_call *ir) } ir_visitor_status +ir_rvalue_enter_visitor::visit_enter(ir_discard *ir) +{ + return rvalue_visit(ir); +} + +ir_visitor_status ir_rvalue_enter_visitor::visit_enter(ir_return *ir) { return rvalue_visit(ir); diff --git a/mesalib/src/glsl/ir_rvalue_visitor.h b/mesalib/src/glsl/ir_rvalue_visitor.h index 04ec0fa39..185c72a5b 100644 --- a/mesalib/src/glsl/ir_rvalue_visitor.h +++ b/mesalib/src/glsl/ir_rvalue_visitor.h @@ -36,6 +36,7 @@ public: ir_visitor_status rvalue_visit(ir_call *); ir_visitor_status rvalue_visit(ir_dereference_array *); ir_visitor_status rvalue_visit(ir_dereference_record *); + ir_visitor_status rvalue_visit(ir_discard *); ir_visitor_status rvalue_visit(ir_expression *); ir_visitor_status rvalue_visit(ir_if *); ir_visitor_status rvalue_visit(ir_return *); @@ -54,6 +55,7 @@ public: virtual ir_visitor_status visit_leave(ir_call *); virtual ir_visitor_status visit_leave(ir_dereference_array *); virtual ir_visitor_status visit_leave(ir_dereference_record *); + virtual ir_visitor_status visit_leave(ir_discard *); virtual ir_visitor_status visit_leave(ir_expression *); virtual ir_visitor_status visit_leave(ir_if *); virtual ir_visitor_status visit_leave(ir_return *); @@ -70,6 +72,7 @@ public: virtual ir_visitor_status visit_enter(ir_call *); virtual ir_visitor_status visit_enter(ir_dereference_array *); virtual ir_visitor_status visit_enter(ir_dereference_record *); + virtual ir_visitor_status visit_enter(ir_discard *); virtual ir_visitor_status visit_enter(ir_expression *); virtual ir_visitor_status visit_enter(ir_if *); virtual ir_visitor_status visit_enter(ir_return *); diff --git a/mesalib/src/glsl/ir_validate.cpp b/mesalib/src/glsl/ir_validate.cpp index 667889480..7a7688cb2 100644 --- a/mesalib/src/glsl/ir_validate.cpp +++ b/mesalib/src/glsl/ir_validate.cpp @@ -61,6 +61,7 @@ public: virtual ir_visitor_status visit(ir_variable *v); virtual ir_visitor_status visit(ir_dereference_variable *ir); + virtual ir_visitor_status visit_enter(ir_discard *ir); virtual ir_visitor_status visit_enter(ir_if *ir); virtual ir_visitor_status visit_enter(ir_function *ir); @@ -133,6 +134,20 @@ ir_validate::visit_enter(class ir_dereference_array *ir) } ir_visitor_status +ir_validate::visit_enter(ir_discard *ir) +{ + if (ir->condition && ir->condition->type != glsl_type::bool_type) { + printf("ir_discard condition %s type instead of bool.\n", + ir->condition->type->name); + ir->print(); + printf("\n"); + abort(); + } + + return visit_continue; +} + +ir_visitor_status ir_validate::visit_enter(ir_if *ir) { if (ir->condition->type != glsl_type::bool_type) { diff --git a/mesalib/src/glsl/link_interface_blocks.cpp b/mesalib/src/glsl/link_interface_blocks.cpp index 0ce502d4f..07f5b4223 100644 --- a/mesalib/src/glsl/link_interface_blocks.cpp +++ b/mesalib/src/glsl/link_interface_blocks.cpp @@ -50,18 +50,20 @@ struct interface_block_definition * represents either the interface instance (for named interfaces), or a * member of the interface (for unnamed interfaces). */ - explicit interface_block_definition(const ir_variable *var) - : type(var->get_interface_type()), - instance_name(NULL), - array_size(-1) + explicit interface_block_definition(ir_variable *var) + : var(var), + type(var->get_interface_type()), + instance_name(NULL) { if (var->is_interface_instance()) { instance_name = var->name; - if (var->type->is_array()) - array_size = var->type->length; } explicitly_declared = (var->data.how_declared != ir_var_declared_implicitly); } + /** + * Interface block ir_variable + */ + ir_variable *var; /** * Interface block type @@ -74,12 +76,6 @@ struct interface_block_definition const char *instance_name; /** - * For an interface block array, the array size (or 0 if unsized). - * Otherwise -1. - */ - int array_size; - - /** * True if this interface block was explicitly declared in the shader; * false if it was an implicitly declared built-in interface block. */ @@ -95,7 +91,8 @@ struct interface_block_definition bool intrastage_match(interface_block_definition *a, const interface_block_definition *b, - ir_variable_mode mode) + ir_variable_mode mode, + struct gl_shader_program *prog) { /* Types must match. */ if (a->type != b->type) { @@ -120,18 +117,13 @@ intrastage_match(interface_block_definition *a, return false; } - /* Array vs. nonarray must be consistent, and sizes must be - * consistent, with the exception that unsized arrays match sized - * arrays. + /* If a block is an array then it must match across the shader. + * Unsized arrays are also processed and matched agaist sized arrays. */ - if ((a->array_size == -1) != (b->array_size == -1)) + if (b->var->type != a->var->type && + (b->instance_name != NULL || a->instance_name != NULL) && + !validate_intrastage_arrays(prog, b->var, a->var)) return false; - if (b->array_size != 0) { - if (a->array_size == 0) - a->array_size = b->array_size; - else if (a->array_size != b->array_size) - return false; - } return true; } @@ -153,8 +145,8 @@ interstage_match(const interface_block_definition *producer, /* Unsized arrays should not occur during interstage linking. They * should have all been assigned a size by link_intrastage_shaders. */ - assert(consumer->array_size != 0); - assert(producer->array_size != 0); + assert(!consumer->var->type->is_unsized_array()); + assert(!producer->var->type->is_unsized_array()); /* Types must match. */ if (consumer->type != producer->type) { @@ -165,20 +157,27 @@ interstage_match(const interface_block_definition *producer, if (consumer->explicitly_declared || producer->explicitly_declared) return false; } + + /* Ignore outermost array if geom shader */ + const glsl_type *consumer_instance_type; if (extra_array_level) { - /* Consumer must be an array, and producer must not. */ - if (consumer->array_size == -1) - return false; - if (producer->array_size != -1) - return false; + consumer_instance_type = consumer->var->type->fields.array; } else { - /* Array vs. nonarray must be consistent, and sizes must be consistent. - * Since unsized arrays have been ruled out, we can check this by just - * making sure the sizes are equal. - */ - if (consumer->array_size != producer->array_size) + consumer_instance_type = consumer->var->type; + } + + /* If a block is an array then it must match across shaders. + * Since unsized arrays have been ruled out, we can check this by just + * making sure the types are equal. + */ + if ((consumer->instance_name != NULL && + consumer_instance_type->is_array()) || + (producer->instance_name != NULL && + producer->var->type->is_array())) { + if (consumer_instance_type != producer->var->type) return false; } + return true; } @@ -298,7 +297,8 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog, */ definitions->store(def); } else if (!intrastage_match(prev_def, &def, - (ir_variable_mode) var->data.mode)) { + (ir_variable_mode) var->data.mode, + prog)) { linker_error(prog, "definitions of interface block `%s' do not" " match\n", iface_type->name); return; @@ -374,7 +374,7 @@ validate_interstage_uniform_blocks(struct gl_shader_program *prog, * uniform matchin rules (for uniforms, it is as though all * shaders are in the same shader stage). */ - if (!intrastage_match(old_def, &new_def, ir_var_uniform)) { + if (!intrastage_match(old_def, &new_def, ir_var_uniform, prog)) { linker_error(prog, "definitions of interface block `%s' do not " "match\n", var->get_interface_type()->name); return; diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp index 3f5eac1e2..0c4467779 100644 --- a/mesalib/src/glsl/linker.cpp +++ b/mesalib/src/glsl/linker.cpp @@ -64,6 +64,7 @@ * \author Ian Romanick <ian.d.romanick@intel.com> */ +#include <ctype.h> #include "main/core.h" #include "glsl_symbol_table.h" #include "glsl_parser_extras.h" @@ -680,6 +681,45 @@ validate_geometry_shader_emissions(struct gl_context *ctx, } } +bool +validate_intrastage_arrays(struct gl_shader_program *prog, + ir_variable *const var, + ir_variable *const existing) +{ + /* Consider the types to be "the same" if both types are arrays + * of the same type and one of the arrays is implicitly sized. + * In addition, set the type of the linked variable to the + * explicitly sized array. + */ + if (var->type->is_array() && existing->type->is_array() && + (var->type->fields.array == existing->type->fields.array) && + ((var->type->length == 0)|| (existing->type->length == 0))) { + if (var->type->length != 0) { + if (var->type->length <= existing->data.max_array_access) { + linker_error(prog, "%s `%s' declared as type " + "`%s' but outermost dimension has an index" + " of `%i'\n", + mode_string(var), + var->name, var->type->name, + existing->data.max_array_access); + } + existing->type = var->type; + return true; + } else if (existing->type->length != 0) { + if(existing->type->length <= var->data.max_array_access) { + linker_error(prog, "%s `%s' declared as type " + "`%s' but outermost dimension has an index" + " of `%i'\n", + mode_string(var), + var->name, existing->type->name, + var->data.max_array_access); + } + return true; + } + } + return false; +} + /** * Perform validation of global variables used across multiple shaders @@ -719,50 +759,23 @@ cross_validate_globals(struct gl_shader_program *prog, */ ir_variable *const existing = variables.get_variable(var->name); if (existing != NULL) { - if (var->type != existing->type) { - /* Consider the types to be "the same" if both types are arrays - * of the same type and one of the arrays is implicitly sized. - * In addition, set the type of the linked variable to the - * explicitly sized array. - */ - if (var->type->is_array() - && existing->type->is_array() - && (var->type->fields.array == existing->type->fields.array) - && ((var->type->length == 0) - || (existing->type->length == 0))) { - if (var->type->length != 0) { - if (var->type->length <= existing->data.max_array_access) { - linker_error(prog, "%s `%s' declared as type " - "`%s' but outermost dimension has an index" - " of `%i'\n", - mode_string(var), - var->name, var->type->name, - existing->data.max_array_access); - return; - } - existing->type = var->type; - } else if (existing->type->length != 0 - && existing->type->length <= - var->data.max_array_access) { + /* Check if types match. Interface blocks have some special + * rules so we handle those elsewhere. + */ + if (var->type != existing->type && + !var->is_interface_instance()) { + if (!validate_intrastage_arrays(prog, var, existing)) { + if (var->type->is_record() && existing->type->is_record() + && existing->type->record_compare(var->type)) { + existing->type = var->type; + } else { linker_error(prog, "%s `%s' declared as type " - "`%s' but outermost dimension has an index" - " of `%i'\n", + "`%s' and type `%s'\n", mode_string(var), - var->name, existing->type->name, - var->data.max_array_access); + var->name, var->type->name, + existing->type->name); return; } - } else if (var->type->is_record() - && existing->type->is_record() - && existing->type->record_compare(var->type)) { - existing->type = var->type; - } else { - linker_error(prog, "%s `%s' declared as type " - "`%s' and type `%s'\n", - mode_string(var), - var->name, var->type->name, - existing->type->name); - return; } } diff --git a/mesalib/src/glsl/linker.h b/mesalib/src/glsl/linker.h index be4da5e0a..ce3dc3232 100644 --- a/mesalib/src/glsl/linker.h +++ b/mesalib/src/glsl/linker.h @@ -61,6 +61,11 @@ link_uniform_blocks(void *mem_ctx, unsigned num_shaders, struct gl_uniform_block **blocks_ret); +bool +validate_intrastage_arrays(struct gl_shader_program *prog, + ir_variable *const var, + ir_variable *const existing); + void validate_intrastage_interface_blocks(struct gl_shader_program *prog, const gl_shader **shader_list, diff --git a/mesalib/src/glsl/loop_controls.cpp b/mesalib/src/glsl/loop_controls.cpp index 2459fc1c3..d7f0b2809 100644 --- a/mesalib/src/glsl/loop_controls.cpp +++ b/mesalib/src/glsl/loop_controls.cpp @@ -123,7 +123,7 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment, const int bias[] = { -1, 0, 1 }; bool valid_loop = false; - for (unsigned i = 0; i < Elements(bias); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(bias); i++) { /* Increment may be of type int, uint or float. */ switch (increment->type->base_type) { case GLSL_TYPE_INT: diff --git a/mesalib/src/glsl/lower_discard_flow.cpp b/mesalib/src/glsl/lower_discard_flow.cpp index 1bc56d79e..ee45bf221 100644 --- a/mesalib/src/glsl/lower_discard_flow.cpp +++ b/mesalib/src/glsl/lower_discard_flow.cpp @@ -90,7 +90,14 @@ ir_visitor_status lower_discard_flow_visitor::visit_enter(ir_discard *ir) { ir_dereference *lhs = new(mem_ctx) ir_dereference_variable(discarded); - ir_rvalue *rhs = new(mem_ctx) ir_constant(true); + ir_rvalue *rhs; + if (ir->condition) { + /* discarded <- condition, use (var_ref discarded) as the condition */ + rhs = ir->condition; + ir->condition = new(mem_ctx) ir_dereference_variable(discarded); + } else { + rhs = new(mem_ctx) ir_constant(true); + } ir_assignment *assign = new(mem_ctx) ir_assignment(lhs, rhs); ir->insert_before(assign); diff --git a/mesalib/src/glsl/lower_instructions.cpp b/mesalib/src/glsl/lower_instructions.cpp index 4779de059..845cfff36 100644 --- a/mesalib/src/glsl/lower_instructions.cpp +++ b/mesalib/src/glsl/lower_instructions.cpp @@ -124,7 +124,7 @@ * Converts double trunc, ceil, floor, round to fract */ -#include "main/core.h" /* for M_LOG2E */ +#include "c99_math.h" #include "program/prog_instruction.h" /* for swizzle */ #include "glsl_types.h" #include "ir.h" diff --git a/mesalib/src/glsl/lower_packed_varyings.cpp b/mesalib/src/glsl/lower_packed_varyings.cpp index 5e844c792..2c9a1c495 100644 --- a/mesalib/src/glsl/lower_packed_varyings.cpp +++ b/mesalib/src/glsl/lower_packed_varyings.cpp @@ -146,7 +146,11 @@ #include "glsl_symbol_table.h" #include "ir.h" +#include "ir_builder.h" #include "ir_optimization.h" +#include "program/prog_instruction.h" + +using namespace ir_builder; namespace { @@ -163,13 +167,14 @@ public: lower_packed_varyings_visitor(void *mem_ctx, unsigned locations_used, ir_variable_mode mode, unsigned gs_input_vertices, - exec_list *out_instructions); + exec_list *out_instructions, + exec_list *out_variables); void run(exec_list *instructions); private: - ir_assignment *bitwise_assign_pack(ir_rvalue *lhs, ir_rvalue *rhs); - ir_assignment *bitwise_assign_unpack(ir_rvalue *lhs, ir_rvalue *rhs); + void bitwise_assign_pack(ir_rvalue *lhs, ir_rvalue *rhs); + void bitwise_assign_unpack(ir_rvalue *lhs, ir_rvalue *rhs); unsigned lower_rvalue(ir_rvalue *rvalue, unsigned fine_location, ir_variable *unpacked_var, const char *name, bool gs_input_toplevel, unsigned vertex_index); @@ -221,13 +226,19 @@ private: * appropriate place in the shader once the visitor has finished running. */ exec_list *out_instructions; + + /** + * Exec list into which the visitor should insert any new variables. + */ + exec_list *out_variables; }; } /* anonymous namespace */ lower_packed_varyings_visitor::lower_packed_varyings_visitor( void *mem_ctx, unsigned locations_used, ir_variable_mode mode, - unsigned gs_input_vertices, exec_list *out_instructions) + unsigned gs_input_vertices, exec_list *out_instructions, + exec_list *out_variables) : mem_ctx(mem_ctx), locations_used(locations_used), packed_varyings((ir_variable **) @@ -235,7 +246,8 @@ lower_packed_varyings_visitor::lower_packed_varyings_visitor( locations_used)), mode(mode), gs_input_vertices(gs_input_vertices), - out_instructions(out_instructions) + out_instructions(out_instructions), + out_variables(out_variables) { } @@ -274,6 +286,7 @@ lower_packed_varyings_visitor::run(exec_list *instructions) } } +#define SWIZZLE_ZWZW MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_W, SWIZZLE_Z, SWIZZLE_W) /** * Make an ir_assignment from \c rhs to \c lhs, performing appropriate @@ -281,7 +294,7 @@ lower_packed_varyings_visitor::run(exec_list *instructions) * * This function is called when packing varyings. */ -ir_assignment * +void lower_packed_varyings_visitor::bitwise_assign_pack(ir_rvalue *lhs, ir_rvalue *rhs) { @@ -300,12 +313,28 @@ lower_packed_varyings_visitor::bitwise_assign_pack(ir_rvalue *lhs, rhs = new(this->mem_ctx) ir_expression(ir_unop_bitcast_f2i, lhs->type, rhs); break; + case GLSL_TYPE_DOUBLE: + assert(rhs->type->vector_elements <= 2); + if (rhs->type->vector_elements == 2) { + ir_variable *t = new(mem_ctx) ir_variable(lhs->type, "pack", ir_var_temporary); + + assert(lhs->type->vector_elements == 4); + this->out_variables->push_tail(t); + this->out_instructions->push_tail( + assign(t, u2i(expr(ir_unop_unpack_double_2x32, swizzle_x(rhs->clone(mem_ctx, NULL)))), 0x3)); + this->out_instructions->push_tail( + assign(t, u2i(expr(ir_unop_unpack_double_2x32, swizzle_y(rhs))), 0xc)); + rhs = deref(t).val; + } else { + rhs = u2i(expr(ir_unop_unpack_double_2x32, rhs)); + } + break; default: assert(!"Unexpected type conversion while lowering varyings"); break; } } - return new(this->mem_ctx) ir_assignment(lhs, rhs); + this->out_instructions->push_tail(new (this->mem_ctx) ir_assignment(lhs, rhs)); } @@ -315,7 +344,7 @@ lower_packed_varyings_visitor::bitwise_assign_pack(ir_rvalue *lhs, * * This function is called when unpacking varyings. */ -ir_assignment * +void lower_packed_varyings_visitor::bitwise_assign_unpack(ir_rvalue *lhs, ir_rvalue *rhs) { @@ -334,12 +363,27 @@ lower_packed_varyings_visitor::bitwise_assign_unpack(ir_rvalue *lhs, rhs = new(this->mem_ctx) ir_expression(ir_unop_bitcast_i2f, lhs->type, rhs); break; + case GLSL_TYPE_DOUBLE: + assert(lhs->type->vector_elements <= 2); + if (lhs->type->vector_elements == 2) { + ir_variable *t = new(mem_ctx) ir_variable(lhs->type, "unpack", ir_var_temporary); + assert(rhs->type->vector_elements == 4); + this->out_variables->push_tail(t); + this->out_instructions->push_tail( + assign(t, expr(ir_unop_pack_double_2x32, i2u(swizzle_xy(rhs->clone(mem_ctx, NULL)))), 0x1)); + this->out_instructions->push_tail( + assign(t, expr(ir_unop_pack_double_2x32, i2u(swizzle(rhs->clone(mem_ctx, NULL), SWIZZLE_ZWZW, 2))), 0x2)); + rhs = deref(t).val; + } else { + rhs = expr(ir_unop_pack_double_2x32, i2u(rhs)); + } + break; default: assert(!"Unexpected type conversion while lowering varyings"); break; } } - return new(this->mem_ctx) ir_assignment(lhs, rhs); + this->out_instructions->push_tail(new(this->mem_ctx) ir_assignment(lhs, rhs)); } @@ -372,6 +416,7 @@ lower_packed_varyings_visitor::lower_rvalue(ir_rvalue *rvalue, bool gs_input_toplevel, unsigned vertex_index) { + unsigned dmul = rvalue->type->is_double() ? 2 : 1; /* When gs_input_toplevel is set, we should be looking at a geometry shader * input array. */ @@ -405,17 +450,26 @@ lower_packed_varyings_visitor::lower_rvalue(ir_rvalue *rvalue, return this->lower_arraylike(rvalue, rvalue->type->matrix_columns, fine_location, unpacked_var, name, false, vertex_index); - } else if (rvalue->type->vector_elements + fine_location % 4 > 4) { + } else if (rvalue->type->vector_elements * dmul + + fine_location % 4 > 4) { /* This vector is going to be "double parked" across two varying slots, - * so handle it as two separate assignments. + * so handle it as two separate assignments. For doubles, a dvec3/dvec4 + * can end up being spread over 3 slots. However the second splitting + * will happen later, here we just always want to split into 2. */ - unsigned left_components = 4 - fine_location % 4; - unsigned right_components - = rvalue->type->vector_elements - left_components; + unsigned left_components, right_components; unsigned left_swizzle_values[4] = { 0, 0, 0, 0 }; unsigned right_swizzle_values[4] = { 0, 0, 0, 0 }; char left_swizzle_name[4] = { 0, 0, 0, 0 }; char right_swizzle_name[4] = { 0, 0, 0, 0 }; + + left_components = 4 - fine_location % 4; + if (rvalue->type->is_double()) { + /* We might actually end up with 0 left components! */ + left_components /= 2; + } + right_components = rvalue->type->vector_elements - left_components; + for (unsigned i = 0; i < left_components; i++) { left_swizzle_values[i] = i; left_swizzle_name[i] = "xyzw"[i]; @@ -433,9 +487,13 @@ lower_packed_varyings_visitor::lower_rvalue(ir_rvalue *rvalue, = ralloc_asprintf(this->mem_ctx, "%s.%s", name, left_swizzle_name); char *right_name = ralloc_asprintf(this->mem_ctx, "%s.%s", name, right_swizzle_name); - fine_location = this->lower_rvalue(left_swizzle, fine_location, - unpacked_var, left_name, false, - vertex_index); + if (left_components) + fine_location = this->lower_rvalue(left_swizzle, fine_location, + unpacked_var, left_name, false, + vertex_index); + else + /* Top up the fine location to the next slot */ + fine_location++; return this->lower_rvalue(right_swizzle, fine_location, unpacked_var, right_name, false, vertex_index); } else { @@ -443,7 +501,7 @@ lower_packed_varyings_visitor::lower_rvalue(ir_rvalue *rvalue, * varying. */ unsigned swizzle_values[4] = { 0, 0, 0, 0 }; - unsigned components = rvalue->type->vector_elements; + unsigned components = rvalue->type->vector_elements * dmul; unsigned location = fine_location / 4; unsigned location_frac = fine_location % 4; for (unsigned i = 0; i < components; ++i) @@ -454,13 +512,9 @@ lower_packed_varyings_visitor::lower_rvalue(ir_rvalue *rvalue, ir_swizzle *swizzle = new(this->mem_ctx) ir_swizzle(packed_deref, swizzle_values, components); if (this->mode == ir_var_shader_out) { - ir_assignment *assignment - = this->bitwise_assign_pack(swizzle, rvalue); - this->out_instructions->push_tail(assignment); + this->bitwise_assign_pack(swizzle, rvalue); } else { - ir_assignment *assignment - = this->bitwise_assign_unpack(rvalue, swizzle); - this->out_instructions->push_tail(assignment); + this->bitwise_assign_unpack(rvalue, swizzle); } return fine_location + components; } @@ -598,7 +652,7 @@ lower_packed_varyings_visitor::needs_lowering(ir_variable *var) } if (type->is_array()) type = type->fields.array; - if (type->vector_elements == 4) + if (type->vector_elements == 4 && !type->is_double()) return false; return true; } @@ -657,9 +711,11 @@ lower_packed_varyings(void *mem_ctx, unsigned locations_used, exec_list void_parameters; ir_function_signature *main_func_sig = main_func->matching_signature(NULL, &void_parameters, false); - exec_list new_instructions; + exec_list new_instructions, new_variables; lower_packed_varyings_visitor visitor(mem_ctx, locations_used, mode, - gs_input_vertices, &new_instructions); + gs_input_vertices, + &new_instructions, + &new_variables); visitor.run(instructions); if (mode == ir_var_shader_out) { if (shader->Stage == MESA_SHADER_GEOMETRY) { @@ -667,15 +723,22 @@ lower_packed_varyings(void *mem_ctx, unsigned locations_used, * to EmitVertex() */ lower_packed_varyings_gs_splicer splicer(mem_ctx, &new_instructions); + + /* Add all the variables in first. */ + main_func_sig->body.head->insert_before(&new_variables); + + /* Now update all the EmitVertex instances */ splicer.run(instructions); } else { /* For other shader types, outputs need to be lowered at the end of * main() */ + main_func_sig->body.append_list(&new_variables); main_func_sig->body.append_list(&new_instructions); } } else { /* Shader inputs need to be lowered at the beginning of main() */ main_func_sig->body.head->insert_before(&new_instructions); + main_func_sig->body.head->insert_before(&new_variables); } } diff --git a/mesalib/src/glsl/nir/glsl_to_nir.cpp b/mesalib/src/glsl/nir/glsl_to_nir.cpp index 544d0d932..adef19c80 100644 --- a/mesalib/src/glsl/nir/glsl_to_nir.cpp +++ b/mesalib/src/glsl/nir/glsl_to_nir.cpp @@ -563,8 +563,14 @@ nir_visitor::visit(ir_discard *ir) * discards will be immediately followed by a return. */ - nir_intrinsic_instr *discard = - nir_intrinsic_instr_create(this->shader, nir_intrinsic_discard); + nir_intrinsic_instr *discard; + if (ir->condition) { + discard = nir_intrinsic_instr_create(this->shader, + nir_intrinsic_discard_if); + discard->src[0] = evaluate_rvalue(ir->condition); + } else { + discard = nir_intrinsic_instr_create(this->shader, nir_intrinsic_discard); + } nir_instr_insert_after_cf_list(this->cf_node_list, &discard->instr); } diff --git a/mesalib/src/glsl/nir/nir.c b/mesalib/src/glsl/nir/nir.c index 5b0e4bc50..ab57fd4e2 100644 --- a/mesalib/src/glsl/nir/nir.c +++ b/mesalib/src/glsl/nir/nir.c @@ -63,6 +63,7 @@ reg_create(void *mem_ctx, struct exec_list *list) { nir_register *reg = ralloc(mem_ctx, nir_register); + reg->parent_instr = NULL; reg->uses = _mesa_set_create(mem_ctx, _mesa_hash_pointer, _mesa_key_pointer_equal); reg->defs = _mesa_set_create(mem_ctx, _mesa_hash_pointer, diff --git a/mesalib/src/glsl/nir/nir.h b/mesalib/src/glsl/nir/nir.h index d74caa959..d5df59609 100644 --- a/mesalib/src/glsl/nir/nir.h +++ b/mesalib/src/glsl/nir/nir.h @@ -66,6 +66,7 @@ name(const in_type *parent) \ struct nir_function_overload; struct nir_function; struct nir_shader; +struct nir_instr; /** @@ -386,6 +387,14 @@ typedef struct { */ bool is_packed; + /** + * If this pointer is non-NULL then this register has exactly one + * definition and that definition dominates all of its uses. This is + * set by the out-of-SSA pass so that backends can get SSA-like + * information even once they have gone out of SSA. + */ + struct nir_instr *parent_instr; + /** set of nir_instr's where this register is used (read from) */ struct set *uses; @@ -408,7 +417,7 @@ typedef enum { nir_instr_type_parallel_copy, } nir_instr_type; -typedef struct { +typedef struct nir_instr { struct exec_node node; nir_instr_type type; struct nir_block *block; diff --git a/mesalib/src/glsl/nir/nir_from_ssa.c b/mesalib/src/glsl/nir/nir_from_ssa.c index 7c5009577..c3090fb06 100644 --- a/mesalib/src/glsl/nir/nir_from_ssa.c +++ b/mesalib/src/glsl/nir/nir_from_ssa.c @@ -26,6 +26,7 @@ */ #include "nir.h" +#include "nir_vla.h" /* * This file implements an out-of-SSA pass as described in "Revisiting @@ -181,7 +182,7 @@ merge_merge_sets(merge_set *a, merge_set *b) static bool merge_sets_interfere(merge_set *a, merge_set *b) { - merge_node *dom[a->size + b->size]; + NIR_VLA(merge_node *, dom, a->size + b->size); int dom_idx = -1; struct exec_node *an = exec_list_get_head(&a->nodes); @@ -508,6 +509,13 @@ get_register_for_ssa_def(nir_ssa_def *def, struct from_ssa_state *state) reg->num_components = def->num_components; reg->num_array_elems = 0; + /* This register comes from an SSA definition that was not part of a + * phi-web. Therefore, we know it has a single unique definition + * that dominates all of its uses. Therefore, we can copy the + * parent_instr from the SSA def safely. + */ + reg->parent_instr = def->parent_instr; + _mesa_hash_table_insert(state->ssa_table, def, reg); return reg; } @@ -666,21 +674,16 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy, } /* The register/source corresponding to the given index */ - nir_src values[num_copies * 2]; - memset(values, 0, sizeof values); - - /* The current location of a given piece of data */ - int loc[num_copies * 2]; + NIR_VLA_ZERO(nir_src, values, num_copies * 2); - /* The piece of data that the given piece of data is to be copied from */ - int pred[num_copies * 2]; + /* The current location of a given piece of data. We will use -1 for "null" */ + NIR_VLA_FILL(int, loc, num_copies * 2, -1); - /* Initialize loc and pred. We will use -1 for "null" */ - memset(loc, -1, sizeof loc); - memset(pred, -1, sizeof pred); + /* The piece of data that the given piece of data is to be copied from. We will use -1 for "null" */ + NIR_VLA_FILL(int, pred, num_copies * 2, -1); /* The destinations we have yet to properly fill */ - int to_do[num_copies * 2]; + NIR_VLA(int, to_do, num_copies * 2); int to_do_idx = -1; /* Now we set everything up: @@ -730,7 +733,7 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy, } /* Currently empty destinations we can go ahead and fill */ - int ready[num_copies * 2]; + NIR_VLA(int, ready, num_copies * 2); int ready_idx = -1; /* Mark the ones that are ready for copying. We know an index is a diff --git a/mesalib/src/glsl/nir/nir_intrinsics.h b/mesalib/src/glsl/nir/nir_intrinsics.h index d94866c85..3bf102fc1 100644 --- a/mesalib/src/glsl/nir/nir_intrinsics.h +++ b/mesalib/src/glsl/nir/nir_intrinsics.h @@ -68,6 +68,8 @@ INTRINSIC(interp_var_at_offset, 1, ARR(2), true, 0, 1, 0, #define BARRIER(name) INTRINSIC(name, 0, ARR(), false, 0, 0, 0, 0) BARRIER(discard) +/** A conditional discard, with a single boolean source. */ +INTRINSIC(discard_if, 1, ARR(1), false, 0, 0, 0, 0) INTRINSIC(emit_vertex, 0, ARR(), false, 0, 0, 1, 0) INTRINSIC(end_primitive, 0, ARR(), false, 0, 0, 1, 0) diff --git a/mesalib/src/glsl/nir/nir_live_variables.c b/mesalib/src/glsl/nir/nir_live_variables.c index 7402dc087..1c96dcf36 100644 --- a/mesalib/src/glsl/nir/nir_live_variables.c +++ b/mesalib/src/glsl/nir/nir_live_variables.c @@ -26,6 +26,7 @@ #include "nir.h" #include "nir_worklist.h" +#include "nir_vla.h" /* * Basic liveness analysis. This works only in SSA form. @@ -130,8 +131,8 @@ static bool propagate_across_edge(nir_block *pred, nir_block *succ, struct live_variables_state *state) { - BITSET_WORD live[state->bitset_words]; - memcpy(live, succ->live_in, sizeof live); + NIR_VLA(BITSET_WORD, live, state->bitset_words); + memcpy(live, succ->live_in, state->bitset_words * sizeof *live); nir_foreach_instr(succ, instr) { if (instr->type != nir_instr_type_phi) diff --git a/mesalib/src/glsl/nir/nir_lower_vars_to_ssa.c b/mesalib/src/glsl/nir/nir_lower_vars_to_ssa.c index 8af753029..9e9a418e3 100644 --- a/mesalib/src/glsl/nir/nir_lower_vars_to_ssa.c +++ b/mesalib/src/glsl/nir/nir_lower_vars_to_ssa.c @@ -26,6 +26,8 @@ */ #include "nir.h" +#include "nir_vla.h" + struct deref_node { struct deref_node *parent; @@ -899,8 +901,8 @@ rename_variables_block(nir_block *block, struct lower_variables_state *state) static void insert_phi_nodes(struct lower_variables_state *state) { - unsigned work[state->impl->num_blocks]; - unsigned has_already[state->impl->num_blocks]; + NIR_VLA_ZERO(unsigned, work, state->impl->num_blocks); + NIR_VLA_ZERO(unsigned, has_already, state->impl->num_blocks); /* * Since the work flags already prevent us from inserting a node that has @@ -910,10 +912,7 @@ insert_phi_nodes(struct lower_variables_state *state) * function. So all we need to handle W is an array and a pointer to the * next element to be inserted and the next element to be removed. */ - nir_block *W[state->impl->num_blocks]; - - memset(work, 0, sizeof work); - memset(has_already, 0, sizeof has_already); + NIR_VLA(nir_block *, W, state->impl->num_blocks); unsigned w_start, w_end; unsigned iter_count = 0; diff --git a/mesalib/src/glsl/nir/nir_opt_copy_propagate.c b/mesalib/src/glsl/nir/nir_opt_copy_propagate.c index dd0ec01ef..ee78e5aa0 100644 --- a/mesalib/src/glsl/nir/nir_opt_copy_propagate.c +++ b/mesalib/src/glsl/nir/nir_opt_copy_propagate.c @@ -53,22 +53,6 @@ static bool is_move(nir_alu_instr *instr) } -static bool -is_swizzleless_move(nir_alu_instr *instr) -{ - if (!is_move(instr)) - return false; - - for (unsigned i = 0; i < 4; i++) { - if (!((instr->dest.write_mask >> i) & 1)) - break; - if (instr->src[0].swizzle[i] != i) - return false; - } - - return true; -} - static bool is_vec(nir_alu_instr *instr) { for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) @@ -80,6 +64,35 @@ static bool is_vec(nir_alu_instr *instr) instr->op == nir_op_vec4; } +static bool +is_swizzleless_move(nir_alu_instr *instr) +{ + if (is_move(instr)) { + for (unsigned i = 0; i < 4; i++) { + if (!((instr->dest.write_mask >> i) & 1)) + break; + if (instr->src[0].swizzle[i] != i) + return false; + } + return true; + } else if (is_vec(instr)) { + nir_ssa_def *def = NULL; + for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) { + if (instr->src[i].swizzle[0] != i) + return false; + + if (def == NULL) { + def = instr->src[i].src.ssa; + } else if (instr->src[i].src.ssa != def) { + return false; + } + } + return true; + } else { + return false; + } +} + typedef struct { nir_ssa_def *def; bool found; diff --git a/mesalib/src/glsl/nir/nir_opt_gcm.c b/mesalib/src/glsl/nir/nir_opt_gcm.c index bf565b969..b4f5fd3d5 100644 --- a/mesalib/src/glsl/nir/nir_opt_gcm.c +++ b/mesalib/src/glsl/nir/nir_opt_gcm.c @@ -121,9 +121,11 @@ gcm_pin_instructions_block(nir_block *block, void *void_state) case nir_op_fddy_coarse: /* These can only go in uniform control flow; pin them for now */ instr->pass_flags = GCM_INSTR_PINNED; + break; default: instr->pass_flags = 0; + break; } break; @@ -134,9 +136,11 @@ gcm_pin_instructions_block(nir_block *block, void *void_state) case nir_texop_lod: /* These two take implicit derivatives so they need to be pinned */ instr->pass_flags = GCM_INSTR_PINNED; + break; default: instr->pass_flags = 0; + break; } break; diff --git a/mesalib/src/glsl/nir/nir_vla.h b/mesalib/src/glsl/nir/nir_vla.h new file mode 100644 index 000000000..753783316 --- /dev/null +++ b/mesalib/src/glsl/nir/nir_vla.h @@ -0,0 +1,54 @@ +/************************************************************************** + * + * Copyright 2015 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#pragma once + + +#include "c99_alloca.h" + + +/* Declare a variable length array, with no initialization */ +#define NIR_VLA(_type, _name, _length) \ + _type *_name = alloca((_length) * sizeof *_name) + + +/* Declare a variable length array, and initialize it with the given byte. + * + * _length is evaluated twice, so expressions with side-effects must be + * avoided. + */ +#define NIR_VLA_FILL(_type, _name, _length, _byte) \ + _type *_name = memset(alloca((_length) * sizeof *_name), _byte, (_length) * sizeof *_name) + + +/* Declare a variable length array, and zero it. + * + * Just like NIR_VLA_FILL, _length is evaluated twice, so expressions with + * side-effects must be avoided. + */ +#define NIR_VLA_ZERO(_type, _name, _length) \ + NIR_VLA_FILL(_type, _name, _length, 0) diff --git a/mesalib/src/glsl/opt_algebraic.cpp b/mesalib/src/glsl/opt_algebraic.cpp index 6784242ff..c6040bff8 100644 --- a/mesalib/src/glsl/opt_algebraic.cpp +++ b/mesalib/src/glsl/opt_algebraic.cpp @@ -744,48 +744,65 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) * a saturate operation */ for (int op = 0; op < 2; op++) { - ir_expression *minmax = op_expr[op]; + ir_expression *inner_expr = op_expr[op]; ir_constant *outer_const = op_const[1 - op]; ir_expression_operation op_cond = (ir->operation == ir_binop_max) ? ir_binop_min : ir_binop_max; - if (!minmax || !outer_const || (minmax->operation != op_cond)) + if (!inner_expr || !outer_const || (inner_expr->operation != op_cond)) continue; + /* One of these has to be a constant */ + if (!inner_expr->operands[0]->as_constant() && + !inner_expr->operands[1]->as_constant()) + break; + /* Found a min(max) combination. Now try to see if its operands * meet our conditions that we can do just a single saturate operation */ for (int minmax_op = 0; minmax_op < 2; minmax_op++) { - ir_rvalue *inner_val_a = minmax->operands[minmax_op]; - ir_rvalue *inner_val_b = minmax->operands[1 - minmax_op]; + ir_rvalue *x = inner_expr->operands[minmax_op]; + ir_rvalue *y = inner_expr->operands[1 - minmax_op]; - if (!inner_val_a || !inner_val_b) + ir_constant *inner_const = y->as_constant(); + if (!inner_const) continue; - /* Found a {min|max} ({max|min} (x, 0.0), 1.0) operation and its variations */ - if ((outer_const->is_one() && inner_val_a->is_zero()) || - (inner_val_a->is_one() && outer_const->is_zero())) - return saturate(inner_val_b); - - /* Found a {min|max} ({max|min} (x, 0.0), b) where b < 1.0 - * and its variations - */ - if (is_less_than_one(outer_const) && inner_val_b->is_zero()) - return expr(ir_binop_min, saturate(inner_val_a), outer_const); - - if (!inner_val_b->as_constant()) - continue; - - if (is_less_than_one(inner_val_b->as_constant()) && outer_const->is_zero()) - return expr(ir_binop_min, saturate(inner_val_a), inner_val_b); - - /* Found a {min|max} ({max|min} (x, b), 1.0), where b > 0.0 - * and its variations - */ - if (outer_const->is_one() && is_greater_than_zero(inner_val_b->as_constant())) - return expr(ir_binop_max, saturate(inner_val_a), inner_val_b); - if (inner_val_b->as_constant()->is_one() && is_greater_than_zero(outer_const)) - return expr(ir_binop_max, saturate(inner_val_a), outer_const); + /* min(max(x, 0.0), 1.0) is sat(x) */ + if (ir->operation == ir_binop_min && + inner_const->is_zero() && + outer_const->is_one()) + return saturate(x); + + /* max(min(x, 1.0), 0.0) is sat(x) */ + if (ir->operation == ir_binop_max && + inner_const->is_one() && + outer_const->is_zero()) + return saturate(x); + + /* min(max(x, 0.0), b) where b < 1.0 is sat(min(x, b)) */ + if (ir->operation == ir_binop_min && + inner_const->is_zero() && + is_less_than_one(outer_const)) + return saturate(expr(ir_binop_min, x, outer_const)); + + /* max(min(x, b), 0.0) where b < 1.0 is sat(min(x, b)) */ + if (ir->operation == ir_binop_max && + is_less_than_one(inner_const) && + outer_const->is_zero()) + return saturate(expr(ir_binop_min, x, inner_const)); + + /* max(min(x, 1.0), b) where b > 0.0 is sat(max(x, b)) */ + if (ir->operation == ir_binop_max && + inner_const->is_one() && + is_greater_than_zero(outer_const)) + return saturate(expr(ir_binop_max, x, outer_const)); + + /* min(max(x, b), 1.0) where b > 0.0 is sat(max(x, b)) */ + if (ir->operation == ir_binop_min && + is_greater_than_zero(inner_const) && + outer_const->is_one()) + return saturate(expr(ir_binop_max, x, inner_const)); } } @@ -849,6 +866,7 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) one = new(mem_ctx) ir_constant(1.0, op2_components); break; default: + one = NULL; unreachable("unexpected type"); } diff --git a/mesalib/src/glsl/opt_conditional_discard.cpp b/mesalib/src/glsl/opt_conditional_discard.cpp new file mode 100644 index 000000000..8a3ad2487 --- /dev/null +++ b/mesalib/src/glsl/opt_conditional_discard.cpp @@ -0,0 +1,81 @@ +/* + * Copyright © 2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_conditional_discard.cpp + * + * Replace + * + * if (cond) discard; + * + * with + * + * (discard <condition>) + */ + +#include "glsl_types.h" +#include "ir.h" + +namespace { + +class opt_conditional_discard_visitor : public ir_hierarchical_visitor { +public: + opt_conditional_discard_visitor() + { + progress = false; + } + + ir_visitor_status visit_leave(ir_if *); + + bool progress; +}; + +} /* anonymous namespace */ + +bool +opt_conditional_discard(exec_list *instructions) +{ + opt_conditional_discard_visitor v; + v.run(instructions); + return v.progress; +} + +ir_visitor_status +opt_conditional_discard_visitor::visit_leave(ir_if *ir) +{ + /* Look for "if (...) discard" with no else clause or extra statements. */ + if (ir->then_instructions.is_empty() || + !ir->then_instructions.head->next->is_tail_sentinel() || + !((ir_instruction *) ir->then_instructions.head)->as_discard() || + !ir->else_instructions.is_empty()) + return visit_continue; + + /* Move the condition and replace the ir_if with the ir_discard. */ + ir_discard *discard = (ir_discard *) ir->then_instructions.head; + discard->condition = ir->condition; + ir->replace_with(discard); + + progress = true; + + return visit_continue; +} diff --git a/mesalib/src/glsl/opt_constant_folding.cpp b/mesalib/src/glsl/opt_constant_folding.cpp index 74b855e5e..4aae3f0dd 100644 --- a/mesalib/src/glsl/opt_constant_folding.cpp +++ b/mesalib/src/glsl/opt_constant_folding.cpp @@ -50,6 +50,7 @@ public: /* empty */ } + virtual ir_visitor_status visit_enter(ir_discard *ir); virtual ir_visitor_status visit_enter(ir_assignment *ir); virtual ir_visitor_status visit_enter(ir_call *ir); @@ -94,6 +95,29 @@ ir_constant_folding_visitor::handle_rvalue(ir_rvalue **rvalue) } ir_visitor_status +ir_constant_folding_visitor::visit_enter(ir_discard *ir) +{ + if (ir->condition) { + ir->condition->accept(this); + handle_rvalue(&ir->condition); + + ir_constant *const_val = ir->condition->as_constant(); + /* If the condition is constant, either remove the condition or + * remove the never-executed assignment. + */ + if (const_val) { + if (const_val->value.b[0]) + ir->condition = NULL; + else + ir->remove(); + this->progress = true; + } + } + + return visit_continue_with_parent; +} + +ir_visitor_status ir_constant_folding_visitor::visit_enter(ir_assignment *ir) { ir->rhs->accept(this); diff --git a/mesalib/src/glsl/s_expression.cpp b/mesalib/src/glsl/s_expression.cpp index 2928a4db8..7eaa491e2 100644 --- a/mesalib/src/glsl/s_expression.cpp +++ b/mesalib/src/glsl/s_expression.cpp @@ -24,6 +24,7 @@ #include <assert.h> #include <limits> +#include <stdio.h> #include "s_expression.h" s_symbol::s_symbol(const char *str, size_t n) diff --git a/mesalib/src/glsl/s_expression.h b/mesalib/src/glsl/s_expression.h index 1d4753530..f0dffb1b2 100644 --- a/mesalib/src/glsl/s_expression.h +++ b/mesalib/src/glsl/s_expression.h @@ -39,8 +39,8 @@ #define SX_AS_INT(x) SX_AS_(int, x) /* Pattern matching macros */ -#define MATCH(list, pat) s_match(list, Elements(pat), pat, false) -#define PARTIAL_MATCH(list, pat) s_match(list, Elements(pat), pat, true) +#define MATCH(list, pat) s_match(list, ARRAY_SIZE(pat), pat, false) +#define PARTIAL_MATCH(list, pat) s_match(list, ARRAY_SIZE(pat), pat, true) /* For our purposes, S-Expressions are: * - <int> diff --git a/mesalib/src/glsl/standalone_scaffolding.cpp b/mesalib/src/glsl/standalone_scaffolding.cpp index ad0d75bf8..6f5a27f85 100644 --- a/mesalib/src/glsl/standalone_scaffolding.cpp +++ b/mesalib/src/glsl/standalone_scaffolding.cpp @@ -30,6 +30,7 @@ #include "standalone_scaffolding.h" #include <assert.h> +#include <stdio.h> #include <string.h> #include "util/ralloc.h" diff --git a/mesalib/src/loader/Makefile.am b/mesalib/src/loader/Makefile.am index 36ddba82b..3d32279ea 100644 --- a/mesalib/src/loader/Makefile.am +++ b/mesalib/src/loader/Makefile.am @@ -30,6 +30,7 @@ libloader_la_CPPFLAGS = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/src \ $(VISIBILITY_CFLAGS) \ + $(MSVC2013_COMPAT_CFLAGS) \ $(LIBUDEV_CFLAGS) libloader_la_SOURCES = $(LOADER_C_FILES) diff --git a/mesalib/src/loader/SConscript b/mesalib/src/loader/SConscript index 359fc1850..16d1053ff 100644 --- a/mesalib/src/loader/SConscript +++ b/mesalib/src/loader/SConscript @@ -2,6 +2,8 @@ Import('*') env = env.Clone() +env.MSVC2013Compat() + env.Prepend(CPPPATH = [ '#include' ]) diff --git a/mesalib/src/mapi/Makefile.am b/mesalib/src/mapi/Makefile.am index 679468291..50c5b2ebb 100644 --- a/mesalib/src/mapi/Makefile.am +++ b/mesalib/src/mapi/Makefile.am @@ -39,11 +39,14 @@ EXTRA_DIST = \ glapi/SConscript \ shared-glapi/SConscript -AM_CFLAGS = $(PTHREAD_CFLAGS) +AM_CFLAGS = \ + $(PTHREAD_CFLAGS) \ + $(MSVC2013_COMPAT_CFLAGS) AM_CPPFLAGS = \ $(DEFINES) \ $(SELINUX_CFLAGS) \ -I$(top_srcdir)/include \ + -I$(top_srcdir)/src \ -I$(top_srcdir)/src/mapi \ -I$(top_builddir)/src/mapi @@ -66,7 +69,7 @@ if HAVE_SHARED_GLAPI BUILT_SOURCES += shared-glapi/glapi_mapi_tmp.h lib_LTLIBRARIES += shared-glapi/libglapi.la -shared_glapi_libglapi_la_SOURCES = $(MAPI_GLAPI_FILES) +shared_glapi_libglapi_la_SOURCES = $(MAPI_GLAPI_FILES) shared-glapi/glapi_mapi_tmp.h shared_glapi_libglapi_la_CPPFLAGS = \ $(AM_CPPFLAGS) \ -DMAPI_MODE_GLAPI \ @@ -115,7 +118,7 @@ glapi_libglapi_la_CPPFLAGS = \ -I$(top_srcdir)/src/mesa if HAVE_SHARED_GLAPI -glapi_libglapi_la_SOURCES += $(MAPI_BRIDGE_FILES) +glapi_libglapi_la_SOURCES += $(MAPI_BRIDGE_FILES) glapi/glapi_mapi_tmp.h glapi_libglapi_la_CPPFLAGS += \ -DMAPI_MODE_BRIDGE \ -DMAPI_ABI_HEADER=\"glapi/glapi_mapi_tmp.h\" @@ -230,10 +233,4 @@ endif es2api/glapi_mapi_tmp.h: glapi/gen/gl_and_es_API.xml $(glapi_gen_mapi_deps) $(call glapi_gen_mapi,$<,es2api) -# XXX: Inline vgapi's Makefile.am here. -EXTRA_DIST += vgapi -# if HAVE_OPENVG -# SUBDIRS += vgapi -# endif - include $(top_srcdir)/install-lib-links.mk diff --git a/mesalib/src/mapi/Makefile.sources b/mesalib/src/mapi/Makefile.sources index 41dbb24c8..07063f390 100644 --- a/mesalib/src/mapi/Makefile.sources +++ b/mesalib/src/mapi/Makefile.sources @@ -15,13 +15,10 @@ # this mode, compile MAPI_BRIDGE_FILES with MAPI_MODE_BRIDGE defined. MAPI_UTIL_FILES = \ - u_compiler.h \ u_current.c \ u_current.h \ u_execmem.c \ - u_execmem.h \ - u_macros.h \ - u_thread.h + u_execmem.h MAPI_BRIDGE_FILES = \ entry.c \ diff --git a/mesalib/src/mapi/entry.c b/mesalib/src/mapi/entry.c index b6e8db28d..27d0db40e 100644 --- a/mesalib/src/mapi/entry.c +++ b/mesalib/src/mapi/entry.c @@ -27,7 +27,9 @@ #include "entry.h" #include "u_current.h" -#include "u_macros.h" + +#define _U_STRINGIFY(x) #x +#define U_STRINGIFY(x) _U_STRINGIFY(x) /* define macros for use by assembly dispatchers */ #define ENTRY_CURRENT_TABLE U_STRINGIFY(u_current_table) @@ -51,7 +53,7 @@ #include <stdlib.h> -static INLINE const struct mapi_table * +static inline const struct mapi_table * entry_current_get(void) { #ifdef MAPI_MODE_BRIDGE diff --git a/mesalib/src/mapi/entry.h b/mesalib/src/mapi/entry.h index dba1c06a3..7c8137c0c 100644 --- a/mesalib/src/mapi/entry.h +++ b/mesalib/src/mapi/entry.h @@ -28,7 +28,6 @@ #ifndef _ENTRY_H_ #define _ENTRY_H_ -#include "u_compiler.h" typedef void (*mapi_func)(void); diff --git a/mesalib/src/mapi/entry_x86-64_tls.h b/mesalib/src/mapi/entry_x86-64_tls.h index 71e9d6063..5c03b0456 100644 --- a/mesalib/src/mapi/entry_x86-64_tls.h +++ b/mesalib/src/mapi/entry_x86-64_tls.h @@ -25,7 +25,6 @@ * Chia-I Wu <olv@lunarg.com> */ -#include "u_macros.h" __asm__(".text\n" ".balign 32\n" @@ -88,7 +87,7 @@ entry_generate(int slot) 0x41, 0xff, 0xa3, 0x34, 0x12, 0x00, 0x00, }; unsigned long addr; - void *code; + char *code; mapi_func entry; addr = x86_64_current_tls(); diff --git a/mesalib/src/mapi/entry_x86_tls.h b/mesalib/src/mapi/entry_x86_tls.h index fa7bc15b8..46d2eced2 100644 --- a/mesalib/src/mapi/entry_x86_tls.h +++ b/mesalib/src/mapi/entry_x86_tls.h @@ -26,7 +26,6 @@ */ #include <string.h> -#include "u_macros.h" __asm__(".text"); @@ -113,7 +112,7 @@ entry_generate(int slot) 0xff, 0xa0, 0x34, 0x12, 0x00, 0x00, /* jmp *0x1234(%eax) */ 0x90, 0x90, 0x90, 0x90 /* nop's */ }; - void *code; + char *code; mapi_func entry; code = u_execmem_alloc(sizeof(code_templ)); diff --git a/mesalib/src/mapi/entry_x86_tsd.h b/mesalib/src/mapi/entry_x86_tsd.h index ece00fac0..ea7bacb43 100644 --- a/mesalib/src/mapi/entry_x86_tsd.h +++ b/mesalib/src/mapi/entry_x86_tsd.h @@ -25,7 +25,6 @@ * Chia-I Wu <olv@lunarg.com> */ -#include "u_macros.h" #define X86_ENTRY_SIZE 32 diff --git a/mesalib/src/mapi/glapi/SConscript b/mesalib/src/mapi/glapi/SConscript index 97ebfe638..8ded46f32 100644 --- a/mesalib/src/mapi/glapi/SConscript +++ b/mesalib/src/mapi/glapi/SConscript @@ -8,6 +8,8 @@ Import('*') env = env.Clone() +env.MSVC2013Compat() + env.Append(CPPDEFINES = [ 'MAPI_MODE_UTIL', ]) @@ -25,6 +27,7 @@ if env['platform'] == 'windows': env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS']) env.Append(CPPPATH = [ + '#/src', '#/src/mapi', '#/src/mesa', Dir('..'), # src/mapi build path diff --git a/mesalib/src/mapi/glapi/gen/gl_enums.py b/mesalib/src/mapi/glapi/gen/gl_enums.py index 35919d68a..d61618f4d 100644 --- a/mesalib/src/mapi/glapi/gen/gl_enums.py +++ b/mesalib/src/mapi/glapi/gen/gl_enums.py @@ -83,7 +83,7 @@ const char *_mesa_lookup_enum_by_nr( int nr ) STATIC_ASSERT(sizeof(enum_string_table) < (1 << 16)); elt = bsearch(& nr, enum_string_table_offsets, - Elements(enum_string_table_offsets), + ARRAY_SIZE(enum_string_table_offsets), sizeof(enum_string_table_offsets[0]), (cfunc) compar_nr); @@ -127,7 +127,7 @@ static const char *prim_names[PRIM_MAX+3] = { const char * _mesa_lookup_prim_by_nr(GLuint nr) { - if (nr < Elements(prim_names)) + if (nr < ARRAY_SIZE(prim_names)) return prim_names[nr]; else return "invalid mode"; diff --git a/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py b/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py index 19e0e15b0..5a69e0343 100644 --- a/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py +++ b/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py @@ -138,10 +138,6 @@ class PrintGenericStubs(gl_XML.gl_print_base): print '# define GL_PREFIX(n) GLNAME(CONCAT(gl,n))' print '# endif' print '' - print '#if defined(HAVE_PTHREAD) || defined(_WIN32)' - print '# define THREADS' - print '#endif' - print '' print '\t.text' print '' print '#ifdef GLX_USE_TLS' @@ -170,7 +166,7 @@ class PrintGenericStubs(gl_XML.gl_print_base): print '\tmovl\t(%rax), %edi' print '\tjmp\tpthread_getspecific@PLT' print '' - print '#elif defined(THREADS)' + print '#else' print '' print '\t.extern\t_glapi_get_dispatch' print '' diff --git a/mesalib/src/mapi/glapi/gen/gl_x86_asm.py b/mesalib/src/mapi/glapi/gen/gl_x86_asm.py index d87d0bd24..f855dbaaa 100644 --- a/mesalib/src/mapi/glapi/gen/gl_x86_asm.py +++ b/mesalib/src/mapi/glapi/gen/gl_x86_asm.py @@ -78,9 +78,6 @@ class PrintGenericStubs(gl_XML.gl_print_base): print '#define GLOBL_FN(x) GLOBL x' print '#endif' print '' - print '#if defined(HAVE_PTHREAD) || defined(_WIN32)' - print '# define THREADS' - print '#endif' print '' print '#ifdef GLX_USE_TLS' print '' @@ -109,7 +106,7 @@ class PrintGenericStubs(gl_XML.gl_print_base): print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\' print '1:\tCALL(_x86_get_dispatch) ;\t\t\t\\' print '\tJMP(GL_OFFSET(off))' - print '#elif defined(THREADS)' + print '#else' print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\' print 'ALIGNTEXT16;\t\t\t\t\t\t\\' print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\' @@ -120,13 +117,6 @@ class PrintGenericStubs(gl_XML.gl_print_base): print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\' print '1:\tCALL(_glapi_get_dispatch) ;\t\t\t\\' print '\tJMP(GL_OFFSET(off))' - print '#else /* Non-threaded version. */' - print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\' - print 'ALIGNTEXT16;\t\t\t\t\t\t\\' - print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\' - print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\' - print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\' - print '\tJMP(GL_OFFSET(off))' print '#endif' print '' print '#ifdef HAVE_ALIAS' @@ -164,7 +154,7 @@ class PrintGenericStubs(gl_XML.gl_print_base): print '\tCALL(GLNAME(pthread_getspecific))' print '\tADD_L(CONST(28), ESP)' print '\tRET' - print '#elif defined(THREADS)' + print '#else' print 'EXTERN GLNAME(_glapi_get_dispatch)' print '#endif' print '' diff --git a/mesalib/src/mapi/glapi/glapi.h b/mesalib/src/mapi/glapi/glapi.h index e2fa9252f..8d991fb3b 100644 --- a/mesalib/src/mapi/glapi/glapi.h +++ b/mesalib/src/mapi/glapi/glapi.h @@ -44,7 +44,7 @@ #ifndef _GLAPI_H #define _GLAPI_H -#include "u_thread.h" +#include "util/macros.h" #ifdef __cplusplus @@ -102,21 +102,12 @@ _GLAPI_EXPORT extern const void *_glapi_Context; _GLAPI_EXPORT extern struct _glapi_table *_glapi_Dispatch; _GLAPI_EXPORT extern void *_glapi_Context; -# ifdef THREADS - -# define GET_DISPATCH() \ +#define GET_DISPATCH() \ (likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch()) -# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) \ +#define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) \ (likely(_glapi_Context) ? _glapi_Context : _glapi_get_context()) -# else - -# define GET_DISPATCH() _glapi_Dispatch -# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _glapi_Context - -# endif - #endif /* defined (GLX_USE_TLS) */ diff --git a/mesalib/src/mapi/glapi/glapi_entrypoint.c b/mesalib/src/mapi/glapi/glapi_entrypoint.c index 362a8f11b..7facd8aca 100644 --- a/mesalib/src/mapi/glapi/glapi_entrypoint.c +++ b/mesalib/src/mapi/glapi/glapi_entrypoint.c @@ -29,6 +29,7 @@ */ +#include "c11/threads.h" #include "glapi/glapi_priv.h" #include "u_execmem.h" @@ -120,11 +121,9 @@ fill_in_entrypoint_offset(_glapi_proc entrypoint, unsigned int offset) #if defined(GLX_USE_TLS) *((unsigned int *)(code + 8)) = 4 * offset; -#elif defined(THREADS) +#else *((unsigned int *)(code + 11)) = 4 * offset; *((unsigned int *)(code + 22)) = 4 * offset; -#else - *((unsigned int *)(code + 7)) = 4 * offset; #endif } @@ -338,7 +337,7 @@ void init_glapi_relocs_once( void ) { #if defined(HAVE_PTHREAD) || defined(GLX_USE_TLS) - static pthread_once_t once_control = PTHREAD_ONCE_INIT; - pthread_once( & once_control, init_glapi_relocs ); + static once_flag flag = ONCE_FLAG_INIT; + call_once(&flag, init_glapi_relocs); #endif } diff --git a/mesalib/src/mapi/glapi/glapi_priv.h b/mesalib/src/mapi/glapi/glapi_priv.h index 92925faac..d3682603d 100644 --- a/mesalib/src/mapi/glapi/glapi_priv.h +++ b/mesalib/src/mapi/glapi/glapi_priv.h @@ -86,10 +86,8 @@ get_entrypoint_address(unsigned int functionOffset); #if defined(USE_X86_ASM) # if defined(GLX_USE_TLS) # define DISPATCH_FUNCTION_SIZE 16 -# elif defined(THREADS) -# define DISPATCH_FUNCTION_SIZE 32 # else -# define DISPATCH_FUNCTION_SIZE 16 +# define DISPATCH_FUNCTION_SIZE 32 # endif #endif diff --git a/mesalib/src/mapi/mapi.c b/mesalib/src/mapi/mapi.c index aa6b91b42..c235adc4a 100644 --- a/mesalib/src/mapi/mapi.c +++ b/mesalib/src/mapi/mapi.c @@ -29,7 +29,6 @@ #include <string.h> #include "u_current.h" -#include "u_thread.h" #include "mapi.h" #include "stub.h" #include "table.h" diff --git a/mesalib/src/mapi/mapi.h b/mesalib/src/mapi/mapi.h index 2aa8d9fe0..9adf8b5a3 100644 --- a/mesalib/src/mapi/mapi.h +++ b/mesalib/src/mapi/mapi.h @@ -28,8 +28,6 @@ #ifndef _MAPI_H_ #define _MAPI_H_ -#include "u_compiler.h" - #ifdef _WIN32 #ifdef MAPI_DLL_EXPORTS #define MAPI_EXPORT __declspec(dllexport) diff --git a/mesalib/src/mapi/mapi_abi.py b/mesalib/src/mapi/mapi_abi.py index d783ed32f..012a5c3f4 100644 --- a/mesalib/src/mapi/mapi_abi.py +++ b/mesalib/src/mapi/mapi_abi.py @@ -816,25 +816,8 @@ typedef int GLclampx; return header -class VGAPIPrinter(ABIPrinter): - """OpenVG API Printer""" - - def __init__(self, entries): - super(VGAPIPrinter, self).__init__(entries) - - self.api_defines = ['VG_VGEXT_PROTOTYPES'] - self.api_headers = ['"VG/openvg.h"', '"VG/vgext.h"'] - self.api_call = 'VG_API_CALL' - self.api_entry = 'VG_API_ENTRY' - self.api_attrs = 'VG_API_EXIT' - - self.prefix_lib = 'vg' - self.prefix_app = 'vega' - self.prefix_noop = 'noop' - self.prefix_warn = 'vg' - def parse_args(): - printers = ['vgapi', 'glapi', 'es1api', 'es2api', 'shared-glapi'] + printers = ['glapi', 'es1api', 'es2api', 'shared-glapi'] modes = ['lib', 'app'] parser = OptionParser(usage='usage: %prog [options] <filename>') @@ -853,7 +836,6 @@ def parse_args(): def main(): printers = { - 'vgapi': VGAPIPrinter, 'glapi': GLAPIPrinter, 'es1api': ES1APIPrinter, 'es2api': ES2APIPrinter, diff --git a/mesalib/src/mapi/stub.c b/mesalib/src/mapi/stub.c index dfadbe1a5..05436bab6 100644 --- a/mesalib/src/mapi/stub.c +++ b/mesalib/src/mapi/stub.c @@ -28,14 +28,14 @@ #include <stdlib.h> #include <string.h> #include <assert.h> +#include "c11/threads.h" +#include "util/macros.h" #include "u_current.h" -#include "u_thread.h" #include "entry.h" #include "stub.h" #include "table.h" -#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) struct mapi_stub { const void *name; @@ -54,16 +54,8 @@ static int next_dynamic_slot = MAPI_TABLE_NUM_STATIC; void stub_init_once(void) { -#ifdef HAVE_PTHREAD - static pthread_once_t once = PTHREAD_ONCE_INIT; - pthread_once(&once, entry_patch_public); -#else - static int first = 1; - if (first) { - first = 0; - entry_patch_public(); - } -#endif + static once_flag flag = ONCE_FLAG_INIT; + call_once(&flag, entry_patch_public); } static int diff --git a/mesalib/src/mapi/table.h b/mesalib/src/mapi/table.h index df59aed4f..e2d6ef03d 100644 --- a/mesalib/src/mapi/table.h +++ b/mesalib/src/mapi/table.h @@ -28,7 +28,7 @@ #ifndef _TABLE_H_ #define _TABLE_H_ -#include "u_compiler.h" +#include "c99_compat.h" #include "entry.h" #define MAPI_TMP_TABLE @@ -37,12 +37,14 @@ #define MAPI_TABLE_NUM_SLOTS (MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC) #define MAPI_TABLE_SIZE (MAPI_TABLE_NUM_SLOTS * sizeof(mapi_func)) +struct mapi_table; + extern const mapi_func table_noop_array[]; /** * Get the no-op dispatch table. */ -static INLINE const struct mapi_table * +static inline const struct mapi_table * table_get_noop(void) { return (const struct mapi_table *) table_noop_array; @@ -51,7 +53,7 @@ table_get_noop(void) /** * Set the function of a slot. */ -static INLINE void +static inline void table_set_func(struct mapi_table *tbl, int slot, mapi_func func) { mapi_func *funcs = (mapi_func *) tbl; @@ -61,7 +63,7 @@ table_set_func(struct mapi_table *tbl, int slot, mapi_func func) /** * Return the function of a slot. */ -static INLINE mapi_func +static inline mapi_func table_get_func(const struct mapi_table *tbl, int slot) { const mapi_func *funcs = (const mapi_func *) tbl; diff --git a/mesalib/src/mapi/u_compiler.h b/mesalib/src/mapi/u_compiler.h deleted file mode 100644 index f376e97a0..000000000 --- a/mesalib/src/mapi/u_compiler.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _U_COMPILER_H_ -#define _U_COMPILER_H_ - -#include "c99_compat.h" /* inline, __func__, etc. */ - - -/* XXX: Use standard `inline` keyword instead */ -#ifndef INLINE -# define INLINE inline -#endif - -/* Function visibility */ -#ifndef PUBLIC -# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define PUBLIC __attribute__((visibility("default"))) -# elif defined(_MSC_VER) -# define PUBLIC __declspec(dllexport) -# else -# define PUBLIC -# endif -#endif - -#ifndef likely -# if defined(__GNUC__) -# define likely(x) __builtin_expect(!!(x), 1) -# define unlikely(x) __builtin_expect(!!(x), 0) -# else -# define likely(x) (x) -# define unlikely(x) (x) -# endif -#endif - -#endif /* _U_COMPILER_H_ */ diff --git a/mesalib/src/mapi/u_current.c b/mesalib/src/mapi/u_current.c index afa887e06..7e7e275f2 100644 --- a/mesalib/src/mapi/u_current.c +++ b/mesalib/src/mapi/u_current.c @@ -48,8 +48,8 @@ * drivers! No changes to the public glapi interface. */ +#include "c11/threads.h" #include "u_current.h" -#include "u_thread.h" #ifndef MAPI_MODE_UTIL @@ -112,11 +112,9 @@ struct mapi_table *u_current_table = (struct mapi_table *) table_noop_array; void *u_current_context; -#ifdef THREADS -struct u_tsd u_current_table_tsd; -static struct u_tsd u_current_context_tsd; +tss_t u_current_table_tsd; +static tss_t u_current_context_tsd; static int ThreadSafe; -#endif /* THREADS */ #endif /* defined(GLX_USE_TLS) */ /*@}*/ @@ -125,20 +123,20 @@ static int ThreadSafe; void u_current_destroy(void) { -#if defined(THREADS) && defined(_WIN32) - u_tsd_destroy(&u_current_table_tsd); - u_tsd_destroy(&u_current_context_tsd); +#if !defined(GLX_USE_TLS) + tss_delete(u_current_table_tsd); + tss_delete(u_current_context_tsd); #endif } -#if defined(THREADS) && !defined(GLX_USE_TLS) +#if !defined(GLX_USE_TLS) static void u_current_init_tsd(void) { - u_tsd_init(&u_current_table_tsd); - u_tsd_init(&u_current_context_tsd); + tss_create(&u_current_table_tsd, NULL); + tss_create(&u_current_context_tsd, NULL); } /** @@ -146,6 +144,43 @@ u_current_init_tsd(void) */ static mtx_t ThreadCheckMutex = _MTX_INITIALIZER_NP; + +#ifdef _WIN32 +typedef DWORD thread_id; +#else +typedef thrd_t thread_id; +#endif + + +static inline thread_id +get_thread_id(void) +{ + /* + * XXX: Callers of of this function assume it is a lightweight function. + * But unfortunately C11's thrd_current() gives no such guarantees. In + * fact, it's pretty hard to have a compliant implementation of + * thrd_current() on Windows with such characteristics. So for now, we + * side-step this mess and use Windows thread primitives directly here. + */ +#ifdef _WIN32 + return GetCurrentThreadId(); +#else + return thrd_current(); +#endif +} + + +static inline int +thread_id_equal(thread_id t1, thread_id t2) +{ +#ifdef _WIN32 + return t1 == t2; +#else + return thrd_equal(t1, t2); +#endif +} + + /** * We should call this periodically from a function such as glXMakeCurrent * in order to test if multiple threads are being used. @@ -153,7 +188,7 @@ static mtx_t ThreadCheckMutex = _MTX_INITIALIZER_NP; void u_current_init(void) { - static unsigned long knownID; + static thread_id knownID; static int firstCall = 1; if (ThreadSafe) @@ -163,10 +198,10 @@ u_current_init(void) if (firstCall) { u_current_init_tsd(); - knownID = u_thread_self(); + knownID = get_thread_id(); firstCall = 0; } - else if (knownID != u_thread_self()) { + else if (!thread_id_equal(knownID, get_thread_id())) { ThreadSafe = 1; u_current_set_table(NULL); u_current_set_context(NULL); @@ -197,11 +232,9 @@ u_current_set_context(const void *ptr) #if defined(GLX_USE_TLS) u_current_context = (void *) ptr; -#elif defined(THREADS) - u_tsd_set(&u_current_context_tsd, (void *) ptr); - u_current_context = (ThreadSafe) ? NULL : (void *) ptr; #else - u_current_context = (void *) ptr; + tss_set(u_current_context_tsd, (void *) ptr); + u_current_context = (ThreadSafe) ? NULL : (void *) ptr; #endif } @@ -215,12 +248,8 @@ u_current_get_context_internal(void) { #if defined(GLX_USE_TLS) return u_current_context; -#elif defined(THREADS) - return (ThreadSafe) - ? u_tsd_get(&u_current_context_tsd) - : u_current_context; #else - return u_current_context; + return ThreadSafe ? tss_get(u_current_context_tsd) : u_current_context; #endif } @@ -241,11 +270,9 @@ u_current_set_table(const struct mapi_table *tbl) #if defined(GLX_USE_TLS) u_current_table = (struct mapi_table *) tbl; -#elif defined(THREADS) - u_tsd_set(&u_current_table_tsd, (void *) tbl); - u_current_table = (ThreadSafe) ? NULL : (void *) tbl; #else - u_current_table = (struct mapi_table *) tbl; + tss_set(u_current_table_tsd, (void *) tbl); + u_current_table = (ThreadSafe) ? NULL : (void *) tbl; #endif } @@ -257,10 +284,10 @@ u_current_get_table_internal(void) { #if defined(GLX_USE_TLS) return u_current_table; -#elif defined(THREADS) - return (struct mapi_table *) ((ThreadSafe) ? - u_tsd_get(&u_current_table_tsd) : (void *) u_current_table); #else - return u_current_table; + if (ThreadSafe) + return (struct mapi_table *) tss_get(u_current_table_tsd); + else + return (struct mapi_table *) u_current_table; #endif } diff --git a/mesalib/src/mapi/u_current.h b/mesalib/src/mapi/u_current.h index 72708d433..ea4f81723 100644 --- a/mesalib/src/mapi/u_current.h +++ b/mesalib/src/mapi/u_current.h @@ -1,6 +1,10 @@ #ifndef _U_CURRENT_H_ #define _U_CURRENT_H_ +#include "c99_compat.h" +#include "util/macros.h" + + #if defined(MAPI_MODE_UTIL) || defined(MAPI_MODE_GLAPI) || \ defined(MAPI_MODE_BRIDGE) @@ -24,8 +28,6 @@ #else /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */ -#include "u_compiler.h" - struct mapi_table; #ifdef GLX_USE_TLS @@ -63,7 +65,7 @@ u_current_set_context(const void *ptr); void * u_current_get_context_internal(void); -static INLINE const struct mapi_table * +static inline const struct mapi_table * u_current_get_table(void) { #ifdef GLX_USE_TLS @@ -74,7 +76,7 @@ u_current_get_table(void) #endif } -static INLINE const void * +static inline const void * u_current_get_context(void) { #ifdef GLX_USE_TLS diff --git a/mesalib/src/mapi/u_execmem.c b/mesalib/src/mapi/u_execmem.c index ac1cae093..89d5c1d08 100644 --- a/mesalib/src/mapi/u_execmem.c +++ b/mesalib/src/mapi/u_execmem.c @@ -32,8 +32,8 @@ */ -#include "u_compiler.h" -#include "u_thread.h" +#include "c99_compat.h" +#include "c11/threads.h" #include "u_execmem.h" diff --git a/mesalib/src/mapi/u_macros.h b/mesalib/src/mapi/u_macros.h deleted file mode 100644 index 72345b5f1..000000000 --- a/mesalib/src/mapi/u_macros.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _U_MACROS_ -#define _U_MACROS_ - -#define _U_STRINGIFY(x) #x -#define _U_CONCAT(x, y) x ## y -#define _U_CONCAT_STR(x, y) #x#y - -#define U_STRINGIFY(x) _U_STRINGIFY(x) -#define U_CONCAT(x, y) _U_CONCAT(x, y) -#define U_CONCAT_STR(x, y) _U_CONCAT_STR(x, y) - -#endif /* _U_MACROS_ */ diff --git a/mesalib/src/mapi/u_thread.h b/mesalib/src/mapi/u_thread.h deleted file mode 100644 index 57c3b076a..000000000 --- a/mesalib/src/mapi/u_thread.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - - -/* - * Thread support for gl dispatch. - * - * Initial version by John Stone (j.stone@acm.org) (johns@cs.umr.edu) - * and Christoph Poliwoda (poliwoda@volumegraphics.com) - * Revised by Keith Whitwell - * Adapted for new gl dispatcher by Brian Paul - * Modified for use in mapi by Chia-I Wu - */ - -/* - * If this file is accidentally included by a non-threaded build, - * it should not cause the build to fail, or otherwise cause problems. - * In general, it should only be included when needed however. - */ - -#ifndef _U_THREAD_H_ -#define _U_THREAD_H_ - -#include <stdio.h> -#include <stdlib.h> -#include "u_compiler.h" - -#include "c11/threads.h" - -#if defined(HAVE_PTHREAD) || defined(_WIN32) -#ifndef THREADS -#define THREADS -#endif -#endif - -/* - * Error messages - */ -#define INIT_TSD_ERROR "Mesa: failed to allocate key for thread specific data" -#define GET_TSD_ERROR "Mesa: failed to get thread specific data" -#define SET_TSD_ERROR "Mesa: thread failed to set thread specific data" - - -/* - * Magic number to determine if a TSD object has been initialized. - * Kind of a hack but there doesn't appear to be a better cross-platform - * solution. - */ -#define INIT_MAGIC 0xff8adc98 - -#ifdef __cplusplus -extern "C" { -#endif - - -struct u_tsd { - tss_t key; - unsigned initMagic; -}; - - -static INLINE unsigned long -u_thread_self(void) -{ - /* - * XXX: Callers of u_thread_self assume it is a lightweight function, - * returning a numeric value. But unfortunately C11's thrd_current() gives - * no such guarantees. In fact, it's pretty hard to have a compliant - * implementation of thrd_current() on Windows with such characteristics. - * So for now, we side-step this mess and use Windows thread primitives - * directly here. - * - * FIXME: On the other hand, u_thread_self() is a bad - * abstraction. Even with pthreads, there is no guarantee that - * pthread_self() will return numeric IDs -- we should be using - * pthread_equal() instead of assuming we can compare thread ids... - */ -#ifdef _WIN32 - return GetCurrentThreadId(); -#else - return (unsigned long) (uintptr_t) thrd_current(); -#endif -} - - -static INLINE void -u_tsd_init(struct u_tsd *tsd) -{ - if (tss_create(&tsd->key, NULL/*free*/) != 0) { - perror(INIT_TSD_ERROR); - exit(-1); - } - tsd->initMagic = INIT_MAGIC; -} - - -static INLINE void * -u_tsd_get(struct u_tsd *tsd) -{ - if (tsd->initMagic != INIT_MAGIC) { - u_tsd_init(tsd); - } - return tss_get(tsd->key); -} - - -static INLINE void -u_tsd_set(struct u_tsd *tsd, void *ptr) -{ - if (tsd->initMagic != INIT_MAGIC) { - u_tsd_init(tsd); - } - if (tss_set(tsd->key, ptr) != 0) { - perror(SET_TSD_ERROR); - exit(-1); - } -} - - -static INLINE void -u_tsd_destroy(struct u_tsd *tsd) -{ - if (tsd->initMagic != INIT_MAGIC) { - return; - } - tss_delete(tsd->key); - tsd->initMagic = 0x0; -} - - -#ifdef __cplusplus -} -#endif - -#endif /* _U_THREAD_H_ */ diff --git a/mesalib/src/mesa/Android.gen.mk b/mesalib/src/mesa/Android.gen.mk index c7b7f7edf..caae2c107 100644 --- a/mesalib/src/mesa/Android.gen.mk +++ b/mesalib/src/mesa/Android.gen.mk @@ -122,5 +122,5 @@ format_info_deps := \ $(LOCAL_PATH)/main/format_parser.py \ $(FORMAT_INFO) -$(intermediates)/main/format_info.c: $(format_info_deps) +$(intermediates)/main/format_info.h: $(format_info_deps) @$(MESA_PYTHON2) $(FORMAT_INFO) $< > $@ diff --git a/mesalib/src/mesa/Makefile.am b/mesalib/src/mesa/Makefile.am index b6cb8f111..3dab8f03f 100644 --- a/mesalib/src/mesa/Makefile.am +++ b/mesalib/src/mesa/Makefile.am @@ -62,7 +62,6 @@ include Makefile.sources EXTRA_DIST = \ drivers/haiku \ drivers/SConscript \ - drivers/windows \ main/format_info.py \ main/format_pack.py \ main/format_parser.py \ @@ -80,7 +79,7 @@ EXTRA_DIST = \ BUILT_SOURCES = \ main/get_hash.h \ - main/format_info.c \ + main/format_info.h \ main/git_sha1.h \ main/format_pack.c \ main/format_unpack.c \ @@ -94,13 +93,13 @@ CLEANFILES = \ GET_HASH_GEN = main/get_hash_generator.py main/get_hash.h: ../mapi/glapi/gen/gl_and_es_API.xml main/get_hash_params.py \ - $(GET_HASH_GEN) Makefile + $(GET_HASH_GEN) $(AM_V_GEN)set -e; \ $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/$(GET_HASH_GEN) \ -f $< > $@.tmp; \ mv $@.tmp $@; -main/format_info.c: main/formats.csv \ +main/format_info.h: main/formats.csv \ main/format_parser.py main/format_info.py $(AM_V_GEN)set -e; \ $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/main/format_info.py \ @@ -123,7 +122,7 @@ main/format_unpack.c: main/format_unpack.py main/formats.csv \ $(srcdir)/main/formats.csv \ | $(INDENT) $(INDENT_FLAGS) > $@; -main/formats.c: main/format_info.c +main/formats.c: main/format_info.h noinst_LTLIBRARIES = $(ARCH_LIBS) if NEED_LIBMESA @@ -136,8 +135,14 @@ noinst_LTLIBRARIES += libmesagallium.la endif AM_CPPFLAGS = $(DEFINES) $(INCLUDE_DIRS) -AM_CFLAGS = $(LLVM_CFLAGS) $(VISIBILITY_CFLAGS) -AM_CXXFLAGS = $(LLVM_CFLAGS) $(VISIBILITY_CXXFLAGS) +AM_CFLAGS = \ + $(LLVM_CFLAGS) \ + $(VISIBILITY_CFLAGS) \ + $(MSVC2013_COMPAT_CFLAGS) +AM_CXXFLAGS = \ + $(LLVM_CFLAGS) \ + $(VISIBILITY_CXXFLAGS) \ + $(MSVC2013_COMPAT_CXXFLAGS) ARCH_LIBS = diff --git a/mesalib/src/mesa/Makefile.sources b/mesalib/src/mesa/Makefile.sources index 5b4e71253..217be9ab3 100644 --- a/mesalib/src/mesa/Makefile.sources +++ b/mesalib/src/mesa/Makefile.sources @@ -86,6 +86,7 @@ MAIN_FILES = \ main/ffvertex_prog.h \ main/fog.c \ main/fog.h \ + main/format_info.h \ main/format_pack.h \ main/format_pack.c \ main/format_unpack.h \ @@ -100,6 +101,7 @@ MAIN_FILES = \ main/framebuffer.h \ main/get.c \ main/get.h \ + main/get_hash.h \ main/genmipmap.c \ main/genmipmap.h \ main/getstring.c \ diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript index 62e81ced1..81939f981 100644 --- a/mesalib/src/mesa/SConscript +++ b/mesalib/src/mesa/SConscript @@ -10,6 +10,8 @@ from sys import executable as python_cmd env = env.Clone() +env.MSVC2013Compat() + env.Append(CPPPATH = [ '#/src', '#/src/mapi', @@ -62,7 +64,7 @@ get_hash_header = env.CodeGenerate( ) format_info = env.CodeGenerate( - target = 'main/format_info.c', + target = 'main/format_info.h', script = 'main/format_info.py', source = 'main/formats.csv', command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET' diff --git a/mesalib/src/mesa/drivers/SConscript b/mesalib/src/mesa/drivers/SConscript index 9888e3306..17813da96 100644 --- a/mesalib/src/mesa/drivers/SConscript +++ b/mesalib/src/mesa/drivers/SConscript @@ -11,8 +11,5 @@ if env['dri']: 'dri/common/SConscript', ]) -if env['platform'] == 'windows': - SConscript('windows/gdi/SConscript') - if env['platform'] == 'haiku': SConscript('haiku/swrast/SConscript') diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.h b/mesalib/src/mesa/drivers/common/driverfuncs.h index 6b9a90074..385ccb8dd 100644 --- a/mesalib/src/mesa/drivers/common/driverfuncs.h +++ b/mesalib/src/mesa/drivers/common/driverfuncs.h @@ -26,6 +26,10 @@ #ifndef DRIVERFUNCS_H #define DRIVERFUNCS_H +#ifdef __cplusplus +extern "C" { +#endif + extern void _mesa_init_driver_functions(struct dd_function_table *driver); @@ -33,5 +37,8 @@ _mesa_init_driver_functions(struct dd_function_table *driver); extern void _mesa_init_driver_state(struct gl_context *ctx); +#ifdef __cplusplus +} // extern "C" +#endif #endif diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index 3636ee83b..fdc4cf1e9 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -393,7 +393,7 @@ _mesa_meta_setup_vertex_objects(GLuint *VAO, GLuint *VBO, void _mesa_meta_init(struct gl_context *ctx) { - ASSERT(!ctx->Meta); + assert(!ctx->Meta); ctx->Meta = CALLOC_STRUCT(gl_meta_state); } @@ -823,6 +823,8 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) void _mesa_meta_end(struct gl_context *ctx) { + assert(ctx->Meta->SaveStackDepth > 0); + struct save_state *save = &ctx->Meta->Save[ctx->Meta->SaveStackDepth - 1]; const GLbitfield state = save->SavedState; int i; @@ -1045,7 +1047,7 @@ _mesa_meta_end(struct gl_context *ctx) if (state & MESA_META_TEXTURE) { GLuint u, tgt; - ASSERT(ctx->Texture.CurrentUnit == 0); + assert(ctx->Texture.CurrentUnit == 0); /* restore texenv for unit[0] */ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, save->EnvMode); @@ -1332,8 +1334,8 @@ _mesa_meta_alloc_texture(struct temp_texture *tex, { GLboolean newTex = GL_FALSE; - ASSERT(width <= tex->MaxSize); - ASSERT(height <= tex->MaxSize); + assert(width <= tex->MaxSize); + assert(height <= tex->MaxSize); if (width > tex->Width || height > tex->Height || @@ -1747,7 +1749,7 @@ meta_clear(struct gl_context *ctx, GLbitfield buffers, bool glsl) _mesa_ClampColor(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE); } else { - ASSERT(metaSave & MESA_META_COLOR_MASK); + assert(metaSave & MESA_META_COLOR_MASK); _mesa_ColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); } diff --git a/mesalib/src/mesa/drivers/common/meta_blit.c b/mesalib/src/mesa/drivers/common/meta_blit.c index 3406be1ed..bb2164276 100644 --- a/mesalib/src/mesa/drivers/common/meta_blit.c +++ b/mesalib/src/mesa/drivers/common/meta_blit.c @@ -82,7 +82,7 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx, y_scale = samples * 0.5; /* We expect only power of 2 samples in source multisample buffer. */ - assert((samples & (samples - 1)) == 0); + assert(samples > 0 && (samples & (samples - 1)) == 0); while (samples >> (shader_offset + 1)) { shader_offset++; } @@ -133,6 +133,8 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx, sample_map = ctx->Const.SampleMap8x; break; default: + sample_number = NULL; + sample_map = NULL; _mesa_problem(ctx, "Unsupported sample count %d\n", samples); unreachable("Unsupported sample count"); } @@ -261,7 +263,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, } /* We expect only power of 2 samples in source multisample buffer. */ - assert((samples & (samples - 1)) == 0); + assert(samples > 0 && (samples & (samples - 1)) == 0); while (samples >> (shader_offset + 1)) { shader_offset++; } diff --git a/mesalib/src/mesa/drivers/common/meta_tex_subimage.c b/mesalib/src/mesa/drivers/common/meta_tex_subimage.c index 68c8273fe..e29addb73 100644 --- a/mesalib/src/mesa/drivers/common/meta_tex_subimage.c +++ b/mesalib/src/mesa/drivers/common/meta_tex_subimage.c @@ -44,7 +44,7 @@ static struct gl_texture_image * create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, - GLenum pbo_target, int width, int height, int depth, + GLenum pbo_target, int width, int height, GLenum format, GLenum type, const void *pixels, const struct gl_pixelstore_attrib *packing, GLuint *tmp_pbo, GLuint *tmp_tex) @@ -57,8 +57,7 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, struct gl_texture_image *tex_image; bool read_only; - if ((packing->ImageHeight != 0 && packing->ImageHeight != height) || - packing->SwapBytes || + if (packing->SwapBytes || packing->LsbFirst || packing->Invert) return NULL; @@ -79,6 +78,8 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, *tmp_pbo = 0; buffer_obj = packing->BufferObj; } else { + bool is_pixel_pack = pbo_target == GL_PIXEL_PACK_BUFFER; + assert(create_pbo); _mesa_GenBuffers(1, tmp_pbo); @@ -89,9 +90,17 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, */ _mesa_BindBuffer(pbo_target, *tmp_pbo); - _mesa_BufferData(pbo_target, row_stride * height, pixels, GL_STREAM_DRAW); + /* In case of GL_PIXEL_PACK_BUFFER, pass null pointer for the pixel + * data to avoid unnecessary data copying in _mesa_BufferData(). + */ + if (is_pixel_pack) + _mesa_BufferData(pbo_target, row_stride * height, NULL, + GL_STREAM_READ); + else + _mesa_BufferData(pbo_target, row_stride * height, pixels, + GL_STREAM_DRAW); - buffer_obj = ctx->Unpack.BufferObj; + buffer_obj = packing->BufferObj; pixels = NULL; _mesa_BindBuffer(pbo_target, 0); @@ -99,14 +108,16 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, _mesa_GenTextures(1, tmp_tex); tex_obj = _mesa_lookup_texture(ctx, *tmp_tex); - tex_obj->Target = depth > 1 ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D; - tex_obj->Immutable = GL_TRUE; _mesa_initialize_texture_object(ctx, tex_obj, *tmp_tex, GL_TEXTURE_2D); + /* This must be set after _mesa_initialize_texture_object, not before. */ + tex_obj->Immutable = GL_TRUE; + /* This is required for interactions with ARB_texture_view. */ + tex_obj->NumLayers = 1; internal_format = _mesa_get_format_base_format(pbo_format); tex_image = _mesa_get_tex_image(ctx, tex_obj, tex_obj->Target, 0); - _mesa_init_teximage_fields(ctx, tex_image, width, height, depth, + _mesa_init_teximage_fields(ctx, tex_image, width, height, 1, 0, internal_format, pbo_format); read_only = pbo_target == GL_PIXEL_UNPACK_BUFFER; @@ -133,6 +144,7 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, const struct gl_pixelstore_attrib *packing) { GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 }; + int full_height, image_height; struct gl_texture_image *pbo_tex_image; GLenum status; bool success = false; @@ -166,9 +178,16 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, return true; } + /* For arrays, use a tall (height * depth) 2D texture but taking into + * account the inter-image padding specified with the image height packing + * property. + */ + image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight; + full_height = image_height * (depth - 1) + height; + pbo_tex_image = create_texture_for_pbo(ctx, create_pbo, GL_PIXEL_UNPACK_BUFFER, - width, height, depth, + width, full_height, format, type, pixels, packing, &pbo, &pbo_tex); if (!pbo_tex_image) @@ -177,8 +196,8 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, if (allocate_storage) ctx->Driver.AllocTextureImageBuffer(ctx, tex_image); - /* Only stash the current FBO */ - _mesa_meta_begin(ctx, 0); + _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER | + MESA_META_PIXEL_STORE)); _mesa_GenFramebuffers(2, fbos); _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbos[0]); @@ -186,8 +205,12 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, if (tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) { assert(depth == 1); + assert(zoffset == 0); depth = height; height = 1; + image_height = 1; + zoffset = yoffset; + yoffset = 0; } _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, @@ -214,15 +237,14 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, goto fail; for (z = 1; z < depth; z++) { - _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - pbo_tex_image, z); _mesa_meta_bind_fbo_image(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex_image, zoffset + z); _mesa_update_state(ctx); _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, - 0, 0, width, height, + 0, z * image_height, + width, z * image_height + height, xoffset, yoffset, xoffset + width, yoffset + height, GL_COLOR_BUFFER_BIT, GL_NEAREST); @@ -249,6 +271,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, const struct gl_pixelstore_attrib *packing) { GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 }; + int full_height, image_height; struct gl_texture_image *pbo_tex_image; GLenum status; bool success = false; @@ -282,22 +305,33 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, return true; } + /* For arrays, use a tall (height * depth) 2D texture but taking into + * account the inter-image padding specified with the image height packing + * property. + */ + image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight; + full_height = image_height * (depth - 1) + height; + pbo_tex_image = create_texture_for_pbo(ctx, false, GL_PIXEL_PACK_BUFFER, - width, height, depth, + width, full_height * depth, format, type, pixels, packing, &pbo, &pbo_tex); if (!pbo_tex_image) return false; - /* Only stash the current FBO */ - _mesa_meta_begin(ctx, 0); + _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER | + MESA_META_PIXEL_STORE)); _mesa_GenFramebuffers(2, fbos); if (tex_image && tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) { assert(depth == 1); + assert(zoffset == 0); depth = height; height = 1; + image_height = 1; + zoffset = yoffset; + yoffset = 0; } /* If we were given a texture, bind it to the read framebuffer. If not, @@ -336,15 +370,14 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, for (z = 1; z < depth; z++) { _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex_image, zoffset + z); - _mesa_meta_bind_fbo_image(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - pbo_tex_image, z); _mesa_update_state(ctx); _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, xoffset, yoffset, xoffset + width, yoffset + height, - 0, 0, width, height, + 0, z * image_height, + width, z * image_height + height, GL_COLOR_BUFFER_BIT, GL_NEAREST); } diff --git a/mesalib/src/mesa/drivers/dri/common/utils.c b/mesalib/src/mesa/drivers/dri/common/utils.c index f2e63c0b9..bb22107e9 100644 --- a/mesalib/src/mesa/drivers/dri/common/utils.c +++ b/mesalib/src/mesa/drivers/dri/common/utils.c @@ -30,6 +30,7 @@ */ #include <string.h> +#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <stdint.h> @@ -485,6 +486,7 @@ driIndexConfigAttrib(const __DRIconfig *config, int index, * Currently only the following queries are supported by this function: * * - \c __DRI2_RENDERER_VERSION + * - \c __DRI2_RENDERER_PREFERRED_PROFILE * - \c __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION * - \c __DRI2_RENDERER_OPENGL_COMPATIBLITY_PROFILE_VERSION * - \c __DRI2_RENDERER_ES_PROFILE_VERSION diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c index d69eb0196..2b284ccf2 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c +++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c @@ -27,10 +27,13 @@ * \author Felix Kuehling */ +#include <stdarg.h> +#include <stdio.h> #include <string.h> #include <assert.h> #include <expat.h> #include <fcntl.h> +#include <math.h> #include <unistd.h> #include <errno.h> #include "main/imports.h" diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am b/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am index da7d03480..555771685 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am +++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am @@ -52,7 +52,7 @@ POT=xmlpool.pot .PHONY: all clean pot po mo -EXTRA_DIST = gen_xmlpool.py t_options.h $(POS) SConscript +EXTRA_DIST = gen_xmlpool.py options.h t_options.h $(POS) SConscript BUILT_SOURCES = options.h CLEANFILES = $(MOS) options.h diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po b/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po index 23e9f4211..03bf29613 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po +++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po @@ -25,15 +25,15 @@ msgid "" msgstr "" "Project-Id-Version: Mesa 10.1.0-devel\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-09-25 22:29-0600\n" -"PO-Revision-Date: 2014-09-26 14:43-0700\n" +"POT-Creation-Date: 2015-02-07 02:08-0700\n" +"PO-Revision-Date: 2015-02-23 14:28-0700\n" "Last-Translator: Alex Henrie <alexhenrie24@gmail.com>\n" "Language-Team: Catalan <ca@li.org>\n" "Language: ca\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.6.9\n" +"X-Generator: Poedit 1.7.4\n" #: t_options.h:56 msgid "Debugging" @@ -83,8 +83,8 @@ msgstr "Deshabilita el GL_ARB_shader_bit_encoding" msgid "" "Force a default GLSL version for shaders that lack an explicit #version line" msgstr "" -"Força una versió GLSL per defecte en els shaders als quals falta una lÃnia " -"#version explÃcita" +"Força una versió GLSL per defecte en els shaders als quals lis manca una " +"lÃnia #version explÃcita" #: t_options.h:110 msgid "Allow GLSL #extension directives in the middle of shaders" @@ -92,7 +92,7 @@ msgstr "Permet les directives #extension GLSL en el mitjà dels shaders" #: t_options.h:120 msgid "Image Quality" -msgstr "Qualitat d'Imatge" +msgstr "Qualitat d'imatge" #: t_options.h:133 msgid "Texture color depth" @@ -149,11 +149,11 @@ msgstr "Mètode d'arrodoniment de color" #: t_options.h:171 msgid "Round color components downward" -msgstr "Arrondeix els components de color a baix" +msgstr "Arrodoneix els components de color a baix" #: t_options.h:172 msgid "Round to nearest color" -msgstr "Arrondeix al color més proper" +msgstr "Arrodoneix al color més proper" #: t_options.h:181 msgid "Color dithering method" @@ -181,15 +181,15 @@ msgstr "Un filtre de postprocessament per a aplicar cel shading a la sortida" #: t_options.h:200 msgid "A post-processing filter to remove the red channel" -msgstr "Un filtre de postprocessament per a treure el canal vermell" +msgstr "Un filtre de postprocessament per a eliminar el canal vermell" #: t_options.h:205 msgid "A post-processing filter to remove the green channel" -msgstr "Un filtre de postprocessament per a treure el canal verd" +msgstr "Un filtre de postprocessament per a eliminar el canal verd" #: t_options.h:210 msgid "A post-processing filter to remove the blue channel" -msgstr "Un filtre de postprocessament per a treure el canal blau" +msgstr "Un filtre de postprocessament per a eliminar el canal blau" #: t_options.h:215 msgid "" @@ -222,17 +222,17 @@ msgstr "Utilitza la canonada TCL de programari" #: t_options.h:240 msgid "Use hardware TCL as first TCL pipeline stage" -msgstr "Utilitza el TCL maquinà ri com la primera fase de la canonada TCL" +msgstr "Utilitza el TCL de maquinari com a la primera fase de la canonada TCL" #: t_options.h:241 msgid "Bypass the TCL pipeline" -msgstr "Passar per alt la canonada TCL" +msgstr "Passa per alt la canonada TCL" #: t_options.h:242 msgid "" "Bypass the TCL pipeline with state-based machine code generated on-the-fly" msgstr "" -"Passar per alt la canonada TCL amb codi mà quina basat en estats, generat " +"Passa per alt la canonada TCL amb codi de mà quina basat en estats, generat " "sobre la marxa" #: t_options.h:251 @@ -245,7 +245,7 @@ msgstr "Espera activa pel maquinari de grà fics" #: t_options.h:253 msgid "Sleep for brief intervals while waiting for the graphics hardware" -msgstr "Dormi per intervals breus mentre s'espera al maquinari de grà fics" +msgstr "Dorm per intervals breus mentre s'espera al maquinari de grà fics" #: t_options.h:254 msgid "Let the graphics hardware emit a software interrupt and sleep" @@ -259,7 +259,7 @@ msgstr "Sincronització amb refresc vertical (intervals d'intercanvi)" #: t_options.h:265 msgid "Never synchronize with vertical refresh, ignore application's choice" msgstr "" -"Mai sincronitzis amb el refresc vertial, ignora l'elecció de l'aplicació" +"Mai sincronitzis amb el refresc vertical, ignora l'elecció de l'aplicació" #: t_options.h:266 msgid "Initial swap interval 0, obey application's choice" @@ -301,7 +301,7 @@ msgstr "Tota la memòria disponible" #: t_options.h:296 msgid "Only card memory (if available)" -msgstr "Només memòria de tarjeta (si està disponible)" +msgstr "Només memòria de targeta (si està disponible)" #: t_options.h:297 msgid "Only GART (AGP/PCIE) memory (if available)" @@ -329,4 +329,20 @@ msgstr "Inicialització" #: t_options.h:341 msgid "Define the graphic device to use if possible" -msgstr "Defineix el dispositiu de grà fics que usar si és possible" +msgstr "Defineix el dispositiu de grà fics que utilitzar si és possible" + +#: t_options.h:350 +msgid "Gallium Nine" +msgstr "Gallium Nine" + +#: t_options.h:354 +msgid "" +"Define the throttling value. -1 for no throttling, -2 for default (usually " +"2), 0 for glfinish behaviour" +msgstr "" +"Defineix el valor de regulació. -1 per a no regular, -2 per al predeterminat " +"(generalment 2), 0 per al comportament de glfinish" + +#: t_options.h:359 +msgid "Use an additional thread to submit buffers." +msgstr "Utilitza un fil addicional per a entregar els buffers." diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po b/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po index a68c329a5..f9d950ac1 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po +++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po @@ -9,8 +9,8 @@ msgid "" msgstr "" "Project-Id-Version: es\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-09-25 22:29-0600\n" -"PO-Revision-Date: 2014-09-26 14:22-0700\n" +"POT-Creation-Date: 2015-02-07 02:08-0700\n" +"PO-Revision-Date: 2015-02-23 14:54-0700\n" "Last-Translator: Alex Henrie <alexhenrie24@gmail.com>\n" "Language-Team: Spanish <es@li.org>\n" "Language: es\n" @@ -18,7 +18,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 1.6.9\n" +"X-Generator: Poedit 1.7.4\n" #: t_options.h:56 msgid "Debugging" @@ -301,11 +301,11 @@ msgstr "Habilitar la extensión GL_ARB_vertex_program" #: t_options.h:323 msgid "Miscellaneous" -msgstr "Misceláneo" +msgstr "Misceláneos" #: t_options.h:327 msgid "Create all visuals with a depth buffer" -msgstr "Crear todos los visuales con buffer de profundidad" +msgstr "Crear todos los visuales con búfer de profundidad" #: t_options.h:337 msgid "Initialization" @@ -314,3 +314,19 @@ msgstr "Inicialización" #: t_options.h:341 msgid "Define the graphic device to use if possible" msgstr "Define el dispositivo de gráficos que usar si es posible" + +#: t_options.h:350 +msgid "Gallium Nine" +msgstr "Gallium Nine" + +#: t_options.h:354 +msgid "" +"Define the throttling value. -1 for no throttling, -2 for default (usually " +"2), 0 for glfinish behaviour" +msgstr "" +"Define el valor de regulación. -1 para no regular, -2 para el por defecto " +"(generalmente 2), 0 para el comportamiento de glfinish" + +#: t_options.h:359 +msgid "Use an additional thread to submit buffers." +msgstr "Usar un hilo adicional para entregar los búfer." diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c index 8005f7d69..fb29078b6 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c @@ -32,6 +32,7 @@ * The back-buffer is allocated by the driver and is private. */ +#include <stdio.h> #include "main/api_exec.h" #include "main/context.h" #include "main/extensions.h" @@ -341,7 +342,7 @@ swrast_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) } /* see bytes_per_line in libGL */ -static INLINE int +static inline int bytes_per_line(unsigned pitch_bits, unsigned mul) { unsigned mask = mul - 1; @@ -481,7 +482,7 @@ swrast_map_renderbuffer(struct gl_context *ctx, return; } - ASSERT(xrb->Base.Buffer); + assert(xrb->Base.Buffer); if (rb->AllocStorage == swrast_alloc_back_storage) { map += (rb->Height - 1) * stride; diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h b/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h index 535f6fe59..1f3a48f38 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -65,13 +65,13 @@ struct dri_context __DRIcontext *cPriv; }; -static INLINE struct dri_context * +static inline struct dri_context * dri_context(__DRIcontext * driContextPriv) { return (struct dri_context *)driContextPriv->driverPrivate; } -static INLINE struct dri_context * +static inline struct dri_context * swrast_context(struct gl_context *ctx) { return (struct dri_context *) ctx; @@ -89,13 +89,13 @@ struct dri_drawable char *row; }; -static INLINE struct dri_drawable * +static inline struct dri_drawable * dri_drawable(__DRIdrawable * driDrawPriv) { return (struct dri_drawable *)driDrawPriv->driverPrivate; } -static INLINE struct dri_drawable * +static inline struct dri_drawable * swrast_drawable(struct gl_framebuffer *fb) { return (struct dri_drawable *) fb; @@ -115,7 +115,7 @@ struct dri_swrast_renderbuffer { GLuint bpp; }; -static INLINE struct dri_swrast_renderbuffer * +static inline struct dri_swrast_renderbuffer * dri_swrast_renderbuffer(struct gl_renderbuffer *rb) { return (struct dri_swrast_renderbuffer *) rb; diff --git a/mesalib/src/mesa/drivers/windows/gdi/SConscript b/mesalib/src/mesa/drivers/windows/gdi/SConscript deleted file mode 100644 index 1f4d7e1fa..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/SConscript +++ /dev/null @@ -1,40 +0,0 @@ -Import('*') - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '#src', - '#src/mapi', - '#src/mesa', -]) - -env.AppendUnique(CPPDEFINES = [ - '_GDI32_', # prevent wgl* being declared __declspec(dllimport) - 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers -]) -if not env['gles']: - # prevent _glapi_* from being declared __declspec(dllimport) - env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS']) - -env.Prepend(LIBS = [ - mesautil, - glapi, - mesa, - glsl, - 'gdi32', - 'user32', - 'kernel32', -]) - -sources = [ - 'mesa.def', - 'wgl.c', - 'wmesa.c', -] - -mesagdi = env.SharedLibrary( - target = 'opengl32', - source = sources, -) - -env.Alias('mesagdi', mesagdi) diff --git a/mesalib/src/mesa/drivers/windows/gdi/colors.h b/mesalib/src/mesa/drivers/windows/gdi/colors.h deleted file mode 100644 index 03e512c1f..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/colors.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Values for wmesa->pixelformat: */ - -#define PF_8A8B8G8R 3 /* 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R */ -#define PF_8R8G8B 4 /* 32-bit TrueColor: 8-R, 8-G, 8-B */ -#define PF_5R6G5B 5 /* 16-bit TrueColor: 5-R, 6-G, 5-B bits */ -#define PF_DITHER8 6 /* Dithered RGB using a lookup table */ -#define PF_LOOKUP 7 /* Undithered RGB using a lookup table */ -#define PF_GRAYSCALE 10 /* Grayscale or StaticGray */ -#define PF_BADFORMAT 11 -#define PF_INDEX8 12 - - -#define BGR8(r,g,b) (unsigned)(((BYTE)((b & 0xc0) | ((g & 0xe0)>>2) | \ - ((r & 0xe0)>>5)))) - -/* Windows uses 5,5,5 for 16-bit */ -#define BGR16(r,g,b) ( (((unsigned short)b ) >> 3) | \ - (((unsigned short)g & 0xf8) << 2) | \ - (((unsigned short)r & 0xf8) << 7) ) - -#define BGR24(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)| \ - ((WORD)((BYTE)(g))<<8))| \ - (((DWORD)(BYTE)(r))<<16))) - -#define BGR32(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)| \ - ((WORD)((BYTE)(g))<<8))| \ - (((DWORD)(BYTE)(r))<<16))) - - diff --git a/mesalib/src/mesa/drivers/windows/gdi/mesa.def b/mesalib/src/mesa/drivers/windows/gdi/mesa.def deleted file mode 100644 index a52207b63..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/mesa.def +++ /dev/null @@ -1,385 +0,0 @@ -; -; Module definition file for Mesa (OPENGL32.DLL) -; -; Note: The OpenGL functions use the STDCALL -; function calling convention. Microsoft's -; OPENGL32 uses this convention and so must the -; Mesa OPENGL32 so that the Mesa DLL can be used -; as a drop-in replacement. -; -; The linker exports STDCALL entry points with -; 'decorated' names; e.g., _glBegin@0, where the -; trailing number is the number of bytes of -; parameter data pushed onto the stack. The -; callee is responsible for popping this data -; off the stack, usually via a RETF n instruction. -; -; However, the Microsoft OPENGL32.DLL does not export -; the decorated names, even though the calling convention -; is STDCALL. So, this module definition file is -; needed to force the Mesa OPENGL32.DLL to export the -; symbols in the same manner as the Microsoft DLL. -; Were it not for this problem, this file would not -; be needed (for the gl* functions) since the entry -; points are compiled with dllexport declspec. -; -EXPORTS - glAccum - glAlphaFunc - glAreTexturesResident - glArrayElement - glBegin - glBindTexture - glBitmap - glBlendFunc - glCallList - glCallLists - glClear - glClearAccum - glClearColor - glClearDepth - glClearIndex - glClearStencil - glClipPlane - glColor3b - glColor3bv - glColor3d - glColor3dv - glColor3f - glColor3fv - glColor3i - glColor3iv - glColor3s - glColor3sv - glColor3ub - glColor3ubv - glColor3ui - glColor3uiv - glColor3us - glColor3usv - glColor4b - glColor4bv - glColor4d - glColor4dv - glColor4f - glColor4fv - glColor4i - glColor4iv - glColor4s - glColor4sv - glColor4ub - glColor4ubv - glColor4ui - glColor4uiv - glColor4us - glColor4usv - glColorMask - glColorMaterial - glColorPointer - glCopyPixels - glCopyTexImage1D - glCopyTexImage2D - glCopyTexSubImage1D - glCopyTexSubImage2D - glCullFace - glDeleteLists - glDeleteTextures - glDepthFunc - glDepthMask - glDepthRange - glDisable - glDisableClientState - glDrawArrays - glDrawBuffer - glDrawElements - glDrawPixels - glEdgeFlag - glEdgeFlagPointer - glEdgeFlagv - glEnable - glEnableClientState - glEnd - glEndList - glEvalCoord1d - glEvalCoord1dv - glEvalCoord1f - glEvalCoord1fv - glEvalCoord2d - glEvalCoord2dv - glEvalCoord2f - glEvalCoord2fv - glEvalMesh1 - glEvalMesh2 - glEvalPoint1 - glEvalPoint2 - glFeedbackBuffer - glFinish - glFlush - glFogf - glFogfv - glFogi - glFogiv - glFrontFace - glFrustum - glGenLists - glGenTextures - glGetBooleanv - glGetClipPlane - glGetDoublev - glGetError - glGetFloatv - glGetIntegerv - glGetLightfv - glGetLightiv - glGetMapdv - glGetMapfv - glGetMapiv - glGetMaterialfv - glGetMaterialiv - glGetPixelMapfv - glGetPixelMapuiv - glGetPixelMapusv - glGetPointerv - glGetPolygonStipple - glGetString - glGetTexEnvfv - glGetTexEnviv - glGetTexGendv - glGetTexGenfv - glGetTexGeniv - glGetTexImage - glGetTexLevelParameterfv - glGetTexLevelParameteriv - glGetTexParameterfv - glGetTexParameteriv - glHint - glIndexMask - glIndexPointer - glIndexd - glIndexdv - glIndexf - glIndexfv - glIndexi - glIndexiv - glIndexs - glIndexsv - glIndexub - glIndexubv - glInitNames - glInterleavedArrays - glIsEnabled - glIsList - glIsTexture - glLightModelf - glLightModelfv - glLightModeli - glLightModeliv - glLightf - glLightfv - glLighti - glLightiv - glLineStipple - glLineWidth - glListBase - glLoadIdentity - glLoadMatrixd - glLoadMatrixf - glLoadName - glLogicOp - glMap1d - glMap1f - glMap2d - glMap2f - glMapGrid1d - glMapGrid1f - glMapGrid2d - glMapGrid2f - glMaterialf - glMaterialfv - glMateriali - glMaterialiv - glMatrixMode - glMultMatrixd - glMultMatrixf - glNewList - glNormal3b - glNormal3bv - glNormal3d - glNormal3dv - glNormal3f - glNormal3fv - glNormal3i - glNormal3iv - glNormal3s - glNormal3sv - glNormalPointer - glOrtho - glPassThrough - glPixelMapfv - glPixelMapuiv - glPixelMapusv - glPixelStoref - glPixelStorei - glPixelTransferf - glPixelTransferi - glPixelZoom - glPointSize - glPolygonMode - glPolygonOffset - glPolygonStipple - glPopAttrib - glPopClientAttrib - glPopMatrix - glPopName - glPrioritizeTextures - glPushAttrib - glPushClientAttrib - glPushMatrix - glPushName - glRasterPos2d - glRasterPos2dv - glRasterPos2f - glRasterPos2fv - glRasterPos2i - glRasterPos2iv - glRasterPos2s - glRasterPos2sv - glRasterPos3d - glRasterPos3dv - glRasterPos3f - glRasterPos3fv - glRasterPos3i - glRasterPos3iv - glRasterPos3s - glRasterPos3sv - glRasterPos4d - glRasterPos4dv - glRasterPos4f - glRasterPos4fv - glRasterPos4i - glRasterPos4iv - glRasterPos4s - glRasterPos4sv - glReadBuffer - glReadPixels - glRectd - glRectdv - glRectf - glRectfv - glRecti - glRectiv - glRects - glRectsv - glRenderMode - glRotated - glRotatef - glScaled - glScalef - glScissor - glSelectBuffer - glShadeModel - glStencilFunc - glStencilMask - glStencilOp - glTexCoord1d - glTexCoord1dv - glTexCoord1f - glTexCoord1fv - glTexCoord1i - glTexCoord1iv - glTexCoord1s - glTexCoord1sv - glTexCoord2d - glTexCoord2dv - glTexCoord2f - glTexCoord2fv - glTexCoord2i - glTexCoord2iv - glTexCoord2s - glTexCoord2sv - glTexCoord3d - glTexCoord3dv - glTexCoord3f - glTexCoord3fv - glTexCoord3i - glTexCoord3iv - glTexCoord3s - glTexCoord3sv - glTexCoord4d - glTexCoord4dv - glTexCoord4f - glTexCoord4fv - glTexCoord4i - glTexCoord4iv - glTexCoord4s - glTexCoord4sv - glTexCoordPointer - glTexEnvf - glTexEnvfv - glTexEnvi - glTexEnviv - glTexGend - glTexGendv - glTexGenf - glTexGenfv - glTexGeni - glTexGeniv - glTexImage1D - glTexImage2D - glTexParameterf - glTexParameterfv - glTexParameteri - glTexParameteriv - glTexSubImage1D - glTexSubImage2D - glTranslated - glTranslatef - glVertex2d - glVertex2dv - glVertex2f - glVertex2fv - glVertex2i - glVertex2iv - glVertex2s - glVertex2sv - glVertex3d - glVertex3dv - glVertex3f - glVertex3fv - glVertex3i - glVertex3iv - glVertex3s - glVertex3sv - glVertex4d - glVertex4dv - glVertex4f - glVertex4fv - glVertex4i - glVertex4iv - glVertex4s - glVertex4sv - glVertexPointer - glViewport - wglChoosePixelFormat - wglCopyContext - wglCreateContext - wglCreateLayerContext - wglDeleteContext - wglDescribeLayerPlane - wglDescribePixelFormat - wglGetCurrentContext - wglGetCurrentDC - wglGetLayerPaletteEntries - wglGetPixelFormat - wglGetProcAddress - wglMakeCurrent - wglRealizeLayerPalette - wglSetLayerPaletteEntries - wglSetPixelFormat - wglShareLists - wglSwapBuffers - wglSwapLayerBuffers - wglUseFontBitmapsA - wglUseFontBitmapsW - wglUseFontOutlinesA - wglUseFontOutlinesW diff --git a/mesalib/src/mesa/drivers/windows/gdi/wgl.c b/mesalib/src/mesa/drivers/windows/gdi/wgl.c deleted file mode 100644 index 3458cc9f3..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/wgl.c +++ /dev/null @@ -1,689 +0,0 @@ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -/* - * File name : wgl.c - * WGL stuff. Added by Oleg Letsinsky, ajl@ultersys.ru - * Some things originated from the 3Dfx WGL functions - */ - -/* - * This file contains the implementation of the wgl* functions for - * Mesa on Windows. Since these functions are provided by Windows in - * GDI/OpenGL, we must supply our versions that work with Mesa here. - */ - - -#include <windows.h> - -#include "main/config.h" -#include "glapi/glapi.h" -#include "swrast/swrast.h" -#include "GL/wmesa.h" /* protos for wmesa* functions */ - -/* - * Pixel Format Descriptors - */ - -/* Extend the PFD to include DB flag */ -struct __pixelformat__ -{ - PIXELFORMATDESCRIPTOR pfd; - GLboolean doubleBuffered; -}; - - - -/* These are the PFD's supported by this driver. */ -struct __pixelformat__ pfd[] = -{ -#if 0 - /* Double Buffer, alpha */ - { - { - sizeof(PIXELFORMATDESCRIPTOR), 1, - PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL| - PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY, - PFD_TYPE_RGBA, - 24, - 8, 0, - 8, 8, - 8, 16, - 8, 24, - 0, 0, 0, 0, 0, - DEFAULT_SOFTWARE_DEPTH_BITS, 8, - 0, 0, 0, - 0, 0, 0 - }, - GL_TRUE - }, - /* Single Buffer, alpha */ - { - { - sizeof(PIXELFORMATDESCRIPTOR), 1, - PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL| - PFD_GENERIC_FORMAT, - PFD_TYPE_RGBA, - 24, - 8, 0, - 8, 8, - 8, 16, - 8, 24, - 0, 0, 0, 0, 0, - DEFAULT_SOFTWARE_DEPTH_BITS, 8, - 0, 0, 0, - 0, 0, 0 - }, - GL_FALSE - }, -#endif - /* Double Buffer, no alpha */ - { - { - sizeof(PIXELFORMATDESCRIPTOR), 1, - PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL| - PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY, - PFD_TYPE_RGBA, - 24, - 8, 0, - 8, 8, - 8, 16, - 0, 0, - 0, 0, 0, 0, 0, - DEFAULT_SOFTWARE_DEPTH_BITS, 8, - 0, 0, 0, - 0, 0, 0 - }, - GL_TRUE - }, - /* Single Buffer, no alpha */ - { - { - sizeof(PIXELFORMATDESCRIPTOR), 1, - PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL| - PFD_GENERIC_FORMAT, - PFD_TYPE_RGBA, - 24, - 8, 0, - 8, 8, - 8, 16, - 0, 0, - 0, 0, 0, 0, 0, - DEFAULT_SOFTWARE_DEPTH_BITS, 8, - 0, 0, 0, - 0, 0, 0 - }, - GL_FALSE - }, -}; - -int npfd = sizeof(pfd) / sizeof(pfd[0]); - - -/* - * Contexts - */ - -typedef struct { - WMesaContext ctx; -} MesaWglCtx; - -#define MESAWGL_CTX_MAX_COUNT 20 - -static MesaWglCtx wgl_ctx[MESAWGL_CTX_MAX_COUNT]; - -static unsigned ctx_count = 0; -static int ctx_current = -1; -static unsigned curPFD = 0; - -static HDC CurrentHDC = 0; - - -WINGDIAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc) -{ - int i = 0; - if (!ctx_count) { - for(i=0;i<MESAWGL_CTX_MAX_COUNT;i++) { - wgl_ctx[i].ctx = NULL; - } - } - for( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) { - if ( wgl_ctx[i].ctx == NULL ) { - wgl_ctx[i].ctx = - WMesaCreateContext(hdc, NULL, (GLboolean)GL_TRUE, - (GLboolean) (pfd[curPFD-1].doubleBuffered ? - GL_TRUE : GL_FALSE), - (GLboolean)(pfd[curPFD-1].pfd.cAlphaBits ? - GL_TRUE : GL_FALSE) ); - if (wgl_ctx[i].ctx == NULL) - break; - ctx_count++; - return ((HGLRC)wgl_ctx[i].ctx); - } - } - SetLastError(0); - return(NULL); -} - -WINGDIAPI BOOL GLAPIENTRY wglDeleteContext(HGLRC hglrc) -{ - int i; - for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) { - if ( wgl_ctx[i].ctx == (WMesaContext) hglrc ){ - WMesaMakeCurrent((WMesaContext) hglrc, NULL); - WMesaDestroyContext(wgl_ctx[i].ctx); - wgl_ctx[i].ctx = NULL; - ctx_count--; - return(TRUE); - } - } - SetLastError(0); - return(FALSE); -} - -WINGDIAPI HGLRC GLAPIENTRY wglGetCurrentContext(VOID) -{ - if (ctx_current < 0) - return 0; - else - return (HGLRC) wgl_ctx[ctx_current].ctx; -} - -WINGDIAPI HDC GLAPIENTRY wglGetCurrentDC(VOID) -{ - return CurrentHDC; -} - -WINGDIAPI BOOL GLAPIENTRY wglMakeCurrent(HDC hdc, HGLRC hglrc) -{ - int i; - - CurrentHDC = hdc; - - if (!hdc || !hglrc) { - WMesaMakeCurrent(NULL, NULL); - ctx_current = -1; - return TRUE; - } - - for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) { - if ( wgl_ctx[i].ctx == (WMesaContext) hglrc ) { - WMesaMakeCurrent( (WMesaContext) hglrc, hdc ); - ctx_current = i; - return TRUE; - } - } - return FALSE; -} - - -WINGDIAPI int GLAPIENTRY wglChoosePixelFormat(HDC hdc, - CONST - PIXELFORMATDESCRIPTOR *ppfd) -{ - int i,best = -1,bestdelta = 0x7FFFFFFF,delta; - (void) hdc; - - if(ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR) || ppfd->nVersion != 1) - { - SetLastError(0); - return(0); - } - for(i = 0; i < npfd;i++) - { - delta = 0; - if( - (ppfd->dwFlags & PFD_DRAW_TO_WINDOW) && - !(pfd[i].pfd.dwFlags & PFD_DRAW_TO_WINDOW)) - continue; - if( - (ppfd->dwFlags & PFD_DRAW_TO_BITMAP) && - !(pfd[i].pfd.dwFlags & PFD_DRAW_TO_BITMAP)) - continue; - if( - (ppfd->dwFlags & PFD_SUPPORT_GDI) && - !(pfd[i].pfd.dwFlags & PFD_SUPPORT_GDI)) - continue; - if( - (ppfd->dwFlags & PFD_SUPPORT_OPENGL) && - !(pfd[i].pfd.dwFlags & PFD_SUPPORT_OPENGL)) - continue; - if( - !(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) && - ((ppfd->dwFlags & PFD_DOUBLEBUFFER) != - (pfd[i].pfd.dwFlags & PFD_DOUBLEBUFFER))) - continue; - if( - !(ppfd->dwFlags & PFD_STEREO_DONTCARE) && - ((ppfd->dwFlags & PFD_STEREO) != - (pfd[i].pfd.dwFlags & PFD_STEREO))) - continue; - if(ppfd->iPixelType != pfd[i].pfd.iPixelType) - delta++; - if(ppfd->cAlphaBits != pfd[i].pfd.cAlphaBits) - delta++; - if(delta < bestdelta) - { - best = i + 1; - bestdelta = delta; - if(bestdelta == 0) - break; - } - } - if(best == -1) - { - SetLastError(0); - return(0); - } - return(best); -} - -WINGDIAPI int GLAPIENTRY wglDescribePixelFormat(HDC hdc, - int iPixelFormat, - UINT nBytes, - LPPIXELFORMATDESCRIPTOR ppfd) -{ - (void) hdc; - - if(ppfd == NULL) - return(npfd); - if(iPixelFormat < 1 || iPixelFormat > npfd || - nBytes != sizeof(PIXELFORMATDESCRIPTOR)) - { - SetLastError(0); - return(0); - } - *ppfd = pfd[iPixelFormat - 1].pfd; - return(npfd); -} - -WINGDIAPI PROC GLAPIENTRY wglGetProcAddress(LPCSTR lpszProc) -{ - PROC p = (PROC) _glapi_get_proc_address((const char *) lpszProc); - if (p) - return p; - - SetLastError(0); - return(NULL); -} - -WINGDIAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc) -{ - (void) hdc; - if(curPFD == 0) { - SetLastError(0); - return(0); - } - return(curPFD); -} - -WINGDIAPI BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int iPixelFormat, - const PIXELFORMATDESCRIPTOR *ppfd) -{ - (void) hdc; - - /* SetPixelFormat (hence wglSetPixelFormat) must not touch ppfd, per - * http://msdn.microsoft.com/en-us/library/dd369049(v=vs.85).aspx - */ - (void) ppfd; - - if(iPixelFormat < 1 || iPixelFormat > npfd) { - SetLastError(0); - return(FALSE); - } - curPFD = iPixelFormat; - return(TRUE); -} - -WINGDIAPI BOOL GLAPIENTRY wglSwapBuffers(HDC hdc) -{ - WMesaSwapBuffers(hdc); - return TRUE; -} - -static FIXED FixedFromDouble(double d) -{ - long l = (long) (d * 65536L); - return *(FIXED *) (void *) &l; -} - - -/* -** This is cribbed from FX/fxwgl.c, and seems to implement support -** for bitmap fonts where the wglUseFontBitmapsA() code implements -** support for outline fonts. In combination they hopefully give -** fairly generic support for fonts. -*/ -static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar, - DWORD numChars, DWORD listBase) -{ -#define VERIFY(a) (void)(a) - - TEXTMETRIC metric; - BITMAPINFO *dibInfo; - HDC bitDevice; - COLORREF tempColor; - int i; - - VERIFY(GetTextMetrics(fontDevice, &metric)); - - dibInfo = calloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD), 1); - dibInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - dibInfo->bmiHeader.biPlanes = 1; - dibInfo->bmiHeader.biBitCount = 1; - dibInfo->bmiHeader.biCompression = BI_RGB; - - bitDevice = CreateCompatibleDC(fontDevice); - - /* Swap fore and back colors so the bitmap has the right polarity */ - tempColor = GetBkColor(bitDevice); - SetBkColor(bitDevice, GetTextColor(bitDevice)); - SetTextColor(bitDevice, tempColor); - - /* Place chars based on base line */ - VERIFY(SetTextAlign(bitDevice, TA_BASELINE) != GDI_ERROR ? 1 : 0); - - for(i = 0; i < (int)numChars; i++) { - SIZE size; - char curChar; - int charWidth,charHeight,bmapWidth,bmapHeight,numBytes,res; - HBITMAP bitObject; - HGDIOBJ origBmap; - unsigned char *bmap; - - curChar = (char)(i + firstChar); - - /* Find how high/wide this character is */ - VERIFY(GetTextExtentPoint32(bitDevice, &curChar, 1, &size)); - - /* Create the output bitmap */ - charWidth = size.cx; - charHeight = size.cy; - /* Round up to the next multiple of 32 bits */ - bmapWidth = ((charWidth + 31) / 32) * 32; - bmapHeight = charHeight; - bitObject = CreateCompatibleBitmap(bitDevice, - bmapWidth, - bmapHeight); - /* VERIFY(bitObject); */ - - /* Assign the output bitmap to the device */ - origBmap = SelectObject(bitDevice, bitObject); - (void) VERIFY(origBmap); - - VERIFY( PatBlt( bitDevice, 0, 0, bmapWidth, bmapHeight,BLACKNESS ) ); - - /* Use our source font on the device */ - VERIFY(SelectObject(bitDevice, GetCurrentObject(fontDevice,OBJ_FONT))); - - /* Draw the character */ - VERIFY(TextOut(bitDevice, 0, metric.tmAscent, &curChar, 1)); - - /* Unselect our bmap object */ - VERIFY(SelectObject(bitDevice, origBmap)); - - /* Convert the display dependant representation to a 1 bit deep DIB */ - numBytes = (bmapWidth * bmapHeight) / 8; - bmap = malloc(numBytes); - dibInfo->bmiHeader.biWidth = bmapWidth; - dibInfo->bmiHeader.biHeight = bmapHeight; - res = GetDIBits(bitDevice, bitObject, 0, bmapHeight, bmap, - dibInfo, - DIB_RGB_COLORS); - /* VERIFY(res); */ - - /* Create the GL object */ - glNewList(i + listBase, GL_COMPILE); - glBitmap(bmapWidth, bmapHeight, 0.0, (GLfloat)metric.tmDescent, - (GLfloat)charWidth, 0.0, - bmap); - glEndList(); - /* CheckGL(); */ - - /* Destroy the bmap object */ - DeleteObject(bitObject); - - /* Deallocate the bitmap data */ - free(bmap); - } - - /* Destroy the DC */ - VERIFY(DeleteDC(bitDevice)); - - free(dibInfo); - - return TRUE; -#undef VERIFY -} - -WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsA(HDC hdc, DWORD first, - DWORD count, DWORD listBase) -{ - int i; - GLuint font_list; - DWORD size; - GLYPHMETRICS gm; - HANDLE hBits; - LPSTR lpBits; - MAT2 mat; - int success = TRUE; - - if (count == 0) - return FALSE; - - font_list = listBase; - - mat.eM11 = FixedFromDouble(1); - mat.eM12 = FixedFromDouble(0); - mat.eM21 = FixedFromDouble(0); - mat.eM22 = FixedFromDouble(-1); - - memset(&gm,0,sizeof(gm)); - - /* - ** If we can't get the glyph outline, it may be because this is a fixed - ** font. Try processing it that way. - */ - if( GetGlyphOutline(hdc, first, GGO_BITMAP, &gm, 0, NULL, &mat) - == GDI_ERROR ) { - return wglUseFontBitmaps_FX( hdc, first, count, listBase ); - } - - /* - ** Otherwise process all desired characters. - */ - for (i = 0; i < (int)count; i++) { - DWORD err; - - glNewList( font_list+i, GL_COMPILE ); - - /* allocate space for the bitmap/outline */ - size = GetGlyphOutline(hdc, first + i, GGO_BITMAP, - &gm, 0, NULL, &mat); - if (size == GDI_ERROR) { - glEndList( ); - err = GetLastError(); - success = FALSE; - continue; - } - - hBits = GlobalAlloc(GHND, size+1); - lpBits = GlobalLock(hBits); - - err = - GetGlyphOutline(hdc, /* handle to device context */ - first + i, /* character to query */ - GGO_BITMAP, /* format of data to return */ - &gm, /* ptr to structure for metrics*/ - size, /* size of buffer for data */ - lpBits, /* pointer to buffer for data */ - &mat /* pointer to transformation */ - /* matrix structure */ - ); - - if (err == GDI_ERROR) { - GlobalUnlock(hBits); - GlobalFree(hBits); - - glEndList( ); - err = GetLastError(); - success = FALSE; - continue; - } - - glBitmap(gm.gmBlackBoxX,gm.gmBlackBoxY, - (GLfloat)-gm.gmptGlyphOrigin.x, - (GLfloat)gm.gmptGlyphOrigin.y, - (GLfloat)gm.gmCellIncX, - (GLfloat)gm.gmCellIncY, - (const GLubyte * )lpBits); - - GlobalUnlock(hBits); - GlobalFree(hBits); - - glEndList( ); - } - - return success; -} - -WINGDIAPI BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1, - HGLRC hglrc2) -{ - WMesaShareLists((WMesaContext)hglrc1, (WMesaContext)hglrc2); - return(TRUE); -} - - - -/* NOT IMPLEMENTED YET */ -WINGDIAPI BOOL GLAPIENTRY wglCopyContext(HGLRC hglrcSrc, - HGLRC hglrcDst, - UINT mask) -{ - (void) hglrcSrc; (void) hglrcDst; (void) mask; - return(FALSE); -} - -WINGDIAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc, - int iLayerPlane) -{ - SetLastError(0); - if (iLayerPlane == 0) - return wglCreateContext( hdc ); - return(NULL); -} - - -WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsW(HDC hdc, - DWORD first, - DWORD count, - DWORD listBase) -{ - (void) hdc; (void) first; (void) count; (void) listBase; - return FALSE; -} - -WINGDIAPI BOOL GLAPIENTRY wglUseFontOutlinesA(HDC hdc, - DWORD first, - DWORD count, - DWORD listBase, - FLOAT deviation, - FLOAT extrusion, - int format, - LPGLYPHMETRICSFLOAT lpgmf) -{ - (void) hdc; (void) first; (void) count; - (void) listBase; (void) deviation; (void) extrusion; (void) format; - (void) lpgmf; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI BOOL GLAPIENTRY wglUseFontOutlinesW(HDC hdc, - DWORD first, - DWORD count, - DWORD listBase, - FLOAT deviation, - FLOAT extrusion, - int format, - LPGLYPHMETRICSFLOAT lpgmf) -{ - (void) hdc; (void) first; (void) count; - (void) listBase; (void) deviation; (void) extrusion; (void) format; - (void) lpgmf; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI BOOL GLAPIENTRY wglDescribeLayerPlane(HDC hdc, - int iPixelFormat, - int iLayerPlane, - UINT nBytes, - LPLAYERPLANEDESCRIPTOR plpd) -{ - (void) hdc; (void) iPixelFormat; (void) iLayerPlane; - (void) nBytes; (void) plpd; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI int GLAPIENTRY wglSetLayerPaletteEntries(HDC hdc, - int iLayerPlane, - int iStart, - int cEntries, - CONST COLORREF *pcr) -{ - (void) hdc; (void) iLayerPlane; (void) iStart; - (void) cEntries; (void) pcr; - SetLastError(0); - return(0); -} - -WINGDIAPI int GLAPIENTRY wglGetLayerPaletteEntries(HDC hdc, - int iLayerPlane, - int iStart, - int cEntries, - COLORREF *pcr) -{ - (void) hdc; (void) iLayerPlane; (void) iStart; (void) cEntries; (void) pcr; - SetLastError(0); - return(0); -} - -WINGDIAPI BOOL GLAPIENTRY wglRealizeLayerPalette(HDC hdc, - int iLayerPlane, - BOOL bRealize) -{ - (void) hdc; (void) iLayerPlane; (void) bRealize; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI BOOL GLAPIENTRY wglSwapLayerBuffers(HDC hdc, - UINT fuPlanes) -{ - (void) hdc; (void) fuPlanes; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI const char * GLAPIENTRY wglGetExtensionsStringARB(HDC hdc) -{ - return "WGL_ARB_extensions_string"; -} diff --git a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c deleted file mode 100644 index c1a9c28b1..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c +++ /dev/null @@ -1,791 +0,0 @@ -/* - * Windows (Win32/Win64) device driver for Mesa - * - */ - -#include "wmesadef.h" -#include "colors.h" -#include "GL/wmesa.h" -#include <winuser.h> -#include "main/context.h" -#include "main/api_exec.h" -#include "main/extensions.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "main/macros.h" -#include "main/version.h" -#include "main/vtxfmt.h" -#include "drivers/common/driverfuncs.h" -#include "drivers/common/meta.h" -#include "vbo/vbo.h" -#include "swrast/swrast.h" -#include "swrast/s_renderbuffer.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" - - -/* linked list of our Framebuffers (windows) */ -static WMesaFramebuffer FirstFramebuffer = NULL; - - -/** - * Create a new WMesaFramebuffer object which will correspond to the - * given HDC (Window handle). - */ -static WMesaFramebuffer -wmesa_new_framebuffer(HDC hdc, struct gl_config *visual) -{ - WMesaFramebuffer pwfb - = malloc(sizeof(struct wmesa_framebuffer)); - if (pwfb) { - _mesa_initialize_window_framebuffer(&pwfb->Base, visual); - pwfb->hDC = hdc; - /* insert at head of list */ - pwfb->next = FirstFramebuffer; - FirstFramebuffer = pwfb; - } - return pwfb; -} - -/** - * Given an hdc, free the corresponding WMesaFramebuffer - */ -static void -wmesa_free_framebuffer(HDC hdc) -{ - WMesaFramebuffer pwfb, prev; - for (pwfb = FirstFramebuffer; pwfb; pwfb = pwfb->next) { - if (pwfb->hDC == hdc) - break; - prev = pwfb; - } - if (pwfb) { - struct gl_framebuffer *fb; - if (pwfb == FirstFramebuffer) - FirstFramebuffer = pwfb->next; - else - prev->next = pwfb->next; - fb = &pwfb->Base; - _mesa_reference_framebuffer(&fb, NULL); - } -} - -/** - * Given an hdc, return the corresponding WMesaFramebuffer - */ -static WMesaFramebuffer -wmesa_lookup_framebuffer(HDC hdc) -{ - WMesaFramebuffer pwfb; - for (pwfb = FirstFramebuffer; pwfb; pwfb = pwfb->next) { - if (pwfb->hDC == hdc) - return pwfb; - } - return NULL; -} - - -/** - * Given a struct gl_framebuffer, return the corresponding WMesaFramebuffer. - */ -static WMesaFramebuffer wmesa_framebuffer(struct gl_framebuffer *fb) -{ - return (WMesaFramebuffer) fb; -} - - -/** - * Given a struct gl_context, return the corresponding WMesaContext. - */ -static WMesaContext wmesa_context(const struct gl_context *ctx) -{ - return (WMesaContext) ctx; -} - - -/* - * Every driver should implement a GetString function in order to - * return a meaningful GL_RENDERER string. - */ -static const GLubyte *wmesa_get_string(struct gl_context *ctx, GLenum name) -{ - return (name == GL_RENDERER) ? - (GLubyte *) "Mesa Windows GDI Driver" : NULL; -} - - -/* - * Determine the pixel format based on the pixel size. - */ -static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC) -{ - pwfb->cColorBits = GetDeviceCaps(hDC, BITSPIXEL); - - /* Only 16 and 32 bit targets are supported now */ - assert(pwfb->cColorBits == 0 || - pwfb->cColorBits == 16 || - pwfb->cColorBits == 24 || - pwfb->cColorBits == 32); - - switch(pwfb->cColorBits){ - case 8: - pwfb->pixelformat = PF_INDEX8; - break; - case 16: - pwfb->pixelformat = PF_5R6G5B; - break; - case 24: - case 32: - pwfb->pixelformat = PF_8R8G8B; - break; - default: - pwfb->pixelformat = PF_BADFORMAT; - } -} - - -/** - * Create DIB for back buffer. - * We write into this memory with the span routines and then blit it - * to the window on a buffer swap. - */ -static BOOL wmCreateBackingStore(WMesaFramebuffer pwfb, long lxSize, long lySize) -{ - LPBITMAPINFO pbmi = &(pwfb->bmi); - HDC hic; - - pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pbmi->bmiHeader.biWidth = lxSize; - pbmi->bmiHeader.biHeight= -lySize; - pbmi->bmiHeader.biPlanes = 1; - pbmi->bmiHeader.biBitCount = GetDeviceCaps(pwfb->hDC, BITSPIXEL); - pbmi->bmiHeader.biCompression = BI_RGB; - pbmi->bmiHeader.biSizeImage = 0; - pbmi->bmiHeader.biXPelsPerMeter = 0; - pbmi->bmiHeader.biYPelsPerMeter = 0; - pbmi->bmiHeader.biClrUsed = 0; - pbmi->bmiHeader.biClrImportant = 0; - - pwfb->cColorBits = pbmi->bmiHeader.biBitCount; - pwfb->ScanWidth = (lxSize * (pwfb->cColorBits / 8) + 3) & ~3; - - hic = CreateIC("display", NULL, NULL, NULL); - pwfb->dib_hDC = CreateCompatibleDC(hic); - - pwfb->hbmDIB = CreateDIBSection(hic, - &pwfb->bmi, - DIB_RGB_COLORS, - (void **)&(pwfb->pbPixels), - 0, - 0); - pwfb->hOldBitmap = SelectObject(pwfb->dib_hDC, pwfb->hbmDIB); - - DeleteDC(hic); - - wmSetPixelFormat(pwfb, pwfb->hDC); - return TRUE; -} - - -static void wmDeleteBackingStore(WMesaFramebuffer pwfb) -{ - if (pwfb->hbmDIB) { - SelectObject(pwfb->dib_hDC, pwfb->hOldBitmap); - DeleteDC(pwfb->dib_hDC); - DeleteObject(pwfb->hbmDIB); - } -} - - -/** - * Find the width and height of the window named by hdc. - */ -static void -get_window_size(HDC hdc, GLuint *width, GLuint *height) -{ - if (WindowFromDC(hdc)) { - RECT rect; - GetClientRect(WindowFromDC(hdc), &rect); - *width = rect.right - rect.left; - *height = rect.bottom - rect.top; - } - else { /* Memory context */ - /* From contributed code - use the size of the desktop - * for the size of a memory context (?) */ - *width = GetDeviceCaps(hdc, HORZRES); - *height = GetDeviceCaps(hdc, VERTRES); - } -} - - -static void -wmesa_get_buffer_size(struct gl_framebuffer *buffer, GLuint *width, GLuint *height) -{ - WMesaFramebuffer pwfb = wmesa_framebuffer(buffer); - get_window_size(pwfb->hDC, width, height); -} - - -static void wmesa_flush(struct gl_context *ctx) -{ - WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->WinSysDrawBuffer); - - if (ctx->Visual.doubleBufferMode == 1) { - BitBlt(pwfb->hDC, 0, 0, pwfb->Base.Width, pwfb->Base.Height, - pwfb->dib_hDC, 0, 0, SRCCOPY); - } - else { - /* Do nothing for single buffer */ - } -} - - -/**********************************************************************/ -/***** CLEAR Functions *****/ -/**********************************************************************/ - -/* - * Clear the color/depth/stencil buffers. - */ -static void clear(struct gl_context *ctx, GLbitfield mask) -{ -#define FLIP(Y) (ctx->DrawBuffer->Height - (Y) - 1) - const GLint x = ctx->DrawBuffer->_Xmin; - const GLint y = ctx->DrawBuffer->_Ymin; - const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; - const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; - - WMesaContext pwc = wmesa_context(ctx); - WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); - int done = 0; - - /* Let swrast do all the work if the masks are not set to - * clear all channels. */ - if (!ctx->Color.ColorMask[0][0] || - !ctx->Color.ColorMask[0][1] || - !ctx->Color.ColorMask[0][2] || - !ctx->Color.ColorMask[0][3]) { - _swrast_Clear(ctx, mask); - return; - } - - if (mask & BUFFER_BITS_COLOR) { - /* setup the clearing color */ - const union gl_color_union color = ctx->Color.ClearColor; - GLubyte col[3]; - UNCLAMPED_FLOAT_TO_UBYTE(col[0], color.f[0]); - UNCLAMPED_FLOAT_TO_UBYTE(col[1], color.f[1]); - UNCLAMPED_FLOAT_TO_UBYTE(col[2], color.f[2]); - pwc->clearColorRef = RGB(col[0], col[1], col[2]); - DeleteObject(pwc->clearPen); - DeleteObject(pwc->clearBrush); - pwc->clearPen = CreatePen(PS_SOLID, 1, pwc->clearColorRef); - pwc->clearBrush = CreateSolidBrush(pwc->clearColorRef); - } - - /* Back buffer */ - if (mask & BUFFER_BIT_BACK_LEFT) { - - int i, rowSize; - UINT bytesPerPixel = pwfb->cColorBits / 8; - LPBYTE lpb, clearRow; - LPWORD lpw; - BYTE bColor; - WORD wColor; - BYTE r, g, b; - DWORD dwColor; - LPDWORD lpdw; - - /* Try for a fast clear - clearing entire buffer with a single - * byte value. */ - if (width == ctx->DrawBuffer->Width && - height == ctx->DrawBuffer->Height) { /* entire buffer */ - /* Now check for an easy clear value */ - switch (bytesPerPixel) { - case 1: - bColor = BGR8(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - memset(pwfb->pbPixels, bColor, - pwfb->ScanWidth * height); - done = 1; - break; - case 2: - wColor = BGR16(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - if (((wColor >> 8) & 0xff) == (wColor & 0xff)) { - memset(pwfb->pbPixels, wColor & 0xff, - pwfb->ScanWidth * height); - done = 1; - } - break; - case 3: - /* fall through */ - case 4: - if (GetRValue(pwc->clearColorRef) == - GetGValue(pwc->clearColorRef) && - GetRValue(pwc->clearColorRef) == - GetBValue(pwc->clearColorRef)) { - memset(pwfb->pbPixels, - GetRValue(pwc->clearColorRef), - pwfb->ScanWidth * height); - done = 1; - } - break; - default: - break; - } - } /* all */ - - if (!done) { - /* Need to clear a row at a time. Begin by setting the first - * row in the area to be cleared to the clear color. */ - - clearRow = pwfb->pbPixels + - pwfb->ScanWidth * FLIP(y) + - bytesPerPixel * x; - switch (bytesPerPixel) { - case 1: - lpb = clearRow; - bColor = BGR8(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - memset(lpb, bColor, width); - break; - case 2: - lpw = (LPWORD)clearRow; - wColor = BGR16(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - for (i=0; i<width; i++) - *lpw++ = wColor; - break; - case 3: - lpb = clearRow; - r = GetRValue(pwc->clearColorRef); - g = GetGValue(pwc->clearColorRef); - b = GetBValue(pwc->clearColorRef); - for (i=0; i<width; i++) { - *lpb++ = b; - *lpb++ = g; - *lpb++ = r; - } - break; - case 4: - lpdw = (LPDWORD)clearRow; - dwColor = BGR32(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - for (i=0; i<width; i++) - *lpdw++ = dwColor; - break; - default: - break; - } /* switch */ - - /* copy cleared row to other rows in buffer */ - lpb = clearRow - pwfb->ScanWidth; - rowSize = width * bytesPerPixel; - for (i=1; i<height; i++) { - memcpy(lpb, clearRow, rowSize); - lpb -= pwfb->ScanWidth; - } - } /* not done */ - mask &= ~BUFFER_BIT_BACK_LEFT; - } /* back buffer */ - - /* front buffer */ - if (mask & BUFFER_BIT_FRONT_LEFT) { - HDC DC = pwc->hDC; - HPEN Old_Pen = SelectObject(DC, pwc->clearPen); - HBRUSH Old_Brush = SelectObject(DC, pwc->clearBrush); - Rectangle(DC, - x, - FLIP(y) + 1, - x + width + 1, - FLIP(y) - height + 1); - SelectObject(DC, Old_Pen); - SelectObject(DC, Old_Brush); - mask &= ~BUFFER_BIT_FRONT_LEFT; - } /* front buffer */ - - /* Call swrast if there is anything left to clear (like DEPTH) */ - if (mask) - _swrast_Clear(ctx, mask); - -#undef FLIP -} - - - -/**********************************************************************/ -/***** BUFFER Functions *****/ -/**********************************************************************/ - - - - -static void -wmesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) -{ - _mesa_delete_renderbuffer(ctx, rb); -} - - -/** - * This is called by Mesa whenever it determines that the window size - * has changed. Do whatever's needed to cope with that. - */ -static GLboolean -wmesa_renderbuffer_storage(struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, - GLuint height) -{ - rb->Width = width; - rb->Height = height; - return GL_TRUE; -} - - -/** - * Called by ctx->Driver.ResizeBuffers() - * Resize the front/back colorbuffers to match the latest window size. - */ -static void -wmesa_resize_buffers(struct gl_context *ctx, struct gl_framebuffer *buffer, - GLuint width, GLuint height) -{ - WMesaFramebuffer pwfb = wmesa_framebuffer(buffer); - - if (pwfb->Base.Width != width || pwfb->Base.Height != height) { - /* Realloc back buffer */ - if (ctx->Visual.doubleBufferMode == 1) { - wmDeleteBackingStore(pwfb); - wmCreateBackingStore(pwfb, width, height); - } - } - _mesa_resize_framebuffer(ctx, buffer, width, height); -} - - -/** - * Called by glViewport. - * This is a good time for us to poll the current window size and adjust - * our renderbuffers to match the current window size. - * Remember, we have no opportunity to respond to conventional - * resize events since the driver has no event loop. - * Thus, we poll. - * MakeCurrent also ends up making a call here, so that ensures - * we get the viewport set correctly, even if the app does not call - * glViewport and relies on the defaults. - */ -static void wmesa_viewport(struct gl_context *ctx) -{ - GLuint new_width, new_height; - - wmesa_get_buffer_size(ctx->WinSysDrawBuffer, &new_width, &new_height); - - /** - * Resize buffers if the window size changed. - */ - wmesa_resize_buffers(ctx, ctx->WinSysDrawBuffer, new_width, new_height); - ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */ -} - - - - -/** - * Called when the driver should update it's state, based on the new_state - * flags. - */ -static void wmesa_update_state(struct gl_context *ctx, GLuint new_state) -{ - _swrast_InvalidateState(ctx, new_state); - _swsetup_InvalidateState(ctx, new_state); - _vbo_InvalidateState(ctx, new_state); - _tnl_InvalidateState(ctx, new_state); - - /* TODO - This code is not complete yet because I - * don't know what to do for all state updates. - */ - - if (new_state & _NEW_BUFFERS) { - } -} - - - - - -/**********************************************************************/ -/***** WMESA Functions *****/ -/**********************************************************************/ - -WMesaContext WMesaCreateContext(HDC hDC, - HPALETTE* Pal, - GLboolean rgb_flag, - GLboolean db_flag, - GLboolean alpha_flag) -{ - WMesaContext c; - struct dd_function_table functions; - GLint red_bits, green_bits, blue_bits, alpha_bits; - struct gl_context *ctx; - struct gl_config *visual; - - (void) Pal; - - /* Indexed mode not supported */ - if (!rgb_flag) - return NULL; - - /* Allocate wmesa context */ - c = CALLOC_STRUCT(wmesa_context); - if (!c) - return NULL; - -#if 0 - /* I do not understand this contributed code */ - /* Support memory and device contexts */ - if(WindowFromDC(hDC) != NULL) { - c->hDC = GetDC(WindowFromDC(hDC)); /* huh ???? */ - } - else { - c->hDC = hDC; - } -#else - c->hDC = hDC; -#endif - - /* Get data for visual */ - /* Dealing with this is actually a bit of overkill because Mesa will end - * up treating all color component size requests less than 8 by using - * a single byte per channel. In addition, the interface to the span - * routines passes colors as an entire byte per channel anyway, so there - * is nothing to be saved by telling the visual to be 16 bits if the device - * is 16 bits. That is, Mesa is going to compute colors down to 8 bits per - * channel anyway. - * But we go through the motions here anyway. - */ - switch (GetDeviceCaps(c->hDC, BITSPIXEL)) { - case 16: - red_bits = green_bits = blue_bits = 5; - alpha_bits = 0; - break; - default: - red_bits = green_bits = blue_bits = 8; - alpha_bits = 8; - break; - } - /* Create visual based on flags */ - visual = _mesa_create_visual(db_flag, /* db_flag */ - GL_FALSE, /* stereo */ - red_bits, green_bits, blue_bits, /* color RGB */ - alpha_flag ? alpha_bits : 0, /* color A */ - DEFAULT_SOFTWARE_DEPTH_BITS, /* depth_bits */ - 8, /* stencil_bits */ - 16,16,16, /* accum RGB */ - alpha_flag ? 16 : 0, /* accum A */ - 1); /* num samples */ - - if (!visual) { - free(c); - return NULL; - } - - /* Set up driver functions */ - _mesa_init_driver_functions(&functions); - functions.GetString = wmesa_get_string; - functions.UpdateState = wmesa_update_state; - functions.Flush = wmesa_flush; - functions.Clear = clear; - functions.ResizeBuffers = wmesa_resize_buffers; - functions.Viewport = wmesa_viewport; - - /* initialize the Mesa context data */ - ctx = &c->gl_ctx; - _mesa_initialize_context(ctx, API_OPENGL_COMPAT, visual, - NULL, &functions); - - /* visual no longer needed - it was copied by _mesa_initialize_context() */ - _mesa_destroy_visual(visual); - - _mesa_enable_sw_extensions(ctx); - - _mesa_meta_init(ctx); - - /* Initialize the software rasterizer and helper modules. */ - if (!_swrast_CreateContext(ctx) || - !_vbo_CreateContext(ctx) || - !_tnl_CreateContext(ctx) || - !_swsetup_CreateContext(ctx)) { - _mesa_free_context_data(ctx); - free(c); - return NULL; - } - _swsetup_Wakeup(ctx); - TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline; - - _mesa_compute_version(ctx); - - /* Exec table initialization requires the version to be computed */ - _mesa_initialize_dispatch_tables(ctx); - _mesa_initialize_vbo_vtxfmt(ctx); - - return c; -} - - -void WMesaDestroyContext( WMesaContext pwc ) -{ - struct gl_context *ctx = &pwc->gl_ctx; - WMesaFramebuffer pwfb; - GET_CURRENT_CONTEXT(cur_ctx); - - if (cur_ctx == ctx) { - /* unbind current if deleting current context */ - WMesaMakeCurrent(NULL, NULL); - } - - /* clean up frame buffer resources */ - pwfb = wmesa_lookup_framebuffer(pwc->hDC); - if (pwfb) { - if (ctx->Visual.doubleBufferMode == 1) - wmDeleteBackingStore(pwfb); - wmesa_free_framebuffer(pwc->hDC); - } - - /* Release for device, not memory contexts */ - if (WindowFromDC(pwc->hDC) != NULL) - { - ReleaseDC(WindowFromDC(pwc->hDC), pwc->hDC); - } - DeleteObject(pwc->clearPen); - DeleteObject(pwc->clearBrush); - - _mesa_meta_free(ctx); - - _swsetup_DestroyContext(ctx); - _tnl_DestroyContext(ctx); - _vbo_DestroyContext(ctx); - _swrast_DestroyContext(ctx); - - _mesa_free_context_data(ctx); - free(pwc); -} - - -/** - * Create a new color renderbuffer. - */ -static struct gl_renderbuffer * -wmesa_new_renderbuffer(void) -{ - struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer); - if (!rb) - return NULL; - - _mesa_init_renderbuffer(rb, (GLuint)0); - - rb->_BaseFormat = GL_RGBA; - rb->InternalFormat = GL_RGBA; - rb->Delete = wmesa_delete_renderbuffer; - rb->AllocStorage = wmesa_renderbuffer_storage; - return rb; -} - - -void WMesaMakeCurrent(WMesaContext c, HDC hdc) -{ - WMesaFramebuffer pwfb; - - { - /* return if already current */ - GET_CURRENT_CONTEXT(ctx); - WMesaContext pwc = wmesa_context(ctx); - if (pwc && c == pwc && pwc->hDC == hdc) - return; - } - - pwfb = wmesa_lookup_framebuffer(hdc); - - /* Lazy creation of framebuffers */ - if (c && !pwfb && hdc) { - struct gl_renderbuffer *rb; - struct gl_config *visual = &c->gl_ctx.Visual; - GLuint width, height; - - get_window_size(hdc, &width, &height); - - c->clearPen = CreatePen(PS_SOLID, 1, 0); - c->clearBrush = CreateSolidBrush(0); - - pwfb = wmesa_new_framebuffer(hdc, visual); - - /* Create back buffer if double buffered */ - if (visual->doubleBufferMode == 1) { - wmCreateBackingStore(pwfb, width, height); - } - - /* make render buffers */ - if (visual->doubleBufferMode == 1) { - rb = wmesa_new_renderbuffer(); - _mesa_add_renderbuffer(&pwfb->Base, BUFFER_BACK_LEFT, rb); - } - rb = wmesa_new_renderbuffer(); - _mesa_add_renderbuffer(&pwfb->Base, BUFFER_FRONT_LEFT, rb); - - /* Let Mesa own the Depth, Stencil, and Accum buffers */ - _swrast_add_soft_renderbuffers(&pwfb->Base, - GL_FALSE, /* color */ - visual->depthBits > 0, - visual->stencilBits > 0, - visual->accumRedBits > 0, - visual->alphaBits >0, - GL_FALSE); - } - - if (c && pwfb) - _mesa_make_current(&c->gl_ctx, &pwfb->Base, &pwfb->Base); - else - _mesa_make_current(NULL, NULL, NULL); -} - - -void WMesaSwapBuffers( HDC hdc ) -{ - GET_CURRENT_CONTEXT(ctx); - WMesaContext pwc = wmesa_context(ctx); - WMesaFramebuffer pwfb = wmesa_lookup_framebuffer(hdc); - - if (!pwfb) { - _mesa_problem(NULL, "wmesa: swapbuffers on unknown hdc"); - return; - } - - /* If we're swapping the buffer associated with the current context - * we have to flush any pending rendering commands first. - */ - if (pwc->hDC == hdc) { - _mesa_notifySwapBuffers(ctx); - - BitBlt(pwfb->hDC, 0, 0, pwfb->Base.Width, pwfb->Base.Height, - pwfb->dib_hDC, 0, 0, SRCCOPY); - } - else { - /* XXX for now only allow swapping current window */ - _mesa_problem(NULL, "wmesa: can't swap non-current window"); - } -} - -void WMesaShareLists(WMesaContext ctx_to_share, WMesaContext ctx) -{ - _mesa_share_state(&ctx->gl_ctx, &ctx_to_share->gl_ctx); -} - diff --git a/mesalib/src/mesa/drivers/windows/gdi/wmesadef.h b/mesalib/src/mesa/drivers/windows/gdi/wmesadef.h deleted file mode 100644 index 9fda88390..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/wmesadef.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef WMESADEF_H -#define WMESADEF_H - -#include <windows.h> - -#include "main/context.h" - - -/** - * The Windows Mesa rendering context, derived from struct gl_context. - */ -struct wmesa_context { - struct gl_context gl_ctx; /* The core GL/Mesa context */ - HDC hDC; - COLORREF clearColorRef; - HPEN clearPen; - HBRUSH clearBrush; -}; - - -/** - * Windows framebuffer, derived from gl_framebuffer - */ -struct wmesa_framebuffer -{ - struct gl_framebuffer Base; - HDC hDC; - int pixelformat; - GLuint ScanWidth; - int cColorBits; - /* back buffer DIB fields */ - HDC dib_hDC; - BITMAPINFO bmi; - HBITMAP hbmDIB; - HBITMAP hOldBitmap; - PBYTE pbPixels; - struct wmesa_framebuffer *next; -}; - -typedef struct wmesa_framebuffer *WMesaFramebuffer; - - -#endif /* WMESADEF_H */ diff --git a/mesalib/src/mesa/main/.gitignore b/mesalib/src/mesa/main/.gitignore index e65472d63..8256ad792 100644 --- a/mesalib/src/mesa/main/.gitignore +++ b/mesalib/src/mesa/main/.gitignore @@ -1,13 +1,11 @@ api_exec.c dispatch.h enums.c -get_es1.c -get_es2.c git_sha1.h git_sha1.h.tmp remap_helper.h get_hash.h get_hash.h.tmp -format_info.c +format_info.h format_pack.c format_unpack.c diff --git a/mesalib/src/mesa/main/api_arrayelt.c b/mesalib/src/mesa/main/api_arrayelt.c index 536326f6e..ea015fd65 100644 --- a/mesalib/src/mesa/main/api_arrayelt.c +++ b/mesalib/src/mesa/main/api_arrayelt.c @@ -1548,7 +1548,7 @@ _ae_update_state(struct gl_context *ctx) */ at->array = attribArray; at->binding = &vao->VertexBinding[attribArray->VertexBinding]; - ASSERT(!at->array->Normalized); + assert(!at->array->Normalized); at->func = AttribFuncsNV[at->array->Normalized] [at->array->Size-1] [TYPE_IDX(at->array->Type)]; @@ -1610,8 +1610,8 @@ _ae_update_state(struct gl_context *ctx) check_vbo(actx, vao->IndexBufferObj); - ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX); - ASSERT(aa - actx->arrays < 32); + assert(at - actx->attribs <= VERT_ATTRIB_MAX); + assert(aa - actx->arrays < 32); at->func = NULL; /* terminate the list */ aa->offset = -1; /* terminate the list */ diff --git a/mesalib/src/mesa/main/api_exec.h b/mesalib/src/mesa/main/api_exec.h index ff35b78bb..1e4a9d61a 100644 --- a/mesalib/src/mesa/main/api_exec.h +++ b/mesalib/src/mesa/main/api_exec.h @@ -26,6 +26,9 @@ #ifndef API_EXEC_H #define API_EXEC_H +#ifdef __cplusplus +extern "C" { +#endif struct _glapi_table; struct gl_context; @@ -39,4 +42,8 @@ _mesa_initialize_exec_table(struct gl_context *ctx); extern void _mesa_initialize_dispatch_tables(struct gl_context *ctx); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/mesalib/src/mesa/main/api_loopback.h b/mesalib/src/mesa/main/api_loopback.h index 2195e01e3..44514405b 100644 --- a/mesalib/src/mesa/main/api_loopback.h +++ b/mesalib/src/mesa/main/api_loopback.h @@ -27,13 +27,7 @@ #ifndef API_LOOPBACK_H #define API_LOOPBACK_H -#include "main/compiler.h" -#include "main/glheader.h" // ? -#include "main/macros.h" // ? -#include "main/mtypes.h" // ? -#include "glapi/glapi.h" // ? -#include "main/dispatch.h" // ? -#include "main/context.h" // ? +#include "main/glheader.h" struct _glapi_table; struct gl_context; diff --git a/mesalib/src/mesa/main/arbprogram.c b/mesalib/src/mesa/main/arbprogram.c index fe8cd6bbc..f474951d7 100644 --- a/mesalib/src/mesa/main/arbprogram.c +++ b/mesalib/src/mesa/main/arbprogram.c @@ -118,8 +118,8 @@ _mesa_BindProgramARB(GLenum target, GLuint id) } /* Never null pointers */ - ASSERT(ctx->VertexProgram.Current); - ASSERT(ctx->FragmentProgram.Current); + assert(ctx->VertexProgram.Current); + assert(ctx->FragmentProgram.Current); if (ctx->Driver.BindProgram) ctx->Driver.BindProgram(ctx, target, newProg); @@ -524,7 +524,7 @@ _mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index, if (get_local_param_pointer(ctx, "glProgramLocalParameterARB", target, index, ¶m)) { - ASSERT(index < MAX_PROGRAM_LOCAL_PARAMS); + assert(index < MAX_PROGRAM_LOCAL_PARAMS); ASSIGN_4V(param, x, y, z, w); } } @@ -639,8 +639,8 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params) return; } - ASSERT(prog); - ASSERT(limits); + assert(prog); + assert(limits); /* Queries supported for both vertex and fragment programs */ switch (pname) { @@ -817,7 +817,7 @@ _mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string) return; } - ASSERT(prog); + assert(prog); if (pname != GL_PROGRAM_STRING_ARB) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramStringARB(pname)"); diff --git a/mesalib/src/mesa/main/arrayobj.c b/mesalib/src/mesa/main/arrayobj.c index 6440ea670..3c8ffb5a4 100644 --- a/mesalib/src/mesa/main/arrayobj.c +++ b/mesalib/src/mesa/main/arrayobj.c @@ -84,10 +84,10 @@ unbind_array_object_vbos(struct gl_context *ctx, struct gl_vertex_array_object * { GLuint i; - for (i = 0; i < Elements(obj->VertexBinding); i++) + for (i = 0; i < ARRAY_SIZE(obj->VertexBinding); i++) _mesa_reference_buffer_object(ctx, &obj->VertexBinding[i].BufferObj, NULL); - for (i = 0; i < Elements(obj->_VertexAttrib); i++) + for (i = 0; i < ARRAY_SIZE(obj->_VertexAttrib); i++) _mesa_reference_buffer_object(ctx, &obj->_VertexAttrib[i].BufferObj, NULL); } @@ -143,7 +143,7 @@ _mesa_reference_vao_(struct gl_context *ctx, struct gl_vertex_array_object *oldObj = *ptr; mtx_lock(&oldObj->Mutex); - ASSERT(oldObj->RefCount > 0); + assert(oldObj->RefCount > 0); oldObj->RefCount--; #if 0 printf("ArrayObj %p %d DECR to %d\n", @@ -153,13 +153,13 @@ _mesa_reference_vao_(struct gl_context *ctx, mtx_unlock(&oldObj->Mutex); if (deleteFlag) { - ASSERT(ctx->Driver.DeleteArrayObject); + assert(ctx->Driver.DeleteArrayObject); ctx->Driver.DeleteArrayObject(ctx, oldObj); } *ptr = NULL; } - ASSERT(!*ptr); + assert(!*ptr); if (vao) { /* reference new array object */ @@ -230,7 +230,7 @@ _mesa_initialize_vao(struct gl_context *ctx, obj->RefCount = 1; /* Init the individual arrays */ - for (i = 0; i < Elements(obj->VertexAttrib); i++) { + for (i = 0; i < ARRAY_SIZE(obj->VertexAttrib); i++) { switch (i) { case VERT_ATTRIB_WEIGHT: init_array(ctx, obj, VERT_ATTRIB_WEIGHT, 1, GL_FLOAT); @@ -335,7 +335,7 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, GLboolean genRequired) struct gl_vertex_array_object * const oldObj = ctx->Array.VAO; struct gl_vertex_array_object *newObj = NULL; - ASSERT(oldObj != NULL); + assert(oldObj != NULL); if ( oldObj->Name == id ) return; /* rebinding the same array object- no change */ @@ -456,7 +456,7 @@ _mesa_DeleteVertexArrays(GLsizei n, const GLuint *ids) struct gl_vertex_array_object *obj = _mesa_lookup_vao(ctx, ids[i]); if ( obj != NULL ) { - ASSERT( obj->Name == ids[i] ); + assert( obj->Name == ids[i] ); /* If the array object is currently bound, the spec says "the binding * for that object reverts to zero and the default vertex array diff --git a/mesalib/src/mesa/main/atifragshader.c b/mesalib/src/mesa/main/atifragshader.c index 1eab7731a..9d967b9e6 100644 --- a/mesalib/src/mesa/main/atifragshader.c +++ b/mesalib/src/mesa/main/atifragshader.c @@ -255,7 +255,7 @@ _mesa_BindFragmentShaderATI(GLuint id) /* do actual bind */ ctx->ATIFragmentShader.Current = newProg; - ASSERT(ctx->ATIFragmentShader.Current); + assert(ctx->ATIFragmentShader.Current); if (newProg) newProg->RefCount++; diff --git a/mesalib/src/mesa/main/atifragshader.h b/mesalib/src/mesa/main/atifragshader.h index afaea009d..590113410 100644 --- a/mesalib/src/mesa/main/atifragshader.h +++ b/mesalib/src/mesa/main/atifragshader.h @@ -8,10 +8,9 @@ #ifndef ATIFRAGSHADER_H #define ATIFRAGSHADER_H -#include "compiler.h" #include "glheader.h" -struct _glapi_table; + struct gl_context; #define MAX_NUM_INSTRUCTIONS_PER_PASS_ATI 8 diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c index 07934b9bc..20216a87d 100644 --- a/mesalib/src/mesa/main/attrib.c +++ b/mesalib/src/mesa/main/attrib.c @@ -1453,7 +1453,7 @@ copy_array_object(struct gl_context *ctx, /* In theory must be the same anyway, but on recreate make sure it matches */ dest->ARBsemantics = src->ARBsemantics; - for (i = 0; i < Elements(src->VertexAttrib); i++) { + for (i = 0; i < ARRAY_SIZE(src->VertexAttrib); i++) { _mesa_copy_client_array(ctx, &dest->_VertexAttrib[i], &src->_VertexAttrib[i]); _mesa_copy_vertex_attrib_array(ctx, &dest->VertexAttrib[i], &src->VertexAttrib[i]); _mesa_copy_vertex_buffer_binding(ctx, &dest->VertexBinding[i], &src->VertexBinding[i]); diff --git a/mesalib/src/mesa/main/attrib.h b/mesalib/src/mesa/main/attrib.h index 44413a6e8..f4fd4929f 100644 --- a/mesalib/src/mesa/main/attrib.h +++ b/mesalib/src/mesa/main/attrib.h @@ -26,7 +26,6 @@ #define ATTRIB_H -#include "compiler.h" #include "glheader.h" struct _glapi_table; diff --git a/mesalib/src/mesa/main/blend.c b/mesalib/src/mesa/main/blend.c index c37c0fea5..774fc888e 100644 --- a/mesalib/src/mesa/main/blend.c +++ b/mesalib/src/mesa/main/blend.c @@ -799,7 +799,7 @@ get_clamp_color(const struct gl_framebuffer *fb, GLenum clamp) if (clamp == GL_TRUE || clamp == GL_FALSE) return clamp; - ASSERT(clamp == GL_FIXED_ONLY); + assert(clamp == GL_FIXED_ONLY); if (!fb) return GL_TRUE; @@ -896,7 +896,7 @@ void _mesa_init_color( struct gl_context * ctx ) ctx->Color.AlphaFunc = GL_ALWAYS; ctx->Color.AlphaRef = 0; ctx->Color.BlendEnabled = 0x0; - for (i = 0; i < Elements(ctx->Color.Blend); i++) { + for (i = 0; i < ARRAY_SIZE(ctx->Color.Blend); i++) { ctx->Color.Blend[i].SrcRGB = GL_ONE; ctx->Color.Blend[i].DstRGB = GL_ZERO; ctx->Color.Blend[i].SrcA = GL_ONE; diff --git a/mesalib/src/mesa/main/blit.c b/mesalib/src/mesa/main/blit.c index b97b56479..0694466eb 100644 --- a/mesalib/src/mesa/main/blit.c +++ b/mesalib/src/mesa/main/blit.c @@ -28,6 +28,7 @@ */ #include <stdbool.h> +#include <stdio.h> #include "context.h" #include "enums.h" @@ -48,7 +49,7 @@ find_attachment(const struct gl_framebuffer *fb, const struct gl_renderbuffer *rb) { GLuint i; - for (i = 0; i < Elements(fb->Attachment); i++) { + for (i = 0; i < ARRAY_SIZE(fb->Attachment); i++) { if (fb->Attachment[i].Renderbuffer == rb) return &fb->Attachment[i]; } @@ -505,7 +506,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, return; } - ASSERT(ctx->Driver.BlitFramebuffer); + assert(ctx->Driver.BlitFramebuffer); ctx->Driver.BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, diff --git a/mesalib/src/mesa/main/blit.h b/mesalib/src/mesa/main/blit.h index 533d6e5d1..01a958af5 100644 --- a/mesalib/src/mesa/main/blit.h +++ b/mesalib/src/mesa/main/blit.h @@ -26,7 +26,6 @@ #ifndef BLIT_H #define BLIT_H -#include "compiler.h" #include "glheader.h" diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c index b372c68f2..e1c587779 100644 --- a/mesalib/src/mesa/main/bufferobj.c +++ b/mesalib/src/mesa/main/bufferobj.c @@ -446,7 +446,7 @@ _mesa_reference_buffer_object_(struct gl_context *ctx, struct gl_buffer_object *oldObj = *ptr; mtx_lock(&oldObj->Mutex); - ASSERT(oldObj->RefCount > 0); + assert(oldObj->RefCount > 0); oldObj->RefCount--; #if 0 printf("BufferObj %p %d DECR to %d\n", @@ -460,18 +460,18 @@ _mesa_reference_buffer_object_(struct gl_context *ctx, /* some sanity checking: don't delete a buffer still in use */ #if 0 /* unfortunately, these tests are invalid during context tear-down */ - ASSERT(ctx->Array.ArrayBufferObj != bufObj); - ASSERT(ctx->Array.VAO->IndexBufferObj != bufObj); - ASSERT(ctx->Array.VAO->Vertex.BufferObj != bufObj); + assert(ctx->Array.ArrayBufferObj != bufObj); + assert(ctx->Array.VAO->IndexBufferObj != bufObj); + assert(ctx->Array.VAO->Vertex.BufferObj != bufObj); #endif - ASSERT(ctx->Driver.DeleteBuffer); + assert(ctx->Driver.DeleteBuffer); ctx->Driver.DeleteBuffer(ctx, oldObj); } *ptr = NULL; } - ASSERT(!*ptr); + assert(!*ptr); if (bufObj) { /* reference new buffer */ @@ -614,7 +614,7 @@ _mesa_buffer_subdata( struct gl_context *ctx, GLintptrARB offset, (void) ctx; /* this should have been caught in _mesa_BufferSubData() */ - ASSERT(size + offset <= bufObj->Size); + assert(size + offset <= bufObj->Size); if (bufObj->Data) { memcpy( (GLubyte *) bufObj->Data + offset, data, size ); @@ -679,7 +679,7 @@ _mesa_buffer_clear_subdata(struct gl_context *ctx, GLsizeiptr i; GLubyte *dest; - ASSERT(ctx->Driver.MapBufferRange); + assert(ctx->Driver.MapBufferRange); dest = ctx->Driver.MapBufferRange(ctx, offset, size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT, @@ -908,7 +908,7 @@ _mesa_handle_bind_buffer_gen(struct gl_context *ctx, /* If this is a new buffer object id, or one which was generated but * never used before, allocate a buffer object now. */ - ASSERT(ctx->Driver.NewBufferObject); + assert(ctx->Driver.NewBufferObject); buf = ctx->Driver.NewBufferObject(ctx, buffer); if (!buf) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller); @@ -1124,7 +1124,7 @@ _mesa_buffer_unmap_all_mappings(struct gl_context *ctx, for (i = 0; i < MAP_COUNT; i++) { if (_mesa_bufferobj_mapped(bufObj, i)) { ctx->Driver.UnmapBuffer(ctx, bufObj, i); - ASSERT(bufObj->Mappings[i].Pointer == NULL); + assert(bufObj->Mappings[i].Pointer == NULL); bufObj->Mappings[i].AccessFlags = 0; } } @@ -1174,12 +1174,12 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids) struct gl_vertex_array_object *vao = ctx->Array.VAO; GLuint j; - ASSERT(bufObj->Name == ids[i] || bufObj == &DummyBufferObject); + assert(bufObj->Name == ids[i] || bufObj == &DummyBufferObject); _mesa_buffer_unmap_all_mappings(ctx, bufObj); /* unbind any vertex pointers bound to this buffer */ - for (j = 0; j < Elements(vao->VertexBinding); j++) { + for (j = 0; j < ARRAY_SIZE(vao->VertexBinding); j++) { unbind(ctx, &vao->VertexBinding[j].BufferObj, bufObj); } @@ -1387,7 +1387,7 @@ _mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data, bufObj->Written = GL_TRUE; bufObj->Immutable = GL_TRUE; - ASSERT(ctx->Driver.BufferData); + assert(ctx->Driver.BufferData); if (!ctx->Driver.BufferData(ctx, target, size, data, GL_DYNAMIC_DRAW, flags, bufObj)) { if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) { @@ -1477,7 +1477,7 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size, size += 100; #endif - ASSERT(ctx->Driver.BufferData); + assert(ctx->Driver.BufferData); if (!ctx->Driver.BufferData(ctx, target, size, data, usage, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | @@ -1525,7 +1525,7 @@ _mesa_BufferSubData(GLenum target, GLintptrARB offset, bufObj->Written = GL_TRUE; - ASSERT(ctx->Driver.BufferSubData); + assert(ctx->Driver.BufferSubData); ctx->Driver.BufferSubData( ctx, offset, size, data, bufObj ); } @@ -1545,7 +1545,7 @@ _mesa_GetBufferSubData(GLenum target, GLintptrARB offset, return; } - ASSERT(ctx->Driver.GetBufferSubData); + assert(ctx->Driver.GetBufferSubData); ctx->Driver.GetBufferSubData( ctx, offset, size, data, bufObj ); } @@ -1722,7 +1722,7 @@ _mesa_MapBuffer(GLenum target, GLenum access) return NULL; } - ASSERT(ctx->Driver.MapBufferRange); + assert(ctx->Driver.MapBufferRange); map = ctx->Driver.MapBufferRange(ctx, 0, bufObj->Size, accessFlags, bufObj, MAP_USER); if (!map) { @@ -1734,9 +1734,9 @@ _mesa_MapBuffer(GLenum target, GLenum access) * This is important because other modules (like VBO) might call * the driver function directly. */ - ASSERT(bufObj->Mappings[MAP_USER].Pointer == map); - ASSERT(bufObj->Mappings[MAP_USER].Length == bufObj->Size); - ASSERT(bufObj->Mappings[MAP_USER].Offset == 0); + assert(bufObj->Mappings[MAP_USER].Pointer == map); + assert(bufObj->Mappings[MAP_USER].Length == bufObj->Size); + assert(bufObj->Mappings[MAP_USER].Offset == 0); bufObj->Mappings[MAP_USER].AccessFlags = accessFlags; } @@ -1824,9 +1824,9 @@ _mesa_UnmapBuffer(GLenum target) status = ctx->Driver.UnmapBuffer(ctx, bufObj, MAP_USER); bufObj->Mappings[MAP_USER].AccessFlags = 0; - ASSERT(bufObj->Mappings[MAP_USER].Pointer == NULL); - ASSERT(bufObj->Mappings[MAP_USER].Offset == 0); - ASSERT(bufObj->Mappings[MAP_USER].Length == 0); + assert(bufObj->Mappings[MAP_USER].Pointer == NULL); + assert(bufObj->Mappings[MAP_USER].Offset == 0); + assert(bufObj->Mappings[MAP_USER].Length == 0); return status; } @@ -2203,7 +2203,7 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, return bufObj->Mappings[MAP_USER].Pointer; } - ASSERT(ctx->Driver.MapBufferRange); + assert(ctx->Driver.MapBufferRange); map = ctx->Driver.MapBufferRange(ctx, offset, length, access, bufObj, MAP_USER); if (!map) { @@ -2214,10 +2214,10 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, * This is important because other modules (like VBO) might call * the driver function directly. */ - ASSERT(bufObj->Mappings[MAP_USER].Pointer == map); - ASSERT(bufObj->Mappings[MAP_USER].Length == length); - ASSERT(bufObj->Mappings[MAP_USER].Offset == offset); - ASSERT(bufObj->Mappings[MAP_USER].AccessFlags == access); + assert(bufObj->Mappings[MAP_USER].Pointer == map); + assert(bufObj->Mappings[MAP_USER].Length == length); + assert(bufObj->Mappings[MAP_USER].Offset == offset); + assert(bufObj->Mappings[MAP_USER].AccessFlags == access); } return map; @@ -2278,7 +2278,7 @@ _mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) return; } - ASSERT(bufObj->Mappings[MAP_USER].AccessFlags & GL_MAP_WRITE_BIT); + assert(bufObj->Mappings[MAP_USER].AccessFlags & GL_MAP_WRITE_BIT); if (ctx->Driver.FlushMappedBufferRange) ctx->Driver.FlushMappedBufferRange(ctx, offset, length, bufObj, diff --git a/mesalib/src/mesa/main/buffers.c b/mesalib/src/mesa/main/buffers.c index e5076e9bb..37a979092 100644 --- a/mesalib/src/mesa/main/buffers.c +++ b/mesalib/src/mesa/main/buffers.c @@ -502,7 +502,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers, GLuint output; for (output = 0; output < n; output++) { mask[output] = draw_buffer_enum_to_bitmask(ctx, buffers[output]); - ASSERT(mask[output] != BAD_MASK); + assert(mask[output] != BAD_MASK); mask[output] &= supportedMask; } destMask = mask; @@ -533,7 +533,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers, if (destMask[buf]) { GLint bufIndex = ffs(destMask[buf]) - 1; /* only one bit should be set in the destMask[buf] field */ - ASSERT(_mesa_bitcount(destMask[buf]) == 1); + assert(_mesa_bitcount(destMask[buf]) == 1); if (fb->_ColorDrawBufferIndexes[buf] != bufIndex) { updated_drawbuffers(ctx); fb->_ColorDrawBufferIndexes[buf] = bufIndex; diff --git a/mesalib/src/mesa/main/clear.c b/mesalib/src/mesa/main/clear.c index 3c4ced8ed..8d707bc34 100644 --- a/mesalib/src/mesa/main/clear.c +++ b/mesalib/src/mesa/main/clear.c @@ -218,7 +218,7 @@ _mesa_Clear( GLbitfield mask ) bufferMask |= BUFFER_BIT_ACCUM; } - ASSERT(ctx->Driver.Clear); + assert(ctx->Driver.Clear); ctx->Driver.Clear(ctx, bufferMask); } } diff --git a/mesalib/src/mesa/main/colortab.h b/mesalib/src/mesa/main/colortab.h index 55c3b59fa..e1165d702 100644 --- a/mesalib/src/mesa/main/colortab.h +++ b/mesalib/src/mesa/main/colortab.h @@ -26,8 +26,6 @@ #ifndef COLORTAB_H #define COLORTAB_H - -#include "compiler.h" #include "glheader.h" struct _glapi_table; diff --git a/mesalib/src/mesa/main/compiler.h b/mesalib/src/mesa/main/compiler.h index cdc843db2..95581fb49 100644 --- a/mesalib/src/mesa/main/compiler.h +++ b/mesalib/src/mesa/main/compiler.h @@ -35,14 +35,6 @@ #include <assert.h> -#include <ctype.h> -#include <math.h> -#include <limits.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <float.h> -#include <stdarg.h> #include "util/macros.h" @@ -55,12 +47,6 @@ extern "C" { /** - * Get standard integer types - */ -#include <stdint.h> - - -/** * Sun compilers define __i386 instead of the gcc-style __i386__ */ #ifdef __SUNPRO_C @@ -78,14 +64,6 @@ extern "C" { /** - * finite macro. - */ -#if defined(_MSC_VER) -# define finite _finite -#endif - - -/** * Disable assorted warnings */ #if defined(_WIN32) && !defined(__CYGWIN__) @@ -105,33 +83,6 @@ extern "C" { #endif - -/* XXX: Use standard `inline` keyword instead */ -#ifndef INLINE -# define INLINE inline -#endif - - -/** - * PUBLIC/USED macros - * - * If we build the library with gcc's -fvisibility=hidden flag, we'll - * use the PUBLIC macro to mark functions that are to be exported. - * - * We also need to define a USED attribute, so the optimizer doesn't - * inline a static function that we later use in an alias. - ajax - */ -#ifndef PUBLIC -# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define PUBLIC __attribute__((visibility("default"))) -# define USED __attribute__((used)) -# else -# define PUBLIC -# define USED -# endif -#endif - - /* XXX: Use standard `__func__` instead */ #ifndef __FUNCTION__ # define __FUNCTION__ __func__ @@ -174,11 +125,6 @@ static inline GLuint CPU_TO_LE32(GLuint x) -#if !defined(CAPI) && defined(_WIN32) -#define CAPI _cdecl -#endif - - /** * Create a macro so that asm functions can be linked into compilers other * than GNU C @@ -196,41 +142,6 @@ static inline GLuint CPU_TO_LE32(GLuint x) #endif #endif -#ifdef USE_X86_ASM -#define _NORMAPI _ASMAPI -#define _NORMAPIP _ASMAPIP -#else -#define _NORMAPI -#define _NORMAPIP * -#endif - - -/* Turn off macro checking systems used by other libraries */ -#ifdef CHECK -#undef CHECK -#endif - - -/** - * ASSERT macro - */ -#if defined(DEBUG) -# define ASSERT(X) assert(X) -#else -# define ASSERT(X) -#endif - - -/* - * A trick to suppress uninitialized variable warning without generating any - * code - */ -#define uninitialized_var(x) x = x - -#ifndef NULL -#define NULL 0 -#endif - /** * LONGSTRING macro @@ -242,111 +153,8 @@ static inline GLuint CPU_TO_LE32(GLuint x) # define LONGSTRING __extension__ #endif - -#ifndef M_PI -#define M_PI (3.14159265358979323846) -#endif - -#ifndef M_E -#define M_E (2.7182818284590452354) -#endif - -#ifndef M_LOG2E -#define M_LOG2E (1.4426950408889634074) -#endif - -#ifndef ONE_DIV_SQRT_LN2 -#define ONE_DIV_SQRT_LN2 (1.201122408786449815) -#endif - -#ifndef FLT_MAX_EXP -#define FLT_MAX_EXP 128 -#endif - #define IEEE_ONE 0x3f800000 -/** - * START/END_FAST_MATH macros: - * - * START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save - * original mode to a temporary). - * END_FAST_MATH: Restore x86 FPU to original mode. - */ -#if defined(__GNUC__) && defined(__i386__) -/* - * Set the x86 FPU control word to guarentee only 32 bits of precision - * are stored in registers. Allowing the FPU to store more introduces - * differences between situations where numbers are pulled out of memory - * vs. situations where the compiler is able to optimize register usage. - * - * In the worst case, we force the compiler to use a memory access to - * truncate the float, by specifying the 'volatile' keyword. - */ -/* Hardware default: All exceptions masked, extended double precision, - * round to nearest (IEEE compliant): - */ -#define DEFAULT_X86_FPU 0x037f -/* All exceptions masked, single precision, round to nearest: - */ -#define FAST_X86_FPU 0x003f -/* The fldcw instruction will cause any pending FP exceptions to be - * raised prior to entering the block, and we clear any pending - * exceptions before exiting the block. Hence, asm code has free - * reign over the FPU while in the fast math block. - */ -#if defined(NO_FAST_MATH) -#define START_FAST_MATH(x) \ -do { \ - static GLuint mask = DEFAULT_X86_FPU; \ - __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ - __asm__ ( "fldcw %0" : : "m" (mask) ); \ -} while (0) -#else -#define START_FAST_MATH(x) \ -do { \ - static GLuint mask = FAST_X86_FPU; \ - __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ - __asm__ ( "fldcw %0" : : "m" (mask) ); \ -} while (0) -#endif -/* Restore original FPU mode, and clear any exceptions that may have - * occurred in the FAST_MATH block. - */ -#define END_FAST_MATH(x) \ -do { \ - __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \ -} while (0) - -#elif defined(_MSC_VER) && defined(_M_IX86) -#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ -#define FAST_X86_FPU 0x003f /* See GCC comments above */ -#if defined(NO_FAST_MATH) -#define START_FAST_MATH(x) do {\ - static GLuint mask = DEFAULT_X86_FPU;\ - __asm fnstcw word ptr [x]\ - __asm fldcw word ptr [mask]\ -} while(0) -#else -#define START_FAST_MATH(x) do {\ - static GLuint mask = FAST_X86_FPU;\ - __asm fnstcw word ptr [x]\ - __asm fldcw word ptr [mask]\ -} while(0) -#endif -#define END_FAST_MATH(x) do {\ - __asm fnclex\ - __asm fldcw word ptr [x]\ -} while(0) - -#else -#define START_FAST_MATH(x) x = 0 -#define END_FAST_MATH(x) (void)(x) -#endif - - -#ifndef Elements -#define Elements(x) (sizeof(x)/sizeof(*(x))) -#endif #ifdef __cplusplus } diff --git a/mesalib/src/mesa/main/condrender.c b/mesalib/src/mesa/main/condrender.c index 75f9d74bc..77e4b95ee 100644 --- a/mesalib/src/mesa/main/condrender.c +++ b/mesalib/src/mesa/main/condrender.c @@ -55,7 +55,7 @@ _mesa_BeginConditionalRender(GLuint queryId, GLenum mode) return; } - ASSERT(ctx->Query.CondRenderMode == GL_NONE); + assert(ctx->Query.CondRenderMode == GL_NONE); /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says: * @@ -70,7 +70,7 @@ _mesa_BeginConditionalRender(GLuint queryId, GLenum mode) "glBeginConditionalRender(bad queryId=%u)", queryId); return; } - ASSERT(q->Id == queryId); + assert(q->Id == queryId); switch (mode) { case GL_QUERY_WAIT: diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index b186a1fad..22c2341d6 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -134,6 +134,7 @@ #include "math/m_matrix.h" #include "main/dispatch.h" /* for _gloffset_COUNT */ #include "uniforms.h" +#include "macros.h" #ifdef USE_SPARC_ASM #include "sparc/sparc.h" @@ -446,7 +447,7 @@ _mesa_init_current(struct gl_context *ctx) GLuint i; /* Init all to (0,0,0,1) */ - for (i = 0; i < Elements(ctx->Current.Attrib); i++) { + for (i = 0; i < ARRAY_SIZE(ctx->Current.Attrib); i++) { ASSIGN_4V( ctx->Current.Attrib[i], 0.0, 0.0, 0.0, 1.0 ); } @@ -656,7 +657,7 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api) consts->MaxSamples = 0; /* GLSL default if NativeIntegers == FALSE */ - consts->UniformBooleanTrue = FLT_AS_UINT(1.0f); + consts->UniformBooleanTrue = FLOAT_AS_UNION(1.0f).u; /* GL_ARB_sync */ consts->MaxServerWaitTimeout = 0x1fff7fffffffULL; @@ -1644,7 +1645,7 @@ _mesa_make_current( struct gl_context *newCtx, /* We used to call _glapi_check_multithread() here. Now do it in drivers */ _glapi_set_context((void *) newCtx); - ASSERT(_mesa_get_current_context() == newCtx); + assert(_mesa_get_current_context() == newCtx); if (!newCtx) { _glapi_set_dispatch(NULL); /* none current */ @@ -1653,8 +1654,8 @@ _mesa_make_current( struct gl_context *newCtx, _glapi_set_dispatch(newCtx->CurrentDispatch); if (drawBuffer && readBuffer) { - ASSERT(_mesa_is_winsys_fbo(drawBuffer)); - ASSERT(_mesa_is_winsys_fbo(readBuffer)); + assert(_mesa_is_winsys_fbo(drawBuffer)); + assert(_mesa_is_winsys_fbo(readBuffer)); _mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer); _mesa_reference_framebuffer(&newCtx->WinSysReadBuffer, readBuffer); diff --git a/mesalib/src/mesa/main/convolve.h b/mesalib/src/mesa/main/convolve.h index 0c0a9dd5e..e696ce497 100644 --- a/mesalib/src/mesa/main/convolve.h +++ b/mesalib/src/mesa/main/convolve.h @@ -28,7 +28,7 @@ #define CONVOLVE_H -#include "compiler.h" +#include "glheader.h" struct _glapi_table; diff --git a/mesalib/src/mesa/main/cpuinfo.c b/mesalib/src/mesa/main/cpuinfo.c index 0755d6b21..67f22ab9c 100644 --- a/mesalib/src/mesa/main/cpuinfo.c +++ b/mesalib/src/mesa/main/cpuinfo.c @@ -23,7 +23,7 @@ */ -#include "main/compiler.h" +#include "main/imports.h" #include "main/cpuinfo.h" diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h index ec8662b30..0c1a13fa4 100644 --- a/mesalib/src/mesa/main/dd.h +++ b/mesalib/src/mesa/main/dd.h @@ -824,7 +824,7 @@ struct dd_function_table { void (*BeginVertices)( struct gl_context *ctx ); /** - * If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if + * If inside glBegin()/glEnd(), it should assert(0). Otherwise, if * FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered * vertices, if FLUSH_UPDATE_CURRENT bit is set updates * __struct gl_contextRec::Current and gl_light_attrib::Material diff --git a/mesalib/src/mesa/main/debug.c b/mesalib/src/mesa/main/debug.c index 089ce8987..b50d79e0c 100644 --- a/mesalib/src/mesa/main/debug.c +++ b/mesalib/src/mesa/main/debug.c @@ -23,6 +23,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include <stdio.h> #include "mtypes.h" #include "attrib.h" #include "colormac.h" @@ -58,8 +59,8 @@ tex_target_name(GLenum tgt) { GL_TEXTURE_EXTERNAL_OES, "GL_TEXTURE_EXTERNAL_OES" } }; GLuint i; - STATIC_ASSERT(Elements(tex_targets) == NUM_TEXTURE_TARGETS); - for (i = 0; i < Elements(tex_targets); i++) { + STATIC_ASSERT(ARRAY_SIZE(tex_targets) == NUM_TEXTURE_TARGETS); + for (i = 0; i < ARRAY_SIZE(tex_targets); i++) { if (tex_targets[i].target == tgt) return tex_targets[i].name; } @@ -117,11 +118,6 @@ void _mesa_print_info( struct gl_context *ctx ) */ _mesa_debug(NULL, "Mesa GL_EXTENSIONS = %s\n", ctx->Extensions.String); -#if defined(THREADS) - _mesa_debug(NULL, "Mesa thread-safe: YES\n"); -#else - _mesa_debug(NULL, "Mesa thread-safe: NO\n"); -#endif #if defined(USE_X86_ASM) _mesa_debug(NULL, "Mesa x86-optimized: YES\n"); #else @@ -168,7 +164,7 @@ set_verbose_flags(const char *str) return; MESA_VERBOSE = 0x0; - for (i = 0; i < Elements(opts); i++) { + for (i = 0; i < ARRAY_SIZE(opts); i++) { if (strstr(str, opts[i].name) || strcmp(str, "all") == 0) MESA_VERBOSE |= opts[i].flag; } @@ -201,7 +197,7 @@ set_debug_flags(const char *str) return; MESA_DEBUG_FLAGS = 0x0; - for (i = 0; i < Elements(opts); i++) { + for (i = 0; i < ARRAY_SIZE(opts); i++) { if (strstr(str, opts[i].name)) MESA_DEBUG_FLAGS |= opts[i].flag; } diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c index 025f6abd2..431c4b48b 100644 --- a/mesalib/src/mesa/main/dlist.c +++ b/mesalib/src/mesa/main/dlist.c @@ -29,6 +29,7 @@ * Display lists management functions. */ +#include "c99_math.h" #include "glheader.h" #include "imports.h" #include "api_arrayelt.h" @@ -912,7 +913,7 @@ translate_id(GLsizei n, GLenum type, const GLvoid * list) return (GLint) uiptr[n]; case GL_FLOAT: fptr = (GLfloat *) list; - return (GLint) FLOORF(fptr[n]); + return (GLint) floorf(fptr[n]); case GL_2_BYTES: ubptr = ((GLubyte *) list) + 2 * n; return (GLint) ubptr[0] * 256 @@ -1035,7 +1036,7 @@ dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes, bool align8) } else { /* make sure instruction size agrees */ - ASSERT(numNodes == InstSize[opcode]); + assert(numNodes == InstSize[opcode]); } } @@ -5089,7 +5090,7 @@ save_Attr1fNV(GLenum attr, GLfloat x) n[2].f = x; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 1; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); @@ -5111,7 +5112,7 @@ save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y) n[3].f = y; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 2; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); @@ -5134,7 +5135,7 @@ save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z) n[4].f = z; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 3; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); @@ -5158,7 +5159,7 @@ save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) n[5].f = w; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 4; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); @@ -5180,7 +5181,7 @@ save_Attr1fARB(GLenum attr, GLfloat x) n[2].f = x; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 1; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1); @@ -5202,7 +5203,7 @@ save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y) n[3].f = y; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 2; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1); @@ -5225,7 +5226,7 @@ save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z) n[4].f = z; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 3; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1); @@ -5249,7 +5250,7 @@ save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w) n[5].f = w; } - ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS); + assert(attr < MAX_VERTEX_GENERIC_ATTRIBS); ctx->ListState.ActiveAttribSize[attr] = 4; ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w); diff --git a/mesalib/src/mesa/main/dlist.h b/mesalib/src/mesa/main/dlist.h index 6189632d4..a1214674c 100644 --- a/mesalib/src/mesa/main/dlist.h +++ b/mesalib/src/mesa/main/dlist.h @@ -32,7 +32,7 @@ #ifndef DLIST_H #define DLIST_H - +#include <stdio.h> #include "main/mtypes.h" diff --git a/mesalib/src/mesa/main/drawpix.c b/mesalib/src/mesa/main/drawpix.c index 1865a66b9..55035f214 100644 --- a/mesalib/src/mesa/main/drawpix.c +++ b/mesalib/src/mesa/main/drawpix.c @@ -173,7 +173,7 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, ctx->Current.RasterTexCoords[0] ); } else { - ASSERT(ctx->RenderMode == GL_SELECT); + assert(ctx->RenderMode == GL_SELECT); /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ } @@ -279,7 +279,7 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, ctx->Current.RasterTexCoords[0] ); } else { - ASSERT(ctx->RenderMode == GL_SELECT); + assert(ctx->RenderMode == GL_SELECT); /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ } @@ -355,7 +355,7 @@ _mesa_Bitmap( GLsizei width, GLsizei height, ctx->Current.RasterTexCoords[0] ); } else { - ASSERT(ctx->RenderMode == GL_SELECT); + assert(ctx->RenderMode == GL_SELECT); /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */ } diff --git a/mesalib/src/mesa/main/drawpix.h b/mesalib/src/mesa/main/drawpix.h index eb2cb8922..181c05ca5 100644 --- a/mesalib/src/mesa/main/drawpix.h +++ b/mesalib/src/mesa/main/drawpix.h @@ -26,9 +26,7 @@ #define DRAWPIX_H -#include "compiler.h" - -struct _glapi_table; +#include "glheader.h" void GLAPIENTRY diff --git a/mesalib/src/mesa/main/drawtex.c b/mesalib/src/mesa/main/drawtex.c index 7c0ec832b..9c4fdf90e 100644 --- a/mesalib/src/mesa/main/drawtex.c +++ b/mesalib/src/mesa/main/drawtex.c @@ -46,7 +46,7 @@ draw_texture(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, if (ctx->NewState) _mesa_update_state(ctx); - ASSERT(ctx->Driver.DrawTex); + assert(ctx->Driver.DrawTex); ctx->Driver.DrawTex(ctx, x, y, z, width, height); _mesa_set_vp_override(ctx, GL_FALSE); diff --git a/mesalib/src/mesa/main/enable.c b/mesalib/src/mesa/main/enable.c index 11365ecc4..9008a3863 100644 --- a/mesalib/src/mesa/main/enable.c +++ b/mesalib/src/mesa/main/enable.c @@ -1060,7 +1060,7 @@ void _mesa_set_enablei(struct gl_context *ctx, GLenum cap, GLuint index, GLboolean state) { - ASSERT(state == 0 || state == 1); + assert(state == 0 || state == 1); switch (cap) { case GL_BLEND: if (!ctx->Extensions.EXT_draw_buffers2) { diff --git a/mesalib/src/mesa/main/errors.c b/mesalib/src/mesa/main/errors.c index 478e4ed33..8ffbf413c 100644 --- a/mesalib/src/mesa/main/errors.c +++ b/mesalib/src/mesa/main/errors.c @@ -28,6 +28,8 @@ */ +#include <stdarg.h> +#include <stdio.h> #include "errors.h" #include "enums.h" #include "imports.h" @@ -136,7 +138,7 @@ gl_enum_to_debug_source(GLenum e) { unsigned i; - for (i = 0; i < Elements(debug_source_enums); i++) { + for (i = 0; i < ARRAY_SIZE(debug_source_enums); i++) { if (debug_source_enums[i] == e) break; } @@ -148,7 +150,7 @@ gl_enum_to_debug_type(GLenum e) { unsigned i; - for (i = 0; i < Elements(debug_type_enums); i++) { + for (i = 0; i < ARRAY_SIZE(debug_type_enums); i++) { if (debug_type_enums[i] == e) break; } @@ -160,7 +162,7 @@ gl_enum_to_debug_severity(GLenum e) { unsigned i; - for (i = 0; i < Elements(debug_severity_enums); i++) { + for (i = 0; i < ARRAY_SIZE(debug_severity_enums); i++) { if (debug_severity_enums[i] == e) break; } @@ -1465,7 +1467,7 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) /* Too long error message. Whoever calls _mesa_error should use * shorter strings. */ - ASSERT(0); + assert(0); return; } @@ -1473,7 +1475,7 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) _mesa_lookup_enum_by_nr(error), s); if (len >= MAX_DEBUG_MESSAGE_LENGTH) { /* Same as above. */ - ASSERT(0); + assert(0); return; } diff --git a/mesalib/src/mesa/main/es1_conversion.c b/mesalib/src/mesa/main/es1_conversion.c index 60a60e287..b254a6ef1 100644 --- a/mesalib/src/mesa/main/es1_conversion.c +++ b/mesalib/src/mesa/main/es1_conversion.c @@ -55,7 +55,7 @@ _mesa_ClipPlanef(GLenum plane, const GLfloat *equation) unsigned int i; GLdouble converted_equation[4]; - for (i = 0; i < Elements(converted_equation); i++) { + for (i = 0; i < ARRAY_SIZE(converted_equation); i++) { converted_equation[i] = (GLdouble) (equation[i]); } @@ -68,7 +68,7 @@ _mesa_ClipPlanex(GLenum plane, const GLfixed *equation) unsigned int i; GLdouble converted_equation[4]; - for (i = 0; i < Elements(converted_equation); i++) { + for (i = 0; i < ARRAY_SIZE(converted_equation); i++) { converted_equation[i] = (GLdouble) (equation[i] / 65536.0); } @@ -117,7 +117,7 @@ _mesa_DrawTexxvOES(const GLfixed *coords) unsigned int i; GLfloat converted_coords[5]; - for (i = 0; i < Elements(converted_coords); i++) { + for (i = 0; i < ARRAY_SIZE(converted_coords); i++) { converted_coords[i] = (GLfloat) (coords[i] / 65536.0f); } @@ -206,7 +206,7 @@ _mesa_GetClipPlanef(GLenum plane, GLfloat *equation) GLdouble converted_equation[4]; _mesa_GetClipPlane(plane, converted_equation); - for (i = 0; i < Elements(converted_equation); i++) { + for (i = 0; i < ARRAY_SIZE(converted_equation); i++) { equation[i] = (GLfloat) (converted_equation[i]); } } @@ -218,7 +218,7 @@ _mesa_GetClipPlanex(GLenum plane, GLfixed *equation) GLdouble converted_equation[4]; _mesa_GetClipPlane(plane, converted_equation); - for (i = 0; i < Elements(converted_equation); i++) { + for (i = 0; i < ARRAY_SIZE(converted_equation); i++) { equation[i] = (GLfixed) (converted_equation[i] * 65536); } } @@ -549,7 +549,7 @@ _mesa_LoadMatrixx(const GLfixed *m) unsigned int i; GLfloat converted_m[16]; - for (i = 0; i < Elements(converted_m); i++) { + for (i = 0; i < ARRAY_SIZE(converted_m); i++) { converted_m[i] = (GLfloat) (m[i] / 65536.0f); } @@ -617,7 +617,7 @@ _mesa_MultMatrixx(const GLfixed *m) unsigned int i; GLfloat converted_m[16]; - for (i = 0; i < Elements(converted_m); i++) { + for (i = 0; i < ARRAY_SIZE(converted_m); i++) { converted_m[i] = (GLfloat) (m[i] / 65536.0f); } @@ -825,7 +825,7 @@ _mesa_TexEnvxv(GLenum target, GLenum pname, const GLfixed *params) unsigned int i; GLfloat converted_params[4]; - for (i = 0; i < Elements(converted_params); i++) { + for (i = 0; i < ARRAY_SIZE(converted_params); i++) { converted_params[i] = (GLfloat) (params[i] / 65536.0f); } diff --git a/mesalib/src/mesa/main/eval.c b/mesalib/src/mesa/main/eval.c index 84cd7563b..86c8f75a1 100644 --- a/mesalib/src/mesa/main/eval.c +++ b/mesalib/src/mesa/main/eval.c @@ -309,7 +309,7 @@ map1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLfloat *pnts; struct gl_1d_map *map = NULL; - ASSERT(type == GL_FLOAT || type == GL_DOUBLE); + assert(type == GL_FLOAT || type == GL_DOUBLE); if (u1 == u2) { _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(u1,u2)" ); @@ -391,7 +391,7 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat *pnts; struct gl_2d_map *map = NULL; - ASSERT(type == GL_FLOAT || type == GL_DOUBLE); + assert(type == GL_FLOAT || type == GL_DOUBLE); if (u1==u2) { _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(u1,u2)" ); @@ -505,7 +505,7 @@ _mesa_GetnMapdvARB( GLenum target, GLenum query, GLsizei bufSize, GLdouble *v ) map1d = get_1d_map(ctx, target); map2d = get_2d_map(ctx, target); - ASSERT(map1d || map2d); + assert(map1d || map2d); switch (query) { case GL_COEFF: @@ -595,7 +595,7 @@ _mesa_GetnMapfvARB( GLenum target, GLenum query, GLsizei bufSize, GLfloat *v ) map1d = get_1d_map(ctx, target); map2d = get_2d_map(ctx, target); - ASSERT(map1d || map2d); + assert(map1d || map2d); switch (query) { case GL_COEFF: @@ -687,7 +687,7 @@ _mesa_GetnMapivARB( GLenum target, GLenum query, GLsizei bufSize, GLint *v ) map1d = get_1d_map(ctx, target); map2d = get_2d_map(ctx, target); - ASSERT(map1d || map2d); + assert(map1d || map2d); switch (query) { case GL_COEFF: diff --git a/mesalib/src/mesa/main/execmem.c b/mesalib/src/mesa/main/execmem.c index 7267cf85f..3a1338515 100644 --- a/mesalib/src/mesa/main/execmem.c +++ b/mesalib/src/mesa/main/execmem.c @@ -31,6 +31,7 @@ */ +#include <stdio.h> #include "imports.h" diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c index 305362297..f8d0d92bf 100644 --- a/mesalib/src/mesa/main/fbobject.c +++ b/mesalib/src/mesa/main/fbobject.c @@ -324,14 +324,14 @@ remove_attachment(struct gl_context *ctx, ctx->Driver.FinishRenderTexture(ctx, rb); if (att->Type == GL_TEXTURE) { - ASSERT(att->Texture); + assert(att->Texture); _mesa_reference_texobj(&att->Texture, NULL); /* unbind */ - ASSERT(!att->Texture); + assert(!att->Texture); } if (att->Type == GL_TEXTURE || att->Type == GL_RENDERBUFFER_EXT) { - ASSERT(!att->Texture); + assert(!att->Texture); _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); /* unbind */ - ASSERT(!att->Renderbuffer); + assert(!att->Renderbuffer); } att->Type = GL_NONE; att->Complete = GL_TRUE; @@ -433,7 +433,7 @@ set_texture_attachment(struct gl_context *ctx, if (att->Texture == texObj) { /* re-attaching same texture */ - ASSERT(att->Type == GL_TEXTURE); + assert(att->Type == GL_TEXTURE); } else { /* new attachment */ @@ -488,7 +488,7 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx, mtx_lock(&fb->Mutex); att = get_attachment(ctx, fb, attachment); - ASSERT(att); + assert(att); if (rb) { set_renderbuffer_attachment(ctx, att, rb); if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { @@ -809,7 +809,7 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format, } } else { - ASSERT(format == GL_STENCIL); + assert(format == GL_STENCIL); if (ctx->Extensions.ARB_depth_texture && baseFormat == GL_DEPTH_STENCIL) { /* OK */ @@ -826,7 +826,7 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format, const GLenum baseFormat = _mesa_get_format_base_format(att->Renderbuffer->Format); - ASSERT(att->Renderbuffer); + assert(att->Renderbuffer); if (!att->Renderbuffer->InternalFormat || att->Renderbuffer->Width < 1 || att->Renderbuffer->Height < 1) { @@ -868,7 +868,7 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format, } } else { - ASSERT(att->Type == GL_NONE); + assert(att->Type == GL_NONE); /* complete */ return; } @@ -1239,7 +1239,7 @@ bind_renderbuffer(GLenum target, GLuint renderbuffer, bool allow_user_names) _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT"); return; } - ASSERT(newRb->AllocStorage); + assert(newRb->AllocStorage); _mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb); newRb->RefCount = 1; /* referenced by hash table */ } @@ -1248,7 +1248,7 @@ bind_renderbuffer(GLenum target, GLuint renderbuffer, bool allow_user_names) newRb = NULL; } - ASSERT(newRb != &DummyRenderbuffer); + assert(newRb != &DummyRenderbuffer); _mesa_reference_renderbuffer(&ctx->CurrentRenderbuffer, newRb); } @@ -1339,7 +1339,7 @@ _mesa_DeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) /* check if deleting currently bound renderbuffer object */ if (rb == ctx->CurrentRenderbuffer) { /* bind default */ - ASSERT(rb->RefCount >= 2); + assert(rb->RefCount >= 2); _mesa_BindRenderbuffer(GL_RENDERBUFFER_EXT, 0); } @@ -1838,7 +1838,7 @@ renderbuffer_storage(GLenum target, GLenum internalFormat, rb->NumSamples = samples; /* Now allocate the storage */ - ASSERT(rb->AllocStorage); + assert(rb->AllocStorage); if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) { /* No error - check/set fields now */ /* If rb->Format == MESA_FORMAT_NONE, the format is unsupported. */ @@ -2036,7 +2036,7 @@ static void check_begin_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb) { GLuint i; - ASSERT(ctx->Driver.RenderTexture); + assert(ctx->Driver.RenderTexture); if (_mesa_is_winsys_fbo(fb)) return; /* can't render to texture with winsys framebuffers */ @@ -2134,8 +2134,8 @@ bind_framebuffer(GLenum target, GLuint framebuffer, bool allow_user_names) newReadFb = ctx->WinSysReadBuffer; } - ASSERT(newDrawFb); - ASSERT(newDrawFb != &DummyFramebuffer); + assert(newDrawFb); + assert(newDrawFb != &DummyFramebuffer); /* save pointers to current/old framebuffers */ oldDrawFb = ctx->DrawBuffer; @@ -2227,17 +2227,17 @@ _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers) struct gl_framebuffer *fb; fb = _mesa_lookup_framebuffer(ctx, framebuffers[i]); if (fb) { - ASSERT(fb == &DummyFramebuffer || fb->Name == framebuffers[i]); + assert(fb == &DummyFramebuffer || fb->Name == framebuffers[i]); /* check if deleting currently bound framebuffer object */ if (fb == ctx->DrawBuffer) { /* bind default */ - ASSERT(fb->RefCount >= 2); + assert(fb->RefCount >= 2); _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); } if (fb == ctx->ReadBuffer) { /* bind default */ - ASSERT(fb->RefCount >= 2); + assert(fb->RefCount >= 2); _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, 0); } diff --git a/mesalib/src/mesa/main/ffvertex_prog.c b/mesalib/src/mesa/main/ffvertex_prog.c index c51c20ddf..395b00e15 100644 --- a/mesalib/src/mesa/main/ffvertex_prog.c +++ b/mesalib/src/mesa/main/ffvertex_prog.c @@ -479,7 +479,7 @@ static struct ureg register_const4f( struct tnl_program *p, values[3].f = s3; idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4, &swizzle ); - ASSERT(swizzle == SWIZZLE_NOOP); + assert(swizzle == SWIZZLE_NOOP); return make_ureg(PROGRAM_CONSTANT, idx); } @@ -530,7 +530,7 @@ static void emit_arg( struct prog_src_register *src, src->Abs = 0; src->RelAddr = 0; /* Check that bitfield sizes aren't exceeded */ - ASSERT(src->Index == reg.idx); + assert(src->Index == reg.idx); } @@ -544,7 +544,7 @@ static void emit_dst( struct prog_dst_register *dst, dst->CondMask = COND_TR; /* always pass cond test */ dst->CondSwizzle = SWIZZLE_NOOP; /* Check that bitfield sizes aren't exceeded */ - ASSERT(dst->Index == reg.idx); + assert(dst->Index == reg.idx); } diff --git a/mesalib/src/mesa/main/format_unpack.py b/mesalib/src/mesa/main/format_unpack.py index 2276a1063..53bdf641d 100644 --- a/mesalib/src/mesa/main/format_unpack.py +++ b/mesalib/src/mesa/main/format_unpack.py @@ -463,8 +463,8 @@ unpack_float_z_X8_UINT_Z24_UNORM(GLuint n, const void *src, GLfloat *dst) GLuint i; for (i = 0; i < n; i++) { dst[i] = (GLfloat) ((s[i] >> 8) * scale); - ASSERT(dst[i] >= 0.0F); - ASSERT(dst[i] <= 1.0F); + assert(dst[i] >= 0.0F); + assert(dst[i] <= 1.0F); } } @@ -477,8 +477,8 @@ unpack_float_z_Z24_UNORM_X8_UINT(GLuint n, const void *src, GLfloat *dst) GLuint i; for (i = 0; i < n; i++) { dst[i] = (GLfloat) ((s[i] & 0x00ffffff) * scale); - ASSERT(dst[i] >= 0.0F); - ASSERT(dst[i] <= 1.0F); + assert(dst[i] >= 0.0F); + assert(dst[i] <= 1.0F); } } diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c index 958d6f245..422c9dc46 100644 --- a/mesalib/src/mesa/main/formats.c +++ b/mesalib/src/mesa/main/formats.c @@ -75,7 +75,7 @@ struct gl_format_info mesa_array_format ArrayFormat; }; -#include "format_info.c" +#include "format_info.h" static const struct gl_format_info * _mesa_get_format_info(mesa_format format) @@ -107,8 +107,8 @@ GLint _mesa_get_format_bytes(mesa_format format) { const struct gl_format_info *info = _mesa_get_format_info(format); - ASSERT(info->BytesPerBlock); - ASSERT(info->BytesPerBlock <= MAX_PIXEL_BYTES || + assert(info->BytesPerBlock); + assert(info->BytesPerBlock <= MAX_PIXEL_BYTES || _mesa_is_format_compressed(format)); return info->BytesPerBlock; } @@ -887,7 +887,7 @@ _mesa_test_formats(void) { GLuint i; - STATIC_ASSERT(Elements(format_info) == MESA_FORMAT_COUNT); + STATIC_ASSERT(ARRAY_SIZE(format_info) == MESA_FORMAT_COUNT); for (i = 0; i < MESA_FORMAT_COUNT; i++) { const struct gl_format_info *info = _mesa_get_format_info(i); diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c index dc0386d23..4f7736a64 100644 --- a/mesalib/src/mesa/main/framebuffer.c +++ b/mesalib/src/mesa/main/framebuffer.c @@ -29,7 +29,7 @@ * ushorts, uints, etc. */ - +#include <stdio.h> #include "glheader.h" #include "imports.h" #include "blend.h" @@ -223,8 +223,8 @@ _mesa_free_framebuffer_data(struct gl_framebuffer *fb) if (att->Texture) { _mesa_reference_texobj(&att->Texture, NULL); } - ASSERT(!att->Renderbuffer); - ASSERT(!att->Texture); + assert(!att->Renderbuffer); + assert(!att->Texture); att->Type = GL_NONE; } } @@ -245,7 +245,7 @@ _mesa_reference_framebuffer_(struct gl_framebuffer **ptr, struct gl_framebuffer *oldFb = *ptr; mtx_lock(&oldFb->Mutex); - ASSERT(oldFb->RefCount > 0); + assert(oldFb->RefCount > 0); oldFb->RefCount--; deleteFlag = (oldFb->RefCount == 0); mtx_unlock(&oldFb->Mutex); @@ -296,8 +296,8 @@ _mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, /* only resize if size is changing */ if (rb->Width != width || rb->Height != height) { if (rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) { - ASSERT(rb->Width == width); - ASSERT(rb->Height == height); + assert(rb->Width == width); + assert(rb->Height == height); } else { _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer"); @@ -402,8 +402,8 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx, } } - ASSERT(bbox[0] <= bbox[1]); - ASSERT(bbox[2] <= bbox[3]); + assert(bbox[0] <= bbox[1]); + assert(bbox[2] <= bbox[3]); } /** @@ -621,8 +621,8 @@ update_color_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) fb->_ColorReadBuffer = NULL; /* legal! */ } else { - ASSERT(fb->_ColorReadBufferIndex >= 0); - ASSERT(fb->_ColorReadBufferIndex < BUFFER_COUNT); + assert(fb->_ColorReadBufferIndex >= 0); + assert(fb->_ColorReadBufferIndex < BUFFER_COUNT); fb->_ColorReadBuffer = fb->Attachment[fb->_ColorReadBufferIndex].Renderbuffer; } @@ -756,7 +756,7 @@ renderbuffer_exists(struct gl_context *ctx, if (!readBuf) { return GL_FALSE; } - ASSERT(_mesa_get_format_bits(readBuf->Format, GL_RED_BITS) > 0 || + assert(_mesa_get_format_bits(readBuf->Format, GL_RED_BITS) > 0 || _mesa_get_format_bits(readBuf->Format, GL_ALPHA_BITS) > 0 || _mesa_get_format_bits(readBuf->Format, GL_TEXTURE_LUMINANCE_SIZE) > 0 || _mesa_get_format_bits(readBuf->Format, GL_TEXTURE_INTENSITY_SIZE) > 0 || diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c index 3f9d74516..a881bc589 100644 --- a/mesalib/src/mesa/main/get.c +++ b/mesalib/src/mesa/main/get.c @@ -497,12 +497,12 @@ print_table_stats(int api) }; const char *api_name; - api_name = api < Elements(api_names) ? api_names[api] : "N/A"; + api_name = api < ARRAY_SIZE(api_names) ? api_names[api] : "N/A"; count = 0; - mask = Elements(table(api)) - 1; + mask = ARRAY_SIZE(table(api)) - 1; memset(collisions, 0, sizeof collisions); - for (i = 0; i < Elements(table(api)); i++) { + for (i = 0; i < ARRAY_SIZE(table(api)); i++) { if (!table(api)[i]) continue; count++; @@ -523,8 +523,8 @@ print_table_stats(int api) } printf("number of enums for %s: %d (total %ld)\n", - api_name, count, Elements(values)); - for (i = 0; i < Elements(collisions) - 1; i++) + api_name, count, ARRAY_SIZE(values)); + for (i = 0; i < ARRAY_SIZE(collisions) - 1; i++) if (collisions[i] > 0) printf(" %d enums with %d %scollisions\n", collisions[i], i, i == 10 ? "or more " : ""); @@ -758,7 +758,7 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu case GL_COMPRESSED_TEXTURE_FORMATS_ARB: v->value_int_n.n = _mesa_get_compressed_formats(ctx, v->value_int_n.ints); - ASSERT(v->value_int_n.n <= (int) ARRAY_SIZE(v->value_int_n.ints)); + assert(v->value_int_n.n <= (int) ARRAY_SIZE(v->value_int_n.ints)); break; case GL_MAX_VARYING_FLOATS_ARB: @@ -1195,11 +1195,11 @@ find_value(const char *func, GLenum pname, void **p, union value *v) * value since it's compatible with GLES2 its entry in table_set[] is at the * end. */ - STATIC_ASSERT(Elements(table_set) == API_OPENGL_LAST + 2); + STATIC_ASSERT(ARRAY_SIZE(table_set) == API_OPENGL_LAST + 2); if (_mesa_is_gles3(ctx)) { api = API_OPENGL_LAST + 1; } - mask = Elements(table(api)) - 1; + mask = ARRAY_SIZE(table(api)) - 1; hash = (pname * prime_factor); while (1) { int idx = table(api)[hash & mask]; diff --git a/mesalib/src/mesa/main/hash.c b/mesalib/src/mesa/main/hash.c index 1a152ec34..d04cccd94 100644 --- a/mesalib/src/mesa/main/hash.c +++ b/mesalib/src/mesa/main/hash.c @@ -371,8 +371,8 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table, { struct hash_entry *entry; - ASSERT(table); - ASSERT(callback); + assert(table); + assert(callback); mtx_lock(&table->Mutex); table->InDeleteAll = GL_TRUE; hash_table_foreach(table->ht, entry) { @@ -401,7 +401,7 @@ _mesa_HashClone(const struct _mesa_HashTable *table) struct hash_entry *entry; struct _mesa_HashTable *clonetable; - ASSERT(table); + assert(table); mtx_lock(&table2->Mutex); clonetable = _mesa_NewHashTable(); @@ -437,8 +437,8 @@ _mesa_HashWalk(const struct _mesa_HashTable *table, struct _mesa_HashTable *table2 = (struct _mesa_HashTable *) table; struct hash_entry *entry; - ASSERT(table); - ASSERT(callback); + assert(table); + assert(callback); mtx_lock(&table2->WalkMutex); hash_table_foreach(table->ht, entry) { callback((uintptr_t)entry->key, entry->data, userData); diff --git a/mesalib/src/mesa/main/histogram.h b/mesalib/src/mesa/main/histogram.h index 1d145a03b..47a2bf0e5 100644 --- a/mesalib/src/mesa/main/histogram.h +++ b/mesalib/src/mesa/main/histogram.h @@ -36,9 +36,8 @@ #ifndef HISTOGRAM_H #define HISTOGRAM_H -#include "compiler.h" +#include "glheader.h" -struct _glapi_table; void GLAPIENTRY _mesa_GetnMinmaxARB(GLenum target, GLboolean reset, GLenum format, diff --git a/mesalib/src/mesa/main/image.c b/mesalib/src/mesa/main/image.c index e97b006e0..711a19062 100644 --- a/mesalib/src/mesa/main/image.c +++ b/mesalib/src/mesa/main/image.c @@ -118,7 +118,7 @@ _mesa_image_offset( GLuint dimensions, GLint skipimages; /* for 3-D volume images */ GLintptr offset; - ASSERT(dimensions >= 1 && dimensions <= 3); + assert(dimensions >= 1 && dimensions <= 3); alignment = packing->Alignment; if (packing->RowLength > 0) { @@ -174,7 +174,7 @@ _mesa_image_offset( GLuint dimensions, if (remainder > 0) bytes_per_row += (alignment - remainder); - ASSERT(bytes_per_row % alignment == 0); + assert(bytes_per_row % alignment == 0); bytes_per_image = bytes_per_row * rows_per_image; @@ -288,7 +288,7 @@ _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, { GLint bytesPerRow, remainder; - ASSERT(packing); + assert(packing); if (type == GL_BITMAP) { if (packing->RowLength == 0) { @@ -336,7 +336,7 @@ _mesa_image_image_stride( const struct gl_pixelstore_attrib *packing, { GLint bytesPerRow, bytesPerImage, remainder; - ASSERT(packing); + assert(packing); if (type == GL_BITMAP) { if (packing->RowLength == 0) { @@ -476,7 +476,7 @@ _mesa_convert_colors(GLenum srcType, const GLvoid *src, if (!tempBuffer) return; - ASSERT(srcType != dstType); + assert(srcType != dstType); switch (srcType) { case GL_UNSIGNED_BYTE: @@ -499,7 +499,7 @@ _mesa_convert_colors(GLenum srcType, const GLvoid *src, const GLubyte (*src1)[4] = (const GLubyte (*)[4]) src; GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst); GLuint i; - ASSERT(dstType == GL_FLOAT); + assert(dstType == GL_FLOAT); for (i = 0; i < count; i++) { if (!mask || mask[i]) { dst4[i][RCOMP] = UBYTE_TO_FLOAT(src1[i][RCOMP]); @@ -532,7 +532,7 @@ _mesa_convert_colors(GLenum srcType, const GLvoid *src, const GLushort (*src2)[4] = (const GLushort (*)[4]) src; GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst); GLuint i; - ASSERT(dstType == GL_FLOAT); + assert(dstType == GL_FLOAT); for (i = 0; i < count; i++) { if (!mask || mask[i]) { dst4[i][RCOMP] = USHORT_TO_FLOAT(src2[i][RCOMP]); @@ -561,7 +561,7 @@ _mesa_convert_colors(GLenum srcType, const GLvoid *src, const GLfloat (*src4)[4] = (const GLfloat (*)[4]) src; GLushort (*dst2)[4] = (GLushort (*)[4]) (useTemp ? tempBuffer : dst); GLuint i; - ASSERT(dstType == GL_UNSIGNED_SHORT); + assert(dstType == GL_UNSIGNED_SHORT); for (i = 0; i < count; i++) { if (!mask || mask[i]) { UNCLAMPED_FLOAT_TO_USHORT(dst2[i][RCOMP], src4[i][RCOMP]); @@ -607,8 +607,8 @@ _mesa_clip_drawpixels(const struct gl_context *ctx, unpack->RowLength = *width; } - ASSERT(ctx->Pixel.ZoomX == 1.0F); - ASSERT(ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F); + assert(ctx->Pixel.ZoomX == 1.0F); + assert(ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F); /* left clipping */ if (*destX < buffer->_Xmin) { @@ -792,20 +792,20 @@ clip_right_or_top(GLint *srcX0, GLint *srcX1, if (*dstX1 > maxValue) { /* X1 outside right edge */ - ASSERT(*dstX0 < maxValue); /* X0 should be inside right edge */ + assert(*dstX0 < maxValue); /* X0 should be inside right edge */ t = (GLfloat) (maxValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0); /* chop off [t, 1] part */ - ASSERT(t >= 0.0 && t <= 1.0); + assert(t >= 0.0 && t <= 1.0); *dstX1 = maxValue; bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; *srcX1 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias); } else if (*dstX0 > maxValue) { /* X0 outside right edge */ - ASSERT(*dstX1 < maxValue); /* X1 should be inside right edge */ + assert(*dstX1 < maxValue); /* X1 should be inside right edge */ t = (GLfloat) (maxValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1); /* chop off [t, 1] part */ - ASSERT(t >= 0.0 && t <= 1.0); + assert(t >= 0.0 && t <= 1.0); *dstX0 = maxValue; bias = (*srcX0 < *srcX1) ? -0.5F : 0.5F; *srcX0 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias); @@ -825,20 +825,20 @@ clip_left_or_bottom(GLint *srcX0, GLint *srcX1, if (*dstX0 < minValue) { /* X0 outside left edge */ - ASSERT(*dstX1 > minValue); /* X1 should be inside left edge */ + assert(*dstX1 > minValue); /* X1 should be inside left edge */ t = (GLfloat) (minValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0); /* chop off [0, t] part */ - ASSERT(t >= 0.0 && t <= 1.0); + assert(t >= 0.0 && t <= 1.0); *dstX0 = minValue; bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F; *srcX0 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias); } else if (*dstX1 < minValue) { /* X1 outside left edge */ - ASSERT(*dstX0 > minValue); /* X0 should be inside left edge */ + assert(*dstX0 > minValue); /* X0 should be inside left edge */ t = (GLfloat) (minValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1); /* chop off [0, t] part */ - ASSERT(t >= 0.0 && t <= 1.0); + assert(t >= 0.0 && t <= 1.0); *dstX1 = minValue; bias = (*srcX0 < *srcX1) ? -0.5F : 0.5F; *srcX1 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias); @@ -936,25 +936,25 @@ _mesa_clip_blit(struct gl_context *ctx, *srcY0, *srcY1, *dstY0, *dstY1); */ - ASSERT(*dstX0 >= dstXmin); - ASSERT(*dstX0 <= dstXmax); - ASSERT(*dstX1 >= dstXmin); - ASSERT(*dstX1 <= dstXmax); - - ASSERT(*dstY0 >= dstYmin); - ASSERT(*dstY0 <= dstYmax); - ASSERT(*dstY1 >= dstYmin); - ASSERT(*dstY1 <= dstYmax); - - ASSERT(*srcX0 >= srcXmin); - ASSERT(*srcX0 <= srcXmax); - ASSERT(*srcX1 >= srcXmin); - ASSERT(*srcX1 <= srcXmax); - - ASSERT(*srcY0 >= srcYmin); - ASSERT(*srcY0 <= srcYmax); - ASSERT(*srcY1 >= srcYmin); - ASSERT(*srcY1 <= srcYmax); + assert(*dstX0 >= dstXmin); + assert(*dstX0 <= dstXmax); + assert(*dstX1 >= dstXmin); + assert(*dstX1 <= dstXmax); + + assert(*dstY0 >= dstYmin); + assert(*dstY0 <= dstYmax); + assert(*dstY1 >= dstYmin); + assert(*dstY1 <= dstYmax); + + assert(*srcX0 >= srcXmin); + assert(*srcX0 <= srcXmax); + assert(*srcX1 >= srcXmin); + assert(*srcX1 <= srcXmax); + + assert(*srcY0 >= srcYmin); + assert(*srcY0 <= srcYmax); + assert(*srcY1 >= srcYmin); + assert(*srcY1 <= srcYmax); return GL_TRUE; } diff --git a/mesalib/src/mesa/main/imports.c b/mesalib/src/mesa/main/imports.c index 4f5a2d11f..a7ffe2296 100644 --- a/mesalib/src/mesa/main/imports.c +++ b/mesalib/src/mesa/main/imports.c @@ -42,8 +42,9 @@ * OTHER DEALINGS IN THE SOFTWARE. */ - - +#include <stdio.h> +#include <stdarg.h> +#include "c99_math.h" #include "imports.h" #include "context.h" #include "mtypes.h" @@ -92,7 +93,7 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment) #else uintptr_t ptr, buf; - ASSERT( alignment > 0 ); + assert( alignment > 0 ); ptr = (uintptr_t)malloc(bytes + alignment + sizeof(void *)); if (!ptr) @@ -141,7 +142,7 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment) #else uintptr_t ptr, buf; - ASSERT( alignment > 0 ); + assert( alignment > 0 ); ptr = (uintptr_t)calloc(1, bytes + alignment + sizeof(void *)); if (!ptr) diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h index 0fcba4fb9..792100061 100644 --- a/mesalib/src/mesa/main/imports.h +++ b/mesalib/src/mesa/main/imports.h @@ -36,6 +36,9 @@ #define IMPORTS_H +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> #include "compiler.h" #include "glheader.h" #include "errors.h" @@ -79,62 +82,8 @@ typedef union { GLfloat f; GLint i; GLuint u; } fi_type; -/********************************************************************** - * Math macros - */ - -#define MAX_GLUSHORT 0xffff -#define MAX_GLUINT 0xffffffff - -/* Degrees to radians conversion: */ -#define DEG2RAD (M_PI/180.0) - - -/** - * \name Work-arounds for platforms that lack C99 math functions - */ -/*@{*/ -#if (!defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE < 600)) && !defined(_ISOC99_SOURCE) \ - && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) \ - && (!defined(_MSC_VER) || (_MSC_VER < 1400)) -#define acosf(f) ((float) acos(f)) -#define asinf(f) ((float) asin(f)) -#define atan2f(x,y) ((float) atan2(x,y)) -#define atanf(f) ((float) atan(f)) -#define ceilf(f) ((float) ceil(f)) -#define cosf(f) ((float) cos(f)) -#define coshf(f) ((float) cosh(f)) -#define expf(f) ((float) exp(f)) -#define exp2f(f) ((float) exp2(f)) -#define floorf(f) ((float) floor(f)) -#define logf(f) ((float) log(f)) - -#ifdef ANDROID -#define log2f(f) (logf(f) * (float) (1.0 / M_LN2)) -#else -#define log2f(f) ((float) log2(f)) -#endif - -#define powf(x,y) ((float) pow(x,y)) -#define sinf(f) ((float) sin(f)) -#define sinhf(f) ((float) sinh(f)) -#define sqrtf(f) ((float) sqrt(f)) -#define tanf(f) ((float) tan(f)) -#define tanhf(f) ((float) tanh(f)) -#define acoshf(f) ((float) acosh(f)) -#define asinhf(f) ((float) asinh(f)) -#define atanhf(f) ((float) atanh(f)) -#endif - #if defined(_MSC_VER) #if _MSC_VER < 1800 /* Not req'd on VS2013 and above */ -static inline float truncf(float x) { return x < 0.0f ? ceilf(x) : floorf(x); } -static inline float exp2f(float x) { return powf(2.0f, x); } -static inline float log2f(float x) { return logf(x) * 1.442695041f; } -static inline float asinhf(float x) { return logf(x + sqrtf(x * x + 1.0f)); } -static inline float acoshf(float x) { return logf(x + sqrtf(x * x - 1.0f)); } -static inline float atanhf(float x) { return (logf(1.0f + x) - logf(1.0f - x)) / 2.0f; } -static inline int isblank(int ch) { return ch == ' ' || ch == '\t'; } #define strtoll(p, e, b) _strtoi64(p, e, b) #endif /* _MSC_VER < 1800 */ #define strcasecmp(s1, s2) _stricmp(s1, s2) @@ -142,23 +91,6 @@ static inline int isblank(int ch) { return ch == ' ' || ch == '\t'; } /*@}*/ -/* - * signbit() is a macro on Linux. Not available on Windows. - */ -#ifndef signbit -#define signbit(x) ((x) < 0.0f) -#endif - - -/** single-precision inverse square root */ -static inline float -INV_SQRTF(float x) -{ - /* XXX we could try Quake's fast inverse square root function here */ - return 1.0F / sqrtf(x); -} - - /*** *** LOG2: Log base 2 of float ***/ @@ -189,6 +121,14 @@ static inline GLfloat LOG2(GLfloat x) +/** + * finite macro. + */ +#if defined(_MSC_VER) +# define finite _finite +#endif + + /*** *** IS_INF_OR_NAN: test if float is infinite or NaN ***/ @@ -203,35 +143,6 @@ static inline GLfloat LOG2(GLfloat x) #endif -/*** - *** CEILF: ceiling of float - *** FLOORF: floor of float - *** FABSF: absolute value of float - *** LOGF: the natural logarithm (base e) of the value - *** EXPF: raise e to the value - *** LDEXPF: multiply value by an integral power of two - *** FREXPF: extract mantissa and exponent from value - ***/ -#if defined(__gnu_linux__) -/* C99 functions */ -#define CEILF(x) ceilf(x) -#define FLOORF(x) floorf(x) -#define FABSF(x) fabsf(x) -#define LOGF(x) logf(x) -#define EXPF(x) expf(x) -#define LDEXPF(x,y) ldexpf(x,y) -#define FREXPF(x,y) frexpf(x,y) -#else -#define CEILF(x) ((GLfloat) ceil(x)) -#define FLOORF(x) ((GLfloat) floor(x)) -#define FABSF(x) ((GLfloat) fabs(x)) -#define LOGF(x) ((GLfloat) log(x)) -#define EXPF(x) ((GLfloat) exp(x)) -#define LDEXPF(x,y) ((GLfloat) ldexp(x,y)) -#define FREXPF(x,y) ((GLfloat) frexp(x,y)) -#endif - - /** * Convert float to int by rounding to nearest integer, away from zero. */ diff --git a/mesalib/src/mesa/main/light.c b/mesalib/src/mesa/main/light.c index e483b826e..4021dbef9 100644 --- a/mesalib/src/mesa/main/light.c +++ b/mesalib/src/mesa/main/light.c @@ -24,6 +24,7 @@ */ +#include "c99_math.h" #include "glheader.h" #include "imports.h" #include "context.h" @@ -101,7 +102,7 @@ _mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *pa { struct gl_light *light; - ASSERT(lnum < MAX_LIGHTS); + assert(lnum < MAX_LIGHTS); light = &ctx->Light.Light[lnum]; switch (pname) { @@ -142,20 +143,20 @@ _mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *pa COPY_3V(light->SpotDirection, params); break; case GL_SPOT_EXPONENT: - ASSERT(params[0] >= 0.0); - ASSERT(params[0] <= ctx->Const.MaxSpotExponent); + assert(params[0] >= 0.0); + assert(params[0] <= ctx->Const.MaxSpotExponent); if (light->SpotExponent == params[0]) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); light->SpotExponent = params[0]; break; case GL_SPOT_CUTOFF: - ASSERT(params[0] == 180.0 || (params[0] >= 0.0 && params[0] <= 90.0)); + assert(params[0] == 180.0 || (params[0] >= 0.0 && params[0] <= 90.0)); if (light->SpotCutoff == params[0]) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); light->SpotCutoff = params[0]; - light->_CosCutoff = (GLfloat) (cos(light->SpotCutoff * DEG2RAD)); + light->_CosCutoff = (GLfloat) (cos(light->SpotCutoff * M_PI / 180.0)); if (light->_CosCutoff < 0) light->_CosCutoff = 0; if (light->SpotCutoff != 180.0F) @@ -164,21 +165,21 @@ _mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *pa light->_Flags &= ~LIGHT_SPOT; break; case GL_CONSTANT_ATTENUATION: - ASSERT(params[0] >= 0.0); + assert(params[0] >= 0.0); if (light->ConstantAttenuation == params[0]) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); light->ConstantAttenuation = params[0]; break; case GL_LINEAR_ATTENUATION: - ASSERT(params[0] >= 0.0); + assert(params[0] >= 0.0); if (light->LinearAttenuation == params[0]) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); light->LinearAttenuation = params[0]; break; case GL_QUADRATIC_ATTENUATION: - ASSERT(params[0] >= 0.0); + assert(params[0] >= 0.0); if (light->QuadraticAttenuation == params[0]) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); @@ -808,7 +809,7 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ) GLuint f; GLfloat (*mat)[4] = ctx->Light.Material.Attrib; - ASSERT(ctx->API == API_OPENGL_COMPAT); + assert(ctx->API == API_OPENGL_COMPAT); FLUSH_VERTICES(ctx, 0); /* update materials */ FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */ @@ -1025,9 +1026,9 @@ update_modelview_scale( struct gl_context *ctx ) GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10]; if (f < 1e-12) f = 1.0; if (ctx->_NeedEyeCoords) - ctx->_ModelViewInvScale = (GLfloat) INV_SQRTF(f); + ctx->_ModelViewInvScale = 1.0f / sqrtf(f); else - ctx->_ModelViewInvScale = (GLfloat) sqrtf(f); + ctx->_ModelViewInvScale = sqrtf(f); } } diff --git a/mesalib/src/mesa/main/macros.h b/mesalib/src/mesa/main/macros.h index cf1f0e9c9..2d7a6a107 100644 --- a/mesalib/src/mesa/main/macros.h +++ b/mesalib/src/mesa/main/macros.h @@ -171,25 +171,25 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256]; ub = ((GLubyte) F_TO_I((f) * 255.0F)) #endif -static inline GLfloat INT_AS_FLT(GLint i) +static fi_type UINT_AS_UNION(GLuint u) { fi_type tmp; - tmp.i = i; - return tmp.f; + tmp.u = u; + return tmp; } -static inline GLfloat UINT_AS_FLT(GLuint u) +static inline fi_type INT_AS_UNION(GLint i) { fi_type tmp; - tmp.u = u; - return tmp.f; + tmp.i = i; + return tmp; } -static inline unsigned FLT_AS_UINT(float f) +static inline fi_type FLOAT_AS_UNION(GLfloat f) { fi_type tmp; tmp.f = f; - return tmp.u; + return tmp; } /** @@ -604,24 +604,26 @@ do { \ * The default values are chosen based on \p type. */ static inline void -COPY_CLEAN_4V_TYPE_AS_FLOAT(GLfloat dst[4], int sz, const GLfloat src[4], +COPY_CLEAN_4V_TYPE_AS_UNION(fi_type dst[4], int sz, const fi_type src[4], GLenum type) { switch (type) { case GL_FLOAT: - ASSIGN_4V(dst, 0, 0, 0, 1); + ASSIGN_4V(dst, FLOAT_AS_UNION(0), FLOAT_AS_UNION(0), + FLOAT_AS_UNION(0), FLOAT_AS_UNION(1)); break; case GL_INT: - ASSIGN_4V(dst, INT_AS_FLT(0), INT_AS_FLT(0), - INT_AS_FLT(0), INT_AS_FLT(1)); + ASSIGN_4V(dst, INT_AS_UNION(0), INT_AS_UNION(0), + INT_AS_UNION(0), INT_AS_UNION(1)); break; case GL_UNSIGNED_INT: - ASSIGN_4V(dst, UINT_AS_FLT(0), UINT_AS_FLT(0), - UINT_AS_FLT(0), UINT_AS_FLT(1)); + ASSIGN_4V(dst, UINT_AS_UNION(0), UINT_AS_UNION(0), + UINT_AS_UNION(0), UINT_AS_UNION(1)); break; default: - ASSIGN_4V(dst, 0.0f, 0.0f, 0.0f, 1.0f); /* silence warnings */ - ASSERT(!"Unexpected type in COPY_CLEAN_4V_TYPE_AS_FLOAT macro"); + ASSIGN_4V(dst, FLOAT_AS_UNION(0), FLOAT_AS_UNION(0), + FLOAT_AS_UNION(0), FLOAT_AS_UNION(1)); /* silence warnings */ + assert(!"Unexpected type in COPY_CLEAN_4V_TYPE_AS_UNION macro"); } COPY_SZ_4V(dst, sz, src); } @@ -775,7 +777,7 @@ NORMALIZE_3FV(GLfloat v[3]) { GLfloat len = (GLfloat) LEN_SQUARED_3FV(v); if (len) { - len = INV_SQRTF(len); + len = 1.0f / sqrtf(len); v[0] *= len; v[1] *= len; v[2] *= len; @@ -801,10 +803,6 @@ DIFFERENT_SIGNS(GLfloat x, GLfloat y) #define ENUM_TO_DOUBLE(E) ((GLdouble)(GLint)(E)) #define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE) -/* Compute the size of an array */ -#ifndef ARRAY_SIZE -# define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif /* Stringify */ #define STRINGIFY(x) #x diff --git a/mesalib/src/mesa/main/matrix.c b/mesalib/src/mesa/main/matrix.c index 0539caa47..80c8a248c 100644 --- a/mesalib/src/mesa/main/matrix.c +++ b/mesalib/src/mesa/main/matrix.c @@ -176,7 +176,7 @@ _mesa_MatrixMode( GLenum mode ) return; } #endif - ASSERT(ctx->Texture.CurrentUnit < Elements(ctx->TextureMatrixStack)); + assert(ctx->Texture.CurrentUnit < ARRAY_SIZE(ctx->TextureMatrixStack)); ctx->CurrentStack = &ctx->TextureMatrixStack[ctx->Texture.CurrentUnit]; break; case GL_MATRIX0_ARB: @@ -697,10 +697,10 @@ void _mesa_init_matrix( struct gl_context * ctx ) _NEW_MODELVIEW); init_matrix_stack(&ctx->ProjectionMatrixStack, MAX_PROJECTION_STACK_DEPTH, _NEW_PROJECTION); - for (i = 0; i < Elements(ctx->TextureMatrixStack); i++) + for (i = 0; i < ARRAY_SIZE(ctx->TextureMatrixStack); i++) init_matrix_stack(&ctx->TextureMatrixStack[i], MAX_TEXTURE_STACK_DEPTH, _NEW_TEXTURE_MATRIX); - for (i = 0; i < Elements(ctx->ProgramMatrixStack); i++) + for (i = 0; i < ARRAY_SIZE(ctx->ProgramMatrixStack); i++) init_matrix_stack(&ctx->ProgramMatrixStack[i], MAX_PROGRAM_MATRIX_STACK_DEPTH, _NEW_TRACK_MATRIX); ctx->CurrentStack = &ctx->ModelviewMatrixStack; @@ -724,9 +724,9 @@ void _mesa_free_matrix_data( struct gl_context *ctx ) free_matrix_stack(&ctx->ModelviewMatrixStack); free_matrix_stack(&ctx->ProjectionMatrixStack); - for (i = 0; i < Elements(ctx->TextureMatrixStack); i++) + for (i = 0; i < ARRAY_SIZE(ctx->TextureMatrixStack); i++) free_matrix_stack(&ctx->TextureMatrixStack[i]); - for (i = 0; i < Elements(ctx->ProgramMatrixStack); i++) + for (i = 0; i < ARRAY_SIZE(ctx->ProgramMatrixStack); i++) free_matrix_stack(&ctx->ProgramMatrixStack[i]); /* combined Modelview*Projection matrix */ _math_matrix_dtr( &ctx->_ModelProjectMatrix ); diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c index 75a12cd16..7732d09b2 100644 --- a/mesalib/src/mesa/main/mipmap.c +++ b/mesalib/src/mesa/main/mipmap.c @@ -153,8 +153,8 @@ do_row(GLenum datatype, GLuint comps, GLint srcWidth, const GLuint k0 = (srcWidth == dstWidth) ? 0 : 1; const GLuint colStride = (srcWidth == dstWidth) ? 1 : 2; - ASSERT(comps >= 1); - ASSERT(comps <= 4); + assert(comps >= 1); + assert(comps <= 4); /* This assertion is no longer valid with non-power-of-2 textures assert(srcWidth == dstWidth || srcWidth == 2 * dstWidth); @@ -788,8 +788,8 @@ do_row_3D(GLenum datatype, GLuint comps, GLint srcWidth, const GLuint colStride = (srcWidth == dstWidth) ? 1 : 2; GLuint i, j, k; - ASSERT(comps >= 1); - ASSERT(comps <= 4); + assert(comps >= 1); + assert(comps <= 4); if ((datatype == GL_UNSIGNED_BYTE) && (comps == 4)) { DECLARE_ROW_POINTERS(GLubyte, 4); @@ -1650,7 +1650,7 @@ make_3d_mipmap(GLenum datatype, GLuint comps, GLint border, } else { /* average border pixels from adjacent src image pairs */ - ASSERT(srcDepthNB == 2 * dstDepthNB); + assert(srcDepthNB == 2 * dstDepthNB); for (img = 0; img < dstDepthNB; img++) { const GLubyte *srcA, *srcB; GLubyte *dst; @@ -1902,7 +1902,7 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target, /* get src image parameters */ srcImage = _mesa_select_tex_image(texObj, target, level); - ASSERT(srcImage); + assert(srcImage); srcWidth = srcImage->Width; srcHeight = srcImage->Height; srcDepth = srcImage->Depth; @@ -2097,7 +2097,7 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target, /* get src image parameters */ srcImage = _mesa_select_tex_image(texObj, target, level); - ASSERT(srcImage); + assert(srcImage); srcWidth = srcImage->Width; srcHeight = srcImage->Height; srcDepth = srcImage->Depth; @@ -2192,12 +2192,12 @@ _mesa_generate_mipmap(struct gl_context *ctx, GLenum target, struct gl_texture_image *srcImage; GLint maxLevel; - ASSERT(texObj); + assert(texObj); srcImage = _mesa_select_tex_image(texObj, target, texObj->BaseLevel); - ASSERT(srcImage); + assert(srcImage); maxLevel = _mesa_max_texture_levels(ctx, texObj->Target) - 1; - ASSERT(maxLevel >= 0); /* bad target */ + assert(maxLevel >= 0); /* bad target */ maxLevel = MIN2(maxLevel, texObj->MaxLevel); diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 6e9977309..efeee8bff 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -36,6 +36,7 @@ #include <stdint.h> /* uint32_t */ #include <stdbool.h> +#include "c11/threads.h" #include "main/glheader.h" #include "main/config.h" diff --git a/mesalib/src/mesa/main/multisample.c b/mesalib/src/mesa/main/multisample.c index b696de9f2..0e9207bc1 100644 --- a/mesalib/src/mesa/main/multisample.c +++ b/mesalib/src/mesa/main/multisample.c @@ -150,16 +150,17 @@ GLenum _mesa_check_sample_count(struct gl_context *ctx, GLenum target, GLenum internalFormat, GLsizei samples) { - /* Section 4.4 (Framebuffer objects) of the OpenGL 3.0 specification says: + /* Section 4.4 (Framebuffer objects), page 198 of the OpenGL ES 3.0.0 + * specification says: * * "If internalformat is a signed or unsigned integer format and samples * is greater than zero, then the error INVALID_OPERATION is generated." */ - if (_mesa_is_gles3(ctx) && _mesa_is_enum_format_integer(internalFormat)) { + if (_mesa_is_gles3(ctx) && _mesa_is_enum_format_integer(internalFormat) + && samples > 0) { return GL_INVALID_OPERATION; } - /* If ARB_internalformat_query is supported, then treat its highest * returned sample count as the absolute maximum for this format; it is * allowed to exceed MAX_SAMPLES. diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c index 2111a7604..f72360817 100644 --- a/mesalib/src/mesa/main/pack.c +++ b/mesalib/src/mesa/main/pack.c @@ -257,9 +257,9 @@ extract_uint_indexes(GLuint n, GLuint indexes[], GLenum srcFormat, GLenum srcType, const GLvoid *src, const struct gl_pixelstore_attrib *unpack ) { - ASSERT(srcFormat == GL_COLOR_INDEX || srcFormat == GL_STENCIL_INDEX); + assert(srcFormat == GL_COLOR_INDEX || srcFormat == GL_STENCIL_INDEX); - ASSERT(srcType == GL_BITMAP || + assert(srcType == GL_BITMAP || srcType == GL_UNSIGNED_BYTE || srcType == GL_BYTE || srcType == GL_UNSIGNED_SHORT || @@ -503,7 +503,7 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n, const struct gl_pixelstore_attrib *srcPacking, GLbitfield transferOps ) { - ASSERT(srcType == GL_BITMAP || + assert(srcType == GL_BITMAP || srcType == GL_UNSIGNED_BYTE || srcType == GL_BYTE || srcType == GL_UNSIGNED_SHORT || @@ -516,7 +516,7 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n, srcType == GL_FLOAT || srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - ASSERT(dstType == GL_UNSIGNED_BYTE || + assert(dstType == GL_UNSIGNED_BYTE || dstType == GL_UNSIGNED_SHORT || dstType == GL_UNSIGNED_INT || dstType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); @@ -988,7 +988,7 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n, else if (dstType == GL_UNSIGNED_SHORT) { GLushort *zValues = (GLushort *) dest; GLuint i; - ASSERT(depthMax <= 0xffff); + assert(depthMax <= 0xffff); for (i = 0; i < n; i++) { zValues[i] = (GLushort) (depthValues[i] * (GLfloat) depthMax); } @@ -1004,7 +1004,7 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n, } } else { - ASSERT(0); + assert(0); } free(depthTemp); @@ -1487,20 +1487,20 @@ _mesa_pack_luminance_from_rgba_integer(GLuint n, case GL_UNSIGNED_BYTE: { GLbyte *dst = (GLbyte *) dstAddr; dst[i] = lum32; + break; } - break; case GL_SHORT: case GL_UNSIGNED_SHORT: { GLshort *dst = (GLshort *) dstAddr; dst[i] = lum32; + break; } - break; case GL_INT: case GL_UNSIGNED_INT: { GLint *dst = (GLint *) dstAddr; dst[i] = lum32; + break; } - break; } } return; @@ -1525,21 +1525,22 @@ _mesa_pack_luminance_from_rgba_integer(GLuint n, GLbyte *dst = (GLbyte *) dstAddr; dst[2*i] = lum32; dst[2*i+1] = alpha; + break; } case GL_SHORT: case GL_UNSIGNED_SHORT: { GLshort *dst = (GLshort *) dstAddr; dst[i] = lum32; dst[2*i+1] = alpha; + break; } - break; case GL_INT: case GL_UNSIGNED_INT: { GLint *dst = (GLint *) dstAddr; dst[i] = lum32; dst[2*i+1] = alpha; + break; } - break; } } return; diff --git a/mesalib/src/mesa/main/pbo.c b/mesalib/src/mesa/main/pbo.c index a0d61a643..5c906ed74 100644 --- a/mesalib/src/mesa/main/pbo.c +++ b/mesalib/src/mesa/main/pbo.c @@ -182,7 +182,7 @@ _mesa_map_validate_pbo_source(struct gl_context *ctx, GLsizei clientMemSize, const GLvoid *ptr, const char *where) { - ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3); + assert(dimensions == 1 || dimensions == 2 || dimensions == 3); if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, format, type, clientMemSize, ptr)) { @@ -220,7 +220,7 @@ void _mesa_unmap_pbo_source(struct gl_context *ctx, const struct gl_pixelstore_attrib *unpack) { - ASSERT(unpack != &ctx->Pack); /* catch pack/unpack mismatch */ + assert(unpack != &ctx->Pack); /* catch pack/unpack mismatch */ if (_mesa_is_bufferobj(unpack->BufferObj)) { ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL); } @@ -279,7 +279,7 @@ _mesa_map_validate_pbo_dest(struct gl_context *ctx, GLenum format, GLenum type, GLsizei clientMemSize, GLvoid *ptr, const char *where) { - ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3); + assert(dimensions == 1 || dimensions == 2 || dimensions == 3); if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, format, type, clientMemSize, ptr)) { @@ -317,7 +317,7 @@ void _mesa_unmap_pbo_dest(struct gl_context *ctx, const struct gl_pixelstore_attrib *pack) { - ASSERT(pack != &ctx->Unpack); /* catch pack/unpack mismatch */ + assert(pack != &ctx->Unpack); /* catch pack/unpack mismatch */ if (_mesa_is_bufferobj(pack->BufferObj)) { ctx->Driver.UnmapBuffer(ctx, pack->BufferObj, MAP_INTERNAL); } diff --git a/mesalib/src/mesa/main/pipelineobj.c b/mesalib/src/mesa/main/pipelineobj.c index b713d956f..fb241af1e 100644 --- a/mesalib/src/mesa/main/pipelineobj.c +++ b/mesalib/src/mesa/main/pipelineobj.c @@ -187,7 +187,7 @@ _mesa_reference_pipeline_object_(struct gl_context *ctx, struct gl_pipeline_object *oldObj = *ptr; mtx_lock(&oldObj->Mutex); - ASSERT(oldObj->RefCount > 0); + assert(oldObj->RefCount > 0); oldObj->RefCount--; deleteFlag = (oldObj->RefCount == 0); mtx_unlock(&oldObj->Mutex); @@ -198,7 +198,7 @@ _mesa_reference_pipeline_object_(struct gl_context *ctx, *ptr = NULL; } - ASSERT(!*ptr); + assert(!*ptr); if (obj) { /* reference new pipeline object */ @@ -471,7 +471,7 @@ _mesa_DeleteProgramPipelines(GLsizei n, const GLuint *pipelines) lookup_pipeline_object(ctx, pipelines[i]); if (obj) { - ASSERT(obj->Name == pipelines[i]); + assert(obj->Name == pipelines[i]); /* If the pipeline object is currently bound, the spec says "If an * object that is currently bound is deleted, the binding for that diff --git a/mesalib/src/mesa/main/pixel.h b/mesalib/src/mesa/main/pixel.h index c12ef97b8..fd1782e1b 100644 --- a/mesalib/src/mesa/main/pixel.h +++ b/mesalib/src/mesa/main/pixel.h @@ -33,10 +33,8 @@ #define PIXEL_H -#include "compiler.h" #include "glheader.h" -struct _glapi_table; struct gl_context; diff --git a/mesalib/src/mesa/main/points.c b/mesalib/src/mesa/main/points.c index de26bf961..5ad1f38f3 100644 --- a/mesalib/src/mesa/main/points.c +++ b/mesalib/src/mesa/main/points.c @@ -103,7 +103,7 @@ _mesa_PointParameterfv( GLenum pname, const GLfloat *params) * If point parameters aren't supported, then this function shouldn't even * exist. */ - ASSERT(!(ctx->Extensions.ARB_point_sprite + assert(!(ctx->Extensions.ARB_point_sprite || ctx->Extensions.NV_point_sprite) || ctx->Extensions.EXT_point_parameters); @@ -253,7 +253,7 @@ _mesa_init_point(struct gl_context *ctx) ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */ ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */ - for (i = 0; i < Elements(ctx->Point.CoordReplace); i++) { + for (i = 0; i < ARRAY_SIZE(ctx->Point.CoordReplace); i++) { ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB/NV_point_sprite */ } } diff --git a/mesalib/src/mesa/main/queryobj.c b/mesalib/src/mesa/main/queryobj.c index 1b19afe4b..0842b540d 100644 --- a/mesalib/src/mesa/main/queryobj.c +++ b/mesalib/src/mesa/main/queryobj.c @@ -146,12 +146,13 @@ static struct gl_query_object ** get_pipe_stats_binding_point(struct gl_context *ctx, GLenum target) { + const int which = target - GL_VERTICES_SUBMITTED_ARB; + assert(which < MAX_PIPELINE_STATISTICS); + if (!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_pipeline_statistics_query) return NULL; - const int which = target - GL_VERTICES_SUBMITTED_ARB; - assert(which < MAX_PIPELINE_STATISTICS); return &ctx->Query.pipeline_stats[which]; } @@ -405,6 +406,22 @@ _mesa_BeginQueryIndexed(GLenum target, GLuint index, GLuint id) "glBeginQuery{Indexed}(query already active)"); return; } + + /* Section 2.14 Asynchronous Queries, page 84 of the OpenGL ES 3.0.4 + * spec states: + * + * "BeginQuery generates an INVALID_OPERATION error if any of the + * following conditions hold: [...] id is the name of an + * existing query object whose type does not match target; [...] + * + * Similar wording exists in the OpenGL 4.5 spec, section 4.2. QUERY + * OBJECTS AND ASYNCHRONOUS QUERIES, page 43. + */ + if (q->EverBound && q->Target != target) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBeginQuery{Indexed}(target mismatch)"); + return; + } } q->Target = target; @@ -666,7 +683,7 @@ _mesa_GetQueryObjectiv(GLuint id, GLenum pname, GLint *params) if (id) q = _mesa_lookup_query_object(ctx, id); - if (!q || q->Active) { + if (!q || q->Active || !q->EverBound) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryObjectivARB(id=%d is invalid or active)", id); return; @@ -717,7 +734,7 @@ _mesa_GetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) if (id) q = _mesa_lookup_query_object(ctx, id); - if (!q || q->Active) { + if (!q || q->Active || !q->EverBound) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryObjectuivARB(id=%d is invalid or active)", id); return; @@ -771,7 +788,7 @@ _mesa_GetQueryObjecti64v(GLuint id, GLenum pname, GLint64EXT *params) if (id) q = _mesa_lookup_query_object(ctx, id); - if (!q || q->Active) { + if (!q || q->Active || !q->EverBound) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryObjectui64vARB(id=%d is invalid or active)", id); return; @@ -811,7 +828,7 @@ _mesa_GetQueryObjectui64v(GLuint id, GLenum pname, GLuint64EXT *params) if (id) q = _mesa_lookup_query_object(ctx, id); - if (!q || q->Active) { + if (!q || q->Active || !q->EverBound) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryObjectuui64vARB(id=%d is invalid or active)", id); return; diff --git a/mesalib/src/mesa/main/rastpos.c b/mesalib/src/mesa/main/rastpos.c index 2027a9bd0..54b2125a8 100644 --- a/mesalib/src/mesa/main/rastpos.c +++ b/mesalib/src/mesa/main/rastpos.c @@ -266,7 +266,7 @@ window_pos3f(GLfloat x, GLfloat y, GLfloat z) { GLuint texSet; for (texSet = 0; texSet < ctx->Const.MaxTextureCoordUnits; texSet++) { - assert(texSet < Elements(ctx->Current.RasterTexCoords)); + assert(texSet < ARRAY_SIZE(ctx->Current.RasterTexCoords)); COPY_4FV( ctx->Current.RasterTexCoords[texSet], ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] ); } @@ -496,7 +496,7 @@ void _mesa_init_rastpos( struct gl_context * ctx ) ctx->Current.RasterDistance = 0.0; ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 ); ASSIGN_4V( ctx->Current.RasterSecondaryColor, 0.0, 0.0, 0.0, 1.0 ); - for (i = 0; i < Elements(ctx->Current.RasterTexCoords); i++) + for (i = 0; i < ARRAY_SIZE(ctx->Current.RasterTexCoords); i++) ASSIGN_4V( ctx->Current.RasterTexCoords[i], 0.0, 0.0, 0.0, 1.0 ); ctx->Current.RasterPosValid = GL_TRUE; } diff --git a/mesalib/src/mesa/main/rastpos.h b/mesalib/src/mesa/main/rastpos.h index 2d36936de..dc28c68d4 100644 --- a/mesalib/src/mesa/main/rastpos.h +++ b/mesalib/src/mesa/main/rastpos.h @@ -32,7 +32,8 @@ #define RASTPOS_H -#include "compiler.h" +#include "glheader.h" + struct _glapi_table; struct gl_context; diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c index ca4b9431b..ed0104c9e 100644 --- a/mesalib/src/mesa/main/readpix.c +++ b/mesalib/src/mesa/main/readpix.c @@ -127,7 +127,7 @@ _mesa_readpixels_needs_slow_path(const struct gl_context *ctx, GLenum format, _mesa_get_read_renderbuffer_for_format(ctx, format); GLenum srcType; - ASSERT(rb); + assert(rb); /* There are different rules depending on the base format. */ switch (format) { @@ -180,7 +180,7 @@ readpixels_can_use_memcpy(const struct gl_context *ctx, GLenum format, GLenum ty struct gl_renderbuffer *rb = _mesa_get_read_renderbuffer_for_format(ctx, format); - ASSERT(rb); + assert(rb); if (_mesa_readpixels_needs_slow_path(ctx, format, type, GL_FALSE)) { return GL_FALSE; @@ -313,10 +313,10 @@ read_depth_pixels( struct gl_context *ctx, return; /* clipping should have been done already */ - ASSERT(x >= 0); - ASSERT(y >= 0); - ASSERT(x + width <= (GLint) rb->Width); - ASSERT(y + height <= (GLint) rb->Height); + assert(x >= 0); + assert(y >= 0); + assert(x + width <= (GLint) rb->Width); + assert(y + height <= (GLint) rb->Height); if (type == GL_UNSIGNED_INT && read_uint_depth_pixels(ctx, x, y, width, height, type, pixels, packing)) { @@ -594,6 +594,7 @@ read_rgba_pixels( struct gl_context *ctx, _mesa_format_convert(dst, dst_format, dst_stride, luminance, luminance_format, luminance_stride, width, height, NULL); + free(luminance); } else { _mesa_pack_luminance_from_rgba_integer(width * height, src, !src_is_uint, dst, format, type); diff --git a/mesalib/src/mesa/main/remap.c b/mesalib/src/mesa/main/remap.c index 4a881865a..5a9538772 100644 --- a/mesalib/src/mesa/main/remap.c +++ b/mesalib/src/mesa/main/remap.c @@ -60,7 +60,7 @@ int driDispatchRemapTable[driDispatchRemapTable_size]; const char * _mesa_get_function_spec(GLint func_index) { - if (func_index < Elements(_mesa_function_pool)) + if (func_index < ARRAY_SIZE(_mesa_function_pool)) return _mesa_function_pool + func_index; else return NULL; @@ -197,7 +197,7 @@ _mesa_do_init_remap_table(const char *pool, const char *spec; /* sanity check */ - ASSERT(i == remap[i].remap_index); + assert(i == remap[i].remap_index); spec = _mesa_function_pool + remap[i].pool_index; offset = _mesa_map_function_spec(spec); diff --git a/mesalib/src/mesa/main/remap.h b/mesalib/src/mesa/main/remap.h index 7199169d3..9d91b83c1 100644 --- a/mesalib/src/mesa/main/remap.h +++ b/mesalib/src/mesa/main/remap.h @@ -27,8 +27,6 @@ #define REMAP_H -#include "main/compiler.h" - struct gl_function_pool_remap { int pool_index; int remap_index; diff --git a/mesalib/src/mesa/main/renderbuffer.c b/mesalib/src/mesa/main/renderbuffer.c index 98f3c13b5..e9d129a1d 100644 --- a/mesalib/src/mesa/main/renderbuffer.c +++ b/mesalib/src/mesa/main/renderbuffer.c @@ -172,7 +172,7 @@ _mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr, struct gl_renderbuffer *oldRb = *ptr; mtx_lock(&oldRb->Mutex); - ASSERT(oldRb->RefCount > 0); + assert(oldRb->RefCount > 0); oldRb->RefCount--; /*printf("RB DECR %p (%d) to %d\n", (void*) oldRb, oldRb->Name, oldRb->RefCount);*/ deleteFlag = (oldRb->RefCount == 0); diff --git a/mesalib/src/mesa/main/samplerobj.c b/mesalib/src/mesa/main/samplerobj.c index d62a06bf1..d66b0b5e8 100644 --- a/mesalib/src/mesa/main/samplerobj.c +++ b/mesalib/src/mesa/main/samplerobj.c @@ -89,7 +89,7 @@ _mesa_reference_sampler_object_(struct gl_context *ctx, struct gl_sampler_object *oldSamp = *ptr; /*mtx_lock(&oldSamp->Mutex);*/ - ASSERT(oldSamp->RefCount > 0); + assert(oldSamp->RefCount > 0); oldSamp->RefCount--; #if 0 printf("SamplerObj %p %d DECR to %d\n", @@ -99,13 +99,13 @@ _mesa_reference_sampler_object_(struct gl_context *ctx, /*mtx_unlock(&oldSamp->Mutex);*/ if (deleteFlag) { - ASSERT(ctx->Driver.DeleteSamplerObject); + assert(ctx->Driver.DeleteSamplerObject); ctx->Driver.DeleteSamplerObject(ctx, oldSamp); } *ptr = NULL; } - ASSERT(!*ptr); + assert(!*ptr); if (samp) { /* reference new sampler */ diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c index 52eab4655..5731d581a 100644 --- a/mesalib/src/mesa/main/shaderapi.c +++ b/mesalib/src/mesa/main/shaderapi.c @@ -523,7 +523,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *params) { struct gl_shader_program *shProg - = _mesa_lookup_shader_program(ctx, program); + = _mesa_lookup_shader_program_err(ctx, program, "glGetProgramiv(program)"); /* Is transform feedback available in this context? */ @@ -546,7 +546,6 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, || _mesa_is_gles3(ctx); if (!shProg) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramiv(program)"); return; } @@ -764,11 +763,25 @@ static void get_program_info_log(struct gl_context *ctx, GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) { - struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, program); + struct gl_shader_program *shProg; + + /* Section 2.5 GL Errors (page 18) of the OpenGL ES 3.0.4 spec and + * section 2.3.1 (Errors) of the OpenGL 4.5 spec say: + * + * "If a negative number is provided where an argument of type sizei or + * sizeiptr is specified, an INVALID_VALUE error is generated." + */ + if (bufSize < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramInfoLog(bufSize < 0)"); + return; + } + + shProg = _mesa_lookup_shader_program_err(ctx, program, + "glGetProgramInfoLog(program)"); if (!shProg) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramInfoLog(program)"); return; } + _mesa_copy_string(infoLog, bufSize, length, shProg->InfoLog); } @@ -777,11 +790,24 @@ static void get_shader_info_log(struct gl_context *ctx, GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) { - struct gl_shader *sh = _mesa_lookup_shader(ctx, shader); + struct gl_shader *sh; + + /* Section 2.5 GL Errors (page 18) of the OpenGL ES 3.0.4 spec and + * section 2.3.1 (Errors) of the OpenGL 4.5 spec say: + * + * "If a negative number is provided where an argument of type sizei or + * sizeiptr is specified, an INVALID_VALUE error is generated." + */ + if (bufSize < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetShaderInfoLog(bufSize < 0)"); + return; + } + + sh = _mesa_lookup_shader_err(ctx, shader, "glGetShaderInfoLog(shader)"); if (!sh) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetShaderInfoLog(shader)"); return; } + _mesa_copy_string(infoLog, bufSize, length, sh->InfoLog); } @@ -1713,7 +1739,7 @@ _mesa_GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length, * Ensure that length always points to valid storage to avoid multiple NULL * pointer checks below. */ - if (length != NULL) + if (length == NULL) length = &length_dummy; diff --git a/mesalib/src/mesa/main/shaderobj.c b/mesalib/src/mesa/main/shaderobj.c index 02ccf450b..d7620c8ef 100644 --- a/mesalib/src/mesa/main/shaderobj.c +++ b/mesalib/src/mesa/main/shaderobj.c @@ -67,7 +67,7 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, GLboolean deleteFlag = GL_FALSE; struct gl_shader *old = *ptr; - ASSERT(old->RefCount > 0); + assert(old->RefCount > 0); old->RefCount--; /*printf("SHADER DECR %p (%d) to %d\n", (void*) old, old->Name, old->RefCount);*/ @@ -207,7 +207,7 @@ _mesa_reference_shader_program_(struct gl_context *ctx, GLboolean deleteFlag = GL_FALSE; struct gl_shader_program *old = *ptr; - ASSERT(old->RefCount > 0); + assert(old->RefCount > 0); old->RefCount--; #if 0 printf("ShaderProgram %p ID=%u RefCount-- to %d\n", diff --git a/mesalib/src/mesa/main/shaderobj.h b/mesalib/src/mesa/main/shaderobj.h index 92f7a33ee..3d696a188 100644 --- a/mesalib/src/mesa/main/shaderobj.h +++ b/mesalib/src/mesa/main/shaderobj.h @@ -114,7 +114,7 @@ _mesa_shader_enum_to_shader_stage(GLenum v) case GL_COMPUTE_SHADER: return MESA_SHADER_COMPUTE; default: - ASSERT(0 && "bad value in _mesa_shader_enum_to_shader_stage()"); + assert(0 && "bad value in _mesa_shader_enum_to_shader_stage()"); return MESA_SHADER_VERTEX; } } diff --git a/mesalib/src/mesa/main/shared.c b/mesalib/src/mesa/main/shared.c index ccf5355f3..0b76cc012 100644 --- a/mesalib/src/mesa/main/shared.c +++ b/mesalib/src/mesa/main/shared.c @@ -105,7 +105,7 @@ _mesa_alloc_shared_state(struct gl_context *ctx) GL_TEXTURE_2D, GL_TEXTURE_1D }; - STATIC_ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS); + STATIC_ASSERT(ARRAY_SIZE(targets) == NUM_TEXTURE_TARGETS); shared->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]); } @@ -159,7 +159,7 @@ delete_program_cb(GLuint id, void *data, void *userData) struct gl_program *prog = (struct gl_program *) data; struct gl_context *ctx = (struct gl_context *) userData; if(prog != &_mesa_DummyProgram) { - ASSERT(prog->RefCount == 1); /* should only be referenced by hash table */ + assert(prog->RefCount == 1); /* should only be referenced by hash table */ prog->RefCount = 0; /* now going away */ ctx->Driver.DeleteProgram(ctx, prog); } @@ -223,7 +223,7 @@ delete_shader_cb(GLuint id, void *data, void *userData) } else { struct gl_shader_program *shProg = (struct gl_shader_program *) data; - ASSERT(shProg->Type == GL_SHADER_PROGRAM_MESA); + assert(shProg->Type == GL_SHADER_PROGRAM_MESA); ctx->Driver.DeleteShaderProgram(ctx, shProg); } } @@ -346,7 +346,7 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared) * Free texture objects (after FBOs since some textures might have * been bound to FBOs). */ - ASSERT(ctx->Driver.DeleteTexture); + assert(ctx->Driver.DeleteTexture); /* the default textures */ for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { ctx->Driver.DeleteTexture(ctx, shared->DefaultTex[i]); diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c index 45bce78fd..dadfb3c8c 100644 --- a/mesalib/src/mesa/main/state.c +++ b/mesalib/src/mesa/main/state.c @@ -275,7 +275,7 @@ update_viewport_matrix(struct gl_context *ctx) const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF; unsigned i; - ASSERT(depthMax > 0); + assert(depthMax > 0); /* Compute scale and bias values. This is really driver-specific * and should be maintained elsewhere if at all. diff --git a/mesalib/src/mesa/main/stencil.h b/mesalib/src/mesa/main/stencil.h index 6480b2adc..3302cb947 100644 --- a/mesalib/src/mesa/main/stencil.h +++ b/mesalib/src/mesa/main/stencil.h @@ -33,6 +33,7 @@ #include "glheader.h" +#include "macros.h" struct gl_context; diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c index b4efeee3b..00234d4cc 100644 --- a/mesalib/src/mesa/main/texcompress.c +++ b/mesalib/src/mesa/main/texcompress.c @@ -570,8 +570,8 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint img, _mesa_get_format_block_size(mesaFormat, &bw, &bh); - ASSERT(col % bw == 0); - ASSERT(row % bh == 0); + assert(col % bw == 0); + assert(row % bh == 0); offset = ((width + bw - 1) / bw) * (row / bh) + col / bw; offset *= blockSize; diff --git a/mesalib/src/mesa/main/texcompress_bptc.c b/mesalib/src/mesa/main/texcompress_bptc.c index c944ac26f..a600180e2 100644 --- a/mesalib/src/mesa/main/texcompress_bptc.c +++ b/mesalib/src/mesa/main/texcompress_bptc.c @@ -1630,7 +1630,7 @@ texstore_bptc_rgb_float(TEXSTORE_PARAMS, GLboolean _mesa_texstore_bptc_rgb_signed_float(TEXSTORE_PARAMS) { - ASSERT(dstFormat == MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT); + assert(dstFormat == MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT); return texstore_bptc_rgb_float(ctx, dims, baseInternalFormat, dstFormat, dstRowStride, dstSlices, @@ -1643,7 +1643,7 @@ _mesa_texstore_bptc_rgb_signed_float(TEXSTORE_PARAMS) GLboolean _mesa_texstore_bptc_rgb_unsigned_float(TEXSTORE_PARAMS) { - ASSERT(dstFormat == MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT); + assert(dstFormat == MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT); return texstore_bptc_rgb_float(ctx, dims, baseInternalFormat, dstFormat, dstRowStride, dstSlices, diff --git a/mesalib/src/mesa/main/texcompress_cpal.c b/mesalib/src/mesa/main/texcompress_cpal.c index 54e9af41d..c46ef8c53 100644 --- a/mesalib/src/mesa/main/texcompress_cpal.c +++ b/mesalib/src/mesa/main/texcompress_cpal.c @@ -32,7 +32,6 @@ #include "glheader.h" -#include "compiler.h" /* for ASSERT */ #include "context.h" #include "mtypes.h" #include "imports.h" @@ -120,7 +119,7 @@ _mesa_cpal_compressed_size(int level, GLenum internalFormat, } info = &formats[internalFormat - GL_PALETTE4_RGB8_OES]; - ASSERT(info->cpal_format == internalFormat); + assert(info->cpal_format == internalFormat); expect_size = info->palette_size * info->size; for (lvl = 0; lvl < num_levels; lvl++) { diff --git a/mesalib/src/mesa/main/texcompress_etc.c b/mesalib/src/mesa/main/texcompress_etc.c index 98b4fe201..f29561cc6 100644 --- a/mesalib/src/mesa/main/texcompress_etc.c +++ b/mesalib/src/mesa/main/texcompress_etc.c @@ -108,7 +108,7 @@ GLboolean _mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS) { /* GL_ETC1_RGB8_OES is only valid in glCompressedTexImage2D */ - ASSERT(0); + assert(0); return GL_FALSE; } @@ -1099,7 +1099,7 @@ etc2_unpack_srgb8_punchthrough_alpha1(uint8_t *dst_row, GLboolean _mesa_texstore_etc2_rgb8(TEXSTORE_PARAMS) { - ASSERT(0); + assert(0); return GL_FALSE; } @@ -1107,7 +1107,7 @@ _mesa_texstore_etc2_rgb8(TEXSTORE_PARAMS) GLboolean _mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS) { - ASSERT(0); + assert(0); return GL_FALSE; } @@ -1115,7 +1115,7 @@ _mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS) GLboolean _mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS) { - ASSERT(0); + assert(0); return GL_FALSE; } @@ -1123,7 +1123,7 @@ _mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS) GLboolean _mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS) { - ASSERT(0); + assert(0); return GL_FALSE; } @@ -1131,7 +1131,7 @@ _mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS) GLboolean _mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS) { - ASSERT(0); + assert(0); return GL_FALSE; } @@ -1139,7 +1139,7 @@ _mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS) GLboolean _mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS) { - ASSERT(0); + assert(0); return GL_FALSE; } @@ -1147,7 +1147,7 @@ _mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS) GLboolean _mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS) { - ASSERT(0); + assert(0); return GL_FALSE; } @@ -1155,7 +1155,7 @@ _mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS) GLboolean _mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS) { - ASSERT(0); + assert(0); return GL_FALSE; } @@ -1163,7 +1163,7 @@ _mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS) GLboolean _mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS) { - ASSERT(0); + assert(0); return GL_FALSE; } @@ -1171,7 +1171,7 @@ _mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS) GLboolean _mesa_texstore_etc2_srgb8_punchthrough_alpha1(TEXSTORE_PARAMS) { - ASSERT(0); + assert(0); return GL_FALSE; } diff --git a/mesalib/src/mesa/main/texcompress_fxt1.c b/mesalib/src/mesa/main/texcompress_fxt1.c index 7b25e1039..562359410 100644 --- a/mesalib/src/mesa/main/texcompress_fxt1.c +++ b/mesalib/src/mesa/main/texcompress_fxt1.c @@ -61,7 +61,7 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS) GLubyte *dst; const GLubyte *tempImage = NULL; - ASSERT(dstFormat == MESA_FORMAT_RGB_FXT1); + assert(dstFormat == MESA_FORMAT_RGB_FXT1); if (srcFormat != GL_RGB || srcType != GL_UNSIGNED_BYTE || @@ -116,7 +116,7 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS) GLubyte *dst; const GLubyte *tempImage = NULL; - ASSERT(dstFormat == MESA_FORMAT_RGBA_FXT1); + assert(dstFormat == MESA_FORMAT_RGBA_FXT1); if (srcFormat != GL_RGBA || srcType != GL_UNSIGNED_BYTE || @@ -1264,12 +1264,12 @@ upscale_teximage2d(GLsizei inWidth, GLsizei inHeight, { GLint i, j, k; - ASSERT(outWidth >= inWidth); - ASSERT(outHeight >= inHeight); + assert(outWidth >= inWidth); + assert(outHeight >= inHeight); #if 0 - ASSERT(inWidth == 1 || inWidth == 2 || inHeight == 1 || inHeight == 2); - ASSERT((outWidth & 3) == 0); - ASSERT((outHeight & 3) == 0); + assert(inWidth == 1 || inWidth == 2 || inHeight == 1 || inHeight == 2); + assert((outWidth & 3) == 0); + assert((outHeight & 3) == 0); #endif for (i = 0; i < outHeight; i++) { diff --git a/mesalib/src/mesa/main/texcompress_rgtc.c b/mesalib/src/mesa/main/texcompress_rgtc.c index e3042011a..f40e4e6c0 100644 --- a/mesalib/src/mesa/main/texcompress_rgtc.c +++ b/mesalib/src/mesa/main/texcompress_rgtc.c @@ -86,7 +86,7 @@ _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS) GLint dstRowDiff, redRowStride; GLubyte *tempImageSlices[1]; - ASSERT(dstFormat == MESA_FORMAT_R_RGTC1_UNORM || + assert(dstFormat == MESA_FORMAT_R_RGTC1_UNORM || dstFormat == MESA_FORMAT_L_LATC1_UNORM); tempImage = malloc(srcWidth * srcHeight * 1 * sizeof(GLubyte)); @@ -139,7 +139,7 @@ _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS) GLint dstRowDiff, redRowStride; GLfloat *tempImageSlices[1]; - ASSERT(dstFormat == MESA_FORMAT_R_RGTC1_SNORM || + assert(dstFormat == MESA_FORMAT_R_RGTC1_SNORM || dstFormat == MESA_FORMAT_L_LATC1_SNORM); redRowStride = 1 * srcWidth * sizeof(GLfloat); @@ -193,7 +193,7 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS) mesa_format tempFormat; GLubyte *tempImageSlices[1]; - ASSERT(dstFormat == MESA_FORMAT_RG_RGTC2_UNORM || + assert(dstFormat == MESA_FORMAT_RG_RGTC2_UNORM || dstFormat == MESA_FORMAT_LA_LATC2_UNORM); if (baseInternalFormat == GL_RG) @@ -258,7 +258,7 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS) mesa_format tempFormat; GLfloat *tempImageSlices[1]; - ASSERT(dstFormat == MESA_FORMAT_RG_RGTC2_SNORM || + assert(dstFormat == MESA_FORMAT_RG_RGTC2_SNORM || dstFormat == MESA_FORMAT_LA_LATC2_SNORM); if (baseInternalFormat == GL_RG) diff --git a/mesalib/src/mesa/main/texcompress_s3tc.c b/mesalib/src/mesa/main/texcompress_s3tc.c index bfb53dce4..41d00d4e9 100644 --- a/mesalib/src/mesa/main/texcompress_s3tc.c +++ b/mesalib/src/mesa/main/texcompress_s3tc.c @@ -133,7 +133,7 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS) GLubyte *dst; const GLubyte *tempImage = NULL; - ASSERT(dstFormat == MESA_FORMAT_RGB_DXT1 || + assert(dstFormat == MESA_FORMAT_RGB_DXT1 || dstFormat == MESA_FORMAT_SRGB_DXT1); if (srcFormat != GL_RGB || @@ -190,7 +190,7 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS) GLubyte *dst; const GLubyte *tempImage = NULL; - ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT1 || + assert(dstFormat == MESA_FORMAT_RGBA_DXT1 || dstFormat == MESA_FORMAT_SRGBA_DXT1); if (srcFormat != GL_RGBA || @@ -247,7 +247,7 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS) GLubyte *dst; const GLubyte *tempImage = NULL; - ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT3 || + assert(dstFormat == MESA_FORMAT_RGBA_DXT3 || dstFormat == MESA_FORMAT_SRGBA_DXT3); if (srcFormat != GL_RGBA || @@ -303,7 +303,7 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS) GLubyte *dst; const GLubyte *tempImage = NULL; - ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT5 || + assert(dstFormat == MESA_FORMAT_RGBA_DXT5 || dstFormat == MESA_FORMAT_SRGBA_DXT5); if (srcFormat != GL_RGBA || diff --git a/mesalib/src/mesa/main/texcompress_s3tc.h b/mesalib/src/mesa/main/texcompress_s3tc.h index 2734210a5..438b71fe3 100644 --- a/mesalib/src/mesa/main/texcompress_s3tc.h +++ b/mesalib/src/mesa/main/texcompress_s3tc.h @@ -25,7 +25,6 @@ #ifndef TEXCOMPRESS_S3TC_H #define TEXCOMPRESS_S3TC_H -#include "compiler.h" #include "glheader.h" #include "texstore.h" #include "texcompress.h" diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c index ec16af9d2..3c4baca70 100644 --- a/mesalib/src/mesa/main/texformat.c +++ b/mesalib/src/mesa/main/texformat.c @@ -430,12 +430,12 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, case GL_RGB9_E5: /* GL_EXT_texture_shared_exponent -- just one format to support */ - ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_R9G9B9E5_FLOAT]); + assert(ctx->TextureFormatSupported[MESA_FORMAT_R9G9B9E5_FLOAT]); return MESA_FORMAT_R9G9B9E5_FLOAT; case GL_R11F_G11F_B10F: /* GL_EXT_texture_packed_float -- just one format to support */ - ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_R11G11B10_FLOAT]); + assert(ctx->TextureFormatSupported[MESA_FORMAT_R11G11B10_FLOAT]); return MESA_FORMAT_R11G11B10_FLOAT; case GL_DEPTH_STENCIL_EXT: @@ -445,10 +445,10 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, break; case GL_DEPTH_COMPONENT32F: - ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_Z_FLOAT32]); + assert(ctx->TextureFormatSupported[MESA_FORMAT_Z_FLOAT32]); return MESA_FORMAT_Z_FLOAT32; case GL_DEPTH32F_STENCIL8: - ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_Z32_FLOAT_S8X24_UINT]); + assert(ctx->TextureFormatSupported[MESA_FORMAT_Z32_FLOAT_S8X24_UINT]); return MESA_FORMAT_Z32_FLOAT_S8X24_UINT; case GL_RED_SNORM: diff --git a/mesalib/src/mesa/main/texgen.h b/mesalib/src/mesa/main/texgen.h index aad5d2ecf..84adfc061 100644 --- a/mesalib/src/mesa/main/texgen.h +++ b/mesalib/src/mesa/main/texgen.h @@ -27,7 +27,6 @@ #define TEXGEN_H -#include "compiler.h" #include "glheader.h" struct _glapi_table; diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c index 24df5b6f8..f975c160e 100644 --- a/mesalib/src/mesa/main/texgetimage.c +++ b/mesalib/src/mesa/main/texgetimage.c @@ -375,7 +375,7 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, GLuint height = texImage->Height; GLuint depth = texImage->Depth; GLuint img; - GLboolean dst_is_integer = _mesa_is_enum_format_integer(format); + GLboolean dst_is_integer; uint32_t dst_format; int dst_stride; uint8_t rebaseSwizzle[4]; @@ -423,6 +423,7 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, * integer then transferOps do not apply. */ assert(!transferOps || (transferOps && !dst_is_integer)); + (void) dst_is_integer; /* silence unused var warning */ for (img = 0; img < depth; img++) { GLubyte *srcMap; diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index 29c325bf2..611d664b6 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -224,7 +224,10 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) if (ctx->Extensions.ARB_stencil_texturing) { switch (internalFormat) { case GL_STENCIL_INDEX: + case GL_STENCIL_INDEX1: + case GL_STENCIL_INDEX4: case GL_STENCIL_INDEX8: + case GL_STENCIL_INDEX16: return GL_STENCIL_INDEX; default: ; /* fallthrough */ @@ -650,8 +653,8 @@ set_tex_image(struct gl_texture_object *tObj, { const GLuint face = _mesa_tex_target_to_face(target); - ASSERT(tObj); - ASSERT(texImage); + assert(tObj); + assert(texImage); if (target == GL_TEXTURE_RECTANGLE_NV || target == GL_TEXTURE_EXTERNAL_OES) assert(level == 0); @@ -696,7 +699,7 @@ _mesa_delete_texture_image(struct gl_context *ctx, /* Free texImage->Data and/or any other driver-specific texture * image storage. */ - ASSERT(ctx->Driver.FreeTextureImageBuffer); + assert(ctx->Driver.FreeTextureImageBuffer); ctx->Driver.FreeTextureImageBuffer( ctx, texImage ); free(texImage); } @@ -729,9 +732,9 @@ _mesa_is_proxy_texture(GLenum target) * NUM_TEXTURE_TARGETS should match number of terms above, except there's no * proxy for GL_TEXTURE_BUFFER and GL_TEXTURE_EXTERNAL_OES. */ - STATIC_ASSERT(NUM_TEXTURE_TARGETS == Elements(targets) + 2); + STATIC_ASSERT(NUM_TEXTURE_TARGETS == ARRAY_SIZE(targets) + 2); - for (i = 0; i < Elements(targets); ++i) + for (i = 0; i < ARRAY_SIZE(targets); ++i) if (target == targets[i]) return GL_TRUE; return GL_FALSE; @@ -739,6 +742,28 @@ _mesa_is_proxy_texture(GLenum target) /** + * Test if a target is an array target. + * + * \param target texture target. + * + * \return true if the target is an array target, false otherwise. + */ +bool +_mesa_is_array_texture(GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D_ARRAY: + case GL_TEXTURE_2D_ARRAY: + case GL_TEXTURE_CUBE_MAP_ARRAY: + case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: + return true; + default: + return false; + }; +} + + +/** * Return the proxy target which corresponds to the given texture target */ static GLenum @@ -807,9 +832,9 @@ _mesa_select_tex_image(const struct gl_texture_object *texObj, { const GLuint face = _mesa_tex_target_to_face(target); - ASSERT(texObj); - ASSERT(level >= 0); - ASSERT(level < MAX_TEXTURE_LEVELS); + assert(texObj); + assert(level >= 0); + assert(level < MAX_TEXTURE_LEVELS); return texObj->Image[face][level]; } @@ -1239,7 +1264,7 @@ make_null_texture(GLint width, GLint height, GLint depth, GLenum format) static void clear_teximage_fields(struct gl_texture_image *img) { - ASSERT(img); + assert(img); img->_BaseFormat = 0; img->InternalFormat = 0; img->Border = 0; @@ -1284,14 +1309,14 @@ init_teximage_fields_ms(struct gl_context *ctx, GLuint numSamples, GLboolean fixedSampleLocations) { GLenum target; - ASSERT(img); - ASSERT(width >= 0); - ASSERT(height >= 0); - ASSERT(depth >= 0); + assert(img); + assert(width >= 0); + assert(height >= 0); + assert(depth >= 0); target = img->TexObject->Target; img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat ); - ASSERT(img->_BaseFormat != -1); + assert(img->_BaseFormat != -1); img->InternalFormat = internalFormat; img->Border = border; img->Width = width; @@ -2184,7 +2209,7 @@ texture_error_check( struct gl_context *ctx, /* additional checks for ycbcr textures */ if (internalFormat == GL_YCBCR_MESA) { - ASSERT(ctx->Extensions.MESA_ycbcr_texture); + assert(ctx->Extensions.MESA_ycbcr_texture); if (type != GL_UNSIGNED_SHORT_8_8_MESA && type != GL_UNSIGNED_SHORT_8_8_REV_MESA) { char message[100]; @@ -2491,8 +2516,8 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions, } if (error_check_subtexture_dimensions(ctx, dimensions, - texImage, xoffset, yoffset, 0, - width, height, 1, + texImage, xoffset, yoffset, zoffset, + width, height, depth, dsa ? "glTextureSubImage" : "glTexSubImage")) { return GL_TRUE; @@ -2815,14 +2840,6 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions, } } - /* check target (proxies not allowed) */ - if (!legal_texsubimage_target(ctx, dimensions, target, dsa)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTex%sSubImage%uD(target=%s)", - suffix, dimensions, - _mesa_lookup_enum_by_nr(target)); - return GL_TRUE; - } - /* Check level */ if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) { _mesa_error(ctx, GL_INVALID_VALUE, @@ -2933,7 +2950,7 @@ check_rtt_cb(GLuint key, void *data, void *userData) att->TextureLevel == level && att->CubeMapFace == face) { _mesa_update_texture_renderbuffer(ctx, ctx->DrawBuffer, att); - ASSERT(att->Renderbuffer->TexImage); + assert(att->Renderbuffer->TexImage); /* Mark fb status as indeterminate to force re-validation */ fb->_Status = 0; } @@ -2977,7 +2994,7 @@ check_gen_mipmap(struct gl_context *ctx, GLenum target, if (texObj->GenerateMipmap && level == texObj->BaseLevel && level < texObj->MaxLevel) { - ASSERT(ctx->Driver.GenerateMipmap); + assert(ctx->Driver.GenerateMipmap); ctx->Driver.GenerateMipmap(ctx, target, texObj); } } @@ -3054,7 +3071,7 @@ _mesa_choose_texture_format(struct gl_context *ctx, prevImage->Width > 0 && prevImage->InternalFormat == internalFormat) { /* use the same format */ - ASSERT(prevImage->TexFormat != MESA_FORMAT_NONE); + assert(prevImage->TexFormat != MESA_FORMAT_NONE); return prevImage->TexFormat; } } @@ -3093,7 +3110,7 @@ _mesa_choose_texture_format(struct gl_context *ctx, /* choose format from scratch */ f = ctx->Driver.ChooseTextureFormat(ctx, target, internalFormat, format, type); - ASSERT(f != MESA_FORMAT_NONE); + assert(f != MESA_FORMAT_NONE); return f; } @@ -4088,6 +4105,16 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level, struct gl_texture_object* texObj; GET_CURRENT_CONTEXT(ctx); + /* Check target (proxies not allowed). Target must be checked prior to + * calling _mesa_get_current_tex_object. + */ + if (!legal_texsubimage_target(ctx, 1, target, false)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glCopyTexSubImage1D(invalid target %s)", + _mesa_lookup_enum_by_nr(target)); + return; + } + texObj = _mesa_get_current_tex_object(ctx, target); if (!texObj) return; @@ -4106,6 +4133,16 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level, struct gl_texture_object* texObj; GET_CURRENT_CONTEXT(ctx); + /* Check target (proxies not allowed). Target must be checked prior to + * calling _mesa_get_current_tex_object. + */ + if (!legal_texsubimage_target(ctx, 2, target, false)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glCopyTexSubImage2D(invalid target %s)", + _mesa_lookup_enum_by_nr(target)); + return; + } + texObj = _mesa_get_current_tex_object(ctx, target); if (!texObj) return; @@ -4125,6 +4162,16 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level, struct gl_texture_object* texObj; GET_CURRENT_CONTEXT(ctx); + /* Check target (proxies not allowed). Target must be checked prior to + * calling _mesa_get_current_tex_object. + */ + if (!legal_texsubimage_target(ctx, 3, target, false)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glCopyTexSubImage3D(invalid target %s)", + _mesa_lookup_enum_by_nr(target)); + return; + } + texObj = _mesa_get_current_tex_object(ctx, target); if (!texObj) return; @@ -4145,6 +4192,14 @@ _mesa_CopyTextureSubImage1D(GLuint texture, GLint level, if (!texObj) return; + /* Check target (proxies not allowed). */ + if (!legal_texsubimage_target(ctx, 1, texObj->Target, true)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glCopyTextureSubImage1D(invalid target %s)", + _mesa_lookup_enum_by_nr(texObj->Target)); + return; + } + _mesa_copy_texture_sub_image(ctx, 1, texObj, texObj->Target, level, xoffset, 0, 0, x, y, width, 1, true); } @@ -4161,6 +4216,14 @@ _mesa_CopyTextureSubImage2D(GLuint texture, GLint level, if (!texObj) return; + /* Check target (proxies not allowed). */ + if (!legal_texsubimage_target(ctx, 2, texObj->Target, true)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glCopyTextureSubImage2D(invalid target %s)", + _mesa_lookup_enum_by_nr(texObj->Target)); + return; + } + _mesa_copy_texture_sub_image(ctx, 2, texObj, texObj->Target, level, xoffset, yoffset, 0, x, y, width, height, true); @@ -4180,6 +4243,14 @@ _mesa_CopyTextureSubImage3D(GLuint texture, GLint level, if (!texObj) return; + /* Check target (proxies not allowed). */ + if (!legal_texsubimage_target(ctx, 3, texObj->Target, true)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glCopyTextureSubImage3D(invalid target %s)", + _mesa_lookup_enum_by_nr(texObj->Target)); + return; + } + _mesa_copy_texture_sub_image(ctx, 3, texObj, texObj->Target, level, xoffset, yoffset, zoffset, x, y, width, height, true); @@ -4454,25 +4525,21 @@ out: /** - * Error checking for glCompressedTexSubImage[123]D(). + * Target checking for glCompressedTexSubImage[123]D(). * \return GL_TRUE if error, GL_FALSE if no error + * Must come before other error checking so that the texture object can + * be correctly retrieved using _mesa_get_current_tex_object. */ static GLboolean -compressed_subtexture_error_check(struct gl_context *ctx, GLint dims, - const struct gl_texture_object *texObj, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLsizei imageSize, bool dsa) +compressed_subtexture_target_check(struct gl_context *ctx, GLenum target, + GLint dims, GLenum format, bool dsa, + const char *caller) { - struct gl_texture_image *texImage; - GLint expectedSize; GLboolean targetOK; - const char *suffix = dsa ? "ture" : ""; if (dsa && target == GL_TEXTURE_RECTANGLE) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCompressedSubTexture%dD(target)", dims); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid target %s)", caller, + _mesa_lookup_enum_by_nr(target)); return GL_TRUE; } @@ -4535,7 +4602,9 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dims, } if (invalidformat) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCompressedTex%sSubImage%uD(target)", suffix, dims); + "%s(invalid target %s for format %s)", caller, + _mesa_lookup_enum_by_nr(target), + _mesa_lookup_enum_by_nr(format)); return GL_TRUE; } } @@ -4549,11 +4618,30 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dims, } if (!targetOK) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glCompressedTex%sSubImage%uD(target)", suffix, dims); + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", caller, + _mesa_lookup_enum_by_nr(target)); return GL_TRUE; } + return GL_FALSE; +} + +/** + * Error checking for glCompressedTexSubImage[123]D(). + * \return GL_TRUE if error, GL_FALSE if no error + */ +static GLboolean +compressed_subtexture_error_check(struct gl_context *ctx, GLint dims, + const struct gl_texture_object *texObj, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize, bool dsa) +{ + struct gl_texture_image *texImage; + GLint expectedSize; + const char *suffix = dsa ? "ture" : ""; + /* this will catch any invalid compressed format token */ if (!_mesa_is_compressed_format(ctx, format)) { _mesa_error(ctx, GL_INVALID_ENUM, @@ -4709,6 +4797,11 @@ _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset, struct gl_texture_object *texObj; GET_CURRENT_CONTEXT(ctx); + if (compressed_subtexture_target_check(ctx, target, 1, format, false, + "glCompressedTexSubImage1D")) { + return; + } + texObj = _mesa_get_current_tex_object(ctx, target); if (!texObj) return; @@ -4731,6 +4824,12 @@ _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset, if (!texObj) return; + if (compressed_subtexture_target_check(ctx, texObj->Target, 1, format, + true, + "glCompressedTextureSubImage1D")) { + return; + } + _mesa_compressed_texture_sub_image(ctx, 1, texObj, texObj->Target, level, xoffset, 0, 0, width, 1, 1, format, imageSize, data, true); @@ -4746,6 +4845,11 @@ _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, struct gl_texture_object *texObj; GET_CURRENT_CONTEXT(ctx); + if (compressed_subtexture_target_check(ctx, target, 2, format, false, + "glCompressedTexSubImage2D")) { + return; + } + texObj = _mesa_get_current_tex_object(ctx, target); if (!texObj) return; @@ -4770,6 +4874,12 @@ _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset, if (!texObj) return; + if (compressed_subtexture_target_check(ctx, texObj->Target, 2, format, + true, + "glCompressedTextureSubImage2D")) { + return; + } + _mesa_compressed_texture_sub_image(ctx, 2, texObj, texObj->Target, level, xoffset, yoffset, 0, width, height, 1, format, imageSize, data, true); @@ -4784,6 +4894,11 @@ _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, struct gl_texture_object *texObj; GET_CURRENT_CONTEXT(ctx); + if (compressed_subtexture_target_check(ctx, target, 3, format, false, + "glCompressedTexSubImage3D")) { + return; + } + texObj = _mesa_get_current_tex_object(ctx, target); if (!texObj) return; @@ -4809,6 +4924,12 @@ _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset, if (!texObj) return; + if (compressed_subtexture_target_check(ctx, texObj->Target, 3, format, + true, + "glCompressedTextureSubImage3D")) { + return; + } + _mesa_compressed_texture_sub_image(ctx, 3, texObj, texObj->Target, level, xoffset, yoffset, zoffset, width, height, depth, @@ -5031,7 +5152,7 @@ _mesa_validate_texbuffer_format(const struct gl_context *ctx, void _mesa_texture_buffer_range(struct gl_context *ctx, - struct gl_texture_object *texObj, GLenum target, + struct gl_texture_object *texObj, GLenum target, GLenum internalFormat, struct gl_buffer_object *bufObj, GLintptr offset, GLsizeiptr size, bool range, diff --git a/mesalib/src/mesa/main/teximage.h b/mesalib/src/mesa/main/teximage.h index 02b0eda38..b7336bc6c 100644 --- a/mesalib/src/mesa/main/teximage.h +++ b/mesalib/src/mesa/main/teximage.h @@ -66,6 +66,9 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ); extern GLboolean _mesa_is_proxy_texture(GLenum target); +extern bool +_mesa_is_array_texture(GLenum target); + extern struct gl_texture_image * _mesa_new_texture_image( struct gl_context *ctx ); diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c index 59090db4e..e018ab910 100644 --- a/mesalib/src/mesa/main/texobj.c +++ b/mesalib/src/mesa/main/texobj.c @@ -28,6 +28,7 @@ */ +#include <stdio.h> #include "bufferobj.h" #include "colortab.h" #include "context.h" @@ -265,7 +266,7 @@ _mesa_initialize_texture_object( struct gl_context *ctx, struct gl_texture_object *obj, GLuint name, GLenum target ) { - ASSERT(target == 0 || + assert(target == 0 || target == GL_TEXTURE_1D || target == GL_TEXTURE_2D || target == GL_TEXTURE_3D || @@ -541,11 +542,11 @@ _mesa_reference_texobj_(struct gl_texture_object **ptr, GLboolean deleteFlag = GL_FALSE; struct gl_texture_object *oldTex = *ptr; - ASSERT(valid_texture_object(oldTex)); + assert(valid_texture_object(oldTex)); (void) valid_texture_object; /* silence warning in release builds */ mtx_lock(&oldTex->Mutex); - ASSERT(oldTex->RefCount > 0); + assert(oldTex->RefCount > 0); oldTex->RefCount--; deleteFlag = (oldTex->RefCount == 0); @@ -568,7 +569,7 @@ _mesa_reference_texobj_(struct gl_texture_object **ptr, if (tex) { /* reference new texture */ - ASSERT(valid_texture_object(tex)); + assert(valid_texture_object(tex)); mtx_lock(&tex->Mutex); if (tex->RefCount == 0) { /* this texture's being deleted (look just above) */ @@ -730,7 +731,7 @@ _mesa_test_texobj_completeness( const struct gl_context *ctx, return; } - ASSERT(maxLevels > 0); + assert(maxLevels > 0); t->_MaxLevel = MIN3(t->MaxLevel, /* 'p' in the GL spec */ @@ -1724,7 +1725,7 @@ _mesa_BindTexture( GLenum target, GLuint texName ) _mesa_reference_texobj(&texUnit->CurrentTex[targetIndex], newTexObj); ctx->Texture.NumCurrentTexUsed = MAX2(ctx->Texture.NumCurrentTexUsed, ctx->Texture.CurrentUnit + 1); - ASSERT(texUnit->CurrentTex[targetIndex]); + assert(texUnit->CurrentTex[targetIndex]); if (texName != 0) texUnit->_BoundTextures |= (1 << targetIndex); @@ -1773,7 +1774,7 @@ _mesa_bind_texture_unit(struct gl_context *ctx, _mesa_reference_texobj(&texUnit->CurrentTex[texObj->TargetIndex], texObj); - ASSERT(texUnit->CurrentTex[texObj->TargetIndex]); + assert(texUnit->CurrentTex[texObj->TargetIndex]); ctx->Texture.NumCurrentTexUsed = MAX2(ctx->Texture.NumCurrentTexUsed, unit + 1); texUnit->_BoundTextures |= (1 << texObj->TargetIndex); diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c index c4a5841c5..1ef728660 100644 --- a/mesalib/src/mesa/main/texparam.c +++ b/mesalib/src/mesa/main/texparam.c @@ -217,8 +217,8 @@ comp_to_swizzle(GLenum comp) static void set_swizzle_component(GLuint *swizzle, GLuint comp, GLuint swz) { - ASSERT(comp < 4); - ASSERT(swz <= SWIZZLE_NIL); + assert(comp < 4); + assert(swz <= SWIZZLE_NIL); { GLuint mask = 0x7 << (3 * comp); GLuint s = (*swizzle & ~mask) | (swz << (3 * comp)); @@ -537,7 +537,7 @@ set_tex_parameteri(struct gl_context *ctx, "glTex%sParameter(swizzle 0x%x)", suffix, params[0]); return GL_FALSE; } - ASSERT(comp < 4); + assert(comp < 4); flush(ctx); texObj->Swizzle[comp] = params[0]; diff --git a/mesalib/src/mesa/main/texstate.c b/mesalib/src/mesa/main/texstate.c index 99c7c8178..0a7f983fb 100644 --- a/mesalib/src/mesa/main/texstate.c +++ b/mesalib/src/mesa/main/texstate.c @@ -28,6 +28,7 @@ * Texture state handling. */ +#include <stdio.h> #include "glheader.h" #include "bufferobj.h" #include "colormac.h" @@ -68,8 +69,8 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst ) { GLuint u, tex; - ASSERT(src); - ASSERT(dst); + assert(src); + assert(dst); dst->Texture.CurrentUnit = src->Texture.CurrentUnit; dst->Texture._GenFlags = src->Texture._GenFlags; @@ -292,7 +293,7 @@ _mesa_ActiveTexture(GLenum texture) k = _mesa_max_tex_unit(ctx); - ASSERT(k <= Elements(ctx->Texture.Unit)); + assert(k <= ARRAY_SIZE(ctx->Texture.Unit)); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) _mesa_debug(ctx, "glActiveTexture %s\n", @@ -363,7 +364,7 @@ update_texture_matrices( struct gl_context *ctx ) ctx->Texture._TexMatEnabled = 0x0; for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) { - ASSERT(u < Elements(ctx->TextureMatrixStack)); + assert(u < ARRAY_SIZE(ctx->TextureMatrixStack)); if (_math_matrix_is_dirty(ctx->TextureMatrixStack[u].Top)) { _math_matrix_analyse( ctx->TextureMatrixStack[u].Top ); @@ -501,7 +502,7 @@ update_texgen(struct gl_context *ctx) ctx->Texture._GenFlags |= texUnit->_GenFlags; } - ASSERT(unit < Elements(ctx->TextureMatrixStack)); + assert(unit < ARRAY_SIZE(ctx->TextureMatrixStack)); if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit); } @@ -797,7 +798,7 @@ alloc_proxy_textures( struct gl_context *ctx ) }; GLint tgt; - STATIC_ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS); + STATIC_ASSERT(ARRAY_SIZE(targets) == NUM_TEXTURE_TARGETS); assert(targets[TEXTURE_2D_INDEX] == GL_TEXTURE_2D); assert(targets[TEXTURE_CUBE_INDEX] == GL_TEXTURE_CUBE_MAP); @@ -882,10 +883,19 @@ _mesa_init_texture(struct gl_context *ctx) * "OpenGL ES 3.0 requires that all cube map filtering be * seamless. OpenGL ES 2.0 specified that a single cube map face be * selected and used for filtering." + * + * Unfortunatley, a call to _mesa_is_gles3 below will only work if + * the driver has already computed and set ctx->Version, however drivers + * seem to call _mesa_initialize_context (which calls this) early + * in the CreateContext hook and _mesa_compute_version much later (since + * it needs information about available extensions). So, we will + * enable seamless cubemaps by default since GLES2. This should work + * for most implementations and drivers that don't support seamless + * cubemaps for GLES2 can still disable it. */ - ctx->Texture.CubeMapSeamless = _mesa_is_gles3(ctx); + ctx->Texture.CubeMapSeamless = ctx->API == API_OPENGLES2; - for (u = 0; u < Elements(ctx->Texture.Unit); u++) + for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) init_texture_unit(ctx, u); /* After we're done initializing the context's texture state the default @@ -918,7 +928,7 @@ _mesa_free_texture_data(struct gl_context *ctx) GLuint u, tgt; /* unreference current textures */ - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { + for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) { /* The _Current texture could account for another reference */ _mesa_reference_texobj(&ctx->Texture.Unit[u]._Current, NULL); @@ -934,7 +944,7 @@ _mesa_free_texture_data(struct gl_context *ctx) /* GL_ARB_texture_buffer_object */ _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, NULL); - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { + for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) { _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[u].Sampler, NULL); } } @@ -950,7 +960,7 @@ _mesa_update_default_objects_texture(struct gl_context *ctx) { GLuint u, tex; - for (u = 0; u < Elements(ctx->Texture.Unit); u++) { + for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u]; for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { _mesa_reference_texobj(&texUnit->CurrentTex[tex], diff --git a/mesalib/src/mesa/main/texstate.h b/mesalib/src/mesa/main/texstate.h index abc07eafb..662435b47 100644 --- a/mesalib/src/mesa/main/texstate.h +++ b/mesalib/src/mesa/main/texstate.h @@ -41,7 +41,7 @@ static inline struct gl_texture_unit * _mesa_get_tex_unit(struct gl_context *ctx, GLuint unit) { - ASSERT(unit < Elements(ctx->Texture.Unit)); + assert(unit < ARRAY_SIZE(ctx->Texture.Unit)); return &(ctx->Texture.Unit[unit]); } diff --git a/mesalib/src/mesa/main/texstorage.c b/mesalib/src/mesa/main/texstorage.c index 3ace5e8bb..53cb2c091 100644 --- a/mesalib/src/mesa/main/texstorage.c +++ b/mesalib/src/mesa/main/texstorage.c @@ -171,7 +171,7 @@ clear_texture_fields(struct gl_context *ctx, GLint level; GLuint face; - for (level = 0; level < Elements(texObj->Image[0]); level++) { + for (level = 0; level < ARRAY_SIZE(texObj->Image[0]); level++) { for (face = 0; face < numFaces; face++) { struct gl_texture_image *texImage = get_tex_image(ctx, texObj, face, level); diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c index 7039cdf81..7ad9d2b68 100644 --- a/mesalib/src/mesa/main/texstore.c +++ b/mesalib/src/mesa/main/texstore.c @@ -154,9 +154,9 @@ _mesa_texstore_z32(TEXSTORE_PARAMS) const GLuint depthScale = 0xffffffff; GLenum dstType; (void) dims; - ASSERT(dstFormat == MESA_FORMAT_Z_UNORM32 || + assert(dstFormat == MESA_FORMAT_Z_UNORM32 || dstFormat == MESA_FORMAT_Z_FLOAT32); - ASSERT(_mesa_get_format_bytes(dstFormat) == sizeof(GLuint)); + assert(_mesa_get_format_bytes(dstFormat) == sizeof(GLuint)); if (dstFormat == MESA_FORMAT_Z_UNORM32) dstType = GL_UNSIGNED_INT; @@ -191,7 +191,7 @@ _mesa_texstore_x8_z24(TEXSTORE_PARAMS) const GLuint depthScale = 0xffffff; (void) dims; - ASSERT(dstFormat == MESA_FORMAT_Z24_UNORM_X8_UINT); + assert(dstFormat == MESA_FORMAT_Z24_UNORM_X8_UINT); { /* general path */ @@ -221,7 +221,7 @@ _mesa_texstore_z24_x8(TEXSTORE_PARAMS) const GLuint depthScale = 0xffffff; (void) dims; - ASSERT(dstFormat == MESA_FORMAT_X8_UINT_Z24_UNORM); + assert(dstFormat == MESA_FORMAT_X8_UINT_Z24_UNORM); { /* general path */ @@ -254,8 +254,8 @@ _mesa_texstore_z16(TEXSTORE_PARAMS) { const GLuint depthScale = 0xffff; (void) dims; - ASSERT(dstFormat == MESA_FORMAT_Z_UNORM16); - ASSERT(_mesa_get_format_bytes(dstFormat) == sizeof(GLushort)); + assert(dstFormat == MESA_FORMAT_Z_UNORM16); + assert(_mesa_get_format_bytes(dstFormat) == sizeof(GLushort)); { /* general path */ @@ -287,14 +287,14 @@ _mesa_texstore_ycbcr(TEXSTORE_PARAMS) (void) ctx; (void) dims; (void) baseInternalFormat; - ASSERT((dstFormat == MESA_FORMAT_YCBCR) || + assert((dstFormat == MESA_FORMAT_YCBCR) || (dstFormat == MESA_FORMAT_YCBCR_REV)); - ASSERT(_mesa_get_format_bytes(dstFormat) == 2); - ASSERT(ctx->Extensions.MESA_ycbcr_texture); - ASSERT(srcFormat == GL_YCBCR_MESA); - ASSERT((srcType == GL_UNSIGNED_SHORT_8_8_MESA) || + assert(_mesa_get_format_bytes(dstFormat) == 2); + assert(ctx->Extensions.MESA_ycbcr_texture); + assert(srcFormat == GL_YCBCR_MESA); + assert((srcType == GL_UNSIGNED_SHORT_8_8_MESA) || (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA)); - ASSERT(baseInternalFormat == GL_YCBCR_MESA); + assert(baseInternalFormat == GL_YCBCR_MESA); /* always just memcpy since no pixel transfer ops apply */ memcpy_texture(ctx, dims, @@ -335,11 +335,11 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS) GLuint *depth = malloc(srcWidth * sizeof(GLuint)); GLubyte *stencil = malloc(srcWidth * sizeof(GLubyte)); - ASSERT(dstFormat == MESA_FORMAT_S8_UINT_Z24_UNORM); - ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || + assert(dstFormat == MESA_FORMAT_S8_UINT_Z24_UNORM); + assert(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT || srcFormat == GL_STENCIL_INDEX); - ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || + assert(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT || srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); @@ -414,11 +414,11 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS) GLuint *depth; GLubyte *stencil; - ASSERT(dstFormat == MESA_FORMAT_Z24_UNORM_S8_UINT); - ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || + assert(dstFormat == MESA_FORMAT_Z24_UNORM_S8_UINT); + assert(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT || srcFormat == GL_STENCIL_INDEX); - ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || + assert(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT || srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); @@ -491,8 +491,8 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_s8(TEXSTORE_PARAMS) { - ASSERT(dstFormat == MESA_FORMAT_S_UINT8); - ASSERT(srcFormat == GL_STENCIL_INDEX); + assert(dstFormat == MESA_FORMAT_S_UINT8); + assert(srcFormat == GL_STENCIL_INDEX); { const GLint srcRowStride @@ -543,11 +543,11 @@ _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS) = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) / sizeof(uint64_t); - ASSERT(dstFormat == MESA_FORMAT_Z32_FLOAT_S8X24_UINT); - ASSERT(srcFormat == GL_DEPTH_STENCIL || + assert(dstFormat == MESA_FORMAT_Z32_FLOAT_S8X24_UINT); + assert(srcFormat == GL_DEPTH_STENCIL || srcFormat == GL_DEPTH_COMPONENT || srcFormat == GL_STENCIL_INDEX); - ASSERT(srcFormat != GL_DEPTH_STENCIL || + assert(srcFormat != GL_DEPTH_STENCIL || srcType == GL_UNSIGNED_INT_24_8 || srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); @@ -606,7 +606,7 @@ texstore_depth_stencil(TEXSTORE_PARAMS) initialized = GL_TRUE; } - ASSERT(table[dstFormat]); + assert(table[dstFormat]); return table[dstFormat](ctx, dims, baseInternalFormat, dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, @@ -666,7 +666,7 @@ texstore_compressed(TEXSTORE_PARAMS) initialized = GL_TRUE; } - ASSERT(table[dstFormat]); + assert(table[dstFormat]); return table[dstFormat](ctx, dims, baseInternalFormat, dstFormat, dstRowStride, dstSlices, srcWidth, srcHeight, srcDepth, @@ -1225,10 +1225,10 @@ _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims, * have to worry about the usual image unpacking or image transfer * operations. */ - ASSERT(texImage); - ASSERT(texImage->Width > 0); - ASSERT(texImage->Height > 0); - ASSERT(texImage->Depth > 0); + assert(texImage); + assert(texImage->Width > 0); + assert(texImage->Height > 0); + assert(texImage->Depth > 0); /* allocate storage for texture data */ if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage)) { diff --git a/mesalib/src/mesa/main/transformfeedback.c b/mesalib/src/mesa/main/transformfeedback.c index a73746335..a3e23ced5 100644 --- a/mesalib/src/mesa/main/transformfeedback.c +++ b/mesalib/src/mesa/main/transformfeedback.c @@ -93,7 +93,7 @@ reference_transform_feedback_object(struct gl_transform_feedback_object **ptr, /* Unreference the old object */ struct gl_transform_feedback_object *oldObj = *ptr; - ASSERT(oldObj->RefCount > 0); + assert(oldObj->RefCount > 0); oldObj->RefCount--; if (oldObj->RefCount == 0) { @@ -104,7 +104,7 @@ reference_transform_feedback_object(struct gl_transform_feedback_object **ptr, *ptr = NULL; } - ASSERT(!*ptr); + assert(!*ptr); if (obj) { /* reference new object */ @@ -143,7 +143,7 @@ void _mesa_init_transform_feedback(struct gl_context *ctx) { /* core mesa expects this, even a dummy one, to be available */ - ASSERT(ctx->Driver.NewTransformFeedback); + assert(ctx->Driver.NewTransformFeedback); ctx->TransformFeedback.DefaultObject = ctx->Driver.NewTransformFeedback(ctx, 0); @@ -185,7 +185,7 @@ void _mesa_free_transform_feedback(struct gl_context *ctx) { /* core mesa expects this, even a dummy one, to be available */ - ASSERT(ctx->Driver.NewTransformFeedback); + assert(ctx->Driver.NewTransformFeedback); _mesa_reference_buffer_object(ctx, &ctx->TransformFeedback.CurrentBuffer, @@ -235,7 +235,7 @@ delete_transform_feedback(struct gl_context *ctx, { GLuint i; - for (i = 0; i < Elements(obj->Buffers); i++) { + for (i = 0; i < ARRAY_SIZE(obj->Buffers); i++) { _mesa_reference_buffer_object(ctx, &obj->Buffers[i], NULL); } diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp index 40327fba4..9f82de952 100644 --- a/mesalib/src/mesa/main/uniform_query.cpp +++ b/mesalib/src/mesa/main/uniform_query.cpp @@ -762,7 +762,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, * been modified. */ bool changed = false; - for (unsigned j = 0; j < Elements(prog->SamplerUnits); j++) { + for (unsigned j = 0; j < ARRAY_SIZE(prog->SamplerUnits); j++) { if ((sh->active_samplers & (1U << j)) != 0 && (prog->SamplerUnits[j] != sh->SamplerUnits[j])) { changed = true; diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c index e471b878c..fb1482f9c 100644 --- a/mesalib/src/mesa/main/uniforms.c +++ b/mesalib/src/mesa/main/uniforms.c @@ -81,7 +81,7 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg, if (prog->SamplersUsed & (1 << s)) { GLuint unit = shader->SamplerUnits[s]; GLuint tgt = shader->SamplerTargets[s]; - assert(unit < Elements(prog->TexturesUsed)); + assert(unit < ARRAY_SIZE(prog->TexturesUsed)); assert(tgt < NUM_TEXTURE_TARGETS); /* The types of the samplers associated with a particular texture @@ -1142,6 +1142,8 @@ _mesa_GetActiveUniformBlockiv(GLuint program, return; case GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER: + if (!_mesa_has_geometry_shaders(ctx)) + break; params[0] = shProg->UniformBlockStageIndex[MESA_SHADER_GEOMETRY][uniformBlockIndex] != -1; return; diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c index 978ec7b53..42e7f89b2 100644 --- a/mesalib/src/mesa/main/varray.c +++ b/mesalib/src/mesa/main/varray.c @@ -24,6 +24,7 @@ */ +#include <stdio.h> #include <inttypes.h> /* for PRId64 macro */ #include "glheader.h" @@ -356,7 +357,7 @@ update_array_format(struct gl_context *ctx, return false; } - ASSERT(size <= 4); + assert(size <= 4); elementSize = _mesa_bytes_per_vertex_attrib(size, type); assert(elementSize != -1); @@ -714,7 +715,7 @@ _mesa_EnableVertexAttribArray(GLuint index) vao = ctx->Array.VAO; - ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(vao->VertexAttrib)); + assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib)); if (!vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) { /* was disabled, now being enabled */ @@ -740,7 +741,7 @@ _mesa_DisableVertexAttribArray(GLuint index) vao = ctx->Array.VAO; - ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(vao->VertexAttrib)); + assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib)); if (vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) { /* was enabled, now being disabled */ @@ -769,7 +770,7 @@ get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname, return 0; } - ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(vao->VertexAttrib)); + assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib)); array = &vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)]; @@ -834,7 +835,7 @@ get_current_attrib(struct gl_context *ctx, GLuint index, const char *function) return NULL; } - ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.VAO->VertexAttrib)); + assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(ctx->Array.VAO->VertexAttrib)); FLUSH_CURRENT(ctx, 0); return ctx->Current.Attrib[VERT_ATTRIB_GENERIC(index)]; @@ -956,7 +957,7 @@ _mesa_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer) return; } - ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.VAO->VertexAttrib)); + assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(ctx->Array.VAO->VertexAttrib)); *pointer = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Ptr; } @@ -1348,7 +1349,7 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor) return; } - ASSERT(genericIndex < Elements(ctx->Array.VAO->VertexAttrib)); + assert(genericIndex < ARRAY_SIZE(ctx->Array.VAO->VertexAttrib)); /* The ARB_vertex_attrib_binding spec says: * @@ -1802,8 +1803,8 @@ _mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex) return; } - ASSERT(VERT_ATTRIB_GENERIC(attribIndex) < - Elements(ctx->Array.VAO->VertexAttrib)); + assert(VERT_ATTRIB_GENERIC(attribIndex) < + ARRAY_SIZE(ctx->Array.VAO->VertexAttrib)); vertex_attrib_binding(ctx, VERT_ATTRIB_GENERIC(attribIndex), VERT_ATTRIB_GENERIC(bindingIndex)); diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c index 4951891cb..8e0c3ef5b 100644 --- a/mesalib/src/mesa/main/version.c +++ b/mesalib/src/mesa/main/version.c @@ -23,6 +23,7 @@ */ +#include <stdio.h> #include "imports.h" #include "mtypes.h" #include "version.h" diff --git a/mesalib/src/mesa/main/vtxfmt.h b/mesalib/src/mesa/main/vtxfmt.h index 34ade8905..4f8bc9cdf 100644 --- a/mesalib/src/mesa/main/vtxfmt.h +++ b/mesalib/src/mesa/main/vtxfmt.h @@ -33,11 +33,18 @@ #ifndef _VTXFMT_H_ #define _VTXFMT_H_ -#include "compiler.h" #include "mtypes.h" +#ifdef __cplusplus +extern "C" { +#endif + extern void _mesa_install_exec_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt ); extern void _mesa_install_save_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt ); extern void _mesa_initialize_vbo_vtxfmt(struct gl_context *ctx); +#ifdef __cplusplus +} // extern "C" +#endif + #endif /* _VTXFMT_H_ */ diff --git a/mesalib/src/mesa/math/m_debug_norm.c b/mesalib/src/mesa/math/m_debug_norm.c index 00e72be54..197b43cf2 100644 --- a/mesalib/src/mesa/math/m_debug_norm.c +++ b/mesalib/src/mesa/math/m_debug_norm.c @@ -26,6 +26,7 @@ * Gareth Hughes */ +#include "c99_math.h" #include "main/glheader.h" #include "main/context.h" #include "main/macros.h" @@ -165,7 +166,7 @@ static void ref_norm_transform_normalize( const GLmatrix *mat, /* Hmmm, don't know how we could test the precalculated * length case... */ - scale = INV_SQRTF( len ); + scale = 1.0f / sqrtf(len); SCALE_SCALAR_3V( out[i], scale, t ); } else { out[i][0] = out[i][1] = out[i][2] = 0; @@ -241,7 +242,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles ) ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 ); for ( j = 0 ; j < 3 ; j++ ) s[i][j] = rnd(); - length[i] = INV_SQRTF( LEN_SQUARED_3FV( s[i] ) ); + length[i] = 1.0f / sqrtf( LEN_SQUARED_3FV( s[i] ) ); } source->data = (GLfloat(*)[4]) s; diff --git a/mesalib/src/mesa/math/m_debug_util.h b/mesalib/src/mesa/math/m_debug_util.h index d05da8994..25ee029ce 100644 --- a/mesalib/src/mesa/math/m_debug_util.h +++ b/mesalib/src/mesa/math/m_debug_util.h @@ -32,6 +32,9 @@ #ifdef DEBUG_MATH /* This code only used for debugging */ +#include "c99_math.h" + + /* Comment this out to deactivate the cycle counter. * NOTE: it works only on CPUs which know the 'rdtsc' command (586 or higher) * (hope, you don't try to debug Mesa on a 386 ;) @@ -286,9 +289,9 @@ static int significand_match( GLfloat a, GLfloat b ) return 0; } - FREXPF( a, &a_ex ); - FREXPF( b, &b_ex ); - FREXPF( d, &d_ex ); + frexpf( a, &a_ex ); + frexpf( b, &b_ex ); + frexpf( d, &d_ex ); if ( a_ex < b_ex ) { return a_ex - d_ex; diff --git a/mesalib/src/mesa/math/m_debug_xform.c b/mesalib/src/mesa/math/m_debug_xform.c index f56b4cfc7..632c82ea2 100644 --- a/mesalib/src/mesa/math/m_debug_xform.c +++ b/mesalib/src/mesa/math/m_debug_xform.c @@ -187,7 +187,7 @@ static int test_transform_function( transform_func func, int psize, mat->type = mtypes[mtype]; m = mat->m; - ASSERT( ((long)m & 15) == 0 ); + assert( ((long)m & 15) == 0 ); init_matrix( m ); @@ -206,7 +206,7 @@ static int test_transform_function( transform_func func, int psize, case VAR: break; default: - ASSERT(0); + assert(0); return 0; } } diff --git a/mesalib/src/mesa/math/m_matrix.c b/mesalib/src/mesa/math/m_matrix.c index 9c9310d93..0475a7ab2 100644 --- a/mesalib/src/mesa/math/m_matrix.c +++ b/mesalib/src/mesa/math/m_matrix.c @@ -34,6 +34,7 @@ */ +#include "c99_math.h" #include "main/glheader.h" #include "main/imports.h" #include "main/macros.h" @@ -376,9 +377,9 @@ static GLboolean invert_matrix_general( GLmatrix *mat ) r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0; /* choose pivot - or die */ - if (FABSF(r3[0])>FABSF(r2[0])) SWAP_ROWS(r3, r2); - if (FABSF(r2[0])>FABSF(r1[0])) SWAP_ROWS(r2, r1); - if (FABSF(r1[0])>FABSF(r0[0])) SWAP_ROWS(r1, r0); + if (fabsf(r3[0])>fabsf(r2[0])) SWAP_ROWS(r3, r2); + if (fabsf(r2[0])>fabsf(r1[0])) SWAP_ROWS(r2, r1); + if (fabsf(r1[0])>fabsf(r0[0])) SWAP_ROWS(r1, r0); if (0.0 == r0[0]) return GL_FALSE; /* eliminate first variable */ @@ -396,8 +397,8 @@ static GLboolean invert_matrix_general( GLmatrix *mat ) if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; } /* choose pivot - or die */ - if (FABSF(r3[1])>FABSF(r2[1])) SWAP_ROWS(r3, r2); - if (FABSF(r2[1])>FABSF(r1[1])) SWAP_ROWS(r2, r1); + if (fabsf(r3[1])>fabsf(r2[1])) SWAP_ROWS(r3, r2); + if (fabsf(r2[1])>fabsf(r1[1])) SWAP_ROWS(r2, r1); if (0.0 == r1[1]) return GL_FALSE; /* eliminate second variable */ @@ -410,7 +411,7 @@ static GLboolean invert_matrix_general( GLmatrix *mat ) s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; } /* choose pivot - or die */ - if (FABSF(r3[2])>FABSF(r2[2])) SWAP_ROWS(r3, r2); + if (fabsf(r3[2])>fabsf(r2[2])) SWAP_ROWS(r3, r2); if (0.0 == r2[2]) return GL_FALSE; /* eliminate third variable */ @@ -508,7 +509,7 @@ static GLboolean invert_matrix_3d_general( GLmatrix *mat ) det = pos + neg; - if (FABSF(det) < 1e-25) + if (fabsf(det) < 1e-25) return GL_FALSE; det = 1.0F / det; @@ -798,8 +799,8 @@ _math_matrix_rotate( GLmatrix *mat, GLfloat m[16]; GLboolean optimized; - s = (GLfloat) sin( angle * DEG2RAD ); - c = (GLfloat) cos( angle * DEG2RAD ); + s = (GLfloat) sin( angle * M_PI / 180.0 ); + c = (GLfloat) cos( angle * M_PI / 180.0 ); memcpy(m, Identity, sizeof(GLfloat)*16); optimized = GL_FALSE; @@ -1069,7 +1070,7 @@ _math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z ) m[2] *= x; m[6] *= y; m[10] *= z; m[3] *= x; m[7] *= y; m[11] *= z; - if (FABSF(x - y) < 1e-8 && FABSF(x - z) < 1e-8) + if (fabsf(x - y) < 1e-8 && fabsf(x - z) < 1e-8) mat->flags |= MAT_FLAG_UNIFORM_SCALE; else mat->flags |= MAT_FLAG_GENERAL_SCALE; diff --git a/mesalib/src/mesa/math/m_norm_tmp.h b/mesalib/src/mesa/math/m_norm_tmp.h index 339c03ff8..c8fab0ed3 100644 --- a/mesalib/src/mesa/math/m_norm_tmp.h +++ b/mesalib/src/mesa/math/m_norm_tmp.h @@ -68,7 +68,7 @@ TAG(transform_normalize_normals)( const GLmatrix *mat, { GLdouble len = tx*tx + ty*ty + tz*tz; if (len > 1e-20) { - GLfloat scale = INV_SQRTF(len); + GLfloat scale = 1.0f / sqrtf(len); out[i][0] = tx * scale; out[i][1] = ty * scale; out[i][2] = tz * scale; @@ -135,7 +135,7 @@ TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat, { GLdouble len = tx*tx + ty*ty + tz*tz; if (len > 1e-20) { - GLfloat scale = INV_SQRTF(len); + GLfloat scale = 1.0f / sqrtf(len); out[i][0] = tx * scale; out[i][1] = ty * scale; out[i][2] = tz * scale; @@ -322,7 +322,7 @@ TAG(normalize_normals)( const GLmatrix *mat, const GLfloat x = from[0], y = from[1], z = from[2]; GLdouble len = x * x + y * y + z * z; if (len > 1e-50) { - len = INV_SQRTF(len); + len = 1.0f / sqrtf(len); out[i][0] = (GLfloat)(x * len); out[i][1] = (GLfloat)(y * len); out[i][2] = (GLfloat)(z * len); diff --git a/mesalib/src/mesa/math/m_trans_tmp.h b/mesalib/src/mesa/math/m_trans_tmp.h index f39a3c83a..0a8bfc538 100644 --- a/mesalib/src/mesa/math/m_trans_tmp.h +++ b/mesalib/src/mesa/math/m_trans_tmp.h @@ -40,13 +40,11 @@ static void DEST_4F( GLfloat (*t)[4], (void) first; (void) start; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) t[i][0] = TRX_4F(f, 0); - if (SZ >= 2) t[i][1] = TRX_4F(f, 1); - if (SZ >= 3) t[i][2] = TRX_4F(f, 2); - if (SZ == 4) t[i][3] = TRX_4F(f, 3); else t[i][3] = 1.0; - } + NEXT_F2; + if (SZ >= 1) t[i][0] = TRX_4F(f, 0); + if (SZ >= 2) t[i][1] = TRX_4F(f, 1); + if (SZ >= 3) t[i][2] = TRX_4F(f, 2); + if (SZ == 4) t[i][3] = TRX_4F(f, 3); else t[i][3] = 1.0; } } #endif @@ -66,13 +64,11 @@ static void DEST_4FN( GLfloat (*t)[4], (void) first; (void) start; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) t[i][0] = TRX_4FN(f, 0); - if (SZ >= 2) t[i][1] = TRX_4FN(f, 1); - if (SZ >= 3) t[i][2] = TRX_4FN(f, 2); - if (SZ == 4) t[i][3] = TRX_4FN(f, 3); else t[i][3] = 1.0; - } + NEXT_F2; + if (SZ >= 1) t[i][0] = TRX_4FN(f, 0); + if (SZ >= 2) t[i][1] = TRX_4FN(f, 1); + if (SZ >= 3) t[i][2] = TRX_4FN(f, 2); + if (SZ == 4) t[i][3] = TRX_4FN(f, 3); else t[i][3] = 1.0; } } #endif @@ -90,12 +86,10 @@ static void DEST_3FN( GLfloat (*t)[3], (void) first; (void) start; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - t[i][0] = TRX_3FN(f, 0); - t[i][1] = TRX_3FN(f, 1); - t[i][2] = TRX_3FN(f, 2); - } + NEXT_F2; + t[i][0] = TRX_3FN(f, 0); + t[i][1] = TRX_3FN(f, 1); + t[i][2] = TRX_3FN(f, 2); } } #endif @@ -112,10 +106,8 @@ static void DEST_1F( GLfloat *t, (void) first; (void) start; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - t[i] = TRX_1F(f, 0); - } + NEXT_F2; + t[i] = TRX_1F(f, 0); } } #endif @@ -132,13 +124,11 @@ static void DEST_4UB( GLubyte (*t)[4], (void) start; (void) first; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) TRX_UB(t[i][0], f, 0); - if (SZ >= 2) TRX_UB(t[i][1], f, 1); - if (SZ >= 3) TRX_UB(t[i][2], f, 2); - if (SZ == 4) TRX_UB(t[i][3], f, 3); else t[i][3] = 255; - } + NEXT_F2; + if (SZ >= 1) TRX_UB(t[i][0], f, 0); + if (SZ >= 2) TRX_UB(t[i][1], f, 1); + if (SZ >= 3) TRX_UB(t[i][2], f, 2); + if (SZ == 4) TRX_UB(t[i][3], f, 3); else t[i][3] = 255; } } #endif @@ -156,13 +146,11 @@ static void DEST_4US( GLushort (*t)[4], (void) start; (void) first; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) TRX_US(t[i][0], f, 0); - if (SZ >= 2) TRX_US(t[i][1], f, 1); - if (SZ >= 3) TRX_US(t[i][2], f, 2); - if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535; - } + NEXT_F2; + if (SZ >= 1) TRX_US(t[i][0], f, 0); + if (SZ >= 2) TRX_US(t[i][1], f, 1); + if (SZ >= 3) TRX_US(t[i][2], f, 2); + if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535; } } #endif @@ -180,10 +168,8 @@ static void DEST_1UB( GLubyte *t, (void) start; (void) first; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - TRX_UB(t[i], f, 0); - } + NEXT_F2; + TRX_UB(t[i], f, 0); } } #endif @@ -202,10 +188,8 @@ static void DEST_1UI( GLuint *t, (void) first; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - t[i] = TRX_UI(f, 0); - } + NEXT_F2; + t[i] = TRX_UI(f, 0); } } #endif @@ -214,19 +198,19 @@ static void DEST_1UI( GLuint *t, static void INIT(void) { #ifdef DEST_1UI - ASSERT(SZ == 1); + assert(SZ == 1); TAB(_1ui)[SRC_IDX] = DEST_1UI; #endif #ifdef DEST_1UB - ASSERT(SZ == 1); + assert(SZ == 1); TAB(_1ub)[SRC_IDX] = DEST_1UB; #endif #ifdef DEST_1F - ASSERT(SZ == 1); + assert(SZ == 1); TAB(_1f)[SRC_IDX] = DEST_1F; #endif #ifdef DEST_3FN - ASSERT(SZ == 3); + assert(SZ == 3); TAB(_3fn)[SRC_IDX] = DEST_3FN; #endif #ifdef DEST_4UB diff --git a/mesalib/src/mesa/math/m_translate.c b/mesalib/src/mesa/math/m_translate.c index 3a8ca74f6..a5bf5d76f 100644 --- a/mesalib/src/mesa/math/m_translate.c +++ b/mesalib/src/mesa/math/m_translate.c @@ -84,10 +84,6 @@ typedef void (*trans_3fn_func)(GLfloat (*to)[3], #define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */ -/* This macro is used on other systems, so undefine it for this module */ - -#undef CHECK - static trans_1f_func _math_trans_1f_tab[MAX_TYPES]; static trans_1ui_func _math_trans_1ui_tab[MAX_TYPES]; static trans_1ub_func _math_trans_1ub_tab[MAX_TYPES]; @@ -108,7 +104,6 @@ static trans_4f_func _math_trans_4fn_tab[5][MAX_TYPES]; #define STRIDE stride #define NEXT_F f += stride #define NEXT_F2 -#define CHECK @@ -604,7 +599,6 @@ static void init_translate_raw(void) #undef CLASS #endif #undef ARGS -#undef CHECK #undef SRC_START #undef DST_START #undef NEXT_F diff --git a/mesalib/src/mesa/math/m_translate.h b/mesalib/src/mesa/math/m_translate.h index bdfa4c770..62f676ca6 100644 --- a/mesalib/src/mesa/math/m_translate.h +++ b/mesalib/src/mesa/math/m_translate.h @@ -26,7 +26,6 @@ #ifndef _M_TRANSLATE_H_ #define _M_TRANSLATE_H_ -#include "main/compiler.h" #include "main/glheader.h" /** diff --git a/mesalib/src/mesa/math/m_vector.c b/mesalib/src/mesa/math/m_vector.c index ff42396b7..831f953d6 100644 --- a/mesalib/src/mesa/math/m_vector.c +++ b/mesalib/src/mesa/math/m_vector.c @@ -26,6 +26,7 @@ * New (3.1) transformation code written by Keith Whitwell. */ +#include <stdio.h> #include "main/glheader.h" #include "main/imports.h" diff --git a/mesalib/src/mesa/math/m_xform.c b/mesalib/src/mesa/math/m_xform.c index 14d1c6453..718ad4993 100644 --- a/mesalib/src/mesa/math/m_xform.c +++ b/mesalib/src/mesa/math/m_xform.c @@ -33,6 +33,7 @@ * 3. Transformation of a point p by a matrix M is: p' = M * p */ +#include "c99_math.h" #include "main/glheader.h" #include "main/macros.h" diff --git a/mesalib/src/mesa/math/m_xform.h b/mesalib/src/mesa/math/m_xform.h index e45880322..2ed62e711 100644 --- a/mesalib/src/mesa/math/m_xform.h +++ b/mesalib/src/mesa/math/m_xform.h @@ -119,7 +119,7 @@ typedef void (*vec_copy_func)( GLvector4f *to, /* * Functions for transformation of normals in the VB. */ -typedef void (_NORMAPIP normal_func)( const GLmatrix *mat, +typedef void (_XFORMAPIP normal_func)( const GLmatrix *mat, GLfloat scale, const GLvector4f *in, const GLfloat lengths[], diff --git a/mesalib/src/mesa/program/arbprogparse.c b/mesalib/src/mesa/program/arbprogparse.c index 53a6f37cb..3ddaeca8a 100644 --- a/mesalib/src/mesa/program/arbprogparse.c +++ b/mesalib/src/mesa/program/arbprogparse.c @@ -73,7 +73,7 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target, struct asm_parser_state state; GLuint i; - ASSERT(target == GL_FRAGMENT_PROGRAM_ARB); + assert(target == GL_FRAGMENT_PROGRAM_ARB); memset(&prog, 0, sizeof(prog)); memset(&state, 0, sizeof(state)); @@ -166,7 +166,7 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target, struct gl_program prog; struct asm_parser_state state; - ASSERT(target == GL_VERTEX_PROGRAM_ARB); + assert(target == GL_VERTEX_PROGRAM_ARB); memset(&prog, 0, sizeof(prog)); memset(&state, 0, sizeof(state)); diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp index b2776da45..39790ec8e 100644 --- a/mesalib/src/mesa/program/ir_to_mesa.cpp +++ b/mesalib/src/mesa/program/ir_to_mesa.cpp @@ -1018,7 +1018,7 @@ void ir_to_mesa_visitor::visit(ir_expression *ir) { unsigned int operand; - src_reg op[Elements(ir->operands)]; + src_reg op[ARRAY_SIZE(ir->operands)]; src_reg result_src; dst_reg result_dst; diff --git a/mesalib/src/mesa/program/prog_execute.c b/mesalib/src/mesa/program/prog_execute.c index b2fbc808a..dc4919ae8 100644 --- a/mesalib/src/mesa/program/prog_execute.c +++ b/mesalib/src/mesa/program/prog_execute.c @@ -35,6 +35,7 @@ */ +#include "c99_math.h" #include "main/glheader.h" #include "main/colormac.h" #include "main/macros.h" @@ -123,7 +124,7 @@ get_src_register_pointer(const struct prog_src_register *source, return (GLfloat *) prog->Parameters->ParameterValues[reg]; case PROGRAM_SYSTEM_VALUE: - assert(reg < (GLint) Elements(machine->SystemValues)); + assert(reg < (GLint) ARRAY_SIZE(machine->SystemValues)); return machine->SystemValues[reg]; default: @@ -190,10 +191,10 @@ fetch_vector4(const struct prog_src_register *source, COPY_4V(result, src); } else { - ASSERT(GET_SWZ(source->Swizzle, 0) <= 3); - ASSERT(GET_SWZ(source->Swizzle, 1) <= 3); - ASSERT(GET_SWZ(source->Swizzle, 2) <= 3); - ASSERT(GET_SWZ(source->Swizzle, 3) <= 3); + assert(GET_SWZ(source->Swizzle, 0) <= 3); + assert(GET_SWZ(source->Swizzle, 1) <= 3); + assert(GET_SWZ(source->Swizzle, 2) <= 3); + assert(GET_SWZ(source->Swizzle, 3) <= 3); result[0] = src[GET_SWZ(source->Swizzle, 0)]; result[1] = src[GET_SWZ(source->Swizzle, 1)]; result[2] = src[GET_SWZ(source->Swizzle, 2)]; @@ -201,13 +202,13 @@ fetch_vector4(const struct prog_src_register *source, } if (source->Abs) { - result[0] = FABSF(result[0]); - result[1] = FABSF(result[1]); - result[2] = FABSF(result[2]); - result[3] = FABSF(result[3]); + result[0] = fabsf(result[0]); + result[1] = fabsf(result[1]); + result[2] = fabsf(result[2]); + result[3] = fabsf(result[3]); } if (source->Negate) { - ASSERT(source->Negate == NEGATE_XYZW); + assert(source->Negate == NEGATE_XYZW); result[0] = -result[0]; result[1] = -result[1]; result[2] = -result[2]; @@ -259,13 +260,13 @@ fetch_vector4_deriv(struct gl_context * ctx, result[3] = deriv[GET_SWZ(source->Swizzle, 3)]; if (source->Abs) { - result[0] = FABSF(result[0]); - result[1] = FABSF(result[1]); - result[2] = FABSF(result[2]); - result[3] = FABSF(result[3]); + result[0] = fabsf(result[0]); + result[1] = fabsf(result[1]); + result[2] = fabsf(result[2]); + result[3] = fabsf(result[3]); } if (source->Negate) { - ASSERT(source->Negate == NEGATE_XYZW); + assert(source->Negate == NEGATE_XYZW); result[0] = -result[0]; result[1] = -result[1]; result[2] = -result[2]; @@ -290,7 +291,7 @@ fetch_vector1(const struct prog_src_register *source, result[0] = src[GET_SWZ(source->Swizzle, 0)]; if (source->Abs) { - result[0] = FABSF(result[0]); + result[0] = fabsf(result[0]); } if (source->Negate) { result[0] = -result[0]; @@ -520,10 +521,10 @@ _mesa_execute_program(struct gl_context * ctx, { GLfloat a[4], result[4]; fetch_vector4(&inst->SrcReg[0], machine, a); - result[0] = FABSF(a[0]); - result[1] = FABSF(a[1]); - result[2] = FABSF(a[2]); - result[3] = FABSF(a[3]); + result[0] = fabsf(a[0]); + result[1] = fabsf(a[1]); + result[2] = fabsf(a[2]); + result[3] = fabsf(a[3]); store_vector4(inst, machine, result); } break; @@ -556,12 +557,12 @@ _mesa_execute_program(struct gl_context * ctx, break; case OPCODE_BGNLOOP: /* no-op */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode + assert(program->Instructions[inst->BranchTarget].Opcode == OPCODE_ENDLOOP); break; case OPCODE_ENDLOOP: /* subtract 1 here since pc is incremented by for(pc) loop */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode + assert(program->Instructions[inst->BranchTarget].Opcode == OPCODE_BGNLOOP); pc = inst->BranchTarget - 1; /* go to matching BNGLOOP */ break; @@ -570,7 +571,7 @@ _mesa_execute_program(struct gl_context * ctx, case OPCODE_ENDSUB: /* end subroutine */ break; case OPCODE_BRK: /* break out of loop (conditional) */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode + assert(program->Instructions[inst->BranchTarget].Opcode == OPCODE_ENDLOOP); if (eval_condition(machine, inst)) { /* break out of loop */ @@ -579,7 +580,7 @@ _mesa_execute_program(struct gl_context * ctx, } break; case OPCODE_CONT: /* continue loop (conditional) */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode + assert(program->Instructions[inst->BranchTarget].Opcode == OPCODE_ENDLOOP); if (eval_condition(machine, inst)) { /* continue at ENDLOOP */ @@ -708,7 +709,7 @@ _mesa_execute_program(struct gl_context * ctx, { GLfloat t[4], q[4], floor_t0; fetch_vector1(&inst->SrcReg[0], machine, t); - floor_t0 = FLOORF(t[0]); + floor_t0 = floorf(t[0]); if (floor_t0 > FLT_MAX_EXP) { SET_POS_INFINITY(q[0]); SET_POS_INFINITY(q[2]); @@ -718,7 +719,7 @@ _mesa_execute_program(struct gl_context * ctx, q[2] = 0.0F; } else { - q[0] = LDEXPF(1.0, (int) floor_t0); + q[0] = ldexpf(1.0, (int) floor_t0); /* Note: GL_NV_vertex_program expects * result.z = result.x * APPX(result.y) * We do what the ARB extension says. @@ -747,10 +748,10 @@ _mesa_execute_program(struct gl_context * ctx, { GLfloat a[4], result[4]; fetch_vector4(&inst->SrcReg[0], machine, a); - result[0] = FLOORF(a[0]); - result[1] = FLOORF(a[1]); - result[2] = FLOORF(a[2]); - result[3] = FLOORF(a[3]); + result[0] = floorf(a[0]); + result[1] = floorf(a[1]); + result[2] = floorf(a[2]); + result[3] = floorf(a[3]); store_vector4(inst, machine, result); } break; @@ -758,17 +759,17 @@ _mesa_execute_program(struct gl_context * ctx, { GLfloat a[4], result[4]; fetch_vector4(&inst->SrcReg[0], machine, a); - result[0] = a[0] - FLOORF(a[0]); - result[1] = a[1] - FLOORF(a[1]); - result[2] = a[2] - FLOORF(a[2]); - result[3] = a[3] - FLOORF(a[3]); + result[0] = a[0] - floorf(a[0]); + result[1] = a[1] - floorf(a[1]); + result[2] = a[2] - floorf(a[2]); + result[3] = a[3] - floorf(a[3]); store_vector4(inst, machine, result); } break; case OPCODE_IF: { GLboolean cond; - ASSERT(program->Instructions[inst->BranchTarget].Opcode + assert(program->Instructions[inst->BranchTarget].Opcode == OPCODE_ELSE || program->Instructions[inst->BranchTarget].Opcode == OPCODE_ENDIF); @@ -797,7 +798,7 @@ _mesa_execute_program(struct gl_context * ctx, break; case OPCODE_ELSE: /* goto ENDIF */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode + assert(program->Instructions[inst->BranchTarget].Opcode == OPCODE_ENDIF); assert(inst->BranchTarget >= 0); pc = inst->BranchTarget; @@ -874,7 +875,7 @@ _mesa_execute_program(struct gl_context * ctx, { GLfloat t[4], q[4], abs_t0; fetch_vector1(&inst->SrcReg[0], machine, t); - abs_t0 = FABSF(t[0]); + abs_t0 = fabsf(t[0]); if (abs_t0 != 0.0F) { if (IS_INF_OR_NAN(abs_t0)) { @@ -884,7 +885,7 @@ _mesa_execute_program(struct gl_context * ctx, } else { int exponent; - GLfloat mantissa = FREXPF(t[0], &exponent); + GLfloat mantissa = frexpf(t[0], &exponent); q[0] = (GLfloat) (exponent - 1); q[1] = (GLfloat) (2.0 * mantissa); /* map [.5, 1) -> [1, 2) */ @@ -1083,8 +1084,8 @@ _mesa_execute_program(struct gl_context * ctx, { GLfloat a[4], result[4]; fetch_vector1(&inst->SrcReg[0], machine, a); - a[0] = FABSF(a[0]); - result[0] = result[1] = result[2] = result[3] = INV_SQRTF(a[0]); + a[0] = fabsf(a[0]); + result[0] = result[1] = result[2] = result[3] = 1.0f / sqrtf(a[0]); store_vector4(inst, machine, result); if (DEBUG_PROG) { printf("RSQ %g = 1/sqrt(|%g|)\n", result[0], a[0]); @@ -1260,7 +1261,7 @@ _mesa_execute_program(struct gl_context * ctx, else if (swz == SWIZZLE_ONE) result[i] = 1.0; else { - ASSERT(swz <= 3); + assert(swz <= 3); result[i] = src[swz]; } if (source->Negate & (1 << i)) @@ -1357,7 +1358,7 @@ _mesa_execute_program(struct gl_context * ctx, fetch_vector4(&inst->SrcReg[0], machine, texcoord); /* Not so sure about this test - if texcoord[3] is - * zero, we'd probably be fine except for an ASSERT in + * zero, we'd probably be fine except for an assert in * IROUND_POS() which gets triggered by the inf values created. */ if (texcoord[3] != 0.0) { diff --git a/mesalib/src/mesa/program/prog_instruction.c b/mesalib/src/mesa/program/prog_instruction.c index 254c0128f..6a9bcb7b5 100644 --- a/mesalib/src/mesa/program/prog_instruction.c +++ b/mesalib/src/mesa/program/prog_instruction.c @@ -200,9 +200,9 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = { GLuint _mesa_num_inst_src_regs(gl_inst_opcode opcode) { - ASSERT(opcode < MAX_OPCODE); - ASSERT(opcode == InstInfo[opcode].Opcode); - ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); + assert(opcode < MAX_OPCODE); + assert(opcode == InstInfo[opcode].Opcode); + assert(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); return InstInfo[opcode].NumSrcRegs; } @@ -213,9 +213,9 @@ _mesa_num_inst_src_regs(gl_inst_opcode opcode) GLuint _mesa_num_inst_dst_regs(gl_inst_opcode opcode) { - ASSERT(opcode < MAX_OPCODE); - ASSERT(opcode == InstInfo[opcode].Opcode); - ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); + assert(opcode < MAX_OPCODE); + assert(opcode == InstInfo[opcode].Opcode); + assert(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); return InstInfo[opcode].NumDstRegs; } diff --git a/mesalib/src/mesa/program/prog_optimize.c b/mesalib/src/mesa/program/prog_optimize.c index 65d427cb4..6d4485acb 100644 --- a/mesalib/src/mesa/program/prog_optimize.c +++ b/mesalib/src/mesa/program/prog_optimize.c @@ -57,7 +57,7 @@ get_src_arg_mask(const struct prog_instruction *inst, GLuint read_mask, channel_mask; GLuint comp; - ASSERT(arg < _mesa_num_inst_src_regs(inst->Opcode)); + assert(arg < _mesa_num_inst_src_regs(inst->Opcode)); /* Form the dst register, find the written channels */ if (inst->CondUpdate) { @@ -133,7 +133,7 @@ get_dst_mask_for_mov(const struct prog_instruction *mov, GLuint src_mask) GLuint comp; GLuint updated_mask = 0x0; - ASSERT(mov->Opcode == OPCODE_MOV); + assert(mov->Opcode == OPCODE_MOV); for (comp = 0; comp < 4; ++comp) { GLuint src_comp; @@ -225,13 +225,13 @@ replace_regs(struct gl_program *prog, gl_register_file file, const GLint map[]) for (j = 0; j < numSrc; j++) { if (inst->SrcReg[j].File == file) { GLuint index = inst->SrcReg[j].Index; - ASSERT(map[index] >= 0); + assert(map[index] >= 0); inst->SrcReg[j].Index = map[index]; } } if (inst->DstReg.File == file) { const GLuint index = inst->DstReg.Index; - ASSERT(map[index] >= 0); + assert(map[index] >= 0); inst->DstReg.Index = map[index]; } } @@ -272,7 +272,7 @@ _mesa_remove_dead_code_global(struct gl_program *prog) if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) { const GLuint index = inst->SrcReg[j].Index; GLuint read_mask; - ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); + assert(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); read_mask = get_src_arg_mask(inst, j, NO_MASK); if (inst->SrcReg[j].RelAddr) { @@ -295,7 +295,7 @@ _mesa_remove_dead_code_global(struct gl_program *prog) /* check dst reg */ if (inst->DstReg.File == PROGRAM_TEMPORARY) { const GLuint index = inst->DstReg.Index; - ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); + assert(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); if (inst->DstReg.RelAddr) { if (dbg) @@ -676,7 +676,7 @@ _mesa_merge_mov_into_inst(struct prog_instruction *inst, for (dst_comp = 0; dst_comp < 4; ++dst_comp) { if (mov->DstReg.WriteMask & (1 << dst_comp)) { const GLuint src_comp = GET_SWZ(mov->SrcReg[0].Swizzle, dst_comp); - ASSERT(src_comp < 4); + assert(src_comp < 4); dst_to_src_comp[dst_comp] = src_comp; } } @@ -692,9 +692,9 @@ _mesa_merge_mov_into_inst(struct prog_instruction *inst, if ((mov->DstReg.WriteMask & (1 << dst_comp)) == 0) continue; src_comp = dst_to_src_comp[dst_comp]; - ASSERT(src_comp < 4); + assert(src_comp < 4); arg_comp = GET_SWZ(arg_swz, src_comp); - ASSERT(arg_comp < 4); + assert(arg_comp < 4); inst->SrcReg[arg].Swizzle |= arg_comp << (3*dst_comp); } } @@ -871,7 +871,7 @@ insert_interval_by_end(struct interval_list *list, const struct interval *inv) { GLuint i; for (i = 0; i + 1 < list->Num; i++) { - ASSERT(list->Intervals[i].End <= list->Intervals[i + 1].End); + assert(list->Intervals[i].End <= list->Intervals[i + 1].End); } } #endif @@ -887,8 +887,8 @@ remove_interval(struct interval_list *list, const struct interval *inv) for (k = 0; k < list->Num; k++) { if (list->Intervals[k].Reg == inv->Reg) { /* found, remove it */ - ASSERT(list->Intervals[k].Start == inv->Start); - ASSERT(list->Intervals[k].End == inv->End); + assert(list->Intervals[k].Start == inv->Start); + assert(list->Intervals[k].End == inv->End); while (k < list->Num - 1) { list->Intervals[k] = list->Intervals[k + 1]; k++; @@ -924,7 +924,7 @@ sort_interval_list_by_start(struct interval_list *list) { GLuint i; for (i = 0; i + 1 < list->Num; i++) { - ASSERT(list->Intervals[i].Start <= list->Intervals[i + 1].Start); + assert(list->Intervals[i].Start <= list->Intervals[i + 1].Start); } } #endif @@ -966,9 +966,9 @@ update_interval(GLint intBegin[], GLint intEnd[], begin = loopStack[0].Start; } - ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); + assert(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); if (intBegin[index] == -1) { - ASSERT(intEnd[index] == -1); + assert(intEnd[index] == -1); intBegin[index] = begin; intEnd[index] = end; } @@ -1176,7 +1176,7 @@ _mesa_reallocate_registers(struct gl_program *prog) else { /* Interval 'inv' has expired */ const GLint regNew = registerMap[inv->Reg]; - ASSERT(regNew >= 0); + assert(regNew >= 0); if (dbg) printf(" expire interval for reg %u\n", inv->Reg); @@ -1188,7 +1188,7 @@ _mesa_reallocate_registers(struct gl_program *prog) /* return register regNew to the free pool */ if (dbg) printf(" free reg %d\n", regNew); - ASSERT(usedRegs[regNew] == GL_TRUE); + assert(usedRegs[regNew] == GL_TRUE); usedRegs[regNew] = GL_FALSE; } } diff --git a/mesalib/src/mesa/program/prog_parameter.c b/mesalib/src/mesa/program/prog_parameter.c index 0ef46415d..5939f6f72 100644 --- a/mesalib/src/mesa/program/prog_parameter.c +++ b/mesalib/src/mesa/program/prog_parameter.c @@ -241,8 +241,8 @@ _mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList, GLenum datatype, GLuint *swizzleOut) { GLint pos; - ASSERT(size >= 1); - ASSERT(size <= 4); + assert(size >= 1); + assert(size <= 4); if (swizzleOut && _mesa_lookup_parameter_constant(paramList, values, @@ -528,7 +528,7 @@ _mesa_clone_parameter_list(const struct gl_program_parameter_list *list) GLuint size = MIN2(p->Size, 4); GLint j = _mesa_add_parameter(clone, p->Type, p->Name, size, p->DataType, list->ParameterValues[i], NULL); - ASSERT(j >= 0); + assert(j >= 0); pCopy = clone->Parameters + j; /* copy state indexes */ if (p->Type == PROGRAM_STATE_VAR) { diff --git a/mesalib/src/mesa/program/prog_parameter_layout.c b/mesalib/src/mesa/program/prog_parameter_layout.c index e83469059..282a367ad 100644 --- a/mesalib/src/mesa/program/prog_parameter_layout.c +++ b/mesalib/src/mesa/program/prog_parameter_layout.c @@ -28,7 +28,7 @@ * \author Ian Romanick <ian.d.romanick@intel.com> */ -#include "main/compiler.h" +#include "main/imports.h" #include "main/mtypes.h" #include "prog_parameter.h" #include "prog_parameter_layout.h" diff --git a/mesalib/src/mesa/program/prog_print.c b/mesalib/src/mesa/program/prog_print.c index 3f499749a..d588d07ff 100644 --- a/mesalib/src/mesa/program/prog_print.c +++ b/mesalib/src/mesa/program/prog_print.c @@ -182,20 +182,20 @@ arb_input_attrib_string(GLuint index, GLenum progType) }; /* sanity checks */ - STATIC_ASSERT(Elements(vertAttribs) == VERT_ATTRIB_MAX); - STATIC_ASSERT(Elements(fragAttribs) == VARYING_SLOT_MAX); + STATIC_ASSERT(ARRAY_SIZE(vertAttribs) == VERT_ATTRIB_MAX); + STATIC_ASSERT(ARRAY_SIZE(fragAttribs) == VARYING_SLOT_MAX); assert(strcmp(vertAttribs[VERT_ATTRIB_TEX0], "vertex.texcoord[0]") == 0); assert(strcmp(vertAttribs[VERT_ATTRIB_GENERIC15], "vertex.attrib[15]") == 0); assert(strcmp(fragAttribs[VARYING_SLOT_TEX0], "fragment.texcoord[0]") == 0); assert(strcmp(fragAttribs[VARYING_SLOT_VAR0+15], "fragment.varying[15]") == 0); if (progType == GL_VERTEX_PROGRAM_ARB) { - assert(index < Elements(vertAttribs)); + assert(index < ARRAY_SIZE(vertAttribs)); return vertAttribs[index]; } else { assert(progType == GL_FRAGMENT_PROGRAM_ARB); - assert(index < Elements(fragAttribs)); + assert(index < ARRAY_SIZE(fragAttribs)); return fragAttribs[index]; } } @@ -321,19 +321,19 @@ arb_output_attrib_string(GLuint index, GLenum progType) }; /* sanity checks */ - STATIC_ASSERT(Elements(vertResults) == VARYING_SLOT_MAX); - STATIC_ASSERT(Elements(fragResults) == FRAG_RESULT_MAX); + STATIC_ASSERT(ARRAY_SIZE(vertResults) == VARYING_SLOT_MAX); + STATIC_ASSERT(ARRAY_SIZE(fragResults) == FRAG_RESULT_MAX); assert(strcmp(vertResults[VARYING_SLOT_POS], "result.position") == 0); assert(strcmp(vertResults[VARYING_SLOT_VAR0], "result.varying[0]") == 0); assert(strcmp(fragResults[FRAG_RESULT_DATA0], "result.color[0]") == 0); if (progType == GL_VERTEX_PROGRAM_ARB) { - assert(index < Elements(vertResults)); + assert(index < ARRAY_SIZE(vertResults)); return vertResults[index]; } else { assert(progType == GL_FRAGMENT_PROGRAM_ARB); - assert(index < Elements(fragResults)); + assert(index < ARRAY_SIZE(fragResults)); return fragResults[index]; } } diff --git a/mesalib/src/mesa/program/prog_statevars.c b/mesalib/src/mesa/program/prog_statevars.c index 7f5daf8c6..57b25a7e3 100644 --- a/mesalib/src/mesa/program/prog_statevars.c +++ b/mesalib/src/mesa/program/prog_statevars.c @@ -29,6 +29,7 @@ */ +#include <stdio.h> #include "main/glheader.h" #include "main/context.h" #include "main/blend.h" @@ -41,6 +42,9 @@ #include "main/samplerobj.h" +#define ONE_DIV_SQRT_LN2 (1.201122408786449815) + + /** * Use the list of tokens in the state[] array to find global GL state * and return it in <value>. Usually, four values are returned in <value> @@ -58,9 +62,9 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], /* state[1] is either 0=front or 1=back side */ const GLuint face = (GLuint) state[1]; const struct gl_material *mat = &ctx->Light.Material; - ASSERT(face == 0 || face == 1); + assert(face == 0 || face == 1); /* we rely on tokens numbered so that _BACK_ == _FRONT_+ 1 */ - ASSERT(MAT_ATTRIB_FRONT_AMBIENT + 1 == MAT_ATTRIB_BACK_AMBIENT); + assert(MAT_ATTRIB_FRONT_AMBIENT + 1 == MAT_ATTRIB_BACK_AMBIENT); /* XXX we could get rid of this switch entirely with a little * work in arbprogparse.c's parse_state_single_item(). */ @@ -170,7 +174,7 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], const GLuint ln = (GLuint) state[1]; const GLuint face = (GLuint) state[2]; GLint i; - ASSERT(face == 0 || face == 1); + assert(face == 0 || face == 1); switch (state[3]) { case STATE_AMBIENT: for (i = 0; i < 3; i++) { @@ -295,8 +299,8 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], const gl_state_index modifier = state[4]; const GLfloat *m; GLuint row, i; - ASSERT(firstRow < 4); - ASSERT(lastRow < 4); + assert(firstRow < 4); + assert(lastRow < 4); if (mat == STATE_MODELVIEW_MATRIX) { matrix = ctx->ModelviewMatrixStack.Top; } @@ -307,11 +311,11 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], matrix = &ctx->_ModelProjectMatrix; } else if (mat == STATE_TEXTURE_MATRIX) { - ASSERT(index < Elements(ctx->TextureMatrixStack)); + assert(index < ARRAY_SIZE(ctx->TextureMatrixStack)); matrix = ctx->TextureMatrixStack[index].Top; } else if (mat == STATE_PROGRAM_MATRIX) { - ASSERT(index < Elements(ctx->ProgramMatrixStack)); + assert(index < ARRAY_SIZE(ctx->ProgramMatrixStack)); matrix = ctx->ProgramMatrixStack[index].Top; } else { diff --git a/mesalib/src/mesa/program/program.c b/mesalib/src/mesa/program/program.c index 6e17fe65f..61a9e97c9 100644 --- a/mesalib/src/mesa/program/program.c +++ b/mesalib/src/mesa/program/program.c @@ -56,21 +56,21 @@ _mesa_init_program(struct gl_context *ctx) * If this assertion fails, we need to increase the field * size for register indexes (see INST_INDEX_BITS). */ - ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents / 4 + assert(ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents / 4 <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents / 4 + assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents / 4 <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxLocalParams <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTemps <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxLocalParams <= (1 << INST_INDEX_BITS)); + assert(ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps <= (1 << INST_INDEX_BITS)); + assert(ctx->Const.Program[MESA_SHADER_VERTEX].MaxLocalParams <= (1 << INST_INDEX_BITS)); + assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTemps <= (1 << INST_INDEX_BITS)); + assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxLocalParams <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents <= 4 * MAX_UNIFORMS); - ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents <= 4 * MAX_UNIFORMS); + assert(ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents <= 4 * MAX_UNIFORMS); + assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents <= 4 * MAX_UNIFORMS); - ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxAddressOffset <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxAddressOffset <= (1 << INST_INDEX_BITS)); + assert(ctx->Const.Program[MESA_SHADER_VERTEX].MaxAddressOffset <= (1 << INST_INDEX_BITS)); + assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxAddressOffset <= (1 << INST_INDEX_BITS)); /* If this fails, increase prog_instruction::TexSrcUnit size */ STATIC_ASSERT(MAX_TEXTURE_UNITS <= (1 << 5)); @@ -364,8 +364,8 @@ void _mesa_delete_program(struct gl_context *ctx, struct gl_program *prog) { (void) ctx; - ASSERT(prog); - ASSERT(prog->RefCount==0); + assert(prog); + assert(prog->RefCount==0); if (prog == &_mesa_DummyProgram) return; @@ -414,12 +414,12 @@ _mesa_reference_program_(struct gl_context *ctx, if (*ptr && prog) { /* sanity check */ if ((*ptr)->Target == GL_VERTEX_PROGRAM_ARB) - ASSERT(prog->Target == GL_VERTEX_PROGRAM_ARB); + assert(prog->Target == GL_VERTEX_PROGRAM_ARB); else if ((*ptr)->Target == GL_FRAGMENT_PROGRAM_ARB) - ASSERT(prog->Target == GL_FRAGMENT_PROGRAM_ARB || + assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB || prog->Target == GL_FRAGMENT_PROGRAM_NV); else if ((*ptr)->Target == MESA_GEOMETRY_PROGRAM) - ASSERT(prog->Target == MESA_GEOMETRY_PROGRAM); + assert(prog->Target == MESA_GEOMETRY_PROGRAM); } #endif @@ -434,14 +434,14 @@ _mesa_reference_program_(struct gl_context *ctx, ((*ptr)->Target == MESA_GEOMETRY_PROGRAM ? "GP" : "FP")), (*ptr)->RefCount - 1); #endif - ASSERT((*ptr)->RefCount > 0); + assert((*ptr)->RefCount > 0); (*ptr)->RefCount--; deleteFlag = ((*ptr)->RefCount == 0); /*mtx_lock(&(*ptr)->Mutex);*/ if (deleteFlag) { - ASSERT(ctx); + assert(ctx); ctx->Driver.DeleteProgram(ctx, *ptr); } @@ -733,7 +733,7 @@ _mesa_combine_programs(struct gl_context *ctx, GLbitfield64 inputsB; GLuint i; - ASSERT(progA->Target == progB->Target); + assert(progA->Target == progB->Target); newInst = _mesa_alloc_instructions(newLength); if (!newInst) @@ -867,14 +867,14 @@ _mesa_find_used_registers(const struct gl_program *prog, const GLuint n = _mesa_num_inst_src_regs(inst->Opcode); if (inst->DstReg.File == file) { - ASSERT(inst->DstReg.Index < usedSize); + assert(inst->DstReg.Index < usedSize); if(inst->DstReg.Index < usedSize) used[inst->DstReg.Index] = GL_TRUE; } for (j = 0; j < n; j++) { if (inst->SrcReg[j].File == file) { - ASSERT(inst->SrcReg[j].Index < (GLint) usedSize); + assert(inst->SrcReg[j].Index < (GLint) usedSize); if (inst->SrcReg[j].Index < (GLint) usedSize) used[inst->SrcReg[j].Index] = GL_TRUE; } diff --git a/mesalib/src/mesa/program/program.h b/mesalib/src/mesa/program/program.h index ef698242f..0b0d1ac6f 100644 --- a/mesalib/src/mesa/program/program.h +++ b/mesalib/src/mesa/program/program.h @@ -210,7 +210,7 @@ _mesa_program_enum_to_shader_stage(GLenum v) case GL_COMPUTE_PROGRAM_NV: return MESA_SHADER_COMPUTE; default: - ASSERT(0); + assert(0); return ~0; } } diff --git a/mesalib/src/mesa/program/program_parse.y b/mesalib/src/mesa/program/program_parse.y index 1664740b4..716b83d2d 100644 --- a/mesalib/src/mesa/program/program_parse.y +++ b/mesalib/src/mesa/program/program_parse.y @@ -21,6 +21,8 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ + +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -2333,11 +2335,11 @@ set_dst_reg(struct prog_dst_register *r, gl_register_file file, GLint index) { const GLint maxIndex = 1 << INST_INDEX_BITS; const GLint minIndex = 0; - ASSERT(index >= minIndex); + assert(index >= minIndex); (void) minIndex; - ASSERT(index <= maxIndex); + assert(index <= maxIndex); (void) maxIndex; - ASSERT(file == PROGRAM_TEMPORARY || + assert(file == PROGRAM_TEMPORARY || file == PROGRAM_ADDRESS || file == PROGRAM_OUTPUT); memset(r, 0, sizeof(*r)); @@ -2375,10 +2377,10 @@ set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index, { const GLint maxIndex = (1 << INST_INDEX_BITS) - 1; const GLint minIndex = -(1 << INST_INDEX_BITS); - ASSERT(file < PROGRAM_FILE_MAX); - ASSERT(index >= minIndex); + assert(file < PROGRAM_FILE_MAX); + assert(index >= minIndex); (void) minIndex; - ASSERT(index <= maxIndex); + assert(index <= maxIndex); (void) maxIndex; memset(r, 0, sizeof(*r)); r->Base.File = file; diff --git a/mesalib/src/mesa/program/programopt.c b/mesalib/src/mesa/program/programopt.c index fdaa4a465..e82c68a53 100644 --- a/mesalib/src/mesa/program/programopt.c +++ b/mesalib/src/mesa/program/programopt.c @@ -335,7 +335,7 @@ _mesa_append_fog_code(struct gl_context *ctx, inst++; } else { - ASSERT(fog_mode == GL_EXP || fog_mode == GL_EXP2); + assert(fog_mode == GL_EXP || fog_mode == GL_EXP2); /* fogPRefOpt.z = d/ln(2), fogPRefOpt.w = d/sqrt(ln(2) */ /* EXP: MUL fogFactorTemp.x, fogPRefOpt.z, fragment.fogcoord.x; */ /* EXP2: MUL fogFactorTemp.x, fogPRefOpt.w, fragment.fogcoord.x; */ diff --git a/mesalib/src/mesa/program/sampler.cpp b/mesalib/src/mesa/program/sampler.cpp index f8584c968..ea3024d51 100644 --- a/mesalib/src/mesa/program/sampler.cpp +++ b/mesalib/src/mesa/program/sampler.cpp @@ -29,7 +29,6 @@ #include "../glsl/program.h" #include "ir_uniform.h" -#include "main/compiler.h" #include "main/mtypes.h" #include "program/hash_table.h" #include "program/prog_parameter.h" diff --git a/mesalib/src/mesa/state_tracker/st_atom.c b/mesalib/src/mesa/state_tracker/st_atom.c index 625ea2965..f0fe11ffa 100644 --- a/mesalib/src/mesa/state_tracker/st_atom.c +++ b/mesalib/src/mesa/state_tracker/st_atom.c @@ -26,6 +26,7 @@ **************************************************************************/ +#include <stdio.h> #include "main/glheader.h" #include "main/context.h" @@ -197,7 +198,7 @@ void st_validate_state( struct st_context *st ) memset(&examined, 0, sizeof(examined)); prev = *state; - for (i = 0; i < Elements(atoms); i++) { + for (i = 0; i < ARRAY_SIZE(atoms); i++) { const struct st_tracked_state *atom = atoms[i]; struct st_state_flags generated; @@ -228,7 +229,7 @@ void st_validate_state( struct st_context *st ) } else { - for (i = 0; i < Elements(atoms); i++) { + for (i = 0; i < ARRAY_SIZE(atoms); i++) { if (check_state(state, &atoms[i]->dirty)) atoms[i]->update( st ); } diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c index f24805cf5..1dbc4b905 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -104,9 +104,9 @@ st_bufferobj_subdata(struct gl_context *ctx, struct st_buffer_object *st_obj = st_buffer_object(obj); /* we may be called from VBO code, so double-check params here */ - ASSERT(offset >= 0); - ASSERT(size >= 0); - ASSERT(offset + size <= obj->Size); + assert(offset >= 0); + assert(size >= 0); + assert(offset + size <= obj->Size); if (!size) return; @@ -148,9 +148,9 @@ st_bufferobj_get_subdata(struct gl_context *ctx, struct st_buffer_object *st_obj = st_buffer_object(obj); /* we may be called from VBO code, so double-check params here */ - ASSERT(offset >= 0); - ASSERT(size >= 0); - ASSERT(offset + size <= obj->Size); + assert(offset >= 0); + assert(size >= 0); + assert(offset + size <= obj->Size); if (!size) return; diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.h b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.h index a5ab12219..647efe4cc 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.h +++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.h @@ -48,7 +48,7 @@ struct st_buffer_object /** cast wrapper */ -static INLINE struct st_buffer_object * +static inline struct st_buffer_object * st_buffer_object(struct gl_buffer_object *obj) { return (struct st_buffer_object *) obj; diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c index 45dea594e..dd81a6273 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_clear.c +++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c @@ -102,7 +102,7 @@ st_destroy_clear(struct st_context *st) /** * Helper function to set the fragment shaders. */ -static INLINE void +static inline void set_fragment_shader(struct st_context *st) { if (!st->clear.fs) @@ -118,7 +118,7 @@ set_fragment_shader(struct st_context *st) /** * Helper function to set the vertex shader. */ -static INLINE void +static inline void set_vertex_shader(struct st_context *st) { /* vertex shader - still required to provide the linkage between @@ -381,7 +381,7 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers) /** * Return if the scissor must be enabled during the clear. */ -static INLINE GLboolean +static inline GLboolean is_scissor_enabled(struct gl_context *ctx, struct gl_renderbuffer *rb) { return (ctx->Scissor.EnableFlags & 1) && @@ -395,7 +395,7 @@ is_scissor_enabled(struct gl_context *ctx, struct gl_renderbuffer *rb) /** * Return if all of the color channels are masked. */ -static INLINE GLboolean +static inline GLboolean is_color_disabled(struct gl_context *ctx, int i) { return !ctx->Color.ColorMask[i][0] && @@ -408,7 +408,7 @@ is_color_disabled(struct gl_context *ctx, int i) /** * Return if any of the color channels are masked. */ -static INLINE GLboolean +static inline GLboolean is_color_masked(struct gl_context *ctx, int i) { return !ctx->Color.ColorMask[i][0] || @@ -421,7 +421,7 @@ is_color_masked(struct gl_context *ctx, int i) /** * Return if all of the stencil bits are masked. */ -static INLINE GLboolean +static inline GLboolean is_stencil_disabled(struct gl_context *ctx, struct gl_renderbuffer *rb) { const GLuint stencilMax = 0xff; @@ -434,7 +434,7 @@ is_stencil_disabled(struct gl_context *ctx, struct gl_renderbuffer *rb) /** * Return if any of the stencil bits are masked. */ -static INLINE GLboolean +static inline GLboolean is_stencil_masked(struct gl_context *ctx, struct gl_renderbuffer *rb) { const GLuint stencilMax = 0xff; diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c index 14fc13952..3edf31bad 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c @@ -201,7 +201,7 @@ st_make_drawpix_z_stencil_program(struct st_context *st, GLuint ic = 0; const GLuint shaderIndex = write_depth * 2 + write_stencil; - assert(shaderIndex < Elements(st->drawpix.shaders)); + assert(shaderIndex < ARRAY_SIZE(st->drawpix.shaders)); if (st->drawpix.shaders[shaderIndex]) { /* already have the proper shader */ @@ -1684,7 +1684,7 @@ st_destroy_drawpix(struct st_context *st) { GLuint i; - for (i = 0; i < Elements(st->drawpix.shaders); i++) { + for (i = 0; i < ARRAY_SIZE(st->drawpix.shaders); i++) { if (st->drawpix.shaders[i]) _mesa_reference_fragprog(st->ctx, &st->drawpix.shaders[i], NULL); } diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.h b/mesalib/src/mesa/state_tracker/st_cb_fbo.h index ae13aa677..f3b310b07 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_fbo.h +++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.h @@ -65,7 +65,7 @@ struct st_renderbuffer }; -static INLINE struct st_renderbuffer * +static inline struct st_renderbuffer * st_renderbuffer(struct gl_renderbuffer *rb) { return (struct st_renderbuffer *) rb; diff --git a/mesalib/src/mesa/state_tracker/st_cb_feedback.c b/mesalib/src/mesa/state_tracker/st_cb_feedback.c index 6b504b8ab..c5410886a 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_feedback.c +++ b/mesalib/src/mesa/state_tracker/st_cb_feedback.c @@ -69,7 +69,7 @@ struct feedback_stage * GL Feedback functions **********************************************************************/ -static INLINE struct feedback_stage * +static inline struct feedback_stage * feedback_stage( struct draw_stage *stage ) { return (struct feedback_stage *)stage; diff --git a/mesalib/src/mesa/state_tracker/st_cb_flush.c b/mesalib/src/mesa/state_tracker/st_cb_flush.c index 5544c6644..6df430049 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_flush.c +++ b/mesalib/src/mesa/state_tracker/st_cb_flush.c @@ -47,7 +47,7 @@ /** Check if we have a front color buffer and if it's been drawn to. */ -static INLINE GLboolean +static inline GLboolean is_front_buffer_dirty(struct st_context *st) { struct gl_framebuffer *fb = st->ctx->DrawBuffer; diff --git a/mesalib/src/mesa/state_tracker/st_cb_program.c b/mesalib/src/mesa/state_tracker/st_cb_program.c index faff9c4bd..aa301d830 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_program.c +++ b/mesalib/src/mesa/state_tracker/st_cb_program.c @@ -143,11 +143,6 @@ st_delete_program(struct gl_context *ctx, struct gl_program *prog) if (stgp->glsl_to_tgsi) free_glsl_to_tgsi_visitor(stgp->glsl_to_tgsi); - - if (stgp->tgsi.tokens) { - st_free_tokens((void *) stgp->tgsi.tokens); - stgp->tgsi.tokens = NULL; - } } break; case GL_FRAGMENT_PROGRAM_ARB: @@ -207,11 +202,6 @@ st_program_string_notify( struct gl_context *ctx, st_release_gp_variants(st, stgp); - if (stgp->tgsi.tokens) { - st_free_tokens((void *) stgp->tgsi.tokens); - stgp->tgsi.tokens = NULL; - } - if (st->gp == stgp) st->dirty.st |= ST_NEW_GEOMETRY_PROGRAM; } diff --git a/mesalib/src/mesa/state_tracker/st_cb_queryobj.h b/mesalib/src/mesa/state_tracker/st_cb_queryobj.h index e4c6c8643..24063211b 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_queryobj.h +++ b/mesalib/src/mesa/state_tracker/st_cb_queryobj.h @@ -49,7 +49,7 @@ struct st_query_object /** * Cast wrapper */ -static INLINE struct st_query_object * +static inline struct st_query_object * st_query_object(struct gl_query_object *q) { return (struct st_query_object *) q; diff --git a/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c b/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c index 370746536..272cbb91d 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c @@ -64,7 +64,7 @@ struct rastpos_stage }; -static INLINE struct rastpos_stage * +static inline struct rastpos_stage * rastpos_stage( struct draw_stage *stage ) { return (struct rastpos_stage *) stage; @@ -191,7 +191,7 @@ new_draw_rastpos_stage(struct gl_context *ctx, struct draw_context *draw) rs->stage.destroy = rastpos_destroy; rs->ctx = ctx; - for (i = 0; i < Elements(rs->array); i++) { + for (i = 0; i < ARRAY_SIZE(rs->array); i++) { rs->array[i].Size = 4; rs->array[i].Type = GL_FLOAT; rs->array[i].Format = GL_RGBA; diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index 0525e879f..a8b19a1f3 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -25,6 +25,7 @@ * **************************************************************************/ +#include <stdio.h> #include "main/bufferobj.h" #include "main/enums.h" #include "main/fbobject.h" diff --git a/mesalib/src/mesa/state_tracker/st_cb_viewport.c b/mesalib/src/mesa/state_tracker/st_cb_viewport.c index 2bd55f6d2..d7a34125e 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_viewport.c +++ b/mesalib/src/mesa/state_tracker/st_cb_viewport.c @@ -39,7 +39,7 @@ * We'll only return non-null for window system framebuffers. * Note that this function may fail. */ -static INLINE struct st_framebuffer * +static inline struct st_framebuffer * st_ws_framebuffer(struct gl_framebuffer *fb) { /* FBO cannot be casted. See st_new_framebuffer */ diff --git a/mesalib/src/mesa/state_tracker/st_cb_xformfb.c b/mesalib/src/mesa/state_tracker/st_cb_xformfb.c index a2bd86aff..07c118e22 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_xformfb.c +++ b/mesalib/src/mesa/state_tracker/st_cb_xformfb.c @@ -59,7 +59,7 @@ struct st_transform_feedback_object { struct pipe_stream_output_target *draw_count; }; -static INLINE struct st_transform_feedback_object * +static inline struct st_transform_feedback_object * st_transform_feedback_object(struct gl_transform_feedback_object *obj) { return (struct st_transform_feedback_object *) obj; @@ -95,7 +95,7 @@ st_delete_transform_feedback(struct gl_context *ctx, pipe_so_target_reference(&sobj->targets[i], NULL); } - for (i = 0; i < Elements(sobj->base.Buffers); i++) { + for (i = 0; i < ARRAY_SIZE(sobj->base.Buffers); i++) { _mesa_reference_buffer_object(ctx, &sobj->base.Buffers[i], NULL); } @@ -115,8 +115,8 @@ st_begin_transform_feedback(struct gl_context *ctx, GLenum mode, unsigned i, max_num_targets; unsigned offsets[PIPE_MAX_SO_BUFFERS] = {0}; - max_num_targets = MIN2(Elements(sobj->base.Buffers), - Elements(sobj->targets)); + max_num_targets = MIN2(ARRAY_SIZE(sobj->base.Buffers), + ARRAY_SIZE(sobj->targets)); /* Convert the transform feedback state into the gallium representation. */ for (i = 0; i < max_num_targets; i++) { @@ -185,7 +185,7 @@ st_transform_feedback_get_draw_target(struct gl_transform_feedback_object *obj) st_transform_feedback_object(obj); unsigned i; - for (i = 0; i < Elements(sobj->targets); i++) { + for (i = 0; i < ARRAY_SIZE(sobj->targets); i++) { if (sobj->targets[i]) { return sobj->targets[i]; } diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c index 5834ebad3..5fe132ac2 100644 --- a/mesalib/src/mesa/state_tracker/st_context.c +++ b/mesalib/src/mesa/state_tracker/st_context.c @@ -117,8 +117,8 @@ st_destroy_context_priv(struct st_context *st) st_destroy_drawpix(st); st_destroy_drawtex(st); - for (shader = 0; shader < Elements(st->state.sampler_views); shader++) { - for (i = 0; i < Elements(st->state.sampler_views[0]); i++) { + for (shader = 0; shader < ARRAY_SIZE(st->state.sampler_views); shader++) { + for (i = 0; i < ARRAY_SIZE(st->state.sampler_views[0]); i++) { pipe_sampler_view_release(st->pipe, &st->state.sampler_views[shader][i]); } @@ -200,7 +200,7 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe, /* Vertex element objects used for drawing rectangles for glBitmap, * glDrawPixels, glClear, etc. */ - for (i = 0; i < Elements(st->velems_util_draw); i++) { + for (i = 0; i < ARRAY_SIZE(st->velems_util_draw); i++) { memset(&st->velems_util_draw[i], 0, sizeof(struct pipe_vertex_element)); st->velems_util_draw[i].src_offset = i * 4 * sizeof(float); st->velems_util_draw[i].instance_divisor = 0; diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h index b091a8856..8a9504bb7 100644 --- a/mesalib/src/mesa/state_tracker/st_context.h +++ b/mesalib/src/mesa/state_tracker/st_context.h @@ -214,7 +214,7 @@ struct st_context /* Need this so that we can implement Mesa callbacks in this module. */ -static INLINE struct st_context *st_context(struct gl_context *ctx) +static inline struct st_context *st_context(struct gl_context *ctx) { return ctx->st; } @@ -246,7 +246,7 @@ void st_invalidate_state(struct gl_context * ctx, GLuint new_state); #define Y_0_TOP 1 #define Y_0_BOTTOM 2 -static INLINE GLuint +static inline GLuint st_fb_orientation(const struct gl_framebuffer *fb) { if (fb && _mesa_is_winsys_fbo(fb)) { diff --git a/mesalib/src/mesa/state_tracker/st_debug.h b/mesalib/src/mesa/state_tracker/st_debug.h index 49b916fb3..cc8197836 100644 --- a/mesalib/src/mesa/state_tracker/st_debug.h +++ b/mesalib/src/mesa/state_tracker/st_debug.h @@ -58,7 +58,7 @@ extern int ST_DEBUG; void st_debug_init( void ); -static INLINE void +static inline void ST_DBG( unsigned flag, const char *fmt, ... ) { if (ST_DEBUG & flag) diff --git a/mesalib/src/mesa/state_tracker/st_draw.h b/mesalib/src/mesa/state_tracker/st_draw.h index 361fe7f91..780d4bde7 100644 --- a/mesalib/src/mesa/state_tracker/st_draw.h +++ b/mesalib/src/mesa/state_tracker/st_draw.h @@ -76,7 +76,7 @@ st_feedback_draw_vbo(struct gl_context *ctx, * This function is basically a cast wrapper to avoid warnings when building * in 64-bit mode. */ -static INLINE unsigned +static inline unsigned pointer_to_offset(const void *ptr) { return (unsigned) (((GLsizeiptr) ptr) & 0xffffffffUL); diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index ce29d076c..bc20f7323 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -347,8 +347,8 @@ init_format_extensions(struct pipe_screen *screen, GLboolean *extension_table = (GLboolean *) extensions; unsigned i; int j; - int num_formats = Elements(mapping->format); - int num_ext = Elements(mapping->extension_offset); + int num_formats = ARRAY_SIZE(mapping->format); + int num_ext = ARRAY_SIZE(mapping->extension_offset); for (i = 0; i < num_mappings; i++) { int num_supported = 0; @@ -630,7 +630,7 @@ void st_init_extensions(struct pipe_screen *screen, extensions->OES_draw_texture = GL_TRUE; /* Expose the extensions which directly correspond to gallium caps. */ - for (i = 0; i < Elements(cap_mapping); i++) { + for (i = 0; i < ARRAY_SIZE(cap_mapping); i++) { if (screen->get_param(screen, cap_mapping[i].cap)) { extension_table[cap_mapping[i].extension_offset] = GL_TRUE; } @@ -638,16 +638,16 @@ void st_init_extensions(struct pipe_screen *screen, /* Expose the extensions which directly correspond to gallium formats. */ init_format_extensions(screen, extensions, rendertarget_mapping, - Elements(rendertarget_mapping), PIPE_TEXTURE_2D, + ARRAY_SIZE(rendertarget_mapping), PIPE_TEXTURE_2D, PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW); init_format_extensions(screen, extensions, depthstencil_mapping, - Elements(depthstencil_mapping), PIPE_TEXTURE_2D, + ARRAY_SIZE(depthstencil_mapping), PIPE_TEXTURE_2D, PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_SAMPLER_VIEW); init_format_extensions(screen, extensions, texture_mapping, - Elements(texture_mapping), PIPE_TEXTURE_2D, + ARRAY_SIZE(texture_mapping), PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); init_format_extensions(screen, extensions, vertex_mapping, - Elements(vertex_mapping), PIPE_BUFFER, + ARRAY_SIZE(vertex_mapping), PIPE_BUFFER, PIPE_BIND_VERTEX_BUFFER); /* Figure out GLSL support. */ @@ -758,22 +758,22 @@ void st_init_extensions(struct pipe_screen *screen, }; consts->MaxSamples = - get_max_samples_for_formats(screen, Elements(color_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats), color_formats, 16, PIPE_BIND_RENDER_TARGET); consts->MaxColorTextureSamples = - get_max_samples_for_formats(screen, Elements(color_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats), color_formats, consts->MaxSamples, PIPE_BIND_SAMPLER_VIEW); consts->MaxDepthTextureSamples = - get_max_samples_for_formats(screen, Elements(depth_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(depth_formats), depth_formats, consts->MaxSamples, PIPE_BIND_SAMPLER_VIEW); consts->MaxIntegerSamples = - get_max_samples_for_formats(screen, Elements(int_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(int_formats), int_formats, consts->MaxSamples, PIPE_BIND_SAMPLER_VIEW); } @@ -831,7 +831,7 @@ void st_init_extensions(struct pipe_screen *screen, extensions->ARB_texture_buffer_range = GL_TRUE; init_format_extensions(screen, extensions, tbo_rgb32, - Elements(tbo_rgb32), PIPE_BUFFER, + ARRAY_SIZE(tbo_rgb32), PIPE_BUFFER, PIPE_BIND_SAMPLER_VIEW); } diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c index 7868bb501..72dbf3bd4 100644 --- a/mesalib/src/mesa/state_tracker/st_format.c +++ b/mesalib/src/mesa/state_tracker/st_format.c @@ -1855,7 +1855,7 @@ st_choose_format(struct st_context *st, GLenum internalFormat, return pf; /* search table for internalFormat */ - for (i = 0; i < Elements(format_map); i++) { + for (i = 0; i < ARRAY_SIZE(format_map); i++) { const struct format_mapping *mapping = &format_map[i]; for (j = 0; mapping->glFormats[j]; j++) { if (mapping->glFormats[j] == internalFormat) { diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 0b3477161..bd191d864 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -1497,7 +1497,7 @@ void glsl_to_tgsi_visitor::visit(ir_expression *ir) { unsigned int operand; - st_src_reg op[Elements(ir->operands)]; + st_src_reg op[ARRAY_SIZE(ir->operands)]; st_src_reg result_src; st_dst_reg result_dst; @@ -3515,7 +3515,7 @@ get_src_arg_mask(st_dst_reg dst, st_src_reg src) */ for (comp = 0; comp < 4; ++comp) { const unsigned coord = GET_SWZ(src.swizzle, comp); - ASSERT(coord < 4); + assert(coord < 4); if (dst.writemask & (1 << comp) && coord <= SWIZZLE_W) read_mask |= 1 << coord; } @@ -4022,7 +4022,7 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void) /* Continuing the block, clear any channels from the write array that * are read by this instruction. */ - for (unsigned i = 0; i < Elements(inst->src); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(inst->src); i++) { if (inst->src[i].file == PROGRAM_TEMPORARY && inst->src[i].reladdr){ /* Any temporary might be read, so no dead code elimination * across this instruction. @@ -4067,7 +4067,7 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void) * If there is already an instruction in the write array for one or more * of the channels, flag that channel write as dead. */ - for (unsigned i = 0; i < Elements(inst->dst); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(inst->dst); i++) { if (inst->dst[i].file == PROGRAM_TEMPORARY && !inst->dst[i].reladdr && !inst->saturate) { @@ -4625,7 +4625,7 @@ dst_register(struct st_translate *t, case PROGRAM_ARRAY: array = index >> 16; - assert(array < Elements(t->arrays)); + assert(array < ARRAY_SIZE(t->arrays)); if (ureg_dst_is_undef(t->arrays[array])) t->arrays[array] = ureg_DECL_array_temporary( @@ -4642,7 +4642,7 @@ dst_register(struct st_translate *t, else assert(index < VARYING_SLOT_MAX); - assert(t->outputMapping[index] < Elements(t->outputs)); + assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs)); return t->outputs[t->outputMapping[index]]; @@ -4659,7 +4659,7 @@ dst_register(struct st_translate *t, * Map a glsl_to_tgsi src register to a TGSI ureg_src register. */ static struct ureg_src -src_register(struct st_translate *t, const struct st_src_reg *reg) +src_register(struct st_translate *t, const st_src_reg *reg) { switch(reg->file) { case PROGRAM_UNDEFINED: @@ -4685,18 +4685,18 @@ src_register(struct st_translate *t, const struct st_src_reg *reg) return t->immediates[reg->index]; case PROGRAM_INPUT: - assert(t->inputMapping[reg->index] < Elements(t->inputs)); + assert(t->inputMapping[reg->index] < ARRAY_SIZE(t->inputs)); return t->inputs[t->inputMapping[reg->index]]; case PROGRAM_OUTPUT: - assert(t->outputMapping[reg->index] < Elements(t->outputs)); + assert(t->outputMapping[reg->index] < ARRAY_SIZE(t->outputs)); return ureg_src(t->outputs[t->outputMapping[reg->index]]); /* not needed? */ case PROGRAM_ADDRESS: return ureg_src(t->address[reg->index]); case PROGRAM_SYSTEM_VALUE: - assert(reg->index < (int) Elements(t->systemValues)); + assert(reg->index < (int) ARRAY_SIZE(t->systemValues)); return t->systemValues[reg->index]; default: @@ -4824,7 +4824,7 @@ translate_tex_offset(struct st_translate *t, array = in_offset->index >> 16; assert(array >= 0); - assert(array < (int) Elements(t->arrays)); + assert(array < (int) ARRAY_SIZE(t->arrays)); dst = t->arrays[array]; offset.File = dst.File; @@ -5200,8 +5200,8 @@ st_translate_program( unsigned i; enum pipe_error ret = PIPE_OK; - assert(numInputs <= Elements(t->inputs)); - assert(numOutputs <= Elements(t->outputs)); + assert(numInputs <= ARRAY_SIZE(t->inputs)); + assert(numOutputs <= ARRAY_SIZE(t->outputs)); assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_FRONT_FACE] == TGSI_SEMANTIC_FACE); diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c index 5411d84b0..840f76a13 100644 --- a/mesalib/src/mesa/state_tracker/st_manager.c +++ b/mesalib/src/mesa/state_tracker/st_manager.c @@ -61,7 +61,7 @@ * We'll only return non-null for window system framebuffers. * Note that this function may fail. */ -static INLINE struct st_framebuffer * +static inline struct st_framebuffer * st_ws_framebuffer(struct gl_framebuffer *fb) { /* FBO cannot be casted. See st_new_framebuffer */ @@ -73,7 +73,7 @@ st_ws_framebuffer(struct gl_framebuffer *fb) /** * Map an attachment to a buffer index. */ -static INLINE gl_buffer_index +static inline gl_buffer_index attachment_to_buffer_index(enum st_attachment_type statt) { gl_buffer_index index; @@ -109,7 +109,7 @@ attachment_to_buffer_index(enum st_attachment_type statt) /** * Map a buffer index to an attachment. */ -static INLINE enum st_attachment_type +static inline enum st_attachment_type buffer_index_to_attachment(gl_buffer_index index) { enum st_attachment_type statt; diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c index 3dd8a14b6..2f1016110 100644 --- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -172,7 +172,7 @@ dst_register( struct st_translate *t, else assert(index < VARYING_SLOT_MAX); - assert(t->outputMapping[index] < Elements(t->outputs)); + assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs)); return t->outputs[t->outputMapping[index]]; @@ -200,7 +200,7 @@ src_register( struct st_translate *t, case PROGRAM_TEMPORARY: assert(index >= 0); - assert(index < Elements(t->temps)); + assert(index < ARRAY_SIZE(t->temps)); if (ureg_dst_is_undef(t->temps[index])) t->temps[index] = ureg_DECL_temporary( t->ureg ); return ureg_src(t->temps[index]); @@ -216,18 +216,18 @@ src_register( struct st_translate *t, return t->constants[index]; case PROGRAM_INPUT: - assert(t->inputMapping[index] < Elements(t->inputs)); + assert(t->inputMapping[index] < ARRAY_SIZE(t->inputs)); return t->inputs[t->inputMapping[index]]; case PROGRAM_OUTPUT: - assert(t->outputMapping[index] < Elements(t->outputs)); + assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs)); return ureg_src(t->outputs[t->outputMapping[index]]); /* not needed? */ case PROGRAM_ADDRESS: return ureg_src(t->address[index]); case PROGRAM_SYSTEM_VALUE: - assert(index < Elements(t->systemValues)); + assert(index < ARRAY_SIZE(t->systemValues)); return t->systemValues[index]; default: @@ -1027,8 +1027,8 @@ st_translate_mesa_program( unsigned i; enum pipe_error ret = PIPE_OK; - assert(numInputs <= Elements(t->inputs)); - assert(numOutputs <= Elements(t->outputs)); + assert(numInputs <= ARRAY_SIZE(t->inputs)); + assert(numOutputs <= ARRAY_SIZE(t->outputs)); t = &translate; memset(t, 0, sizeof *t); @@ -1254,14 +1254,3 @@ out: return ret; } - - -/** - * Tokens cannot be free with free otherwise the builtin gallium - * malloc debugging will get confused. - */ -void -st_free_tokens(const struct tgsi_token *tokens) -{ - ureg_free_tokens(tokens); -} diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.h b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.h index 1aa797a32..62bb654e9 100644 --- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.h +++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.h @@ -62,9 +62,6 @@ st_translate_mesa_program( boolean passthrough_edgeflags, boolean clamp_color); -void -st_free_tokens(const struct tgsi_token *tokens); - unsigned st_translate_texture_target(GLuint textarget, GLboolean shadow); diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c index 10a5f2900..4cfd817ce 100644 --- a/mesalib/src/mesa/state_tracker/st_program.c +++ b/mesalib/src/mesa/state_tracker/st_program.c @@ -69,7 +69,7 @@ delete_vp_variant(struct st_context *st, struct st_vp_variant *vpv) draw_delete_vertex_shader( st->draw, vpv->draw_shader ); if (vpv->tgsi.tokens) - st_free_tokens(vpv->tgsi.tokens); + ureg_free_tokens(vpv->tgsi.tokens); free( vpv ); } @@ -108,7 +108,7 @@ delete_fp_variant(struct st_context *st, struct st_fp_variant *fpv) if (fpv->parameters) _mesa_free_parameter_list(fpv->parameters); if (fpv->tgsi.tokens) - st_free_tokens(fpv->tgsi.tokens); + ureg_free_tokens(fpv->tgsi.tokens); free(fpv); } @@ -869,106 +869,79 @@ st_translate_geometry_program(struct st_context *st, GLuint outputMapping[VARYING_SLOT_MAX]; struct pipe_context *pipe = st->pipe; GLuint attr; - GLbitfield64 inputsRead; - GLuint vslot = 0; uint gs_num_inputs = 0; - uint gs_builtin_inputs = 0; - uint gs_array_offset = 0; + + ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; + ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS]; ubyte gs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; ubyte gs_output_semantic_index[PIPE_MAX_SHADER_OUTPUTS]; uint gs_num_outputs = 0; GLint i; - GLuint maxSlot = 0; struct ureg_program *ureg; - + struct pipe_shader_state state = {0}; struct st_gp_variant *gpv; gpv = CALLOC_STRUCT(st_gp_variant); if (!gpv) return NULL; - if (!stgp->glsl_to_tgsi) { - _mesa_remove_output_reads(&stgp->Base.Base, PROGRAM_OUTPUT); - } - - ureg = ureg_create( TGSI_PROCESSOR_GEOMETRY ); + ureg = ureg_create(TGSI_PROCESSOR_GEOMETRY); if (ureg == NULL) { free(gpv); return NULL; } - /* which vertex output goes to the first geometry input */ - vslot = 0; - memset(inputMapping, 0, sizeof(inputMapping)); memset(outputMapping, 0, sizeof(outputMapping)); /* * Convert Mesa program inputs to TGSI input register semantics. */ - inputsRead = stgp->Base.Base.InputsRead; for (attr = 0; attr < VARYING_SLOT_MAX; attr++) { - if ((inputsRead & BITFIELD64_BIT(attr)) != 0) { - const GLuint slot = gs_num_inputs; - - gs_num_inputs++; + if ((stgp->Base.Base.InputsRead & BITFIELD64_BIT(attr)) != 0) { + const GLuint slot = gs_num_inputs++; inputMapping[attr] = slot; - stgp->input_map[slot + gs_array_offset] = vslot - gs_builtin_inputs; - stgp->input_to_index[attr] = vslot; - stgp->index_to_input[vslot] = attr; - ++vslot; - - if (attr != VARYING_SLOT_PRIMITIVE_ID) { - gs_array_offset += 2; - } else - ++gs_builtin_inputs; - -#if 0 - debug_printf("input map at %d = %d\n", - slot + gs_array_offset, stgp->input_map[slot + gs_array_offset]); -#endif - switch (attr) { case VARYING_SLOT_PRIMITIVE_ID: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_PRIMID; - stgp->input_semantic_index[slot] = 0; + input_semantic_name[slot] = TGSI_SEMANTIC_PRIMID; + input_semantic_index[slot] = 0; break; case VARYING_SLOT_POS: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_POSITION; - stgp->input_semantic_index[slot] = 0; + input_semantic_name[slot] = TGSI_SEMANTIC_POSITION; + input_semantic_index[slot] = 0; break; case VARYING_SLOT_COL0: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; - stgp->input_semantic_index[slot] = 0; + input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + input_semantic_index[slot] = 0; break; case VARYING_SLOT_COL1: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; - stgp->input_semantic_index[slot] = 1; + input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + input_semantic_index[slot] = 1; break; case VARYING_SLOT_FOGC: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_FOG; - stgp->input_semantic_index[slot] = 0; + input_semantic_name[slot] = TGSI_SEMANTIC_FOG; + input_semantic_index[slot] = 0; break; case VARYING_SLOT_CLIP_VERTEX: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_CLIPVERTEX; - stgp->input_semantic_index[slot] = 0; + input_semantic_name[slot] = TGSI_SEMANTIC_CLIPVERTEX; + input_semantic_index[slot] = 0; break; case VARYING_SLOT_CLIP_DIST0: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST; - stgp->input_semantic_index[slot] = 0; + input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST; + input_semantic_index[slot] = 0; break; case VARYING_SLOT_CLIP_DIST1: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST; - stgp->input_semantic_index[slot] = 1; + input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST; + input_semantic_index[slot] = 1; break; case VARYING_SLOT_PSIZ: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_PSIZE; - stgp->input_semantic_index[slot] = 0; + input_semantic_name[slot] = TGSI_SEMANTIC_PSIZE; + input_semantic_index[slot] = 0; break; case VARYING_SLOT_TEX0: case VARYING_SLOT_TEX1: @@ -979,16 +952,16 @@ st_translate_geometry_program(struct st_context *st, case VARYING_SLOT_TEX6: case VARYING_SLOT_TEX7: if (st->needs_texcoord_semantic) { - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_TEXCOORD; - stgp->input_semantic_index[slot] = attr - VARYING_SLOT_TEX0; + input_semantic_name[slot] = TGSI_SEMANTIC_TEXCOORD; + input_semantic_index[slot] = attr - VARYING_SLOT_TEX0; break; } /* fall through */ case VARYING_SLOT_VAR0: default: assert(attr >= VARYING_SLOT_VAR0 && attr < VARYING_SLOT_MAX); - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; - stgp->input_semantic_index[slot] = + input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + input_semantic_index[slot] = st_get_generic_varying_index(st, attr); break; } @@ -1007,10 +980,8 @@ st_translate_geometry_program(struct st_context *st, */ for (attr = 0; attr < VARYING_SLOT_MAX; attr++) { if (stgp->Base.Base.OutputsWritten & BITFIELD64_BIT(attr)) { - GLuint slot; + GLuint slot = gs_num_outputs++; - slot = gs_num_outputs; - gs_num_outputs++; outputMapping[attr] = slot; switch (attr) { @@ -1083,7 +1054,7 @@ st_translate_geometry_program(struct st_context *st, /* fall through */ case VARYING_SLOT_VAR0: default: - assert(slot < Elements(gs_output_semantic_name)); + assert(slot < ARRAY_SIZE(gs_output_semantic_name)); assert(attr >= VARYING_SLOT_VAR0); gs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; gs_output_semantic_index[slot] = @@ -1093,93 +1064,38 @@ st_translate_geometry_program(struct st_context *st, } } - /* find max output slot referenced to compute gs_num_outputs */ - for (attr = 0; attr < VARYING_SLOT_MAX; attr++) { - if (outputMapping[attr] != ~0U && outputMapping[attr] > maxSlot) - maxSlot = outputMapping[attr]; - } - gs_num_outputs = maxSlot + 1; - -#if 0 /* debug */ - { - GLuint i; - printf("outputMapping? %d\n", outputMapping ? 1 : 0); - if (outputMapping) { - printf("attr -> slot\n"); - for (i = 0; i < 16; i++) { - printf(" %2d %3d\n", i, outputMapping[i]); - } - } - printf("slot sem_name sem_index\n"); - for (i = 0; i < gs_num_outputs; i++) { - printf(" %2d %d %d\n", - i, - gs_output_semantic_name[i], - gs_output_semantic_index[i]); - } - } -#endif - - /* free old shader state, if any */ - if (stgp->tgsi.tokens) { - st_free_tokens(stgp->tgsi.tokens); - stgp->tgsi.tokens = NULL; - } - ureg_property(ureg, TGSI_PROPERTY_GS_INPUT_PRIM, stgp->Base.InputType); ureg_property(ureg, TGSI_PROPERTY_GS_OUTPUT_PRIM, stgp->Base.OutputType); ureg_property(ureg, TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES, stgp->Base.VerticesOut); ureg_property(ureg, TGSI_PROPERTY_GS_INVOCATIONS, stgp->Base.Invocations); - if (stgp->glsl_to_tgsi) - st_translate_program(st->ctx, - TGSI_PROCESSOR_GEOMETRY, - ureg, - stgp->glsl_to_tgsi, - &stgp->Base.Base, - /* inputs */ - gs_num_inputs, - inputMapping, - stgp->input_semantic_name, - stgp->input_semantic_index, - NULL, - NULL, - /* outputs */ - gs_num_outputs, - outputMapping, - gs_output_semantic_name, - gs_output_semantic_index, - FALSE, - FALSE); - else - st_translate_mesa_program(st->ctx, - TGSI_PROCESSOR_GEOMETRY, - ureg, - &stgp->Base.Base, - /* inputs */ - gs_num_inputs, - inputMapping, - stgp->input_semantic_name, - stgp->input_semantic_index, - NULL, - /* outputs */ - gs_num_outputs, - outputMapping, - gs_output_semantic_name, - gs_output_semantic_index, - FALSE, - FALSE); - - stgp->num_inputs = gs_num_inputs; - stgp->tgsi.tokens = ureg_get_tokens( ureg, NULL ); - ureg_destroy( ureg ); - - if (stgp->glsl_to_tgsi) { - st_translate_stream_output_info(stgp->glsl_to_tgsi, - outputMapping, - &stgp->tgsi.stream_output); - } + st_translate_program(st->ctx, + TGSI_PROCESSOR_GEOMETRY, + ureg, + stgp->glsl_to_tgsi, + &stgp->Base.Base, + /* inputs */ + gs_num_inputs, + inputMapping, + input_semantic_name, + input_semantic_index, + NULL, + NULL, + /* outputs */ + gs_num_outputs, + outputMapping, + gs_output_semantic_name, + gs_output_semantic_index, + FALSE, + FALSE); + + state.tokens = ureg_get_tokens(ureg, NULL); + ureg_destroy(ureg); + + st_translate_stream_output_info(stgp->glsl_to_tgsi, + outputMapping, + &state.stream_output); if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) { _mesa_print_program(&stgp->Base.Base); @@ -1187,13 +1103,15 @@ st_translate_geometry_program(struct st_context *st, } if (ST_DEBUG & DEBUG_TGSI) { - tgsi_dump(stgp->tgsi.tokens, 0); + tgsi_dump(state.tokens, 0); debug_printf("\n"); } /* fill in new variant */ - gpv->driver_shader = pipe->create_gs_state(pipe, &stgp->tgsi); + gpv->driver_shader = pipe->create_gs_state(pipe, &state); gpv->key = *key; + + ureg_free_tokens(state.tokens); return gpv; } @@ -1229,51 +1147,6 @@ st_get_gp_variant(struct st_context *st, } - - -/** - * Debug- print current shader text - */ -void -st_print_shaders(struct gl_context *ctx) -{ - struct gl_shader_program **shProg = ctx->_Shader->CurrentProgram; - unsigned j; - - for (j = 0; j < 3; j++) { - unsigned i; - - if (shProg[j] == NULL) - continue; - - for (i = 0; i < shProg[j]->NumShaders; i++) { - struct gl_shader *sh; - - switch (shProg[j]->Shaders[i]->Type) { - case GL_VERTEX_SHADER: - sh = (i != 0) ? NULL : shProg[j]->Shaders[i]; - break; - case GL_GEOMETRY_SHADER_ARB: - sh = (i != 1) ? NULL : shProg[j]->Shaders[i]; - break; - case GL_FRAGMENT_SHADER: - sh = (i != 2) ? NULL : shProg[j]->Shaders[i]; - break; - default: - assert(0); - sh = NULL; - break; - } - - if (sh != NULL) { - printf("GLSL shader %u of %u:\n", i, shProg[j]->NumShaders); - printf("%s\n", sh->Source); - } - } - } -} - - /** * Vert/Geom/Frag programs have per-context variants. Free all the * variants attached to the given program which match the given context. @@ -1374,7 +1247,7 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData) destroy_program_variants(st, shProg->Shaders[i]->Program); } - for (i = 0; i < Elements(shProg->_LinkedShaders); i++) { + for (i = 0; i < ARRAY_SIZE(shProg->_LinkedShaders); i++) { if (shProg->_LinkedShaders[i]) destroy_program_variants(st, shProg->_LinkedShaders[i]->Program); } diff --git a/mesalib/src/mesa/state_tracker/st_program.h b/mesalib/src/mesa/state_tracker/st_program.h index 870d0d57a..451d7bb6a 100644 --- a/mesalib/src/mesa/state_tracker/st_program.h +++ b/mesalib/src/mesa/state_tracker/st_program.h @@ -203,49 +203,31 @@ struct st_geometry_program struct gl_geometry_program Base; /**< The Mesa geometry program */ struct glsl_to_tgsi_visitor* glsl_to_tgsi; - /** map GP input back to VP output */ - GLuint input_map[PIPE_MAX_SHADER_INPUTS]; - - /** maps a Mesa VARYING_SLOT_x to a packed TGSI input index */ - GLuint input_to_index[VARYING_SLOT_MAX]; - /** maps a TGSI input index back to a Mesa VARYING_SLOT_x */ - GLuint index_to_input[PIPE_MAX_SHADER_INPUTS]; - - GLuint num_inputs; - - GLuint input_to_slot[VARYING_SLOT_MAX]; /**< Maps VARYING_SLOT_x to slot */ - GLuint num_input_slots; - - ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; - ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS]; - - struct pipe_shader_state tgsi; - struct st_gp_variant *variants; }; -static INLINE struct st_fragment_program * +static inline struct st_fragment_program * st_fragment_program( struct gl_fragment_program *fp ) { return (struct st_fragment_program *)fp; } -static INLINE struct st_vertex_program * +static inline struct st_vertex_program * st_vertex_program( struct gl_vertex_program *vp ) { return (struct st_vertex_program *)vp; } -static INLINE struct st_geometry_program * +static inline struct st_geometry_program * st_geometry_program( struct gl_geometry_program *gp ) { return (struct st_geometry_program *)gp; } -static INLINE void +static inline void st_reference_vertprog(struct st_context *st, struct st_vertex_program **ptr, struct st_vertex_program *prog) @@ -255,7 +237,7 @@ st_reference_vertprog(struct st_context *st, (struct gl_program *) prog); } -static INLINE void +static inline void st_reference_geomprog(struct st_context *st, struct st_geometry_program **ptr, struct st_geometry_program *prog) @@ -265,7 +247,7 @@ st_reference_geomprog(struct st_context *st, (struct gl_program *) prog); } -static INLINE void +static inline void st_reference_fragprog(struct st_context *st, struct st_fragment_program **ptr, struct st_fragment_program *prog) @@ -278,7 +260,7 @@ st_reference_fragprog(struct st_context *st, /** * This defines mapping from Mesa VARYING_SLOTs to TGSI GENERIC slots. */ -static INLINE unsigned +static inline unsigned st_get_generic_varying_index(struct st_context *st, GLuint attr) { if (attr >= VARYING_SLOT_VAR0) { @@ -340,10 +322,6 @@ extern void st_release_gp_variants(struct st_context *st, struct st_geometry_program *stgp); - -extern void -st_print_shaders(struct gl_context *ctx); - extern void st_destroy_program_variants(struct st_context *st); diff --git a/mesalib/src/mesa/state_tracker/st_texture.h b/mesalib/src/mesa/state_tracker/st_texture.h index 2f540295f..6b7f8c750 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.h +++ b/mesalib/src/mesa/state_tracker/st_texture.h @@ -117,32 +117,32 @@ struct st_texture_object }; -static INLINE struct st_texture_image * +static inline struct st_texture_image * st_texture_image(struct gl_texture_image *img) { return (struct st_texture_image *) img; } -static INLINE const struct st_texture_image * +static inline const struct st_texture_image * st_texture_image_const(const struct gl_texture_image *img) { return (const struct st_texture_image *) img; } -static INLINE struct st_texture_object * +static inline struct st_texture_object * st_texture_object(struct gl_texture_object *obj) { return (struct st_texture_object *) obj; } -static INLINE const struct st_texture_object * +static inline const struct st_texture_object * st_texture_object_const(const struct gl_texture_object *obj) { return (const struct st_texture_object *) obj; } -static INLINE struct pipe_resource * +static inline struct pipe_resource * st_get_texobj_resource(struct gl_texture_object *texObj) { struct st_texture_object *stObj = st_texture_object(texObj); @@ -150,14 +150,14 @@ st_get_texobj_resource(struct gl_texture_object *texObj) } -static INLINE struct pipe_resource * +static inline struct pipe_resource * st_get_stobj_resource(struct st_texture_object *stObj) { return stObj ? stObj->pt : NULL; } -static INLINE struct pipe_sampler_view * +static inline struct pipe_sampler_view * st_create_texture_sampler_view_format(struct pipe_context *pipe, struct pipe_resource *texture, enum pipe_format format) @@ -169,7 +169,7 @@ st_create_texture_sampler_view_format(struct pipe_context *pipe, return pipe->create_sampler_view(pipe, texture, &templ); } -static INLINE struct pipe_sampler_view * +static inline struct pipe_sampler_view * st_create_texture_sampler_view(struct pipe_context *pipe, struct pipe_resource *texture) { diff --git a/mesalib/src/mesa/swrast/s_aaline.c b/mesalib/src/mesa/swrast/s_aaline.c index 6aea9d545..f3258e813 100644 --- a/mesalib/src/mesa/swrast/s_aaline.c +++ b/mesalib/src/mesa/swrast/s_aaline.c @@ -23,6 +23,7 @@ */ +#include "c99_math.h" #include "main/glheader.h" #include "main/imports.h" #include "main/macros.h" @@ -203,7 +204,7 @@ compute_lambda(const GLfloat sPlane[4], const GLfloat tPlane[4], if (rho2 == 0.0F) return 0.0; else - return (GLfloat) (LOGF(rho2) * 1.442695 * 0.5);/* 1.442695 = 1/log(2) */ + return logf(rho2) * 1.442695f * 0.5f;/* 1.442695 = 1/log(2) */ } @@ -477,7 +478,7 @@ _swrast_choose_aa_line_function(struct gl_context *ctx) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - ASSERT(ctx->Line.SmoothFlag); + assert(ctx->Line.SmoothFlag); if (ctx->Texture._EnabledCoordUnits != 0 || _swrast_use_fragment_program(ctx) diff --git a/mesalib/src/mesa/swrast/s_aatriangle.c b/mesalib/src/mesa/swrast/s_aatriangle.c index 219282748..1d076cc7d 100644 --- a/mesalib/src/mesa/swrast/s_aatriangle.c +++ b/mesalib/src/mesa/swrast/s_aatriangle.c @@ -102,7 +102,7 @@ do { \ static inline GLfloat solve_plane(GLfloat x, GLfloat y, const GLfloat plane[4]) { - ASSERT(plane[2] != 0.0F); + assert(plane[2] != 0.0F); return (plane[3] + plane[0] * x + plane[1] * y) / -plane[2]; } @@ -201,7 +201,7 @@ compute_coveragef(const GLfloat v0[3], const GLfloat v1[3], GLint stop = 4, i; GLfloat insideCount = 16.0F; - ASSERT(dx0 * dy1 - dx1 * dy0 >= 0.0); /* area >= 0.0 */ + assert(dx0 * dy1 - dx1 * dy0 >= 0.0); /* area >= 0.0 */ for (i = 0; i < stop; i++) { const GLfloat sx = x + samples[i][0]; @@ -282,7 +282,7 @@ _swrast_set_aa_triangle_function(struct gl_context *ctx) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - ASSERT(ctx->Polygon.SmoothFlag); + assert(ctx->Polygon.SmoothFlag); if (ctx->Texture._EnabledCoordUnits != 0 || _swrast_use_fragment_program(ctx) @@ -294,5 +294,5 @@ _swrast_set_aa_triangle_function(struct gl_context *ctx) SWRAST_CONTEXT(ctx)->Triangle = rgba_aa_tri; } - ASSERT(SWRAST_CONTEXT(ctx)->Triangle); + assert(SWRAST_CONTEXT(ctx)->Triangle); } diff --git a/mesalib/src/mesa/swrast/s_aatritemp.h b/mesalib/src/mesa/swrast/s_aatritemp.h index fd374a524..230dab816 100644 --- a/mesalib/src/mesa/swrast/s_aatritemp.h +++ b/mesalib/src/mesa/swrast/s_aatritemp.h @@ -284,7 +284,7 @@ /* (cx,cy) = center of fragment */ const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; SWspanarrays *array = span.array; - ASSERT(ix >= 0); + assert(ix >= 0); array->coverage[ix] = coverage; #ifdef DO_Z array->z[ix] = (GLuint) solve_plane(cx, cy, zPlane); diff --git a/mesalib/src/mesa/swrast/s_alpha.c b/mesalib/src/mesa/swrast/s_alpha.c index fba143a52..b1a7ff132 100644 --- a/mesalib/src/mesa/swrast/s_alpha.c +++ b/mesalib/src/mesa/swrast/s_alpha.c @@ -130,7 +130,7 @@ _swrast_alpha_test(const struct gl_context *ctx, SWspan *span) } else { /* Interpolate alpha values */ - ASSERT(span->interpMask & SPAN_RGBA); + assert(span->interpMask & SPAN_RGBA); if (span->array->ChanType == GL_UNSIGNED_BYTE) { const GLfixed alphaStep = span->alphaStep; GLfixed alpha = span->alpha; diff --git a/mesalib/src/mesa/swrast/s_atifragshader.c b/mesalib/src/mesa/swrast/s_atifragshader.c index 1e91e2bee..0bf03771f 100644 --- a/mesalib/src/mesa/swrast/s_atifragshader.c +++ b/mesalib/src/mesa/swrast/s_atifragshader.c @@ -571,7 +571,7 @@ _swrast_exec_fragment_shader(struct gl_context * ctx, SWspan *span) GLuint i; /* incoming colors should be floats */ - ASSERT(span->array->ChanType == GL_FLOAT); + assert(span->array->ChanType == GL_FLOAT); for (i = 0; i < span->end; i++) { if (span->array->mask[i]) { diff --git a/mesalib/src/mesa/swrast/s_bitmap.c b/mesalib/src/mesa/swrast/s_bitmap.c index e364ec129..324daea36 100644 --- a/mesalib/src/mesa/swrast/s_bitmap.c +++ b/mesalib/src/mesa/swrast/s_bitmap.c @@ -55,7 +55,7 @@ _swrast_Bitmap( struct gl_context *ctx, GLint px, GLint py, GLuint count = 0; SWspan span; - ASSERT(ctx->RenderMode == GL_RENDER); + assert(ctx->RenderMode == GL_RENDER); if (!_mesa_check_conditional_render(ctx)) return; /* don't draw */ @@ -154,8 +154,8 @@ _swrast_Bitmap( struct gl_context *ctx, GLint px, GLint py, GLint row, col; SWspan span; - ASSERT(ctx->RenderMode == GL_RENDER); - ASSERT(bitmap); + assert(ctx->RenderMode == GL_RENDER); + assert(bitmap); swrast_render_start(ctx); diff --git a/mesalib/src/mesa/swrast/s_blend.c b/mesalib/src/mesa/swrast/s_blend.c index 1037b6236..7cb119407 100644 --- a/mesalib/src/mesa/swrast/s_blend.c +++ b/mesalib/src/mesa/swrast/s_blend.c @@ -75,10 +75,10 @@ blend_noop(struct gl_context *ctx, GLuint n, const GLubyte mask[], { GLint bytes; - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].SrcRGB == GL_ZERO); - ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE); + assert(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].SrcRGB == GL_ZERO); + assert(ctx->Color.Blend[0].DstRGB == GL_ONE); (void) ctx; /* just memcpy */ @@ -101,10 +101,10 @@ static void _BLENDAPI blend_replace(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].SrcRGB == GL_ONE); - ASSERT(ctx->Color.Blend[0].DstRGB == GL_ZERO); + assert(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].SrcRGB == GL_ONE); + assert(ctx->Color.Blend[0].DstRGB == GL_ZERO); (void) ctx; (void) n; (void) mask; @@ -125,13 +125,13 @@ blend_transparency_ubyte(struct gl_context *ctx, GLuint n, const GLubyte mask[], const GLubyte (*dest)[4] = (const GLubyte (*)[4]) dst; GLuint i; - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(chanType == GL_UNSIGNED_BYTE); + assert(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA); + assert(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA); + assert(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA); + assert(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA); + assert(chanType == GL_UNSIGNED_BYTE); (void) ctx; @@ -148,10 +148,10 @@ blend_transparency_ubyte(struct gl_context *ctx, GLuint n, const GLubyte mask[], const GLint g = DIV255((rgba[i][GCOMP] - dest[i][GCOMP]) * t) + dest[i][GCOMP]; const GLint b = DIV255((rgba[i][BCOMP] - dest[i][BCOMP]) * t) + dest[i][BCOMP]; const GLint a = DIV255((rgba[i][ACOMP] - dest[i][ACOMP]) * t) + dest[i][ACOMP]; - ASSERT(r <= 255); - ASSERT(g <= 255); - ASSERT(b <= 255); - ASSERT(a <= 255); + assert(r <= 255); + assert(g <= 255); + assert(b <= 255); + assert(a <= 255); rgba[i][RCOMP] = (GLubyte) r; rgba[i][GCOMP] = (GLubyte) g; rgba[i][BCOMP] = (GLubyte) b; @@ -170,13 +170,13 @@ blend_transparency_ushort(struct gl_context *ctx, GLuint n, const GLubyte mask[] const GLushort (*dest)[4] = (const GLushort (*)[4]) dst; GLuint i; - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(chanType == GL_UNSIGNED_SHORT); + assert(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA); + assert(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA); + assert(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA); + assert(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA); + assert(chanType == GL_UNSIGNED_SHORT); (void) ctx; @@ -208,13 +208,13 @@ blend_transparency_float(struct gl_context *ctx, GLuint n, const GLubyte mask[], const GLfloat (*dest)[4] = (const GLfloat (*)[4]) dst; GLuint i; - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(chanType == GL_FLOAT); + assert(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA); + assert(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA); + assert(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA); + assert(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA); + assert(chanType == GL_FLOAT); (void) ctx; @@ -248,10 +248,10 @@ blend_add(struct gl_context *ctx, GLuint n, const GLubyte mask[], { GLuint i; - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].SrcRGB == GL_ONE); - ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE); + assert(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].SrcRGB == GL_ONE); + assert(ctx->Color.Blend[0].DstRGB == GL_ONE); (void) ctx; if (chanType == GL_UNSIGNED_BYTE) { @@ -289,7 +289,7 @@ blend_add(struct gl_context *ctx, GLuint n, const GLubyte mask[], else { GLfloat (*rgba)[4] = (GLfloat (*)[4]) src; const GLfloat (*dest)[4] = (const GLfloat (*)[4]) dst; - ASSERT(chanType == GL_FLOAT); + assert(chanType == GL_FLOAT); for (i=0;i<n;i++) { if (mask[i]) { /* don't RGB clamp to max */ @@ -313,8 +313,8 @@ blend_min(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { GLuint i; - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_MIN); - ASSERT(ctx->Color.Blend[0].EquationA == GL_MIN); + assert(ctx->Color.Blend[0].EquationRGB == GL_MIN); + assert(ctx->Color.Blend[0].EquationA == GL_MIN); (void) ctx; if (chanType == GL_UNSIGNED_BYTE) { @@ -344,7 +344,7 @@ blend_min(struct gl_context *ctx, GLuint n, const GLubyte mask[], else { GLfloat (*rgba)[4] = (GLfloat (*)[4]) src; const GLfloat (*dest)[4] = (const GLfloat (*)[4]) dst; - ASSERT(chanType == GL_FLOAT); + assert(chanType == GL_FLOAT); for (i=0;i<n;i++) { if (mask[i]) { rgba[i][RCOMP] = MIN2( rgba[i][RCOMP], dest[i][RCOMP] ); @@ -366,8 +366,8 @@ blend_max(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { GLuint i; - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_MAX); - ASSERT(ctx->Color.Blend[0].EquationA == GL_MAX); + assert(ctx->Color.Blend[0].EquationRGB == GL_MAX); + assert(ctx->Color.Blend[0].EquationA == GL_MAX); (void) ctx; if (chanType == GL_UNSIGNED_BYTE) { @@ -397,7 +397,7 @@ blend_max(struct gl_context *ctx, GLuint n, const GLubyte mask[], else { GLfloat (*rgba)[4] = (GLfloat (*)[4]) src; const GLfloat (*dest)[4] = (const GLfloat (*)[4]) dst; - ASSERT(chanType == GL_FLOAT); + assert(chanType == GL_FLOAT); for (i=0;i<n;i++) { if (mask[i]) { rgba[i][RCOMP] = MAX2( rgba[i][RCOMP], dest[i][RCOMP] ); @@ -450,7 +450,7 @@ blend_modulate(struct gl_context *ctx, GLuint n, const GLubyte mask[], else { GLfloat (*rgba)[4] = (GLfloat (*)[4]) src; const GLfloat (*dest)[4] = (const GLfloat (*)[4]) dst; - ASSERT(chanType == GL_FLOAT); + assert(chanType == GL_FLOAT); for (i=0;i<n;i++) { if (mask[i]) { rgba[i][RCOMP] = rgba[i][RCOMP] * dest[i][RCOMP]; @@ -998,9 +998,9 @@ _swrast_blend_span(struct gl_context *ctx, struct gl_renderbuffer *rb, SWspan *s SWcontext *swrast = SWRAST_CONTEXT(ctx); void *rbPixels; - ASSERT(span->end <= SWRAST_MAX_WIDTH); - ASSERT(span->arrayMask & SPAN_RGBA); - ASSERT(!ctx->Color.ColorLogicOpEnabled); + assert(span->end <= SWRAST_MAX_WIDTH); + assert(span->arrayMask & SPAN_RGBA); + assert(!ctx->Color.ColorLogicOpEnabled); rbPixels = _swrast_get_dest_rgba(ctx, rb, span); diff --git a/mesalib/src/mesa/swrast/s_blit.c b/mesalib/src/mesa/swrast/s_blit.c index 16e5b8c1c..3e838a41d 100644 --- a/mesalib/src/mesa/swrast/s_blit.c +++ b/mesalib/src/mesa/swrast/s_blit.c @@ -52,8 +52,8 @@ NAME(GLint srcWidth, GLint dstWidth, \ if (flip) { \ for (dstCol = 0; dstCol < dstWidth; dstCol++) { \ GLint srcCol = (dstCol * srcWidth) / dstWidth; \ - ASSERT(srcCol >= 0); \ - ASSERT(srcCol < srcWidth); \ + assert(srcCol >= 0); \ + assert(srcCol < srcWidth); \ srcCol = srcWidth - 1 - srcCol; /* flip */ \ if (SIZE == 1) { \ dst[dstCol] = src[srcCol]; \ @@ -73,8 +73,8 @@ NAME(GLint srcWidth, GLint dstWidth, \ else { \ for (dstCol = 0; dstCol < dstWidth; dstCol++) { \ GLint srcCol = (dstCol * srcWidth) / dstWidth; \ - ASSERT(srcCol >= 0); \ - ASSERT(srcCol < srcWidth); \ + assert(srcCol >= 0); \ + assert(srcCol < srcWidth); \ if (SIZE == 1) { \ dst[dstCol] = src[srcCol]; \ } \ @@ -299,8 +299,8 @@ blit_nearest(struct gl_context *ctx, GLint srcRow = IROUND(srcRowF); GLubyte *dstRowStart = dstMap + dstRowStride * dstRow; - ASSERT(srcRow >= 0); - ASSERT(srcRow < srcHeight); + assert(srcRow >= 0); + assert(srcRow < srcHeight); if (invertY) { srcRow = srcHeight - 1 - srcRow; @@ -412,8 +412,8 @@ resample_linear_row_ub(GLint srcWidth, GLint dstWidth, GLfloat colWeight = srcCol - srcCol0; /* fractional part of srcCol */ GLfloat red, green, blue, alpha; - ASSERT(srcCol0 < srcWidth); - ASSERT(srcCol1 <= srcWidth); + assert(srcCol0 < srcWidth); + assert(srcCol1 <= srcWidth); if (srcCol1 == srcWidth) { /* last column fudge */ @@ -467,8 +467,8 @@ resample_linear_row_float(GLint srcWidth, GLint dstWidth, GLfloat colWeight = srcCol - srcCol0; /* fractional part of srcCol */ GLfloat red, green, blue, alpha; - ASSERT(srcCol0 < srcWidth); - ASSERT(srcCol1 <= srcWidth); + assert(srcCol0 < srcWidth); + assert(srcCol1 <= srcWidth); if (srcCol1 == srcWidth) { /* last column fudge */ @@ -801,7 +801,7 @@ _swrast_BlitFramebuffer(struct gl_context *ctx, } } else { - ASSERT(filter == GL_LINEAR); + assert(filter == GL_LINEAR); if (mask & GL_COLOR_BUFFER_BIT) { /* depth/stencil not allowed */ blit_linear(ctx, readFb, drawFb, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1); diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c index ad11aa2c1..51cc22760 100644 --- a/mesalib/src/mesa/swrast/s_context.c +++ b/mesalib/src/mesa/swrast/s_context.c @@ -251,6 +251,7 @@ _swrast_update_fog_state( struct gl_context *ctx ) const struct gl_fragment_program *fp = ctx->FragmentProgram._Current; assert(fp == NULL || fp->Base.Target == GL_FRAGMENT_PROGRAM_ARB); + (void) fp; /* silence unused var warning */ /* determine if fog is needed, and if so, which fog mode */ swrast->_FogEnabled = (!_swrast_use_fragment_program(ctx) && @@ -351,7 +352,7 @@ _swrast_validate_triangle( struct gl_context *ctx, _swrast_validate_derived( ctx ); swrast->choose_triangle( ctx ); - ASSERT(swrast->Triangle); + assert(swrast->Triangle); if (swrast->SpecularVertexAdd) { /* separate specular color, but no texture */ @@ -373,7 +374,7 @@ _swrast_validate_line( struct gl_context *ctx, const SWvertex *v0, const SWverte _swrast_validate_derived( ctx ); swrast->choose_line( ctx ); - ASSERT(swrast->Line); + assert(swrast->Line); if (swrast->SpecularVertexAdd) { swrast->SpecLine = swrast->Line; diff --git a/mesalib/src/mesa/swrast/s_copypix.c b/mesalib/src/mesa/swrast/s_copypix.c index e21c69dbc..17140ad2d 100644 --- a/mesalib/src/mesa/swrast/s_copypix.c +++ b/mesalib/src/mesa/swrast/s_copypix.c @@ -158,7 +158,7 @@ copy_rgba_pixels(struct gl_context *ctx, GLint srcx, GLint srcy, p = NULL; } - ASSERT(width < SWRAST_MAX_WIDTH); + assert(width < SWRAST_MAX_WIDTH); for (row = 0; row < height; row++, sy += stepy, dy += stepy) { GLvoid *rgba = span.array->attribs[VARYING_SLOT_COL0]; @@ -468,7 +468,7 @@ swrast_fast_copy_pixels(struct gl_context *ctx, dstRb = dstFb->Attachment[BUFFER_DEPTH].Renderbuffer; } else { - ASSERT(type == GL_DEPTH_STENCIL_EXT); + assert(type == GL_DEPTH_STENCIL_EXT); /* XXX correct? */ srcRb = srcFb->Attachment[BUFFER_DEPTH].Renderbuffer; dstRb = dstFb->Attachment[BUFFER_DEPTH].Renderbuffer; diff --git a/mesalib/src/mesa/swrast/s_drawpix.c b/mesalib/src/mesa/swrast/s_drawpix.c index c99251904..bf427266c 100644 --- a/mesalib/src/mesa/swrast/s_drawpix.c +++ b/mesalib/src/mesa/swrast/s_drawpix.c @@ -373,7 +373,7 @@ draw_depth_pixels( struct gl_context *ctx, GLint x, GLint y, while (skipPixels < width) { const GLint spanWidth = MIN2(width - skipPixels, SWRAST_MAX_WIDTH); GLint row; - ASSERT(span.end <= SWRAST_MAX_WIDTH); + assert(span.end <= SWRAST_MAX_WIDTH); for (row = 0; row < height; row++) { const GLvoid *zSrc = _mesa_image_address2d(unpack, pixels, width, height, @@ -595,8 +595,8 @@ draw_depth_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, depthRb = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; stencilRb = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer; - ASSERT(depthRb); - ASSERT(stencilRb); + assert(depthRb); + assert(stencilRb); if (depthRb == stencilRb && (depthRb->Format == MESA_FORMAT_S8_UINT_Z24_UNORM || diff --git a/mesalib/src/mesa/swrast/s_fog.c b/mesalib/src/mesa/swrast/s_fog.c index 34b7c2d28..e270b7e24 100644 --- a/mesalib/src/mesa/swrast/s_fog.c +++ b/mesalib/src/mesa/swrast/s_fog.c @@ -23,6 +23,7 @@ */ +#include "c99_math.h" #include "main/glheader.h" #include "main/colormac.h" #include "main/macros.h" @@ -49,12 +50,12 @@ _swrast_z_to_fogfactor(struct gl_context *ctx, GLfloat z) return CLAMP(f, 0.0F, 1.0F); case GL_EXP: d = ctx->Fog.Density; - f = EXPF(-d * z); + f = expf(-d * z); f = CLAMP(f, 0.0F, 1.0F); return f; case GL_EXP2: d = ctx->Fog.Density; - f = EXPF(-(d * d * z * z)); + f = expf(-(d * d * z * z)); f = CLAMP(f, 0.0F, 1.0F); return f; default: @@ -66,14 +67,14 @@ _swrast_z_to_fogfactor(struct gl_context *ctx, GLfloat z) #define LINEAR_FOG(f, coord) f = (fogEnd - coord) * fogScale -#define EXP_FOG(f, coord) f = EXPF(density * coord) +#define EXP_FOG(f, coord) f = expf(density * coord) #define EXP2_FOG(f, coord) \ do { \ GLfloat tmp = negDensitySquared * coord * coord; \ if (tmp < FLT_MIN_10_EXP) \ tmp = FLT_MIN_10_EXP; \ - f = EXPF(tmp); \ + f = expf(tmp); \ } while(0) @@ -91,7 +92,7 @@ if (span->arrayAttribs & VARYING_BIT_FOGC) { \ GLuint i; \ for (i = 0; i < span->end; i++) { \ const GLfloat fogCoord = span->array->attribs[VARYING_SLOT_FOGC][i][0]; \ - const GLfloat c = FABSF(fogCoord); \ + const GLfloat c = fabsf(fogCoord); \ GLfloat f, oneMinusF; \ FOG_FUNC(f, c); \ f = CLAMP(f, 0.0F, 1.0F); \ @@ -108,7 +109,7 @@ else { \ GLfloat w = span->attrStart[VARYING_SLOT_POS][3]; \ GLuint i; \ for (i = 0; i < span->end; i++) { \ - const GLfloat c = FABSF(fogCoord) / w; \ + const GLfloat c = fabsf(fogCoord) / w; \ GLfloat f, oneMinusF; \ FOG_FUNC(f, c); \ f = CLAMP(f, 0.0F, 1.0F); \ @@ -134,8 +135,8 @@ _swrast_fog_rgba_span( const struct gl_context *ctx, SWspan *span ) const SWcontext *swrast = CONST_SWRAST_CONTEXT(ctx); GLfloat rFog, gFog, bFog; - ASSERT(swrast->_FogEnabled); - ASSERT(span->arrayMask & SPAN_RGBA); + assert(swrast->_FogEnabled); + assert(span->arrayMask & SPAN_RGBA); /* compute (scaled) fog color */ if (span->array->ChanType == GL_UNSIGNED_BYTE) { @@ -174,7 +175,7 @@ _swrast_fog_rgba_span( const struct gl_context *ctx, SWspan *span ) } else { GLfloat (*rgba)[4] = span->array->attribs[VARYING_SLOT_COL0]; - ASSERT(span->array->ChanType == GL_FLOAT); + assert(span->array->ChanType == GL_FLOAT); FOG_LOOP(GLfloat, LINEAR_FOG); } } @@ -193,7 +194,7 @@ _swrast_fog_rgba_span( const struct gl_context *ctx, SWspan *span ) } else { GLfloat (*rgba)[4] = span->array->attribs[VARYING_SLOT_COL0]; - ASSERT(span->array->ChanType == GL_FLOAT); + assert(span->array->ChanType == GL_FLOAT); FOG_LOOP(GLfloat, EXP_FOG); } } @@ -212,7 +213,7 @@ _swrast_fog_rgba_span( const struct gl_context *ctx, SWspan *span ) } else { GLfloat (*rgba)[4] = span->array->attribs[VARYING_SLOT_COL0]; - ASSERT(span->array->ChanType == GL_FLOAT); + assert(span->array->ChanType == GL_FLOAT); FOG_LOOP(GLfloat, EXP2_FOG); } } @@ -237,7 +238,7 @@ _swrast_fog_rgba_span( const struct gl_context *ctx, SWspan *span ) } else { GLfloat (*rgba)[4] = span->array->attribs[VARYING_SLOT_COL0]; - ASSERT(span->array->ChanType == GL_FLOAT); + assert(span->array->ChanType == GL_FLOAT); FOG_LOOP(GLfloat, BLEND_FOG); } } diff --git a/mesalib/src/mesa/swrast/s_fragprog.c b/mesalib/src/mesa/swrast/s_fragprog.c index 1d7c33619..12bcda311 100644 --- a/mesalib/src/mesa/swrast/s_fragprog.c +++ b/mesalib/src/mesa/swrast/s_fragprog.c @@ -273,7 +273,7 @@ _swrast_exec_fragment_program( struct gl_context *ctx, SWspan *span ) /* incoming colors should be floats */ if (program->Base.InputsRead & VARYING_BIT_COL0) { - ASSERT(span->array->ChanType == GL_FLOAT); + assert(span->array->ChanType == GL_FLOAT); } run_program(ctx, span, 0, span->end); diff --git a/mesalib/src/mesa/swrast/s_lines.c b/mesalib/src/mesa/swrast/s_lines.c index b63296aa4..3e626b9e0 100644 --- a/mesalib/src/mesa/swrast/s_lines.c +++ b/mesalib/src/mesa/swrast/s_lines.c @@ -67,7 +67,7 @@ draw_wide_line( struct gl_context *ctx, SWspan *span, GLboolean xMajor ) ctx->Const.MaxLineWidth); GLint start; - ASSERT(span->end < SWRAST_MAX_WIDTH); + assert(span->end < SWRAST_MAX_WIDTH); if (width & 1) start = width / 2; @@ -233,7 +233,7 @@ _swrast_choose_line( struct gl_context *ctx ) if (ctx->Line.SmoothFlag) { /* antialiased lines */ _swrast_choose_aa_line_function(ctx); - ASSERT(swrast->Line); + assert(swrast->Line); } else if (ctx->Texture._EnabledCoordUnits || _swrast_use_fragment_program(ctx) @@ -252,8 +252,8 @@ _swrast_choose_line( struct gl_context *ctx ) #endif } else { - ASSERT(!ctx->Depth.Test); - ASSERT(ctx->Line.Width == 1.0); + assert(!ctx->Depth.Test); + assert(ctx->Line.Width == 1.0); /* simple lines */ USE(simple_no_z_rgba_line); } @@ -262,7 +262,7 @@ _swrast_choose_line( struct gl_context *ctx ) USE(_swrast_feedback_line); } else { - ASSERT(ctx->RenderMode == GL_SELECT); + assert(ctx->RenderMode == GL_SELECT); USE(_swrast_select_line); } } diff --git a/mesalib/src/mesa/swrast/s_linetemp.h b/mesalib/src/mesa/swrast/s_linetemp.h index 7b1eac36a..352c88428 100644 --- a/mesalib/src/mesa/swrast/s_linetemp.h +++ b/mesalib/src/mesa/swrast/s_linetemp.h @@ -212,8 +212,8 @@ NAME( struct gl_context *ctx, const SWvertex *vert0, const SWvertex *vert1 ) #endif } - ASSERT(dx >= 0); - ASSERT(dy >= 0); + assert(dx >= 0); + assert(dy >= 0); numPixels = MAX2(dx, dy); diff --git a/mesalib/src/mesa/swrast/s_logic.c b/mesalib/src/mesa/swrast/s_logic.c index f68273fd2..c7cac2e40 100644 --- a/mesalib/src/mesa/swrast/s_logic.c +++ b/mesalib/src/mesa/swrast/s_logic.c @@ -193,8 +193,8 @@ _swrast_logicop_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, { void *rbPixels; - ASSERT(span->end < SWRAST_MAX_WIDTH); - ASSERT(span->arrayMask & SPAN_RGBA); + assert(span->end < SWRAST_MAX_WIDTH); + assert(span->arrayMask & SPAN_RGBA); rbPixels = _swrast_get_dest_rgba(ctx, rb, span); diff --git a/mesalib/src/mesa/swrast/s_masking.c b/mesalib/src/mesa/swrast/s_masking.c index c3aa41891..c95587b20 100644 --- a/mesalib/src/mesa/swrast/s_masking.c +++ b/mesalib/src/mesa/swrast/s_masking.c @@ -46,8 +46,8 @@ _swrast_mask_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, const GLuint n = span->end; void *rbPixels; - ASSERT(n < SWRAST_MAX_WIDTH); - ASSERT(span->arrayMask & SPAN_RGBA); + assert(n < SWRAST_MAX_WIDTH); + assert(span->arrayMask & SPAN_RGBA); rbPixels = _swrast_get_dest_rgba(ctx, rb, span); diff --git a/mesalib/src/mesa/swrast/s_points.c b/mesalib/src/mesa/swrast/s_points.c index b9bec237e..8180483ba 100644 --- a/mesalib/src/mesa/swrast/s_points.c +++ b/mesalib/src/mesa/swrast/s_points.c @@ -140,7 +140,7 @@ sprite_point(struct gl_context *ctx, const SWvertex *vert) if (attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7) { /* a texcoord attribute */ const GLuint u = attr - VARYING_SLOT_TEX0; - ASSERT(u < Elements(ctx->Point.CoordReplace)); + assert(u < ARRAY_SIZE(ctx->Point.CoordReplace)); if (ctx->Point.CoordReplace[u]) { tCoords[numTcoords++] = attr; @@ -504,7 +504,7 @@ pixel_point(struct gl_context *ctx, const SWvertex *vert) span->array->z[count] = (GLint) (vert->attrib[VARYING_SLOT_POS][2] + 0.5F); span->end = count + 1; - ASSERT(span->end <= SWRAST_MAX_WIDTH); + assert(span->end <= SWRAST_MAX_WIDTH); } diff --git a/mesalib/src/mesa/swrast/s_renderbuffer.c b/mesalib/src/mesa/swrast/s_renderbuffer.c index dfd3a6057..d8c4ed386 100644 --- a/mesalib/src/mesa/swrast/s_renderbuffer.c +++ b/mesalib/src/mesa/swrast/s_renderbuffer.c @@ -153,7 +153,7 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, } else { /* the internalFormat should have been error checked long ago */ - ASSERT(rb->_BaseFormat); + assert(rb->_BaseFormat); } return GL_TRUE; diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c index 321959df9..5d618f048 100644 --- a/mesalib/src/mesa/swrast/s_span.c +++ b/mesalib/src/mesa/swrast/s_span.c @@ -31,6 +31,7 @@ * \author Brian Paul */ +#include "c99_math.h" #include "main/glheader.h" #include "main/colormac.h" #include "main/format_pack.h" @@ -205,7 +206,7 @@ interpolate_active_attribs(struct gl_context *ctx, SWspan *span, v3 += dv3dx; w += dwdx; } - ASSERT((span->arrayAttribs & BITFIELD64_BIT(attr)) == 0); + assert((span->arrayAttribs & BITFIELD64_BIT(attr)) == 0); span->arrayAttribs |= BITFIELD64_BIT(attr); } ATTRIB_LOOP_END @@ -223,7 +224,7 @@ interpolate_int_colors(struct gl_context *ctx, SWspan *span) const GLuint n = span->end; GLuint i; - ASSERT(!(span->arrayMask & SPAN_RGBA)); + assert(!(span->arrayMask & SPAN_RGBA)); #endif switch (span->array->ChanType) { @@ -336,7 +337,7 @@ interpolate_float_colors(SWspan *span) } else { /* interpolate red/green/blue/alpha to get float colors */ - ASSERT(span->interpMask & SPAN_RGBA); + assert(span->interpMask & SPAN_RGBA); if (span->interpMask & SPAN_FLAT) { GLfloat r = FixedToFloat(span->red); GLfloat g = FixedToFloat(span->green); @@ -383,7 +384,7 @@ _swrast_span_interpolate_z( const struct gl_context *ctx, SWspan *span ) const GLuint n = span->end; GLuint i; - ASSERT(!(span->arrayMask & SPAN_Z)); + assert(!(span->arrayMask & SPAN_Z)); if (ctx->DrawBuffer->Visual.depthBits <= 16) { GLfixed zval = span->z; @@ -443,10 +444,10 @@ _swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy, GLfloat dsdy2 = (s + dsdy) / (q + dqdy) - s * invQ; GLfloat dtdy2 = (t + dtdy) / (q + dqdy) - t * invQ; GLfloat maxU, maxV, rho, lambda; - dsdx2 = FABSF(dsdx2); - dsdy2 = FABSF(dsdy2); - dtdx2 = FABSF(dtdx2); - dtdy2 = FABSF(dtdy2); + dsdx2 = fabsf(dsdx2); + dsdy2 = fabsf(dsdy2); + dtdx2 = fabsf(dtdx2); + dtdy2 = fabsf(dtdy2); maxU = MAX2(dsdx2, dsdy2) * texW; maxV = MAX2(dtdx2, dtdy2) * texH; rho = MAX2(maxU, maxV); @@ -658,7 +659,7 @@ stipple_polygon_span(struct gl_context *ctx, SWspan *span) { GLubyte *mask = span->array->mask; - ASSERT(ctx->Polygon.StippleFlag); + assert(ctx->Polygon.StippleFlag); if (span->arrayMask & SPAN_XY) { /* arrays of x/y pixel coords */ @@ -748,7 +749,7 @@ clip_span( struct gl_context *ctx, SWspan *span ) /* Clip to right */ if (x + n > xmax) { - ASSERT(x < xmax); + assert(x < xmax); n = span->end = xmax - x; } @@ -757,8 +758,8 @@ clip_span( struct gl_context *ctx, SWspan *span ) const GLint leftClip = xmin - x; GLuint i; - ASSERT(leftClip > 0); - ASSERT(x + n > xmin); + assert(leftClip > 0); + assert(x + n > xmin); /* Clip 'leftClip' pixels from the left side. * The span->leftClip field will be applied when we interpolate @@ -813,10 +814,10 @@ clip_span( struct gl_context *ctx, SWspan *span ) span->writeAll = GL_FALSE; } - ASSERT(span->x >= xmin); - ASSERT(span->x + span->end <= xmax); - ASSERT(span->y >= ymin); - ASSERT(span->y < ymax); + assert(span->x >= xmin); + assert(span->x + span->end <= xmax); + assert(span->y >= ymin); + assert(span->y < ymax); return GL_TRUE; /* some pixels visible */ } @@ -837,9 +838,9 @@ add_specular(struct gl_context *ctx, SWspan *span) GLfloat (*col1)[4] = span->array->attribs[VARYING_SLOT_COL1]; GLuint i; - ASSERT(!_swrast_use_fragment_program(ctx)); - ASSERT(span->arrayMask & SPAN_RGBA); - ASSERT(swrast->_ActiveAttribMask & VARYING_BIT_COL1); + assert(!_swrast_use_fragment_program(ctx)); + assert(span->arrayMask & SPAN_RGBA); + assert(swrast->_ActiveAttribMask & VARYING_BIT_COL1); (void) swrast; /* silence warning */ if (span->array->ChanType == GL_FLOAT) { @@ -859,8 +860,8 @@ add_specular(struct gl_context *ctx, SWspan *span) interpolate_active_attribs(ctx, span, VARYING_BIT_COL1); } - ASSERT(span->arrayAttribs & VARYING_BIT_COL0); - ASSERT(span->arrayAttribs & VARYING_BIT_COL1); + assert(span->arrayAttribs & VARYING_BIT_COL0); + assert(span->arrayAttribs & VARYING_BIT_COL1); for (i = 0; i < span->end; i++) { if (mask[i]) { @@ -887,8 +888,8 @@ apply_aa_coverage(SWspan *span) for (i = 0; i < span->end; i++) { const GLfloat a = rgba[i][ACOMP] * coverage[i]; rgba[i][ACOMP] = (GLubyte) CLAMP(a, 0.0, 255.0); - ASSERT(coverage[i] >= 0.0); - ASSERT(coverage[i] <= 1.0); + assert(coverage[i] >= 0.0); + assert(coverage[i] <= 1.0); } } else if (span->array->ChanType == GL_UNSIGNED_SHORT) { @@ -916,7 +917,7 @@ clamp_colors(SWspan *span) { GLfloat (*rgba)[4] = span->array->attribs[VARYING_SLOT_COL0]; GLuint i; - ASSERT(span->array->ChanType == GL_FLOAT); + assert(span->array->ChanType == GL_FLOAT); for (i = 0; i < span->end; i++) { rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F); rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F); @@ -945,7 +946,7 @@ convert_color_type(SWspan *span, GLenum srcType, GLenum newType, GLuint output) src = span->array->rgba8; } else { - ASSERT(srcType == GL_UNSIGNED_SHORT); + assert(srcType == GL_UNSIGNED_SHORT); src = span->array->rgba16; } @@ -1008,7 +1009,7 @@ shade_texture_span(struct gl_context *ctx, SWspan *span) _swrast_exec_fragment_program(ctx, span); } else { - ASSERT(ctx->ATIFragmentShader._Enabled); + assert(ctx->ATIFragmentShader._Enabled); _swrast_exec_fragment_shader(ctx, span); } } @@ -1147,7 +1148,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) span->interpMask, span->arrayMask); */ - ASSERT(span->primitive == GL_POINT || + assert(span->primitive == GL_POINT || span->primitive == GL_LINE || span->primitive == GL_POLYGON || span->primitive == GL_BITMAP); @@ -1167,7 +1168,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) return; } - ASSERT(span->end <= SWRAST_MAX_WIDTH); + assert(span->end <= SWRAST_MAX_WIDTH); /* Depth bounds test */ if (ctx->Depth.BoundsTest && fb->Visual.depthBits > 0) { @@ -1229,8 +1230,8 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) } else if (fb->Visual.depthBits > 0) { /* Just regular depth testing */ - ASSERT(ctx->Depth.Test); - ASSERT(span->arrayMask & SPAN_Z); + assert(ctx->Depth.Test); + assert(span->arrayMask & SPAN_Z); if (!_swrast_depth_test_span(ctx, span)) { /* all fragments failed test */ goto end; @@ -1272,7 +1273,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) } #endif - ASSERT(span->arrayMask & SPAN_RGBA); + assert(span->arrayMask & SPAN_RGBA); if (span->primitive == GL_BITMAP || !swrast->SpecularVertexAdd) { /* Add primary and specular (diffuse + specular) colors */ @@ -1353,7 +1354,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) 4 * span->end * sizeof(GLchan)); } - ASSERT(rb->_BaseFormat == GL_RGBA || + assert(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RED || rb->_BaseFormat == GL_RG || @@ -1457,8 +1458,8 @@ _swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb, length = (GLint) n; } - ASSERT(rb); - ASSERT(rb->_BaseFormat == GL_RGBA || + assert(rb); + assert(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RG || rb->_BaseFormat == GL_RED || @@ -1468,6 +1469,7 @@ _swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb, rb->_BaseFormat == GL_ALPHA); assert(srb->Map); + (void) srb; /* silence unused var warning */ src = _swrast_pixel_address(rb, x + skip, y); diff --git a/mesalib/src/mesa/swrast/s_stencil.c b/mesalib/src/mesa/swrast/s_stencil.c index eba9da863..294b593a2 100644 --- a/mesalib/src/mesa/swrast/s_stencil.c +++ b/mesalib/src/mesa/swrast/s_stencil.c @@ -280,7 +280,7 @@ compute_pass_fail_masks(GLuint n, const GLubyte origMask[], { GLuint i; for (i = 0; i < n; i++) { - ASSERT(newMask[i] == 0 || newMask[i] == 1); + assert(newMask[i] == 0 || newMask[i] == 1); passMask[i] = origMask[i] & newMask[i]; failMask[i] = origMask[i] & (newMask[i] ^ 1); } diff --git a/mesalib/src/mesa/swrast/s_texcombine.c b/mesalib/src/mesa/swrast/s_texcombine.c index def5eb19e..58ff16465 100644 --- a/mesalib/src/mesa/swrast/s_texcombine.c +++ b/mesalib/src/mesa/swrast/s_texcombine.c @@ -188,7 +188,7 @@ texture_combine( struct gl_context *ctx, GLuint unit, /* ARB_texture_env_crossbar source */ { const GLuint srcUnit = srcRGB - GL_TEXTURE0; - ASSERT(srcUnit < ctx->Const.MaxTextureUnits); + assert(srcUnit < ctx->Const.MaxTextureUnits); if (!ctx->Texture.Unit[srcUnit]._Current) goto end; argRGB[term] = get_texel_array(swrast, srcUnit); @@ -278,7 +278,7 @@ texture_combine( struct gl_context *ctx, GLuint unit, /* ARB_texture_env_crossbar source */ { const GLuint srcUnit = srcA - GL_TEXTURE0; - ASSERT(srcUnit < ctx->Const.MaxTextureUnits); + assert(srcUnit < ctx->Const.MaxTextureUnits); if (!ctx->Texture.Unit[srcUnit]._Current) goto end; argA[term] = get_texel_array(swrast, srcUnit); @@ -628,7 +628,7 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span ) return; } - ASSERT(span->end <= SWRAST_MAX_WIDTH); + assert(span->end <= SWRAST_MAX_WIDTH); /* * Save copy of the incoming fragment colors (the GL_PRIMARY_COLOR) diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c index 9629024b9..3c4ee15ba 100644 --- a/mesalib/src/mesa/swrast/s_texfetch.c +++ b/mesalib/src/mesa/swrast/s_texfetch.c @@ -573,7 +573,7 @@ set_fetch_functions(const struct gl_sampler_object *samp, } #endif - STATIC_ASSERT(Elements(texfetch_funcs) == MESA_FORMAT_COUNT); + STATIC_ASSERT(ARRAY_SIZE(texfetch_funcs) == MESA_FORMAT_COUNT); if (samp->sRGBDecode == GL_SKIP_DECODE_EXT && _mesa_get_format_color_encoding(format) == GL_SRGB) { @@ -598,7 +598,7 @@ set_fetch_functions(const struct gl_sampler_object *samp, texImage->FetchCompressedTexel = _mesa_get_compressed_fetch_func(format); - ASSERT(texImage->FetchTexel); + assert(texImage->FetchTexel); } void diff --git a/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c index fa79fdc5b..3ade99519 100644 --- a/mesalib/src/mesa/swrast/s_texfilter.c +++ b/mesalib/src/mesa/swrast/s_texfilter.c @@ -23,6 +23,7 @@ */ +#include "c99_math.h" #include "main/glheader.h" #include "main/context.h" #include "main/colormac.h" @@ -223,7 +224,7 @@ linear_texel_locations(GLenum wrapMode, } break; case GL_MIRROR_CLAMP_EXT: - u = FABSF(s); + u = fabsf(s); if (u >= 1.0F) u = (GLfloat) size; else @@ -233,7 +234,7 @@ linear_texel_locations(GLenum wrapMode, *i1 = *i0 + 1; break; case GL_MIRROR_CLAMP_TO_EDGE_EXT: - u = FABSF(s); + u = fabsf(s); if (u >= 1.0F) u = (GLfloat) size; else @@ -250,7 +251,7 @@ linear_texel_locations(GLenum wrapMode, { const GLfloat min = -1.0F / (2.0F * size); const GLfloat max = 1.0F - min; - u = FABSF(s); + u = fabsf(s); if (u <= min) u = min * size; else if (u >= max) @@ -354,7 +355,7 @@ nearest_texel_location(GLenum wrapMode, { /* s limited to [0,1] */ /* i limited to [0,size-1] */ - const GLfloat u = FABSF(s); + const GLfloat u = fabsf(s); if (u <= 0.0F) i = 0; else if (u >= 1.0F) @@ -369,7 +370,7 @@ nearest_texel_location(GLenum wrapMode, /* i limited to [0, size-1] */ const GLfloat min = 1.0F / (2.0F * size); const GLfloat max = 1.0F - min; - const GLfloat u = FABSF(s); + const GLfloat u = fabsf(s); if (u < min) i = 0; else if (u > max) @@ -384,7 +385,7 @@ nearest_texel_location(GLenum wrapMode, /* i limited to [0, size-1] */ const GLfloat min = -1.0F / (2.0F * size); const GLfloat max = 1.0F - min; - const GLfloat u = FABSF(s); + const GLfloat u = fabsf(s); if (u < min) i = -1; else if (u > max) @@ -668,7 +669,7 @@ compute_min_mag_ranges(const struct gl_sampler_object *samp, GLfloat minMagThresh; /* we shouldn't be here if minfilter == magfilter */ - ASSERT(samp->MinFilter != samp->MagFilter); + assert(samp->MinFilter != samp->MagFilter); /* This bit comes from the OpenGL spec: */ if (samp->MagFilter == GL_LINEAR @@ -690,12 +691,12 @@ compute_min_mag_ranges(const struct gl_sampler_object *samp, printf("lambda delta = %g\n", lambda[0] - lambda[n-1]); if (lambda[0] >= lambda[n-1]) { /* decreasing */ for (i = 0; i < n - 1; i++) { - ASSERT((GLint) (lambda[i] * 10) >= (GLint) (lambda[i+1] * 10)); + assert((GLint) (lambda[i] * 10) >= (GLint) (lambda[i+1] * 10)); } } else { /* increasing */ for (i = 0; i < n - 1; i++) { - ASSERT((GLint) (lambda[i] * 10) <= (GLint) (lambda[i+1] * 10)); + assert((GLint) (lambda[i] * 10) <= (GLint) (lambda[i+1] * 10)); } } } @@ -749,13 +750,13 @@ compute_min_mag_ranges(const struct gl_sampler_object *samp, for (i = 0; i < n; i++) { if (lambda[i] > minMagThresh) { /* minification */ - ASSERT(i >= *minStart); - ASSERT(i < *minEnd); + assert(i >= *minStart); + assert(i < *minEnd); } else { /* magnification */ - ASSERT(i >= *magStart); - ASSERT(i < *magEnd); + assert(i >= *magStart); + assert(i < *magEnd); } } } @@ -920,7 +921,7 @@ sample_1d_nearest_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = nearest_mipmap_level(tObj, lambda[i]); sample_1d_nearest(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]); @@ -936,7 +937,7 @@ sample_1d_linear_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = nearest_mipmap_level(tObj, lambda[i]); sample_1d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]); @@ -952,7 +953,7 @@ sample_1d_nearest_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -978,7 +979,7 @@ sample_1d_linear_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -1042,7 +1043,7 @@ sample_lambda_1d( struct gl_context *ctx, GLuint magStart, magEnd; /* texels with magnification */ GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); compute_min_mag_ranges(samp, n, lambda, &minStart, &minEnd, &magStart, &magEnd); @@ -1226,10 +1227,10 @@ sample_2d_linear_repeat(struct gl_context *ctx, (void) ctx; - ASSERT(samp->WrapS == GL_REPEAT); - ASSERT(samp->WrapT == GL_REPEAT); - ASSERT(img->Border == 0); - ASSERT(swImg->_IsPowerOfTwo); + assert(samp->WrapS == GL_REPEAT); + assert(samp->WrapT == GL_REPEAT); + assert(img->Border == 0); + assert(swImg->_IsPowerOfTwo); linear_repeat_texel_location(width, texcoord[0], &i0, &i1, &wi); linear_repeat_texel_location(height, texcoord[1], &j0, &j1, &wj); @@ -1266,7 +1267,7 @@ sample_2d_linear_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = nearest_mipmap_level(tObj, lambda[i]); sample_2d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]); @@ -1282,7 +1283,7 @@ sample_2d_nearest_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -1308,7 +1309,7 @@ sample_2d_linear_mipmap_linear( struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4] ) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -1334,9 +1335,9 @@ sample_2d_linear_mipmap_linear_repeat(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); - ASSERT(samp->WrapS == GL_REPEAT); - ASSERT(samp->WrapT == GL_REPEAT); + assert(lambda != NULL); + assert(samp->WrapS == GL_REPEAT); + assert(samp->WrapT == GL_REPEAT); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -1426,11 +1427,11 @@ opt_sample_rgb_2d(struct gl_context *ctx, GLuint k; (void) ctx; (void) lambda; - ASSERT(samp->WrapS==GL_REPEAT); - ASSERT(samp->WrapT==GL_REPEAT); - ASSERT(img->Border==0); - ASSERT(img->TexFormat == MESA_FORMAT_BGR_UNORM8); - ASSERT(swImg->_IsPowerOfTwo); + assert(samp->WrapS==GL_REPEAT); + assert(samp->WrapT==GL_REPEAT); + assert(img->Border==0); + assert(img->TexFormat == MESA_FORMAT_BGR_UNORM8); + assert(swImg->_IsPowerOfTwo); (void) swImg; for (k=0; k<n; k++) { @@ -1471,11 +1472,11 @@ opt_sample_rgba_2d(struct gl_context *ctx, GLuint i; (void) ctx; (void) lambda; - ASSERT(samp->WrapS==GL_REPEAT); - ASSERT(samp->WrapT==GL_REPEAT); - ASSERT(img->Border==0); - ASSERT(img->TexFormat == MESA_FORMAT_A8B8G8R8_UNORM); - ASSERT(swImg->_IsPowerOfTwo); + assert(samp->WrapS==GL_REPEAT); + assert(samp->WrapT==GL_REPEAT); + assert(img->Border==0); + assert(img->TexFormat == MESA_FORMAT_A8B8G8R8_UNORM); + assert(swImg->_IsPowerOfTwo); (void) swImg; for (i = 0; i < n; i++) { @@ -1511,7 +1512,7 @@ sample_lambda_2d(struct gl_context *ctx, swImg->RowStride) && swImg->_IsPowerOfTwo; - ASSERT(lambda != NULL); + assert(lambda != NULL); compute_min_mag_ranges(samp, n, lambda, &minStart, &minEnd, &magStart, &magEnd); @@ -1674,7 +1675,7 @@ sample_2d_ewa(struct gl_context *ctx, GLfloat F = A*C-B*B/4.0f; /* check if it is an ellipse */ - /* ASSERT(F > 0.0); */ + /* assert(F > 0.0); */ /* Compute the ellipse's (u,v) bounding box in texture space */ GLfloat d = -B*B+4.0f*C*A; @@ -2164,7 +2165,7 @@ sample_3d_linear_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = nearest_mipmap_level(tObj, lambda[i]); sample_3d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]); @@ -2180,7 +2181,7 @@ sample_3d_nearest_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -2206,7 +2207,7 @@ sample_3d_linear_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -2270,7 +2271,7 @@ sample_lambda_3d(struct gl_context *ctx, GLuint magStart, magEnd; /* texels with magnification */ GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); compute_min_mag_ranges(samp, n, lambda, &minStart, &minEnd, &magStart, &magEnd); @@ -2358,7 +2359,7 @@ choose_cube_face(const struct gl_texture_object *texObj, const GLfloat rx = texcoord[0]; const GLfloat ry = texcoord[1]; const GLfloat rz = texcoord[2]; - const GLfloat arx = FABSF(rx), ary = FABSF(ry), arz = FABSF(rz); + const GLfloat arx = fabsf(rx), ary = fabsf(ry), arz = fabsf(rz); GLuint face; GLfloat sc, tc, ma; @@ -2471,7 +2472,7 @@ sample_cube_nearest_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { const struct gl_texture_image **images; GLfloat newCoord[4]; @@ -2506,7 +2507,7 @@ sample_cube_linear_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { const struct gl_texture_image **images; GLfloat newCoord[4]; @@ -2531,7 +2532,7 @@ sample_cube_nearest_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { const struct gl_texture_image **images; GLfloat newCoord[4]; @@ -2566,7 +2567,7 @@ sample_cube_linear_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { const struct gl_texture_image **images; GLfloat newCoord[4]; @@ -2604,7 +2605,7 @@ sample_lambda_cube(struct gl_context *ctx, GLuint minStart, minEnd; /* texels with minification */ GLuint magStart, magEnd; /* texels with magnification */ - ASSERT(lambda != NULL); + assert(lambda != NULL); compute_min_mag_ranges(samp, n, lambda, &minStart, &minEnd, &magStart, &magEnd); @@ -2687,10 +2688,10 @@ sample_nearest_rect(struct gl_context *ctx, (void) ctx; (void) lambda; - ASSERT(samp->WrapS == GL_CLAMP || + assert(samp->WrapS == GL_CLAMP || samp->WrapS == GL_CLAMP_TO_EDGE || samp->WrapS == GL_CLAMP_TO_BORDER); - ASSERT(samp->WrapT == GL_CLAMP || + assert(samp->WrapT == GL_CLAMP || samp->WrapT == GL_CLAMP_TO_EDGE || samp->WrapT == GL_CLAMP_TO_BORDER); @@ -2722,10 +2723,10 @@ sample_linear_rect(struct gl_context *ctx, (void) ctx; (void) lambda; - ASSERT(samp->WrapS == GL_CLAMP || + assert(samp->WrapS == GL_CLAMP || samp->WrapS == GL_CLAMP_TO_EDGE || samp->WrapS == GL_CLAMP_TO_BORDER); - ASSERT(samp->WrapT == GL_CLAMP || + assert(samp->WrapT == GL_CLAMP || samp->WrapT == GL_CLAMP_TO_EDGE || samp->WrapT == GL_CLAMP_TO_BORDER); @@ -2947,7 +2948,7 @@ sample_2d_array_linear_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = nearest_mipmap_level(tObj, lambda[i]); sample_2d_array_linear(ctx, samp, tObj->Image[0][level], @@ -2964,7 +2965,7 @@ sample_2d_array_nearest_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -2992,7 +2993,7 @@ sample_2d_array_linear_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -3059,7 +3060,7 @@ sample_lambda_2d_array(struct gl_context *ctx, GLuint magStart, magEnd; /* texels with magnification */ GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); compute_min_mag_ranges(samp, n, lambda, &minStart, &minEnd, &magStart, &magEnd); @@ -3242,7 +3243,7 @@ sample_1d_array_linear_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = nearest_mipmap_level(tObj, lambda[i]); sample_1d_array_linear(ctx, samp, tObj->Image[0][level], @@ -3259,7 +3260,7 @@ sample_1d_array_nearest_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -3285,7 +3286,7 @@ sample_1d_array_linear_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -3349,7 +3350,7 @@ sample_lambda_1d_array(struct gl_context *ctx, GLuint magStart, magEnd; /* texels with magnification */ GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); compute_min_mag_ranges(samp, n, lambda, &minStart, &minEnd, &magStart, &magEnd); @@ -3555,10 +3556,10 @@ sample_depth_texture( struct gl_context *ctx, GLenum function; GLfloat result; - ASSERT(img->_BaseFormat == GL_DEPTH_COMPONENT || + assert(img->_BaseFormat == GL_DEPTH_COMPONENT || img->_BaseFormat == GL_DEPTH_STENCIL_EXT); - ASSERT(tObj->Target == GL_TEXTURE_1D || + assert(tObj->Target == GL_TEXTURE_1D || tObj->Target == GL_TEXTURE_2D || tObj->Target == GL_TEXTURE_RECTANGLE_NV || tObj->Target == GL_TEXTURE_1D_ARRAY_EXT || @@ -3595,7 +3596,7 @@ sample_depth_texture( struct gl_context *ctx, } else { GLuint i; - ASSERT(samp->MagFilter == GL_LINEAR); + assert(samp->MagFilter == GL_LINEAR); for (i = 0; i < n; i++) { GLfloat depth00, depth01, depth10, depth11, depthRef; GLint i0, i1, j0, j1; @@ -3730,7 +3731,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, return &sample_linear_1d; } else { - ASSERT(sampler->MinFilter == GL_NEAREST); + assert(sampler->MinFilter == GL_NEAREST); return &sample_nearest_1d; } case GL_TEXTURE_2D: @@ -3755,7 +3756,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, swrast_texture_image_const(img); texture_sample_func func; - ASSERT(sampler->MinFilter == GL_NEAREST); + assert(sampler->MinFilter == GL_NEAREST); func = &sample_nearest_2d; if (sampler->WrapS == GL_REPEAT && sampler->WrapT == GL_REPEAT && @@ -3777,7 +3778,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, return &sample_linear_3d; } else { - ASSERT(sampler->MinFilter == GL_NEAREST); + assert(sampler->MinFilter == GL_NEAREST); return &sample_nearest_3d; } case GL_TEXTURE_CUBE_MAP: @@ -3788,7 +3789,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, return &sample_linear_cube; } else { - ASSERT(sampler->MinFilter == GL_NEAREST); + assert(sampler->MinFilter == GL_NEAREST); return &sample_nearest_cube; } case GL_TEXTURE_RECTANGLE_NV: @@ -3802,7 +3803,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, return &sample_linear_rect; } else { - ASSERT(sampler->MinFilter == GL_NEAREST); + assert(sampler->MinFilter == GL_NEAREST); return &sample_nearest_rect; } case GL_TEXTURE_1D_ARRAY_EXT: @@ -3816,7 +3817,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, return &sample_linear_1d_array; } else { - ASSERT(sampler->MinFilter == GL_NEAREST); + assert(sampler->MinFilter == GL_NEAREST); return &sample_nearest_1d_array; } case GL_TEXTURE_2D_ARRAY_EXT: @@ -3830,7 +3831,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, return &sample_linear_2d_array; } else { - ASSERT(sampler->MinFilter == GL_NEAREST); + assert(sampler->MinFilter == GL_NEAREST); return &sample_nearest_2d_array; } default: diff --git a/mesalib/src/mesa/swrast/s_texrender.c b/mesalib/src/mesa/swrast/s_texrender.c index d67e48ad3..29bb270d6 100644 --- a/mesalib/src/mesa/swrast/s_texrender.c +++ b/mesalib/src/mesa/swrast/s_texrender.c @@ -18,7 +18,7 @@ static void delete_texture_wrapper(struct gl_context *ctx, struct gl_renderbuffer *rb) { - ASSERT(rb->RefCount == 0); + assert(rb->RefCount == 0); free(rb); } diff --git a/mesalib/src/mesa/swrast/s_triangle.c b/mesalib/src/mesa/swrast/s_triangle.c index 1d8e31c2e..af039c359 100644 --- a/mesalib/src/mesa/swrast/s_triangle.c +++ b/mesalib/src/mesa/swrast/s_triangle.c @@ -78,8 +78,8 @@ _swrast_culltriangle( struct gl_context *ctx, #define NAME flat_rgba_triangle #define INTERP_Z 1 #define SETUP_CODE \ - ASSERT(ctx->Texture._EnabledCoordUnits == 0);\ - ASSERT(ctx->Light.ShadeModel==GL_FLAT); \ + assert(ctx->Texture._EnabledCoordUnits == 0);\ + assert(ctx->Light.ShadeModel==GL_FLAT); \ span.interpMask |= SPAN_RGBA; \ span.red = ChanToFixed(v2->color[0]); \ span.green = ChanToFixed(v2->color[1]); \ @@ -104,8 +104,8 @@ _swrast_culltriangle( struct gl_context *ctx, #define SETUP_CODE \ { \ /* texturing must be off */ \ - ASSERT(ctx->Texture._EnabledCoordUnits == 0); \ - ASSERT(ctx->Light.ShadeModel==GL_SMOOTH); \ + assert(ctx->Texture._EnabledCoordUnits == 0); \ + assert(ctx->Light.ShadeModel==GL_SMOOTH); \ } #define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span); #include "s_tritemp.h" @@ -137,7 +137,7 @@ _swrast_culltriangle( struct gl_context *ctx, const GLubyte *texture = (const GLubyte *) swImg->ImageSlices[0]; \ const GLint smask = texImg->Width - 1; \ const GLint tmask = texImg->Height - 1; \ - ASSERT(texImg->TexFormat == MESA_FORMAT_BGR_UNORM8); \ + assert(texImg->TexFormat == MESA_FORMAT_BGR_UNORM8); \ if (!rb || !texture) { \ return; \ } @@ -195,7 +195,7 @@ _swrast_culltriangle( struct gl_context *ctx, const GLubyte *texture = (const GLubyte *) swImg->ImageSlices[0]; \ const GLint smask = texImg->Width - 1; \ const GLint tmask = texImg->Height - 1; \ - ASSERT(texImg->TexFormat == MESA_FORMAT_BGR_UNORM8); \ + assert(texImg->TexFormat == MESA_FORMAT_BGR_UNORM8); \ if (!rb || !texture) { \ return; \ } @@ -513,7 +513,7 @@ affine_span(struct gl_context *ctx, SWspan *span, break; } span->interpMask &= ~SPAN_RGBA; - ASSERT(span->arrayMask & SPAN_RGBA); + assert(span->arrayMask & SPAN_RGBA); _swrast_write_rgba_span(ctx, span); @@ -783,7 +783,7 @@ fast_persp_span(struct gl_context *ctx, SWspan *span, break; } - ASSERT(span->arrayMask & SPAN_RGBA); + assert(span->arrayMask & SPAN_RGBA); _swrast_write_rgba_span(ctx, span); #undef SPAN_NEAREST @@ -885,9 +885,9 @@ fast_persp_span(struct gl_context *ctx, SWspan *span, struct gl_renderbuffer *rb = \ ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; \ struct gl_query_object *q = ctx->Query.CurrentOcclusionObject; \ - ASSERT(ctx->Depth.Test); \ - ASSERT(!ctx->Depth.Mask); \ - ASSERT(ctx->Depth.Func == GL_LESS); \ + assert(ctx->Depth.Test); \ + assert(!ctx->Depth.Mask); \ + assert(ctx->Depth.Func == GL_LESS); \ assert(rb->Format == MESA_FORMAT_Z_UNORM16); \ if (!q) { \ return; \ @@ -1015,7 +1015,7 @@ _swrast_choose_triangle( struct gl_context *ctx ) if (ctx->Polygon.SmoothFlag) { _swrast_set_aa_triangle_function(ctx); - ASSERT(swrast->Triangle); + assert(swrast->Triangle); return; } @@ -1134,8 +1134,8 @@ _swrast_choose_triangle( struct gl_context *ctx ) } } else { - ASSERT(!swrast->_FogEnabled); - ASSERT(!_mesa_need_secondary_color(ctx)); + assert(!swrast->_FogEnabled); + assert(!_mesa_need_secondary_color(ctx)); if (ctx->Light.ShadeModel==GL_SMOOTH) { /* smooth shaded, no texturing, stippled or some raster ops */ #if CHAN_BITS != 8 diff --git a/mesalib/src/mesa/swrast/s_tritemp.h b/mesalib/src/mesa/swrast/s_tritemp.h index 8a278dff6..fb73b2d59 100644 --- a/mesalib/src/mesa/swrast/s_tritemp.h +++ b/mesalib/src/mesa/swrast/s_tritemp.h @@ -91,6 +91,11 @@ */ +#ifndef MAX_GLUINT +#define MAX_GLUINT 0xffffffff +#endif + + /* * Some code we unfortunately need to prevent negative interpolated colors. */ @@ -380,7 +385,7 @@ static void NAME(struct gl_context *ctx, const SWvertex *v0, # endif /* INTERP_ALPHA */ } else { - ASSERT(ctx->Light.ShadeModel == GL_FLAT); + assert(ctx->Light.ShadeModel == GL_FLAT); span.interpMask |= SPAN_FLAT; span.attrStepX[VARYING_SLOT_COL0][0] = span.attrStepY[VARYING_SLOT_COL0][0] = 0.0F; span.attrStepX[VARYING_SLOT_COL0][1] = span.attrStepY[VARYING_SLOT_COL0][1] = 0.0F; @@ -662,7 +667,7 @@ static void NAME(struct gl_context *ctx, const SWvertex *v0, # endif } else { - ASSERT(ctx->Light.ShadeModel == GL_FLAT); + assert(ctx->Light.ShadeModel == GL_FLAT); rLeft = ChanToFixed(v2->color[RCOMP]); gLeft = ChanToFixed(v2->color[GCOMP]); bLeft = ChanToFixed(v2->color[BCOMP]); diff --git a/mesalib/src/mesa/swrast/s_zoom.c b/mesalib/src/mesa/swrast/s_zoom.c index 352c61ad2..ab22652c7 100644 --- a/mesalib/src/mesa/swrast/s_zoom.c +++ b/mesalib/src/mesa/swrast/s_zoom.c @@ -53,8 +53,8 @@ compute_zoomed_bounds(struct gl_context *ctx, GLint imageX, GLint imageY, const struct gl_framebuffer *fb = ctx->DrawBuffer; GLint c0, c1, r0, r1; - ASSERT(spanX >= imageX); - ASSERT(spanY >= imageY); + assert(spanX >= imageX); + assert(spanY >= imageY); /* * Compute destination columns: [c0, c1) @@ -149,12 +149,12 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, } zoomedWidth = x1 - x0; - ASSERT(zoomedWidth > 0); - ASSERT(zoomedWidth <= SWRAST_MAX_WIDTH); + assert(zoomedWidth > 0); + assert(zoomedWidth <= SWRAST_MAX_WIDTH); /* no pixel arrays! must be horizontal spans. */ - ASSERT((span->arrayMask & SPAN_XY) == 0); - ASSERT(span->primitive == GL_BITMAP); + assert((span->arrayMask & SPAN_XY) == 0); + assert(span->primitive == GL_BITMAP); INIT_SPAN(zoomed, GL_BITMAP); zoomed.x = x0; @@ -184,7 +184,7 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, zoomed.interpMask = span->interpMask & ~SPAN_RGBA; zoomed.arrayMask |= SPAN_RGBA; zoomed.arrayAttribs |= VARYING_BIT_COL0; /* we'll produce these values */ - ASSERT(span->arrayMask & SPAN_RGBA); + assert(span->arrayMask & SPAN_RGBA); } else if (format == GL_DEPTH_COMPONENT) { /* Copy color info */ @@ -199,7 +199,7 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, /* we'll generate an array of depth values */ zoomed.interpMask = span->interpMask & ~SPAN_Z; zoomed.arrayMask |= SPAN_Z; - ASSERT(span->arrayMask & SPAN_Z); + assert(span->arrayMask & SPAN_Z); } else { _mesa_problem(ctx, "Bad format in zoom_span"); @@ -213,8 +213,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, GLint i; for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); + assert(j >= 0); + assert(j < (GLint) span->end); COPY_4UBV(zoomed.array->rgba8[i], rgba[j]); } } @@ -223,8 +223,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, GLint i; for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); + assert(j >= 0); + assert(j < (GLint) span->end); COPY_4V(zoomed.array->rgba16[i], rgba[j]); } } @@ -233,8 +233,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, GLint i; for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); + assert(j >= 0); + assert(j < (GLint) span->end); COPY_4V(zoomed.array->attribs[VARYING_SLOT_COL0][i], rgba[j]); } } @@ -245,8 +245,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, GLint i; for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); + assert(j >= 0); + assert(j < (GLint) span->end); zoomed.array->rgba8[i][0] = rgb[j][0]; zoomed.array->rgba8[i][1] = rgb[j][1]; zoomed.array->rgba8[i][2] = rgb[j][2]; @@ -258,8 +258,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, GLint i; for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); + assert(j >= 0); + assert(j < (GLint) span->end); zoomed.array->rgba16[i][0] = rgb[j][0]; zoomed.array->rgba16[i][1] = rgb[j][1]; zoomed.array->rgba16[i][2] = rgb[j][2]; @@ -271,8 +271,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, GLint i; for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); + assert(j >= 0); + assert(j < (GLint) span->end); zoomed.array->attribs[VARYING_SLOT_COL0][i][0] = rgb[j][0]; zoomed.array->attribs[VARYING_SLOT_COL0][i][1] = rgb[j][1]; zoomed.array->attribs[VARYING_SLOT_COL0][i][2] = rgb[j][2]; @@ -285,8 +285,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, GLint i; for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); + assert(j >= 0); + assert(j < (GLint) span->end); zoomed.array->z[i] = zValues[j]; } /* Now, fall into the RGB path below */ @@ -372,8 +372,8 @@ _swrast_write_zoomed_stencil_span(struct gl_context *ctx, GLint imgX, GLint imgY } zoomedWidth = x1 - x0; - ASSERT(zoomedWidth > 0); - ASSERT(zoomedWidth <= SWRAST_MAX_WIDTH); + assert(zoomedWidth > 0); + assert(zoomedWidth <= SWRAST_MAX_WIDTH); zoomedVals = malloc(zoomedWidth * sizeof(GLubyte)); if (!zoomedVals) @@ -382,8 +382,8 @@ _swrast_write_zoomed_stencil_span(struct gl_context *ctx, GLint imgX, GLint imgY /* zoom the span horizontally */ for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - spanX; - ASSERT(j >= 0); - ASSERT(j < width); + assert(j >= 0); + assert(j < width); zoomedVals[i] = stencil[j]; } @@ -417,8 +417,8 @@ _swrast_write_zoomed_z_span(struct gl_context *ctx, GLint imgX, GLint imgY, } zoomedWidth = x1 - x0; - ASSERT(zoomedWidth > 0); - ASSERT(zoomedWidth <= SWRAST_MAX_WIDTH); + assert(zoomedWidth > 0); + assert(zoomedWidth <= SWRAST_MAX_WIDTH); zoomedVals = malloc(zoomedWidth * sizeof(GLuint)); if (!zoomedVals) @@ -427,8 +427,8 @@ _swrast_write_zoomed_z_span(struct gl_context *ctx, GLint imgX, GLint imgY, /* zoom the span horizontally */ for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - spanX; - ASSERT(j >= 0); - ASSERT(j < width); + assert(j >= 0); + assert(j < width); zoomedVals[i] = zVals[j]; } diff --git a/mesalib/src/mesa/swrast_setup/ss_triangle.c b/mesalib/src/mesa/swrast_setup/ss_triangle.c index 42ba891ab..483c41592 100644 --- a/mesalib/src/mesa/swrast_setup/ss_triangle.c +++ b/mesalib/src/mesa/swrast_setup/ss_triangle.c @@ -25,6 +25,7 @@ * Keith Whitwell <keithw@vmware.com> */ +#include "c99_math.h" #include "main/glheader.h" #include "main/colormac.h" #include "main/macros.h" diff --git a/mesalib/src/mesa/swrast_setup/ss_tritmp.h b/mesalib/src/mesa/swrast_setup/ss_tritmp.h index d4513c9ac..c38c76a4a 100644 --- a/mesalib/src/mesa/swrast_setup/ss_tritmp.h +++ b/mesalib/src/mesa/swrast_setup/ss_tritmp.h @@ -142,8 +142,8 @@ static void TAG(triangle)(struct gl_context *ctx, GLuint e0, GLuint e1, GLuint e const GLfloat ez = z[0] - z[2]; const GLfloat fz = z[1] - z[2]; const GLfloat oneOverArea = 1.0F / cc; - const GLfloat dzdx = FABSF((ey * fz - ez * fy) * oneOverArea); - const GLfloat dzdy = FABSF((ez * fx - ex * fz) * oneOverArea); + const GLfloat dzdx = fabsf((ey * fz - ez * fy) * oneOverArea); + const GLfloat dzdy = fabsf((ez * fx - ex * fz) * oneOverArea); offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor; } /* new Z values */ diff --git a/mesalib/src/mesa/tnl/t_context.c b/mesalib/src/mesa/tnl/t_context.c index eb5bae41d..bc705d7a3 100644 --- a/mesalib/src/mesa/tnl/t_context.c +++ b/mesalib/src/mesa/tnl/t_context.c @@ -130,7 +130,7 @@ _tnl_InvalidateState( struct gl_context *ctx, GLuint new_state ) GLuint i; if (new_state & (_NEW_HINT | _NEW_PROGRAM)) { - ASSERT(tnl->AllowVertexFog || tnl->AllowPixelFog); + assert(tnl->AllowVertexFog || tnl->AllowPixelFog); tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) || !tnl->AllowPixelFog) && !fp; } diff --git a/mesalib/src/mesa/tnl/t_draw.c b/mesalib/src/mesa/tnl/t_draw.c index be3f059bb..60265d60b 100644 --- a/mesalib/src/mesa/tnl/t_draw.c +++ b/mesalib/src/mesa/tnl/t_draw.c @@ -25,6 +25,8 @@ * Keith Whitwell <keithw@vmware.com> */ +#include <stdio.h> + #include "main/glheader.h" #include "main/bufferobj.h" #include "main/condrender.h" diff --git a/mesalib/src/mesa/tnl/t_pipeline.c b/mesalib/src/mesa/tnl/t_pipeline.c index 78508aecf..0adbef012 100644 --- a/mesalib/src/mesa/tnl/t_pipeline.c +++ b/mesalib/src/mesa/tnl/t_pipeline.c @@ -112,6 +112,84 @@ static GLuint check_output_changes( struct gl_context *ctx ) #endif } +/** + * START/END_FAST_MATH macros: + * + * START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save + * original mode to a temporary). + * END_FAST_MATH: Restore x86 FPU to original mode. + */ +#if defined(__GNUC__) && defined(__i386__) +/* + * Set the x86 FPU control word to guarentee only 32 bits of precision + * are stored in registers. Allowing the FPU to store more introduces + * differences between situations where numbers are pulled out of memory + * vs. situations where the compiler is able to optimize register usage. + * + * In the worst case, we force the compiler to use a memory access to + * truncate the float, by specifying the 'volatile' keyword. + */ +/* Hardware default: All exceptions masked, extended double precision, + * round to nearest (IEEE compliant): + */ +#define DEFAULT_X86_FPU 0x037f +/* All exceptions masked, single precision, round to nearest: + */ +#define FAST_X86_FPU 0x003f +/* The fldcw instruction will cause any pending FP exceptions to be + * raised prior to entering the block, and we clear any pending + * exceptions before exiting the block. Hence, asm code has free + * reign over the FPU while in the fast math block. + */ +#if defined(NO_FAST_MATH) +#define START_FAST_MATH(x) \ +do { \ + static GLuint mask = DEFAULT_X86_FPU; \ + __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ + __asm__ ( "fldcw %0" : : "m" (mask) ); \ +} while (0) +#else +#define START_FAST_MATH(x) \ +do { \ + static GLuint mask = FAST_X86_FPU; \ + __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \ + __asm__ ( "fldcw %0" : : "m" (mask) ); \ +} while (0) +#endif +/* Restore original FPU mode, and clear any exceptions that may have + * occurred in the FAST_MATH block. + */ +#define END_FAST_MATH(x) \ +do { \ + __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \ +} while (0) + +#elif defined(_MSC_VER) && defined(_M_IX86) +#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */ +#define FAST_X86_FPU 0x003f /* See GCC comments above */ +#if defined(NO_FAST_MATH) +#define START_FAST_MATH(x) do {\ + static GLuint mask = DEFAULT_X86_FPU;\ + __asm fnstcw word ptr [x]\ + __asm fldcw word ptr [mask]\ +} while(0) +#else +#define START_FAST_MATH(x) do {\ + static GLuint mask = FAST_X86_FPU;\ + __asm fnstcw word ptr [x]\ + __asm fldcw word ptr [mask]\ +} while(0) +#endif +#define END_FAST_MATH(x) do {\ + __asm fnclex\ + __asm fldcw word ptr [x]\ +} while(0) + +#else +#define START_FAST_MATH(x) x = 0 +#define END_FAST_MATH(x) (void)(x) +#endif + void _tnl_run_pipeline( struct gl_context *ctx ) { diff --git a/mesalib/src/mesa/tnl/t_rasterpos.c b/mesalib/src/mesa/tnl/t_rasterpos.c index 2f52bb306..9ecf947df 100644 --- a/mesalib/src/mesa/tnl/t_rasterpos.c +++ b/mesalib/src/mesa/tnl/t_rasterpos.c @@ -23,6 +23,7 @@ */ +#include "c99_math.h" #include "main/glheader.h" #include "main/colormac.h" #include "main/feedback.h" @@ -271,7 +272,7 @@ compute_texgen(struct gl_context *ctx, const GLfloat vObj[4], const GLfloat vEye rz = u[2] - normal[2] * two_nu; m = rx * rx + ry * ry + (rz + 1.0F) * (rz + 1.0F); if (m > 0.0F) - mInv = 0.5F * INV_SQRTF(m); + mInv = 0.5F * (1.0f / sqrtf(m)); else mInv = 0.0F; diff --git a/mesalib/src/mesa/tnl/t_vb_cliptmp.h b/mesalib/src/mesa/tnl/t_vb_cliptmp.h index 7dafb83cf..12181f085 100644 --- a/mesalib/src/mesa/tnl/t_vb_cliptmp.h +++ b/mesalib/src/mesa/tnl/t_vb_cliptmp.h @@ -155,7 +155,7 @@ TAG(clip_line)( struct gl_context *ctx, GLuint v0, GLuint v1, GLubyte mask ) newvert++; } else { - ASSERT(t0 == 0.0); + assert(t0 == 0.0); } /* Note: we need to use vertex v0_orig when computing the new @@ -174,7 +174,7 @@ TAG(clip_line)( struct gl_context *ctx, GLuint v0, GLuint v1, GLubyte mask ) newvert++; } else { - ASSERT(t1 == 0.0); + assert(t1 == 0.0); } tnl->Driver.Render.ClippedLine( ctx, v0, v1 ); @@ -239,7 +239,7 @@ TAG(clip_tri)( struct gl_context *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte if (ctx->Light.ShadeModel == GL_FLAT) { if (pv != inlist[0]) { - ASSERT( inlist[0] >= VB->Count ); + assert( inlist[0] >= VB->Count ); tnl->Driver.Render.CopyPV( ctx, inlist[0], pv ); } } @@ -302,7 +302,7 @@ TAG(clip_quad)( struct gl_context *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint if (ctx->Light.ShadeModel == GL_FLAT) { if (pv != inlist[0]) { - ASSERT( inlist[0] >= VB->Count ); + assert( inlist[0] >= VB->Count ); tnl->Driver.Render.CopyPV( ctx, inlist[0], pv ); } } diff --git a/mesalib/src/mesa/tnl/t_vb_fog.c b/mesalib/src/mesa/tnl/t_vb_fog.c index ab7901edb..3626f1da3 100644 --- a/mesalib/src/mesa/tnl/t_vb_fog.c +++ b/mesalib/src/mesa/tnl/t_vb_fog.c @@ -26,6 +26,7 @@ */ +#include "c99_math.h" #include "main/glheader.h" #include "main/colormac.h" #include "main/macros.h" @@ -78,7 +79,7 @@ init_static_data( void ) GLfloat f = 0.0F; GLint i = 0; for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) { - exp_table[i] = EXPF(-f); + exp_table[i] = expf(-f); } inited = 1; } @@ -186,7 +187,7 @@ run_fog_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage) NOTE should avoid going through array twice */ coord = input->start; for (i = 0; i < input->count; i++) { - *coord = FABSF(*coord); + *coord = fabsf(*coord); STRIDE_F(coord, input->stride); } } @@ -201,7 +202,7 @@ run_fog_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage) input->count = VB->EyePtr->count; coord = VB->EyePtr->start; for (i = 0 ; i < VB->EyePtr->count; i++) { - input->data[i][0] = FABSF(coord[2]); + input->data[i][0] = fabsf(coord[2]); STRIDE_F(coord, VB->EyePtr->stride); } } diff --git a/mesalib/src/mesa/tnl/t_vb_light.c b/mesalib/src/mesa/tnl/t_vb_light.c index f6884a464..7781b6a6c 100644 --- a/mesalib/src/mesa/tnl/t_vb_light.c +++ b/mesalib/src/mesa/tnl/t_vb_light.c @@ -23,7 +23,7 @@ */ - +#include "c99_math.h" #include "main/glheader.h" #include "main/colormac.h" #include "main/light.h" @@ -123,7 +123,7 @@ validate_shine_table( struct gl_context *ctx, GLuint side, GLfloat shininess ) struct tnl_shine_tab *list = tnl->_ShineTabList; struct tnl_shine_tab *s; - ASSERT(side < 2); + assert(side < 2); foreach(s, list) if ( s->shininess == shininess ) diff --git a/mesalib/src/mesa/tnl/t_vb_points.c b/mesalib/src/mesa/tnl/t_vb_points.c index 5f6c25857..0f8578daa 100644 --- a/mesalib/src/mesa/tnl/t_vb_points.c +++ b/mesalib/src/mesa/tnl/t_vb_points.c @@ -25,6 +25,7 @@ * Brian Paul */ +#include "c99_math.h" #include "main/glheader.h" #include "main/mtypes.h" #include "main/dd.h" @@ -62,9 +63,9 @@ run_point_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage) GLuint i; for (i = 0; i < VB->Count; i++) { - const GLfloat dist = FABSF(*eyeCoord); + const GLfloat dist = fabsf(*eyeCoord); const GLfloat q = p0 + dist * (p1 + dist * p2); - const GLfloat atten = (q != 0.0F) ? INV_SQRTF(q) : 1.0F; + const GLfloat atten = (q != 0.0F) ? (1.0f / sqrtf(q)) : 1.0F; size[i][0] = pointSize * atten; /* clamping done in rasterization */ eyeCoord += eyeCoordStride; } diff --git a/mesalib/src/mesa/tnl/t_vb_program.c b/mesalib/src/mesa/tnl/t_vb_program.c index d08abe7c2..464a4cddd 100644 --- a/mesalib/src/mesa/tnl/t_vb_program.c +++ b/mesalib/src/mesa/tnl/t_vb_program.c @@ -392,7 +392,7 @@ run_vp( struct gl_context *ctx, struct tnl_pipeline_stage *stage ) store->results[VARYING_SLOT_FOGC].data[i][3] = 1.0; } #ifdef NAN_CHECK - ASSERT(machine->Outputs[0][3] != 0.0F); + assert(machine->Outputs[0][3] != 0.0F); #endif #if 0 printf("HPOS: %f %f %f %f\n", diff --git a/mesalib/src/mesa/tnl/t_vb_render.c b/mesalib/src/mesa/tnl/t_vb_render.c index aff5b9a68..4960ac096 100644 --- a/mesalib/src/mesa/tnl/t_vb_render.c +++ b/mesalib/src/mesa/tnl/t_vb_render.c @@ -38,6 +38,7 @@ */ +#include <stdio.h> #include "main/glheader.h" #include "main/context.h" #include "main/enums.h" @@ -271,22 +272,22 @@ static GLboolean run_render( struct gl_context *ctx, * that window coordinates are guarenteed not to change before * rendering. */ - ASSERT(tnl->Driver.Render.Start); + assert(tnl->Driver.Render.Start); tnl->Driver.Render.Start( ctx ); - ASSERT(tnl->Driver.Render.BuildVertices); - ASSERT(tnl->Driver.Render.PrimitiveNotify); - ASSERT(tnl->Driver.Render.Points); - ASSERT(tnl->Driver.Render.Line); - ASSERT(tnl->Driver.Render.Triangle); - ASSERT(tnl->Driver.Render.Quad); - ASSERT(tnl->Driver.Render.ResetLineStipple); - ASSERT(tnl->Driver.Render.Interp); - ASSERT(tnl->Driver.Render.CopyPV); - ASSERT(tnl->Driver.Render.ClippedLine); - ASSERT(tnl->Driver.Render.ClippedPolygon); - ASSERT(tnl->Driver.Render.Finish); + assert(tnl->Driver.Render.BuildVertices); + assert(tnl->Driver.Render.PrimitiveNotify); + assert(tnl->Driver.Render.Points); + assert(tnl->Driver.Render.Line); + assert(tnl->Driver.Render.Triangle); + assert(tnl->Driver.Render.Quad); + assert(tnl->Driver.Render.ResetLineStipple); + assert(tnl->Driver.Render.Interp); + assert(tnl->Driver.Render.CopyPV); + assert(tnl->Driver.Render.ClippedLine); + assert(tnl->Driver.Render.ClippedPolygon); + assert(tnl->Driver.Render.Finish); tnl->Driver.Render.BuildVertices( ctx, 0, VB->Count, ~0 ); diff --git a/mesalib/src/mesa/tnl/t_vb_texgen.c b/mesalib/src/mesa/tnl/t_vb_texgen.c index 8f527e343..9a61ef2fe 100644 --- a/mesalib/src/mesa/tnl/t_vb_texgen.c +++ b/mesalib/src/mesa/tnl/t_vb_texgen.c @@ -116,7 +116,7 @@ static void build_m3( GLfloat f[][3], GLfloat m[], fz = f[i][2] = u[2] - norm[2] * two_nu; m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F); if (m[i] != 0.0F) { - m[i] = 0.5F * INV_SQRTF(m[i]); + m[i] = 0.5F * (1.0f / sqrtf(m[i])); } } } @@ -145,7 +145,7 @@ static void build_m2( GLfloat f[][3], GLfloat m[], fz = f[i][2] = u[2] - norm[2] * two_nu; m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F); if (m[i] != 0.0F) { - m[i] = 0.5F * INV_SQRTF(m[i]); + m[i] = 0.5F * (1.0f / sqrtf(m[i])); } } } diff --git a/mesalib/src/mesa/tnl/t_vertex.c b/mesalib/src/mesa/tnl/t_vertex.c index 90b97a092..369d6d945 100644 --- a/mesalib/src/mesa/tnl/t_vertex.c +++ b/mesalib/src/mesa/tnl/t_vertex.c @@ -25,6 +25,7 @@ * Keith Whitwell <keithw@vmware.com> */ +#include <stdio.h> #include "main/glheader.h" #include "main/context.h" #include "main/colormac.h" diff --git a/mesalib/src/mesa/tnl/t_vertex_sse.c b/mesalib/src/mesa/tnl/t_vertex_sse.c index 93128fbe6..963432c48 100644 --- a/mesalib/src/mesa/tnl/t_vertex_sse.c +++ b/mesalib/src/mesa/tnl/t_vertex_sse.c @@ -25,6 +25,8 @@ * Keith Whitwell <keithw@vmware.com> */ +#include <stdio.h> + #include "main/glheader.h" #include "main/context.h" #include "main/colormac.h" diff --git a/mesalib/src/mesa/vbo/vbo.h b/mesalib/src/mesa/vbo/vbo.h index 6e1a4aa1a..54dee6c46 100644 --- a/mesalib/src/mesa/vbo/vbo.h +++ b/mesalib/src/mesa/vbo/vbo.h @@ -35,6 +35,10 @@ #include <stdbool.h> #include "main/glheader.h" +#ifdef __cplusplus +extern "C" { +#endif + struct gl_client_array; struct gl_context; struct gl_transform_feedback_object; @@ -228,4 +232,8 @@ _es_VertexAttrib3fv(GLuint indx, const GLfloat* values); void GLAPIENTRY _es_VertexAttrib4fv(GLuint indx, const GLfloat* values); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/mesalib/src/mesa/vbo/vbo_attrib_tmp.h b/mesalib/src/mesa/vbo/vbo_attrib_tmp.h index 0c44540fc..b1c3d9842 100644 --- a/mesalib/src/mesa/vbo/vbo_attrib_tmp.h +++ b/mesalib/src/mesa/vbo/vbo_attrib_tmp.h @@ -28,6 +28,22 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "util/u_format_r11g11b10f.h" #include "main/varray.h" + +/* ATTR */ +#define ATTR( A, N, T, V0, V1, V2, V3 ) \ + ATTR_##T((A), (N), (T), (V0), (V1), (V2), (V3)) + +#define ATTR_GL_UNSIGNED_INT( A, N, T, V0, V1, V2, V3 ) \ + ATTR_UNION(A, N, T, UINT_AS_UNION(V0), UINT_AS_UNION(V1), \ + UINT_AS_UNION(V2), UINT_AS_UNION(V3)) +#define ATTR_GL_INT( A, N, T, V0, V1, V2, V3 ) \ + ATTR_UNION(A, N, T, INT_AS_UNION(V0), INT_AS_UNION(V1), \ + INT_AS_UNION(V2), INT_AS_UNION(V3)) +#define ATTR_GL_FLOAT( A, N, T, V0, V1, V2, V3 ) \ + ATTR_UNION(A, N, T, FLOAT_AS_UNION(V0), FLOAT_AS_UNION(V1),\ + FLOAT_AS_UNION(V2), FLOAT_AS_UNION(V3)) + + /* float */ #define ATTR1FV( A, V ) ATTR( A, 1, GL_FLOAT, (V)[0], 0, 0, 1 ) #define ATTR2FV( A, V ) ATTR( A, 2, GL_FLOAT, (V)[0], (V)[1], 0, 1 ) @@ -41,8 +57,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* int */ #define ATTRI( A, N, X, Y, Z, W) ATTR( A, N, GL_INT, \ - INT_AS_FLT(X), INT_AS_FLT(Y), \ - INT_AS_FLT(Z), INT_AS_FLT(W) ) + X, Y, Z, W ) #define ATTR2IV( A, V ) ATTRI( A, 2, (V)[0], (V)[1], 0, 1 ) #define ATTR3IV( A, V ) ATTRI( A, 3, (V)[0], (V)[1], (V)[2], 1 ) @@ -56,8 +71,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* uint */ #define ATTRUI( A, N, X, Y, Z, W) ATTR( A, N, GL_UNSIGNED_INT, \ - UINT_AS_FLT(X), UINT_AS_FLT(Y), \ - UINT_AS_FLT(Z), UINT_AS_FLT(W) ) + X, Y, Z, W ) #define ATTR2UIV( A, V ) ATTRUI( A, 2, (V)[0], (V)[1], 0, 1 ) #define ATTR3UIV( A, V ) ATTRUI( A, 3, (V)[0], (V)[1], (V)[2], 1 ) diff --git a/mesalib/src/mesa/vbo/vbo_context.c b/mesalib/src/mesa/vbo/vbo_context.c index 19712aa58..fd1ffe2f7 100644 --- a/mesalib/src/mesa/vbo/vbo_context.c +++ b/mesalib/src/mesa/vbo/vbo_context.c @@ -108,7 +108,7 @@ static void init_mat_currval(struct gl_context *ctx) &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT]; GLuint i; - ASSERT(NR_MAT_ATTRIBS == MAT_ATTRIB_MAX); + assert(NR_MAT_ATTRIBS == MAT_ATTRIB_MAX); memset(arrays, 0, sizeof(*arrays) * NR_MAT_ATTRIBS); @@ -172,14 +172,14 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx ) GLuint i; /* identity mapping */ - for (i = 0; i < Elements(vbo->map_vp_none); i++) + for (i = 0; i < ARRAY_SIZE(vbo->map_vp_none); i++) vbo->map_vp_none[i] = i; /* map material attribs to generic slots */ for (i = 0; i < NR_MAT_ATTRIBS; i++) vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)] = VBO_ATTRIB_MAT_FRONT_AMBIENT + i; - for (i = 0; i < Elements(vbo->map_vp_arb); i++) + for (i = 0; i < ARRAY_SIZE(vbo->map_vp_arb); i++) vbo->map_vp_arb[i] = i; } diff --git a/mesalib/src/mesa/vbo/vbo_context.h b/mesalib/src/mesa/vbo/vbo_context.h index e22451305..6099b56e6 100644 --- a/mesalib/src/mesa/vbo/vbo_context.h +++ b/mesalib/src/mesa/vbo/vbo_context.h @@ -56,6 +56,11 @@ #include "vbo_exec.h" #include "vbo_save.h" +#include "main/macros.h" + +#ifdef __cplusplus +extern "C" { +#endif struct vbo_context { struct gl_client_array currval[VBO_ATTRIB_MAX]; @@ -124,7 +129,7 @@ vbo_draw_method(struct vbo_context *vbo, gl_draw_method method) ctx->Array._DrawArrays = vbo->save.inputs; break; default: - ASSERT(0); + assert(0); } ctx->NewDriverState |= ctx->DriverFlags.NewArray; @@ -146,33 +151,36 @@ vbo_attrtype_to_integer_flag(GLenum format) case GL_UNSIGNED_INT: return GL_TRUE; default: - ASSERT(0); + assert(0); return GL_FALSE; } } - /** * Return default component values for the given format. - * The return type is an array of floats, because that's how we declare - * the vertex storage despite the fact we sometimes store integers in there. + * The return type is an array of fi_types, because that's how we declare + * the vertex storage : floats , integers or unsigned integers. */ -static inline const GLfloat * -vbo_get_default_vals_as_float(GLenum format) +static inline const fi_type * +vbo_get_default_vals_as_union(GLenum format) { static const GLfloat default_float[4] = { 0, 0, 0, 1 }; static const GLint default_int[4] = { 0, 0, 0, 1 }; switch (format) { case GL_FLOAT: - return default_float; + return (fi_type *)default_float; case GL_INT: case GL_UNSIGNED_INT: - return (const GLfloat*)default_int; + return (fi_type *)default_int; default: - ASSERT(0); + assert(0); return NULL; } } +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/mesalib/src/mesa/vbo/vbo_exec.h b/mesalib/src/mesa/vbo/vbo_exec.h index bb265def8..f17fe684c 100644 --- a/mesalib/src/mesa/vbo/vbo_exec.h +++ b/mesalib/src/mesa/vbo/vbo_exec.h @@ -38,6 +38,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "vbo.h" #include "vbo_attrib.h" +#include "main/imports.h" /** * Max number of primitives (number of glBegin/End pairs) per VBO. @@ -71,7 +72,7 @@ struct vbo_exec_eval2_map { struct vbo_exec_copied_vtx { - GLfloat buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS]; + fi_type buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS]; GLuint nr; }; @@ -91,10 +92,10 @@ struct vbo_exec_context struct _mesa_prim prim[VBO_MAX_PRIM]; GLuint prim_count; - GLfloat *buffer_map; - GLfloat *buffer_ptr; /* cursor, points into buffer */ + fi_type *buffer_map; + fi_type *buffer_ptr; /* cursor, points into buffer */ GLuint buffer_used; /* in bytes */ - GLfloat vertex[VBO_ATTRIB_MAX*4]; /* current vertex */ + fi_type vertex[VBO_ATTRIB_MAX*4]; /* current vertex */ GLuint vert_count; GLuint max_vert; @@ -104,7 +105,7 @@ struct vbo_exec_context GLenum attrtype[VBO_ATTRIB_MAX]; GLubyte active_sz[VBO_ATTRIB_MAX]; - GLfloat *attrptr[VBO_ATTRIB_MAX]; + fi_type *attrptr[VBO_ATTRIB_MAX]; struct gl_client_array arrays[VERT_ATTRIB_MAX]; /* According to program mode, the values above plus current diff --git a/mesalib/src/mesa/vbo/vbo_exec_api.c b/mesalib/src/mesa/vbo/vbo_exec_api.c index 5f8250e78..9669abe7d 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_api.c +++ b/mesalib/src/mesa/vbo/vbo_exec_api.c @@ -115,7 +115,7 @@ static void vbo_exec_wrap_buffers( struct vbo_exec_context *exec ) */ void vbo_exec_vtx_wrap( struct vbo_exec_context *exec ) { - GLfloat *data = exec->vtx.copied.buffer; + fi_type *data = exec->vtx.copied.buffer; GLuint i; /* Run pipeline on current vertices, copy wrapped vertices @@ -159,9 +159,9 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) * ctx->Current.Attrib and ctx->Light.Material.Attrib arrays. */ GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; - GLfloat tmp[4]; + fi_type tmp[4]; - COPY_CLEAN_4V_TYPE_AS_FLOAT(tmp, + COPY_CLEAN_4V_TYPE_AS_UNION(tmp, exec->vtx.attrsz[i], exec->vtx.attrptr[i], exec->vtx.attrtype[i]); @@ -214,7 +214,7 @@ vbo_exec_copy_from_current(struct vbo_exec_context *exec) GLint i; for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) { - const GLfloat *current = (GLfloat *) vbo->currval[i].Ptr; + const fi_type *current = (fi_type *) vbo->currval[i].Ptr; switch (exec->vtx.attrsz[i]) { case 4: exec->vtx.attrptr[i][3] = current[3]; case 3: exec->vtx.attrptr[i][2] = current[2]; @@ -240,7 +240,7 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, struct gl_context *ctx = exec->ctx; struct vbo_context *vbo = vbo_context(ctx); const GLint lastcount = exec->vtx.vert_count; - GLfloat *old_attrptr[VBO_ATTRIB_MAX]; + fi_type *old_attrptr[VBO_ATTRIB_MAX]; const GLuint old_vtx_size = exec->vtx.vertex_size; /* floats per vertex */ const GLuint oldSize = exec->vtx.attrsz[attr]; GLuint i; @@ -287,7 +287,7 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, if (unlikely(oldSize)) { /* Size changed, recalculate all the attrptr[] values */ - GLfloat *tmp = exec->vtx.vertex; + fi_type *tmp = exec->vtx.vertex; for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) { if (exec->vtx.attrsz[i]) { @@ -306,7 +306,7 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, else { /* Just have to append the new attribute at the end */ exec->vtx.attrptr[attr] = exec->vtx.vertex + - exec->vtx.vertex_size - newSize; + exec->vtx.vertex_size - newSize; } /* Replay stored vertices to translate them @@ -315,8 +315,8 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, * -- No need to replay - just copy piecewise */ if (unlikely(exec->vtx.copied.nr)) { - GLfloat *data = exec->vtx.copied.buffer; - GLfloat *dest = exec->vtx.buffer_ptr; + fi_type *data = exec->vtx.copied.buffer; + fi_type *dest = exec->vtx.buffer_ptr; GLuint j; assert(exec->vtx.buffer_ptr == exec->vtx.buffer_map); @@ -331,13 +331,13 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, if (j == attr) { if (oldSize) { - GLfloat tmp[4]; - COPY_CLEAN_4V_TYPE_AS_FLOAT(tmp, oldSize, + fi_type tmp[4]; + COPY_CLEAN_4V_TYPE_AS_UNION(tmp, oldSize, data + old_offset, exec->vtx.attrtype[j]); COPY_SZ_4V(dest + new_offset, newSize, tmp); } else { - GLfloat *current = (GLfloat *)vbo->currval[j].Ptr; + fi_type *current = (fi_type *)vbo->currval[j].Ptr; COPY_SZ_4V(dest + new_offset, sz, current); } } @@ -376,14 +376,14 @@ vbo_exec_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint newSize) } else if (newSize < exec->vtx.active_sz[attr]) { GLuint i; - const GLfloat *id = - vbo_get_default_vals_as_float(exec->vtx.attrtype[attr]); + const fi_type *id = + vbo_get_default_vals_as_union(exec->vtx.attrtype[attr]); /* New size is smaller - just need to fill in some * zeros. Don't need to flush or wrap. */ for (i = newSize; i <= exec->vtx.attrsz[attr]; i++) - exec->vtx.attrptr[attr][i-1] = id[i-1]; + exec->vtx.attrptr[attr][i-1] = id[i-1]; } exec->vtx.active_sz[attr] = newSize; @@ -401,7 +401,7 @@ vbo_exec_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint newSize) * This macro is used to implement all the glVertex, glColor, glTexCoord, * glVertexAttrib, etc functions. */ -#define ATTR( A, N, T, V0, V1, V2, V3 ) \ +#define ATTR_UNION( A, N, T, V0, V1, V2, V3 ) \ do { \ struct vbo_exec_context *exec = &vbo_context(ctx)->exec; \ \ @@ -412,12 +412,12 @@ do { \ vbo_exec_fixup_vertex(ctx, A, N); \ \ { \ - GLfloat *dest = exec->vtx.attrptr[A]; \ + fi_type *dest = exec->vtx.attrptr[A]; \ if (N>0) dest[0] = V0; \ if (N>1) dest[1] = V1; \ if (N>2) dest[2] = V2; \ if (N>3) dest[3] = V3; \ - exec->vtx.attrtype[A] = T; \ + exec->vtx.attrtype[A] = T; \ } \ \ if ((A) == 0) { \ @@ -1036,7 +1036,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) &exec->vtx.bufferobj, ctx->Shared->NullBufferObj); - ASSERT(!exec->vtx.buffer_map); + assert(!exec->vtx.buffer_map); exec->vtx.buffer_map = _mesa_align_malloc(VBO_VERT_BUFFER_SIZE, 64); exec->vtx.buffer_ptr = exec->vtx.buffer_map; @@ -1044,16 +1044,16 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) _mesa_noop_vtxfmt_init(&exec->vtxfmt_noop); for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) { - ASSERT(i < Elements(exec->vtx.attrsz)); + assert(i < ARRAY_SIZE(exec->vtx.attrsz)); exec->vtx.attrsz[i] = 0; - ASSERT(i < Elements(exec->vtx.attrtype)); + assert(i < ARRAY_SIZE(exec->vtx.attrtype)); exec->vtx.attrtype[i] = GL_FLOAT; - ASSERT(i < Elements(exec->vtx.active_sz)); + assert(i < ARRAY_SIZE(exec->vtx.active_sz)); exec->vtx.active_sz[i] = 0; } for (i = 0 ; i < VERT_ATTRIB_MAX; i++) { - ASSERT(i < Elements(exec->vtx.inputs)); - ASSERT(i < Elements(exec->vtx.arrays)); + assert(i < ARRAY_SIZE(exec->vtx.inputs)); + assert(i < ARRAY_SIZE(exec->vtx.arrays)); exec->vtx.inputs[i] = &exec->vtx.arrays[i]; } @@ -1099,7 +1099,7 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) /* True VBOs should already be unmapped */ if (exec->vtx.buffer_map) { - ASSERT(exec->vtx.bufferobj->Name == 0 || + assert(exec->vtx.bufferobj->Name == 0 || exec->vtx.bufferobj->Name == IMM_BUFFER_NAME); if (exec->vtx.bufferobj->Name == 0) { _mesa_align_free(exec->vtx.buffer_map); @@ -1110,7 +1110,7 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) /* Drop any outstanding reference to the vertex buffer */ - for (i = 0; i < Elements(exec->vtx.arrays); i++) { + for (i = 0; i < ARRAY_SIZE(exec->vtx.arrays); i++) { _mesa_reference_buffer_object(ctx, &exec->vtx.arrays[i].BufferObj, NULL); diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c index c16fe77ee..3ea775c0e 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_array.c +++ b/mesalib/src/mesa/vbo/vbo_exec_array.c @@ -26,6 +26,7 @@ * **************************************************************************/ +#include <stdio.h> #include "main/glheader.h" #include "main/context.h" #include "main/state.h" @@ -181,8 +182,7 @@ vbo_get_minmax_index(struct gl_context *ctx, break; } default: - assert(0); - break; + unreachable("not reached"); } if (_mesa_is_bufferobj(ib->obj)) { @@ -331,7 +331,7 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType, } /* check element j of each enabled array */ - for (k = 0; k < Elements(vao->_VertexAttrib); k++) { + for (k = 0; k < ARRAY_SIZE(vao->_VertexAttrib); k++) { check_array_data(ctx, &vao->_VertexAttrib[k], k, j); } } @@ -341,7 +341,7 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType, MAP_INTERNAL); } - for (k = 0; k < Elements(vao->_VertexAttrib); k++) { + for (k = 0; k < ARRAY_SIZE(vao->_VertexAttrib); k++) { unmap_array_buffer(ctx, &vao->_VertexAttrib[k]); } } diff --git a/mesalib/src/mesa/vbo/vbo_exec_draw.c b/mesalib/src/mesa/vbo/vbo_exec_draw.c index 362cc1040..91f2ca43a 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_draw.c +++ b/mesalib/src/mesa/vbo/vbo_exec_draw.c @@ -25,6 +25,7 @@ * Keith Whitwell <keithw@vmware.com> */ +#include <stdio.h> #include "main/glheader.h" #include "main/bufferobj.h" #include "main/compiler.h" @@ -73,8 +74,8 @@ vbo_copy_vertices( struct vbo_exec_context *exec ) GLuint nr = exec->vtx.prim[exec->vtx.prim_count-1].count; GLuint ovf, i; GLuint sz = exec->vtx.vertex_size; - GLfloat *dst = exec->vtx.copied.buffer; - const GLfloat *src = (exec->vtx.buffer_map + + fi_type *dst = exec->vtx.copied.buffer; + const fi_type *src = (exec->vtx.buffer_map + exec->vtx.prim[exec->vtx.prim_count-1].start * exec->vtx.vertex_size); @@ -172,7 +173,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr]; } for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) { - ASSERT(VERT_ATTRIB_GENERIC(attr) < Elements(exec->vtx.inputs)); + assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs)); exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr]; } @@ -183,7 +184,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr]; } for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) { - ASSERT(VERT_ATTRIB_GENERIC(attr) < Elements(exec->vtx.inputs)); + assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs)); exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->currval[VBO_ATTRIB_GENERIC0+attr]; } @@ -213,8 +214,8 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) (GLbyte *)exec->vtx.vertex; /* override the default array set above */ - ASSERT(attr < Elements(exec->vtx.inputs)); - ASSERT(attr < Elements(exec->vtx.arrays)); /* arrays[] */ + assert(attr < ARRAY_SIZE(exec->vtx.inputs)); + assert(attr < ARRAY_SIZE(exec->vtx.arrays)); /* arrays[] */ exec->vtx.inputs[attr] = &arrays[attr]; if (_mesa_is_bufferobj(exec->vtx.bufferobj)) { @@ -309,7 +310,7 @@ vbo_exec_vtx_map( struct vbo_exec_context *exec ) /* The VBO exists and there's room for more */ if (exec->vtx.bufferobj->Size > 0) { exec->vtx.buffer_map = - (GLfloat *)ctx->Driver.MapBufferRange(ctx, + (fi_type *)ctx->Driver.MapBufferRange(ctx, exec->vtx.buffer_used, (VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used), @@ -336,7 +337,7 @@ vbo_exec_vtx_map( struct vbo_exec_context *exec ) exec->vtx.bufferobj)) { /* buffer allocation worked, now map the buffer */ exec->vtx.buffer_map = - (GLfloat *)ctx->Driver.MapBufferRange(ctx, + (fi_type *)ctx->Driver.MapBufferRange(ctx, 0, VBO_VERT_BUFFER_SIZE, accessRange, exec->vtx.bufferobj, diff --git a/mesalib/src/mesa/vbo/vbo_exec_eval.c b/mesalib/src/mesa/vbo/vbo_exec_eval.c index 82f89b95f..b26655bd5 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_eval.c +++ b/mesalib/src/mesa/vbo/vbo_exec_eval.c @@ -35,20 +35,20 @@ static void clear_active_eval1( struct vbo_exec_context *exec, GLuint attr ) { - assert(attr < Elements(exec->eval.map1)); + assert(attr < ARRAY_SIZE(exec->eval.map1)); exec->eval.map1[attr].map = NULL; } static void clear_active_eval2( struct vbo_exec_context *exec, GLuint attr ) { - assert(attr < Elements(exec->eval.map2)); + assert(attr < ARRAY_SIZE(exec->eval.map2)); exec->eval.map2[attr].map = NULL; } static void set_active_eval1( struct vbo_exec_context *exec, GLuint attr, GLuint dim, struct gl_1d_map *map ) { - assert(attr < Elements(exec->eval.map1)); + assert(attr < ARRAY_SIZE(exec->eval.map1)); if (!exec->eval.map1[attr].map) { exec->eval.map1[attr].map = map; exec->eval.map1[attr].sz = dim; @@ -58,7 +58,7 @@ static void set_active_eval1( struct vbo_exec_context *exec, GLuint attr, GLuint static void set_active_eval2( struct vbo_exec_context *exec, GLuint attr, GLuint dim, struct gl_2d_map *map ) { - assert(attr < Elements(exec->eval.map2)); + assert(attr < ARRAY_SIZE(exec->eval.map2)); if (!exec->eval.map2[attr].map) { exec->eval.map2[attr].map = map; exec->eval.map2[attr].sz = dim; @@ -130,11 +130,12 @@ void vbo_exec_do_EvalCoord1f(struct vbo_exec_context *exec, GLfloat u) struct gl_1d_map *map = exec->eval.map1[attr].map; if (map) { GLfloat uu = (u - map->u1) * map->du; - GLfloat data[4]; + fi_type data[4]; - ASSIGN_4V(data, 0, 0, 0, 1); + ASSIGN_4V(data, FLOAT_AS_UNION(0), FLOAT_AS_UNION(0), + FLOAT_AS_UNION(0), FLOAT_AS_UNION(1)); - _math_horner_bezier_curve(map->Points, data, uu, + _math_horner_bezier_curve(map->Points, &data[0].f, uu, exec->eval.map1[attr].sz, map->Order); @@ -176,12 +177,13 @@ void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec, if (map) { GLfloat uu = (u - map->u1) * map->du; GLfloat vv = (v - map->v1) * map->dv; - GLfloat data[4]; + fi_type data[4]; - ASSIGN_4V(data, 0, 0, 0, 1); + ASSIGN_4V(data, FLOAT_AS_UNION(0), FLOAT_AS_UNION(0), + FLOAT_AS_UNION(0), FLOAT_AS_UNION(1)); _math_horner_bezier_surf(map->Points, - data, + &data[0].f, uu, vv, exec->eval.map2[attr].sz, map->Uorder, map->Vorder); @@ -203,7 +205,7 @@ void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec, ASSIGN_4V(vertex, 0, 0, 0, 1); if (exec->ctx->Eval.AutoNormal) { - GLfloat normal[4]; + fi_type normal[4]; GLfloat du[4], dv[4]; _math_de_casteljau_surf(map->Points, vertex, du, dv, uu, vv, @@ -221,11 +223,11 @@ void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec, } - CROSS3(normal, du, dv); - NORMALIZE_3FV(normal); - normal[3] = 1.0; + CROSS3(&normal[0].f, du, dv); + NORMALIZE_3FV(&normal[0].f); + normal[3] = FLOAT_AS_UNION(1.0); - COPY_SZ_4V( exec->vtx.attrptr[VBO_ATTRIB_NORMAL], + COPY_SZ_4V( exec->vtx.attrptr[VBO_ATTRIB_NORMAL], exec->vtx.attrsz[VBO_ATTRIB_NORMAL], normal ); diff --git a/mesalib/src/mesa/vbo/vbo_rebase.c b/mesalib/src/mesa/vbo/vbo_rebase.c index 82a0b8e2b..b06df4ab2 100644 --- a/mesalib/src/mesa/vbo/vbo_rebase.c +++ b/mesalib/src/mesa/vbo/vbo_rebase.c @@ -46,6 +46,7 @@ * of zero. */ +#include <stdio.h> #include "main/glheader.h" #include "main/imports.h" #include "main/mtypes.h" diff --git a/mesalib/src/mesa/vbo/vbo_save.h b/mesalib/src/mesa/vbo/vbo_save.h index fd26b5f61..5b1ac8177 100644 --- a/mesalib/src/mesa/vbo/vbo_save.h +++ b/mesalib/src/mesa/vbo/vbo_save.h @@ -40,7 +40,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. struct vbo_save_copied_vtx { - GLfloat buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS]; + fi_type buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS]; GLuint nr; }; @@ -69,7 +69,7 @@ struct vbo_save_vertex_list { * Keep this in regular (non-VBO) memory to avoid repeated * map/unmap of the VBO when updating GL current data. */ - GLfloat *current_data; + fi_type *current_data; GLuint current_size; GLuint buffer_offset; @@ -107,7 +107,7 @@ struct vbo_save_vertex_list { */ struct vbo_save_vertex_store { struct gl_buffer_object *bufferobj; - GLfloat *buffer; + fi_type *buffer; GLuint used; GLuint refcount; }; @@ -133,7 +133,7 @@ struct vbo_save_context { GLboolean out_of_memory; /**< True if last VBO allocation failed */ - GLfloat *buffer; + fi_type *buffer; GLuint count; GLuint wrap_count; GLuint replay_flags; @@ -144,9 +144,9 @@ struct vbo_save_context { struct vbo_save_vertex_store *vertex_store; struct vbo_save_primitive_store *prim_store; - GLfloat *buffer_ptr; /* cursor, points into buffer */ - GLfloat vertex[VBO_ATTRIB_MAX*4]; /* current values */ - GLfloat *attrptr[VBO_ATTRIB_MAX]; + fi_type *buffer_ptr; /* cursor, points into buffer */ + fi_type vertex[VBO_ATTRIB_MAX*4]; /* current values */ + fi_type *attrptr[VBO_ATTRIB_MAX]; GLuint vert_count; GLuint max_vert; GLboolean dangling_attr_ref; @@ -155,7 +155,7 @@ struct vbo_save_context { struct vbo_save_copied_vtx copied; - GLfloat *current[VBO_ATTRIB_MAX]; /* points into ctx->ListState */ + fi_type *current[VBO_ATTRIB_MAX]; /* points into ctx->ListState */ GLubyte *currentsz[VBO_ATTRIB_MAX]; }; @@ -186,7 +186,7 @@ void vbo_save_playback_vertex_list( struct gl_context *ctx, void *data ); void vbo_save_api_init( struct vbo_save_context *save ); -GLfloat * +fi_type * vbo_save_map_vertex_store(struct gl_context *ctx, struct vbo_save_vertex_store *vertex_store); diff --git a/mesalib/src/mesa/vbo/vbo_save_api.c b/mesalib/src/mesa/vbo/vbo_save_api.c index beef342be..fd9a5de3d 100644 --- a/mesalib/src/mesa/vbo/vbo_save_api.c +++ b/mesalib/src/mesa/vbo/vbo_save_api.c @@ -99,14 +99,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. static GLuint _save_copy_vertices(struct gl_context *ctx, const struct vbo_save_vertex_list *node, - const GLfloat * src_buffer) + const fi_type * src_buffer) { struct vbo_save_context *save = &vbo_context(ctx)->save; const struct _mesa_prim *prim = &node->prim[node->prim_count - 1]; GLuint nr = prim->count; GLuint sz = save->vertex_size; - const GLfloat *src = src_buffer + prim->start * sz; - GLfloat *dst = save->copied.buffer; + const fi_type *src = src_buffer + prim->start * sz; + fi_type *dst = save->copied.buffer; GLuint ovf, i; if (prim->end) @@ -233,7 +233,7 @@ free_vertex_store(struct gl_context *ctx, } -GLfloat * +fi_type * vbo_save_map_vertex_store(struct gl_context *ctx, struct vbo_save_vertex_store *vertex_store) { @@ -249,7 +249,7 @@ vbo_save_map_vertex_store(struct gl_context *ctx, /* Map the remaining free space in the VBO */ GLintptr offset = vertex_store->used * sizeof(GLfloat); GLsizeiptr size = vertex_store->bufferobj->Size - offset; - GLfloat *range = (GLfloat *) + fi_type *range = (fi_type *) ctx->Driver.MapBufferRange(ctx, offset, size, access, vertex_store->bufferobj, MAP_INTERNAL); @@ -549,7 +549,7 @@ static void _save_wrap_filled_vertex(struct gl_context *ctx) { struct vbo_save_context *save = &vbo_context(ctx)->save; - GLfloat *data = save->copied.buffer; + fi_type *data = save->copied.buffer; GLuint i; /* Emit a glEnd to close off the last vertex list. @@ -578,7 +578,7 @@ _save_copy_to_current(struct gl_context *ctx) for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) { if (save->attrsz[i]) { save->currentsz[i][0] = save->attrsz[i]; - COPY_CLEAN_4V_TYPE_AS_FLOAT(save->current[i], save->attrsz[i], + COPY_CLEAN_4V_TYPE_AS_UNION(save->current[i], save->attrsz[i], save->attrptr[i], save->attrtype[i]); } } @@ -620,7 +620,7 @@ _save_upgrade_vertex(struct gl_context *ctx, GLuint attr, GLuint newsz) struct vbo_save_context *save = &vbo_context(ctx)->save; GLuint oldsz; GLuint i; - GLfloat *tmp; + fi_type *tmp; /* Store the current run of vertices, and emit a GL_END. Emit a * BEGIN in the new buffer. @@ -669,8 +669,8 @@ _save_upgrade_vertex(struct gl_context *ctx, GLuint attr, GLuint newsz) * and will need fixup at runtime. */ if (save->copied.nr) { - const GLfloat *data = save->copied.buffer; - GLfloat *dest = save->buffer; + const fi_type *data = save->copied.buffer; + fi_type *dest = save->buffer; GLuint j; /* Need to note this and fix up at runtime (or loopback): @@ -685,7 +685,7 @@ _save_upgrade_vertex(struct gl_context *ctx, GLuint attr, GLuint newsz) if (save->attrsz[j]) { if (j == attr) { if (oldsz) { - COPY_CLEAN_4V_TYPE_AS_FLOAT(dest, oldsz, data, + COPY_CLEAN_4V_TYPE_AS_UNION(dest, oldsz, data, save->attrtype[j]); data += oldsz; dest += newsz; @@ -729,7 +729,7 @@ save_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint sz) } else if (sz < save->active_sz[attr]) { GLuint i; - const GLfloat *id = vbo_get_default_vals_as_float(save->attrtype[attr]); + const fi_type *id = vbo_get_default_vals_as_union(save->attrtype[attr]); /* New size is equal or smaller - just need to fill in some * zeros. @@ -772,7 +772,7 @@ _save_reset_vertex(struct gl_context *ctx) * 3f version won't otherwise set color[3] to 1.0 -- this is the job * of the chooser function when switching between Color4f and Color3f. */ -#define ATTR(A, N, T, V0, V1, V2, V3) \ +#define ATTR_UNION(A, N, T, V0, V1, V2, V3) \ do { \ struct vbo_save_context *save = &vbo_context(ctx)->save; \ \ @@ -780,12 +780,12 @@ do { \ save_fixup_vertex(ctx, A, N); \ \ { \ - GLfloat *dest = save->attrptr[A]; \ + fi_type *dest = save->attrptr[A]; \ if (N>0) dest[0] = V0; \ if (N>1) dest[1] = V1; \ if (N>2) dest[2] = V2; \ if (N>3) dest[3] = V3; \ - save->attrtype[A] = T; \ + save->attrtype[A] = T; \ } \ \ if ((A) == 0) { \ @@ -1564,16 +1564,16 @@ _save_current_init(struct gl_context *ctx) for (i = VBO_ATTRIB_POS; i <= VBO_ATTRIB_GENERIC15; i++) { const GLuint j = i - VBO_ATTRIB_POS; - ASSERT(j < VERT_ATTRIB_MAX); + assert(j < VERT_ATTRIB_MAX); save->currentsz[i] = &ctx->ListState.ActiveAttribSize[j]; - save->current[i] = ctx->ListState.CurrentAttrib[j]; + save->current[i] = (fi_type *) ctx->ListState.CurrentAttrib[j]; } for (i = VBO_ATTRIB_FIRST_MATERIAL; i <= VBO_ATTRIB_LAST_MATERIAL; i++) { const GLuint j = i - VBO_ATTRIB_FIRST_MATERIAL; - ASSERT(j < MAT_ATTRIB_MAX); + assert(j < MAT_ATTRIB_MAX); save->currentsz[i] = &ctx->ListState.ActiveMaterialSize[j]; - save->current[i] = ctx->ListState.CurrentMaterial[j]; + save->current[i] = (fi_type *) ctx->ListState.CurrentMaterial[j]; } } diff --git a/mesalib/src/mesa/vbo/vbo_save_draw.c b/mesalib/src/mesa/vbo/vbo_save_draw.c index d0521d794..74e266d19 100644 --- a/mesalib/src/mesa/vbo/vbo_save_draw.c +++ b/mesalib/src/mesa/vbo/vbo_save_draw.c @@ -47,8 +47,8 @@ _playback_copy_to_current(struct gl_context *ctx, const struct vbo_save_vertex_list *node) { struct vbo_context *vbo = vbo_context(ctx); - GLfloat vertex[VBO_ATTRIB_MAX * 4]; - GLfloat *data; + fi_type vertex[VBO_ATTRIB_MAX * 4]; + fi_type *data; GLuint i, offset; if (node->current_size == 0) @@ -75,10 +75,10 @@ _playback_copy_to_current(struct gl_context *ctx, for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) { if (node->attrsz[i]) { - GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; - GLfloat tmp[4]; + fi_type *current = (fi_type *)vbo->currval[i].Ptr; + fi_type tmp[4]; - COPY_CLEAN_4V_TYPE_AS_FLOAT(tmp, + COPY_CLEAN_4V_TYPE_AS_UNION(tmp, node->attrsz[i], data, node->attrtype[i]); diff --git a/mesalib/src/mesa/vbo/vbo_save_loopback.c b/mesalib/src/mesa/vbo/vbo_save_loopback.c index 8c93ae86a..7410f1875 100644 --- a/mesalib/src/mesa/vbo/vbo_save_loopback.c +++ b/mesalib/src/mesa/vbo/vbo_save_loopback.c @@ -25,6 +25,7 @@ * **************************************************************************/ +#include <stdio.h> #include "main/context.h" #include "main/glheader.h" #include "main/enums.h" diff --git a/mesalib/src/mesa/vbo/vbo_split_copy.c b/mesalib/src/mesa/vbo/vbo_split_copy.c index ca752e810..d1107dd84 100644 --- a/mesalib/src/mesa/vbo/vbo_split_copy.c +++ b/mesalib/src/mesa/vbo/vbo_split_copy.c @@ -29,6 +29,8 @@ /* Split indexed primitives with per-vertex copying. */ +#include <stdio.h> + #include "main/glheader.h" #include "main/bufferobj.h" #include "main/imports.h" diff --git a/mesalib/src/mesa/x86/common_x86.c b/mesalib/src/mesa/x86/common_x86.c index 25f5c40e2..14b497d06 100644 --- a/mesalib/src/mesa/x86/common_x86.c +++ b/mesalib/src/mesa/x86/common_x86.c @@ -344,13 +344,13 @@ _mesa_get_x86_features(void) #elif defined(USE_X86_64_ASM) { - unsigned int uninitialized_var(eax), uninitialized_var(ebx), - uninitialized_var(ecx), uninitialized_var(edx); + unsigned int eax, ebx, ecx, edx; /* Always available on x86-64. */ _mesa_x86_cpu_features |= X86_FEATURE_XMM | X86_FEATURE_XMM2; - __get_cpuid(1, &eax, &ebx, &ecx, &edx); + if (!__get_cpuid(1, &eax, &ebx, &ecx, &edx)) + return; if (ecx & bit_SSE4_1) _mesa_x86_cpu_features |= X86_FEATURE_SSE4_1; diff --git a/mesalib/src/mesa/x86/gen_matypes.c b/mesalib/src/mesa/x86/gen_matypes.c index 1e904aa0b..18ffb728a 100644 --- a/mesalib/src/mesa/x86/gen_matypes.c +++ b/mesalib/src/mesa/x86/gen_matypes.c @@ -35,6 +35,8 @@ #ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS #endif + +#include <stdio.h> #include <inttypes.h> #include "main/glheader.h" diff --git a/mesalib/src/util/Makefile.am b/mesalib/src/util/Makefile.am index 9af233059..ec49dc6cf 100644 --- a/mesalib/src/util/Makefile.am +++ b/mesalib/src/util/Makefile.am @@ -25,6 +25,9 @@ include Makefile.sources noinst_LTLIBRARIES = libmesautil.la +AM_CPPFLAGS = \ + -I$(top_srcdir)/include + libmesautil_la_CPPFLAGS = \ $(DEFINES) \ -I$(top_srcdir)/include \ @@ -34,7 +37,8 @@ libmesautil_la_CPPFLAGS = \ -I$(top_srcdir)/src/gallium/include \ -I$(top_srcdir)/src/gallium/auxiliary \ $(SHA1_CFLAGS) \ - $(VISIBILITY_CFLAGS) + $(VISIBILITY_CFLAGS) \ + $(MSVC2008_COMPAT_CFLAGS) libmesautil_la_SOURCES = \ $(MESA_UTIL_FILES) \ diff --git a/mesalib/src/util/SConscript b/mesalib/src/util/SConscript index 84bd7a1e1..9e4d481f8 100644 --- a/mesalib/src/util/SConscript +++ b/mesalib/src/util/SConscript @@ -6,6 +6,8 @@ from sys import executable as python_cmd env = env.Clone() +env.MSVC2008Compat() + env.Prepend(CPPPATH = [ '#include', '#src', diff --git a/mesalib/src/util/bitset.h b/mesalib/src/util/bitset.h index 17c5d5d25..febcddefd 100644 --- a/mesalib/src/util/bitset.h +++ b/mesalib/src/util/bitset.h @@ -94,6 +94,6 @@ __bitset_ffs(const BITSET_WORD *x, int n) return 0; } -#define BITSET_FFS(x) __bitset_ffs(x, Elements(x)) +#define BITSET_FFS(x) __bitset_ffs(x, ARRAY_SIZE(x)) #endif diff --git a/mesalib/src/util/macros.h b/mesalib/src/util/macros.h index eec8b9352..b862bfd5f 100644 --- a/mesalib/src/util/macros.h +++ b/mesalib/src/util/macros.h @@ -156,4 +156,27 @@ do { \ # endif #endif +/** + * PUBLIC/USED macros + * + * If we build the library with gcc's -fvisibility=hidden flag, we'll + * use the PUBLIC macro to mark functions that are to be exported. + * + * We also need to define a USED attribute, so the optimizer doesn't + * inline a static function that we later use in an alias. - ajax + */ +#ifndef PUBLIC +# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define PUBLIC __attribute__((visibility("default"))) +# define USED __attribute__((used)) +# elif defined(_MSC_VER) +# define PUBLIC __declspec(dllexport) +# define USED +# else +# define PUBLIC +# define USED +# endif +#endif + + #endif /* UTIL_MACROS_H */ diff --git a/mesalib/src/util/register_allocate.c b/mesalib/src/util/register_allocate.c index 684ee5d6c..2ad8c3ce1 100644 --- a/mesalib/src/util/register_allocate.c +++ b/mesalib/src/util/register_allocate.c @@ -168,6 +168,12 @@ struct ra_graph { unsigned int *stack; unsigned int stack_count; + + /** + * Tracks the start of the set of optimistically-colored registers in the + * stack. + */ + unsigned int stack_optimistic_start; }; /** @@ -454,6 +460,7 @@ static void ra_simplify(struct ra_graph *g) { bool progress = true; + unsigned int stack_optimistic_start = UINT_MAX; int i; while (progress) { @@ -482,6 +489,9 @@ ra_simplify(struct ra_graph *g) } if (!progress && best_optimistic_node != ~0U) { + if (stack_optimistic_start == UINT_MAX) + stack_optimistic_start = g->stack_count; + decrement_q(g, best_optimistic_node); g->stack[g->stack_count] = best_optimistic_node; g->stack_count++; @@ -489,6 +499,8 @@ ra_simplify(struct ra_graph *g) progress = true; } } + + g->stack_optimistic_start = stack_optimistic_start; } /** @@ -542,7 +554,17 @@ ra_select(struct ra_graph *g) g->nodes[n].reg = r; g->stack_count--; - if (g->regs->round_robin) + /* Rotate the starting point except for any nodes above the lowest + * optimistically colorable node. The likelihood that we will succeed + * at allocating optimistically colorable nodes is highly dependent on + * the way that the previous nodes popped off the stack are laid out. + * The round-robin strategy increases the fragmentation of the register + * file and decreases the number of nearby nodes assigned to the same + * color, what increases the likelihood of spilling with respect to the + * dense packing strategy. + */ + if (g->regs->round_robin && + g->stack_count - 1 <= g->stack_optimistic_start) start_search_reg = r + 1; } diff --git a/mesalib/src/util/register_allocate.h b/mesalib/src/util/register_allocate.h index dc6874495..61f182eff 100644 --- a/mesalib/src/util/register_allocate.h +++ b/mesalib/src/util/register_allocate.h @@ -27,6 +27,12 @@ #include <stdbool.h> + +#ifdef __cplusplus +extern "C" { +#endif + + struct ra_class; struct ra_regs; @@ -77,3 +83,7 @@ void ra_set_node_spill_cost(struct ra_graph *g, unsigned int n, float cost); int ra_get_best_spill_node(struct ra_graph *g); /** @} */ + +#ifdef __cplusplus +} // extern "C" +#endif |