diff options
119 files changed, 3824 insertions, 2019 deletions
diff --git a/X11/xtrans/Xtrans.c b/X11/xtrans/Xtrans.c index d9e32d01f..ae8ffad8e 100644 --- a/X11/xtrans/Xtrans.c +++ b/X11/xtrans/Xtrans.c @@ -48,8 +48,9 @@ from The Open Group. */ #include <ctype.h> -#ifdef HAVE_SYSTEMD_DAEMON +#include <stdlib.h> #include <string.h> +#ifdef HAVE_SYSTEMD_DAEMON #include <systemd/sd-daemon.h> #endif @@ -166,8 +167,8 @@ TRANS(SelectTransport) (const char *protocol) protobuf[PROTOBUFSIZE-1] = '\0'; for (i = 0; i < PROTOBUFSIZE && protobuf[i] != '\0'; i++) - if (isupper (protobuf[i])) - protobuf[i] = tolower (protobuf[i]); + if (isupper ((unsigned char)protobuf[i])) + protobuf[i] = tolower ((unsigned char)protobuf[i]); /* Look at all of the configured protocols */ diff --git a/X11/xtrans/xtrans.pc.in b/X11/xtrans/xtrans.pc.in index 90d19b16f..b8d135b3f 100644 --- a/X11/xtrans/xtrans.pc.in +++ b/X11/xtrans/xtrans.pc.in @@ -6,4 +6,4 @@ includedir=@includedir@ Name: XTrans Description: Abstract network code for X Version: @PACKAGE_VERSION@ -Cflags: -I${includedir} -D_BSD_SOURCE @fchown_define@ @sticky_bit_define@ +Cflags: -I${includedir} -D_DEFAULT_SOURCE -D_BSD_SOURCE @fchown_define@ @sticky_bit_define@ diff --git a/fontconfig/configure.ac b/fontconfig/configure.ac index 1086a9a55..80875dfa2 100644 --- a/fontconfig/configure.ac +++ b/fontconfig/configure.ac @@ -321,6 +321,10 @@ AC_CHECK_MEMBER(FT_Bitmap_Size.y_ppem, #include FT_FREETYPE_H]) AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,$HAVE_FT_BITMAP_SIZE_Y_PPEM, [FT_Bitmap_Size structure includes y_ppem field]) +AC_CHECK_MEMBERS([TT_OS2.usLowerOpticalPointSize, TT_OS2.usUpperOpticalPointSize], [], [], [[ +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_TRUETYPE_TABLES_H]]) CFLAGS="$fontconfig_save_cflags" LIBS="$fontconfig_save_libs" diff --git a/fontconfig/doc/Makefile.am b/fontconfig/doc/Makefile.am index 78a7cdbf1..7503219b8 100644 --- a/fontconfig/doc/Makefile.am +++ b/fontconfig/doc/Makefile.am @@ -81,6 +81,7 @@ DOC_FUNCS_FNCS = \ fcobjectset.fncs \ fcobjecttype.fncs \ fcpattern.fncs \ + fcrange.fncs \ fcstring.fncs \ fcstrset.fncs \ fcvalue.fncs \ diff --git a/fontconfig/doc/fcpattern.fncs b/fontconfig/doc/fcpattern.fncs index 1df1c4f61..1049d77af 100644 --- a/fontconfig/doc/fcpattern.fncs +++ b/fontconfig/doc/fcpattern.fncs @@ -181,12 +181,21 @@ values added to the list have binding <parameter>weak</parameter> instead of <pa @TYPE2+++++++@ const char * @ARG2+++++++@ object @TYPE3+++++++@ const FcLangSet * @ARG3+++++++@ l +@PROTOTYPE++++++++@ +@RET++++++++@ FcBool +@FUNC++++++++@ FcPatternAddRange +@TYPE1++++++++@ FcPattern * @ARG1++++++++@ p +@TYPE2++++++++@ const char * @ARG2++++++++@ object +@TYPE3++++++++@ const FcRange * @ARG3++++++++@ r + @PURPOSE@ Add a typed value to a pattern @DESC@ These are all convenience functions that insert objects of the specified type into the pattern. Use these in preference to FcPatternAdd as they will provide compile-time typechecking. These all append values to any existing list of values. + +<function>FcPatternAddRange</function> are available since 2.11.91. @@ @RET@ FcResult @@ -257,16 +266,24 @@ within the pattern directly. Applications must not free this value. @FUNC++++++@ FcPatternGetFTFace @TYPE1++++++@ FcPattern * @ARG1++++++@ p @TYPE2++++++@ const char * @ARG2++++++@ object -@TYPE3+++++@ int% @ARG3+++++@ n -@TYPE3++++++@ FT_Face * @ARG3++++++@ f +@TYPE3++++++@ int% @ARG3++++++@ n +@TYPE4++++++@ FT_Face * @ARG4++++++@ f @PROTOTYPE+++++++@ @RET+++++++@ FcResult @FUNC+++++++@ FcPatternGetLangSet @TYPE1+++++++@ FcPattern * @ARG1+++++++@ p @TYPE2+++++++@ const char * @ARG2+++++++@ object -@TYPE3+++++@ int% @ARG3+++++@ n -@TYPE3+++++++@ FcLangSet ** @ARG3+++++++@ l +@TYPE3+++++++@ int% @ARG3+++++++@ n +@TYPE4+++++++@ FcLangSet ** @ARG4+++++++@ l + +@PROTOTYPE++++++++@ +@RET++++++++@ FcResult +@FUNC++++++++@ FcPatternGetRange +@TYPE1++++++++@ FcPattern * @ARG1++++++++@ p +@TYPE2++++++++@ const char * @ARG2++++++++@ object +@TYPE3++++++++@ int% @ARG3++++++++@ n +@TYPE4++++++++@ FcRange ** @ARG4++++++++@ r @PURPOSE@ Return a typed value from a pattern @DESC@ @@ -275,6 +292,8 @@ returned data is of the expected type. They return FcResultTypeMismatch if this is not the case. Note that these (like FcPatternGet) do not make a copy of any data structure referenced by the return value. Use these in preference to FcPatternGet to provide compile-time typechecking. + +<function>FcPatternGetRange</function> are available since 2.11.91. @@ @RET@ FcPattern * diff --git a/fontconfig/doc/fcrange.fncs b/fontconfig/doc/fcrange.fncs new file mode 100644 index 000000000..605459525 --- /dev/null +++ b/fontconfig/doc/fcrange.fncs @@ -0,0 +1,64 @@ +/* + * fontconfig/doc/fcrange.fncs + * + * 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. + */ +@RET@ FcRange * +@FUNC@ FcRangeCopy +@TYPE1@ const FcRange * @ARG1@ range +@PURPOSE@ Copy a range object +@DESC@ +<function>FcRangeCopy</function> creates a new FcRange object and +populates it with the contents of <parameter>range</parameter>. +@SINCE@ 2.11.91 +@@ + +@RET@ FcRange * +@FUNC@ FcRangeCreateDouble +@TYPE1@ double @ARG1@ begin +@TYPE2@ double @ARG2@ end +@PURPOSE@ create a range object for double +@DESC@ +<function>FcRangeCreateDouble</function> creates a new FcRange object with +double sized value. +@SINCE@ 2.11.91 +@@ + +@RET@ FcRange * +@FUNC@ FcRangeCreateInteger +@TYPE1@ int @ARG1@ begin +@TYPE2@ int @ARG2@ end +@PURPOSE@ create a range object for integer +@DESC@ +<function>FcRangeCreateInteger</function> creates a new FcRange object with +integer sized value. +@SINCE@ 2.11.91 +@@ + +@RET@ void +@FUNC@ FcRangeDestroy +@TYPE1@ FcRange * @ARG1@ range +@PURPOSE@ destroy a range object +@DESC@ +<function>FcRangeDestroy</function> destroys a FcRange object, freeing +all memory associated with it. +@SINCE@ 2.11.91 +@@ diff --git a/fontconfig/doc/fontconfig-devel.sgml b/fontconfig/doc/fontconfig-devel.sgml index 7306d7924..e2cb1c281 100644 --- a/fontconfig/doc/fontconfig-devel.sgml +++ b/fontconfig/doc/fontconfig-devel.sgml @@ -16,6 +16,7 @@ <!ENTITY fcobjectset SYSTEM "fcobjectset.sgml"> <!ENTITY fcobjecttype SYSTEM "fcobjecttype.sgml"> <!ENTITY fcpattern SYSTEM "fcpattern.sgml"> +<!ENTITY fcrange SYSTEM "fcrange.sgml"> <!ENTITY fcstring SYSTEM "fcstring.sgml"> <!ENTITY fcstrset SYSTEM "fcstrset.sgml"> <!ENTITY fcvalue SYSTEM "fcvalue.sgml"> @@ -508,6 +509,12 @@ FcMatrix structures hold an affine transformation in matrix form. </para> &fcmatrix; </sect2> + <sect2><title>FcRange</title> + <para> +An FcRange holds two variables to indicate a range in between. + </para> + &fcrange; + </sect2> <sect2><title>FcConfig</title> <para> An FcConfig object holds the internal representation of a configuration. diff --git a/fontconfig/fontconfig/fcprivate.h b/fontconfig/fontconfig/fcprivate.h index 210c1d8a3..a6ee5c234 100644 --- a/fontconfig/fontconfig/fcprivate.h +++ b/fontconfig/fontconfig/fcprivate.h @@ -77,6 +77,9 @@ case FcTypeLangSet: \ __v__.u.l = va_arg (va, const FcLangSet *); \ break; \ + case FcTypeRange: \ + __v__.u.r = va_arg (va, const FcRange *); \ + break; \ } \ if (!FcPatternAdd (__p__, __o__, __v__, FcTrue)) \ goto _FcPatternVapBuild_bail1; \ diff --git a/fontconfig/fontconfig/fontconfig.h b/fontconfig/fontconfig/fontconfig.h index 225825127..069cb60dd 100644 --- a/fontconfig/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig/fontconfig.h @@ -75,7 +75,7 @@ typedef int FcBool; #define FC_STYLE "style" /* String */ #define FC_SLANT "slant" /* Int */ #define FC_WEIGHT "weight" /* Int */ -#define FC_SIZE "size" /* Double */ +#define FC_SIZE "size" /* Range (double) */ #define FC_ASPECT "aspect" /* Double */ #define FC_PIXEL_SIZE "pixelsize" /* Double */ #define FC_SPACING "spacing" /* Int */ @@ -194,7 +194,8 @@ typedef enum _FcType { FcTypeMatrix, FcTypeCharSet, FcTypeFTFace, - FcTypeLangSet + FcTypeLangSet, + FcTypeRange } FcType; typedef struct _FcMatrix { @@ -231,6 +232,8 @@ typedef struct _FcPattern FcPattern; typedef struct _FcLangSet FcLangSet; +typedef struct _FcRange FcRange; + typedef struct _FcValue { FcType type; union { @@ -242,6 +245,7 @@ typedef struct _FcValue { const FcCharSet *c; void *f; const FcLangSet *l; + const FcRange *r; } u; } FcValue; @@ -853,6 +857,9 @@ FcPatternAddBool (FcPattern *p, const char *object, FcBool b); FcPublic FcBool FcPatternAddLangSet (FcPattern *p, const char *object, const FcLangSet *ls); +FcPublic FcBool +FcPatternAddRange (FcPattern *p, const char *object, const FcRange *r); + FcPublic FcResult FcPatternGetInteger (const FcPattern *p, const char *object, int n, int *i); @@ -874,6 +881,9 @@ FcPatternGetBool (const FcPattern *p, const char *object, int n, FcBool *b); FcPublic FcResult FcPatternGetLangSet (const FcPattern *p, const char *object, int n, FcLangSet **ls); +FcPublic FcResult +FcPatternGetRange (const FcPattern *p, const char *object, int id, FcRange **r); + FcPublic FcPattern * FcPatternVaBuild (FcPattern *p, va_list va); @@ -883,6 +893,20 @@ FcPatternBuild (FcPattern *p, ...) FC_ATTRIBUTE_SENTINEL(0); FcPublic FcChar8 * FcPatternFormat (FcPattern *pat, const FcChar8 *format); +/* fcrange.c */ +FcPublic FcRange * +FcRangeCreateDouble (double begin, double end); + +FcPublic FcRange * +FcRangeCreateInteger (FcChar32 begin, FcChar32 end); + +FcPublic void +FcRangeDestroy (FcRange *range); + +FcPublic FcRange * +FcRangeCopy (const FcRange *r); + + /* fcstr.c */ FcPublic FcChar8 * diff --git a/fontconfig/src/Makefile.am b/fontconfig/src/Makefile.am index 066cc03e7..be20eba05 100644 --- a/fontconfig/src/Makefile.am +++ b/fontconfig/src/Makefile.am @@ -151,6 +151,7 @@ libfontconfig_la_SOURCES = \ fcobjs.h \ fcobjshash.h \ fcpat.c \ + fcrange.c \ fcserialize.c \ fcstat.c \ fcstr.c \ diff --git a/fontconfig/src/fccfg.c b/fontconfig/src/fccfg.c index 6377fd7c6..cdb8c0f25 100644 --- a/fontconfig/src/fccfg.c +++ b/fontconfig/src/fccfg.c @@ -722,6 +722,11 @@ FcConfigPromote (FcValue v, FcValue u, FcValuePromotionBuffer *buf) v.u.l = FcLangSetPromote (v.u.s, buf); v.type = FcTypeLangSet; } + if (buf && v.type == FcTypeDouble && u.type == FcTypeRange) + { + v.u.r = FcRangePromote (v.u.d, buf); + v.type = FcTypeRange; + } return v; } @@ -894,6 +899,9 @@ FcConfigCompareValue (const FcValue *left_o, break; } break; + case FcTypeRange: + ret = FcRangeCompare (op, left.u.r, right.u.r); + break; } } else @@ -915,10 +923,11 @@ FcConfigCompareValue (const FcValue *left_o, static FcValue FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e) { - FcValue v, vl, vr; + FcValue v, vl, vr, vle, vre; FcMatrix *m; FcChar8 *str; FcOp op = FC_OP_GET_OP (e->op); + FcValuePromotionBuffer buf1, buf2; switch ((int) op) { case FcOpInteger: @@ -967,6 +976,11 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e) v.u.l = e->u.lval; v = FcValueSave (v); break; + case FcOpRange: + v.type = FcTypeRange; + v.u.r = e->u.rval; + v = FcValueSave (v); + break; case FcOpBool: v.type = FcTypeBool; v.u.b = e->u.bval; @@ -1033,28 +1047,28 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e) case FcOpDivide: vl = FcConfigEvaluate (p, p_pat, kind, e->u.tree.left); vr = FcConfigEvaluate (p, p_pat, kind, e->u.tree.right); - vl = FcConfigPromote (vl, vr, NULL); - vr = FcConfigPromote (vr, vl, NULL); - if (vl.type == vr.type) + vle = FcConfigPromote (vl, vr, &buf1); + vre = FcConfigPromote (vr, vle, &buf2); + if (vle.type == vre.type) { - switch ((int) vl.type) { + switch ((int) vle.type) { case FcTypeDouble: switch ((int) op) { case FcOpPlus: v.type = FcTypeDouble; - v.u.d = vl.u.d + vr.u.d; + v.u.d = vle.u.d + vre.u.d; break; case FcOpMinus: v.type = FcTypeDouble; - v.u.d = vl.u.d - vr.u.d; + v.u.d = vle.u.d - vre.u.d; break; case FcOpTimes: v.type = FcTypeDouble; - v.u.d = vl.u.d * vr.u.d; + v.u.d = vle.u.d * vre.u.d; break; case FcOpDivide: v.type = FcTypeDouble; - v.u.d = vl.u.d / vr.u.d; + v.u.d = vle.u.d / vre.u.d; break; default: v.type = FcTypeVoid; @@ -1071,11 +1085,11 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e) switch ((int) op) { case FcOpOr: v.type = FcTypeBool; - v.u.b = vl.u.b || vr.u.b; + v.u.b = vle.u.b || vre.u.b; break; case FcOpAnd: v.type = FcTypeBool; - v.u.b = vl.u.b && vr.u.b; + v.u.b = vle.u.b && vre.u.b; break; default: v.type = FcTypeVoid; @@ -1086,7 +1100,7 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e) switch ((int) op) { case FcOpPlus: v.type = FcTypeString; - str = FcStrPlus (vl.u.s, vr.u.s); + str = FcStrPlus (vle.u.s, vre.u.s); v.u.s = FcStrdup (str); FcStrFree (str); @@ -1105,7 +1119,7 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e) m = malloc (sizeof (FcMatrix)); if (m) { - FcMatrixMultiply (m, vl.u.m, vr.u.m); + FcMatrixMultiply (m, vle.u.m, vre.u.m); v.u.m = m; } else @@ -1122,13 +1136,13 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e) switch ((int) op) { case FcOpPlus: v.type = FcTypeCharSet; - v.u.c = FcCharSetUnion (vl.u.c, vr.u.c); + v.u.c = FcCharSetUnion (vle.u.c, vre.u.c); if (!v.u.c) v.type = FcTypeVoid; break; case FcOpMinus: v.type = FcTypeCharSet; - v.u.c = FcCharSetSubtract (vl.u.c, vr.u.c); + v.u.c = FcCharSetSubtract (vle.u.c, vre.u.c); if (!v.u.c) v.type = FcTypeVoid; break; @@ -1141,13 +1155,13 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e) switch ((int) op) { case FcOpPlus: v.type = FcTypeLangSet; - v.u.l = FcLangSetUnion (vl.u.l, vr.u.l); + v.u.l = FcLangSetUnion (vle.u.l, vre.u.l); if (!v.u.l) v.type = FcTypeVoid; break; case FcOpMinus: v.type = FcTypeLangSet; - v.u.l = FcLangSetSubtract (vl.u.l, vr.u.l); + v.u.l = FcLangSetSubtract (vle.u.l, vre.u.l); if (!v.u.l) v.type = FcTypeVoid; break; diff --git a/fontconfig/src/fcdbg.c b/fontconfig/src/fcdbg.c index d74bc2769..ef038f017 100644 --- a/fontconfig/src/fcdbg.c +++ b/fontconfig/src/fcdbg.c @@ -29,6 +29,8 @@ static void _FcValuePrintFile (FILE *f, const FcValue v) { + FcRange r; + switch (v.type) { case FcTypeUnknown: fprintf (f, "<unknown>"); @@ -61,6 +63,10 @@ _FcValuePrintFile (FILE *f, const FcValue v) case FcTypeFTFace: fprintf (f, "face"); break; + case FcTypeRange: + r = FcRangeCanonicalize (v.u.r); + fprintf (f, "(%g, %g)", r.u.d.begin, r.u.d.end); + break; } } @@ -261,6 +267,8 @@ FcOpPrint (FcOp op_) void FcExprPrint (const FcExpr *expr) { + FcRange r; + if (!expr) printf ("none"); else switch (FC_OP_GET_OP (expr->op)) { case FcOpInteger: printf ("%d", expr->u.ival); break; @@ -277,7 +285,10 @@ FcExprPrint (const FcExpr *expr) FcExprPrint (expr->u.mexpr->yy); printf ("]"); break; - case FcOpRange: break; + case FcOpRange: + r = FcRangeCanonicalize (expr->u.rval); + printf ("(%g, %g)", r.u.d.begin, r.u.d.end); + break; case FcOpBool: printf ("%s", expr->u.bval ? "true" : "false"); break; case FcOpCharSet: printf ("charset\n"); break; case FcOpLangSet: diff --git a/fontconfig/src/fcdefault.c b/fontconfig/src/fcdefault.c index 4beda7c00..7c16f4841 100644 --- a/fontconfig/src/fcdefault.c +++ b/fontconfig/src/fcdefault.c @@ -219,6 +219,7 @@ FcDefaultSubstitute (FcPattern *pattern) { FcValue v, namelang, v2; int i; + double dpi, size, scale, pixelsize; if (FcPatternObjectGet (pattern, FC_WEIGHT_OBJECT, 0, &v) == FcResultNoMatch ) FcPatternObjectAddInteger (pattern, FC_WEIGHT_OBJECT, FC_WEIGHT_NORMAL); @@ -233,32 +234,30 @@ FcDefaultSubstitute (FcPattern *pattern) if (FcPatternObjectGet (pattern, FcBoolDefaults[i].field, 0, &v) == FcResultNoMatch) FcPatternObjectAddBool (pattern, FcBoolDefaults[i].field, FcBoolDefaults[i].value); - if (FcPatternObjectGet (pattern, FC_PIXEL_SIZE_OBJECT, 0, &v) == FcResultNoMatch) - { - double dpi, size, scale; + if (FcPatternObjectGetDouble (pattern, FC_SIZE_OBJECT, 0, &size) != FcResultMatch) + size = 12.0L; + if (FcPatternObjectGetDouble (pattern, FC_SCALE_OBJECT, 0, &scale) != FcResultMatch) + scale = 1.0; + if (FcPatternObjectGetDouble (pattern, FC_DPI_OBJECT, 0, &dpi) != FcResultMatch) + dpi = 75.0; - if (FcPatternObjectGetDouble (pattern, FC_SIZE_OBJECT, 0, &size) != FcResultMatch) - { - size = 12.0; - (void) FcPatternObjectDel (pattern, FC_SIZE_OBJECT); - FcPatternObjectAddDouble (pattern, FC_SIZE_OBJECT, size); - } - if (FcPatternObjectGetDouble (pattern, FC_SCALE_OBJECT, 0, &scale) != FcResultMatch) - { - scale = 1.0; - (void) FcPatternObjectDel (pattern, FC_SCALE_OBJECT); - FcPatternObjectAddDouble (pattern, FC_SCALE_OBJECT, scale); - } - size *= scale; - if (FcPatternObjectGetDouble (pattern, FC_DPI_OBJECT, 0, &dpi) != FcResultMatch) - { - dpi = 75.0; - (void) FcPatternObjectDel (pattern, FC_DPI_OBJECT); - FcPatternObjectAddDouble (pattern, FC_DPI_OBJECT, dpi); - } - size *= dpi / 72.0; - FcPatternObjectAddDouble (pattern, FC_PIXEL_SIZE_OBJECT, size); + if (FcPatternObjectGet (pattern, FC_PIXEL_SIZE_OBJECT, 0, &v) != FcResultMatch) + { + (void) FcPatternObjectDel (pattern, FC_SCALE_OBJECT); + FcPatternObjectAddDouble (pattern, FC_SCALE_OBJECT, scale); + pixelsize = size * scale; + (void) FcPatternObjectDel (pattern, FC_DPI_OBJECT); + FcPatternObjectAddDouble (pattern, FC_DPI_OBJECT, dpi); + pixelsize *= dpi / 72.0; + FcPatternObjectAddDouble (pattern, FC_PIXEL_SIZE_OBJECT, pixelsize); + } + else + { + size = v.u.d; + size = size / dpi * 72.0 / scale; } + (void) FcPatternObjectDel (pattern, FC_SIZE_OBJECT); + FcPatternObjectAddDouble (pattern, FC_SIZE_OBJECT, size); if (FcPatternObjectGet (pattern, FC_FONTVERSION_OBJECT, 0, &v) == FcResultNoMatch) { diff --git a/fontconfig/src/fcfreetype.c b/fontconfig/src/fcfreetype.c index d271d69e2..d0932b31b 100644 --- a/fontconfig/src/fcfreetype.c +++ b/fontconfig/src/fcfreetype.c @@ -1107,6 +1107,8 @@ FcFreeTypeQueryFace (const FT_Face face, FcChar8 *hashstr = NULL; FT_Error err; FT_ULong len = 0, alen; + FcRange *r = NULL; + double lower_size = 0.0L, upper_size = DBL_MAX; pat = FcPatternCreate (); if (!pat) @@ -1514,6 +1516,39 @@ FcFreeTypeQueryFace (const FT_Face face, free (complex_); } +#if defined (HAVE_TT_OS2_USUPPEROPTICALPOINTSIZE) && defined (HAVE_TT_OS2_USLOWEROPTICALPOINTSIZE) + if (os2 && os2->version >= 0x0005 && os2->version != 0xffff) + { + /* usLowerPointSize and usUpperPointSize is actually twips */ + lower_size = os2->usLowerOpticalPointSize / 20.0L; + upper_size = os2->usUpperOpticalPointSize / 20.0L; + } +#endif + if (os2) + { + r = FcRangeCreateDouble (lower_size, upper_size); + if (!FcPatternAddRange (pat, FC_SIZE, r)) + { + FcRangeDestroy (r); + goto bail1; + } + FcRangeDestroy (r); + } + else + { + for (i = 0; i < face->num_fixed_sizes; i++) + { + double d = FcGetPixelSize (face, i); + r = FcRangeCreateDouble (d, d); + if (!FcPatternAddRange (pat, FC_SIZE, r)) + { + FcRangeDestroy (r); + goto bail1; + } + FcRangeDestroy (r); + } + } + /* * Type 1: Check for FontInfo dictionary information * Code from g2@magestudios.net (Gerard Escalante) diff --git a/fontconfig/src/fcint.h b/fontconfig/src/fcint.h index cdf2daba0..dd26fd89a 100644 --- a/fontconfig/src/fcint.h +++ b/fontconfig/src/fcint.h @@ -38,6 +38,8 @@ #include <assert.h> #include <errno.h> #include <limits.h> +#include <float.h> +#include <math.h> #include <unistd.h> #include <stddef.h> #include <sys/types.h> @@ -94,6 +96,11 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA; #define FC_MAX(a,b) ((a) > (b) ? (a) : (b)) #define FC_ABS(a) ((a) < 0 ? -(a) : (a)) +#define FcDoubleIsZero(a) (fabs ((a)) <= DBL_EPSILON) +#define FcDoubleCmpEQ(a,b) (fabs ((a) - (b)) <= DBL_EPSILON) +#define FcDoubleCmpGE(a,b) (FcDoubleCmpEQ (a, b) || (a) > (b)) +#define FcDoubleCmpLE(a,b) (FcDoubleCmpEQ (a, b) || (a) < (b)) + /* slim_internal.h */ #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun) #define FcPrivate __attribute__((__visibility__("hidden"))) @@ -161,6 +168,7 @@ typedef enum _FcValueBinding { #define FcValueString(v) FcPointerMember(v,u.s,FcChar8) #define FcValueCharSet(v) FcPointerMember(v,u.c,const FcCharSet) #define FcValueLangSet(v) FcPointerMember(v,u.l,const FcLangSet) +#define FcValueRange(v) FcPointerMember(v,u.r,const FcRange) typedef struct _FcValueList *FcValueListPtr; @@ -244,20 +252,38 @@ typedef struct _FcExprName { FcMatchKind kind; } FcExprName; +typedef struct _FcRangeInt { + FcChar32 begin; + FcChar32 end; +} FcRangeInt; +typedef struct _FcRangeDouble { + double begin; + double end; +} FcRangeDouble; +struct _FcRange { + FcBool is_double; + FcBool is_inclusive; + union { + FcRangeInt i; + FcRangeDouble d; + } u; +}; + typedef struct _FcExpr { FcOp op; union { - int ival; - double dval; - const FcChar8 *sval; - FcExprMatrix *mexpr; - FcBool bval; - FcCharSet *cval; - FcLangSet *lval; - - FcExprName name; - const FcChar8 *constant; + int ival; + double dval; + const FcChar8 *sval; + FcExprMatrix *mexpr; + FcBool bval; + FcCharSet *cval; + FcLangSet *lval; + FcRange *rval; + + FcExprName name; + const FcChar8 *constant; struct { struct _FcExpr *left, *right; } tree; @@ -532,13 +558,6 @@ typedef struct _FcFileTime { typedef struct _FcCharMap FcCharMap; -typedef struct _FcRange FcRange; - -struct _FcRange { - FcChar32 begin; - FcChar32 end; -}; - typedef struct _FcStatFS FcStatFS; struct _FcStatFS { @@ -1008,6 +1027,9 @@ FcPatternObjectAddBool (FcPattern *p, FcObject object, FcBool b); FcPrivate FcBool FcPatternObjectAddLangSet (FcPattern *p, FcObject object, const FcLangSet *ls); +FcPrivate FcBool +FcPatternObjectAddRange (FcPattern *p, FcObject object, const FcRange *r); + FcPrivate FcResult FcPatternObjectGetInteger (const FcPattern *p, FcObject object, int n, int *i); @@ -1029,6 +1051,9 @@ FcPatternObjectGetBool (const FcPattern *p, FcObject object, int n, FcBool *b); FcPrivate FcResult FcPatternObjectGetLangSet (const FcPattern *p, FcObject object, int n, FcLangSet **ls); +FcPrivate FcResult +FcPatternObjectGetRange (const FcPattern *p, FcObject object, int id, FcRange **r); + FcPrivate FcBool FcPatternAppend (FcPattern *p, FcPattern *s); @@ -1056,6 +1081,32 @@ extern FcPrivate const FcMatrix FcIdentityMatrix; FcPrivate void FcMatrixFree (FcMatrix *mat); +/* fcrange.c */ + +FcPrivate FcRange +FcRangeCanonicalize (const FcRange *range); + +FcPrivate FcRange * +FcRangePromote (double v, FcValuePromotionBuffer *vbuf); + +FcPrivate FcBool +FcRangeIsZero (const FcRange *r); + +FcPrivate FcBool +FcRangeIsInRange (const FcRange *a, const FcRange *b); + +FcPrivate FcBool +FcRangeCompare (FcOp op, const FcRange *a, const FcRange *b); + +FcPrivate FcChar32 +FcRangeHash (const FcRange *r); + +FcPrivate FcBool +FcRangeSerializeAlloc (FcSerialize *serialize, const FcRange *r); + +FcPrivate FcRange * +FcRangeSerialize (FcSerialize *serialize, const FcRange *r); + /* fcstat.c */ FcPrivate int diff --git a/fontconfig/src/fclist.c b/fontconfig/src/fclist.c index a365098a4..6ad297ca4 100644 --- a/fontconfig/src/fclist.c +++ b/fontconfig/src/fclist.c @@ -273,6 +273,8 @@ FcListValueHash (FcValue *value) return (long) v.u.f; case FcTypeLangSet: return FcLangSetHash (v.u.l); + case FcTypeRange: + return FcRangeHash (v.u.r); } return 0; } diff --git a/fontconfig/src/fcmatch.c b/fontconfig/src/fcmatch.c index 93e013f9b..0c0a0670e 100644 --- a/fontconfig/src/fcmatch.c +++ b/fontconfig/src/fcmatch.c @@ -189,6 +189,49 @@ FcCompareSize (FcValue *value1, FcValue *value2) } static double +FcCompareSizeRange (FcValue *v1, FcValue *v2) +{ + FcValue value1 = FcValueCanonicalize (v1); + FcValue value2 = FcValueCanonicalize (v2); + FcRange *r1 = NULL, *r2 = NULL; + double ret = -1.0; + + switch ((int) value1.type) { + case FcTypeDouble: + r1 = FcRangeCreateDouble (value1.u.d, value1.u.d); + break; + case FcTypeRange: + r1 = FcRangeCopy (value1.u.r); + break; + default: + goto bail; + } + switch ((int) value2.type) { + case FcTypeDouble: + r2 = FcRangeCreateDouble (value2.u.d, value2.u.d); + break; + case FcTypeRange: + r2 = FcRangeCopy (value2.u.r); + break; + default: + goto bail; + } + + if (FcRangeIsInRange (r1, r2)) + ret = 0.0; + else + ret = FC_MIN (fabs (r1->u.d.end - r2->u.d.begin), fabs (r1->u.d.begin - r2->u.d.end)); + +bail: + if (r1) + FcRangeDestroy (r1); + if (r2) + FcRangeDestroy (r2); + + return ret; +} + +static double FcCompareFilename (FcValue *v1, FcValue *v2) { const FcChar8 *s1 = FcValueString (v1), *s2 = FcValueString (v2); @@ -227,6 +270,7 @@ FcCompareHash (FcValue *v1, FcValue *v2) #define PRI_FcCompareLang(n) PRI1(n) #define PRI_FcComparePostScript(n) PRI1(n) #define PRI_FcCompareHash(n) PRI1(n) +#define PRI_FcCompareSizeRange(n) PRI1(n) #define FC_OBJECT(NAME, Type, Cmp) PRI_##Cmp(NAME) @@ -255,6 +299,7 @@ typedef enum _FcMatcherPriority { PRI_FAMILY_WEAK, PRI_POSTSCRIPT_NAME_WEAK, PRI1(SPACING), + PRI1(SIZE), PRI1(PIXEL_SIZE), PRI1(STYLE), PRI1(SLANT), diff --git a/fontconfig/src/fcname.c b/fontconfig/src/fcname.c index f302948dd..466617872 100644 --- a/fontconfig/src/fcname.c +++ b/fontconfig/src/fcname.c @@ -87,6 +87,10 @@ FcObjectValidType (FcObject object, FcType type) if (type == FcTypeLangSet || type == FcTypeString) return FcTrue; break; + case FcTypeRange: + if (type == FcTypeRange || type == FcTypeDouble) + return FcTrue; + break; default: if (type == t->type) return FcTrue; @@ -273,6 +277,8 @@ FcNameConvert (FcType type, FcChar8 *string) { FcValue v; FcMatrix m; + double b, e; + char *p; v.type = type; switch ((int) v.type) { @@ -307,6 +313,20 @@ FcNameConvert (FcType type, FcChar8 *string) if (!v.u.l) v.type = FcTypeVoid; break; + case FcTypeRange: + if (sscanf ((char *) string, "(%lg %lg)", &b, &e) != 2) + { + v.u.d = strtod ((char *) string, &p); + if (p != NULL && p[0] != 0) + { + v.type = FcTypeVoid; + break; + } + v.type = FcTypeDouble; + } + else + v.u.r = FcRangeCreateDouble (b, e); + break; default: break; } @@ -476,6 +496,7 @@ FcNameUnparseValue (FcStrBuf *buf, { FcChar8 temp[1024]; FcValue v = FcValueCanonicalize(v0); + FcRange r; switch (v.type) { case FcTypeUnknown: @@ -501,6 +522,18 @@ FcNameUnparseValue (FcStrBuf *buf, return FcNameUnparseLangSet (buf, v.u.l); case FcTypeFTFace: return FcTrue; + case FcTypeRange: + r = FcRangeCanonicalize (v.u.r); + if (!FcDoubleIsZero (r.u.d.begin) || !FcDoubleIsZero (r.u.d.end)) + { + if (FcDoubleCmpEQ (r.u.d.begin, r.u.d.end)) + sprintf ((char *) temp, "%g", r.u.d.begin); + else + sprintf ((char *) temp, "(%g %g)", r.u.d.begin, r.u.d.end); + return FcNameUnparseString (buf, temp, 0); + } + else + return FcTrue; } return FcFalse; } @@ -533,12 +566,13 @@ FcNameUnparse (FcPattern *pat) FcChar8 * FcNameUnparseEscaped (FcPattern *pat, FcBool escape) { - FcStrBuf buf; - FcChar8 buf_static[8192]; + FcStrBuf buf, buf2; + FcChar8 buf_static[8192], buf2_static[256]; int i; FcPatternElt *e; FcStrBufInit (&buf, buf_static, sizeof (buf_static)); + FcStrBufInit (&buf2, buf2_static, sizeof (buf2_static)); e = FcPatternObjectFindElt (pat, FC_FAMILY_OBJECT); if (e) { @@ -548,10 +582,17 @@ FcNameUnparseEscaped (FcPattern *pat, FcBool escape) e = FcPatternObjectFindElt (pat, FC_SIZE_OBJECT); if (e) { - if (!FcNameUnparseString (&buf, (FcChar8 *) "-", 0)) + FcChar8 *p; + + if (!FcNameUnparseString (&buf2, (FcChar8 *) "-", 0)) goto bail0; - if (!FcNameUnparseValueList (&buf, FcPatternEltValues(e), escape ? (FcChar8 *) FC_ESCAPE_FIXED : 0)) + if (!FcNameUnparseValueList (&buf2, FcPatternEltValues(e), escape ? (FcChar8 *) FC_ESCAPE_FIXED : 0)) goto bail0; + p = FcStrBufDoneStatic (&buf2); + FcStrBufDestroy (&buf2); + if (strlen ((const char *)p) > 1) + if (!FcStrBufString (&buf, p)) + goto bail0; } for (i = 0; i < NUM_OBJECT_TYPES; i++) { diff --git a/fontconfig/src/fcobjs.h b/fontconfig/src/fcobjs.h index a0ee0795b..72e71f99c 100644 --- a/fontconfig/src/fcobjs.h +++ b/fontconfig/src/fcobjs.h @@ -31,7 +31,7 @@ FC_OBJECT (FULLNAMELANG, FcTypeString, NULL) FC_OBJECT (SLANT, FcTypeInteger, FcCompareNumber) FC_OBJECT (WEIGHT, FcTypeInteger, FcCompareNumber) FC_OBJECT (WIDTH, FcTypeInteger, FcCompareNumber) -FC_OBJECT (SIZE, FcTypeDouble, NULL) +FC_OBJECT (SIZE, FcTypeRange, FcCompareSizeRange) FC_OBJECT (ASPECT, FcTypeDouble, NULL) FC_OBJECT (PIXEL_SIZE, FcTypeDouble, FcCompareSize) FC_OBJECT (SPACING, FcTypeInteger, FcCompareNumber) diff --git a/fontconfig/src/fcpat.c b/fontconfig/src/fcpat.c index 986cca391..7e7d54a4e 100644 --- a/fontconfig/src/fcpat.c +++ b/fontconfig/src/fcpat.c @@ -57,6 +57,9 @@ FcValueDestroy (FcValue v) case FcTypeLangSet: FcLangSetDestroy ((FcLangSet *) v.u.l); break; + case FcTypeRange: + FcRangeDestroy ((FcRange *) v.u.r); + break; default: break; } @@ -81,6 +84,10 @@ FcValueCanonicalize (const FcValue *v) new.u.l = FcValueLangSet(v); new.type = FcTypeLangSet; break; + case FcTypeRange: + new.u.r = FcValueRange(v); + new.type = FcTypeRange; + break; default: new = *v; break; @@ -112,6 +119,11 @@ FcValueSave (FcValue v) if (!v.u.l) v.type = FcTypeVoid; break; + case FcTypeRange: + v.u.r = FcRangeCopy (v.u.r); + if (!v.u.r) + v.type = FcTypeVoid; + break; default: break; } @@ -145,6 +157,9 @@ FcValueListDestroy (FcValueListPtr l) FcLangSetDestroy ((FcLangSet *) (l->value.u.l)); break; + case FcTypeRange: + FcRangeDestroy ((FcRange *) (l->value.u.r)); + break; default: break; } @@ -267,6 +282,8 @@ FcValueEqual (FcValue va, FcValue vb) return va.u.f == vb.u.f; case FcTypeLangSet: return FcLangSetEqual (va.u.l, vb.u.l); + case FcTypeRange: + return FcRangeIsInRange (va.u.r, vb.u.r); } return FcFalse; } @@ -320,6 +337,8 @@ FcValueHash (const FcValue *v) FcStringHash ((const FcChar8 *) ((FT_Face) v->u.f)->style_name); case FcTypeLangSet: return FcLangSetHash (FcValueLangSet(v)); + case FcTypeRange: + return FcRangeHash (v->u.r); } return 0; } @@ -841,6 +860,22 @@ FcPatternAddLangSet (FcPattern *p, const char *object, const FcLangSet *ls) return FcPatternAdd (p, object, v, FcTrue); } +FcBool +FcPatternObjectAddRange (FcPattern *p, FcObject object, const FcRange *r) +{ + FcValue v; + + v.type = FcTypeRange; + v.u.r = (FcRange *)r; + return FcPatternObjectAdd (p, object, v, FcTrue); +} + +FcBool +FcPatternAddRange (FcPattern *p, const char *object, const FcRange *r) +{ + return FcPatternObjectAddRange (p, FcObjectFromName (object), r); +} + FcResult FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v) { @@ -1025,6 +1060,31 @@ FcPatternGetLangSet(const FcPattern *p, const char *object, int id, FcLangSet ** return FcResultMatch; } +FcResult +FcPatternObjectGetRange (const FcPattern *p, FcObject object, int id, FcRange **r) +{ + FcValue v; + FcResult res; + + res = FcPatternObjectGet (p, object, id, &v); + if (res != FcResultMatch) + return res; + switch ((int)v.type) { + case FcTypeRange: + *r = (FcRange *)v.u.r; + break; + default: + return FcResultTypeMismatch; + } + return FcResultMatch; +} + +FcResult +FcPatternGetRange (const FcPattern *p, const char *object, int id, FcRange **r) +{ + return FcPatternObjectGetRange (p, FcObjectFromName (object), id, r); +} + FcPattern * FcPatternDuplicate (const FcPattern *orig) { @@ -1230,6 +1290,10 @@ FcValueListSerializeAlloc (FcSerialize *serialize, const FcValueList *vl) if (!FcLangSetSerializeAlloc (serialize, vl->value.u.l)) return FcFalse; break; + case FcTypeRange: + if (!FcRangeSerializeAlloc (serialize, vl->value.u.r)) + return FcFalse; + break; default: break; } @@ -1245,6 +1309,7 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl) FcChar8 *s_serialized; FcCharSet *c_serialized; FcLangSet *l_serialized; + FcRange *r_serialized; FcValueList *head_serialized = NULL; FcValueList *prev_serialized = NULL; @@ -1303,6 +1368,14 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl) l_serialized, FcLangSet); break; + case FcTypeRange: + r_serialized = FcRangeSerialize (serialize, vl->value.u.r); + if (!r_serialized) + return NULL; + vl_serialized->value.u.r = FcPtrToEncodedOffset (&vl_serialized->value, + r_serialized, + FcRange); + break; default: break; } diff --git a/fontconfig/src/fcrange.c b/fontconfig/src/fcrange.c new file mode 100644 index 000000000..7d0c1c0b1 --- /dev/null +++ b/fontconfig/src/fcrange.c @@ -0,0 +1,207 @@ +/* + * fontconfig/src/fcrange.c + * + * Copyright © 2002 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. + */ + +#include "fcint.h" + + +FcRange * +FcRangeCreateDouble (double begin, double end) +{ + FcRange *ret = malloc (sizeof (FcRange)); + + if (ret) + { + ret->is_double = FcTrue; + ret->is_inclusive = FcDoubleCmpEQ (begin, end); + ret->u.d.begin = begin; + ret->u.d.end = end; + } + + return ret; +} + +FcRange * +FcRangeCreateInteger (FcChar32 begin, FcChar32 end) +{ + FcRange *ret = malloc (sizeof (FcRange)); + + if (ret) + { + ret->is_double = FcFalse; + ret->is_inclusive = (begin == end); + ret->u.i.begin = begin; + ret->u.i.end = end; + } + + return ret; +} + +void +FcRangeDestroy (FcRange *range) +{ + free (range); +} + +FcRange * +FcRangeCopy (const FcRange *range) +{ + FcRange *ret; + + if (range->is_double) + ret = FcRangeCreateDouble (range->u.d.begin, range->u.d.end); + else + ret = FcRangeCreateInteger (range->u.i.begin, range->u.i.end); + + return ret; +} + +FcRange +FcRangeCanonicalize (const FcRange *range) +{ + FcRange new; + + if (range->is_double) + new = *range; + else + { + new.is_double = FcTrue; + new.is_inclusive = range->is_inclusive; + new.u.d.begin = (double)range->u.i.begin; + new.u.d.end = (double)range->u.i.end; + } + return new; +} + +FcRange * +FcRangePromote (double v, FcValuePromotionBuffer *vbuf) +{ + typedef struct { + FcRange r; + } FcRangePromotionBuffer; + FcRangePromotionBuffer *buf = (FcRangePromotionBuffer *) vbuf; + + FC_ASSERT_STATIC (sizeof (FcRangePromotionBuffer) <= sizeof (FcValuePromotionBuffer)); + buf->r.is_double = FcTrue; + buf->r.is_inclusive = FcTrue; + buf->r.u.d.begin = v; + buf->r.u.d.end = v; + + return &buf->r; +} + +FcBool +FcRangeIsZero (const FcRange *r) +{ + FcRange c; + + if (!r) + return FcFalse; + c = FcRangeCanonicalize (r); + + return FcDoubleIsZero (c.u.d.begin) && FcDoubleIsZero (c.u.d.end); +} + +FcBool +FcRangeIsInRange (const FcRange *a, const FcRange *b) +{ + FcRange ca, cb; + FcBool f; + + if (!a || !b) + return FcFalse; + + ca = FcRangeCanonicalize (a); + cb = FcRangeCanonicalize (b); + if (ca.is_inclusive & cb.is_inclusive) + f = ca.u.d.end <= cb.u.d.end; + else + f = ca.u.d.end < cb.u.d.end; + + return FcDoubleCmpGE (ca.u.d.begin, cb.u.d.begin) && f; +} + +FcBool +FcRangeCompare (FcOp op, const FcRange *a, const FcRange *b) +{ + FcRange ca, cb; + + switch ((int) op) { + case FcOpEqual: + case FcOpContains: + case FcOpListing: + return FcRangeIsInRange (a, b); + case FcOpNotEqual: + case FcOpNotContains: + return !FcRangeIsInRange (a, b); + case FcOpLess: + ca = FcRangeCanonicalize (a); + cb = FcRangeCanonicalize (b); + return ca.u.d.begin < cb.u.d.begin; + case FcOpLessEqual: + ca = FcRangeCanonicalize (a); + cb = FcRangeCanonicalize (b); + return FcDoubleCmpLE (ca.u.d.begin, cb.u.d.begin); + case FcOpMore: + ca = FcRangeCanonicalize (a); + cb = FcRangeCanonicalize (b); + return ca.u.d.end > cb.u.d.end; + case FcOpMoreEqual: + ca = FcRangeCanonicalize (a); + cb = FcRangeCanonicalize (b); + return FcDoubleCmpGE (ca.u.d.end, cb.u.d.end); + default: + break; + } + return FcFalse; +} + +FcChar32 +FcRangeHash (const FcRange *r) +{ + FcRange c = FcRangeCanonicalize (r); + int b = (int) (c.u.d.begin * 100); + int e = (int) (c.u.d.end * 100); + + return b ^ (b << 1) ^ (e << 9); +} + +FcBool +FcRangeSerializeAlloc (FcSerialize *serialize, const FcRange *r) +{ + if (!FcSerializeAlloc (serialize, r, sizeof (FcRange))) + return FcFalse; + return FcTrue; +} + +FcRange * +FcRangeSerialize (FcSerialize *serialize, const FcRange *r) +{ + FcRange *r_serialize = FcSerializePtr (serialize, r); + + if (!r_serialize) + return NULL; + memcpy (r_serialize, r, sizeof (FcRange)); + + return r_serialize; +} diff --git a/fontconfig/src/fcxml.c b/fontconfig/src/fcxml.c index 91d166f38..c68b0cfce 100644 --- a/fontconfig/src/fcxml.c +++ b/fontconfig/src/fcxml.c @@ -169,6 +169,18 @@ FcExprCreateMatrix (FcConfig *config, const FcExprMatrix *matrix) } static FcExpr * +FcExprCreateRange (FcConfig *config, FcRange *range) +{ + FcExpr *e = FcConfigAllocExpr (config); + if (e) + { + e->op = FcOpRange; + e->u.rval = FcRangeCopy (range); + } + return e; +} + +static FcExpr * FcExprCreateBool (FcConfig *config, FcBool b) { FcExpr *e = FcConfigAllocExpr (config); @@ -258,6 +270,7 @@ FcExprDestroy (FcExpr *e) FcExprMatrixFree (e->u.mexpr); break; case FcOpRange: + FcRangeDestroy (e->u.rval); break; case FcOpCharSet: FcCharSetDestroy (e->u.cval); @@ -503,7 +516,7 @@ typedef struct _FcVStack { int integer; double _double; FcExprMatrix *matrix; - FcRange range; + FcRange *range; FcBool bool_; FcCharSet *charset; FcLangSet *langset; @@ -593,6 +606,8 @@ FcTypeName (FcType type) return "FT_Face"; case FcTypeLangSet: return "langset"; + case FcTypeRange: + return "range"; default: return "unknown"; } @@ -608,7 +623,9 @@ FcTypecheckValue (FcConfigParse *parse, FcType value, FcType type) if (value != type) { if ((value == FcTypeLangSet && type == FcTypeString) || - (value == FcTypeString && type == FcTypeLangSet)) + (value == FcTypeString && type == FcTypeLangSet) || + (value == FcTypeInteger && type == FcTypeRange) || + (value == FcTypeDouble && type == FcTypeRange)) return; if (type == FcTypeUnknown) return; @@ -651,6 +668,9 @@ FcTypecheckExpr (FcConfigParse *parse, FcExpr *expr, FcType type) case FcOpLangSet: FcTypecheckValue (parse, FcTypeLangSet, type); break; + case FcOpRange: + FcTypecheckValue (parse, FcTypeRange, type); + break; case FcOpNil: break; case FcOpField: @@ -865,11 +885,10 @@ FcVStackPushMatrix (FcConfigParse *parse, FcExprMatrix *matrix) static FcBool FcVStackPushRange (FcConfigParse *parse, FcRange *range) { - FcVStack *vstack = FcVStackCreateAndPush (parse); + FcVStack *vstack = FcVStackCreateAndPush (parse); if (!vstack) return FcFalse; - vstack->u.range.begin = range->begin; - vstack->u.range.end = range->end; + vstack->u.range = range; vstack->tag = FcVStackRange; return FcTrue; } @@ -1017,9 +1036,11 @@ FcVStackPopAndDestroy (FcConfigParse *parse) case FcVStackMatrix: FcExprMatrixFreeShallow (vstack->u.matrix); break; - case FcVStackRange: case FcVStackBool: break; + case FcVStackRange: + FcRangeDestroy (vstack->u.range); + break; case FcVStackCharSet: FcCharSetDestroy (vstack->u.charset); break; @@ -1232,7 +1253,9 @@ static void FcParseBlank (FcConfigParse *parse) { int n = FcVStackElements (parse); - FcChar32 i; + FcChar32 i, begin, end; + FcRange r; + while (n-- > 0) { FcVStack *v = FcVStackFetch (parse, n); @@ -1248,9 +1271,12 @@ FcParseBlank (FcConfigParse *parse) goto bail; break; case FcVStackRange: - if (v->u.range.begin <= v->u.range.end) + r = FcRangeCanonicalize (v->u.range); + begin = (FcChar32)r.u.d.begin; + end = (FcChar32)r.u.d.end; + if (begin <= end) { - for (i = v->u.range.begin; i <= v->u.range.end; i++) + for (i = begin; i <= end; i++) { if (!FcBlanksAdd (parse->config->blanks, i)) goto bail; @@ -1463,9 +1489,11 @@ static void FcParseRange (FcConfigParse *parse) { FcVStack *vstack; - FcRange r = {0, 0}; - FcChar32 n; + FcRange *r; + FcChar32 n[2] = {0, 0}; int count = 1; + double d[2] = {0.0L, 0.0L}; + FcBool dflag = FcFalse; while ((vstack = FcVStackPeek (parse))) { @@ -1476,31 +1504,52 @@ FcParseRange (FcConfigParse *parse) } switch ((int) vstack->tag) { case FcVStackInteger: - n = vstack->u.integer; + if (dflag) + d[count] = (double)vstack->u.integer; + else + n[count] = vstack->u.integer; + break; + case FcVStackDouble: + if (count == 0 && !dflag) + d[1] = (double)n[1]; + d[count] = vstack->u._double; + dflag = FcTrue; break; default: FcConfigMessage (parse, FcSevereError, "invalid element in range"); - n = 0; + if (dflag) + d[count] = 0.0L; + else + n[count] = 0; break; } - if (count == 1) - r.end = n; - else - r.begin = n; count--; FcVStackPopAndDestroy (parse); } - if (count < 0) + if (count >= 0) + { + FcConfigMessage (parse, FcSevereError, "invalid range"); + return; + } + if (dflag) { - if (r.begin > r.end) + if (d[0] > d[1]) { FcConfigMessage (parse, FcSevereError, "invalid range"); return; } - FcVStackPushRange (parse, &r); + r = FcRangeCreateDouble (d[0], d[1]); } else - FcConfigMessage (parse, FcSevereError, "invalid range"); + { + if (n[0] > n[1]) + { + FcConfigMessage (parse, FcSevereError, "invalid range"); + return; + } + r = FcRangeCreateInteger (n[0], n[1]); + } + FcVStackPushRange (parse, r); } static FcBool @@ -1536,7 +1585,8 @@ FcParseCharSet (FcConfigParse *parse) { FcVStack *vstack; FcCharSet *charset = FcCharSetCreate (); - FcChar32 i; + FcChar32 i, begin, end; + FcRange r; int n = 0; while ((vstack = FcVStackPeek (parse))) @@ -1551,9 +1601,13 @@ FcParseCharSet (FcConfigParse *parse) n++; break; case FcVStackRange: - if (vstack->u.range.begin <= vstack->u.range.end) + r = FcRangeCanonicalize (vstack->u.range); + begin = (FcChar32)r.u.d.begin; + end = (FcChar32)r.u.d.end; + + if (begin <= end) { - for (i = vstack->u.range.begin; i <= vstack->u.range.end; i++) + for (i = begin; i <= end; i++) { if (!FcCharSetAddChar (charset, i)) { @@ -1888,6 +1942,7 @@ FcPopExpr (FcConfigParse *parse) expr = FcExprCreateMatrix (parse->config, vstack->u.matrix); break; case FcVStackRange: + expr = FcExprCreateRange (parse->config, vstack->u.range); break; case FcVStackBool: expr = FcExprCreateBool (parse->config, vstack->u.bool_); @@ -2653,6 +2708,11 @@ FcPopValue (FcConfigParse *parse) if (value.u.l) value.type = FcTypeLangSet; break; + case FcVStackRange: + value.u.r = FcRangeCopy (vstack->u.range); + if (value.u.r) + value.type = FcTypeRange; + break; default: FcConfigMessage (parse, FcSevereWarning, "unknown pattern element %d", vstack->tag); diff --git a/mesalib/SConstruct b/mesalib/SConstruct index de735e94c..0e10818ba 100644 --- a/mesalib/SConstruct +++ b/mesalib/SConstruct @@ -59,13 +59,6 @@ else: Help(opts.GenerateHelpText(env)) -# fail early for a common error on windows -if env['gles']: - try: - import libxml2 - except ImportError: - raise SCons.Errors.UserError, "GLES requires libxml2-python to build" - ####################################################################### # Environment setup diff --git a/mesalib/configure.ac b/mesalib/configure.ac index c5042f93e..1e5e49667 100644 --- a/mesalib/configure.ac +++ b/mesalib/configure.ac @@ -54,7 +54,6 @@ AM_PROG_CC_C_O AM_PROG_AS AC_CHECK_PROGS([MAKE], [gmake make]) AC_CHECK_PROGS([PYTHON2], [python2 python]) -AX_PYTHON_MODULE([libxml2], [needed]) AC_PROG_SED AC_PROG_MKDIR_P @@ -1549,7 +1548,6 @@ if test "x$enable_gallium_llvm" = xyes; then LLVM_CXXFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cxxflags"` LLVM_INCLUDEDIR=`$LLVM_CONFIG --includedir` LLVM_LIBDIR=`$LLVM_CONFIG --libdir` - LLVM_LDFLAGS="-Wl,-rpath,$LLVM_LIBDIR $LLVM_LDFLAGS" AC_COMPUTE_INT([LLVM_VERSION_MAJOR], [LLVM_VERSION_MAJOR], [#include "${LLVM_INCLUDEDIR}/llvm/Config/llvm-config.h"]) diff --git a/mesalib/docs/README.WIN32 b/mesalib/docs/README.WIN32 index 0cd007c8a..c8759f65b 100644 --- a/mesalib/docs/README.WIN32 +++ b/mesalib/docs/README.WIN32 @@ -36,17 +36,15 @@ Recipe Building on windows requires several open-source packages. These are steps that work as of this writing. -1) install python 2.7 -2) install scons (latest) -3) install mingw, flex, and bison -4) install libxml2 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs - get libxml2-python-2.9.1.win-amd64-py2.7.exe -5) install pywin32 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs +- install python 2.7 +- install scons (latest) +- install mingw, flex, and bison +- install pywin32 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs get pywin32-218.4.win-amd64-py2.7.exe -6) install git -7) download mesa from git +- install git +- download mesa from git see http://www.mesa3d.org/repository.html -8) run scons +- run scons General ------- diff --git a/mesalib/docs/install.html b/mesalib/docs/install.html index 24492a786..5061eded0 100644 --- a/mesalib/docs/install.html +++ b/mesalib/docs/install.html @@ -44,10 +44,6 @@ On Windows with MinGW, install flex and bison with: </li> <li>python - Python is needed for building the Gallium components. Version 2.6.4 or later should work. -<br> -<br> -To build OpenGL ES 1.1 and 2.0 you'll also need -<a href="http://xmlsoft.org/sources/win32/python/libxml2-python-2.7.7.win32-py2.7.exe">libxml2-python</a>. </li> </ul> diff --git a/mesalib/m4/ax_python_module.m4 b/mesalib/m4/ax_python_module.m4 deleted file mode 100644 index 2e6670a0f..000000000 --- a/mesalib/m4/ax_python_module.m4 +++ /dev/null @@ -1,49 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_python_module.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PYTHON_MODULE(modname[, fatal]) -# -# DESCRIPTION -# -# Checks for Python module. -# -# If fatal is non-empty then absence of a module will trigger an error. -# -# LICENSE -# -# Copyright (c) 2008 Andrew Collier -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 6 - -AU_ALIAS([AC_PYTHON_MODULE], [AX_PYTHON_MODULE]) -AC_DEFUN([AX_PYTHON_MODULE],[ - if test -z $PYTHON2; - then - PYTHON2="python" - fi - PYTHON_NAME=`basename $PYTHON2` - AC_MSG_CHECKING($PYTHON_NAME module: $1) - $PYTHON2 -c "import $1" 2>/dev/null - if test $? -eq 0; - then - AC_MSG_RESULT(yes) - eval AS_TR_CPP(HAVE_PYMOD_$1)=yes - else - AC_MSG_RESULT(no) - eval AS_TR_CPP(HAVE_PYMOD_$1)=no - # - if test -n "$2" - then - AC_MSG_ERROR(failed to find required module $1) - exit 1 - fi - fi -]) diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy index faaf4388c..2d0e7be54 100644 --- a/mesalib/src/glsl/glsl_parser.yy +++ b/mesalib/src/glsl/glsl_parser.yy @@ -1901,7 +1901,6 @@ struct_specifier: $$ = new(ctx) ast_struct_specifier($2, $4); $$->set_location_range(@2, @5); state->symbols->add_type($2, glsl_type::void_type); - state->symbols->add_type_ast($2, new(ctx) ast_type_specifier($$)); } | STRUCT '{' struct_declaration_list '}' { diff --git a/mesalib/src/glsl/glsl_symbol_table.cpp b/mesalib/src/glsl/glsl_symbol_table.cpp index 11569f47e..a05236203 100644 --- a/mesalib/src/glsl/glsl_symbol_table.cpp +++ b/mesalib/src/glsl/glsl_symbol_table.cpp @@ -162,23 +162,6 @@ bool glsl_symbol_table::add_type(const char *name, const glsl_type *t) return _mesa_symbol_table_add_symbol(table, -1, name, entry) == 0; } -static char *make_ast_name(const char *name) -{ - char *ast_name = new char[strlen("#ast.") + strlen(name) + 1]; - strcpy(ast_name, "#ast."); - strcat(ast_name + strlen("#ast."), name); - return ast_name; -} - -bool glsl_symbol_table::add_type_ast(const char *name, const class ast_type_specifier *a) -{ - symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(a); - char *ast_name = make_ast_name(name); - bool ret = _mesa_symbol_table_add_symbol(table, -1, ast_name, entry) == 0; - delete [] ast_name; - return ret; -} - bool glsl_symbol_table::add_interface(const char *name, const glsl_type *i, enum ir_variable_mode mode) { @@ -230,14 +213,6 @@ const glsl_type *glsl_symbol_table::get_type(const char *name) return entry != NULL ? entry->t : NULL; } -const class ast_type_specifier *glsl_symbol_table::get_type_ast(const char *name) -{ - char *ast_name = make_ast_name(name); - symbol_table_entry *entry = get_entry(ast_name); - delete [] ast_name; - return entry != NULL ? entry->a : NULL; -} - const glsl_type *glsl_symbol_table::get_interface(const char *name, enum ir_variable_mode mode) { diff --git a/mesalib/src/glsl/glsl_symbol_table.h b/mesalib/src/glsl/glsl_symbol_table.h index 0e62448e2..f323fc305 100644 --- a/mesalib/src/glsl/glsl_symbol_table.h +++ b/mesalib/src/glsl/glsl_symbol_table.h @@ -98,7 +98,6 @@ public: /*@{*/ bool add_variable(ir_variable *v); bool add_type(const char *name, const glsl_type *t); - bool add_type_ast(const char *name, const class ast_type_specifier *t); bool add_function(ir_function *f); bool add_interface(const char *name, const glsl_type *i, enum ir_variable_mode mode); @@ -115,7 +114,6 @@ public: /*@{*/ ir_variable *get_variable(const char *name); const glsl_type *get_type(const char *name); - const class ast_type_specifier *get_type_ast(const char *name); ir_function *get_function(const char *name); const glsl_type *get_interface(const char *name, enum ir_variable_mode mode); diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h index ed3f086ce..8fa3b9ef6 100644 --- a/mesalib/src/glsl/ir.h +++ b/mesalib/src/glsl/ir.h @@ -1914,15 +1914,6 @@ public: * Get the variable that is ultimately referenced by an r-value */ virtual ir_variable *variable_referenced() const = 0; - - /** - * Get the constant that is ultimately referenced by an r-value, - * in a constant expression evaluation context. - * - * The offset is used when the reference is to a specific column of - * a matrix. - */ - virtual void constant_referenced(struct hash_table *variable_context, ir_constant *&store, int &offset) const = 0; }; @@ -1950,15 +1941,6 @@ public: return this->var; } - /** - * Get the constant that is ultimately referenced by an r-value, - * in a constant expression evaluation context. - * - * The offset is used when the reference is to a specific column of - * a matrix. - */ - virtual void constant_referenced(struct hash_table *variable_context, ir_constant *&store, int &offset) const; - virtual ir_variable *whole_variable_referenced() { /* ir_dereference_variable objects always dereference the entire @@ -2010,15 +1992,6 @@ public: return this->array->variable_referenced(); } - /** - * Get the constant that is ultimately referenced by an r-value, - * in a constant expression evaluation context. - * - * The offset is used when the reference is to a specific column of - * a matrix. - */ - virtual void constant_referenced(struct hash_table *variable_context, ir_constant *&store, int &offset) const; - virtual void accept(ir_visitor *v) { v->visit(this); @@ -2058,15 +2031,6 @@ public: return this->record->variable_referenced(); } - /** - * Get the constant that is ultimately referenced by an r-value, - * in a constant expression evaluation context. - * - * The offset is used when the reference is to a specific column of - * a matrix. - */ - virtual void constant_referenced(struct hash_table *variable_context, ir_constant *&store, int &offset) const; - virtual void accept(ir_visitor *v) { v->visit(this); diff --git a/mesalib/src/glsl/ir_clone.cpp b/mesalib/src/glsl/ir_clone.cpp index 311c992be..167b80c9f 100644 --- a/mesalib/src/glsl/ir_clone.cpp +++ b/mesalib/src/glsl/ir_clone.cpp @@ -265,10 +265,12 @@ ir_assignment::clone(void *mem_ctx, struct hash_table *ht) const if (this->condition) new_condition = this->condition->clone(mem_ctx, ht); - return new(mem_ctx) ir_assignment(this->lhs->clone(mem_ctx, ht), - this->rhs->clone(mem_ctx, ht), - new_condition, - this->write_mask); + ir_assignment *cloned = + new(mem_ctx) ir_assignment(this->lhs->clone(mem_ctx, ht), + this->rhs->clone(mem_ctx, ht), + new_condition); + cloned->write_mask = this->write_mask; + return cloned; } ir_function * diff --git a/mesalib/src/glsl/ir_constant_expression.cpp b/mesalib/src/glsl/ir_constant_expression.cpp index 7fa5a09d4..8afe8f776 100644 --- a/mesalib/src/glsl/ir_constant_expression.cpp +++ b/mesalib/src/glsl/ir_constant_expression.cpp @@ -386,8 +386,104 @@ unpack_half_1x16(uint16_t u) return _mesa_half_to_float(u); } +/** + * Get the constant that is ultimately referenced by an r-value, in a constant + * expression evaluation context. + * + * The offset is used when the reference is to a specific column of a matrix. + */ +static bool +constant_referenced(const ir_dereference *deref, + struct hash_table *variable_context, + ir_constant *&store, int &offset) +{ + store = NULL; + offset = 0; + + if (variable_context == NULL) + return false; + + switch (deref->ir_type) { + case ir_type_dereference_array: { + const ir_dereference_array *const da = + (const ir_dereference_array *) deref; + + ir_constant *const index_c = + da->array_index->constant_expression_value(variable_context); + + if (!index_c || !index_c->type->is_scalar() || !index_c->type->is_integer()) + break; + + const int index = index_c->type->base_type == GLSL_TYPE_INT ? + index_c->get_int_component(0) : + index_c->get_uint_component(0); + + ir_constant *substore; + int suboffset; + + const ir_dereference *const deref = da->array->as_dereference(); + if (!deref) + break; + + if (!constant_referenced(deref, variable_context, substore, suboffset)) + break; + + const glsl_type *const vt = da->array->type; + if (vt->is_array()) { + store = substore->get_array_element(index); + offset = 0; + } else if (vt->is_matrix()) { + store = substore; + offset = index * vt->vector_elements; + } else if (vt->is_vector()) { + store = substore; + offset = suboffset + index; + } + + break; + } + + case ir_type_dereference_record: { + const ir_dereference_record *const dr = + (const ir_dereference_record *) deref; + + const ir_dereference *const deref = dr->record->as_dereference(); + if (!deref) + break; + + ir_constant *substore; + int suboffset; + + if (!constant_referenced(deref, variable_context, substore, suboffset)) + break; + + /* Since we're dropping it on the floor... + */ + assert(suboffset == 0); + + store = substore->get_record_field(dr->field); + break; + } + + case ir_type_dereference_variable: { + const ir_dereference_variable *const dv = + (const ir_dereference_variable *) deref; + + store = (ir_constant *) hash_table_find(variable_context, dv->var); + break; + } + + default: + assert(!"Should not get here."); + break; + } + + return store != NULL; +} + + ir_constant * -ir_rvalue::constant_expression_value(struct hash_table *variable_context) +ir_rvalue::constant_expression_value(struct hash_table *) { assert(this->type->is_error()); return NULL; @@ -1534,7 +1630,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context) ir_constant * -ir_texture::constant_expression_value(struct hash_table *variable_context) +ir_texture::constant_expression_value(struct hash_table *) { /* texture lookups aren't constant expressions */ return NULL; @@ -1570,19 +1666,6 @@ ir_swizzle::constant_expression_value(struct hash_table *variable_context) } -void -ir_dereference_variable::constant_referenced(struct hash_table *variable_context, - ir_constant *&store, int &offset) const -{ - if (variable_context) { - store = (ir_constant *)hash_table_find(variable_context, var); - offset = 0; - } else { - store = NULL; - offset = 0; - } -} - ir_constant * ir_dereference_variable::constant_expression_value(struct hash_table *variable_context) { @@ -1610,60 +1693,6 @@ ir_dereference_variable::constant_expression_value(struct hash_table *variable_c } -void -ir_dereference_array::constant_referenced(struct hash_table *variable_context, - ir_constant *&store, int &offset) const -{ - ir_constant *index_c = array_index->constant_expression_value(variable_context); - - if (!index_c || !index_c->type->is_scalar() || !index_c->type->is_integer()) { - store = 0; - offset = 0; - return; - } - - int index = index_c->type->base_type == GLSL_TYPE_INT ? - index_c->get_int_component(0) : - index_c->get_uint_component(0); - - ir_constant *substore; - int suboffset; - const ir_dereference *deref = array->as_dereference(); - if (!deref) { - store = 0; - offset = 0; - return; - } - - deref->constant_referenced(variable_context, substore, suboffset); - - if (!substore) { - store = 0; - offset = 0; - return; - } - - const glsl_type *vt = array->type; - if (vt->is_array()) { - store = substore->get_array_element(index); - offset = 0; - return; - } - if (vt->is_matrix()) { - store = substore; - offset = index * vt->vector_elements; - return; - } - if (vt->is_vector()) { - store = substore; - offset = suboffset + index; - return; - } - - store = 0; - offset = 0; -} - ir_constant * ir_dereference_array::constant_expression_value(struct hash_table *variable_context) { @@ -1719,33 +1748,8 @@ ir_dereference_array::constant_expression_value(struct hash_table *variable_cont } -void -ir_dereference_record::constant_referenced(struct hash_table *variable_context, - ir_constant *&store, int &offset) const -{ - ir_constant *substore; - int suboffset; - const ir_dereference *deref = record->as_dereference(); - if (!deref) { - store = 0; - offset = 0; - return; - } - - deref->constant_referenced(variable_context, substore, suboffset); - - if (!substore) { - store = 0; - offset = 0; - return; - } - - store = substore->get_record_field(field); - offset = 0; -} - ir_constant * -ir_dereference_record::constant_expression_value(struct hash_table *variable_context) +ir_dereference_record::constant_expression_value(struct hash_table *) { ir_constant *v = this->record->constant_expression_value(); @@ -1754,7 +1758,7 @@ ir_dereference_record::constant_expression_value(struct hash_table *variable_con ir_constant * -ir_assignment::constant_expression_value(struct hash_table *variable_context) +ir_assignment::constant_expression_value(struct hash_table *) { /* FINISHME: Handle CEs involving assignment (return RHS) */ return NULL; @@ -1762,7 +1766,7 @@ ir_assignment::constant_expression_value(struct hash_table *variable_context) ir_constant * -ir_constant::constant_expression_value(struct hash_table *variable_context) +ir_constant::constant_expression_value(struct hash_table *) { return this; } @@ -1803,9 +1807,8 @@ bool ir_function_signature::constant_expression_evaluate_expression_list(const s ir_constant *store = NULL; int offset = 0; - asg->lhs->constant_referenced(variable_context, store, offset); - if (!store) + if (!constant_referenced(asg->lhs, variable_context, store, offset)) return false; ir_constant *value = asg->rhs->constant_expression_value(variable_context); @@ -1836,9 +1839,9 @@ bool ir_function_signature::constant_expression_evaluate_expression_list(const s ir_constant *store = NULL; int offset = 0; - call->return_deref->constant_referenced(variable_context, store, offset); - if (!store) + if (!constant_referenced(call->return_deref, variable_context, + store, offset)) return false; ir_constant *value = call->constant_expression_value(variable_context); diff --git a/mesalib/src/mapi/glapi/gen/glX_XML.py b/mesalib/src/mapi/glapi/gen/glX_XML.py index 03a35b740..12ff291fc 100644 --- a/mesalib/src/mapi/glapi/gen/glX_XML.py +++ b/mesalib/src/mapi/glapi/gen/glX_XML.py @@ -33,29 +33,27 @@ import sys, getopt, string class glx_item_factory(gl_XML.gl_item_factory): """Factory to create GLX protocol oriented objects derived from gl_item.""" - def create_item(self, name, element, context): - if name == "function": - return glx_function(element, context) - elif name == "enum": - return glx_enum(element, context) - elif name == "api": - return glx_api(self) - else: - return gl_XML.gl_item_factory.create_item(self, name, element, context) + def create_function(self, element, context): + return glx_function(element, context) + + def create_enum(self, element, context, category): + return glx_enum(element, context, category) + + def create_api(self): + return glx_api(self) class glx_enum(gl_XML.gl_enum): - def __init__(self, element, context): - gl_XML.gl_enum.__init__(self, element, context) + def __init__(self, element, context, category): + gl_XML.gl_enum.__init__(self, element, context, category) self.functions = {} - child = element.children - while child: - if child.type == "element" and child.name == "size": - n = child.nsProp( "name", None ) - c = child.nsProp( "count", None ) - m = child.nsProp( "mode", None ) + for child in element.getchildren(): + if child.tag == "size": + n = child.get( "name" ) + c = child.get( "count" ) + m = child.get( "mode", "set" ) if not c: c = self.default_count @@ -70,8 +68,6 @@ class glx_enum(gl_XML.gl_enum): if not self.functions.has_key(n): self.functions[ n ] = [c, mode] - child = child.next - return @@ -120,10 +116,10 @@ class glx_function(gl_XML.gl_function): # appears after the function that it aliases. if not self.vectorequiv: - self.vectorequiv = element.nsProp("vectorequiv", None) + self.vectorequiv = element.get("vectorequiv") - name = element.nsProp("name", None) + name = element.get("name") if name == self.name: for param in self.parameters: self.parameters_by_name[ param.name ] = param @@ -135,12 +131,11 @@ class glx_function(gl_XML.gl_function): self.counter_list.append(param.counter) - child = element.children - while child: - if child.type == "element" and child.name == "glx": - rop = child.nsProp( 'rop', None ) - sop = child.nsProp( 'sop', None ) - vop = child.nsProp( 'vendorpriv', None ) + for child in element.getchildren(): + if child.tag == "glx": + rop = child.get( 'rop' ) + sop = child.get( 'sop' ) + vop = child.get( 'vendorpriv' ) if rop: self.glx_rop = int(rop) @@ -152,12 +147,12 @@ class glx_function(gl_XML.gl_function): self.glx_vendorpriv = int(vop) self.glx_vendorpriv_names.append(name) - self.img_reset = child.nsProp( 'img_reset', None ) + self.img_reset = child.get( 'img_reset' ) # The 'handcode' attribute can be one of 'true', # 'false', 'client', or 'server'. - handcode = child.nsProp( 'handcode', None ) + handcode = child.get( 'handcode', 'false' ) if handcode == "false": self.server_handcode = 0 self.client_handcode = 0 @@ -179,8 +174,6 @@ class glx_function(gl_XML.gl_function): self.reply_always_array = gl_XML.is_attr_true( child, 'always_array' ) self.dimensions_in_reply = gl_XML.is_attr_true( child, 'dimensions_in_reply' ) - child = child.next - # Do some validation of the GLX protocol information. As # new tests are discovered, they should be added here. diff --git a/mesalib/src/mapi/glapi/gen/glX_doc.py b/mesalib/src/mapi/glapi/gen/glX_doc.py deleted file mode 100644 index 35d068894..000000000 --- a/mesalib/src/mapi/glapi/gen/glX_doc.py +++ /dev/null @@ -1,280 +0,0 @@ -#!/usr/bin/env python - -# (C) Copyright IBM Corporation 2004, 2005 -# 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 -# on 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 -# IBM 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. -# -# Authors: -# Ian Romanick <idr@us.ibm.com> - -import gl_XML, glX_XML, glX_proto_common, license -import sys, getopt - - -class glx_doc_item_factory(glX_proto_common.glx_proto_item_factory): - """Factory to create GLX protocol documentation oriented objects derived from glItem.""" - - def create_item(self, name, element, context): - if name == "parameter": - return glx_doc_parameter(element, context) - else: - return glX_proto_common.glx_proto_item_factory.create_item(self, name, element, context) - - -class glx_doc_parameter(gl_XML.gl_parameter): - def packet_type(self, type_dict): - """Get the type string for the packet header - - GLX protocol documentation uses type names like CARD32, - FLOAT64, LISTofCARD8, and ENUM. This function converts the - type of the parameter to one of these names.""" - - list_of = "" - if self.is_array(): - list_of = "LISTof" - - t_name = self.get_base_type_string() - if not type_dict.has_key( t_name ): - type_name = "CARD8" - else: - type_name = type_dict[ t_name ] - - return "%s%s" % (list_of, type_name) - - - def packet_size(self): - p = None - s = self.size() - if s == 0: - a_prod = "n" - b_prod = self.p_type.size - - if not self.count_parameter_list and self.counter: - a_prod = self.counter - elif self.count_parameter_list and not self.counter or self.is_output: - pass - elif self.count_parameter_list and self.counter: - b_prod = self.counter - else: - raise RuntimeError("Parameter '%s' to function '%s' has size 0." % (self.name, self.context.name)) - - ss = "%s*%s" % (a_prod, b_prod) - - return [ss, p] - else: - if s % 4 != 0: - p = "p" - - return [str(s), p] - -class PrintGlxProtoText(gl_XML.gl_print_base): - def __init__(self): - gl_XML.gl_print_base.__init__(self) - self.license = "" - - - def printHeader(self): - return - - - def body_size(self, f): - # At some point, refactor this function and - # glXFunction::command_payload_length. - - size = 0; - size_str = "" - pad_str = "" - plus = "" - for p in f.parameterIterateGlxSend(): - [s, pad] = p.packet_size() - try: - size += int(s) - except Exception,e: - size_str += "%s%s" % (plus, s) - plus = "+" - - if pad != None: - pad_str = pad - - return [size, size_str, pad_str] - - - def print_render_header(self, f): - [size, size_str, pad_str] = self.body_size(f) - size += 4; - - if size_str == "": - s = "%u" % ((size + 3) & ~3) - elif pad_str != "": - s = "%u+%s+%s" % (size, size_str, pad_str) - else: - s = "%u+%s" % (size, size_str) - - print ' 2 %-15s rendering command length' % (s) - print ' 2 %-4u rendering command opcode' % (f.glx_rop) - return - - - def print_single_header(self, f): - [size, size_str, pad_str] = self.body_size(f) - size = ((size + 3) / 4) + 2; - - if f.glx_vendorpriv != 0: - size += 1 - - print ' 1 CARD8 opcode (X assigned)' - print ' 1 %-4u GLX opcode (%s)' % (f.opcode_real_value(), f.opcode_real_name()) - - if size_str == "": - s = "%u" % (size) - elif pad_str != "": - s = "%u+((%s+%s)/4)" % (size, size_str, pad_str) - else: - s = "%u+((%s)/4)" % (size, size_str) - - print ' 2 %-15s request length' % (s) - - if f.glx_vendorpriv != 0: - print ' 4 %-4u vendor specific opcode' % (f.opcode_value()) - - print ' 4 GLX_CONTEXT_TAG context tag' - - return - - - def print_reply(self, f): - print ' =>' - print ' 1 1 reply' - print ' 1 unused' - print ' 2 CARD16 sequence number' - - if f.output == None: - print ' 4 0 reply length' - elif f.reply_always_array: - print ' 4 m reply length' - else: - print ' 4 m reply length, m = (n == 1 ? 0 : n)' - - - output = None - for x in f.parameterIterateOutputs(): - output = x - break - - - unused = 24 - if f.return_type != 'void': - print ' 4 %-15s return value' % (f.return_type) - unused -= 4 - elif output != None: - print ' 4 unused' - unused -= 4 - - if output != None: - print ' 4 CARD32 n' - unused -= 4 - - if output != None: - if not f.reply_always_array: - print '' - print ' if (n = 1) this follows:' - print '' - print ' 4 CARD32 %s' % (output.name) - print ' %-2u unused' % (unused - 4) - print '' - print ' otherwise this follows:' - print '' - - print ' %-2u unused' % (unused) - - [s, pad] = output.packet_size() - print ' %-8s %-15s %s' % (s, output.packet_type( self.type_map ), output.name) - if pad != None: - try: - bytes = int(s) - bytes = 4 - (bytes & 3) - print ' %-8u %-15s unused' % (bytes, "") - except Exception,e: - print ' %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s) - else: - print ' %-2u unused' % (unused) - - - def print_body(self, f): - for p in f.parameterIterateGlxSend(): - [s, pad] = p.packet_size() - print ' %-8s %-15s %s' % (s, p.packet_type( self.type_map ), p.name) - if pad != None: - try: - bytes = int(s) - bytes = 4 - (bytes & 3) - print ' %-8u %-15s unused' % (bytes, "") - except Exception,e: - print ' %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s) - - def printBody(self, api): - self.type_map = {} - for t in api.typeIterate(): - self.type_map[ "GL" + t.name ] = t.glx_name - - - # At some point this should be expanded to support pixel - # functions, but I'm not going to lose any sleep over it now. - - for f in api.functionIterateByOffset(): - if f.client_handcode or f.server_handcode or f.vectorequiv or len(f.get_images()): - continue - - - if f.glx_rop: - print ' %s' % (f.name) - self.print_render_header(f) - elif f.glx_sop or f.glx_vendorpriv: - print ' %s' % (f.name) - self.print_single_header(f) - else: - continue - - self.print_body(f) - - if f.needs_reply(): - self.print_reply(f) - - print '' - return - - -if __name__ == '__main__': - file_name = "gl_API.xml" - - try: - (args, trail) = getopt.getopt(sys.argv[1:], "f:") - except Exception,e: - show_usage() - - for (arg,val) in args: - if arg == "-f": - file_name = val - - api = gl_XML.parse_GL_API( file_name, glx_doc_item_factory() ) - - printer = PrintGlxProtoText() - printer.Print( api ) diff --git a/mesalib/src/mapi/glapi/gen/glX_proto_common.py b/mesalib/src/mapi/glapi/gen/glX_proto_common.py index 86d9189a9..ae2c2d581 100644 --- a/mesalib/src/mapi/glapi/gen/glX_proto_common.py +++ b/mesalib/src/mapi/glapi/gen/glX_proto_common.py @@ -32,18 +32,15 @@ import string class glx_proto_item_factory(glX_XML.glx_item_factory): """Factory to create GLX protocol oriented objects derived from gl_item.""" - def create_item(self, name, element, context): - if name == "type": - return glx_proto_type(element, context) - else: - return glX_XML.glx_item_factory.create_item(self, name, element, context) + def create_type(self, element, context, category): + return glx_proto_type(element, context, category) class glx_proto_type(gl_XML.gl_type): - def __init__(self, element, context): - gl_XML.gl_type.__init__(self, element, context) + def __init__(self, element, context, category): + gl_XML.gl_type.__init__(self, element, context, category) - self.glx_name = element.nsProp( "glx_name", None ) + self.glx_name = element.get( "glx_name" ) return diff --git a/mesalib/src/mapi/glapi/gen/gl_XML.py b/mesalib/src/mapi/glapi/gen/gl_XML.py index 3bbc79439..1a2bc2b91 100644 --- a/mesalib/src/mapi/glapi/gen/gl_XML.py +++ b/mesalib/src/mapi/glapi/gen/gl_XML.py @@ -26,20 +26,19 @@ # Ian Romanick <idr@us.ibm.com> from decimal import Decimal -import libxml2 +import xml.etree.ElementTree as ET import re, sys, string +import os.path import typeexpr def parse_GL_API( file_name, factory = None ): - doc = libxml2.readFile( file_name, None, libxml2.XML_PARSE_XINCLUDE + libxml2.XML_PARSE_NOBLANKS + libxml2.XML_PARSE_DTDVALID + libxml2.XML_PARSE_DTDATTR + libxml2.XML_PARSE_DTDLOAD + libxml2.XML_PARSE_NOENT ) - ret = doc.xincludeProcess() if not factory: factory = gl_item_factory() - api = factory.create_item( "api", None, None ) - api.process_element( doc ) + api = factory.create_api() + api.parse_file( file_name ) # After the XML has been processed, we need to go back and assign # dispatch offsets to the functions that request that their offsets @@ -51,12 +50,10 @@ def parse_GL_API( file_name, factory = None ): func.offset = api.next_offset; api.next_offset += 1 - doc.freeDoc() - return api -def is_attr_true( element, name ): +def is_attr_true( element, name, default = "false" ): """Read a name value from an element's attributes. The value read from the attribute list must be either 'true' or @@ -64,7 +61,7 @@ def is_attr_true( element, name ): value is 'true', non-zero will be returned. An exception will be raised for any other value.""" - value = element.nsProp( name, None ) + value = element.get( name, default ) if value == "true": return 1 elif value == "false": @@ -254,8 +251,8 @@ class gl_print_base(object): def real_function_name(element): - name = element.nsProp( "name", None ) - alias = element.nsProp( "alias", None ) + name = element.get( "name" ) + alias = element.get( "alias" ) if alias: return alias @@ -324,21 +321,22 @@ def create_parameter_string(parameters, include_names): class gl_item(object): - def __init__(self, element, context): + def __init__(self, element, context, category): self.context = context - self.name = element.nsProp( "name", None ) - self.category = real_category_name( element.parent.nsProp( "name", None ) ) + self.name = element.get( "name" ) + self.category = real_category_name( category ) + return class gl_type( gl_item ): - def __init__(self, element, context): - gl_item.__init__(self, element, context) - self.size = int( element.nsProp( "size", None ), 0 ) + def __init__(self, element, context, category): + gl_item.__init__(self, element, context, category) + self.size = int( element.get( "size" ), 0 ) te = typeexpr.type_expression( None ) tn = typeexpr.type_node() - tn.size = int( element.nsProp( "size", None ), 0 ) + tn.size = int( element.get( "size" ), 0 ) tn.integer = not is_attr_true( element, "float" ) tn.unsigned = is_attr_true( element, "unsigned" ) tn.pointer = is_attr_true( element, "pointer" ) @@ -354,11 +352,11 @@ class gl_type( gl_item ): class gl_enum( gl_item ): - def __init__(self, element, context): - gl_item.__init__(self, element, context) - self.value = int( element.nsProp( "value", None ), 0 ) + def __init__(self, element, context, category): + gl_item.__init__(self, element, context, category) + self.value = int( element.get( "value" ), 0 ) - temp = element.nsProp( "count", None ) + temp = element.get( "count" ) if not temp or temp == "?": self.default_count = -1 else: @@ -404,12 +402,12 @@ class gl_enum( gl_item ): class gl_parameter(object): def __init__(self, element, context): - self.name = element.nsProp( "name", None ) + self.name = element.get( "name" ) - ts = element.nsProp( "type", None ) + ts = element.get( "type" ) self.type_expr = typeexpr.type_expression( ts, context ) - temp = element.nsProp( "variable_param", None ) + temp = element.get( "variable_param" ) if temp: self.count_parameter_list = temp.split( ' ' ) else: @@ -420,7 +418,7 @@ class gl_parameter(object): # statement will throw an exception, and the except block will # take over. - c = element.nsProp( "count", None ) + c = element.get( "count" ) try: count = int(c) self.count = count @@ -430,7 +428,7 @@ class gl_parameter(object): self.count = 0 self.counter = c - self.count_scale = int(element.nsProp( "count_scale", None )) + self.count_scale = int(element.get( "count_scale", "1" )) elements = (count * self.count_scale) if elements == 1: @@ -450,19 +448,19 @@ class gl_parameter(object): # Pixel data has special parameters. - self.width = element.nsProp('img_width', None) - self.height = element.nsProp('img_height', None) - self.depth = element.nsProp('img_depth', None) - self.extent = element.nsProp('img_extent', None) + self.width = element.get('img_width') + self.height = element.get('img_height') + self.depth = element.get('img_depth') + self.extent = element.get('img_extent') - self.img_xoff = element.nsProp('img_xoff', None) - self.img_yoff = element.nsProp('img_yoff', None) - self.img_zoff = element.nsProp('img_zoff', None) - self.img_woff = element.nsProp('img_woff', None) + self.img_xoff = element.get('img_xoff') + self.img_yoff = element.get('img_yoff') + self.img_zoff = element.get('img_zoff') + self.img_woff = element.get('img_woff') - self.img_format = element.nsProp('img_format', None) - self.img_type = element.nsProp('img_type', None) - self.img_target = element.nsProp('img_target', None) + self.img_format = element.get('img_format') + self.img_type = element.get('img_type') + self.img_target = element.get('img_target') self.img_pad_dimensions = is_attr_true( element, 'img_pad_dimensions' ) self.img_null_flag = is_attr_true( element, 'img_null_flag' ) @@ -648,17 +646,17 @@ class gl_function( gl_item ): def process_element(self, element): - name = element.nsProp( "name", None ) - alias = element.nsProp( "alias", None ) + name = element.get( "name" ) + alias = element.get( "alias" ) - if is_attr_true(element, "static_dispatch"): + if is_attr_true(element, "static_dispatch", "true"): self.static_entry_points.append(name) self.entry_points.append( name ) self.entry_point_api_map[name] = {} for api in ('es1', 'es2'): - version_str = element.nsProp(api, None) + version_str = element.get(api, 'none') assert version_str is not None if version_str != 'none': version_decimal = Decimal(version_str) @@ -667,15 +665,15 @@ class gl_function( gl_item ): version_decimal < self.api_map[api]: self.api_map[api] = version_decimal - exec_flavor = element.nsProp('exec', None) + exec_flavor = element.get('exec') if exec_flavor: self.exec_flavor = exec_flavor - deprecated = element.nsProp('deprecated', None) + deprecated = element.get('deprecated', 'none') if deprecated != 'none': self.deprecated = Decimal(deprecated) - if not is_attr_true(element, 'desktop'): + if not is_attr_true(element, 'desktop', 'true'): self.desktop = False if alias: @@ -686,7 +684,7 @@ class gl_function( gl_item ): # Only try to set the offset when a non-alias entry-point # is being processed. - offset = element.nsProp( "offset", None ) + offset = element.get( "offset" ) if offset: try: o = int( offset ) @@ -712,16 +710,12 @@ class gl_function( gl_item ): parameters = [] return_type = "void" - child = element.children - while child: - if child.type == "element": - if child.name == "return": - return_type = child.nsProp( "type", None ) - elif child.name == "param": - param = self.context.factory.create_item( "parameter", child, self.context) - parameters.append( param ) - - child = child.next + for child in element.getchildren(): + if child.tag == "return": + return_type = child.get( "type", "void" ) + elif child.tag == "param": + param = self.context.factory.create_parameter(child, self.context) + parameters.append( param ) if self.initialized: @@ -746,7 +740,7 @@ class gl_function( gl_item ): if param.is_image(): self.images.append( param ) - if element.children: + if element.getchildren(): self.initialized = 1 self.entry_point_parameters[name] = parameters else: @@ -848,19 +842,20 @@ class gl_function( gl_item ): class gl_item_factory(object): """Factory to create objects derived from gl_item.""" - def create_item(self, item_name, element, context): - if item_name == "function": - return gl_function(element, context) - if item_name == "type": - return gl_type(element, context) - elif item_name == "enum": - return gl_enum(element, context) - elif item_name == "parameter": - return gl_parameter(element, context) - elif item_name == "api": - return gl_api(self) - else: - return None + def create_function(self, element, context): + return gl_function(element, context) + + def create_type(self, element, context, category): + return gl_type(element, context, category) + + def create_enum(self, element, context, category): + return gl_enum(element, context, category) + + def create_parameter(self, element, context): + return gl_parameter(element, context) + + def create_api(self): + return gl_api(self) class gl_api(object): @@ -903,66 +898,64 @@ class gl_api(object): self.functions_by_name = functions_by_name - def process_element(self, doc): - element = doc.children - while element.type != "element" or element.name != "OpenGLAPI": - element = element.next - if element: - self.process_OpenGLAPI(element) - return + def parse_file(self, file_name): + doc = ET.parse( file_name ) + self.process_element(file_name, doc) - def process_OpenGLAPI(self, element): - child = element.children - while child: - if child.type == "element": - if child.name == "category": - self.process_category( child ) - elif child.name == "OpenGLAPI": - self.process_OpenGLAPI( child ) + def process_element(self, file_name, doc): + element = doc.getroot() + if element.tag == "OpenGLAPI": + self.process_OpenGLAPI(file_name, element) + return + - child = child.next + def process_OpenGLAPI(self, file_name, element): + for child in element.getchildren(): + if child.tag == "category": + self.process_category( child ) + elif child.tag == "OpenGLAPI": + self.process_OpenGLAPI( file_name, child ) + elif child.tag == '{http://www.w3.org/2001/XInclude}include': + href = child.get('href') + href = os.path.join(os.path.dirname(file_name), href) + self.parse_file(href) return def process_category(self, cat): - cat_name = cat.nsProp( "name", None ) - cat_number = cat.nsProp( "number", None ) + cat_name = cat.get( "name" ) + cat_number = cat.get( "number" ) [cat_type, key] = classify_category(cat_name, cat_number) self.categories[cat_type][key] = [cat_name, cat_number] - child = cat.children - while child: - if child.type == "element": - if child.name == "function": - func_name = real_function_name( child ) - - temp_name = child.nsProp( "name", None ) - self.category_dict[ temp_name ] = [cat_name, cat_number] - - if self.functions_by_name.has_key( func_name ): - func = self.functions_by_name[ func_name ] - func.process_element( child ) - else: - func = self.factory.create_item( "function", child, self ) - self.functions_by_name[ func_name ] = func + for child in cat.getchildren(): + if child.tag == "function": + func_name = real_function_name( child ) - if func.offset >= self.next_offset: - self.next_offset = func.offset + 1 + temp_name = child.get( "name" ) + self.category_dict[ temp_name ] = [cat_name, cat_number] + if self.functions_by_name.has_key( func_name ): + func = self.functions_by_name[ func_name ] + func.process_element( child ) + else: + func = self.factory.create_function( child, self ) + self.functions_by_name[ func_name ] = func - elif child.name == "enum": - enum = self.factory.create_item( "enum", child, self ) - self.enums_by_name[ enum.name ] = enum - elif child.name == "type": - t = self.factory.create_item( "type", child, self ) - self.types_by_name[ "GL" + t.name ] = t + if func.offset >= self.next_offset: + self.next_offset = func.offset + 1 - child = child.next + elif child.tag == "enum": + enum = self.factory.create_enum( child, self, cat_name ) + self.enums_by_name[ enum.name ] = enum + elif child.tag == "type": + t = self.factory.create_type( child, self, cat_name ) + self.types_by_name[ "GL" + t.name ] = t return diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index 76cbb41a9..acf927b09 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -53,6 +53,7 @@ #include "main/mipmap.h" #include "main/multisample.h" #include "main/objectlabel.h" +#include "main/pipelineobj.h" #include "main/pixel.h" #include "main/pbo.h" #include "main/polygon.h" @@ -535,12 +536,20 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) _mesa_set_enable(ctx, GL_FRAGMENT_SHADER_ATI, GL_FALSE); } + if (ctx->Extensions.ARB_separate_shader_objects) { + /* Warning it must be done before _mesa_UseProgram call */ + _mesa_reference_pipeline_object(ctx, &save->_Shader, ctx->_Shader); + _mesa_reference_pipeline_object(ctx, &save->Pipeline, + ctx->Pipeline.Current); + _mesa_BindProgramPipeline(0); + } + for (i = 0; i < MESA_SHADER_STAGES; i++) { _mesa_reference_shader_program(ctx, &save->Shader[i], - ctx->Shader.CurrentProgram[i]); + ctx->_Shader->CurrentProgram[i]); } _mesa_reference_shader_program(ctx, &save->ActiveShader, - ctx->Shader.ActiveProgram); + ctx->_Shader->ActiveProgram); _mesa_UseProgram(0); } @@ -880,25 +889,37 @@ _mesa_meta_end(struct gl_context *ctx) save->ATIFragmentShaderEnabled); } + /* Warning it must be done before _mesa_use_shader_program call */ + if (ctx->Extensions.ARB_separate_shader_objects) { + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, save->_Shader); + _mesa_reference_pipeline_object(ctx, &ctx->Pipeline.Current, + save->Pipeline); + _mesa_reference_pipeline_object(ctx, &save->Pipeline, NULL); + } + if (ctx->Extensions.ARB_vertex_shader) { _mesa_use_shader_program(ctx, GL_VERTEX_SHADER, - save->Shader[MESA_SHADER_VERTEX]); + save->Shader[MESA_SHADER_VERTEX], + ctx->_Shader); } if (_mesa_has_geometry_shaders(ctx)) _mesa_use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, - save->Shader[MESA_SHADER_GEOMETRY]); + save->Shader[MESA_SHADER_GEOMETRY], + ctx->_Shader); if (ctx->Extensions.ARB_fragment_shader) _mesa_use_shader_program(ctx, GL_FRAGMENT_SHADER, - save->Shader[MESA_SHADER_FRAGMENT]); + save->Shader[MESA_SHADER_FRAGMENT], + ctx->_Shader); - _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, + _mesa_reference_shader_program(ctx, &ctx->_Shader->ActiveProgram, save->ActiveShader); for (i = 0; i < MESA_SHADER_STAGES; i++) _mesa_reference_shader_program(ctx, &save->Shader[i], NULL); _mesa_reference_shader_program(ctx, &save->ActiveShader, NULL); + _mesa_reference_pipeline_object(ctx, &save->_Shader, NULL); } if (state & MESA_META_STENCIL_TEST) { diff --git a/mesalib/src/mesa/drivers/common/meta.h b/mesalib/src/mesa/drivers/common/meta.h index e2ccb939e..4faae0b40 100644 --- a/mesalib/src/mesa/drivers/common/meta.h +++ b/mesalib/src/mesa/drivers/common/meta.h @@ -121,6 +121,8 @@ struct save_state GLboolean ATIFragmentShaderEnabled; struct gl_shader_program *Shader[MESA_SHADER_STAGES]; struct gl_shader_program *ActiveShader; + struct gl_pipeline_object *_Shader; + struct gl_pipeline_object *Pipeline; /** MESA_META_STENCIL_TEST */ struct gl_stencil_attrib Stencil; diff --git a/mesalib/src/mesa/main/api_validate.c b/mesalib/src/mesa/main/api_validate.c index f3fd1a475..8f0b1998d 100644 --- a/mesalib/src/mesa/main/api_validate.c +++ b/mesalib/src/mesa/main/api_validate.c @@ -125,11 +125,14 @@ check_valid_to_render(struct gl_context *ctx, const char *function) return GL_FALSE; break; - case API_OPENGL_COMPAT: case API_OPENGL_CORE: + if (ctx->Array.VAO == ctx->Array.DefaultVAO) + return GL_FALSE; + /* fallthrough */ + case API_OPENGL_COMPAT: { const struct gl_shader_program *vsProg = - ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]; + ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; GLboolean haveVertexShader = (vsProg && vsProg->LinkStatus); GLboolean haveVertexProgram = ctx->VertexProgram._Enabled; if (haveVertexShader || haveVertexProgram) { @@ -270,9 +273,9 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) * TRIANGLES_ADJACENCY_ARB or TRIANGLE_STRIP_ADJACENCY_ARB. * */ - if (ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]) { + if (ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]) { const GLenum geom_mode = - ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->Geom.InputType; + ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]->Geom.InputType; switch (mode) { case GL_POINTS: valid_enum = (geom_mode == GL_POINTS); @@ -331,8 +334,8 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) if (_mesa_is_xfb_active_and_unpaused(ctx)) { GLboolean pass = GL_TRUE; - if(ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]) { - switch (ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->Geom.OutputType) { + if(ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]) { + switch (ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]->Geom.OutputType) { case GL_POINTS: pass = ctx->TransformFeedback.Mode == GL_POINTS; break; diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index cd009c115..860ae8605 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -1841,6 +1841,7 @@ shader_linked_or_absent(struct gl_context *ctx, * Prior to drawing anything with glBegin, glDrawArrays, etc. this function * is called to see if it's valid to render. This involves checking that * the current shader is valid and the framebuffer is complete. + * It also check the current pipeline object is valid if any. * If an error is detected it'll be recorded here. * \return GL_TRUE if OK to render, GL_FALSE if not */ @@ -1855,7 +1856,7 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) _mesa_update_state(ctx); for (i = 0; i < MESA_SHADER_COMPUTE; i++) { - if (!shader_linked_or_absent(ctx, ctx->Shader.CurrentProgram[i], + if (!shader_linked_or_absent(ctx, ctx->_Shader->CurrentProgram[i], &from_glsl_shader[i], where)) return GL_FALSE; } @@ -1892,6 +1893,15 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) } } + /* A pipeline object is bound */ + if (ctx->_Shader->Name && !ctx->_Shader->Validated) { + /* Error message will be printed inside _mesa_validate_program_pipeline. + */ + if (!_mesa_validate_program_pipeline(ctx, ctx->_Shader, GL_TRUE)) { + return GL_FALSE; + } + } + if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "%s(incomplete framebuffer)", where); @@ -1903,8 +1913,8 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) } #ifdef DEBUG - if (ctx->Shader.Flags & GLSL_LOG) { - struct gl_shader_program **shProg = ctx->Shader.CurrentProgram; + if (ctx->_Shader->Flags & GLSL_LOG) { + struct gl_shader_program **shProg = ctx->_Shader->CurrentProgram; gl_shader_stage i; for (i = 0; i < MESA_SHADER_STAGES; i++) { diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c index 107919f0b..6c4f1b548 100644 --- a/mesalib/src/mesa/main/fbobject.c +++ b/mesalib/src/mesa/main/fbobject.c @@ -632,7 +632,8 @@ _mesa_is_legal_color_format(const struct gl_context *ctx, GLenum baseFormat) * Is the given base format a legal format for a color renderbuffer? */ static GLboolean -is_format_color_renderable(const struct gl_context *ctx, mesa_format format, GLenum internalFormat) +is_format_color_renderable(const struct gl_context *ctx, mesa_format format, + GLenum internalFormat) { const GLenum baseFormat = _mesa_get_format_base_format(format); @@ -664,7 +665,8 @@ is_format_color_renderable(const struct gl_context *ctx, mesa_format format, GLe break; } - if (format == MESA_FORMAT_B10G10R10A2_UNORM && internalFormat != GL_RGB10_A2) { + if (format == MESA_FORMAT_B10G10R10A2_UNORM && + internalFormat != GL_RGB10_A2) { return GL_FALSE; } @@ -948,7 +950,8 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx, attFormat = texImg->TexFormat; numImages++; - if (!is_format_color_renderable(ctx, attFormat, texImg->InternalFormat) && + if (!is_format_color_renderable(ctx, attFormat, + texImg->InternalFormat) && !is_legal_depth_format(ctx, f)) { fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; fbo_incomplete(ctx, "texture attachment incomplete", -1); @@ -1071,7 +1074,9 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx, return; } else if (is_layered != att->Layered) { fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS; - fbo_incomplete(ctx, "framebuffer attachment layer mode is inconsistent", i); + fbo_incomplete(ctx, + "framebuffer attachment layer mode is inconsistent", + i); return; } else if (att_layer_count > max_layer_count) { max_layer_count = att_layer_count; @@ -1149,7 +1154,8 @@ _mesa_IsRenderbuffer(GLuint renderbuffer) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); if (renderbuffer) { - struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, renderbuffer); + struct gl_renderbuffer *rb = + _mesa_lookup_renderbuffer(ctx, renderbuffer); if (rb != NULL && rb != &DummyRenderbuffer) return GL_TRUE; } @@ -1291,8 +1297,8 @@ _mesa_DeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers) } /* Section 4.4.2 (Attaching Images to Framebuffer Objects), - * subsection "Attaching Renderbuffer Images to a Framebuffer," of - * the OpenGL 3.1 spec says: + * subsection "Attaching Renderbuffer Images to a Framebuffer," + * of the OpenGL 3.1 spec says: * * "If a renderbuffer object is deleted while its image is * attached to one or more attachment points in the currently @@ -1387,15 +1393,15 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) case GL_ALPHA8: case GL_ALPHA12: case GL_ALPHA16: - return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_framebuffer_object - ? GL_ALPHA : 0; + return (ctx->API == API_OPENGL_COMPAT && + ctx->Extensions.ARB_framebuffer_object) ? GL_ALPHA : 0; case GL_LUMINANCE: case GL_LUMINANCE4: case GL_LUMINANCE8: case GL_LUMINANCE12: case GL_LUMINANCE16: - return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_framebuffer_object - ? GL_LUMINANCE : 0; + return (ctx->API == API_OPENGL_COMPAT && + ctx->Extensions.ARB_framebuffer_object) ? GL_LUMINANCE : 0; case GL_LUMINANCE_ALPHA: case GL_LUMINANCE4_ALPHA4: case GL_LUMINANCE6_ALPHA2: @@ -1403,15 +1409,15 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) case GL_LUMINANCE12_ALPHA4: case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: - return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_framebuffer_object - ? GL_LUMINANCE_ALPHA : 0; + return (ctx->API == API_OPENGL_COMPAT && + ctx->Extensions.ARB_framebuffer_object) ? GL_LUMINANCE_ALPHA : 0; case GL_INTENSITY: case GL_INTENSITY4: case GL_INTENSITY8: case GL_INTENSITY12: case GL_INTENSITY16: - return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_framebuffer_object - ? GL_INTENSITY : 0; + return (ctx->API == API_OPENGL_COMPAT && + ctx->Extensions.ARB_framebuffer_object) ? GL_INTENSITY : 0; case GL_RGB8: return GL_RGB; case GL_RGB: @@ -1458,11 +1464,13 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) return GL_DEPTH_STENCIL; case GL_DEPTH_COMPONENT32F: return ctx->Version >= 30 - || (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_depth_buffer_float) + || (ctx->API == API_OPENGL_COMPAT && + ctx->Extensions.ARB_depth_buffer_float) ? GL_DEPTH_COMPONENT : 0; case GL_DEPTH32F_STENCIL8: return ctx->Version >= 30 - || (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_depth_buffer_float) + || (ctx->API == API_OPENGL_COMPAT && + ctx->Extensions.ARB_depth_buffer_float) ? GL_DEPTH_STENCIL : 0; case GL_RED: case GL_R16: @@ -1694,7 +1702,7 @@ invalidate_rb(GLuint key, void *data, void *userData) /** - * Helper function used by _mesa_RenderbufferStorage() and + * Helper function used by _mesa_RenderbufferStorage() and * _mesa_RenderbufferStorageMultisample(). * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorage(). */ @@ -2142,6 +2150,7 @@ _mesa_BindFramebuffer(GLenum target, GLuint framebuffer) bind_framebuffer(target, framebuffer, _mesa_is_gles(ctx)); } + void GLAPIENTRY _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) { @@ -2152,6 +2161,7 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) bind_framebuffer(target, framebuffer, true); } + void GLAPIENTRY _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers) { @@ -2222,7 +2232,6 @@ _mesa_GenFramebuffers(GLsizei n, GLuint *framebuffers) } - GLenum GLAPIENTRY _mesa_CheckFramebufferStatus(GLenum target) { @@ -2297,7 +2306,7 @@ reuse_framebuffer_texture_attachment(struct gl_framebuffer *fb, * glFramebufferTexture(), false otherwise. */ static void -framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, +framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset, GLboolean layered) { @@ -2492,10 +2501,9 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, } - void GLAPIENTRY _mesa_FramebufferTexture1D(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, GLint level) + GLenum textarget, GLuint texture, GLint level) { GET_CURRENT_CONTEXT(ctx); @@ -2528,7 +2536,7 @@ _mesa_FramebufferTexture1D(GLenum target, GLenum attachment, void GLAPIENTRY _mesa_FramebufferTexture2D(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, GLint level) + GLenum textarget, GLuint texture, GLint level) { GET_CURRENT_CONTEXT(ctx); @@ -2579,8 +2587,8 @@ _mesa_FramebufferTexture2D(GLenum target, GLenum attachment, void GLAPIENTRY _mesa_FramebufferTexture3D(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, - GLint level, GLint zoffset) + GLenum textarget, GLuint texture, + GLint level, GLint zoffset) { GET_CURRENT_CONTEXT(ctx); @@ -2597,7 +2605,7 @@ _mesa_FramebufferTexture3D(GLenum target, GLenum attachment, void GLAPIENTRY _mesa_FramebufferTextureLayer(GLenum target, GLenum attachment, - GLuint texture, GLint level, GLint layer) + GLuint texture, GLint level, GLint layer) { GET_CURRENT_CONTEXT(ctx); @@ -2624,8 +2632,8 @@ _mesa_FramebufferTexture(GLenum target, GLenum attachment, void GLAPIENTRY _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment, - GLenum renderbufferTarget, - GLuint renderbuffer) + GLenum renderbufferTarget, + GLuint renderbuffer) { struct gl_renderbuffer_attachment *att; struct gl_framebuffer *fb; @@ -2634,7 +2642,8 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment, fb = get_framebuffer_target(ctx, target); if (!fb) { - _mesa_error(ctx, GL_INVALID_ENUM, "glFramebufferRenderbufferEXT(target)"); + _mesa_error(ctx, GL_INVALID_ENUM, + "glFramebufferRenderbufferEXT(target)"); return; } @@ -2691,7 +2700,6 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment, } } - FLUSH_VERTICES(ctx, _NEW_BUFFERS); assert(ctx->Driver.FramebufferRenderbuffer); @@ -2706,7 +2714,7 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment, void GLAPIENTRY _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, - GLenum pname, GLint *params) + GLenum pname, GLint *params) { const struct gl_renderbuffer_attachment *att; struct gl_framebuffer *buffer; @@ -2734,7 +2742,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, * OES_framebuffer_object spec refers to the EXT_framebuffer_object * spec. */ - if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_framebuffer_object) + if ((!_mesa_is_desktop_gl(ctx) || + !ctx->Extensions.ARB_framebuffer_object) && !_mesa_is_gles3(ctx)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetFramebufferAttachmentParameteriv(bound FBO = 0)"); @@ -2845,7 +2854,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, } return; case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: - if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_framebuffer_object) + if ((!_mesa_is_desktop_gl(ctx) || + !ctx->Extensions.ARB_framebuffer_object) && !_mesa_is_gles3(ctx)) { goto invalid_pname_enum; } @@ -2855,7 +2865,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, } else { if (ctx->Extensions.EXT_framebuffer_sRGB) { - *params = _mesa_get_format_color_encoding(att->Renderbuffer->Format); + *params = + _mesa_get_format_color_encoding(att->Renderbuffer->Format); } else { /* According to ARB_framebuffer_sRGB, we should return LINEAR @@ -2865,7 +2876,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, } return; case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: - if ((ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.ARB_framebuffer_object) + if ((ctx->API != API_OPENGL_COMPAT || + !ctx->Extensions.ARB_framebuffer_object) && ctx->API != API_OPENGL_CORE && !_mesa_is_gles3(ctx)) { goto invalid_pname_enum; @@ -2884,7 +2896,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, * attachment is DEPTH_STENCIL_ATTACHMENT the query will fail and * generate an INVALID_OPERATION error. */ - if (_mesa_is_gles3(ctx) && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { + if (_mesa_is_gles3(ctx) && + attachment == GL_DEPTH_STENCIL_ATTACHMENT) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetFramebufferAttachmentParameteriv(cannot query " "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE of " @@ -2916,7 +2929,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_framebuffer_object) + if ((!_mesa_is_desktop_gl(ctx) || + !ctx->Extensions.ARB_framebuffer_object) && !_mesa_is_gles3(ctx)) { goto invalid_pname_enum; } @@ -3079,6 +3093,7 @@ invalid_enum: return; } + void GLAPIENTRY _mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, @@ -3089,6 +3104,7 @@ _mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, "glInvalidateSubFramebuffer"); } + void GLAPIENTRY _mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments) @@ -3106,10 +3122,12 @@ _mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments, * <MAX_VIEWPORT_DIMS[1]> respectively." */ invalidate_framebuffer_storage(target, numAttachments, attachments, - 0, 0, MAX_VIEWPORT_WIDTH, MAX_VIEWPORT_HEIGHT, + 0, 0, + MAX_VIEWPORT_WIDTH, MAX_VIEWPORT_HEIGHT, "glInvalidateFramebuffer"); } + void GLAPIENTRY _mesa_DiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments) diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp index cad67aa85..1d2ad604b 100644 --- a/mesalib/src/mesa/main/ff_fragment_shader.cpp +++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp @@ -317,9 +317,9 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx ) { /* _NEW_PROGRAM */ const GLboolean vertexShader = - (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX] && - ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->LinkStatus && - ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]); + (ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] && + ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]->LinkStatus && + ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]); const GLboolean vertexProgram = ctx->VertexProgram._Enabled; GLbitfield fp_inputs = 0x0; @@ -383,7 +383,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx ) * validation (see additional comments in state.c). */ if (vertexShader) - vprog = ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]->Program; + vprog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]->Program; else vprog = &ctx->VertexProgram.Current->Base; diff --git a/mesalib/src/mesa/main/format_pack.c b/mesalib/src/mesa/main/format_pack.c index 9fbd41746..e3cbfff7e 100644 --- a/mesalib/src/mesa/main/format_pack.c +++ b/mesalib/src/mesa/main/format_pack.c @@ -96,22 +96,22 @@ linear_ubyte_to_srgb_ubyte(GLubyte cl) */ static void -pack_ubyte_RGBA8888(const GLubyte src[4], void *dst) +pack_ubyte_A8B8G8R8_UNORM(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); *d = PACK_COLOR_8888(src[RCOMP], src[GCOMP], src[BCOMP], src[ACOMP]); } static void -pack_float_RGBA8888(const GLfloat src[4], void *dst) +pack_float_A8B8G8R8_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_RGBA8888(v, dst); + pack_ubyte_A8B8G8R8_UNORM(v, dst); } static void -pack_row_ubyte_RGBA8888(GLuint n, const GLubyte src[][4], void *dst) +pack_row_ubyte_A8B8G8R8_UNORM(GLuint n, const GLubyte src[][4], void *dst) { GLuint *d = ((GLuint *) dst); GLuint i; @@ -122,14 +122,14 @@ pack_row_ubyte_RGBA8888(GLuint n, const GLubyte src[][4], void *dst) } static void -pack_row_float_RGBA8888(GLuint n, const GLfloat src[][4], void *dst) +pack_row_float_A8B8G8R8_UNORM(GLuint n, const GLfloat src[][4], void *dst) { GLuint *d = ((GLuint *) dst); GLuint i; for (i = 0; i < n; i++) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_RGBA8888(v, d + i); + pack_ubyte_A8B8G8R8_UNORM(v, d + i); } } @@ -140,22 +140,22 @@ pack_row_float_RGBA8888(GLuint n, const GLfloat src[][4], void *dst) */ static void -pack_ubyte_RGBA8888_REV(const GLubyte src[4], void *dst) +pack_ubyte_R8G8B8A8_UNORM(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); *d = PACK_COLOR_8888(src[ACOMP], src[BCOMP], src[GCOMP], src[RCOMP]); } static void -pack_float_RGBA8888_REV(const GLfloat src[4], void *dst) +pack_float_R8G8B8A8_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_RGBA8888_REV(v, dst); + pack_ubyte_R8G8B8A8_UNORM(v, dst); } static void -pack_row_ubyte_RGBA8888_REV(GLuint n, const GLubyte src[][4], void *dst) +pack_row_ubyte_R8G8B8A8_UNORM(GLuint n, const GLubyte src[][4], void *dst) { GLuint *d = ((GLuint *) dst); GLuint i; @@ -166,14 +166,14 @@ pack_row_ubyte_RGBA8888_REV(GLuint n, const GLubyte src[][4], void *dst) } static void -pack_row_float_RGBA8888_REV(GLuint n, const GLfloat src[][4], void *dst) +pack_row_float_R8G8B8A8_UNORM(GLuint n, const GLfloat src[][4], void *dst) { GLuint *d = ((GLuint *) dst); GLuint i; for (i = 0; i < n; i++) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_RGBA8888_REV(v, d + i); + pack_ubyte_R8G8B8A8_UNORM(v, d + i); } } @@ -183,22 +183,22 @@ pack_row_float_RGBA8888_REV(GLuint n, const GLfloat src[][4], void *dst) */ static void -pack_ubyte_ARGB8888(const GLubyte src[4], void *dst) +pack_ubyte_B8G8R8A8_UNORM(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); *d = PACK_COLOR_8888(src[ACOMP], src[RCOMP], src[GCOMP], src[BCOMP]); } static void -pack_float_ARGB8888(const GLfloat src[4], void *dst) +pack_float_B8G8R8A8_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_ARGB8888(v, dst); + pack_ubyte_B8G8R8A8_UNORM(v, dst); } static void -pack_row_ubyte_ARGB8888(GLuint n, const GLubyte src[][4], void *dst) +pack_row_ubyte_B8G8R8A8_UNORM(GLuint n, const GLubyte src[][4], void *dst) { GLuint *d = ((GLuint *) dst); GLuint i; @@ -209,14 +209,14 @@ pack_row_ubyte_ARGB8888(GLuint n, const GLubyte src[][4], void *dst) } static void -pack_row_float_ARGB8888(GLuint n, const GLfloat src[][4], void *dst) +pack_row_float_B8G8R8A8_UNORM(GLuint n, const GLfloat src[][4], void *dst) { GLuint *d = ((GLuint *) dst); GLuint i; for (i = 0; i < n; i++) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_ARGB8888(v, d + i); + pack_ubyte_B8G8R8A8_UNORM(v, d + i); } } @@ -226,22 +226,22 @@ pack_row_float_ARGB8888(GLuint n, const GLfloat src[][4], void *dst) */ static void -pack_ubyte_ARGB8888_REV(const GLubyte src[4], void *dst) +pack_ubyte_A8R8G8B8_UNORM(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); *d = PACK_COLOR_8888(src[BCOMP], src[GCOMP], src[RCOMP], src[ACOMP]); } static void -pack_float_ARGB8888_REV(const GLfloat src[4], void *dst) +pack_float_A8R8G8B8_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_ARGB8888_REV(v, dst); + pack_ubyte_A8R8G8B8_UNORM(v, dst); } static void -pack_row_ubyte_ARGB8888_REV(GLuint n, const GLubyte src[][4], void *dst) +pack_row_ubyte_A8R8G8B8_UNORM(GLuint n, const GLubyte src[][4], void *dst) { GLuint *d = ((GLuint *) dst); GLuint i; @@ -252,14 +252,14 @@ pack_row_ubyte_ARGB8888_REV(GLuint n, const GLubyte src[][4], void *dst) } static void -pack_row_float_ARGB8888_REV(GLuint n, const GLfloat src[][4], void *dst) +pack_row_float_A8R8G8B8_UNORM(GLuint n, const GLfloat src[][4], void *dst) { GLuint *d = ((GLuint *) dst); GLuint i; for (i = 0; i < n; i++) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_ARGB8888_REV(v, d + i); + pack_ubyte_A8R8G8B8_UNORM(v, d + i); } } @@ -269,22 +269,22 @@ pack_row_float_ARGB8888_REV(GLuint n, const GLfloat src[][4], void *dst) */ static void -pack_ubyte_XRGB8888(const GLubyte src[4], void *dst) +pack_ubyte_B8G8R8X8_UNORM(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); *d = PACK_COLOR_8888(0x0, src[RCOMP], src[GCOMP], src[BCOMP]); } static void -pack_float_XRGB8888(const GLfloat src[4], void *dst) +pack_float_B8G8R8X8_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_XRGB8888(v, dst); + pack_ubyte_B8G8R8X8_UNORM(v, dst); } static void -pack_row_ubyte_XRGB8888(GLuint n, const GLubyte src[][4], void *dst) +pack_row_ubyte_B8G8R8X8_UNORM(GLuint n, const GLubyte src[][4], void *dst) { GLuint *d = ((GLuint *) dst); GLuint i; @@ -294,14 +294,14 @@ pack_row_ubyte_XRGB8888(GLuint n, const GLubyte src[][4], void *dst) } static void -pack_row_float_XRGB8888(GLuint n, const GLfloat src[][4], void *dst) +pack_row_float_B8G8R8X8_UNORM(GLuint n, const GLfloat src[][4], void *dst) { GLuint *d = ((GLuint *) dst); GLuint i; for (i = 0; i < n; i++) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_XRGB8888(v, d + i); + pack_ubyte_B8G8R8X8_UNORM(v, d + i); } } @@ -311,22 +311,22 @@ pack_row_float_XRGB8888(GLuint n, const GLfloat src[][4], void *dst) */ static void -pack_ubyte_XRGB8888_REV(const GLubyte src[4], void *dst) +pack_ubyte_X8R8G8B8_UNORM(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); *d = PACK_COLOR_8888(src[BCOMP], src[GCOMP], src[RCOMP], 0); } static void -pack_float_XRGB8888_REV(const GLfloat src[4], void *dst) +pack_float_X8R8G8B8_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_XRGB8888_REV(v, dst); + pack_ubyte_X8R8G8B8_UNORM(v, dst); } static void -pack_row_ubyte_XRGB8888_REV(GLuint n, const GLubyte src[][4], void *dst) +pack_row_ubyte_X8R8G8B8_UNORM(GLuint n, const GLubyte src[][4], void *dst) { GLuint *d = ((GLuint *) dst); GLuint i; @@ -336,14 +336,14 @@ pack_row_ubyte_XRGB8888_REV(GLuint n, const GLubyte src[][4], void *dst) } static void -pack_row_float_XRGB8888_REV(GLuint n, const GLfloat src[][4], void *dst) +pack_row_float_X8R8G8B8_UNORM(GLuint n, const GLfloat src[][4], void *dst) { GLuint *d = ((GLuint *) dst); GLuint i; for (i = 0; i < n; i++) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_XRGB8888_REV(v, d + i); + pack_ubyte_X8R8G8B8_UNORM(v, d + i); } } @@ -353,7 +353,7 @@ pack_row_float_XRGB8888_REV(GLuint n, const GLfloat src[][4], void *dst) */ static void -pack_ubyte_RGB888(const GLubyte src[4], void *dst) +pack_ubyte_BGR_UNORM8(const GLubyte src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); d[2] = src[RCOMP]; @@ -362,7 +362,7 @@ pack_ubyte_RGB888(const GLubyte src[4], void *dst) } static void -pack_float_RGB888(const GLfloat src[4], void *dst) +pack_float_BGR_UNORM8(const GLfloat src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); UNCLAMPED_FLOAT_TO_UBYTE(d[2], src[RCOMP]); @@ -371,7 +371,7 @@ pack_float_RGB888(const GLfloat src[4], void *dst) } static void -pack_row_ubyte_RGB888(GLuint n, const GLubyte src[][4], void *dst) +pack_row_ubyte_BGR_UNORM8(GLuint n, const GLubyte src[][4], void *dst) { GLubyte *d = ((GLubyte *) dst); GLuint i; @@ -383,7 +383,7 @@ pack_row_ubyte_RGB888(GLuint n, const GLubyte src[][4], void *dst) } static void -pack_row_float_RGB888(GLuint n, const GLfloat src[][4], void *dst) +pack_row_float_BGR_UNORM8(GLuint n, const GLfloat src[][4], void *dst) { GLubyte *d = ((GLubyte *) dst); GLuint i; @@ -402,7 +402,7 @@ pack_row_float_RGB888(GLuint n, const GLfloat src[][4], void *dst) */ static void -pack_ubyte_BGR888(const GLubyte src[4], void *dst) +pack_ubyte_RGB_UNORM8(const GLubyte src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); d[2] = src[BCOMP]; @@ -411,7 +411,7 @@ pack_ubyte_BGR888(const GLubyte src[4], void *dst) } static void -pack_float_BGR888(const GLfloat src[4], void *dst) +pack_float_RGB_UNORM8(const GLfloat src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); UNCLAMPED_FLOAT_TO_UBYTE(d[2], src[BCOMP]); @@ -420,7 +420,7 @@ pack_float_BGR888(const GLfloat src[4], void *dst) } static void -pack_row_ubyte_BGR888(GLuint n, const GLubyte src[][4], void *dst) +pack_row_ubyte_RGB_UNORM8(GLuint n, const GLubyte src[][4], void *dst) { GLubyte *d = ((GLubyte *) dst); GLuint i; @@ -432,7 +432,7 @@ pack_row_ubyte_BGR888(GLuint n, const GLubyte src[][4], void *dst) } static void -pack_row_float_BGR888(GLuint n, const GLfloat src[][4], void *dst) +pack_row_float_RGB_UNORM8(GLuint n, const GLfloat src[][4], void *dst) { GLubyte *d = ((GLubyte *) dst); GLuint i; @@ -451,41 +451,41 @@ pack_row_float_BGR888(GLuint n, const GLfloat src[][4], void *dst) */ static void -pack_ubyte_RGB565(const GLubyte src[4], void *dst) +pack_ubyte_B5G6R5_UNORM(const GLubyte src[4], void *dst) { GLushort *d = ((GLushort *) dst); *d = PACK_COLOR_565(src[RCOMP], src[GCOMP], src[BCOMP]); } static void -pack_float_RGB565(const GLfloat src[4], void *dst) +pack_float_B5G6R5_UNORM(const GLfloat src[4], void *dst) { GLubyte v[3]; UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]); UNCLAMPED_FLOAT_TO_UBYTE(v[1], src[GCOMP]); UNCLAMPED_FLOAT_TO_UBYTE(v[2], src[BCOMP]); - pack_ubyte_RGB565(v, dst); + pack_ubyte_B5G6R5_UNORM(v, dst); } static void -pack_row_ubyte_RGB565(GLuint n, const GLubyte src[][4], void *dst) +pack_row_ubyte_B5G6R5_UNORM(GLuint n, const GLubyte src[][4], void *dst) { GLushort *d = ((GLushort *) dst); GLuint i; for (i = 0; i < n; i++) { - pack_ubyte_RGB565(src[i], d + i); + pack_ubyte_B5G6R5_UNORM(src[i], d + i); } } static void -pack_row_float_RGB565(GLuint n, const GLfloat src[][4], void *dst) +pack_row_float_B5G6R5_UNORM(GLuint n, const GLfloat src[][4], void *dst) { GLushort *d = ((GLushort *) dst); GLuint i; for (i = 0; i < n; i++) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_RGB565(v, d + i); + pack_ubyte_B5G6R5_UNORM(v, d + i); } } @@ -497,14 +497,14 @@ pack_row_float_RGB565(GLuint n, const GLfloat src[][4], void *dst) */ static void -pack_ubyte_RGB565_REV(const GLubyte src[4], void *dst) +pack_ubyte_R5G6B5_UNORM(const GLubyte src[4], void *dst) { GLushort *d = ((GLushort *) dst); *d = PACK_COLOR_565_REV(src[RCOMP], src[GCOMP], src[BCOMP]); } static void -pack_float_RGB565_REV(const GLfloat src[4], void *dst) +pack_float_R5G6B5_UNORM(const GLfloat src[4], void *dst) { GLushort *d = ((GLushort *) dst); GLubyte r, g, b; @@ -515,24 +515,24 @@ pack_float_RGB565_REV(const GLfloat src[4], void *dst) } static void -pack_row_ubyte_RGB565_REV(GLuint n, const GLubyte src[][4], void *dst) +pack_row_ubyte_R5G6B5_UNORM(GLuint n, const GLubyte src[][4], void *dst) { GLushort *d = ((GLushort *) dst); GLuint i; for (i = 0; i < n; i++) { - pack_ubyte_RGB565_REV(src[i], d + i); + pack_ubyte_R5G6B5_UNORM(src[i], d + i); } } static void -pack_row_float_RGB565_REV(GLuint n, const GLfloat src[][4], void *dst) +pack_row_float_R5G6B5_UNORM(GLuint n, const GLfloat src[][4], void *dst) { GLushort *d = ((GLushort *) dst); GLuint i; for (i = 0; i < n; i++) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src[i]); - pack_ubyte_RGB565_REV(v, d + i); + pack_ubyte_R5G6B5_UNORM(v, d + i); } } @@ -542,18 +542,18 @@ pack_row_float_RGB565_REV(GLuint n, const GLfloat src[][4], void *dst) */ static void -pack_ubyte_ARGB4444(const GLubyte src[4], void *dst) +pack_ubyte_B4G4R4A4_UNORM(const GLubyte src[4], void *dst) { GLushort *d = ((GLushort *) dst); *d = PACK_COLOR_4444(src[ACOMP], src[RCOMP], src[GCOMP], src[BCOMP]); } static void -pack_float_ARGB4444(const GLfloat src[4], void *dst) +pack_float_B4G4R4A4_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_ARGB4444(v, dst); + pack_ubyte_B4G4R4A4_UNORM(v, dst); } /* use fallback row packing functions */ @@ -564,18 +564,18 @@ pack_float_ARGB4444(const GLfloat src[4], void *dst) */ static void -pack_ubyte_ARGB4444_REV(const GLubyte src[4], void *dst) +pack_ubyte_A4R4G4B4_UNORM(const GLubyte src[4], void *dst) { GLushort *d = ((GLushort *) dst); *d = PACK_COLOR_4444(src[BCOMP], src[GCOMP], src[RCOMP], src[ACOMP]); } static void -pack_float_ARGB4444_REV(const GLfloat src[4], void *dst) +pack_float_A4R4G4B4_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_ARGB4444_REV(v, dst); + pack_ubyte_A4R4G4B4_UNORM(v, dst); } /* use fallback row packing functions */ @@ -586,18 +586,18 @@ pack_float_ARGB4444_REV(const GLfloat src[4], void *dst) */ static void -pack_ubyte_RGBA5551(const GLubyte src[4], void *dst) +pack_ubyte_A1B5G5R5_UNORM(const GLubyte src[4], void *dst) { GLushort *d = ((GLushort *) dst); *d = PACK_COLOR_5551(src[RCOMP], src[GCOMP], src[BCOMP], src[ACOMP]); } static void -pack_float_RGBA5551(const GLfloat src[4], void *dst) +pack_float_A1B5G5R5_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_RGBA5551(v, dst); + pack_ubyte_A1B5G5R5_UNORM(v, dst); } /* use fallback row packing functions */ @@ -608,18 +608,18 @@ pack_float_RGBA5551(const GLfloat src[4], void *dst) */ static void -pack_ubyte_ARGB1555(const GLubyte src[4], void *dst) +pack_ubyte_B5G5R5A1_UNORM(const GLubyte src[4], void *dst) { GLushort *d = ((GLushort *) dst); *d = PACK_COLOR_1555(src[ACOMP], src[RCOMP], src[GCOMP], src[BCOMP]); } static void -pack_float_ARGB1555(const GLfloat src[4], void *dst) +pack_float_B5G5R5A1_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_ARGB1555(v, dst); + pack_ubyte_B5G5R5A1_UNORM(v, dst); } @@ -629,7 +629,7 @@ pack_float_ARGB1555(const GLfloat src[4], void *dst) */ static void -pack_ubyte_ARGB1555_REV(const GLubyte src[4], void *dst) +pack_ubyte_A1R5G5B5_UNORM(const GLubyte src[4], void *dst) { GLushort *d = ((GLushort *) dst), tmp; tmp = PACK_COLOR_1555(src[ACOMP], src[RCOMP], src[GCOMP], src[BCOMP]); @@ -637,75 +637,75 @@ pack_ubyte_ARGB1555_REV(const GLubyte src[4], void *dst) } static void -pack_float_ARGB1555_REV(const GLfloat src[4], void *dst) +pack_float_A1R5G5B5_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; _mesa_unclamped_float_rgba_to_ubyte(v, src); - pack_ubyte_ARGB1555_REV(v, dst); + pack_ubyte_A1R5G5B5_UNORM(v, dst); } /* MESA_FORMAT_L4A4_UNORM */ static void -pack_ubyte_AL44(const GLubyte src[4], void *dst) +pack_ubyte_L4A4_UNORM(const GLubyte src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); *d = PACK_COLOR_44(src[ACOMP], src[RCOMP]); } static void -pack_float_AL44(const GLfloat src[4], void *dst) +pack_float_L4A4_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]); UNCLAMPED_FLOAT_TO_UBYTE(v[3], src[ACOMP]); - pack_ubyte_AL44(v, dst); + pack_ubyte_L4A4_UNORM(v, dst); } /* MESA_FORMAT_L8A8_UNORM */ static void -pack_ubyte_AL88(const GLubyte src[4], void *dst) +pack_ubyte_L8A8_UNORM(const GLubyte src[4], void *dst) { GLushort *d = ((GLushort *) dst); *d = PACK_COLOR_88(src[ACOMP], src[RCOMP]); } static void -pack_float_AL88(const GLfloat src[4], void *dst) +pack_float_L8A8_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]); UNCLAMPED_FLOAT_TO_UBYTE(v[3], src[ACOMP]); - pack_ubyte_AL88(v, dst); + pack_ubyte_L8A8_UNORM(v, dst); } /* MESA_FORMAT_A8L8_UNORM */ static void -pack_ubyte_AL88_REV(const GLubyte src[4], void *dst) +pack_ubyte_A8L8_UNORM(const GLubyte src[4], void *dst) { GLushort *d = ((GLushort *) dst); *d = PACK_COLOR_88(src[RCOMP], src[ACOMP]); } static void -pack_float_AL88_REV(const GLfloat src[4], void *dst) +pack_float_A8L8_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]); UNCLAMPED_FLOAT_TO_UBYTE(v[3], src[ACOMP]); - pack_ubyte_AL88_REV(v, dst); + pack_ubyte_A8L8_UNORM(v, dst); } /* MESA_FORMAT_L16A16_UNORM */ static void -pack_ubyte_AL1616(const GLubyte src[4], void *dst) +pack_ubyte_L16A16_UNORM(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort l = UBYTE_TO_USHORT(src[RCOMP]); @@ -714,7 +714,7 @@ pack_ubyte_AL1616(const GLubyte src[4], void *dst) } static void -pack_float_AL1616(const GLfloat src[4], void *dst) +pack_float_L16A16_UNORM(const GLfloat src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort l, a; @@ -727,7 +727,7 @@ pack_float_AL1616(const GLfloat src[4], void *dst) /* MESA_FORMAT_A16L16_UNORM */ static void -pack_ubyte_AL1616_REV(const GLubyte src[4], void *dst) +pack_ubyte_A16L16_UNORM(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort l = UBYTE_TO_USHORT(src[RCOMP]); @@ -736,7 +736,7 @@ pack_ubyte_AL1616_REV(const GLubyte src[4], void *dst) } static void -pack_float_AL1616_REV(const GLfloat src[4], void *dst) +pack_float_A16L16_UNORM(const GLfloat src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort l, a; @@ -749,34 +749,34 @@ pack_float_AL1616_REV(const GLfloat src[4], void *dst) /* MESA_FORMAT_B2G3R3_UNORM */ static void -pack_ubyte_RGB332(const GLubyte src[4], void *dst) +pack_ubyte_B2G3R3_UNORM(const GLubyte src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); *d = PACK_COLOR_332(src[RCOMP], src[GCOMP], src[BCOMP]); } static void -pack_float_RGB332(const GLfloat src[4], void *dst) +pack_float_B2G3R3_UNORM(const GLfloat src[4], void *dst) { GLubyte v[4]; UNCLAMPED_FLOAT_TO_UBYTE(v[0], src[RCOMP]); UNCLAMPED_FLOAT_TO_UBYTE(v[1], src[GCOMP]); UNCLAMPED_FLOAT_TO_UBYTE(v[2], src[BCOMP]); - pack_ubyte_RGB332(v, dst); + pack_ubyte_B2G3R3_UNORM(v, dst); } /* MESA_FORMAT_A_UNORM8 */ static void -pack_ubyte_A8(const GLubyte src[4], void *dst) +pack_ubyte_A_UNORM8(const GLubyte src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); *d = src[ACOMP]; } static void -pack_float_A8(const GLfloat src[4], void *dst) +pack_float_A_UNORM8(const GLfloat src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); UNCLAMPED_FLOAT_TO_UBYTE(d[0], src[ACOMP]); @@ -786,14 +786,14 @@ pack_float_A8(const GLfloat src[4], void *dst) /* MESA_FORMAT_A_UNORM16 */ static void -pack_ubyte_A16(const GLubyte src[4], void *dst) +pack_ubyte_A_UNORM16(const GLubyte src[4], void *dst) { GLushort *d = ((GLushort *) dst); *d = UBYTE_TO_USHORT(src[ACOMP]); } static void -pack_float_A16(const GLfloat src[4], void *dst) +pack_float_A_UNORM16(const GLfloat src[4], void *dst) { GLushort *d = ((GLushort *) dst); UNCLAMPED_FLOAT_TO_USHORT(d[0], src[ACOMP]); @@ -803,14 +803,14 @@ pack_float_A16(const GLfloat src[4], void *dst) /* MESA_FORMAT_L_UNORM8 */ static void -pack_ubyte_L8(const GLubyte src[4], void *dst) +pack_ubyte_L_UNORM8(const GLubyte src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); *d = src[RCOMP]; } static void -pack_float_L8(const GLfloat src[4], void *dst) +pack_float_L_UNORM8(const GLfloat src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); UNCLAMPED_FLOAT_TO_UBYTE(d[0], src[RCOMP]); @@ -820,14 +820,14 @@ pack_float_L8(const GLfloat src[4], void *dst) /* MESA_FORMAT_L_UNORM16 */ static void -pack_ubyte_L16(const GLubyte src[4], void *dst) +pack_ubyte_L_UNORM16(const GLubyte src[4], void *dst) { GLushort *d = ((GLushort *) dst); *d = UBYTE_TO_USHORT(src[RCOMP]); } static void -pack_float_L16(const GLfloat src[4], void *dst) +pack_float_L_UNORM16(const GLfloat src[4], void *dst) { GLushort *d = ((GLushort *) dst); UNCLAMPED_FLOAT_TO_USHORT(d[0], src[RCOMP]); @@ -867,14 +867,14 @@ pack_float_YCBCR_REV(const GLfloat src[4], void *dst) /* MESA_FORMAT_R_UNORM8 */ static void -pack_ubyte_R8(const GLubyte src[4], void *dst) +pack_ubyte_R_UNORM8(const GLubyte src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); *d = src[RCOMP]; } static void -pack_float_R8(const GLfloat src[4], void *dst) +pack_float_R_UNORM8(const GLfloat src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); GLubyte r; @@ -886,14 +886,14 @@ pack_float_R8(const GLfloat src[4], void *dst) /* MESA_FORMAT_R8G8_UNORM */ static void -pack_ubyte_GR88(const GLubyte src[4], void *dst) +pack_ubyte_R8G8_UNORM(const GLubyte src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); *d = PACK_COLOR_88(src[GCOMP], src[RCOMP]); } static void -pack_float_GR88(const GLfloat src[4], void *dst) +pack_float_R8G8_UNORM(const GLfloat src[4], void *dst) { GLushort *d = ((GLushort *) dst); GLubyte r, g; @@ -906,14 +906,14 @@ pack_float_GR88(const GLfloat src[4], void *dst) /* MESA_FORMAT_G8R8_UNORM */ static void -pack_ubyte_RG88(const GLubyte src[4], void *dst) +pack_ubyte_G8R8_UNORM(const GLubyte src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); *d = PACK_COLOR_88(src[RCOMP], src[GCOMP]); } static void -pack_float_RG88(const GLfloat src[4], void *dst) +pack_float_G8R8_UNORM(const GLfloat src[4], void *dst) { GLushort *d = ((GLushort *) dst); GLubyte r, g; @@ -926,14 +926,14 @@ pack_float_RG88(const GLfloat src[4], void *dst) /* MESA_FORMAT_R_UNORM16 */ static void -pack_ubyte_R16(const GLubyte src[4], void *dst) +pack_ubyte_R_UNORM16(const GLubyte src[4], void *dst) { GLushort *d = ((GLushort *) dst); *d = UBYTE_TO_USHORT(src[RCOMP]); } static void -pack_float_R16(const GLfloat src[4], void *dst) +pack_float_R_UNORM16(const GLfloat src[4], void *dst) { GLushort *d = ((GLushort *) dst); UNCLAMPED_FLOAT_TO_USHORT(d[0], src[RCOMP]); @@ -943,7 +943,7 @@ pack_float_R16(const GLfloat src[4], void *dst) /* MESA_FORMAT_R16G16_UNORM */ static void -pack_ubyte_GR1616(const GLubyte src[4], void *dst) +pack_ubyte_R16G16_UNORM(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r = UBYTE_TO_USHORT(src[RCOMP]); @@ -952,7 +952,7 @@ pack_ubyte_GR1616(const GLubyte src[4], void *dst) } static void -pack_float_GR1616(const GLfloat src[4], void *dst) +pack_float_R16G16_UNORM(const GLfloat src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r, g; @@ -965,7 +965,7 @@ pack_float_GR1616(const GLfloat src[4], void *dst) /* MESA_FORMAT_G16R16_UNORM */ static void -pack_ubyte_RG1616(const GLubyte src[4], void *dst) +pack_ubyte_G16R16_UNORM(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r = UBYTE_TO_USHORT(src[RCOMP]); @@ -975,7 +975,7 @@ pack_ubyte_RG1616(const GLubyte src[4], void *dst) static void -pack_float_RG1616(const GLfloat src[4], void *dst) +pack_float_G16R16_UNORM(const GLfloat src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r, g; @@ -988,7 +988,7 @@ pack_float_RG1616(const GLfloat src[4], void *dst) /* MESA_FORMAT_B10G10R10A2_UNORM */ static void -pack_ubyte_ARGB2101010(const GLubyte src[4], void *dst) +pack_ubyte_B10G10R10A2_UNORM(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r = UBYTE_TO_USHORT(src[RCOMP]); @@ -999,7 +999,7 @@ pack_ubyte_ARGB2101010(const GLubyte src[4], void *dst) } static void -pack_float_ARGB2101010(const GLfloat src[4], void *dst) +pack_float_B10G10R10A2_UNORM(const GLfloat src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r, g, b, a; @@ -1014,7 +1014,7 @@ pack_float_ARGB2101010(const GLfloat src[4], void *dst) /* MESA_FORMAT_R10G10B10A2_UINT */ static void -pack_ubyte_ABGR2101010_UINT(const GLubyte src[4], void *dst) +pack_ubyte_R10G10B10A2_UINT(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r = UBYTE_TO_USHORT(src[RCOMP]); @@ -1025,7 +1025,7 @@ pack_ubyte_ABGR2101010_UINT(const GLubyte src[4], void *dst) } static void -pack_float_ABGR2101010_UINT(const GLfloat src[4], void *dst) +pack_float_R10G10B10A2_UINT(const GLfloat src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r, g, b, a; @@ -1040,7 +1040,7 @@ pack_float_ABGR2101010_UINT(const GLfloat src[4], void *dst) /* MESA_FORMAT_BGR_SRGB8 */ static void -pack_ubyte_SRGB8(const GLubyte src[4], void *dst) +pack_ubyte_BGR_SRGB8(const GLubyte src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); d[2] = linear_ubyte_to_srgb_ubyte(src[RCOMP]); @@ -1049,7 +1049,7 @@ pack_ubyte_SRGB8(const GLubyte src[4], void *dst) } static void -pack_float_SRGB8(const GLfloat src[4], void *dst) +pack_float_BGR_SRGB8(const GLfloat src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); d[2] = linear_float_to_srgb_ubyte(src[RCOMP]); @@ -1061,7 +1061,7 @@ pack_float_SRGB8(const GLfloat src[4], void *dst) /* MESA_FORMAT_A8B8G8R8_SRGB */ static void -pack_ubyte_SRGBA8(const GLubyte src[4], void *dst) +pack_ubyte_A8B8G8R8_SRGB(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLubyte r = linear_ubyte_to_srgb_ubyte(src[RCOMP]); @@ -1071,7 +1071,7 @@ pack_ubyte_SRGBA8(const GLubyte src[4], void *dst) } static void -pack_float_SRGBA8(const GLfloat src[4], void *dst) +pack_float_A8B8G8R8_SRGB(const GLfloat src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLubyte r, g, b, a; @@ -1086,7 +1086,7 @@ pack_float_SRGBA8(const GLfloat src[4], void *dst) /* MESA_FORMAT_B8G8R8A8_SRGB */ static void -pack_ubyte_SARGB8(const GLubyte src[4], void *dst) +pack_ubyte_B8G8R8A8_SRGB(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLubyte r = linear_ubyte_to_srgb_ubyte(src[RCOMP]); @@ -1096,7 +1096,7 @@ pack_ubyte_SARGB8(const GLubyte src[4], void *dst) } static void -pack_float_SARGB8(const GLfloat src[4], void *dst) +pack_float_B8G8R8A8_SRGB(const GLfloat src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLubyte r, g, b, a; @@ -1111,7 +1111,7 @@ pack_float_SARGB8(const GLfloat src[4], void *dst) /* MESA_FORMAT_R8G8B8A8_SRGB */ static void -pack_ubyte_SABGR8(const GLubyte src[4], void *dst) +pack_ubyte_R8G8B8A8_SRGB(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLubyte r = linear_ubyte_to_srgb_ubyte(src[RCOMP]); @@ -1121,7 +1121,7 @@ pack_ubyte_SABGR8(const GLubyte src[4], void *dst) } static void -pack_float_SABGR8(const GLfloat src[4], void *dst) +pack_float_R8G8B8A8_SRGB(const GLfloat src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLubyte r, g, b, a; @@ -1136,14 +1136,14 @@ pack_float_SABGR8(const GLfloat src[4], void *dst) /* MESA_FORMAT_L_SRGB8 */ static void -pack_ubyte_SL8(const GLubyte src[4], void *dst) +pack_ubyte_L_SRGB8(const GLubyte src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); *d = linear_ubyte_to_srgb_ubyte(src[RCOMP]); } static void -pack_float_SL8(const GLfloat src[4], void *dst) +pack_float_L_SRGB8(const GLfloat src[4], void *dst) { GLubyte *d = ((GLubyte *) dst); GLubyte l = linear_float_to_srgb_ubyte(src[RCOMP]); @@ -1154,7 +1154,7 @@ pack_float_SL8(const GLfloat src[4], void *dst) /* MESA_FORMAT_L8A8_SRGB */ static void -pack_ubyte_SLA8(const GLubyte src[4], void *dst) +pack_ubyte_L8A8_SRGB(const GLubyte src[4], void *dst) { GLushort *d = ((GLushort *) dst); GLubyte l = linear_ubyte_to_srgb_ubyte(src[RCOMP]); @@ -1162,7 +1162,7 @@ pack_ubyte_SLA8(const GLubyte src[4], void *dst) } static void -pack_float_SLA8(const GLfloat src[4], void *dst) +pack_float_L8A8_SRGB(const GLfloat src[4], void *dst) { GLushort *d = ((GLushort *) dst); GLubyte a, l = linear_float_to_srgb_ubyte(src[RCOMP]); @@ -1262,14 +1262,14 @@ pack_float_RGB_FLOAT16(const GLfloat src[4], void *dst) /* MESA_FORMAT_A_FLOAT32 */ static void -pack_ubyte_ALPHA_FLOAT32(const GLubyte src[4], void *dst) +pack_ubyte_A_FLOAT32(const GLubyte src[4], void *dst) { GLfloat *d = ((GLfloat *) dst); d[0] = UBYTE_TO_FLOAT(src[ACOMP]); } static void -pack_float_ALPHA_FLOAT32(const GLfloat src[4], void *dst) +pack_float_A_FLOAT32(const GLfloat src[4], void *dst) { GLfloat *d = ((GLfloat *) dst); d[0] = src[ACOMP]; @@ -1279,48 +1279,48 @@ pack_float_ALPHA_FLOAT32(const GLfloat src[4], void *dst) /* MESA_FORMAT_A_FLOAT16 */ static void -pack_ubyte_ALPHA_FLOAT16(const GLubyte src[4], void *dst) +pack_ubyte_A_FLOAT16(const GLubyte src[4], void *dst) { GLhalfARB *d = ((GLhalfARB *) dst); d[0] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[ACOMP])); } static void -pack_float_ALPHA_FLOAT16(const GLfloat src[4], void *dst) +pack_float_A_FLOAT16(const GLfloat src[4], void *dst) { GLhalfARB *d = ((GLhalfARB *) dst); d[0] = _mesa_float_to_half(src[ACOMP]); } -/* MESA_FORMAT_L_FLOAT32 (and INTENSITY_FLOAT32, R_FLOAT32) */ +/* MESA_FORMAT_L_FLOAT32 (and I_FLOAT32, R_FLOAT32) */ static void -pack_ubyte_LUMINANCE_FLOAT32(const GLubyte src[4], void *dst) +pack_ubyte_L_FLOAT32(const GLubyte src[4], void *dst) { GLfloat *d = ((GLfloat *) dst); d[0] = UBYTE_TO_FLOAT(src[RCOMP]); } static void -pack_float_LUMINANCE_FLOAT32(const GLfloat src[4], void *dst) +pack_float_L_FLOAT32(const GLfloat src[4], void *dst) { GLfloat *d = ((GLfloat *) dst); d[0] = src[RCOMP]; } -/* MESA_FORMAT_L_FLOAT16 (and INTENSITY_FLOAT16, R_FLOAT32) */ +/* MESA_FORMAT_L_FLOAT16 (and I_FLOAT16, R_FLOAT32) */ static void -pack_ubyte_LUMINANCE_FLOAT16(const GLubyte src[4], void *dst) +pack_ubyte_L_FLOAT16(const GLubyte src[4], void *dst) { GLhalfARB *d = ((GLhalfARB *) dst); d[0] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[RCOMP])); } static void -pack_float_LUMINANCE_FLOAT16(const GLfloat src[4], void *dst) +pack_float_L_FLOAT16(const GLfloat src[4], void *dst) { GLhalfARB *d = ((GLhalfARB *) dst); d[0] = _mesa_float_to_half(src[RCOMP]); @@ -1330,7 +1330,7 @@ pack_float_LUMINANCE_FLOAT16(const GLfloat src[4], void *dst) /* MESA_FORMAT_LA_FLOAT32 */ static void -pack_ubyte_LUMINANCE_ALPHA_FLOAT32(const GLubyte src[4], void *dst) +pack_ubyte_LA_FLOAT32(const GLubyte src[4], void *dst) { GLfloat *d = ((GLfloat *) dst); d[0] = UBYTE_TO_FLOAT(src[RCOMP]); @@ -1338,7 +1338,7 @@ pack_ubyte_LUMINANCE_ALPHA_FLOAT32(const GLubyte src[4], void *dst) } static void -pack_float_LUMINANCE_ALPHA_FLOAT32(const GLfloat src[4], void *dst) +pack_float_LA_FLOAT32(const GLfloat src[4], void *dst) { GLfloat *d = ((GLfloat *) dst); d[0] = src[RCOMP]; @@ -1349,7 +1349,7 @@ pack_float_LUMINANCE_ALPHA_FLOAT32(const GLfloat src[4], void *dst) /* MESA_FORMAT_LA_FLOAT16 */ static void -pack_ubyte_LUMINANCE_ALPHA_FLOAT16(const GLubyte src[4], void *dst) +pack_ubyte_LA_FLOAT16(const GLubyte src[4], void *dst) { GLhalfARB *d = ((GLhalfARB *) dst); d[0] = _mesa_float_to_half(UBYTE_TO_FLOAT(src[RCOMP])); @@ -1357,7 +1357,7 @@ pack_ubyte_LUMINANCE_ALPHA_FLOAT16(const GLubyte src[4], void *dst) } static void -pack_float_LUMINANCE_ALPHA_FLOAT16(const GLfloat src[4], void *dst) +pack_float_LA_FLOAT16(const GLfloat src[4], void *dst) { GLhalfARB *d = ((GLhalfARB *) dst); d[0] = _mesa_float_to_half(src[RCOMP]); @@ -1453,7 +1453,7 @@ pack_float_RGBA_16(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_R8(const GLfloat src[4], void *dst) +pack_float_R_SNORM8(const GLfloat src[4], void *dst) { GLbyte *d = (GLbyte *) dst; *d = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1465,7 +1465,7 @@ pack_float_SIGNED_R8(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_RG88_REV(const GLfloat src[4], void *dst) +pack_float_R8G8_SNORM(const GLfloat src[4], void *dst) { GLushort *d = (GLushort *) dst; GLbyte r = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1479,7 +1479,7 @@ pack_float_SIGNED_RG88_REV(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_RGBX8888(const GLfloat src[4], void *dst) +pack_float_X8B8G8R8_SNORM(const GLfloat src[4], void *dst) { GLuint *d = (GLuint *) dst; GLbyte r = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1495,7 +1495,7 @@ pack_float_SIGNED_RGBX8888(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_RGBA8888(const GLfloat src[4], void *dst) +pack_float_A8B8G8R8_SNORM(const GLfloat src[4], void *dst) { GLuint *d = (GLuint *) dst; GLbyte r = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1511,7 +1511,7 @@ pack_float_SIGNED_RGBA8888(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_RGBA8888_REV(const GLfloat src[4], void *dst) +pack_float_R8G8B8A8_SNORM(const GLfloat src[4], void *dst) { GLuint *d = (GLuint *) dst; GLbyte r = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1527,7 +1527,7 @@ pack_float_SIGNED_RGBA8888_REV(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_R16(const GLfloat src[4], void *dst) +pack_float_R_SNORM16(const GLfloat src[4], void *dst) { GLshort *d = (GLshort *) dst; *d = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1539,7 +1539,7 @@ pack_float_SIGNED_R16(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_GR1616(const GLfloat src[4], void *dst) +pack_float_R16G16_SNORM(const GLfloat src[4], void *dst) { GLuint *d = (GLuint *) dst; GLshort r = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1553,7 +1553,7 @@ pack_float_SIGNED_GR1616(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_RGB_16(const GLfloat src[4], void *dst) +pack_float_RGB_SNORM16(const GLfloat src[4], void *dst) { GLshort *d = (GLshort *) dst; d[0] = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1567,7 +1567,7 @@ pack_float_SIGNED_RGB_16(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_RGBA_16(const GLfloat src[4], void *dst) +pack_float_RGBA_SNORM16(const GLfloat src[4], void *dst) { GLshort *d = (GLshort *) dst; d[0] = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1582,7 +1582,7 @@ pack_float_SIGNED_RGBA_16(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_A8(const GLfloat src[4], void *dst) +pack_float_A_SNORM8(const GLfloat src[4], void *dst) { GLbyte *d = (GLbyte *) dst; *d = FLOAT_TO_BYTE(CLAMP(src[ACOMP], -1.0f, 1.0f)); @@ -1594,7 +1594,7 @@ pack_float_SIGNED_A8(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_L8(const GLfloat src[4], void *dst) +pack_float_L_SNORM8(const GLfloat src[4], void *dst) { GLbyte *d = (GLbyte *) dst; *d = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1606,7 +1606,7 @@ pack_float_SIGNED_L8(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_AL88(const GLfloat src[4], void *dst) +pack_float_L8A8_SNORM(const GLfloat src[4], void *dst) { GLushort *d = (GLushort *) dst; GLbyte l = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1620,7 +1620,7 @@ pack_float_SIGNED_AL88(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_A16(const GLfloat src[4], void *dst) +pack_float_A_SNORM16(const GLfloat src[4], void *dst) { GLshort *d = (GLshort *) dst; *d = FLOAT_TO_SHORT(CLAMP(src[ACOMP], -1.0f, 1.0f)); @@ -1632,7 +1632,7 @@ pack_float_SIGNED_A16(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_L16(const GLfloat src[4], void *dst) +pack_float_L_SNORM16(const GLfloat src[4], void *dst) { GLshort *d = (GLshort *) dst; *d = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1644,7 +1644,7 @@ pack_float_SIGNED_L16(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_AL1616(const GLfloat src[4], void *dst) +pack_float_LA_SNORM16(const GLfloat src[4], void *dst) { GLuint *d = (GLuint *) dst; GLshort l = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1658,14 +1658,14 @@ pack_float_SIGNED_AL1616(const GLfloat src[4], void *dst) */ static void -pack_float_RGB9_E5_FLOAT(const GLfloat src[4], void *dst) +pack_float_R9G9B9E5_FLOAT(const GLfloat src[4], void *dst) { GLuint *d = (GLuint *) dst; *d = float3_to_rgb9e5(src); } static void -pack_ubyte_RGB9_E5_FLOAT(const GLubyte src[4], void *dst) +pack_ubyte_R9G9B9E5_FLOAT(const GLubyte src[4], void *dst) { GLuint *d = (GLuint *) dst; GLfloat rgb[3]; @@ -1682,7 +1682,7 @@ pack_ubyte_RGB9_E5_FLOAT(const GLubyte src[4], void *dst) */ static void -pack_ubyte_R11_G11_B10_FLOAT(const GLubyte src[4], void *dst) +pack_ubyte_R11G11B10_FLOAT(const GLubyte src[4], void *dst) { GLuint *d = (GLuint *) dst; GLfloat rgb[3]; @@ -1693,7 +1693,7 @@ pack_ubyte_R11_G11_B10_FLOAT(const GLubyte src[4], void *dst) } static void -pack_float_R11_G11_B10_FLOAT(const GLfloat src[4], void *dst) +pack_float_R11G11B10_FLOAT(const GLfloat src[4], void *dst) { GLuint *d = (GLuint *) dst; *d = float3_to_r11g11b10f(src); @@ -1760,7 +1760,7 @@ pack_float_XBGR8888_SNORM(const GLfloat src[4], void *dst) */ static void -pack_float_XBGR8888_SRGB(const GLfloat src[4], void *dst) +pack_float_R8G8B8X8_SRGB(const GLfloat src[4], void *dst) { GLuint *d = (GLuint *) dst; GLubyte r = linear_float_to_srgb_ubyte(src[RCOMP]); @@ -1773,7 +1773,7 @@ pack_float_XBGR8888_SRGB(const GLfloat src[4], void *dst) /* MESA_FORMAT_B10G10R10X2_UNORM */ static void -pack_ubyte_XRGB2101010_UNORM(const GLubyte src[4], void *dst) +pack_ubyte_B10G10R10X2_UNORM(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r = UBYTE_TO_USHORT(src[RCOMP]); @@ -1783,7 +1783,7 @@ pack_ubyte_XRGB2101010_UNORM(const GLubyte src[4], void *dst) } static void -pack_float_XRGB2101010_UNORM(const GLfloat src[4], void *dst) +pack_float_B10G10R10X2_UNORM(const GLfloat src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r, g, b; @@ -1797,7 +1797,7 @@ pack_float_XRGB2101010_UNORM(const GLfloat src[4], void *dst) /* MESA_FORMAT_RGBX_UNORM16 */ static void -pack_ubyte_XBGR16161616_UNORM(const GLubyte src[4], void *dst) +pack_ubyte_RGBX_UNORM16(const GLubyte src[4], void *dst) { GLushort *d = ((GLushort *) dst); d[0] = UBYTE_TO_USHORT(src[RCOMP]); @@ -1807,7 +1807,7 @@ pack_ubyte_XBGR16161616_UNORM(const GLubyte src[4], void *dst) } static void -pack_float_XBGR16161616_UNORM(const GLfloat src[4], void *dst) +pack_float_RGBX_UNORM16(const GLfloat src[4], void *dst) { GLushort *d = ((GLushort *) dst); UNCLAMPED_FLOAT_TO_USHORT(d[0], src[RCOMP]); @@ -1820,7 +1820,7 @@ pack_float_XBGR16161616_UNORM(const GLfloat src[4], void *dst) /* MESA_FORMAT_RGBX_SNORM16 */ static void -pack_float_XBGR16161616_SNORM(const GLfloat src[4], void *dst) +pack_float_RGBX_SNORM16(const GLfloat src[4], void *dst) { GLushort *d = ((GLushort *) dst); UNCLAMPED_FLOAT_TO_SHORT(d[0], src[RCOMP]); @@ -1845,7 +1845,7 @@ pack_float_XBGR16161616_FLOAT(const GLfloat src[4], void *dst) /* MESA_FORMAT_RGBX_FLOAT32 */ static void -pack_float_XBGR32323232_FLOAT(const GLfloat src[4], void *dst) +pack_float_RGBX_FLOAT32(const GLfloat src[4], void *dst) { GLfloat *d = ((GLfloat *) dst); d[0] = src[RCOMP]; @@ -1857,7 +1857,7 @@ pack_float_XBGR32323232_FLOAT(const GLfloat src[4], void *dst) /* MESA_FORMAT_R10G10B10A2_UNORM */ static void -pack_ubyte_ABGR2101010(const GLubyte src[4], void *dst) +pack_ubyte_R10G10B10A2_UNORM(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r = UBYTE_TO_USHORT(src[RCOMP]); @@ -1868,7 +1868,7 @@ pack_ubyte_ABGR2101010(const GLubyte src[4], void *dst) } static void -pack_float_ABGR2101010(const GLfloat src[4], void *dst) +pack_float_R10G10B10A2_UNORM(const GLfloat src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r, g, b, a; @@ -1884,7 +1884,7 @@ pack_float_ABGR2101010(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_RG88(const GLfloat src[4], void *dst) +pack_float_G8R8_SNORM(const GLfloat src[4], void *dst) { GLushort *d = (GLushort *) dst; GLbyte r = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1897,7 +1897,7 @@ pack_float_SIGNED_RG88(const GLfloat src[4], void *dst) */ static void -pack_float_SIGNED_RG1616(const GLfloat src[4], void *dst) +pack_float_G16R16_SNORM(const GLfloat src[4], void *dst) { GLuint *d = (GLuint *) dst; GLshort r = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f)); @@ -1910,7 +1910,7 @@ pack_float_SIGNED_RG1616(const GLfloat src[4], void *dst) */ static void -pack_float_XRGB8888_SRGB(const GLfloat src[4], void *dst) +pack_float_B8G8R8X8_SRGB(const GLfloat src[4], void *dst) { GLuint *d = (GLuint *) dst; GLubyte r = linear_float_to_srgb_ubyte(src[RCOMP]); @@ -1933,45 +1933,45 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format) table[MESA_FORMAT_NONE] = NULL; - table[MESA_FORMAT_A8B8G8R8_UNORM] = pack_ubyte_RGBA8888; - table[MESA_FORMAT_R8G8B8A8_UNORM] = pack_ubyte_RGBA8888_REV; - table[MESA_FORMAT_B8G8R8A8_UNORM] = pack_ubyte_ARGB8888; - table[MESA_FORMAT_A8R8G8B8_UNORM] = pack_ubyte_ARGB8888_REV; - table[MESA_FORMAT_X8B8G8R8_UNORM] = pack_ubyte_RGBA8888; /* reused */ - table[MESA_FORMAT_R8G8B8X8_UNORM] = pack_ubyte_RGBA8888_REV; /* reused */ - table[MESA_FORMAT_B8G8R8X8_UNORM] = pack_ubyte_XRGB8888; - table[MESA_FORMAT_X8R8G8B8_UNORM] = pack_ubyte_XRGB8888_REV; - table[MESA_FORMAT_BGR_UNORM8] = pack_ubyte_RGB888; - table[MESA_FORMAT_RGB_UNORM8] = pack_ubyte_BGR888; - table[MESA_FORMAT_B5G6R5_UNORM] = pack_ubyte_RGB565; - table[MESA_FORMAT_R5G6B5_UNORM] = pack_ubyte_RGB565_REV; - table[MESA_FORMAT_B4G4R4A4_UNORM] = pack_ubyte_ARGB4444; - table[MESA_FORMAT_A4R4G4B4_UNORM] = pack_ubyte_ARGB4444_REV; - table[MESA_FORMAT_A1B5G5R5_UNORM] = pack_ubyte_RGBA5551; - table[MESA_FORMAT_B5G5R5A1_UNORM] = pack_ubyte_ARGB1555; - table[MESA_FORMAT_A1R5G5B5_UNORM] = pack_ubyte_ARGB1555_REV; - table[MESA_FORMAT_L4A4_UNORM] = pack_ubyte_AL44; - table[MESA_FORMAT_L8A8_UNORM] = pack_ubyte_AL88; - table[MESA_FORMAT_A8L8_UNORM] = pack_ubyte_AL88_REV; - table[MESA_FORMAT_L16A16_UNORM] = pack_ubyte_AL1616; - table[MESA_FORMAT_A16L16_UNORM] = pack_ubyte_AL1616_REV; - table[MESA_FORMAT_B2G3R3_UNORM] = pack_ubyte_RGB332; - table[MESA_FORMAT_A_UNORM8] = pack_ubyte_A8; - table[MESA_FORMAT_A_UNORM16] = pack_ubyte_A16; - table[MESA_FORMAT_L_UNORM8] = pack_ubyte_L8; - table[MESA_FORMAT_L_UNORM16] = pack_ubyte_L16; - table[MESA_FORMAT_I_UNORM8] = pack_ubyte_L8; /* reuse pack_ubyte_L8 */ - table[MESA_FORMAT_I_UNORM16] = pack_ubyte_L16; /* reuse pack_ubyte_L16 */ + table[MESA_FORMAT_A8B8G8R8_UNORM] = pack_ubyte_A8B8G8R8_UNORM; + table[MESA_FORMAT_R8G8B8A8_UNORM] = pack_ubyte_R8G8B8A8_UNORM; + table[MESA_FORMAT_B8G8R8A8_UNORM] = pack_ubyte_B8G8R8A8_UNORM; + table[MESA_FORMAT_A8R8G8B8_UNORM] = pack_ubyte_A8R8G8B8_UNORM; + table[MESA_FORMAT_X8B8G8R8_UNORM] = pack_ubyte_A8B8G8R8_UNORM; /* reused */ + table[MESA_FORMAT_R8G8B8X8_UNORM] = pack_ubyte_R8G8B8A8_UNORM; /* reused */ + table[MESA_FORMAT_B8G8R8X8_UNORM] = pack_ubyte_B8G8R8X8_UNORM; + table[MESA_FORMAT_X8R8G8B8_UNORM] = pack_ubyte_X8R8G8B8_UNORM; + table[MESA_FORMAT_BGR_UNORM8] = pack_ubyte_BGR_UNORM8; + table[MESA_FORMAT_RGB_UNORM8] = pack_ubyte_RGB_UNORM8; + table[MESA_FORMAT_B5G6R5_UNORM] = pack_ubyte_B5G6R5_UNORM; + table[MESA_FORMAT_R5G6B5_UNORM] = pack_ubyte_R5G6B5_UNORM; + table[MESA_FORMAT_B4G4R4A4_UNORM] = pack_ubyte_B4G4R4A4_UNORM; + table[MESA_FORMAT_A4R4G4B4_UNORM] = pack_ubyte_A4R4G4B4_UNORM; + table[MESA_FORMAT_A1B5G5R5_UNORM] = pack_ubyte_A1B5G5R5_UNORM; + table[MESA_FORMAT_B5G5R5A1_UNORM] = pack_ubyte_B5G5R5A1_UNORM; + table[MESA_FORMAT_A1R5G5B5_UNORM] = pack_ubyte_A1R5G5B5_UNORM; + table[MESA_FORMAT_L4A4_UNORM] = pack_ubyte_L4A4_UNORM; + table[MESA_FORMAT_L8A8_UNORM] = pack_ubyte_L8A8_UNORM; + table[MESA_FORMAT_A8L8_UNORM] = pack_ubyte_A8L8_UNORM; + table[MESA_FORMAT_L16A16_UNORM] = pack_ubyte_L16A16_UNORM; + table[MESA_FORMAT_A16L16_UNORM] = pack_ubyte_A16L16_UNORM; + table[MESA_FORMAT_B2G3R3_UNORM] = pack_ubyte_B2G3R3_UNORM; + table[MESA_FORMAT_A_UNORM8] = pack_ubyte_A_UNORM8; + table[MESA_FORMAT_A_UNORM16] = pack_ubyte_A_UNORM16; + table[MESA_FORMAT_L_UNORM8] = pack_ubyte_L_UNORM8; + table[MESA_FORMAT_L_UNORM16] = pack_ubyte_L_UNORM16; + table[MESA_FORMAT_I_UNORM8] = pack_ubyte_L_UNORM8; /* reuse pack_ubyte_L_UNORM8 */ + table[MESA_FORMAT_I_UNORM16] = pack_ubyte_L_UNORM16; /* reuse pack_ubyte_L_UNORM16 */ table[MESA_FORMAT_YCBCR] = pack_ubyte_YCBCR; table[MESA_FORMAT_YCBCR_REV] = pack_ubyte_YCBCR_REV; - table[MESA_FORMAT_R_UNORM8] = pack_ubyte_R8; - table[MESA_FORMAT_R8G8_UNORM] = pack_ubyte_GR88; - table[MESA_FORMAT_G8R8_UNORM] = pack_ubyte_RG88; - table[MESA_FORMAT_R_UNORM16] = pack_ubyte_R16; - table[MESA_FORMAT_R16G16_UNORM] = pack_ubyte_GR1616; - table[MESA_FORMAT_G16R16_UNORM] = pack_ubyte_RG1616; - table[MESA_FORMAT_B10G10R10A2_UNORM] = pack_ubyte_ARGB2101010; - table[MESA_FORMAT_R10G10B10A2_UINT] = pack_ubyte_ABGR2101010_UINT; + table[MESA_FORMAT_R_UNORM8] = pack_ubyte_R_UNORM8; + table[MESA_FORMAT_R8G8_UNORM] = pack_ubyte_R8G8_UNORM; + table[MESA_FORMAT_G8R8_UNORM] = pack_ubyte_G8R8_UNORM; + table[MESA_FORMAT_R_UNORM16] = pack_ubyte_R_UNORM16; + table[MESA_FORMAT_R16G16_UNORM] = pack_ubyte_R16G16_UNORM; + table[MESA_FORMAT_G16R16_UNORM] = pack_ubyte_G16R16_UNORM; + table[MESA_FORMAT_B10G10R10A2_UNORM] = pack_ubyte_B10G10R10A2_UNORM; + table[MESA_FORMAT_R10G10B10A2_UINT] = pack_ubyte_R10G10B10A2_UINT; /* should never convert RGBA to these formats */ table[MESA_FORMAT_S8_UINT_Z24_UNORM] = NULL; @@ -1983,12 +1983,12 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format) table[MESA_FORMAT_S_UINT8] = NULL; /* sRGB */ - table[MESA_FORMAT_BGR_SRGB8] = pack_ubyte_SRGB8; - table[MESA_FORMAT_A8B8G8R8_SRGB] = pack_ubyte_SRGBA8; - table[MESA_FORMAT_B8G8R8A8_SRGB] = pack_ubyte_SARGB8; - table[MESA_FORMAT_R8G8B8A8_SRGB] = pack_ubyte_SABGR8; - table[MESA_FORMAT_L_SRGB8] = pack_ubyte_SL8; - table[MESA_FORMAT_L8A8_SRGB] = pack_ubyte_SLA8; + table[MESA_FORMAT_BGR_SRGB8] = pack_ubyte_BGR_SRGB8; + table[MESA_FORMAT_A8B8G8R8_SRGB] = pack_ubyte_A8B8G8R8_SRGB; + table[MESA_FORMAT_B8G8R8A8_SRGB] = pack_ubyte_B8G8R8A8_SRGB; + table[MESA_FORMAT_R8G8B8A8_SRGB] = pack_ubyte_R8G8B8A8_SRGB; + table[MESA_FORMAT_L_SRGB8] = pack_ubyte_L_SRGB8; + table[MESA_FORMAT_L8A8_SRGB] = pack_ubyte_L8A8_SRGB; /* n/a */ table[MESA_FORMAT_SRGB_DXT1] = NULL; /* pack_ubyte_SRGB_DXT1; */ table[MESA_FORMAT_SRGBA_DXT1] = NULL; /* pack_ubyte_SRGBA_DXT1; */ @@ -2006,16 +2006,16 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format) table[MESA_FORMAT_RGBA_FLOAT16] = pack_ubyte_RGBA_FLOAT16; table[MESA_FORMAT_RGB_FLOAT32] = pack_ubyte_RGB_FLOAT32; table[MESA_FORMAT_RGB_FLOAT16] = pack_ubyte_RGB_FLOAT16; - table[MESA_FORMAT_A_FLOAT32] = pack_ubyte_ALPHA_FLOAT32; - table[MESA_FORMAT_A_FLOAT16] = pack_ubyte_ALPHA_FLOAT16; - table[MESA_FORMAT_L_FLOAT32] = pack_ubyte_LUMINANCE_FLOAT32; - table[MESA_FORMAT_L_FLOAT16] = pack_ubyte_LUMINANCE_FLOAT16; - table[MESA_FORMAT_LA_FLOAT32] = pack_ubyte_LUMINANCE_ALPHA_FLOAT32; - table[MESA_FORMAT_LA_FLOAT16] = pack_ubyte_LUMINANCE_ALPHA_FLOAT16; - table[MESA_FORMAT_I_FLOAT32] = pack_ubyte_LUMINANCE_FLOAT32; - table[MESA_FORMAT_I_FLOAT16] = pack_ubyte_LUMINANCE_FLOAT16; - table[MESA_FORMAT_R_FLOAT32] = pack_ubyte_LUMINANCE_FLOAT32; - table[MESA_FORMAT_R_FLOAT16] = pack_ubyte_LUMINANCE_FLOAT16; + table[MESA_FORMAT_A_FLOAT32] = pack_ubyte_A_FLOAT32; + table[MESA_FORMAT_A_FLOAT16] = pack_ubyte_A_FLOAT16; + table[MESA_FORMAT_L_FLOAT32] = pack_ubyte_L_FLOAT32; + table[MESA_FORMAT_L_FLOAT16] = pack_ubyte_L_FLOAT16; + table[MESA_FORMAT_LA_FLOAT32] = pack_ubyte_LA_FLOAT32; + table[MESA_FORMAT_LA_FLOAT16] = pack_ubyte_LA_FLOAT16; + table[MESA_FORMAT_I_FLOAT32] = pack_ubyte_L_FLOAT32; + table[MESA_FORMAT_I_FLOAT16] = pack_ubyte_L_FLOAT16; + table[MESA_FORMAT_R_FLOAT32] = pack_ubyte_L_FLOAT32; + table[MESA_FORMAT_R_FLOAT16] = pack_ubyte_L_FLOAT16; table[MESA_FORMAT_RG_FLOAT32] = pack_ubyte_RG_FLOAT32; table[MESA_FORMAT_RG_FLOAT16] = pack_ubyte_RG_FLOAT16; @@ -2053,8 +2053,8 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format) table[MESA_FORMAT_RGBA_UNORM16] = pack_ubyte_RGBA_16; - table[MESA_FORMAT_R9G9B9E5_FLOAT] = pack_ubyte_RGB9_E5_FLOAT; - table[MESA_FORMAT_R11G11B10_FLOAT] = pack_ubyte_R11_G11_B10_FLOAT; + table[MESA_FORMAT_R9G9B9E5_FLOAT] = pack_ubyte_R9G9B9E5_FLOAT; + table[MESA_FORMAT_R11G11B10_FLOAT] = pack_ubyte_R11G11B10_FLOAT; table[MESA_FORMAT_B4G4R4X4_UNORM] = pack_ubyte_XRGB4444_UNORM; table[MESA_FORMAT_B5G5R5X1_UNORM] = pack_ubyte_XRGB1555_UNORM; @@ -2062,8 +2062,8 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format) table[MESA_FORMAT_R8G8B8X8_SRGB] = NULL; table[MESA_FORMAT_RGBX_UINT8] = NULL; table[MESA_FORMAT_RGBX_SINT8] = NULL; - table[MESA_FORMAT_B10G10R10X2_UNORM] = pack_ubyte_XRGB2101010_UNORM; - table[MESA_FORMAT_RGBX_UNORM16] = pack_ubyte_XBGR16161616_UNORM; + table[MESA_FORMAT_B10G10R10X2_UNORM] = pack_ubyte_B10G10R10X2_UNORM; + table[MESA_FORMAT_RGBX_UNORM16] = pack_ubyte_RGBX_UNORM16; table[MESA_FORMAT_RGBX_SNORM16] = NULL; table[MESA_FORMAT_RGBX_FLOAT16] = NULL; table[MESA_FORMAT_RGBX_UINT16] = NULL; @@ -2072,7 +2072,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format) table[MESA_FORMAT_RGBX_UINT32] = NULL; table[MESA_FORMAT_RGBX_SINT32] = NULL; - table[MESA_FORMAT_R10G10B10A2_UNORM] = pack_ubyte_ABGR2101010; + table[MESA_FORMAT_R10G10B10A2_UNORM] = pack_ubyte_R10G10B10A2_UNORM; table[MESA_FORMAT_B8G8R8X8_SRGB] = NULL; @@ -2098,46 +2098,46 @@ _mesa_get_pack_float_rgba_function(mesa_format format) table[MESA_FORMAT_NONE] = NULL; - table[MESA_FORMAT_A8B8G8R8_UNORM] = pack_float_RGBA8888; - table[MESA_FORMAT_R8G8B8A8_UNORM] = pack_float_RGBA8888_REV; - table[MESA_FORMAT_B8G8R8A8_UNORM] = pack_float_ARGB8888; - table[MESA_FORMAT_A8R8G8B8_UNORM] = pack_float_ARGB8888_REV; - table[MESA_FORMAT_X8B8G8R8_UNORM] = pack_float_RGBA8888; /* reused */ - table[MESA_FORMAT_R8G8B8X8_UNORM] = pack_float_RGBA8888_REV; /* reused */ - table[MESA_FORMAT_B8G8R8X8_UNORM] = pack_float_XRGB8888; - table[MESA_FORMAT_X8R8G8B8_UNORM] = pack_float_XRGB8888_REV; - table[MESA_FORMAT_BGR_UNORM8] = pack_float_RGB888; - table[MESA_FORMAT_RGB_UNORM8] = pack_float_BGR888; - table[MESA_FORMAT_B5G6R5_UNORM] = pack_float_RGB565; - table[MESA_FORMAT_R5G6B5_UNORM] = pack_float_RGB565_REV; - table[MESA_FORMAT_B4G4R4A4_UNORM] = pack_float_ARGB4444; - table[MESA_FORMAT_A4R4G4B4_UNORM] = pack_float_ARGB4444_REV; - table[MESA_FORMAT_A1B5G5R5_UNORM] = pack_float_RGBA5551; - table[MESA_FORMAT_B5G5R5A1_UNORM] = pack_float_ARGB1555; - table[MESA_FORMAT_A1R5G5B5_UNORM] = pack_float_ARGB1555_REV; - - table[MESA_FORMAT_L4A4_UNORM] = pack_float_AL44; - table[MESA_FORMAT_L8A8_UNORM] = pack_float_AL88; - table[MESA_FORMAT_A8L8_UNORM] = pack_float_AL88_REV; - table[MESA_FORMAT_L16A16_UNORM] = pack_float_AL1616; - table[MESA_FORMAT_A16L16_UNORM] = pack_float_AL1616_REV; - table[MESA_FORMAT_B2G3R3_UNORM] = pack_float_RGB332; - table[MESA_FORMAT_A_UNORM8] = pack_float_A8; - table[MESA_FORMAT_A_UNORM16] = pack_float_A16; - table[MESA_FORMAT_L_UNORM8] = pack_float_L8; - table[MESA_FORMAT_L_UNORM16] = pack_float_L16; - table[MESA_FORMAT_I_UNORM8] = pack_float_L8; /* reuse pack_float_L8 */ - table[MESA_FORMAT_I_UNORM16] = pack_float_L16; /* reuse pack_float_L16 */ + table[MESA_FORMAT_A8B8G8R8_UNORM] = pack_float_A8B8G8R8_UNORM; + table[MESA_FORMAT_R8G8B8A8_UNORM] = pack_float_R8G8B8A8_UNORM; + table[MESA_FORMAT_B8G8R8A8_UNORM] = pack_float_B8G8R8A8_UNORM; + table[MESA_FORMAT_A8R8G8B8_UNORM] = pack_float_A8R8G8B8_UNORM; + table[MESA_FORMAT_X8B8G8R8_UNORM] = pack_float_A8B8G8R8_UNORM; /* reused */ + table[MESA_FORMAT_R8G8B8X8_UNORM] = pack_float_R8G8B8A8_UNORM; /* reused */ + table[MESA_FORMAT_B8G8R8X8_UNORM] = pack_float_B8G8R8X8_UNORM; + table[MESA_FORMAT_X8R8G8B8_UNORM] = pack_float_X8R8G8B8_UNORM; + table[MESA_FORMAT_BGR_UNORM8] = pack_float_BGR_UNORM8; + table[MESA_FORMAT_RGB_UNORM8] = pack_float_RGB_UNORM8; + table[MESA_FORMAT_B5G6R5_UNORM] = pack_float_B5G6R5_UNORM; + table[MESA_FORMAT_R5G6B5_UNORM] = pack_float_R5G6B5_UNORM; + table[MESA_FORMAT_B4G4R4A4_UNORM] = pack_float_B4G4R4A4_UNORM; + table[MESA_FORMAT_A4R4G4B4_UNORM] = pack_float_A4R4G4B4_UNORM; + table[MESA_FORMAT_A1B5G5R5_UNORM] = pack_float_A1B5G5R5_UNORM; + table[MESA_FORMAT_B5G5R5A1_UNORM] = pack_float_B5G5R5A1_UNORM; + table[MESA_FORMAT_A1R5G5B5_UNORM] = pack_float_A1R5G5B5_UNORM; + + table[MESA_FORMAT_L4A4_UNORM] = pack_float_L4A4_UNORM; + table[MESA_FORMAT_L8A8_UNORM] = pack_float_L8A8_UNORM; + table[MESA_FORMAT_A8L8_UNORM] = pack_float_A8L8_UNORM; + table[MESA_FORMAT_L16A16_UNORM] = pack_float_L16A16_UNORM; + table[MESA_FORMAT_A16L16_UNORM] = pack_float_A16L16_UNORM; + table[MESA_FORMAT_B2G3R3_UNORM] = pack_float_B2G3R3_UNORM; + table[MESA_FORMAT_A_UNORM8] = pack_float_A_UNORM8; + table[MESA_FORMAT_A_UNORM16] = pack_float_A_UNORM16; + table[MESA_FORMAT_L_UNORM8] = pack_float_L_UNORM8; + table[MESA_FORMAT_L_UNORM16] = pack_float_L_UNORM16; + table[MESA_FORMAT_I_UNORM8] = pack_float_L_UNORM8; /* reuse pack_float_L_UNORM8 */ + table[MESA_FORMAT_I_UNORM16] = pack_float_L_UNORM16; /* reuse pack_float_L_UNORM16 */ table[MESA_FORMAT_YCBCR] = pack_float_YCBCR; table[MESA_FORMAT_YCBCR_REV] = pack_float_YCBCR_REV; - table[MESA_FORMAT_R_UNORM8] = pack_float_R8; - table[MESA_FORMAT_R8G8_UNORM] = pack_float_GR88; - table[MESA_FORMAT_G8R8_UNORM] = pack_float_RG88; - table[MESA_FORMAT_R_UNORM16] = pack_float_R16; - table[MESA_FORMAT_R16G16_UNORM] = pack_float_GR1616; - table[MESA_FORMAT_G16R16_UNORM] = pack_float_RG1616; - table[MESA_FORMAT_B10G10R10A2_UNORM] = pack_float_ARGB2101010; - table[MESA_FORMAT_R10G10B10A2_UINT] = pack_float_ABGR2101010_UINT; + table[MESA_FORMAT_R_UNORM8] = pack_float_R_UNORM8; + table[MESA_FORMAT_R8G8_UNORM] = pack_float_R8G8_UNORM; + table[MESA_FORMAT_G8R8_UNORM] = pack_float_G8R8_UNORM; + table[MESA_FORMAT_R_UNORM16] = pack_float_R_UNORM16; + table[MESA_FORMAT_R16G16_UNORM] = pack_float_R16G16_UNORM; + table[MESA_FORMAT_G16R16_UNORM] = pack_float_G16R16_UNORM; + table[MESA_FORMAT_B10G10R10A2_UNORM] = pack_float_B10G10R10A2_UNORM; + table[MESA_FORMAT_R10G10B10A2_UINT] = pack_float_R10G10B10A2_UINT; /* should never convert RGBA to these formats */ table[MESA_FORMAT_S8_UINT_Z24_UNORM] = NULL; @@ -2148,12 +2148,12 @@ _mesa_get_pack_float_rgba_function(mesa_format format) table[MESA_FORMAT_Z_UNORM32] = NULL; table[MESA_FORMAT_S_UINT8] = NULL; - table[MESA_FORMAT_BGR_SRGB8] = pack_float_SRGB8; - table[MESA_FORMAT_A8B8G8R8_SRGB] = pack_float_SRGBA8; - table[MESA_FORMAT_B8G8R8A8_SRGB] = pack_float_SARGB8; - table[MESA_FORMAT_R8G8B8A8_SRGB] = pack_float_SABGR8; - table[MESA_FORMAT_L_SRGB8] = pack_float_SL8; - table[MESA_FORMAT_L8A8_SRGB] = pack_float_SLA8; + table[MESA_FORMAT_BGR_SRGB8] = pack_float_BGR_SRGB8; + table[MESA_FORMAT_A8B8G8R8_SRGB] = pack_float_A8B8G8R8_SRGB; + table[MESA_FORMAT_B8G8R8A8_SRGB] = pack_float_B8G8R8A8_SRGB; + table[MESA_FORMAT_R8G8B8A8_SRGB] = pack_float_R8G8B8A8_SRGB; + table[MESA_FORMAT_L_SRGB8] = pack_float_L_SRGB8; + table[MESA_FORMAT_L8A8_SRGB] = pack_float_L8A8_SRGB; /* n/a */ table[MESA_FORMAT_SRGB_DXT1] = NULL; @@ -2172,17 +2172,17 @@ _mesa_get_pack_float_rgba_function(mesa_format format) table[MESA_FORMAT_RGBA_FLOAT16] = pack_float_RGBA_FLOAT16; table[MESA_FORMAT_RGB_FLOAT32] = pack_float_RGB_FLOAT32; table[MESA_FORMAT_RGB_FLOAT16] = pack_float_RGB_FLOAT16; - table[MESA_FORMAT_A_FLOAT32] = pack_float_ALPHA_FLOAT32; - table[MESA_FORMAT_A_FLOAT16] = pack_float_ALPHA_FLOAT16; - table[MESA_FORMAT_L_FLOAT32] = pack_float_LUMINANCE_FLOAT32; - table[MESA_FORMAT_L_FLOAT16] = pack_float_LUMINANCE_FLOAT16; - table[MESA_FORMAT_LA_FLOAT32] = pack_float_LUMINANCE_ALPHA_FLOAT32; - table[MESA_FORMAT_LA_FLOAT16] = pack_float_LUMINANCE_ALPHA_FLOAT16; - - table[MESA_FORMAT_I_FLOAT32] = pack_float_LUMINANCE_FLOAT32; - table[MESA_FORMAT_I_FLOAT16] = pack_float_LUMINANCE_FLOAT16; - table[MESA_FORMAT_R_FLOAT32] = pack_float_LUMINANCE_FLOAT32; - table[MESA_FORMAT_R_FLOAT16] = pack_float_LUMINANCE_FLOAT16; + table[MESA_FORMAT_A_FLOAT32] = pack_float_A_FLOAT32; + table[MESA_FORMAT_A_FLOAT16] = pack_float_A_FLOAT16; + table[MESA_FORMAT_L_FLOAT32] = pack_float_L_FLOAT32; + table[MESA_FORMAT_L_FLOAT16] = pack_float_L_FLOAT16; + table[MESA_FORMAT_LA_FLOAT32] = pack_float_LA_FLOAT32; + table[MESA_FORMAT_LA_FLOAT16] = pack_float_LA_FLOAT16; + + table[MESA_FORMAT_I_FLOAT32] = pack_float_L_FLOAT32; + table[MESA_FORMAT_I_FLOAT16] = pack_float_L_FLOAT16; + table[MESA_FORMAT_R_FLOAT32] = pack_float_L_FLOAT32; + table[MESA_FORMAT_R_FLOAT16] = pack_float_L_FLOAT16; table[MESA_FORMAT_RG_FLOAT32] = pack_float_RG_FLOAT32; table[MESA_FORMAT_RG_FLOAT16] = pack_float_RG_FLOAT16; @@ -2198,49 +2198,49 @@ _mesa_get_pack_float_rgba_function(mesa_format format) table[MESA_FORMAT_RGBA_UNORM16] = pack_float_RGBA_16; - table[MESA_FORMAT_R_SNORM8] = pack_float_SIGNED_R8; - table[MESA_FORMAT_R8G8_SNORM] = pack_float_SIGNED_RG88_REV; - table[MESA_FORMAT_X8B8G8R8_SNORM] = pack_float_SIGNED_RGBX8888; - table[MESA_FORMAT_A8B8G8R8_SNORM] = pack_float_SIGNED_RGBA8888; - table[MESA_FORMAT_R8G8B8A8_SNORM] = pack_float_SIGNED_RGBA8888_REV; - table[MESA_FORMAT_R_SNORM16] = pack_float_SIGNED_R16; - table[MESA_FORMAT_R16G16_SNORM] = pack_float_SIGNED_GR1616; - table[MESA_FORMAT_RGB_SNORM16] = pack_float_SIGNED_RGB_16; - table[MESA_FORMAT_RGBA_SNORM16] = pack_float_SIGNED_RGBA_16; - table[MESA_FORMAT_A_SNORM8] = pack_float_SIGNED_A8; - table[MESA_FORMAT_L_SNORM8] = pack_float_SIGNED_L8; - table[MESA_FORMAT_L8A8_SNORM] = pack_float_SIGNED_AL88; - table[MESA_FORMAT_I_SNORM8] = pack_float_SIGNED_L8; /* reused */ - table[MESA_FORMAT_A_SNORM16] = pack_float_SIGNED_A16; - table[MESA_FORMAT_L_SNORM16] = pack_float_SIGNED_L16; - table[MESA_FORMAT_LA_SNORM16] = pack_float_SIGNED_AL1616; - table[MESA_FORMAT_I_SNORM16] = pack_float_SIGNED_L16; /* reused */ - - table[MESA_FORMAT_R9G9B9E5_FLOAT] = pack_float_RGB9_E5_FLOAT; - table[MESA_FORMAT_R11G11B10_FLOAT] = pack_float_R11_G11_B10_FLOAT; + table[MESA_FORMAT_R_SNORM8] = pack_float_R_SNORM8; + table[MESA_FORMAT_R8G8_SNORM] = pack_float_R8G8_SNORM; + table[MESA_FORMAT_X8B8G8R8_SNORM] = pack_float_X8B8G8R8_SNORM; + table[MESA_FORMAT_A8B8G8R8_SNORM] = pack_float_A8B8G8R8_SNORM; + table[MESA_FORMAT_R8G8B8A8_SNORM] = pack_float_R8G8B8A8_SNORM; + table[MESA_FORMAT_R_SNORM16] = pack_float_R_SNORM16; + table[MESA_FORMAT_R16G16_SNORM] = pack_float_R16G16_SNORM; + table[MESA_FORMAT_RGB_SNORM16] = pack_float_RGB_SNORM16; + table[MESA_FORMAT_RGBA_SNORM16] = pack_float_RGBA_SNORM16; + table[MESA_FORMAT_A_SNORM8] = pack_float_A_SNORM8; + table[MESA_FORMAT_L_SNORM8] = pack_float_L_SNORM8; + table[MESA_FORMAT_L8A8_SNORM] = pack_float_L8A8_SNORM; + table[MESA_FORMAT_I_SNORM8] = pack_float_L_SNORM8; /* reused */ + table[MESA_FORMAT_A_SNORM16] = pack_float_A_SNORM16; + table[MESA_FORMAT_L_SNORM16] = pack_float_L_SNORM16; + table[MESA_FORMAT_LA_SNORM16] = pack_float_LA_SNORM16; + table[MESA_FORMAT_I_SNORM16] = pack_float_L_SNORM16; /* reused */ + + table[MESA_FORMAT_R9G9B9E5_FLOAT] = pack_float_R9G9B9E5_FLOAT; + table[MESA_FORMAT_R11G11B10_FLOAT] = pack_float_R11G11B10_FLOAT; table[MESA_FORMAT_B4G4R4X4_UNORM] = pack_float_XRGB4444_UNORM; table[MESA_FORMAT_B5G5R5X1_UNORM] = pack_float_XRGB1555_UNORM; table[MESA_FORMAT_R8G8B8X8_SNORM] = pack_float_XBGR8888_SNORM; - table[MESA_FORMAT_R8G8B8X8_SRGB] = pack_float_XBGR8888_SRGB; + table[MESA_FORMAT_R8G8B8X8_SRGB] = pack_float_R8G8B8X8_SRGB; table[MESA_FORMAT_RGBX_UINT8] = NULL; table[MESA_FORMAT_RGBX_SINT8] = NULL; - table[MESA_FORMAT_B10G10R10X2_UNORM] = pack_float_XRGB2101010_UNORM; - table[MESA_FORMAT_RGBX_UNORM16] = pack_float_XBGR16161616_UNORM; - table[MESA_FORMAT_RGBX_SNORM16] = pack_float_XBGR16161616_SNORM; + table[MESA_FORMAT_B10G10R10X2_UNORM] = pack_float_B10G10R10X2_UNORM; + table[MESA_FORMAT_RGBX_UNORM16] = pack_float_RGBX_UNORM16; + table[MESA_FORMAT_RGBX_SNORM16] = pack_float_RGBX_SNORM16; table[MESA_FORMAT_RGBX_FLOAT16] = pack_float_XBGR16161616_FLOAT; table[MESA_FORMAT_RGBX_UINT16] = NULL; table[MESA_FORMAT_RGBX_SINT16] = NULL; - table[MESA_FORMAT_RGBX_FLOAT32] = pack_float_XBGR32323232_FLOAT; + table[MESA_FORMAT_RGBX_FLOAT32] = pack_float_RGBX_FLOAT32; table[MESA_FORMAT_RGBX_UINT32] = NULL; table[MESA_FORMAT_RGBX_SINT32] = NULL; - table[MESA_FORMAT_R10G10B10A2_UNORM] = pack_float_ABGR2101010; + table[MESA_FORMAT_R10G10B10A2_UNORM] = pack_float_R10G10B10A2_UNORM; - table[MESA_FORMAT_G8R8_SNORM] = pack_float_SIGNED_RG88; - table[MESA_FORMAT_G16R16_SNORM] = pack_float_SIGNED_RG1616; + table[MESA_FORMAT_G8R8_SNORM] = pack_float_G8R8_SNORM; + table[MESA_FORMAT_G16R16_SNORM] = pack_float_G16R16_SNORM; - table[MESA_FORMAT_B8G8R8X8_SRGB] = pack_float_XRGB8888_SRGB; + table[MESA_FORMAT_B8G8R8X8_SRGB] = pack_float_B8G8R8X8_SRGB; initialized = GL_TRUE; } @@ -2262,18 +2262,18 @@ get_pack_float_rgba_row_function(mesa_format format) */ memset(table, 0, sizeof(table)); - table[MESA_FORMAT_A8B8G8R8_UNORM] = pack_row_float_RGBA8888; - table[MESA_FORMAT_R8G8B8A8_UNORM] = pack_row_float_RGBA8888_REV; - table[MESA_FORMAT_B8G8R8A8_UNORM] = pack_row_float_ARGB8888; - table[MESA_FORMAT_A8R8G8B8_UNORM] = pack_row_float_ARGB8888_REV; - table[MESA_FORMAT_X8B8G8R8_UNORM] = pack_row_float_RGBA8888; /* reused */ - table[MESA_FORMAT_R8G8B8X8_UNORM] = pack_row_float_RGBA8888_REV; /* reused */ - table[MESA_FORMAT_B8G8R8X8_UNORM] = pack_row_float_XRGB8888; - table[MESA_FORMAT_X8R8G8B8_UNORM] = pack_row_float_XRGB8888_REV; - table[MESA_FORMAT_BGR_UNORM8] = pack_row_float_RGB888; - table[MESA_FORMAT_RGB_UNORM8] = pack_row_float_BGR888; - table[MESA_FORMAT_B5G6R5_UNORM] = pack_row_float_RGB565; - table[MESA_FORMAT_R5G6B5_UNORM] = pack_row_float_RGB565_REV; + table[MESA_FORMAT_A8B8G8R8_UNORM] = pack_row_float_A8B8G8R8_UNORM; + table[MESA_FORMAT_R8G8B8A8_UNORM] = pack_row_float_R8G8B8A8_UNORM; + table[MESA_FORMAT_B8G8R8A8_UNORM] = pack_row_float_B8G8R8A8_UNORM; + table[MESA_FORMAT_A8R8G8B8_UNORM] = pack_row_float_A8R8G8B8_UNORM; + table[MESA_FORMAT_X8B8G8R8_UNORM] = pack_row_float_A8B8G8R8_UNORM; /* reused */ + table[MESA_FORMAT_R8G8B8X8_UNORM] = pack_row_float_R8G8B8A8_UNORM; /* reused */ + table[MESA_FORMAT_B8G8R8X8_UNORM] = pack_row_float_B8G8R8X8_UNORM; + table[MESA_FORMAT_X8R8G8B8_UNORM] = pack_row_float_X8R8G8B8_UNORM; + table[MESA_FORMAT_BGR_UNORM8] = pack_row_float_BGR_UNORM8; + table[MESA_FORMAT_RGB_UNORM8] = pack_row_float_RGB_UNORM8; + table[MESA_FORMAT_B5G6R5_UNORM] = pack_row_float_B5G6R5_UNORM; + table[MESA_FORMAT_R5G6B5_UNORM] = pack_row_float_R5G6B5_UNORM; initialized = GL_TRUE; } @@ -2295,18 +2295,18 @@ get_pack_ubyte_rgba_row_function(mesa_format format) */ memset(table, 0, sizeof(table)); - table[MESA_FORMAT_A8B8G8R8_UNORM] = pack_row_ubyte_RGBA8888; - table[MESA_FORMAT_R8G8B8A8_UNORM] = pack_row_ubyte_RGBA8888_REV; - table[MESA_FORMAT_B8G8R8A8_UNORM] = pack_row_ubyte_ARGB8888; - table[MESA_FORMAT_A8R8G8B8_UNORM] = pack_row_ubyte_ARGB8888_REV; - table[MESA_FORMAT_X8B8G8R8_UNORM] = pack_row_ubyte_RGBA8888; /* reused */ - table[MESA_FORMAT_R8G8B8X8_UNORM] = pack_row_ubyte_RGBA8888_REV; /* reused */ - table[MESA_FORMAT_B8G8R8X8_UNORM] = pack_row_ubyte_XRGB8888; - table[MESA_FORMAT_X8R8G8B8_UNORM] = pack_row_ubyte_XRGB8888_REV; - table[MESA_FORMAT_BGR_UNORM8] = pack_row_ubyte_RGB888; - table[MESA_FORMAT_RGB_UNORM8] = pack_row_ubyte_BGR888; - table[MESA_FORMAT_B5G6R5_UNORM] = pack_row_ubyte_RGB565; - table[MESA_FORMAT_R5G6B5_UNORM] = pack_row_ubyte_RGB565_REV; + table[MESA_FORMAT_A8B8G8R8_UNORM] = pack_row_ubyte_A8B8G8R8_UNORM; + table[MESA_FORMAT_R8G8B8A8_UNORM] = pack_row_ubyte_R8G8B8A8_UNORM; + table[MESA_FORMAT_B8G8R8A8_UNORM] = pack_row_ubyte_B8G8R8A8_UNORM; + table[MESA_FORMAT_A8R8G8B8_UNORM] = pack_row_ubyte_A8R8G8B8_UNORM; + table[MESA_FORMAT_X8B8G8R8_UNORM] = pack_row_ubyte_A8B8G8R8_UNORM; /* reused */ + table[MESA_FORMAT_R8G8B8X8_UNORM] = pack_row_ubyte_R8G8B8A8_UNORM; /* reused */ + table[MESA_FORMAT_B8G8R8X8_UNORM] = pack_row_ubyte_B8G8R8X8_UNORM; + table[MESA_FORMAT_X8R8G8B8_UNORM] = pack_row_ubyte_X8R8G8B8_UNORM; + table[MESA_FORMAT_BGR_UNORM8] = pack_row_ubyte_BGR_UNORM8; + table[MESA_FORMAT_RGB_UNORM8] = pack_row_ubyte_RGB_UNORM8; + table[MESA_FORMAT_B5G6R5_UNORM] = pack_row_ubyte_B5G6R5_UNORM; + table[MESA_FORMAT_R5G6B5_UNORM] = pack_row_ubyte_R5G6B5_UNORM; initialized = GL_TRUE; } @@ -2425,7 +2425,7 @@ _mesa_pack_ubyte_rgba_rect(mesa_format format, GLuint width, GLuint height, **/ static void -pack_float_z_Z24_S8(const GLfloat *src, void *dst) +pack_float_S8_UINT_Z24_UNORM(const GLfloat *src, void *dst) { /* don't disturb the stencil values */ GLuint *d = ((GLuint *) dst); @@ -2437,7 +2437,7 @@ pack_float_z_Z24_S8(const GLfloat *src, void *dst) } static void -pack_float_z_S8_Z24(const GLfloat *src, void *dst) +pack_float_Z24_UNORM_S8_UINT(const GLfloat *src, void *dst) { /* don't disturb the stencil values */ GLuint *d = ((GLuint *) dst); @@ -2449,7 +2449,7 @@ pack_float_z_S8_Z24(const GLfloat *src, void *dst) } static void -pack_float_z_Z16(const GLfloat *src, void *dst) +pack_float_Z_UNORM16(const GLfloat *src, void *dst) { GLushort *d = ((GLushort *) dst); const GLfloat scale = (GLfloat) 0xffff; @@ -2457,7 +2457,7 @@ pack_float_z_Z16(const GLfloat *src, void *dst) } static void -pack_float_z_Z32(const GLfloat *src, void *dst) +pack_float_Z_UNORM32(const GLfloat *src, void *dst) { GLuint *d = ((GLuint *) dst); const GLdouble scale = (GLdouble) 0xffffffff; @@ -2465,7 +2465,7 @@ pack_float_z_Z32(const GLfloat *src, void *dst) } static void -pack_float_z_Z32_FLOAT(const GLfloat *src, void *dst) +pack_float_Z_FLOAT32(const GLfloat *src, void *dst) { GLfloat *d = (GLfloat *) dst; *d = *src; @@ -2477,17 +2477,17 @@ _mesa_get_pack_float_z_func(mesa_format format) switch (format) { case MESA_FORMAT_S8_UINT_Z24_UNORM: case MESA_FORMAT_X8_UINT_Z24_UNORM: - return pack_float_z_Z24_S8; + return pack_float_S8_UINT_Z24_UNORM; case MESA_FORMAT_Z24_UNORM_S8_UINT: case MESA_FORMAT_Z24_UNORM_X8_UINT: - return pack_float_z_S8_Z24; + return pack_float_Z24_UNORM_S8_UINT; case MESA_FORMAT_Z_UNORM16: - return pack_float_z_Z16; + return pack_float_Z_UNORM16; case MESA_FORMAT_Z_UNORM32: - return pack_float_z_Z32; + return pack_float_Z_UNORM32; case MESA_FORMAT_Z_FLOAT32: case MESA_FORMAT_Z32_FLOAT_S8X24_UINT: - return pack_float_z_Z32_FLOAT; + return pack_float_Z_FLOAT32; default: _mesa_problem(NULL, "unexpected format in _mesa_get_pack_float_z_func()"); @@ -2503,7 +2503,7 @@ _mesa_get_pack_float_z_func(mesa_format format) **/ static void -pack_uint_z_Z24_S8(const GLuint *src, void *dst) +pack_uint_S8_UINT_Z24_UNORM(const GLuint *src, void *dst) { /* don't disturb the stencil values */ GLuint *d = ((GLuint *) dst); @@ -2513,7 +2513,7 @@ pack_uint_z_Z24_S8(const GLuint *src, void *dst) } static void -pack_uint_z_S8_Z24(const GLuint *src, void *dst) +pack_uint_Z24_UNORM_S8_UINT(const GLuint *src, void *dst) { /* don't disturb the stencil values */ GLuint *d = ((GLuint *) dst); @@ -2523,21 +2523,21 @@ pack_uint_z_S8_Z24(const GLuint *src, void *dst) } static void -pack_uint_z_Z16(const GLuint *src, void *dst) +pack_uint_Z_UNORM16(const GLuint *src, void *dst) { GLushort *d = ((GLushort *) dst); *d = *src >> 16; } static void -pack_uint_z_Z32(const GLuint *src, void *dst) +pack_uint_Z_UNORM32(const GLuint *src, void *dst) { GLuint *d = ((GLuint *) dst); *d = *src; } static void -pack_uint_z_Z32_FLOAT(const GLuint *src, void *dst) +pack_uint_Z_FLOAT32(const GLuint *src, void *dst) { GLuint *d = ((GLuint *) dst); const GLdouble scale = 1.0 / (GLdouble) 0xffffffff; @@ -2547,7 +2547,7 @@ pack_uint_z_Z32_FLOAT(const GLuint *src, void *dst) } static void -pack_uint_z_Z32_FLOAT_X24S8(const GLuint *src, void *dst) +pack_uint_Z_FLOAT32_X24S8(const GLuint *src, void *dst) { GLfloat *d = ((GLfloat *) dst); const GLdouble scale = 1.0 / (GLdouble) 0xffffffff; @@ -2562,18 +2562,18 @@ _mesa_get_pack_uint_z_func(mesa_format format) switch (format) { case MESA_FORMAT_S8_UINT_Z24_UNORM: case MESA_FORMAT_X8_UINT_Z24_UNORM: - return pack_uint_z_Z24_S8; + return pack_uint_S8_UINT_Z24_UNORM; case MESA_FORMAT_Z24_UNORM_S8_UINT: case MESA_FORMAT_Z24_UNORM_X8_UINT: - return pack_uint_z_S8_Z24; + return pack_uint_Z24_UNORM_S8_UINT; case MESA_FORMAT_Z_UNORM16: - return pack_uint_z_Z16; + return pack_uint_Z_UNORM16; case MESA_FORMAT_Z_UNORM32: - return pack_uint_z_Z32; + return pack_uint_Z_UNORM32; case MESA_FORMAT_Z_FLOAT32: - return pack_uint_z_Z32_FLOAT; + return pack_uint_Z_FLOAT32; case MESA_FORMAT_Z32_FLOAT_S8X24_UINT: - return pack_uint_z_Z32_FLOAT_X24S8; + return pack_uint_Z_FLOAT32_X24S8; default: _mesa_problem(NULL, "unexpected format in _mesa_get_pack_uint_z_func()"); return NULL; diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c index f85c875e4..2ef2e31d6 100644 --- a/mesalib/src/mesa/main/format_unpack.c +++ b/mesalib/src/mesa/main/format_unpack.c @@ -89,7 +89,7 @@ typedef void (*unpack_rgba_func)(const void *src, GLfloat dst[][4], GLuint n); static void -unpack_RGBA8888(const void *src, GLfloat dst[][4], GLuint n) +unpack_A8B8G8R8_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -102,7 +102,7 @@ unpack_RGBA8888(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_RGBA8888_REV(const void *src, GLfloat dst[][4], GLuint n) +unpack_R8G8B8A8_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -115,7 +115,7 @@ unpack_RGBA8888_REV(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_ARGB8888(const void *src, GLfloat dst[][4], GLuint n) +unpack_B8G8R8A8_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -128,7 +128,7 @@ unpack_ARGB8888(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_ARGB8888_REV(const void *src, GLfloat dst[][4], GLuint n) +unpack_A8R8G8B8_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -167,7 +167,7 @@ unpack_RGBX8888_REV(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_XRGB8888(const void *src, GLfloat dst[][4], GLuint n) +unpack_B8G8R8X8_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -180,7 +180,7 @@ unpack_XRGB8888(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_XRGB8888_REV(const void *src, GLfloat dst[][4], GLuint n) +unpack_X8R8G8B8_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -193,7 +193,7 @@ unpack_XRGB8888_REV(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_RGB888(const void *src, GLfloat dst[][4], GLuint n) +unpack_BGR_UNORM8(const void *src, GLfloat dst[][4], GLuint n) { const GLubyte *s = (const GLubyte *) src; GLuint i; @@ -206,7 +206,7 @@ unpack_RGB888(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_BGR888(const void *src, GLfloat dst[][4], GLuint n) +unpack_RGB_UNORM8(const void *src, GLfloat dst[][4], GLuint n) { const GLubyte *s = (const GLubyte *) src; GLuint i; @@ -219,7 +219,7 @@ unpack_BGR888(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_RGB565(const void *src, GLfloat dst[][4], GLuint n) +unpack_B5G6R5_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -232,7 +232,7 @@ unpack_RGB565(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_RGB565_REV(const void *src, GLfloat dst[][4], GLuint n) +unpack_R5G6B5_UNORM(const void *src, GLfloat dst[][4], GLuint n) { /* Warning: this function does not match the current Mesa definition * of MESA_FORMAT_R5G6B5_UNORM. @@ -249,7 +249,7 @@ unpack_RGB565_REV(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_ARGB4444(const void *src, GLfloat dst[][4], GLuint n) +unpack_B4G4R4A4_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -262,7 +262,7 @@ unpack_ARGB4444(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_ARGB4444_REV(const void *src, GLfloat dst[][4], GLuint n) +unpack_A4R4G4B4_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -275,7 +275,7 @@ unpack_ARGB4444_REV(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_RGBA5551(const void *src, GLfloat dst[][4], GLuint n) +unpack_A1B5G5R5_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -288,7 +288,7 @@ unpack_RGBA5551(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_ARGB1555(const void *src, GLfloat dst[][4], GLuint n) +unpack_B5G5R5A1_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -301,7 +301,7 @@ unpack_ARGB1555(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_ARGB1555_REV(const void *src, GLfloat dst[][4], GLuint n) +unpack_A1R5G5B5_UNORM(const void *src, GLfloat dst[][4], GLuint n) { /* Warning: this function does not match the current Mesa definition * of MESA_FORMAT_A1R5G5B5_UNORM. @@ -318,7 +318,7 @@ unpack_ARGB1555_REV(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_AL44(const void *src, GLfloat dst[][4], GLuint n) +unpack_L4A4_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLubyte *s = ((const GLubyte *) src); GLuint i; @@ -331,7 +331,7 @@ unpack_AL44(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_AL88(const void *src, GLfloat dst[][4], GLuint n) +unpack_L8A8_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -344,7 +344,7 @@ unpack_AL88(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_AL88_REV(const void *src, GLfloat dst[][4], GLuint n) +unpack_A8L8_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -357,7 +357,7 @@ unpack_AL88_REV(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_AL1616(const void *src, GLfloat dst[][4], GLuint n) +unpack_L16A16_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -370,7 +370,7 @@ unpack_AL1616(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_AL1616_REV(const void *src, GLfloat dst[][4], GLuint n) +unpack_A16L16_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -383,7 +383,7 @@ unpack_AL1616_REV(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_RGB332(const void *src, GLfloat dst[][4], GLuint n) +unpack_B2G3R3_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLubyte *s = ((const GLubyte *) src); GLuint i; @@ -397,7 +397,7 @@ unpack_RGB332(const void *src, GLfloat dst[][4], GLuint n) static void -unpack_A8(const void *src, GLfloat dst[][4], GLuint n) +unpack_A_UNORM8(const void *src, GLfloat dst[][4], GLuint n) { const GLubyte *s = ((const GLubyte *) src); GLuint i; @@ -410,7 +410,7 @@ unpack_A8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_A16(const void *src, GLfloat dst[][4], GLuint n) +unpack_A_UNORM16(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -423,7 +423,7 @@ unpack_A16(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_L8(const void *src, GLfloat dst[][4], GLuint n) +unpack_L_UNORM8(const void *src, GLfloat dst[][4], GLuint n) { const GLubyte *s = ((const GLubyte *) src); GLuint i; @@ -436,7 +436,7 @@ unpack_L8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_L16(const void *src, GLfloat dst[][4], GLuint n) +unpack_L_UNORM16(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -449,7 +449,7 @@ unpack_L16(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_I8(const void *src, GLfloat dst[][4], GLuint n) +unpack_I_UNORM8(const void *src, GLfloat dst[][4], GLuint n) { const GLubyte *s = ((const GLubyte *) src); GLuint i; @@ -462,7 +462,7 @@ unpack_I8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_I16(const void *src, GLfloat dst[][4], GLuint n) +unpack_I_UNORM16(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -525,7 +525,7 @@ unpack_YCBCR_REV(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_R8(const void *src, GLfloat dst[][4], GLuint n) +unpack_R_UNORM8(const void *src, GLfloat dst[][4], GLuint n) { const GLubyte *s = ((const GLubyte *) src); GLuint i; @@ -538,7 +538,7 @@ unpack_R8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_GR88(const void *src, GLfloat dst[][4], GLuint n) +unpack_R8G8_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -551,7 +551,7 @@ unpack_GR88(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_RG88(const void *src, GLfloat dst[][4], GLuint n) +unpack_G8R8_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -564,7 +564,7 @@ unpack_RG88(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_R16(const void *src, GLfloat dst[][4], GLuint n) +unpack_R_UNORM16(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -577,7 +577,7 @@ unpack_R16(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_GR1616(const void *src, GLfloat dst[][4], GLuint n) +unpack_R16G16_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -590,7 +590,7 @@ unpack_GR1616(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_RG1616(const void *src, GLfloat dst[][4], GLuint n) +unpack_G16R16_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -603,7 +603,7 @@ unpack_RG1616(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_ARGB2101010(const void *src, GLfloat dst[][4], GLuint n) +unpack_B10G10R10A2_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -617,7 +617,7 @@ unpack_ARGB2101010(const void *src, GLfloat dst[][4], GLuint n) static void -unpack_ARGB2101010_UINT(const void *src, GLfloat dst[][4], GLuint n) +unpack_B10G10R10A2_UINT(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = (const GLuint *) src; GLuint i; @@ -631,7 +631,7 @@ unpack_ARGB2101010_UINT(const void *src, GLfloat dst[][4], GLuint n) static void -unpack_ABGR2101010_UINT(const void *src, GLfloat dst[][4], GLuint n) +unpack_R10G10B10A2_UINT(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -717,20 +717,20 @@ unpack_Z32(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_Z32_FLOAT(const void *src, GLfloat dst[][4], GLuint n) +unpack_Z32_FLOAT_X24S8(const void *src, GLfloat dst[][4], GLuint n) { - const GLfloat *s = ((const GLfloat *) src); + const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src; GLuint i; for (i = 0; i < n; i++) { dst[i][0] = dst[i][1] = - dst[i][2] = s[i * 2]; + dst[i][2] = s[i].z; dst[i][3] = 1.0F; } } static void -unpack_Z32_FLOAT_X24S8(const void *src, GLfloat dst[][4], GLuint n) +unpack_Z32_FLOAT(const void *src, GLfloat dst[][4], GLuint n) { const GLfloat *s = ((const GLfloat *) src); GLuint i; @@ -758,7 +758,7 @@ unpack_S8(const void *src, GLfloat dst[][4], GLuint n) static void -unpack_SRGB8(const void *src, GLfloat dst[][4], GLuint n) +unpack_BGR_SRGB8(const void *src, GLfloat dst[][4], GLuint n) { const GLubyte *s = (const GLubyte *) src; GLuint i; @@ -771,7 +771,7 @@ unpack_SRGB8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SRGBA8(const void *src, GLfloat dst[][4], GLuint n) +unpack_A8B8G8R8_SRGB(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -784,7 +784,7 @@ unpack_SRGBA8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SARGB8(const void *src, GLfloat dst[][4], GLuint n) +unpack_B8G8R8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -797,7 +797,7 @@ unpack_SARGB8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SABGR8(const void *src, GLfloat dst[][4], GLuint n) +unpack_R8G8B8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -810,7 +810,7 @@ unpack_SABGR8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SL8(const void *src, GLfloat dst[][4], GLuint n) +unpack_L_SRGB8(const void *src, GLfloat dst[][4], GLuint n) { const GLubyte *s = ((const GLubyte *) src); GLuint i; @@ -823,7 +823,7 @@ unpack_SL8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SLA8(const void *src, GLfloat dst[][4], GLuint n) +unpack_L8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = (const GLushort *) src; GLuint i; @@ -939,7 +939,7 @@ unpack_RGB_FLOAT16(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_ALPHA_FLOAT32(const void *src, GLfloat dst[][4], GLuint n) +unpack_A_FLOAT32(const void *src, GLfloat dst[][4], GLuint n) { const GLfloat *s = (const GLfloat *) src; GLuint i; @@ -952,7 +952,7 @@ unpack_ALPHA_FLOAT32(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_ALPHA_FLOAT16(const void *src, GLfloat dst[][4], GLuint n) +unpack_A_FLOAT16(const void *src, GLfloat dst[][4], GLuint n) { const GLhalfARB *s = (const GLhalfARB *) src; GLuint i; @@ -965,7 +965,7 @@ unpack_ALPHA_FLOAT16(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_LUMINANCE_FLOAT32(const void *src, GLfloat dst[][4], GLuint n) +unpack_L_FLOAT32(const void *src, GLfloat dst[][4], GLuint n) { const GLfloat *s = (const GLfloat *) src; GLuint i; @@ -978,7 +978,7 @@ unpack_LUMINANCE_FLOAT32(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_LUMINANCE_FLOAT16(const void *src, GLfloat dst[][4], GLuint n) +unpack_L_FLOAT16(const void *src, GLfloat dst[][4], GLuint n) { const GLhalfARB *s = (const GLhalfARB *) src; GLuint i; @@ -991,7 +991,7 @@ unpack_LUMINANCE_FLOAT16(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_LUMINANCE_ALPHA_FLOAT32(const void *src, GLfloat dst[][4], GLuint n) +unpack_LA_FLOAT32(const void *src, GLfloat dst[][4], GLuint n) { const GLfloat *s = (const GLfloat *) src; GLuint i; @@ -1004,7 +1004,7 @@ unpack_LUMINANCE_ALPHA_FLOAT32(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_LUMINANCE_ALPHA_FLOAT16(const void *src, GLfloat dst[][4], GLuint n) +unpack_LA_FLOAT16(const void *src, GLfloat dst[][4], GLuint n) { const GLhalfARB *s = (const GLhalfARB *) src; GLuint i; @@ -1017,7 +1017,7 @@ unpack_LUMINANCE_ALPHA_FLOAT16(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_INTENSITY_FLOAT32(const void *src, GLfloat dst[][4], GLuint n) +unpack_I_FLOAT32(const void *src, GLfloat dst[][4], GLuint n) { const GLfloat *s = (const GLfloat *) src; GLuint i; @@ -1030,7 +1030,7 @@ unpack_INTENSITY_FLOAT32(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_INTENSITY_FLOAT16(const void *src, GLfloat dst[][4], GLuint n) +unpack_I_FLOAT16(const void *src, GLfloat dst[][4], GLuint n) { const GLhalfARB *s = (const GLhalfARB *) src; GLuint i; @@ -1721,7 +1721,7 @@ unpack_DUDV8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_R8(const void *src, GLfloat dst[][4], GLuint n) +unpack_R_SNORM8(const void *src, GLfloat dst[][4], GLuint n) { const GLbyte *s = ((const GLbyte *) src); GLuint i; @@ -1734,7 +1734,7 @@ unpack_SIGNED_R8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_RG88_REV(const void *src, GLfloat dst[][4], GLuint n) +unpack_R8G8_SNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -1747,7 +1747,7 @@ unpack_SIGNED_RG88_REV(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_RGBX8888(const void *src, GLfloat dst[][4], GLuint n) +unpack_X8B8G8R8_SNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -1760,7 +1760,7 @@ unpack_SIGNED_RGBX8888(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_RGBA8888(const void *src, GLfloat dst[][4], GLuint n) +unpack_A8B8G8R8_SNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -1773,7 +1773,7 @@ unpack_SIGNED_RGBA8888(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_RGBA8888_REV(const void *src, GLfloat dst[][4], GLuint n) +unpack_R8G8B8A8_SNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -1786,7 +1786,7 @@ unpack_SIGNED_RGBA8888_REV(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_R16(const void *src, GLfloat dst[][4], GLuint n) +unpack_R_SNORM16(const void *src, GLfloat dst[][4], GLuint n) { const GLshort *s = ((const GLshort *) src); GLuint i; @@ -1799,7 +1799,7 @@ unpack_SIGNED_R16(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_GR1616(const void *src, GLfloat dst[][4], GLuint n) +unpack_R16G16_SNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -1812,7 +1812,7 @@ unpack_SIGNED_GR1616(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_RGB_16(const void *src, GLfloat dst[][4], GLuint n) +unpack_RGB_SNORM16(const void *src, GLfloat dst[][4], GLuint n) { const GLshort *s = (const GLshort *) src; GLuint i; @@ -1825,7 +1825,7 @@ unpack_SIGNED_RGB_16(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_RGBA_16(const void *src, GLfloat dst[][4], GLuint n) +unpack_RGBA_SNORM16(const void *src, GLfloat dst[][4], GLuint n) { const GLshort *s = (const GLshort *) src; GLuint i; @@ -1967,7 +1967,7 @@ unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1(const void *src, GLfloat dst[][4], } static void -unpack_SIGNED_A8(const void *src, GLfloat dst[][4], GLuint n) +unpack_A_SNORM8(const void *src, GLfloat dst[][4], GLuint n) { const GLbyte *s = ((const GLbyte *) src); GLuint i; @@ -1980,7 +1980,7 @@ unpack_SIGNED_A8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_L8(const void *src, GLfloat dst[][4], GLuint n) +unpack_L_SNORM8(const void *src, GLfloat dst[][4], GLuint n) { const GLbyte *s = ((const GLbyte *) src); GLuint i; @@ -1993,7 +1993,7 @@ unpack_SIGNED_L8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_AL88(const void *src, GLfloat dst[][4], GLuint n) +unpack_L8A8_SNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLshort *s = ((const GLshort *) src); GLuint i; @@ -2006,7 +2006,7 @@ unpack_SIGNED_AL88(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_I8(const void *src, GLfloat dst[][4], GLuint n) +unpack_I_SNORM8(const void *src, GLfloat dst[][4], GLuint n) { const GLbyte *s = ((const GLbyte *) src); GLuint i; @@ -2019,7 +2019,7 @@ unpack_SIGNED_I8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_A16(const void *src, GLfloat dst[][4], GLuint n) +unpack_A_SNORM16(const void *src, GLfloat dst[][4], GLuint n) { const GLshort *s = ((const GLshort *) src); GLuint i; @@ -2032,7 +2032,7 @@ unpack_SIGNED_A16(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_L16(const void *src, GLfloat dst[][4], GLuint n) +unpack_L_SNORM16(const void *src, GLfloat dst[][4], GLuint n) { const GLshort *s = ((const GLshort *) src); GLuint i; @@ -2045,7 +2045,7 @@ unpack_SIGNED_L16(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_AL1616(const void *src, GLfloat dst[][4], GLuint n) +unpack_LA_SNORM16(const void *src, GLfloat dst[][4], GLuint n) { const GLshort *s = (const GLshort *) src; GLuint i; @@ -2058,7 +2058,7 @@ unpack_SIGNED_AL1616(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_I16(const void *src, GLfloat dst[][4], GLuint n) +unpack_I_SNORM16(const void *src, GLfloat dst[][4], GLuint n) { const GLshort *s = ((const GLshort *) src); GLuint i; @@ -2071,7 +2071,7 @@ unpack_SIGNED_I16(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_RGB9_E5_FLOAT(const void *src, GLfloat dst[][4], GLuint n) +unpack_R9G9B9E5_FLOAT(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = (const GLuint *) src; GLuint i; @@ -2082,7 +2082,7 @@ unpack_RGB9_E5_FLOAT(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_R11_G11_B10_FLOAT(const void *src, GLfloat dst[][4], GLuint n) +unpack_R11G11B10_FLOAT(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = (const GLuint *) src; GLuint i; @@ -2132,7 +2132,7 @@ unpack_XBGR8888_SNORM(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_XBGR8888_SRGB(const void *src, GLfloat dst[][4], GLuint n) +unpack_R8G8B8X8_SRGB(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -2171,7 +2171,7 @@ unpack_XBGR8888_SINT(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_XRGB2101010_UNORM(const void *src, GLfloat dst[][4], GLuint n) +unpack_B10G10R10X2_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -2184,7 +2184,7 @@ unpack_XRGB2101010_UNORM(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_XBGR16161616_UNORM(const void *src, GLfloat dst[][4], GLuint n) +unpack_RGBX_UNORM16(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = (const GLushort *) src; GLuint i; @@ -2197,7 +2197,7 @@ unpack_XBGR16161616_UNORM(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_XBGR16161616_SNORM(const void *src, GLfloat dst[][4], GLuint n) +unpack_RGBX_SNORM16(const void *src, GLfloat dst[][4], GLuint n) { const GLshort *s = (const GLshort *) src; GLuint i; @@ -2249,7 +2249,7 @@ unpack_XBGR16161616_SINT(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_XBGR32323232_FLOAT(const void *src, GLfloat dst[][4], GLuint n) +unpack_RGBX_FLOAT32(const void *src, GLfloat dst[][4], GLuint n) { const GLfloat *s = (const GLfloat *) src; GLuint i; @@ -2288,7 +2288,7 @@ unpack_XBGR32323232_SINT(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_ABGR2101010(const void *src, GLfloat dst[][4], GLuint n) +unpack_R10G10B10A2_UNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -2301,7 +2301,7 @@ unpack_ABGR2101010(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_RG88(const void *src, GLfloat dst[][4], GLuint n) +unpack_G8R8_SNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -2314,7 +2314,7 @@ unpack_SIGNED_RG88(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_SIGNED_RG1616(const void *src, GLfloat dst[][4], GLuint n) +unpack_G16R16_SNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -2327,7 +2327,7 @@ unpack_SIGNED_RG1616(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_XRGB8888_SRGB(const void *src, GLfloat dst[][4], GLuint n) +unpack_B8G8R8X8_SRGB(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -2351,46 +2351,46 @@ get_unpack_rgba_function(mesa_format format) if (!initialized) { table[MESA_FORMAT_NONE] = NULL; - table[MESA_FORMAT_A8B8G8R8_UNORM] = unpack_RGBA8888; - table[MESA_FORMAT_R8G8B8A8_UNORM] = unpack_RGBA8888_REV; - table[MESA_FORMAT_B8G8R8A8_UNORM] = unpack_ARGB8888; - table[MESA_FORMAT_A8R8G8B8_UNORM] = unpack_ARGB8888_REV; + table[MESA_FORMAT_A8B8G8R8_UNORM] = unpack_A8B8G8R8_UNORM; + table[MESA_FORMAT_R8G8B8A8_UNORM] = unpack_R8G8B8A8_UNORM; + table[MESA_FORMAT_B8G8R8A8_UNORM] = unpack_B8G8R8A8_UNORM; + table[MESA_FORMAT_A8R8G8B8_UNORM] = unpack_A8R8G8B8_UNORM; table[MESA_FORMAT_X8B8G8R8_UNORM] = unpack_RGBX8888; table[MESA_FORMAT_R8G8B8X8_UNORM] = unpack_RGBX8888_REV; - table[MESA_FORMAT_B8G8R8X8_UNORM] = unpack_XRGB8888; - table[MESA_FORMAT_X8R8G8B8_UNORM] = unpack_XRGB8888_REV; - table[MESA_FORMAT_BGR_UNORM8] = unpack_RGB888; - table[MESA_FORMAT_RGB_UNORM8] = unpack_BGR888; - table[MESA_FORMAT_B5G6R5_UNORM] = unpack_RGB565; - table[MESA_FORMAT_R5G6B5_UNORM] = unpack_RGB565_REV; - table[MESA_FORMAT_B4G4R4A4_UNORM] = unpack_ARGB4444; - table[MESA_FORMAT_A4R4G4B4_UNORM] = unpack_ARGB4444_REV; - table[MESA_FORMAT_A1B5G5R5_UNORM] = unpack_RGBA5551; - table[MESA_FORMAT_B5G5R5A1_UNORM] = unpack_ARGB1555; - table[MESA_FORMAT_A1R5G5B5_UNORM] = unpack_ARGB1555_REV; - table[MESA_FORMAT_L4A4_UNORM] = unpack_AL44; - table[MESA_FORMAT_L8A8_UNORM] = unpack_AL88; - table[MESA_FORMAT_A8L8_UNORM] = unpack_AL88_REV; - table[MESA_FORMAT_L16A16_UNORM] = unpack_AL1616; - table[MESA_FORMAT_A16L16_UNORM] = unpack_AL1616_REV; - table[MESA_FORMAT_B2G3R3_UNORM] = unpack_RGB332; - table[MESA_FORMAT_A_UNORM8] = unpack_A8; - table[MESA_FORMAT_A_UNORM16] = unpack_A16; - table[MESA_FORMAT_L_UNORM8] = unpack_L8; - table[MESA_FORMAT_L_UNORM16] = unpack_L16; - table[MESA_FORMAT_I_UNORM8] = unpack_I8; - table[MESA_FORMAT_I_UNORM16] = unpack_I16; + table[MESA_FORMAT_B8G8R8X8_UNORM] = unpack_B8G8R8X8_UNORM; + table[MESA_FORMAT_X8R8G8B8_UNORM] = unpack_X8R8G8B8_UNORM; + table[MESA_FORMAT_BGR_UNORM8] = unpack_BGR_UNORM8; + table[MESA_FORMAT_RGB_UNORM8] = unpack_RGB_UNORM8; + table[MESA_FORMAT_B5G6R5_UNORM] = unpack_B5G6R5_UNORM; + table[MESA_FORMAT_R5G6B5_UNORM] = unpack_R5G6B5_UNORM; + table[MESA_FORMAT_B4G4R4A4_UNORM] = unpack_B4G4R4A4_UNORM; + table[MESA_FORMAT_A4R4G4B4_UNORM] = unpack_A4R4G4B4_UNORM; + table[MESA_FORMAT_A1B5G5R5_UNORM] = unpack_A1B5G5R5_UNORM; + table[MESA_FORMAT_B5G5R5A1_UNORM] = unpack_B5G5R5A1_UNORM; + table[MESA_FORMAT_A1R5G5B5_UNORM] = unpack_A1R5G5B5_UNORM; + table[MESA_FORMAT_L4A4_UNORM] = unpack_L4A4_UNORM; + table[MESA_FORMAT_L8A8_UNORM] = unpack_L8A8_UNORM; + table[MESA_FORMAT_A8L8_UNORM] = unpack_A8L8_UNORM; + table[MESA_FORMAT_L16A16_UNORM] = unpack_L16A16_UNORM; + table[MESA_FORMAT_A16L16_UNORM] = unpack_A16L16_UNORM; + table[MESA_FORMAT_B2G3R3_UNORM] = unpack_B2G3R3_UNORM; + table[MESA_FORMAT_A_UNORM8] = unpack_A_UNORM8; + table[MESA_FORMAT_A_UNORM16] = unpack_A_UNORM16; + table[MESA_FORMAT_L_UNORM8] = unpack_L_UNORM8; + table[MESA_FORMAT_L_UNORM16] = unpack_L_UNORM16; + table[MESA_FORMAT_I_UNORM8] = unpack_I_UNORM8; + table[MESA_FORMAT_I_UNORM16] = unpack_I_UNORM16; table[MESA_FORMAT_YCBCR] = unpack_YCBCR; table[MESA_FORMAT_YCBCR_REV] = unpack_YCBCR_REV; - table[MESA_FORMAT_R_UNORM8] = unpack_R8; - table[MESA_FORMAT_R8G8_UNORM] = unpack_GR88; - table[MESA_FORMAT_G8R8_UNORM] = unpack_RG88; - table[MESA_FORMAT_R_UNORM16] = unpack_R16; - table[MESA_FORMAT_R16G16_UNORM] = unpack_GR1616; - table[MESA_FORMAT_G16R16_UNORM] = unpack_RG1616; - table[MESA_FORMAT_B10G10R10A2_UNORM] = unpack_ARGB2101010; - table[MESA_FORMAT_B10G10R10A2_UINT] = unpack_ARGB2101010_UINT; - table[MESA_FORMAT_R10G10B10A2_UINT] = unpack_ABGR2101010_UINT; + table[MESA_FORMAT_R_UNORM8] = unpack_R_UNORM8; + table[MESA_FORMAT_R8G8_UNORM] = unpack_R8G8_UNORM; + table[MESA_FORMAT_G8R8_UNORM] = unpack_G8R8_UNORM; + table[MESA_FORMAT_R_UNORM16] = unpack_R_UNORM16; + table[MESA_FORMAT_R16G16_UNORM] = unpack_R16G16_UNORM; + table[MESA_FORMAT_G16R16_UNORM] = unpack_G16R16_UNORM; + table[MESA_FORMAT_B10G10R10A2_UNORM] = unpack_B10G10R10A2_UNORM; + table[MESA_FORMAT_B10G10R10A2_UINT] = unpack_B10G10R10A2_UINT; + table[MESA_FORMAT_R10G10B10A2_UINT] = unpack_R10G10B10A2_UINT; table[MESA_FORMAT_S8_UINT_Z24_UNORM] = unpack_Z24_S8; table[MESA_FORMAT_Z24_UNORM_S8_UINT] = unpack_S8_Z24; table[MESA_FORMAT_Z_UNORM16] = unpack_Z16; @@ -2398,12 +2398,12 @@ get_unpack_rgba_function(mesa_format format) table[MESA_FORMAT_X8_UINT_Z24_UNORM] = unpack_Z24_X8; table[MESA_FORMAT_Z_UNORM32] = unpack_Z32; table[MESA_FORMAT_S_UINT8] = unpack_S8; - table[MESA_FORMAT_BGR_SRGB8] = unpack_SRGB8; - table[MESA_FORMAT_A8B8G8R8_SRGB] = unpack_SRGBA8; - table[MESA_FORMAT_B8G8R8A8_SRGB] = unpack_SARGB8; - table[MESA_FORMAT_R8G8B8A8_SRGB] = unpack_SABGR8; - table[MESA_FORMAT_L_SRGB8] = unpack_SL8; - table[MESA_FORMAT_L8A8_SRGB] = unpack_SLA8; + table[MESA_FORMAT_BGR_SRGB8] = unpack_BGR_SRGB8; + table[MESA_FORMAT_A8B8G8R8_SRGB] = unpack_A8B8G8R8_SRGB; + table[MESA_FORMAT_B8G8R8A8_SRGB] = unpack_B8G8R8A8_SRGB; + table[MESA_FORMAT_R8G8B8A8_SRGB] = unpack_R8G8B8A8_SRGB; + table[MESA_FORMAT_L_SRGB8] = unpack_L_SRGB8; + table[MESA_FORMAT_L8A8_SRGB] = unpack_L8A8_SRGB; table[MESA_FORMAT_SRGB_DXT1] = unpack_SRGB_DXT1; table[MESA_FORMAT_SRGBA_DXT1] = unpack_SRGBA_DXT1; table[MESA_FORMAT_SRGBA_DXT3] = unpack_SRGBA_DXT3; @@ -2420,14 +2420,14 @@ get_unpack_rgba_function(mesa_format format) table[MESA_FORMAT_RGBA_FLOAT16] = unpack_RGBA_FLOAT16; table[MESA_FORMAT_RGB_FLOAT32] = unpack_RGB_FLOAT32; table[MESA_FORMAT_RGB_FLOAT16] = unpack_RGB_FLOAT16; - table[MESA_FORMAT_A_FLOAT32] = unpack_ALPHA_FLOAT32; - table[MESA_FORMAT_A_FLOAT16] = unpack_ALPHA_FLOAT16; - table[MESA_FORMAT_L_FLOAT32] = unpack_LUMINANCE_FLOAT32; - table[MESA_FORMAT_L_FLOAT16] = unpack_LUMINANCE_FLOAT16; - table[MESA_FORMAT_LA_FLOAT32] = unpack_LUMINANCE_ALPHA_FLOAT32; - table[MESA_FORMAT_LA_FLOAT16] = unpack_LUMINANCE_ALPHA_FLOAT16; - table[MESA_FORMAT_I_FLOAT32] = unpack_INTENSITY_FLOAT32; - table[MESA_FORMAT_I_FLOAT16] = unpack_INTENSITY_FLOAT16; + table[MESA_FORMAT_A_FLOAT32] = unpack_A_FLOAT32; + table[MESA_FORMAT_A_FLOAT16] = unpack_A_FLOAT16; + table[MESA_FORMAT_L_FLOAT32] = unpack_L_FLOAT32; + table[MESA_FORMAT_L_FLOAT16] = unpack_L_FLOAT16; + table[MESA_FORMAT_LA_FLOAT32] = unpack_LA_FLOAT32; + table[MESA_FORMAT_LA_FLOAT16] = unpack_LA_FLOAT16; + table[MESA_FORMAT_I_FLOAT32] = unpack_I_FLOAT32; + table[MESA_FORMAT_I_FLOAT16] = unpack_I_FLOAT16; table[MESA_FORMAT_R_FLOAT32] = unpack_R_FLOAT32; table[MESA_FORMAT_R_FLOAT16] = unpack_R_FLOAT16; table[MESA_FORMAT_RG_FLOAT32] = unpack_RG_FLOAT32; @@ -2487,15 +2487,15 @@ get_unpack_rgba_function(mesa_format format) table[MESA_FORMAT_RGBA_UINT32] = unpack_RGBA_UINT32; table[MESA_FORMAT_DUDV8] = unpack_DUDV8; - table[MESA_FORMAT_R_SNORM8] = unpack_SIGNED_R8; - table[MESA_FORMAT_R8G8_SNORM] = unpack_SIGNED_RG88_REV; - table[MESA_FORMAT_X8B8G8R8_SNORM] = unpack_SIGNED_RGBX8888; - table[MESA_FORMAT_A8B8G8R8_SNORM] = unpack_SIGNED_RGBA8888; - table[MESA_FORMAT_R8G8B8A8_SNORM] = unpack_SIGNED_RGBA8888_REV; - table[MESA_FORMAT_R_SNORM16] = unpack_SIGNED_R16; - table[MESA_FORMAT_R16G16_SNORM] = unpack_SIGNED_GR1616; - table[MESA_FORMAT_RGB_SNORM16] = unpack_SIGNED_RGB_16; - table[MESA_FORMAT_RGBA_SNORM16] = unpack_SIGNED_RGBA_16; + table[MESA_FORMAT_R_SNORM8] = unpack_R_SNORM8; + table[MESA_FORMAT_R8G8_SNORM] = unpack_R8G8_SNORM; + table[MESA_FORMAT_X8B8G8R8_SNORM] = unpack_X8B8G8R8_SNORM; + table[MESA_FORMAT_A8B8G8R8_SNORM] = unpack_A8B8G8R8_SNORM; + table[MESA_FORMAT_R8G8B8A8_SNORM] = unpack_R8G8B8A8_SNORM; + table[MESA_FORMAT_R_SNORM16] = unpack_R_SNORM16; + table[MESA_FORMAT_R16G16_SNORM] = unpack_R16G16_SNORM; + table[MESA_FORMAT_RGB_SNORM16] = unpack_RGB_SNORM16; + table[MESA_FORMAT_RGBA_SNORM16] = unpack_RGBA_SNORM16; table[MESA_FORMAT_RGBA_UNORM16] = unpack_RGBA_16; table[MESA_FORMAT_R_RGTC1_UNORM] = unpack_RED_RGTC1; @@ -2521,17 +2521,17 @@ get_unpack_rgba_function(mesa_format format) unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1; table[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1] = unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1; - table[MESA_FORMAT_A_SNORM8] = unpack_SIGNED_A8; - table[MESA_FORMAT_L_SNORM8] = unpack_SIGNED_L8; - table[MESA_FORMAT_L8A8_SNORM] = unpack_SIGNED_AL88; - table[MESA_FORMAT_I_SNORM8] = unpack_SIGNED_I8; - table[MESA_FORMAT_A_SNORM16] = unpack_SIGNED_A16; - table[MESA_FORMAT_L_SNORM16] = unpack_SIGNED_L16; - table[MESA_FORMAT_LA_SNORM16] = unpack_SIGNED_AL1616; - table[MESA_FORMAT_I_SNORM16] = unpack_SIGNED_I16; - - table[MESA_FORMAT_R9G9B9E5_FLOAT] = unpack_RGB9_E5_FLOAT; - table[MESA_FORMAT_R11G11B10_FLOAT] = unpack_R11_G11_B10_FLOAT; + table[MESA_FORMAT_A_SNORM8] = unpack_A_SNORM8; + table[MESA_FORMAT_L_SNORM8] = unpack_L_SNORM8; + table[MESA_FORMAT_L8A8_SNORM] = unpack_L8A8_SNORM; + table[MESA_FORMAT_I_SNORM8] = unpack_I_SNORM8; + table[MESA_FORMAT_A_SNORM16] = unpack_A_SNORM16; + table[MESA_FORMAT_L_SNORM16] = unpack_L_SNORM16; + table[MESA_FORMAT_LA_SNORM16] = unpack_LA_SNORM16; + table[MESA_FORMAT_I_SNORM16] = unpack_I_SNORM16; + + table[MESA_FORMAT_R9G9B9E5_FLOAT] = unpack_R9G9B9E5_FLOAT; + table[MESA_FORMAT_R11G11B10_FLOAT] = unpack_R11G11B10_FLOAT; table[MESA_FORMAT_Z_FLOAT32] = unpack_Z32_FLOAT; table[MESA_FORMAT_Z32_FLOAT_S8X24_UINT] = unpack_Z32_FLOAT_X24S8; @@ -2539,25 +2539,25 @@ get_unpack_rgba_function(mesa_format format) table[MESA_FORMAT_B4G4R4X4_UNORM] = unpack_XRGB4444_UNORM; table[MESA_FORMAT_B5G5R5X1_UNORM] = unpack_XRGB1555_UNORM; table[MESA_FORMAT_R8G8B8X8_SNORM] = unpack_XBGR8888_SNORM; - table[MESA_FORMAT_R8G8B8X8_SRGB] = unpack_XBGR8888_SRGB; + table[MESA_FORMAT_R8G8B8X8_SRGB] = unpack_R8G8B8X8_SRGB; table[MESA_FORMAT_RGBX_UINT8] = unpack_XBGR8888_UINT; table[MESA_FORMAT_RGBX_SINT8] = unpack_XBGR8888_SINT; - table[MESA_FORMAT_B10G10R10X2_UNORM] = unpack_XRGB2101010_UNORM; - table[MESA_FORMAT_RGBX_UNORM16] = unpack_XBGR16161616_UNORM; - table[MESA_FORMAT_RGBX_SNORM16] = unpack_XBGR16161616_SNORM; + table[MESA_FORMAT_B10G10R10X2_UNORM] = unpack_B10G10R10X2_UNORM; + table[MESA_FORMAT_RGBX_UNORM16] = unpack_RGBX_UNORM16; + table[MESA_FORMAT_RGBX_SNORM16] = unpack_RGBX_SNORM16; table[MESA_FORMAT_RGBX_FLOAT16] = unpack_XBGR16161616_FLOAT; table[MESA_FORMAT_RGBX_UINT16] = unpack_XBGR16161616_UINT; table[MESA_FORMAT_RGBX_SINT16] = unpack_XBGR16161616_SINT; - table[MESA_FORMAT_RGBX_FLOAT32] = unpack_XBGR32323232_FLOAT; + table[MESA_FORMAT_RGBX_FLOAT32] = unpack_RGBX_FLOAT32; table[MESA_FORMAT_RGBX_UINT32] = unpack_XBGR32323232_UINT; table[MESA_FORMAT_RGBX_SINT32] = unpack_XBGR32323232_SINT; - table[MESA_FORMAT_R10G10B10A2_UNORM] = unpack_ABGR2101010; + table[MESA_FORMAT_R10G10B10A2_UNORM] = unpack_R10G10B10A2_UNORM; - table[MESA_FORMAT_G8R8_SNORM] = unpack_SIGNED_RG88; - table[MESA_FORMAT_G16R16_SNORM] = unpack_SIGNED_RG1616; + table[MESA_FORMAT_G8R8_SNORM] = unpack_G8R8_SNORM; + table[MESA_FORMAT_G16R16_SNORM] = unpack_G16R16_SNORM; - table[MESA_FORMAT_B8G8R8X8_SRGB] = unpack_XRGB8888_SRGB; + table[MESA_FORMAT_B8G8R8X8_SRGB] = unpack_B8G8R8X8_SRGB; initialized = GL_TRUE; } @@ -2589,7 +2589,7 @@ _mesa_unpack_rgba_row(mesa_format format, GLuint n, static void -unpack_ubyte_RGBA8888(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_A8B8G8R8_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -2602,7 +2602,7 @@ unpack_ubyte_RGBA8888(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_RGBA8888_REV(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_R8G8B8A8_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -2615,7 +2615,7 @@ unpack_ubyte_RGBA8888_REV(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_ARGB8888(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_B8G8R8A8_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -2628,7 +2628,7 @@ unpack_ubyte_ARGB8888(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_ARGB8888_REV(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_A8R8G8B8_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -2667,7 +2667,7 @@ unpack_ubyte_RGBX8888_REV(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_XRGB8888(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_B8G8R8X8_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -2680,7 +2680,7 @@ unpack_ubyte_XRGB8888(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_XRGB8888_REV(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_X8R8G8B8_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -2693,7 +2693,7 @@ unpack_ubyte_XRGB8888_REV(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_RGB888(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_BGR_UNORM8(const void *src, GLubyte dst[][4], GLuint n) { const GLubyte *s = (const GLubyte *) src; GLuint i; @@ -2706,7 +2706,7 @@ unpack_ubyte_RGB888(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_BGR888(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_RGB_UNORM8(const void *src, GLubyte dst[][4], GLuint n) { const GLubyte *s = (const GLubyte *) src; GLuint i; @@ -2719,7 +2719,7 @@ unpack_ubyte_BGR888(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_RGB565(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_B5G6R5_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -2732,7 +2732,7 @@ unpack_ubyte_RGB565(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_RGB565_REV(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_R5G6B5_UNORM(const void *src, GLubyte dst[][4], GLuint n) { /* Warning: this function does not match the current Mesa definition * of MESA_FORMAT_R5G6B5_UNORM. @@ -2749,7 +2749,7 @@ unpack_ubyte_RGB565_REV(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_ARGB4444(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_B4G4R4A4_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -2762,7 +2762,7 @@ unpack_ubyte_ARGB4444(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_ARGB4444_REV(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_A4R4G4B4_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -2775,7 +2775,7 @@ unpack_ubyte_ARGB4444_REV(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_RGBA5551(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_A1B5G5R5_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -2788,7 +2788,7 @@ unpack_ubyte_RGBA5551(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_ARGB1555(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_B5G5R5A1_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -2801,7 +2801,7 @@ unpack_ubyte_ARGB1555(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_ARGB1555_REV(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_A1R5G5B5_UNORM(const void *src, GLubyte dst[][4], GLuint n) { /* Warning: this function does not match the current Mesa definition * of MESA_FORMAT_A1R5G5B5_UNORM. @@ -2818,7 +2818,7 @@ unpack_ubyte_ARGB1555_REV(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_AL44(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_L4A4_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLubyte *s = ((const GLubyte *) src); GLuint i; @@ -2831,7 +2831,7 @@ unpack_ubyte_AL44(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_AL88(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_L8A8_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -2844,7 +2844,7 @@ unpack_ubyte_AL88(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_AL88_REV(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_A8L8_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -2857,7 +2857,7 @@ unpack_ubyte_AL88_REV(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_RGB332(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_B2G3R3_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLubyte *s = ((const GLubyte *) src); GLuint i; @@ -2870,7 +2870,7 @@ unpack_ubyte_RGB332(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_A8(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_A_UNORM8(const void *src, GLubyte dst[][4], GLuint n) { const GLubyte *s = ((const GLubyte *) src); GLuint i; @@ -2883,7 +2883,7 @@ unpack_ubyte_A8(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_L8(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_L_UNORM8(const void *src, GLubyte dst[][4], GLuint n) { const GLubyte *s = ((const GLubyte *) src); GLuint i; @@ -2897,7 +2897,7 @@ unpack_ubyte_L8(const void *src, GLubyte dst[][4], GLuint n) static void -unpack_ubyte_I8(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_I_UNORM8(const void *src, GLubyte dst[][4], GLuint n) { const GLubyte *s = ((const GLubyte *) src); GLuint i; @@ -2910,7 +2910,7 @@ unpack_ubyte_I8(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_R8(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_R_UNORM8(const void *src, GLubyte dst[][4], GLuint n) { const GLubyte *s = ((const GLubyte *) src); GLuint i; @@ -2923,7 +2923,7 @@ unpack_ubyte_R8(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_GR88(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_R8G8_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -2936,7 +2936,7 @@ unpack_ubyte_GR88(const void *src, GLubyte dst[][4], GLuint n) } static void -unpack_ubyte_RG88(const void *src, GLubyte dst[][4], GLuint n) +unpack_ubyte_G8R8_UNORM(const void *src, GLubyte dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -2959,16 +2959,16 @@ _mesa_unpack_ubyte_rgba_row(mesa_format format, GLuint n, { switch (format) { case MESA_FORMAT_A8B8G8R8_UNORM: - unpack_ubyte_RGBA8888(src, dst, n); + unpack_ubyte_A8B8G8R8_UNORM(src, dst, n); break; case MESA_FORMAT_R8G8B8A8_UNORM: - unpack_ubyte_RGBA8888_REV(src, dst, n); + unpack_ubyte_R8G8B8A8_UNORM(src, dst, n); break; case MESA_FORMAT_B8G8R8A8_UNORM: - unpack_ubyte_ARGB8888(src, dst, n); + unpack_ubyte_B8G8R8A8_UNORM(src, dst, n); break; case MESA_FORMAT_A8R8G8B8_UNORM: - unpack_ubyte_ARGB8888_REV(src, dst, n); + unpack_ubyte_A8R8G8B8_UNORM(src, dst, n); break; case MESA_FORMAT_X8B8G8R8_UNORM: unpack_ubyte_RGBX8888(src, dst, n); @@ -2977,67 +2977,67 @@ _mesa_unpack_ubyte_rgba_row(mesa_format format, GLuint n, unpack_ubyte_RGBX8888_REV(src, dst, n); break; case MESA_FORMAT_B8G8R8X8_UNORM: - unpack_ubyte_XRGB8888(src, dst, n); + unpack_ubyte_B8G8R8X8_UNORM(src, dst, n); break; case MESA_FORMAT_X8R8G8B8_UNORM: - unpack_ubyte_XRGB8888_REV(src, dst, n); + unpack_ubyte_X8R8G8B8_UNORM(src, dst, n); break; case MESA_FORMAT_BGR_UNORM8: - unpack_ubyte_RGB888(src, dst, n); + unpack_ubyte_BGR_UNORM8(src, dst, n); break; case MESA_FORMAT_RGB_UNORM8: - unpack_ubyte_BGR888(src, dst, n); + unpack_ubyte_RGB_UNORM8(src, dst, n); break; case MESA_FORMAT_B5G6R5_UNORM: - unpack_ubyte_RGB565(src, dst, n); + unpack_ubyte_B5G6R5_UNORM(src, dst, n); break; case MESA_FORMAT_R5G6B5_UNORM: - unpack_ubyte_RGB565_REV(src, dst, n); + unpack_ubyte_R5G6B5_UNORM(src, dst, n); break; case MESA_FORMAT_B4G4R4A4_UNORM: - unpack_ubyte_ARGB4444(src, dst, n); + unpack_ubyte_B4G4R4A4_UNORM(src, dst, n); break; case MESA_FORMAT_A4R4G4B4_UNORM: - unpack_ubyte_ARGB4444_REV(src, dst, n); + unpack_ubyte_A4R4G4B4_UNORM(src, dst, n); break; case MESA_FORMAT_A1B5G5R5_UNORM: - unpack_ubyte_RGBA5551(src, dst, n); + unpack_ubyte_A1B5G5R5_UNORM(src, dst, n); break; case MESA_FORMAT_B5G5R5A1_UNORM: - unpack_ubyte_ARGB1555(src, dst, n); + unpack_ubyte_B5G5R5A1_UNORM(src, dst, n); break; case MESA_FORMAT_A1R5G5B5_UNORM: - unpack_ubyte_ARGB1555_REV(src, dst, n); + unpack_ubyte_A1R5G5B5_UNORM(src, dst, n); break; case MESA_FORMAT_L4A4_UNORM: - unpack_ubyte_AL44(src, dst, n); + unpack_ubyte_L4A4_UNORM(src, dst, n); break; case MESA_FORMAT_L8A8_UNORM: - unpack_ubyte_AL88(src, dst, n); + unpack_ubyte_L8A8_UNORM(src, dst, n); break; case MESA_FORMAT_A8L8_UNORM: - unpack_ubyte_AL88_REV(src, dst, n); + unpack_ubyte_A8L8_UNORM(src, dst, n); break; case MESA_FORMAT_B2G3R3_UNORM: - unpack_ubyte_RGB332(src, dst, n); + unpack_ubyte_B2G3R3_UNORM(src, dst, n); break; case MESA_FORMAT_A_UNORM8: - unpack_ubyte_A8(src, dst, n); + unpack_ubyte_A_UNORM8(src, dst, n); break; case MESA_FORMAT_L_UNORM8: - unpack_ubyte_L8(src, dst, n); + unpack_ubyte_L_UNORM8(src, dst, n); break; case MESA_FORMAT_I_UNORM8: - unpack_ubyte_I8(src, dst, n); + unpack_ubyte_I_UNORM8(src, dst, n); break; case MESA_FORMAT_R_UNORM8: - unpack_ubyte_R8(src, dst, n); + unpack_ubyte_R_UNORM8(src, dst, n); break; case MESA_FORMAT_R8G8_UNORM: - unpack_ubyte_GR88(src, dst, n); + unpack_ubyte_R8G8_UNORM(src, dst, n); break; case MESA_FORMAT_G8R8_UNORM: - unpack_ubyte_RG88(src, dst, n); + unpack_ubyte_G8R8_UNORM(src, dst, n); break; default: /* get float values, convert to ubyte */ @@ -3123,7 +3123,7 @@ unpack_int_rgba_RGBA_INT8(const GLbyte *src, GLuint dst[][4], GLuint n) } static void -unpack_int_rgba_ARGB8888(const GLbyte *src, GLuint dst[][4], GLuint n) +unpack_int_rgba_B8G8R8A8_UNORM(const GLbyte *src, GLuint dst[][4], GLuint n) { unsigned int i; @@ -3136,7 +3136,7 @@ unpack_int_rgba_ARGB8888(const GLbyte *src, GLuint dst[][4], GLuint n) } static void -unpack_int_rgba_XRGB8888(const GLbyte *src, GLuint dst[][4], GLuint n) +unpack_int_rgba_B8G8R8X8_UNORM(const GLbyte *src, GLuint dst[][4], GLuint n) { unsigned int i; @@ -3560,7 +3560,7 @@ unpack_int_rgba_INTENSITY_INT8(const GLbyte *src, GLuint dst[][4], GLuint n) } static void -unpack_int_rgba_ARGB2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n) +unpack_int_rgba_B10G10R10A2_UINT(const GLuint *src, GLuint dst[][4], GLuint n) { unsigned int i; @@ -3574,7 +3574,7 @@ unpack_int_rgba_ARGB2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n) } static void -unpack_int_rgba_ABGR2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n) +unpack_int_rgba_R10G10B10A2_UINT(const GLuint *src, GLuint dst[][4], GLuint n) { unsigned int i; @@ -3588,7 +3588,7 @@ unpack_int_rgba_ABGR2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n) } static void -unpack_int_rgba_ARGB2101010(const GLuint *src, GLuint dst[][4], GLuint n) +unpack_int_rgba_B10G10R10A2_UNORM(const GLuint *src, GLuint dst[][4], GLuint n) { unsigned int i; @@ -3667,7 +3667,7 @@ unpack_int_rgba_XBGR32323232_UINT(const GLuint *src, GLuint dst[][4], GLuint n) } static void -unpack_int_rgba_ABGR2101010(const GLuint *src, GLuint dst[][4], GLuint n) +unpack_int_rgba_R10G10B10A2_UNORM(const GLuint *src, GLuint dst[][4], GLuint n) { unsigned int i; @@ -3708,11 +3708,11 @@ _mesa_unpack_uint_rgba_row(mesa_format format, GLuint n, break; case MESA_FORMAT_B8G8R8A8_UNORM: - unpack_int_rgba_ARGB8888(src, dst, n); + unpack_int_rgba_B8G8R8A8_UNORM(src, dst, n); break; case MESA_FORMAT_B8G8R8X8_UNORM: - unpack_int_rgba_XRGB8888(src, dst, n); + unpack_int_rgba_B8G8R8X8_UNORM(src, dst, n); break; case MESA_FORMAT_RGB_UINT32: @@ -3848,15 +3848,15 @@ _mesa_unpack_uint_rgba_row(mesa_format format, GLuint n, break; case MESA_FORMAT_B10G10R10A2_UINT: - unpack_int_rgba_ARGB2101010_UINT(src, dst, n); + unpack_int_rgba_B10G10R10A2_UINT(src, dst, n); break; case MESA_FORMAT_R10G10B10A2_UINT: - unpack_int_rgba_ABGR2101010_UINT(src, dst, n); + unpack_int_rgba_R10G10B10A2_UINT(src, dst, n); break; case MESA_FORMAT_B10G10R10A2_UNORM: - unpack_int_rgba_ARGB2101010(src, dst, n); + unpack_int_rgba_B10G10R10A2_UNORM(src, dst, n); break; case MESA_FORMAT_RGBX_UINT8: @@ -3881,7 +3881,7 @@ _mesa_unpack_uint_rgba_row(mesa_format format, GLuint n, break; case MESA_FORMAT_R10G10B10A2_UNORM: - unpack_int_rgba_ABGR2101010(src, dst, n); + unpack_int_rgba_R10G10B10A2_UNORM(src, dst, n); break; default: @@ -3963,7 +3963,7 @@ unpack_float_z_X8_Z24(GLuint n, const void *src, GLfloat *dst) } static void -unpack_float_z_Z16(GLuint n, const void *src, GLfloat *dst) +unpack_float_Z_UNORM16(GLuint n, const void *src, GLfloat *dst) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -3973,7 +3973,7 @@ unpack_float_z_Z16(GLuint n, const void *src, GLfloat *dst) } static void -unpack_float_z_Z32(GLuint n, const void *src, GLfloat *dst) +unpack_float_Z_UNORM32(GLuint n, const void *src, GLfloat *dst) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -4020,10 +4020,10 @@ _mesa_unpack_float_z_row(mesa_format format, GLuint n, unpack = unpack_float_z_X8_Z24; break; case MESA_FORMAT_Z_UNORM16: - unpack = unpack_float_z_Z16; + unpack = unpack_float_Z_UNORM16; break; case MESA_FORMAT_Z_UNORM32: - unpack = unpack_float_z_Z32; + unpack = unpack_float_Z_UNORM32; break; case MESA_FORMAT_Z_FLOAT32: unpack = unpack_float_z_Z32F; @@ -4067,7 +4067,7 @@ unpack_uint_z_X8_Z24(const void *src, GLuint *dst, GLuint n) } static void -unpack_uint_z_Z16(const void *src, GLuint *dst, GLuint n) +unpack_uint_Z_UNORM16(const void *src, GLuint *dst, GLuint n) { const GLushort *s = ((const GLushort *)src); GLuint i; @@ -4077,13 +4077,13 @@ unpack_uint_z_Z16(const void *src, GLuint *dst, GLuint n) } static void -unpack_uint_z_Z32(const void *src, GLuint *dst, GLuint n) +unpack_uint_Z_UNORM32(const void *src, GLuint *dst, GLuint n) { memcpy(dst, src, n * sizeof(GLuint)); } static void -unpack_uint_z_Z32_FLOAT(const void *src, GLuint *dst, GLuint n) +unpack_uint_Z_FLOAT32(const void *src, GLuint *dst, GLuint n) { const float *s = (const float *)src; GLuint i; @@ -4093,7 +4093,7 @@ unpack_uint_z_Z32_FLOAT(const void *src, GLuint *dst, GLuint n) } static void -unpack_uint_z_Z32_FLOAT_X24S8(const void *src, GLuint *dst, GLuint n) +unpack_uint_Z_FLOAT32_X24S8(const void *src, GLuint *dst, GLuint n) { const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src; GLuint i; @@ -4125,16 +4125,16 @@ _mesa_unpack_uint_z_row(mesa_format format, GLuint n, unpack = unpack_uint_z_X8_Z24; break; case MESA_FORMAT_Z_UNORM16: - unpack = unpack_uint_z_Z16; + unpack = unpack_uint_Z_UNORM16; break; case MESA_FORMAT_Z_UNORM32: - unpack = unpack_uint_z_Z32; + unpack = unpack_uint_Z_UNORM32; break; case MESA_FORMAT_Z_FLOAT32: - unpack = unpack_uint_z_Z32_FLOAT; + unpack = unpack_uint_Z_FLOAT32; break; case MESA_FORMAT_Z32_FLOAT_S8X24_UINT: - unpack = unpack_uint_z_Z32_FLOAT_X24S8; + unpack = unpack_uint_Z_FLOAT32_X24S8; break; default: _mesa_problem(NULL, "bad format %s in _mesa_unpack_uint_z_row", diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c index fb2501c69..4fb1f116b 100644 --- a/mesalib/src/mesa/main/formats.c +++ b/mesalib/src/mesa/main/formats.c @@ -3153,9 +3153,9 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, case MESA_FORMAT_L_UNORM16: return format == GL_LUMINANCE && type == GL_UNSIGNED_SHORT && !swapBytes; case MESA_FORMAT_I_UNORM8: - return format == GL_RED && type == GL_UNSIGNED_BYTE; + return format == GL_INTENSITY && type == GL_UNSIGNED_BYTE; case MESA_FORMAT_I_UNORM16: - return format == GL_RED && type == GL_UNSIGNED_SHORT && !swapBytes; + return format == GL_INTENSITY && type == GL_UNSIGNED_SHORT && !swapBytes; case MESA_FORMAT_YCBCR: return format == GL_YCBCR_MESA && @@ -3247,9 +3247,9 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, return format == GL_LUMINANCE_ALPHA && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_I_FLOAT32: - return format == GL_RED && type == GL_FLOAT && !swapBytes; + return format == GL_INTENSITY && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_I_FLOAT16: - return format == GL_RED && type == GL_HALF_FLOAT && !swapBytes; + return format == GL_INTENSITY && type == GL_HALF_FLOAT && !swapBytes; case MESA_FORMAT_R_FLOAT32: return format == GL_RED && type == GL_FLOAT && !swapBytes; @@ -3277,17 +3277,13 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, return format == GL_ALPHA_INTEGER && type == GL_INT && !swapBytes; case MESA_FORMAT_I_UINT8: - return format == GL_RED_INTEGER && type == GL_UNSIGNED_BYTE; case MESA_FORMAT_I_UINT16: - return format == GL_RED_INTEGER && type == GL_UNSIGNED_SHORT && !swapBytes; case MESA_FORMAT_I_UINT32: - return format == GL_RED_INTEGER && type == GL_UNSIGNED_INT && !swapBytes; case MESA_FORMAT_I_SINT8: - return format == GL_RED_INTEGER && type == GL_BYTE; case MESA_FORMAT_I_SINT16: - return format == GL_RED_INTEGER && type == GL_SHORT && !swapBytes; case MESA_FORMAT_I_SINT32: - return format == GL_RED_INTEGER && type == GL_INT && !swapBytes; + /* GL_INTENSITY_INTEGER_EXT doesn't exist. */ + return GL_FALSE; case MESA_FORMAT_L_UINT8: return format == GL_LUMINANCE_INTEGER_EXT && type == GL_UNSIGNED_BYTE; @@ -3454,7 +3450,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, return format == GL_LUMINANCE_ALPHA && type == GL_BYTE && littleEndian && !swapBytes; case MESA_FORMAT_I_SNORM8: - return format == GL_RED && type == GL_BYTE; + return format == GL_INTENSITY && type == GL_BYTE; case MESA_FORMAT_A_SNORM16: return format == GL_ALPHA && type == GL_SHORT && !swapBytes; case MESA_FORMAT_L_SNORM16: @@ -3463,7 +3459,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, return format == GL_LUMINANCE_ALPHA && type == GL_SHORT && littleEndian && !swapBytes; case MESA_FORMAT_I_SNORM16: - return format == GL_RED && type == GL_SHORT && littleEndian && + return format == GL_INTENSITY && type == GL_SHORT && littleEndian && !swapBytes; case MESA_FORMAT_B10G10R10A2_UINT: diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c index 88cf202df..6d9579008 100644 --- a/mesalib/src/mesa/main/get.c +++ b/mesalib/src/mesa/main/get.c @@ -387,6 +387,7 @@ EXTRA_EXT(ARB_texture_cube_map_array); EXTRA_EXT(ARB_texture_buffer_range); EXTRA_EXT(ARB_texture_multisample); EXTRA_EXT(ARB_texture_gather); +EXTRA_EXT(ARB_separate_shader_objects); EXTRA_EXT(ARB_shader_atomic_counters); EXTRA_EXT(ARB_draw_indirect); EXTRA_EXT(ARB_shader_image_load_store); @@ -873,6 +874,18 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu v->value_int = ctx->TransformFeedback.CurrentObject->Name; break; case GL_CURRENT_PROGRAM: + /* The Changelog of the ARB_separate_shader_objects spec says: + * + * 24 25 Jul 2011 pbrown Remove the language erroneously deleting + * CURRENT_PROGRAM. In the EXT extension, this + * token was aliased to ACTIVE_PROGRAM_EXT, and + * was used to indicate the last program set by + * either ActiveProgramEXT or UseProgram. In + * the ARB extension, the SSO active programs + * are now program pipeline object state and + * CURRENT_PROGRAM should still be used to query + * the last program set by UseProgram (bug 7822). + */ v->value_int = ctx->Shader.ActiveProgram ? ctx->Shader.ActiveProgram->Name : 0; break; @@ -1002,6 +1015,14 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu case GL_DRAW_INDIRECT_BUFFER_BINDING: v->value_int = ctx->DrawIndirectBuffer->Name; break; + /* GL_ARB_separate_shader_objects */ + case GL_PROGRAM_PIPELINE_BINDING: + if (ctx->Pipeline.Current) { + v->value_int = ctx->Pipeline.Current->Name; + } else { + v->value_int = 0; + } + break; } } diff --git a/mesalib/src/mesa/main/get_hash_params.py b/mesalib/src/mesa/main/get_hash_params.py index 674d0032a..06d0bbacc 100644 --- a/mesalib/src/mesa/main/get_hash_params.py +++ b/mesalib/src/mesa/main/get_hash_params.py @@ -726,6 +726,9 @@ descriptor=[ [ "MAX_PROGRAM_TEXTURE_GATHER_OFFSET", "CONTEXT_INT(Const.MaxProgramTextureGatherOffset), extra_ARB_texture_gather"], [ "MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB", "CONTEXT_INT(Const.MaxProgramTextureGatherComponents), extra_ARB_texture_gather"], +# GL_ARB_separate_shader_objects + [ "PROGRAM_PIPELINE_BINDING", "LOC_CUSTOM, TYPE_INT, GL_PROGRAM_PIPELINE_BINDING, extra_ARB_separate_shader_objects" ], + # GL_ARB_shader_atomic_counters [ "ATOMIC_COUNTER_BUFFER_BINDING", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_shader_atomic_counters" ], [ "MAX_ATOMIC_COUNTER_BUFFER_BINDINGS", "CONTEXT_INT(Const.MaxAtomicBufferBindings), extra_ARB_shader_atomic_counters" ], diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index c6d90c579..33cb88881 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -2807,6 +2807,10 @@ struct gl_pipeline_object GLbitfield Flags; /**< Mask of GLSL_x flags */ GLboolean EverBound; /**< Has the pipeline object been created */ + + GLboolean Validated; /**< Pipeline Validation status */ + + GLchar *InfoLog; }; /** @@ -2817,6 +2821,9 @@ struct gl_pipeline_shader_state /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */ struct gl_pipeline_object *Current; + /* Default Object to ensure that _Shader is never NULL */ + struct gl_pipeline_object *Default; + /** Pipeline objects */ struct _mesa_HashTable *Objects; }; @@ -4123,6 +4130,26 @@ struct gl_context struct gl_pipeline_shader_state Pipeline; /**< GLSL pipeline shader object state */ struct gl_pipeline_object Shader; /**< GLSL shader object state */ + + /** + * Current active shader pipeline state + * + * Almost all internal users want ::_Shader instead of ::Shader. The + * exceptions are bits of legacy GLSL API that do not know about separate + * shader objects. + * + * If a program is active via \c glUseProgram, this will point to + * \c ::Shader. + * + * If a program pipeline is active via \c glBindProgramPipeline, this will + * point to \c ::Pipeline.Current. + * + * If neither a program nor a program pipeline is active, this will point to + * \c ::Pipeline.Default. This ensures that \c ::_Shader will never be + * \c NULL. + */ + struct gl_pipeline_object *_Shader; + struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES]; struct gl_query_state Query; /**< occlusion, timer queries */ diff --git a/mesalib/src/mesa/main/pipelineobj.c b/mesalib/src/mesa/main/pipelineobj.c index 27012df72..f55251e06 100644 --- a/mesalib/src/mesa/main/pipelineobj.c +++ b/mesalib/src/mesa/main/pipelineobj.c @@ -80,6 +80,7 @@ _mesa_new_pipeline_object(struct gl_context *ctx, GLuint name) mtx_init(&obj->Mutex, mtx_plain); obj->RefCount = 1; obj->Flags = _mesa_get_shader_flags(); + obj->InfoLog = NULL; } return obj; @@ -94,6 +95,10 @@ _mesa_init_pipeline(struct gl_context *ctx) ctx->Pipeline.Objects = _mesa_NewHashTable(); ctx->Pipeline.Current = NULL; + + /* Install a default Pipeline */ + ctx->Pipeline.Default = _mesa_new_pipeline_object(ctx, 0); + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, ctx->Pipeline.Default); } @@ -117,6 +122,10 @@ _mesa_free_pipeline_data(struct gl_context *ctx) { _mesa_HashDeleteAll(ctx->Pipeline.Objects, delete_pipelineobj_cb, ctx); _mesa_DeleteHashTable(ctx->Pipeline.Objects); + + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, NULL); + _mesa_delete_pipeline_object(ctx, ctx->Pipeline.Default); + } /** @@ -214,6 +223,109 @@ _mesa_reference_pipeline_object_(struct gl_context *ctx, void GLAPIENTRY _mesa_UseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program) { + GET_CURRENT_CONTEXT(ctx); + + struct gl_pipeline_object *pipe = lookup_pipeline_object(ctx, pipeline); + struct gl_shader_program *shProg = NULL; + GLbitfield any_valid_stages; + + if (!pipe) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glUseProgramStages(pipeline)"); + return; + } + + /* Object is created by any Pipeline call but glGenProgramPipelines, + * glIsProgramPipeline and GetProgramPipelineInfoLog + */ + pipe->EverBound = GL_TRUE; + + /* Section 2.11.4 (Program Pipeline Objects) of the OpenGL 4.1 spec says: + * + * "If stages is not the special value ALL_SHADER_BITS, and has a bit + * set that is not recognized, the error INVALID_VALUE is generated." + * + * NOT YET SUPPORTED: + * GL_TESS_CONTROL_SHADER_BIT + * GL_TESS_EVALUATION_SHADER_BIT + */ + any_valid_stages = GL_VERTEX_SHADER_BIT | GL_FRAGMENT_SHADER_BIT; + if (_mesa_has_geometry_shaders(ctx)) + any_valid_stages |= GL_GEOMETRY_SHADER_BIT; + + if (stages != GL_ALL_SHADER_BITS && (stages & ~any_valid_stages) != 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glUseProgramStages(Stages)"); + return; + } + + /* Section 2.17.2 (Transform Feedback Primitive Capture) of the OpenGL 4.1 + * spec says: + * + * "The error INVALID_OPERATION is generated: + * + * ... + * + * - by UseProgramStages if the program pipeline object it refers + * to is current and the current transform feedback object is + * active and not paused; + */ + if (ctx->_Shader == pipe) { + if (_mesa_is_xfb_active_and_unpaused(ctx)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUseProgramStages(transform feedback active)"); + return; + } + } + + if (program) { + shProg = _mesa_lookup_shader_program_err(ctx, program, + "glUseProgramStages"); + if (shProg == NULL) + return; + + /* Section 2.11.4 (Program Pipeline Objects) of the OpenGL 4.1 spec + * says: + * + * "If the program object named by program was linked without the + * PROGRAM_SEPARABLE parameter set, or was not linked successfully, + * the error INVALID_OPERATION is generated and the corresponding + * shader stages in the pipeline program pipeline object are not + * modified." + */ + if (!shProg->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUseProgramStages(program not linked)"); + return; + } + + if (!shProg->SeparateShader) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUseProgramStages(program wasn't linked with the " + "PROGRAM_SEPARABLE flag)"); + return; + } + } + + /* Enable individual stages from the program as requested by the + * application. If there is no shader for a requested stage in the + * program, _mesa_use_shader_program will enable fixed-function processing + * as dictated by the spec. + * + * Section 2.11.4 (Program Pipeline Objects) of the OpenGL 4.1 spec + * says: + * + * "If UseProgramStages is called with program set to zero or with a + * program object that contains no executable code for the given + * stages, it is as if the pipeline object has no programmable stage + * configured for the indicated shader stages." + */ + if ((stages & GL_VERTEX_SHADER_BIT) != 0) + _mesa_use_shader_program(ctx, GL_VERTEX_SHADER, shProg, pipe); + + if ((stages & GL_FRAGMENT_SHADER_BIT) != 0) + _mesa_use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg, pipe); + + if ((stages & GL_GEOMETRY_SHADER_BIT) != 0) + _mesa_use_shader_program(ctx, GL_GEOMETRY_SHADER, shProg, pipe); } /** @@ -259,6 +371,75 @@ _mesa_ActiveShaderProgram(GLuint pipeline, GLuint program) void GLAPIENTRY _mesa_BindProgramPipeline(GLuint pipeline) { + GET_CURRENT_CONTEXT(ctx); + struct gl_pipeline_object *newObj = NULL; + + /* Rebinding the same pipeline object: no change. + */ + if (ctx->_Shader->Name == pipeline) + return; + + /* Section 2.17.2 (Transform Feedback Primitive Capture) of the OpenGL 4.1 + * spec says: + * + * "The error INVALID_OPERATION is generated: + * + * ... + * + * - by BindProgramPipeline if the current transform feedback + * object is active and not paused; + */ + if (_mesa_is_xfb_active_and_unpaused(ctx)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindProgramPipeline(transform feedback active)"); + return; + } + + /* Get pointer to new pipeline object (newObj) + */ + if (pipeline) { + /* non-default pipeline object */ + newObj = lookup_pipeline_object(ctx, pipeline); + if (!newObj) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindProgramPipeline(non-gen name)"); + return; + } + + /* Object is created by any Pipeline call but glGenProgramPipelines, + * glIsProgramPipeline and GetProgramPipelineInfoLog + */ + newObj->EverBound = GL_TRUE; + } + + /* First bind the Pipeline to pipeline binding point */ + _mesa_reference_pipeline_object(ctx, &ctx->Pipeline.Current, newObj); + + /* Section 2.11.3 (Program Objects) of the OpenGL 4.1 spec says: + * + * "If there is a current program object established by UseProgram, + * that program is considered current for all stages. Otherwise, if + * there is a bound program pipeline object (see section 2.11.4), the + * program bound to the appropriate stage of the pipeline object is + * considered current." + */ + if (&ctx->Shader != ctx->_Shader) { + if (pipeline) { + /* Bound the pipeline to the current program and + * restore the pipeline state + */ + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, newObj); + } else { + /* Unbind the pipeline */ + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, + ctx->Pipeline.Default); + } + + FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); + + if (ctx->Driver.UseProgram) + ctx->Driver.UseProgram(ctx, NULL); + } } /** @@ -393,14 +574,10 @@ _mesa_GetProgramPipelineiv(GLuint pipeline, GLenum pname, GLint *params) *params = pipe->ActiveProgram ? pipe->ActiveProgram->Name : 0; return; case GL_INFO_LOG_LENGTH: - /* FINISHME: Implement the info log. - */ - *params = 0; + *params = pipe->InfoLog ? strlen(pipe->InfoLog) + 1 : 0; return; case GL_VALIDATE_STATUS: - /* FINISHME: Implement validation status. - */ - *params = 0; + *params = pipe->Validated; return; case GL_VERTEX_SHADER: *params = pipe->CurrentProgram[MESA_SHADER_VERTEX] @@ -431,15 +608,222 @@ _mesa_GetProgramPipelineiv(GLuint pipeline, GLenum pname, GLint *params) } /** + * Determines whether every stage in a linked program is active in the + * specified pipeline. + */ +static bool +program_stages_all_active(struct gl_pipeline_object *pipe, + const struct gl_shader_program *prog) +{ + unsigned i; + bool status = true; + + if (!prog) + return true; + + for (i = 0; i < MESA_SHADER_STAGES; i++) { + if (prog->_LinkedShaders[i]) { + if (pipe->CurrentProgram[i]) { + if (prog->Name != pipe->CurrentProgram[i]->Name) { + status = false; + } + } else { + status = false; + } + } + } + + if (!status) { + pipe->InfoLog = ralloc_asprintf(pipe, + "Program %d is not active for all " + "shaders that was linked", + prog->Name); + } + + return status; +} + +extern GLboolean +_mesa_validate_program_pipeline(struct gl_context* ctx, + struct gl_pipeline_object *pipe, + GLboolean IsBound) +{ + unsigned i; + + pipe->Validated = GL_FALSE; + + /* Release and reset the info log. + */ + if (pipe->InfoLog != NULL) + ralloc_free(pipe->InfoLog); + + pipe->InfoLog = NULL; + + /* Section 2.11.11 (Shader Execution), subheading "Validation," of the + * OpenGL 4.1 spec says: + * + * "[INVALID_OPERATION] is generated by any command that transfers + * vertices to the GL if: + * + * - A program object is active for at least one, but not all of + * the shader stages that were present when the program was + * linked." + * + * For each possible program stage, verify that the program bound to that + * stage has all of its stages active. In other words, if the program + * bound to the vertex stage also has a fragment shader, the fragment + * shader must also be bound to the fragment stage. + */ + for (i = 0; i < MESA_SHADER_STAGES; i++) { + if (!program_stages_all_active(pipe, pipe->CurrentProgram[i])) { + goto err; + } + } + + /* Section 2.11.11 (Shader Execution), subheading "Validation," of the + * OpenGL 4.1 spec says: + * + * "[INVALID_OPERATION] is generated by any command that transfers + * vertices to the GL if: + * + * ... + * + * - One program object is active for at least two shader stages + * and a second program is active for a shader stage between two + * stages for which the first program was active." + * + * Without Tesselation, the only case where this can occur is the geometry + * shader between the fragment shader and vertex shader. + */ + if (pipe->CurrentProgram[MESA_SHADER_GEOMETRY] + && pipe->CurrentProgram[MESA_SHADER_FRAGMENT] + && pipe->CurrentProgram[MESA_SHADER_VERTEX]) { + if (pipe->CurrentProgram[MESA_SHADER_VERTEX]->Name == pipe->CurrentProgram[MESA_SHADER_FRAGMENT]->Name && + pipe->CurrentProgram[MESA_SHADER_GEOMETRY]->Name != pipe->CurrentProgram[MESA_SHADER_VERTEX]->Name) { + pipe->InfoLog = + ralloc_asprintf(pipe, + "Program %d is active for geometry stage between " + "two stages for which another program %d is " + "active", + pipe->CurrentProgram[MESA_SHADER_GEOMETRY]->Name, + pipe->CurrentProgram[MESA_SHADER_VERTEX]->Name); + goto err; + } + } + + /* Section 2.11.11 (Shader Execution), subheading "Validation," of the + * OpenGL 4.1 spec says: + * + * "[INVALID_OPERATION] is generated by any command that transfers + * vertices to the GL if: + * + * ... + * + * - There is an active program for tessellation control, + * tessellation evaluation, or geometry stages with corresponding + * executable shader, but there is no active program with + * executable vertex shader." + */ + if (!pipe->CurrentProgram[MESA_SHADER_VERTEX] + && pipe->CurrentProgram[MESA_SHADER_GEOMETRY]) { + pipe->InfoLog = ralloc_strdup(pipe, "Program lacks a vertex shader"); + goto err; + } + + /* Section 2.11.11 (Shader Execution), subheading "Validation," of the + * OpenGL 4.1 spec says: + * + * "[INVALID_OPERATION] is generated by any command that transfers + * vertices to the GL if: + * + * ... + * + * - There is no current program object specified by UseProgram, + * there is a current program pipeline object, and the current + * program for any shader stage has been relinked since being + * applied to the pipeline object via UseProgramStages with the + * PROGRAM_SEPARABLE parameter set to FALSE. + */ + for (i = 0; i < MESA_SHADER_STAGES; i++) { + if (pipe->CurrentProgram[i] && !pipe->CurrentProgram[i]->SeparateShader) { + pipe->InfoLog = ralloc_asprintf(pipe, + "Program %d was relinked without " + "PROGRAM_SEPARABLE state", + pipe->CurrentProgram[i]->Name); + goto err; + } + } + + /* Section 2.11.11 (Shader Execution), subheading "Validation," of the + * OpenGL 4.1 spec says: + * + * "[INVALID_OPERATION] is generated by any command that transfers + * vertices to the GL if: + * + * ... + * + * - Any two active samplers in the current program object are of + * different types, but refer to the same texture image unit. + * + * - The number of active samplers in the program exceeds the + * maximum number of texture image units allowed." + */ + if (!_mesa_sampler_uniforms_pipeline_are_valid(pipe)) + goto err; + + pipe->Validated = GL_TRUE; + return GL_TRUE; + +err: + if (IsBound) + _mesa_error(ctx, GL_INVALID_OPERATION, + "glValidateProgramPipeline failed to validate the pipeline"); + + return GL_FALSE; +} + +/** * Check compatibility of pipeline's program */ void GLAPIENTRY _mesa_ValidateProgramPipeline(GLuint pipeline) { + GET_CURRENT_CONTEXT(ctx); + + struct gl_pipeline_object *pipe = lookup_pipeline_object(ctx, pipeline); + + if (!pipe) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glValidateProgramPipeline(pipeline)"); + return; + } + + _mesa_validate_program_pipeline(ctx, pipe, + (ctx->_Shader->Name == pipe->Name)); } void GLAPIENTRY _mesa_GetProgramPipelineInfoLog(GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog) { + GET_CURRENT_CONTEXT(ctx); + + struct gl_pipeline_object *pipe = lookup_pipeline_object(ctx, pipeline); + + if (!pipe) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetProgramPipelineInfoLog(pipeline)"); + return; + } + + if (bufSize < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetProgramPipelineInfoLog(bufSize)"); + return; + } + + if (pipe->InfoLog) + _mesa_copy_string(infoLog, bufSize, length, pipe->InfoLog); + else + *length = 0; } diff --git a/mesalib/src/mesa/main/pipelineobj.h b/mesalib/src/mesa/main/pipelineobj.h index 46d5fab42..ceaf4f14c 100644 --- a/mesalib/src/mesa/main/pipelineobj.h +++ b/mesalib/src/mesa/main/pipelineobj.h @@ -59,6 +59,9 @@ _mesa_reference_pipeline_object(struct gl_context *ctx, _mesa_reference_pipeline_object_(ctx, ptr, obj); } +extern GLboolean +_mesa_validate_program_pipeline(struct gl_context * ctx, struct gl_pipeline_object *pipe, GLboolean IsBound); + extern void GLAPIENTRY _mesa_UseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program); diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c index 5060cbb0b..1c8e6b4cf 100644 --- a/mesalib/src/mesa/main/shaderapi.c +++ b/mesalib/src/mesa/main/shaderapi.c @@ -44,6 +44,7 @@ #include "main/hash.h" #include "main/hash_table.h" #include "main/mtypes.h" +#include "main/pipelineobj.h" #include "main/shaderapi.h" #include "main/shaderobj.h" #include "main/transformfeedback.h" @@ -144,6 +145,8 @@ _mesa_free_shader_state(struct gl_context *ctx) _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL); /* Extended for ARB_separate_shader_objects */ + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, NULL); + assert(ctx->Shader.RefCount == 1); mtx_destroy(&ctx->Shader.Mutex); } @@ -465,8 +468,8 @@ static GLuint get_handle(struct gl_context *ctx, GLenum pname) { if (pname == GL_PROGRAM_OBJECT_ARB) { - if (ctx->Shader.ActiveProgram) - return ctx->Shader.ActiveProgram->Name; + if (ctx->_Shader->ActiveProgram) + return ctx->_Shader->ActiveProgram->Name; else return 0; } @@ -837,7 +840,7 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj) */ sh->CompileStatus = GL_FALSE; } else { - if (ctx->Shader.Flags & GLSL_DUMP) { + if (ctx->_Shader->Flags & GLSL_DUMP) { fprintf(stderr, "GLSL source for %s shader %d:\n", _mesa_shader_stage_to_string(sh->Stage), sh->Name); fprintf(stderr, "%s\n", sh->Source); @@ -849,11 +852,11 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj) */ _mesa_glsl_compile_shader(ctx, sh, false, false); - if (ctx->Shader.Flags & GLSL_LOG) { + if (ctx->_Shader->Flags & GLSL_LOG) { _mesa_write_shader_to_file(sh); } - if (ctx->Shader.Flags & GLSL_DUMP) { + if (ctx->_Shader->Flags & GLSL_DUMP) { if (sh->CompileStatus) { fprintf(stderr, "GLSL IR for shader %d:\n", sh->Name); _mesa_print_ir(stderr, sh->ir, NULL); @@ -871,7 +874,7 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj) } if (!sh->CompileStatus) { - if (ctx->Shader.Flags & GLSL_DUMP_ON_ERROR) { + if (ctx->_Shader->Flags & GLSL_DUMP_ON_ERROR) { fprintf(stderr, "GLSL source for %s shader %d:\n", _mesa_shader_stage_to_string(sh->Stage), sh->Name); fprintf(stderr, "%s\n", sh->Source); @@ -879,7 +882,7 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj) fflush(stderr); } - if (ctx->Shader.Flags & GLSL_REPORT_ERRORS) { + if (ctx->_Shader->Flags & GLSL_REPORT_ERRORS) { _mesa_debug(ctx, "Error compiling shader %u:\n%s\n", sh->Name, sh->InfoLog); } @@ -915,7 +918,7 @@ link_program(struct gl_context *ctx, GLuint program) _mesa_glsl_link_shader(ctx, shProg); if (shProg->LinkStatus == GL_FALSE && - (ctx->Shader.Flags & GLSL_REPORT_ERRORS)) { + (ctx->_Shader->Flags & GLSL_REPORT_ERRORS)) { _mesa_debug(ctx, "Error linking program %u:\n%s\n", shProg->Name, shProg->InfoLog); } @@ -986,17 +989,21 @@ _mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg, */ static void use_shader_program(struct gl_context *ctx, GLenum type, - struct gl_shader_program *shProg) + struct gl_shader_program *shProg, + struct gl_pipeline_object *shTarget) { struct gl_shader_program **target; gl_shader_stage stage = _mesa_shader_enum_to_shader_stage(type); - target = &ctx->Shader.CurrentProgram[stage]; + target = &shTarget->CurrentProgram[stage]; if ((shProg == NULL) || (shProg->_LinkedShaders[stage] == NULL)) shProg = NULL; if (*target != shProg) { - FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); + /* Program is current, flush it */ + if (shTarget == ctx->_Shader) { + FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); + } /* If the shader is also bound as the current rendering shader, unbind * it from that binding point as well. This ensures that the correct @@ -1013,9 +1020,9 @@ use_shader_program(struct gl_context *ctx, GLenum type, /* Empty for now. */ break; case GL_FRAGMENT_SHADER: - if (*target == ctx->Shader._CurrentFragmentProgram) { + if (*target == ctx->_Shader->_CurrentFragmentProgram) { _mesa_reference_shader_program(ctx, - &ctx->Shader._CurrentFragmentProgram, + &ctx->_Shader->_CurrentFragmentProgram, NULL); } break; @@ -1032,10 +1039,10 @@ use_shader_program(struct gl_context *ctx, GLenum type, void _mesa_use_program(struct gl_context *ctx, struct gl_shader_program *shProg) { - use_shader_program(ctx, GL_VERTEX_SHADER, shProg); - use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, shProg); - use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg); - use_shader_program(ctx, GL_COMPUTE_SHADER, shProg); + use_shader_program(ctx, GL_VERTEX_SHADER, shProg, &ctx->Shader); + use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, shProg, &ctx->Shader); + use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg, &ctx->Shader); + use_shader_program(ctx, GL_COMPUTE_SHADER, shProg, &ctx->Shader); _mesa_active_program(ctx, shProg, "glUseProgram"); if (ctx->Driver.UseProgram) @@ -1533,7 +1540,7 @@ _mesa_UseProgram(GLhandleARB program) } /* debug code */ - if (ctx->Shader.Flags & GLSL_USE_PROG) { + if (ctx->_Shader->Flags & GLSL_USE_PROG) { print_shader_info(shProg); } } @@ -1541,7 +1548,31 @@ _mesa_UseProgram(GLhandleARB program) shProg = NULL; } - _mesa_use_program(ctx, shProg); + /* The "Dependencies on EXT_separate_shader_objects" section of the + * ARB_separate_shader_object spec says: + * + * "The executable code for an individual shader stage is taken from + * the current program for that stage. If there is a current program + * object for any shader stage or for uniform updates established by + * UseProgram, UseShaderProgramEXT, or ActiveProgramEXT, the current + * program for that stage (if any) is considered current. Otherwise, + * if there is a bound program pipeline object ..." + */ + if (program) { + /* Attach shader state to the binding point */ + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, &ctx->Shader); + /* Update the program */ + _mesa_use_program(ctx, shProg); + } else { + /* Must be done first: detach the progam */ + _mesa_use_program(ctx, shProg); + /* Unattach shader_state binding point */ + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, ctx->Pipeline.Default); + /* If a pipeline was bound, rebind it */ + if (ctx->Pipeline.Current) { + _mesa_BindProgramPipeline(ctx->Pipeline.Current->Name); + } + } } @@ -1773,9 +1804,10 @@ _mesa_ProgramParameteri(GLuint program, GLenum pname, GLint value) void _mesa_use_shader_program(struct gl_context *ctx, GLenum type, - struct gl_shader_program *shProg) + struct gl_shader_program *shProg, + struct gl_pipeline_object *shTarget) { - use_shader_program(ctx, type, shProg); + use_shader_program(ctx, type, shProg, shTarget); if (ctx->Driver.UseProgram) ctx->Driver.UseProgram(ctx, shProg); @@ -1815,7 +1847,41 @@ _mesa_UseShaderProgramEXT(GLenum type, GLuint program) } } - _mesa_use_shader_program(ctx, type, shProg); + /* The "Dependencies on EXT_separate_shader_objects" section of the + * ARB_separate_shader_object spec says: + * + * "The executable code for an individual shader stage is taken from + * the current program for that stage. If there is a current program + * object for any shader stage or for uniform updates established by + * UseProgram, UseShaderProgramEXT, or ActiveProgramEXT, the current + * program for that stage (if any) is considered current. Otherwise, + * if there is a bound program pipeline object ..." + */ + if (program) { + /* Attach shader state to the binding point */ + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, &ctx->Shader); + /* Update the program */ + _mesa_use_shader_program(ctx, type, shProg, ctx->_Shader); + } else { + /* Must be done first: detach the progam */ + _mesa_use_shader_program(ctx, type, shProg, ctx->_Shader); + + /* Nothing remains current */ + if (!ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX] && + !ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY] && + !ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT] && + !ctx->Shader.ActiveProgram) { + + /* Unattach shader_state binding point */ + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, + ctx->Pipeline.Default); + + /* If a pipeline was bound, rebind it */ + if (ctx->Pipeline.Current) { + _mesa_BindProgramPipeline(ctx->Pipeline.Current->Name); + } + } + } } @@ -1830,7 +1896,39 @@ _mesa_ActiveProgramEXT(GLuint program) ? _mesa_lookup_shader_program_err(ctx, program, "glActiveProgramEXT") : NULL; - _mesa_active_program(ctx, shProg, "glActiveProgramEXT"); + /* The "Dependencies on EXT_separate_shader_objects" section of the + * ARB_separate_shader_object spec says: + * + * "The executable code for an individual shader stage is taken from + * the current program for that stage. If there is a current program + * object for any shader stage or for uniform updates established by + * UseProgram, UseShaderProgramEXT, or ActiveProgramEXT, the current + * program for that stage (if any) is considered current. Otherwise, + * if there is a bound program pipeline object ..." + */ + if (shProg != NULL) { + /* Attach shader state to the binding point */ + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, &ctx->Shader); + _mesa_active_program(ctx, shProg, "glActiveProgramEXT"); + } else { + /* Must be done first: unset the current active progam */ + _mesa_active_program(ctx, shProg, "glActiveProgramEXT"); + + /* Nothing remains current */ + if (!ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX] && + !ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY] && + !ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT] && + !ctx->Shader.ActiveProgram) { + + /* Unattach shader_state binding point */ + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, ctx->Pipeline.Default); + /* If a pipeline was bound, rebind it */ + if (ctx->Pipeline.Current) { + _mesa_BindProgramPipeline(ctx->Pipeline.Current->Name); + } + } + } + return; } diff --git a/mesalib/src/mesa/main/shaderapi.h b/mesalib/src/mesa/main/shaderapi.h index 44426cc65..17b05b313 100644 --- a/mesalib/src/mesa/main/shaderapi.h +++ b/mesalib/src/mesa/main/shaderapi.h @@ -202,7 +202,8 @@ _mesa_ProgramParameteri(GLuint program, GLenum pname, GLint value); void _mesa_use_shader_program(struct gl_context *ctx, GLenum type, - struct gl_shader_program *shProg); + struct gl_shader_program *shProg, + struct gl_pipeline_object *shTarget); extern void GLAPIENTRY _mesa_UseShaderProgramEXT(GLenum type, GLuint program); diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c index 0866a140f..c122c16aa 100644 --- a/mesalib/src/mesa/main/state.c +++ b/mesalib/src/mesa/main/state.c @@ -95,11 +95,11 @@ static GLbitfield update_program(struct gl_context *ctx) { const struct gl_shader_program *vsProg = - ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]; + ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; const struct gl_shader_program *gsProg = - ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]; + ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]; struct gl_shader_program *fsProg = - ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]; + ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT]; const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current; const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current; const struct gl_geometry_program *prevGP = ctx->GeometryProgram._Current; @@ -125,7 +125,7 @@ update_program(struct gl_context *ctx) && fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]) { /* Use GLSL fragment shader */ _mesa_reference_shader_program(ctx, - &ctx->Shader._CurrentFragmentProgram, + &ctx->_Shader->_CurrentFragmentProgram, fsProg); _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, gl_fragment_program(fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program)); @@ -135,7 +135,7 @@ update_program(struct gl_context *ctx) else if (ctx->FragmentProgram._Enabled) { /* Use user-defined fragment program */ _mesa_reference_shader_program(ctx, - &ctx->Shader._CurrentFragmentProgram, + &ctx->_Shader->_CurrentFragmentProgram, NULL); _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, ctx->FragmentProgram.Current); @@ -147,7 +147,7 @@ update_program(struct gl_context *ctx) struct gl_shader_program *f = _mesa_get_fixed_func_fragment_program(ctx); _mesa_reference_shader_program(ctx, - &ctx->Shader._CurrentFragmentProgram, + &ctx->_Shader->_CurrentFragmentProgram, f); _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, gl_fragment_program(f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program)); @@ -310,7 +310,7 @@ update_multisample(struct gl_context *ctx) static void update_twoside(struct gl_context *ctx) { - if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX] || + if (ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] || ctx->VertexProgram._Enabled) { ctx->VertexProgram._TwoSideEnabled = ctx->VertexProgram.TwoSideEnabled; } else { diff --git a/mesalib/src/mesa/main/texstate.c b/mesalib/src/mesa/main/texstate.c index 08725f601..fcae878cf 100644 --- a/mesalib/src/mesa/main/texstate.c +++ b/mesalib/src/mesa/main/texstate.c @@ -532,9 +532,9 @@ update_texture_state( struct gl_context *ctx ) int i; for (i = 0; i < MESA_SHADER_STAGES; i++) { - if (ctx->Shader.CurrentProgram[i] && - ctx->Shader.CurrentProgram[i]->LinkStatus) { - prog[i] = ctx->Shader.CurrentProgram[i]->_LinkedShaders[i]->Program; + if (ctx->_Shader->CurrentProgram[i] && + ctx->_Shader->CurrentProgram[i]->LinkStatus) { + prog[i] = ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i]->Program; } else { if (i == MESA_SHADER_FRAGMENT && ctx->FragmentProgram._Enabled) prog[i] = &ctx->FragmentProgram.Current->Base; diff --git a/mesalib/src/mesa/main/transformfeedback.c b/mesalib/src/mesa/main/transformfeedback.c index 6b9565ca3..abeb25e87 100644 --- a/mesalib/src/mesa/main/transformfeedback.c +++ b/mesalib/src/mesa/main/transformfeedback.c @@ -388,8 +388,8 @@ get_xfb_source(struct gl_context *ctx) { int i; for (i = MESA_SHADER_GEOMETRY; i >= MESA_SHADER_VERTEX; i--) { - if (ctx->Shader.CurrentProgram[i] != NULL) - return ctx->Shader.CurrentProgram[i]; + if (ctx->_Shader->CurrentProgram[i] != NULL) + return ctx->_Shader->CurrentProgram[i]; } return NULL; } diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp index fa13ef9fe..5f1af0873 100644 --- a/mesalib/src/mesa/main/uniform_query.cpp +++ b/mesalib/src/mesa/main/uniform_query.cpp @@ -698,7 +698,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, return; } - if (ctx->Shader.Flags & GLSL_UNIFORMS) { + if (ctx->_Shader->Flags & GLSL_UNIFORMS) { log_uniform(values, basicType, components, 1, count, false, shProg, location, uni); } @@ -920,7 +920,7 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg, } } - if (ctx->Shader.Flags & GLSL_UNIFORMS) { + if (ctx->_Shader->Flags & GLSL_UNIFORMS) { log_uniform(values, GLSL_TYPE_FLOAT, components, vectors, count, bool(transpose), shProg, location, uni); } @@ -1089,3 +1089,80 @@ _mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg, return true; } + +extern "C" bool +_mesa_sampler_uniforms_pipeline_are_valid(struct gl_pipeline_object *pipeline) +{ + /* Section 2.11.11 (Shader Execution), subheading "Validation," of the + * OpenGL 4.1 spec says: + * + * "[INVALID_OPERATION] is generated by any command that transfers + * vertices to the GL if: + * + * ... + * + * - Any two active samplers in the current program object are of + * different types, but refer to the same texture image unit. + * + * - The number of active samplers in the program exceeds the + * maximum number of texture image units allowed." + */ + unsigned active_samplers = 0; + const struct gl_shader_program **shProg = + (const struct gl_shader_program **) pipeline->CurrentProgram; + + const glsl_type *unit_types[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; + memset(unit_types, 0, sizeof(unit_types)); + + for (unsigned idx = 0; idx < ARRAY_SIZE(pipeline->CurrentProgram); idx++) { + if (!shProg[idx]) + continue; + + for (unsigned i = 0; i < shProg[idx]->NumUserUniformStorage; i++) { + const struct gl_uniform_storage *const storage = + &shProg[idx]->UniformStorage[i]; + const glsl_type *const t = (storage->type->is_array()) + ? storage->type->fields.array : storage->type; + + if (!t->is_sampler()) + continue; + + active_samplers++; + + const unsigned count = MAX2(1, storage->type->array_size()); + for (unsigned j = 0; j < count; j++) { + const unsigned unit = storage->storage[j].i; + + /* The types of the samplers associated with a particular texture + * unit must be an exact match. Page 74 (page 89 of the PDF) of + * the OpenGL 3.3 core spec says: + * + * "It is not allowed to have variables of different sampler + * types pointing to the same texture image unit within a + * program object." + */ + if (unit_types[unit] == NULL) { + unit_types[unit] = t; + } else if (unit_types[unit] != t) { + pipeline->InfoLog = + ralloc_asprintf(pipeline, + "Texture unit %d is accessed both as %s " + "and %s", + unit, unit_types[unit]->name, t->name); + return false; + } + } + } + } + + if (active_samplers > MAX_COMBINED_TEXTURE_IMAGE_UNITS) { + pipeline->InfoLog = + ralloc_asprintf(pipeline, + "the number of active samplers %d exceed the " + "maximum %d", + active_samplers, MAX_COMBINED_TEXTURE_IMAGE_UNITS); + return false; + } + + return true; +} diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c index e9b374b0d..1daade428 100644 --- a/mesalib/src/mesa/main/uniforms.c +++ b/mesalib/src/mesa/main/uniforms.c @@ -137,7 +137,7 @@ void GLAPIENTRY _mesa_Uniform1f(GLint location, GLfloat v0) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_FLOAT); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GL_FLOAT); } void GLAPIENTRY @@ -147,7 +147,7 @@ _mesa_Uniform2f(GLint location, GLfloat v0, GLfloat v1) GLfloat v[2]; v[0] = v0; v[1] = v1; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC2); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_FLOAT_VEC2); } void GLAPIENTRY @@ -158,7 +158,7 @@ _mesa_Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) v[0] = v0; v[1] = v1; v[2] = v2; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC3); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_FLOAT_VEC3); } void GLAPIENTRY @@ -171,14 +171,14 @@ _mesa_Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, v[1] = v1; v[2] = v2; v[3] = v3; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_FLOAT_VEC4); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_FLOAT_VEC4); } void GLAPIENTRY _mesa_Uniform1i(GLint location, GLint v0) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_INT); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GL_INT); } void GLAPIENTRY @@ -188,7 +188,7 @@ _mesa_Uniform2i(GLint location, GLint v0, GLint v1) GLint v[2]; v[0] = v0; v[1] = v1; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC2); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_INT_VEC2); } void GLAPIENTRY @@ -199,7 +199,7 @@ _mesa_Uniform3i(GLint location, GLint v0, GLint v1, GLint v2) v[0] = v0; v[1] = v1; v[2] = v2; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC3); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_INT_VEC3); } void GLAPIENTRY @@ -211,63 +211,63 @@ _mesa_Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) v[1] = v1; v[2] = v2; v[3] = v3; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_INT_VEC4); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_INT_VEC4); } void GLAPIENTRY _mesa_Uniform1fv(GLint location, GLsizei count, const GLfloat * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT); } void GLAPIENTRY _mesa_Uniform2fv(GLint location, GLsizei count, const GLfloat * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC2); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT_VEC2); } void GLAPIENTRY _mesa_Uniform3fv(GLint location, GLsizei count, const GLfloat * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC3); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT_VEC3); } void GLAPIENTRY _mesa_Uniform4fv(GLint location, GLsizei count, const GLfloat * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_FLOAT_VEC4); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_FLOAT_VEC4); } void GLAPIENTRY _mesa_Uniform1iv(GLint location, GLsizei count, const GLint * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT); } void GLAPIENTRY _mesa_Uniform2iv(GLint location, GLsizei count, const GLint * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC2); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT_VEC2); } void GLAPIENTRY _mesa_Uniform3iv(GLint location, GLsizei count, const GLint * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC3); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT_VEC3); } void GLAPIENTRY _mesa_Uniform4iv(GLint location, GLsizei count, const GLint * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_INT_VEC4); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_INT_VEC4); } /** Same as above with direct state access **/ @@ -467,7 +467,7 @@ void GLAPIENTRY _mesa_Uniform1ui(GLint location, GLuint v0) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, &v0, GL_UNSIGNED_INT); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, &v0, GL_UNSIGNED_INT); } void GLAPIENTRY @@ -477,7 +477,7 @@ _mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1) GLuint v[2]; v[0] = v0; v[1] = v1; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC2); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC2); } void GLAPIENTRY @@ -488,7 +488,7 @@ _mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) v[0] = v0; v[1] = v1; v[2] = v2; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC3); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC3); } void GLAPIENTRY @@ -500,35 +500,35 @@ _mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) v[1] = v1; v[2] = v2; v[3] = v3; - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC4); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, 1, v, GL_UNSIGNED_INT_VEC4); } void GLAPIENTRY _mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT); } void GLAPIENTRY _mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC2); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC2); } void GLAPIENTRY _mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC3); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC3); } void GLAPIENTRY _mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform(ctx, ctx->Shader.ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC4); + _mesa_uniform(ctx, ctx->_Shader->ActiveProgram, location, count, value, GL_UNSIGNED_INT_VEC4); } @@ -538,7 +538,7 @@ _mesa_UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, 2, 2, location, count, transpose, value); } @@ -547,7 +547,7 @@ _mesa_UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, 3, 3, location, count, transpose, value); } @@ -556,7 +556,7 @@ _mesa_UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, 4, 4, location, count, transpose, value); } @@ -703,7 +703,7 @@ _mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, 2, 3, location, count, transpose, value); } @@ -712,7 +712,7 @@ _mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, 3, 2, location, count, transpose, value); } @@ -721,7 +721,7 @@ _mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, 2, 4, location, count, transpose, value); } @@ -730,7 +730,7 @@ _mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, 4, 2, location, count, transpose, value); } @@ -739,7 +739,7 @@ _mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, 3, 4, location, count, transpose, value); } @@ -748,7 +748,7 @@ _mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->Shader.ActiveProgram, + _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, 4, 3, location, count, transpose, value); } diff --git a/mesalib/src/mesa/main/uniforms.h b/mesalib/src/mesa/main/uniforms.h index d7afdc106..c8b555cbe 100644 --- a/mesalib/src/mesa/main/uniforms.h +++ b/mesalib/src/mesa/main/uniforms.h @@ -300,6 +300,8 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg, extern bool _mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg, char *errMsg, size_t errMsgLength); +extern bool +_mesa_sampler_uniforms_pipeline_are_valid(struct gl_pipeline_object *); extern const struct gl_program_parameter * get_uniform_parameter(struct gl_shader_program *shProg, GLint index); diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c index b4b6fa9be..b88d70018 100644 --- a/mesalib/src/mesa/main/varray.c +++ b/mesalib/src/mesa/main/varray.c @@ -1223,7 +1223,7 @@ _mesa_MultiDrawArrays( GLenum mode, const GLint *first, for (i = 0; i < primcount; i++) { if (count[i] > 0) { - CALL_DrawArrays(ctx->Exec, (mode, first[i], count[i])); + CALL_DrawArrays(ctx->CurrentDispatch, (mode, first[i], count[i])); } } } @@ -1243,7 +1243,7 @@ _mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, for ( i = 0 ; i < primcount ; i++ ) { if ( count[i] > 0 ) { GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); - CALL_DrawArrays(ctx->Exec, ( m, first[i], count[i] )); + CALL_DrawArrays(ctx->CurrentDispatch, ( m, first[i], count[i] )); } } } @@ -1265,7 +1265,8 @@ _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, for ( i = 0 ; i < primcount ; i++ ) { if ( count[i] > 0 ) { GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); - CALL_DrawElements(ctx->Exec, ( m, count[i], type, indices[i] )); + CALL_DrawElements(ctx->CurrentDispatch, ( m, count[i], type, + indices[i] )); } } } diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp index 9919874a6..95987107f 100644 --- a/mesalib/src/mesa/program/ir_to_mesa.cpp +++ b/mesalib/src/mesa/program/ir_to_mesa.cpp @@ -2917,7 +2917,7 @@ get_mesa_program(struct gl_context *ctx, set_branchtargets(&v, mesa_instructions, num_instructions); - if (ctx->Shader.Flags & GLSL_DUMP) { + if (ctx->_Shader->Flags & GLSL_DUMP) { fprintf(stderr, "\n"); fprintf(stderr, "GLSL IR for linked %s program %d:\n", target_string, shader_program->Name); @@ -2953,7 +2953,7 @@ get_mesa_program(struct gl_context *ctx, _mesa_reference_program(ctx, &shader->Program, prog); - if ((ctx->Shader.Flags & GLSL_NO_OPT) == 0) { + if ((ctx->_Shader->Flags & GLSL_NO_OPT) == 0) { _mesa_optimize_program(ctx, prog); } @@ -3096,7 +3096,7 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) } } - if (ctx->Shader.Flags & GLSL_DUMP) { + if (ctx->_Shader->Flags & GLSL_DUMP) { if (!prog->LinkStatus) { fprintf(stderr, "GLSL shader program %d failed to link\n", prog->Name); } diff --git a/mesalib/src/mesa/state_tracker/st_atom_clip.c b/mesalib/src/mesa/state_tracker/st_atom_clip.c index 274b36a62..f82c1332a 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_clip.c +++ b/mesalib/src/mesa/state_tracker/st_atom_clip.c @@ -52,7 +52,7 @@ static void update_clip( struct st_context *st ) /* if we have a vertex shader that writes clip vertex we need to pass the pre-projection transformed coordinates into the driver. */ if (st->vp) { - if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]) + if (ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]) use_eye = TRUE; } diff --git a/mesalib/src/mesa/state_tracker/st_atom_constbuf.c b/mesalib/src/mesa/state_tracker/st_atom_constbuf.c index a5013ed2c..7984bf742 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_constbuf.c +++ b/mesalib/src/mesa/state_tracker/st_atom_constbuf.c @@ -219,7 +219,7 @@ static void st_bind_ubos(struct st_context *st, static void bind_vs_ubos(struct st_context *st) { struct gl_shader_program *prog = - st->ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]; + st->ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; if (!prog) return; @@ -239,7 +239,7 @@ const struct st_tracked_state st_bind_vs_ubos = { static void bind_fs_ubos(struct st_context *st) { struct gl_shader_program *prog = - st->ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]; + st->ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT]; if (!prog) return; @@ -259,7 +259,7 @@ const struct st_tracked_state st_bind_fs_ubos = { static void bind_gs_ubos(struct st_context *st) { struct gl_shader_program *prog = - st->ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]; + st->ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]; if (!prog) return; diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c index 75e6face4..c9bffce4f 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_texture.c +++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c @@ -50,91 +50,165 @@ /** - * Combine depth texture mode with "swizzle" so that depth mode swizzling - * takes place before texture swizzling, and return the resulting swizzle. - * If the format is not a depth format, return "swizzle" unchanged. - * - * \param format PIPE_FORMAT_*. - * \param swizzle Texture swizzle, a bitmask computed using MAKE_SWIZZLE4. - * \param depthmode One of GL_LUMINANCE, GL_INTENSITY, GL_ALPHA, GL_RED. + * Return swizzle1(swizzle2) */ -static GLuint -apply_depthmode(enum pipe_format format, GLuint swizzle, GLenum depthmode) +static unsigned +swizzle_swizzle(unsigned swizzle1, unsigned swizzle2) { - const struct util_format_description *desc = - util_format_description(format); - unsigned char swiz[4]; - unsigned i; - - if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS || - desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_NONE) { - /* Not a depth format. */ - return swizzle; + unsigned i, swz[4]; + + for (i = 0; i < 4; i++) { + unsigned s = GET_SWZ(swizzle1, i); + switch (s) { + case SWIZZLE_X: + case SWIZZLE_Y: + case SWIZZLE_Z: + case SWIZZLE_W: + swz[i] = GET_SWZ(swizzle2, s); + break; + case SWIZZLE_ZERO: + swz[i] = SWIZZLE_ZERO; + break; + case SWIZZLE_ONE: + swz[i] = SWIZZLE_ONE; + break; + default: + assert(!"Bad swizzle term"); + swz[i] = SWIZZLE_X; + } } - for (i = 0; i < 4; i++) - swiz[i] = GET_SWZ(swizzle, i); + return MAKE_SWIZZLE4(swz[0], swz[1], swz[2], swz[3]); +} - switch (depthmode) { - case GL_LUMINANCE: - /* Rewrite reads from W to ONE, and reads from XYZ to XXX. */ - for (i = 0; i < 4; i++) - if (swiz[i] == SWIZZLE_W) - swiz[i] = SWIZZLE_ONE; - else if (swiz[i] < SWIZZLE_W) - swiz[i] = SWIZZLE_X; - break; +/** + * Given a user-specified texture base format, the actual gallium texture + * format and the current GL_DEPTH_MODE, return a texture swizzle. + * + * Consider the case where the user requests a GL_RGB internal texture + * format the driver actually uses an RGBA format. The A component should + * be ignored and sampling from the texture should always return (r,g,b,1). + * But if we rendered to the texture we might have written A values != 1. + * By sampling the texture with a ".xyz1" swizzle we'll get the expected A=1. + * This function computes the texture swizzle needed to get the expected + * values. + * + * In the case of depth textures, the GL_DEPTH_MODE state determines the + * texture swizzle. + * + * This result must be composed with the user-specified swizzle to get + * the final swizzle. + */ +static unsigned +compute_texture_format_swizzle(GLenum baseFormat, GLenum depthMode, + enum pipe_format actualFormat) +{ + switch (baseFormat) { + case GL_RGBA: + return SWIZZLE_XYZW; + case GL_RGB: + if (util_format_has_alpha(actualFormat)) + return MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ONE); + else + return SWIZZLE_XYZW; + case GL_RG: + if (util_format_get_nr_components(actualFormat) > 2) + return MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_ZERO, SWIZZLE_ONE); + else + return SWIZZLE_XYZW; + case GL_RED: + if (util_format_get_nr_components(actualFormat) > 1) + return MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_ZERO, + SWIZZLE_ZERO, SWIZZLE_ONE); + else + return SWIZZLE_XYZW; + case GL_ALPHA: + if (util_format_get_nr_components(actualFormat) > 1) + return MAKE_SWIZZLE4(SWIZZLE_ZERO, SWIZZLE_ZERO, + SWIZZLE_ZERO, SWIZZLE_W); + else + return SWIZZLE_XYZW; + case GL_LUMINANCE: + if (util_format_get_nr_components(actualFormat) > 1) + return MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_ONE); + else + return SWIZZLE_XYZW; + case GL_LUMINANCE_ALPHA: + if (util_format_get_nr_components(actualFormat) > 2) + return MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_W); + else + return SWIZZLE_XYZW; + case GL_INTENSITY: + if (util_format_get_nr_components(actualFormat) > 1) + return SWIZZLE_XXXX; + else + return SWIZZLE_XYZW; + case GL_STENCIL_INDEX: + return SWIZZLE_XYZW; + case GL_DEPTH_STENCIL: + /* fall-through */ + case GL_DEPTH_COMPONENT: + /* Now examine the depth mode */ + switch (depthMode) { + case GL_LUMINANCE: + return MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_ONE); case GL_INTENSITY: - /* Rewrite reads from XYZW to XXXX. */ - for (i = 0; i < 4; i++) - if (swiz[i] <= SWIZZLE_W) - swiz[i] = SWIZZLE_X; - break; - + return MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X); case GL_ALPHA: - /* Rewrite reads from W to X, and reads from XYZ to 000. */ - for (i = 0; i < 4; i++) - if (swiz[i] == SWIZZLE_W) - swiz[i] = SWIZZLE_X; - else if (swiz[i] < SWIZZLE_W) - swiz[i] = SWIZZLE_ZERO; - break; + return MAKE_SWIZZLE4(SWIZZLE_ZERO, SWIZZLE_ZERO, + SWIZZLE_ZERO, SWIZZLE_X); case GL_RED: - /* Rewrite reads W to 1, XYZ to X00 */ - for (i = 0; i < 4; i++) - if (swiz[i] == SWIZZLE_W) - swiz[i] = SWIZZLE_ONE; - else if (swiz[i] == SWIZZLE_Y || swiz[i] == SWIZZLE_Z) - swiz[i] = SWIZZLE_ZERO; - break; + return MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_ZERO, + SWIZZLE_ZERO, SWIZZLE_ONE); + default: + assert(!"Unexpected depthMode"); + return SWIZZLE_XYZW; + } + default: + assert(!"Unexpected baseFormat"); + return SWIZZLE_XYZW; } - - return MAKE_SWIZZLE4(swiz[0], swiz[1], swiz[2], swiz[3]); } +static unsigned +get_texture_format_swizzle(const struct st_texture_object *stObj) +{ + const struct gl_texture_image *texImage = + stObj->base.Image[0][stObj->base.BaseLevel]; + unsigned tex_swizzle; + + if (texImage) { + tex_swizzle = compute_texture_format_swizzle(texImage->_BaseFormat, + stObj->base.DepthMode, + stObj->pt->format); + } + else { + tex_swizzle = SWIZZLE_XYZW; + } + + /* Combine the texture format swizzle with user's swizzle */ + return swizzle_swizzle(stObj->base._Swizzle, tex_swizzle); +} + + /** - * Return TRUE if the swizzling described by "swizzle" and - * "depthmode" (for depth textures only) is different from the swizzling - * set in the given sampler view. + * Return TRUE if the texture's sampler view swizzle is equal to + * the texture's swizzle. * - * \param sv A sampler view. - * \param swizzle Texture swizzle, a bitmask computed using MAKE_SWIZZLE4. - * \param depthmode One of GL_LUMINANCE, GL_INTENSITY, GL_ALPHA. + * \param stObj the st texture object, */ static boolean -check_sampler_swizzle(struct pipe_sampler_view *sv, - GLuint swizzle, GLenum depthmode) +check_sampler_swizzle(const struct st_texture_object *stObj) { - swizzle = apply_depthmode(sv->texture->format, swizzle, depthmode); - - if ((sv->swizzle_r != GET_SWZ(swizzle, 0)) || - (sv->swizzle_g != GET_SWZ(swizzle, 1)) || - (sv->swizzle_b != GET_SWZ(swizzle, 2)) || - (sv->swizzle_a != GET_SWZ(swizzle, 3))) - return TRUE; - return FALSE; + const struct pipe_sampler_view *sv = stObj->sampler_view; + unsigned swizzle = get_texture_format_swizzle(stObj); + + return ((sv->swizzle_r != GET_SWZ(swizzle, 0)) || + (sv->swizzle_g != GET_SWZ(swizzle, 1)) || + (sv->swizzle_b != GET_SWZ(swizzle, 2)) || + (sv->swizzle_a != GET_SWZ(swizzle, 3))); } @@ -145,9 +219,7 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe, enum pipe_format format) { struct pipe_sampler_view templ; - GLuint swizzle = apply_depthmode(stObj->pt->format, - stObj->base._Swizzle, - stObj->base.DepthMode); + unsigned swizzle = get_texture_format_swizzle(stObj); u_sampler_view_default_template(&templ, stObj->pt, @@ -260,9 +332,7 @@ update_single_texture(struct st_context *st, /* if sampler view has changed dereference it */ if (stObj->sampler_view) { - if (check_sampler_swizzle(stObj->sampler_view, - stObj->base._Swizzle, - stObj->base.DepthMode) || + if (check_sampler_swizzle(stObj) || (view_format != stObj->sampler_view->format) || stObj->base.BaseLevel != stObj->sampler_view->u.tex.first_level) { pipe_sampler_view_release(pipe, &stObj->sampler_view); diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c index 2b3636151..6119cc275 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c @@ -1364,7 +1364,7 @@ blit_copy_pixels(struct gl_context *ctx, GLint srcx, GLint srcy, !ctx->Stencil.Enabled && !ctx->FragmentProgram.Enabled && !ctx->VertexProgram.Enabled && - !ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT] && + !ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT] && ctx->DrawBuffer->_NumColorDrawBuffers == 1 && !ctx->Query.CondRenderQuery && !ctx->Query.CurrentOcclusionObject) { diff --git a/mesalib/src/mesa/state_tracker/st_cb_queryobj.c b/mesalib/src/mesa/state_tracker/st_cb_queryobj.c index 5186a5157..78a737094 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_queryobj.c +++ b/mesalib/src/mesa/state_tracker/st_cb_queryobj.c @@ -141,7 +141,13 @@ st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q) stq->pq = pipe->create_query(pipe, type); stq->type = type; } - pipe->begin_query(pipe, stq->pq); + if (stq->pq) { + pipe->begin_query(pipe, stq->pq); + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBeginQuery"); + return; + } } assert(stq->type == type); } @@ -162,7 +168,8 @@ st_EndQuery(struct gl_context *ctx, struct gl_query_object *q) stq->type = PIPE_QUERY_TIMESTAMP; } - pipe->end_query(pipe, stq->pq); + if (stq->pq) + pipe->end_query(pipe, stq->pq); } @@ -171,6 +178,13 @@ get_query_result(struct pipe_context *pipe, struct st_query_object *stq, boolean wait) { + if (!stq->pq) { + /* Only needed in case we failed to allocate the gallium query earlier. + * Return TRUE so we don't spin on this forever. + */ + return TRUE; + } + if (!pipe->get_query_result(pipe, stq->pq, wait, diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c index 0ffc76263..807a86fdf 100644 --- a/mesalib/src/mesa/state_tracker/st_context.c +++ b/mesalib/src/mesa/state_tracker/st_context.c @@ -33,6 +33,7 @@ #include "main/shaderobj.h" #include "main/version.h" #include "main/vtxfmt.h" +#include "main/hash.h" #include "program/prog_cache.h" #include "vbo/vbo.h" #include "glapi/glapi.h" @@ -66,6 +67,7 @@ #include "st_gen_mipmap.h" #include "st_program.h" #include "st_vdpau.h" +#include "st_texture.h" #include "pipe/p_context.h" #include "util/u_inlines.h" #include "util/u_upload_mgr.h" @@ -280,6 +282,19 @@ static void st_destroy_context_priv( struct st_context *st ) free( st ); } + +/** + * Callback to release the sampler view attached to a texture object. + * Called by _mesa_HashWalk(). + */ +static void +destroy_tex_sampler_cb(GLuint id, void *data, void *userData) +{ + struct gl_texture_object *texObj = (struct gl_texture_object *) data; + struct st_context *st = (struct st_context *) userData; + + st_texture_release_sampler_view(st, st_texture_object(texObj)); +} void st_destroy_context( struct st_context *st ) { @@ -288,6 +303,8 @@ void st_destroy_context( struct st_context *st ) struct gl_context *ctx = st->ctx; GLuint i; + _mesa_HashWalk(ctx->Shared->TexObjects, destroy_tex_sampler_cb, st); + /* need to unbind and destroy CSO objects before anything else */ cso_release_all(st->cso_context); diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c index dba5870a0..c8189faad 100644 --- a/mesalib/src/mesa/state_tracker/st_draw.c +++ b/mesalib/src/mesa/state_tracker/st_draw.c @@ -131,7 +131,7 @@ setup_index_buffer(struct st_context *st, static void check_uniforms(struct gl_context *ctx) { - struct gl_shader_program **shProg = ctx->Shader.CurrentProgram; + struct gl_shader_program **shProg = ctx->_Shader->CurrentProgram; unsigned j; for (j = 0; j < 3; j++) { 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 a9e75d8a6..f019a55c2 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -5198,7 +5198,7 @@ get_mesa_program(struct gl_context *ctx, /* Write the END instruction. */ v->emit(NULL, TGSI_OPCODE_END); - if (ctx->Shader.Flags & GLSL_DUMP) { + if (ctx->_Shader->Flags & GLSL_DUMP) { printf("\n"); printf("GLSL IR for linked %s program %d:\n", _mesa_shader_stage_to_string(shader->Stage), diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c index 692a57008..2f0ec32f5 100644 --- a/mesalib/src/mesa/state_tracker/st_program.c +++ b/mesalib/src/mesa/state_tracker/st_program.c @@ -1204,7 +1204,7 @@ st_get_gp_variant(struct st_context *st, void st_print_shaders(struct gl_context *ctx) { - struct gl_shader_program **shProg = ctx->Shader.CurrentProgram; + struct gl_shader_program **shProg = ctx->_Shader->CurrentProgram; unsigned j; for (j = 0; j < 3; j++) { diff --git a/mesalib/src/mesa/state_tracker/st_texture.c b/mesalib/src/mesa/state_tracker/st_texture.c index b5ccc76d4..a3b345356 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.c +++ b/mesalib/src/mesa/state_tracker/st_texture.c @@ -412,3 +412,10 @@ st_create_color_map_texture(struct gl_context *ctx) return pt; } +void +st_texture_release_sampler_view(struct st_context *st, + struct st_texture_object *stObj) +{ + if (stObj->sampler_view && stObj->sampler_view->context == st->pipe) + pipe_sampler_view_reference(&stObj->sampler_view, NULL); +} diff --git a/mesalib/src/mesa/state_tracker/st_texture.h b/mesalib/src/mesa/state_tracker/st_texture.h index bce2a0934..b4a27a00a 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.h +++ b/mesalib/src/mesa/state_tracker/st_texture.h @@ -227,4 +227,8 @@ st_texture_image_copy(struct pipe_context *pipe, extern struct pipe_resource * st_create_color_map_texture(struct gl_context *ctx); +extern void +st_texture_release_sampler_view(struct st_context *st, + struct st_texture_object *stObj); + #endif diff --git a/mesalib/src/mesa/swrast/s_fragprog.c b/mesalib/src/mesa/swrast/s_fragprog.c index fa45fa97a..21699f3ea 100644 --- a/mesalib/src/mesa/swrast/s_fragprog.c +++ b/mesalib/src/mesa/swrast/s_fragprog.c @@ -182,7 +182,7 @@ init_machine(struct gl_context *ctx, struct gl_program_machine *machine, machine->Samplers = program->Base.SamplerUnits; /* if running a GLSL program (not ARB_fragment_program) */ - if (ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]) { + if (ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT]) { /* Store front/back facing value */ machine->Attribs[VARYING_SLOT_FACE][col][0] = 1.0F - span->facing; } diff --git a/xorg-server/dix/gc.c b/xorg-server/dix/gc.c index efe6d6090..88d650121 100644 --- a/xorg-server/dix/gc.c +++ b/xorg-server/dix/gc.c @@ -261,12 +261,14 @@ ChangeGC(ClientPtr client, GC * pGC, BITS32 mask, ChangeGCValPtr pUnion) case GCStipple: NEXT_PTR(PixmapPtr, pPixmap); - if ((pPixmap->drawable.depth != 1) || - (pPixmap->drawable.pScreen != pGC->pScreen)) { + if (pPixmap && ((pPixmap->drawable.depth != 1) || + (pPixmap->drawable.pScreen != pGC->pScreen))) + { error = BadMatch; } else { - pPixmap->refcnt++; + if (pPixmap) + pPixmap->refcnt++; if (pGC->stipple) (*pGC->pScreen->DestroyPixmap) (pGC->stipple); pGC->stipple = pPixmap; diff --git a/xorg-server/fb/fbblt.c b/xorg-server/fb/fbblt.c index 72a05f61a..c615106d1 100644 --- a/xorg-server/fb/fbblt.c +++ b/xorg-server/fb/fbblt.c @@ -56,42 +56,48 @@ fbBlt(FbBits * srcLine, int n, nmiddle; Bool destInvarient; int startbyte, endbyte; - int careful; FbDeclareMergeRop(); + if (alu == GXcopy && pm == FB_ALLONES && + !(srcX & 7) && !(dstX & 7) && !(width & 7)) + { + CARD8 *src_byte = (CARD8 *) srcLine + (srcX >> 3); + CARD8 *dst_byte = (CARD8 *) dstLine + (dstX >> 3); + FbStride src_byte_stride = srcStride << (FB_SHIFT - 3); + FbStride dst_byte_stride = dstStride << (FB_SHIFT - 3); + int width_byte = (width >> 3); + + /* Make sure there's no overlap; we can't use memcpy in that + * case as it's not well defined, so fall through to the + * general code + */ + if (src_byte + width_byte <= dst_byte || + dst_byte + width_byte <= src_byte) + { + int i; + + if (!upsidedown) + for (i = 0; i < height; i++) + MEMCPY_WRAPPED(dst_byte + i * dst_byte_stride, + src_byte + i * src_byte_stride, + width_byte); + else + for (i = height - 1; i >= 0; i--) + MEMCPY_WRAPPED(dst_byte + i * dst_byte_stride, + src_byte + i * src_byte_stride, + width_byte); + + return; + } + } + if (bpp == 24 && !FbCheck24Pix(pm)) { fbBlt24(srcLine, srcStride, srcX, dstLine, dstStride, dstX, width, height, alu, pm, reverse, upsidedown); return; } - careful = !((srcLine < dstLine && srcLine + width * (bpp >> 3) > dstLine) || - (dstLine < srcLine && dstLine + width * (bpp >> 3) > srcLine)) - || (bpp & 7); - - if (alu == GXcopy && pm == FB_ALLONES && !careful && - !(srcX & 7) && !(dstX & 7) && !(width & 7)) { - int i; - CARD8 *tmpsrc = (CARD8 *) srcLine; - CARD8 *tmpdst = (CARD8 *) dstLine; - - srcStride *= sizeof(FbBits); - dstStride *= sizeof(FbBits); - width >>= 3; - tmpsrc += (srcX >> 3); - tmpdst += (dstX >> 3); - - if (!upsidedown) - for (i = 0; i < height; i++) - MEMCPY_WRAPPED(tmpdst + i * dstStride, tmpsrc + i * srcStride, width); - else - for (i = height - 1; i >= 0; i--) - MEMCPY_WRAPPED(tmpdst + i * dstStride, tmpsrc + i * srcStride, width); - - return; - } - FbInitializeMergeRop(alu, pm); destInvarient = FbDestInvarientMergeRop(); if (upsidedown) { diff --git a/xorg-server/glamor/Makefile.am b/xorg-server/glamor/Makefile.am index ffc8c23d8..8555e4087 100644 --- a/xorg-server/glamor/Makefile.am +++ b/xorg-server/glamor/Makefile.am @@ -20,8 +20,11 @@ libglamor_la_SOURCES = \ glamor_polylines.c \ glamor_putimage.c \ glamor_setspans.c \ + glamor_segment.c \ glamor_render.c \ glamor_gradient.c \ + glamor_program.c \ + glamor_transform.c \ glamor_trapezoid.c \ glamor_tile.c \ glamor_triangles.c\ @@ -29,7 +32,7 @@ libglamor_la_SOURCES = \ glamor_getimage.c\ glamor_copyplane.c\ glamor_glyphblt.c\ - glamor_polyops.c\ + glamor_points.c\ glamor_priv.h\ glamor_pixmap.c\ glamor_largepixmap.c\ diff --git a/xorg-server/glamor/glamor.c b/xorg-server/glamor/glamor.c index 0f7d68b70..30944326b 100644 --- a/xorg-server/glamor/glamor.c +++ b/xorg-server/glamor/glamor.c @@ -76,6 +76,10 @@ glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type) pixmap_priv->base.glamor_priv = glamor_priv; } pixmap_priv->type = type; + pixmap_priv->base.box.x1 = 0; + pixmap_priv->base.box.x2 = pixmap->drawable.width; + pixmap_priv->base.box.y1 = 0; + pixmap_priv->base.box.y2 = pixmap->drawable.height; } _X_EXPORT void @@ -178,8 +182,14 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3; screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL); - if (type == GLAMOR_MEMORY_MAP || glamor_check_fbo_size(glamor_priv, w, h)) { + if (type == GLAMOR_MEMORY_MAP || usage == GLAMOR_CREATE_NO_LARGE || + glamor_check_fbo_size(glamor_priv, w, h)) + { pixmap_priv->type = type; + pixmap_priv->base.box.x1 = 0; + pixmap_priv->base.box.y1 = 0; + pixmap_priv->base.box.x2 = w; + pixmap_priv->base.box.y2 = h; fbo = glamor_create_fbo(glamor_priv, w, h, format, usage); } else { @@ -341,7 +351,7 @@ glamor_init(ScreenPtr screen, unsigned int flags) else glamor_priv->gl_flavor = GLAMOR_GL_ES2; - gl_version = glamor_gl_get_version(); + gl_version = epoxy_gl_version(); /* We'd like to require GL_ARB_map_buffer_range or * GL_OES_map_buffer_range, since it offers more information to @@ -357,29 +367,31 @@ glamor_init(ScreenPtr screen, unsigned int flags) * Windows with Intel 4-series (G45) graphics or older. */ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) { - if (gl_version < GLAMOR_GL_VERSION_ENCODE(1, 3)) { - ErrorF("Require OpenGL version 1.3 or later.\n"); + if (gl_version < 21) { + ErrorF("Require OpenGL version 2.1 or later.\n"); goto fail; } } else { - if (gl_version < GLAMOR_GL_VERSION_ENCODE(2, 0)) { + if (gl_version < 20) { ErrorF("Require Open GLES2.0 or later.\n"); goto fail; } - if (!glamor_gl_has_extension("GL_EXT_texture_format_BGRA8888")) { + if (!epoxy_has_gl_extension("GL_EXT_texture_format_BGRA8888")) { ErrorF("GL_EXT_texture_format_BGRA8888 required\n"); goto fail; } } - glamor_priv->has_khr_debug = glamor_gl_has_extension("GL_KHR_debug"); + glamor_priv->has_khr_debug = epoxy_has_gl_extension("GL_KHR_debug"); glamor_priv->has_pack_invert = - glamor_gl_has_extension("GL_MESA_pack_invert"); + epoxy_has_gl_extension("GL_MESA_pack_invert"); glamor_priv->has_fbo_blit = - glamor_gl_has_extension("GL_EXT_framebuffer_blit"); + epoxy_has_gl_extension("GL_EXT_framebuffer_blit"); + glamor_priv->has_map_buffer_range = + epoxy_has_gl_extension("GL_ARB_map_buffer_range"); glamor_priv->has_buffer_storage = - glamor_gl_has_extension("GL_ARB_buffer_storage"); + epoxy_has_gl_extension("GL_ARB_buffer_storage"); glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glamor_priv->max_fbo_size); #ifdef MAX_FBO_SIZE glamor_priv->max_fbo_size = MAX_FBO_SIZE; diff --git a/xorg-server/glamor/glamor.h b/xorg-server/glamor/glamor.h index d05d2f4ea..11ec49361 100644 --- a/xorg-server/glamor/glamor.h +++ b/xorg-server/glamor/glamor.h @@ -140,9 +140,16 @@ extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type); extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap); extern _X_EXPORT void glamor_block_handler(ScreenPtr screen); + extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, unsigned int usage); +#define GLAMOR_CREATE_PIXMAP_CPU 0x100 +#define GLAMOR_CREATE_PIXMAP_FIXUP 0x101 +#define GLAMOR_CREATE_FBO_NO_FBO 0x103 +#define GLAMOR_CREATE_PIXMAP_MAP 0x104 +#define GLAMOR_CREATE_NO_LARGE 0x105 + /* @glamor_egl_exchange_buffers: Exchange the underlying buffers(KHR image,fbo). * * @front: front pixmap. diff --git a/xorg-server/glamor/glamor_core.c b/xorg-server/glamor/glamor_core.c index 6c0b3c834..5711be72f 100644 --- a/xorg-server/glamor/glamor_core.c +++ b/xorg-server/glamor/glamor_core.c @@ -559,48 +559,3 @@ glamor_bitmap_to_region(PixmapPtr pixmap) return ret; } -/* Borrow from cairo. */ -Bool -glamor_gl_has_extension(const char *extension) -{ - const char *pext; - int ext_len; - - ext_len = strlen(extension); - - pext = (const char *) glGetString(GL_EXTENSIONS); - - if (pext == NULL || extension == NULL) - return FALSE; - - while ((pext = strstr(pext, extension)) != NULL) { - if (pext[ext_len] == ' ' || pext[ext_len] == '\0') - return TRUE; - pext += ext_len; - } - return FALSE; -} - -int -glamor_gl_get_version(void) -{ - int major, minor; - const char *version = (const char *) glGetString(GL_VERSION); - const char *dot = version == NULL ? NULL : strchr(version, '.'); - const char *major_start = dot; - - /* Sanity check */ - if (dot == NULL || dot == version || *(dot + 1) == '\0') { - major = 0; - minor = 0; - } - else { - /* Find the start of the major version in the string */ - while (major_start > version && *major_start != ' ') - --major_start; - major = strtol(major_start, NULL, 10); - minor = strtol(dot + 1, NULL, 10); - } - - return GLAMOR_GL_VERSION_ENCODE(major, minor); -} diff --git a/xorg-server/glamor/glamor_fbo.c b/xorg-server/glamor/glamor_fbo.c index 640b6fd81..4f6da67fb 100644 --- a/xorg-server/glamor/glamor_fbo.c +++ b/xorg-server/glamor/glamor_fbo.c @@ -361,9 +361,6 @@ glamor_create_fbo(glamor_screen_private *glamor_priv, GLint tex = 0; int cache_flag; - if (!glamor_check_fbo_size(glamor_priv, w, h)) - return NULL; - if (flag == GLAMOR_CREATE_FBO_NO_FBO) goto new_fbo; diff --git a/xorg-server/glamor/glamor_fill.c b/xorg-server/glamor/glamor_fill.c index 7461b62fa..2fa726e72 100644 --- a/xorg-server/glamor/glamor_fill.c +++ b/xorg-server/glamor/glamor_fill.c @@ -218,9 +218,6 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color) } } - if (_X_UNLIKELY(nbox > 1)) - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo); - glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), vertices); glEnableVertexAttribArray(GLAMOR_VERTEX_POS); diff --git a/xorg-server/glamor/glamor_glyphs.c b/xorg-server/glamor/glamor_glyphs.c index 2b2c735d4..a04ae8261 100644 --- a/xorg-server/glamor/glamor_glyphs.c +++ b/xorg-server/glamor/glamor_glyphs.c @@ -332,7 +332,7 @@ glamor_realize_glyph_caches(ScreenPtr pScreen) pixmap = pScreen->CreatePixmap(pScreen, CACHE_PICTURE_SIZE, CACHE_PICTURE_SIZE + MASK_CACHE_MAX_SIZE, - depth, 0); + depth, GLAMOR_CREATE_NO_LARGE); if (!pixmap) goto bail; diff --git a/xorg-server/glamor/glamor_gradient.c b/xorg-server/glamor/glamor_gradient.c index f77d6a8e3..c24f3427f 100644 --- a/xorg-server/glamor/glamor_gradient.c +++ b/xorg-server/glamor/glamor_gradient.c @@ -247,7 +247,6 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count, "{\n"\ " float t = 0.0;\n"\ " float sqrt_value;\n"\ - " int revserse = 0;\n"\ " t_invalid = 0;\n"\ " \n"\ " vec3 tmp = vec3(source_texture.x, source_texture.y, 1.0);\n"\ @@ -295,30 +294,11 @@ _glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count, " }\n"\ " \n"\ " if(repeat_type == %d){\n" /* repeat normal*/\ - " while(t > 1.0) \n"\ - " t = t - 1.0; \n"\ - " while(t < 0.0) \n"\ - " t = t + 1.0; \n"\ + " t = fract(t);\n"\ " }\n"\ " \n"\ " if(repeat_type == %d) {\n" /* repeat reflect*/\ - " while(t > 1.0) {\n"\ - " t = t - 1.0; \n"\ - " if(revserse == 0)\n"\ - " revserse = 1;\n"\ - " else\n"\ - " revserse = 0;\n"\ - " }\n"\ - " while(t < 0.0) {\n"\ - " t = t + 1.0; \n"\ - " if(revserse == 0)\n"\ - " revserse = 1;\n"\ - " else\n"\ - " revserse = 0;\n"\ - " }\n"\ - " if(revserse == 1) {\n"\ - " t = 1.0 - t; \n"\ - " }\n"\ + " t = abs(fract(t * 0.5 + 0.5) * 2.0 - 1.0);\n"\ " }\n"\ " \n"\ " return t;\n"\ @@ -492,7 +472,6 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count, " vec4 stop_color_before;\n"\ " vec4 stop_color_after;\n"\ " float new_alpha; \n"\ - " int revserse = 0;\n"\ " vec4 gradient_color;\n"\ " float percentage; \n"\ " vec3 source_texture_trans = transform_mat * tmp;\n"\ @@ -512,30 +491,11 @@ _glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count, " distance = distance - _p1_distance; \n"\ " \n"\ " if(repeat_type == %d){\n" /* repeat normal*/\ - " while(distance > _pt_distance) \n"\ - " distance = distance - (_pt_distance); \n"\ - " while(distance < 0.0) \n"\ - " distance = distance + (_pt_distance); \n"\ + " distance = mod(distance, _pt_distance);\n"\ " }\n"\ " \n"\ " if(repeat_type == %d) {\n" /* repeat reflect*/\ - " while(distance > _pt_distance) {\n"\ - " distance = distance - (_pt_distance); \n"\ - " if(revserse == 0)\n"\ - " revserse = 1;\n"\ - " else\n"\ - " revserse = 0;\n"\ - " }\n"\ - " while(distance < 0.0) {\n"\ - " distance = distance + (_pt_distance); \n"\ - " if(revserse == 0)\n"\ - " revserse = 1;\n"\ - " else\n"\ - " revserse = 0;\n"\ - " }\n"\ - " if(revserse == 1) {\n"\ - " distance = (_pt_distance) - distance; \n"\ - " }\n"\ + " distance = abs(mod(distance + _pt_distance, 2.0 * _pt_distance) - _pt_distance);\n"\ " }\n"\ " \n"\ " len_percentage = distance/(_pt_distance);\n"\ @@ -1160,9 +1120,6 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen, free(stop_colors); } - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glDisableVertexAttribArray(GLAMOR_VERTEX_POS); glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE); @@ -1181,9 +1138,6 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen, free(stop_colors); } - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glDisableVertexAttribArray(GLAMOR_VERTEX_POS); glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE); glamor_put_context(glamor_priv); @@ -1511,9 +1465,6 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen, free(stop_colors); } - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glDisableVertexAttribArray(GLAMOR_VERTEX_POS); glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE); @@ -1532,9 +1483,6 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen, free(stop_colors); } - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glDisableVertexAttribArray(GLAMOR_VERTEX_POS); glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE); glamor_put_context(glamor_priv); diff --git a/xorg-server/glamor/glamor_largepixmap.c b/xorg-server/glamor/glamor_largepixmap.c index b8c064038..b3a8d5d20 100644 --- a/xorg-server/glamor/glamor_largepixmap.c +++ b/xorg-server/glamor/glamor_largepixmap.c @@ -1015,7 +1015,6 @@ glamor_composite_largepixmap_region(CARD8 op, INT16 x_dest, INT16 y_dest, CARD16 width, CARD16 height) { - glamor_screen_private *glamor_priv; glamor_pixmap_clipped_regions *clipped_dest_regions; glamor_pixmap_clipped_regions *clipped_source_regions; glamor_pixmap_clipped_regions *clipped_mask_regions; @@ -1044,9 +1043,8 @@ glamor_composite_largepixmap_region(CARD8 op, else mask_repeat_type = RepeatNone; - glamor_priv = dest_pixmap_priv->base.glamor_priv; - fixed_block_width = glamor_priv->max_fbo_size; - fixed_block_height = glamor_priv->max_fbo_size; + fixed_block_width = dest_pixmap_priv->large.block_w; + fixed_block_height = dest_pixmap_priv->large.block_h; /* If we got an totally out-of-box region for a source or mask * region without repeat, we need to set it as null_source and * give it a solid color (0,0,0,0). */ @@ -1112,8 +1110,8 @@ glamor_composite_largepixmap_region(CARD8 op, /*compute the correct block width and height whose transformed source/mask *region can fit into one texture.*/ - if (force_clip || fixed_block_width < glamor_priv->max_fbo_size - || fixed_block_height < glamor_priv->max_fbo_size) + if (force_clip || fixed_block_width < dest_pixmap_priv->large.block_w + || fixed_block_height < dest_pixmap_priv->large.block_h) clipped_dest_regions = glamor_compute_clipped_regions_ext(dest_pixmap_priv, region, &n_dest_regions, diff --git a/xorg-server/glamor/glamor_pixmap.c b/xorg-server/glamor/glamor_pixmap.c index 615faad33..891ecdd37 100644 --- a/xorg-server/glamor/glamor_pixmap.c +++ b/xorg-server/glamor/glamor_pixmap.c @@ -1013,10 +1013,9 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, clipped_regions = glamor_compute_clipped_regions_ext(pixmap_priv, ®ion, &n_region, - pixmap_priv->base. - glamor_priv->max_fbo_size, - pixmap_priv->base. - glamor_priv->max_fbo_size, 0, + pixmap_priv->large.block_w, + pixmap_priv->large.block_h, + 0, 0); DEBUGF("prepare upload %dx%d to a large pixmap %p\n", w, h, pixmap); for (i = 0; i < n_region; i++) { @@ -1374,10 +1373,9 @@ glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h, clipped_regions = glamor_compute_clipped_regions_ext(pixmap_priv, ®ion, &n_region, - pixmap_priv->base. - glamor_priv->max_fbo_size, - pixmap_priv->base. - glamor_priv->max_fbo_size, 0, + pixmap_priv->large.block_w, + pixmap_priv->large.block_h, + 0, 0); DEBUGF("start download large pixmap %p %dx%d \n", pixmap, w, h); diff --git a/xorg-server/glamor/glamor_points.c b/xorg-server/glamor/glamor_points.c new file mode 100644 index 000000000..5399f96e8 --- /dev/null +++ b/xorg-server/glamor/glamor_points.c @@ -0,0 +1,129 @@ +/* + * Copyright © 2009 Intel Corporation + * Copyright © 1998 Keith Packard + * + * 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. + * + * Authors: + * Zhigang Gong <zhigang.gong@linux.intel.com> + * + */ + +#include "glamor_priv.h" +#include "glamor_transform.h" + +static const glamor_facet glamor_facet_point = { + .name = "poly_point", + .vs_vars = "attribute vec2 primitive;\n", + .vs_exec = GLAMOR_POS(gl_Position, primitive), +}; + +Bool +glamor_poly_point_nf(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPointPtr ppt) +{ + ScreenPtr screen = drawable->pScreen; + glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); + PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); + glamor_program *prog = &glamor_priv->point_prog; + glamor_pixmap_private *pixmap_priv; + int off_x, off_y; + GLshort *vbo_ppt; + char *vbo_offset; + int box_x, box_y; + + pixmap_priv = glamor_get_pixmap_private(pixmap); + if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) + goto bail; + + glamor_get_context(glamor_priv); + + if (prog->failed) + goto bail_ctx; + + if (!prog->prog) { + if (!glamor_build_program(screen, prog, + &glamor_facet_point, + &glamor_fill_solid)) + goto bail_ctx; + } + + if (!glamor_use_program(pixmap, gc, prog, NULL)) + goto bail_ctx; + + vbo_ppt = glamor_get_vbo_space(screen, npt * (2 * sizeof (INT16)), &vbo_offset); + glEnableVertexAttribArray(GLAMOR_VERTEX_POS); + glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_SHORT, GL_FALSE, 0, vbo_offset); + if (mode == CoordModePrevious) { + int n = npt; + INT16 x = 0, y = 0; + while (n--) { + vbo_ppt[0] = (x += ppt->x); + vbo_ppt[1] = (y += ppt->y); + vbo_ppt += 2; + ppt++; + } + } else + memcpy(vbo_ppt, ppt, npt * (2 * sizeof (INT16))); + glamor_put_vbo_space(screen); + + glEnable(GL_SCISSOR_TEST); + + glamor_pixmap_loop(pixmap_priv, box_x, box_y) { + int nbox = RegionNumRects(gc->pCompositeClip); + BoxPtr box = RegionRects(gc->pCompositeClip); + + glamor_set_destination_drawable(drawable, box_x, box_y, TRUE, TRUE, prog->matrix_uniform, &off_x, &off_y); + + while (nbox--) { + glScissor(box->x1 + off_x, + box->y1 + off_y, + box->x2 - box->x1, + box->y2 - box->y1); + box++; + glDrawArrays(GL_POINTS, 0, npt); + } + } + + glDisable(GL_SCISSOR_TEST); + glDisable(GL_COLOR_LOGIC_OP); + glDisableVertexAttribArray(GLAMOR_VERTEX_POS); + + glamor_put_context(glamor_priv); + + glamor_priv->state = RENDER_STATE; + glamor_priv->render_idle_cnt = 0; + + return TRUE; + +bail_ctx: + glDisable(GL_COLOR_LOGIC_OP); + glamor_put_context(glamor_priv); +bail: + return FALSE; +} + +void +glamor_poly_point(DrawablePtr drawable, GCPtr gc, int mode, int npt, + DDXPointPtr ppt) +{ + if (glamor_poly_point_nf(drawable, gc, mode, npt, ppt)) + return; + miPolyPoint(drawable, gc, mode, npt, ppt); +} diff --git a/xorg-server/glamor/glamor_polyops.c b/xorg-server/glamor/glamor_polyops.c deleted file mode 100644 index 1484d80f1..000000000 --- a/xorg-server/glamor/glamor_polyops.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright © 2009 Intel Corporation - * Copyright © 1998 Keith Packard - * - * 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. - * - * Authors: - * Zhigang Gong <zhigang.gong@linux.intel.com> - * - */ - -#include "glamor_priv.h" - -static Bool -_glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, - DDXPointPtr ppt, Bool fallback) -{ - if (!fallback && glamor_ddx_fallback_check_gc(pGC) - && glamor_ddx_fallback_check_pixmap(pDrawable)) - return FALSE; - - miPolyPoint(pDrawable, pGC, mode, npt, ppt); - - return TRUE; -} - -void -glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, - DDXPointPtr ppt) -{ - _glamor_poly_point(pDrawable, pGC, mode, npt, ppt, TRUE); -} - -Bool -glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, - DDXPointPtr ppt) -{ - return _glamor_poly_point(pDrawable, pGC, mode, npt, ppt, FALSE); -} - -static Bool -_glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg, - xSegment *pSeg, Bool fallback) -{ - if (!fallback && glamor_ddx_fallback_check_gc(pGC) - && glamor_ddx_fallback_check_pixmap(pDrawable)) - return FALSE; - - miPolySegment(pDrawable, pGC, nseg, pSeg); - - return TRUE; -} - -void -glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSeg) -{ - _glamor_poly_segment(pDrawable, pGC, nseg, pSeg, TRUE); -} - -Bool -glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC, int nseg, - xSegment *pSeg) -{ - return _glamor_poly_segment(pDrawable, pGC, nseg, pSeg, FALSE); -} diff --git a/xorg-server/glamor/glamor_priv.h b/xorg-server/glamor/glamor_priv.h index bc7d3f827..4c305abfc 100644 --- a/xorg-server/glamor/glamor_priv.h +++ b/xorg-server/glamor/glamor_priv.h @@ -52,6 +52,7 @@ #include "glamor_debug.h" #include "glamor_context.h" +#include "glamor_program.h" #include <list.h> @@ -153,13 +154,6 @@ enum glamor_gl_flavor { GLAMOR_GL_ES2 // OPENGL ES2.0 API }; -#define GLAMOR_CREATE_PIXMAP_CPU 0x100 -#define GLAMOR_CREATE_PIXMAP_FIXUP 0x101 -#define GLAMOR_CREATE_FBO_NO_FBO 0x103 -#define GLAMOR_CREATE_PIXMAP_MAP 0x104 - -#define GLAMOR_CREATE_TEXTURE_EXACT_SIZE 0x104 - #define GLAMOR_NUM_GLYPH_CACHE_FORMATS 2 #define GLAMOR_COMPOSITE_VBO_VERT_CNT (64*1024) @@ -213,6 +207,7 @@ typedef struct glamor_screen_private { enum glamor_gl_flavor gl_flavor; int has_pack_invert; int has_fbo_blit; + int has_map_buffer_range; int has_buffer_storage; int has_khr_debug; int max_fbo_size; @@ -225,6 +220,9 @@ typedef struct glamor_screen_private { GLint solid_prog; GLint solid_color_uniform_location; + /* glamor point shader */ + glamor_program point_prog; + /* vertext/elment_index buffer object for render */ GLuint vbo, ebo; /** Next offset within the VBO that glamor_get_vbo_space() will use. */ @@ -421,6 +419,7 @@ typedef struct glamor_pixmap_private_base { unsigned char gl_tex:1; glamor_pixmap_fbo *fbo; PixmapPtr pixmap; + BoxRec box; int drm_stride; glamor_screen_private *glamor_priv; PicturePtr picture; @@ -476,6 +475,52 @@ typedef struct glamor_pixmap_private { }; } glamor_pixmap_private; +static inline glamor_pixmap_fbo * +glamor_pixmap_fbo_at(glamor_pixmap_private *priv, int x, int y) +{ + if (priv->type == GLAMOR_TEXTURE_LARGE) { + assert(x < priv->large.block_wcnt); + assert(y < priv->large.block_hcnt); + return priv->large.fbo_array[y * priv->large.block_wcnt + x]; + } + assert (x == 0); + assert (y == 0); + return priv->base.fbo; +} + +static inline BoxPtr +glamor_pixmap_box_at(glamor_pixmap_private *priv, int x, int y) +{ + if (priv->type == GLAMOR_TEXTURE_LARGE) { + assert(x < priv->large.block_wcnt); + assert(y < priv->large.block_hcnt); + return &priv->large.box_array[y * priv->large.block_wcnt + x]; + } + assert (x == 0); + assert (y == 0); + return &priv->base.box; +} + +static inline int +glamor_pixmap_wcnt(glamor_pixmap_private *priv) +{ + if (priv->type == GLAMOR_TEXTURE_LARGE) + return priv->large.block_wcnt; + return 1; +} + +static inline int +glamor_pixmap_hcnt(glamor_pixmap_private *priv) +{ + if (priv->type == GLAMOR_TEXTURE_LARGE) + return priv->large.block_hcnt; + return 1; +} + +#define glamor_pixmap_loop(priv, x, y) \ + for (y = 0; y < glamor_pixmap_hcnt(priv); y++) \ + for (x = 0; x < glamor_pixmap_wcnt(priv); x++) + /* * Pixmap dynamic status, used by dynamic upload feature. * @@ -619,12 +664,6 @@ Bool glamor_set_alu(ScreenPtr screen, unsigned char alu); Bool glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask); Bool glamor_change_window_attributes(WindowPtr pWin, unsigned long mask); RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap); -Bool glamor_gl_has_extension(const char *extension); -int glamor_gl_get_version(void); - -#define GLAMOR_GL_VERSION_ENCODE(major, minor) ( \ - ((major) * 256) \ - + ((minor) * 1)) /* glamor_fill.c */ Bool glamor_fill(DrawablePtr drawable, diff --git a/xorg-server/glamor/glamor_program.c b/xorg-server/glamor/glamor_program.c new file mode 100644 index 000000000..e2e1434ee --- /dev/null +++ b/xorg-server/glamor/glamor_program.c @@ -0,0 +1,394 @@ +/* + * Copyright © 2014 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 copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS 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. + */ + +#include "glamor_priv.h" +#include "glamor_transform.h" +#include "glamor_program.h" + +static Bool +use_solid(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg) +{ + return glamor_set_solid(pixmap, gc, TRUE, prog->fg_uniform); +} + +const glamor_facet glamor_fill_solid = { + .name = "solid", + .fs_exec = " gl_FragColor = fg;\n", + .locations = glamor_program_location_fg, + .use = use_solid, +}; + +static Bool +use_tile(PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg) +{ + return glamor_set_tiled(pixmap, gc, prog->fill_offset_uniform, prog->fill_size_uniform); +} + +static const glamor_facet glamor_fill_tile = { + .name = "tile", + .version = 130, + .vs_exec = " fill_pos = fill_offset + primitive.xy + pos;\n", + .fs_exec = " gl_FragColor = texelFetch(sampler, ivec2(mod(fill_pos,fill_size)), 0);\n", + .locations = glamor_program_location_fill, + .use = use_tile, +}; + +#if 0 +static Bool +use_stipple(PixmapPtr pixmap, GCPtr gc, glamor_program *prog) +{ + return glamor_set_stippled(pixmap, gc, prog->fg_uniform, prog->fill_offset_uniform, prog->fill_size_uniform); +} + +static const glamor_facet glamor_fill_stipple = { + .name = "stipple", + .version = 130, + .vs_exec = " fill_pos = fill_offset + primitive.xy + pos;\n"; + .fs_exec = (" if (texelFetch(sampler, ivec2(mod(fill_pos,fill_size)), 0).x == 0)\n" + " discard;\n" + " gl_FragColor = fg;\n") + .locations = glamor_program_location_fg | glamor_program_location_fill + .use = use_stipple, +}; + +static const glamor_facet glamor_fill_opaque_stipple = { + .name = "opaque_stipple", + .version = 130, + .vs_exec = " fill_pos = fill_offset + primitive.xy + pos;\n"; + .fs_exec = (" if (texelFetch(sampler, ivec2(mod(fill_pos,fill_size)), 0).x == 0)\n" + " gl_FragColor = bg;\n" + " else\n" + " gl_FragColor = fg;\n"), + .locations = glamor_program_location_fg | glamor_program_location_bg | glamor_program_location_fill + .use = use_opaque_stipple +}; +#endif + +static const glamor_facet *glamor_facet_fill[4] = { + &glamor_fill_solid, + &glamor_fill_tile, + NULL, + NULL, +}; + +typedef struct { + glamor_program_location location; + const char *vs_vars; + const char *fs_vars; +} glamor_location_var; + +static glamor_location_var location_vars[] = { + { + .location = glamor_program_location_fg, + .fs_vars = "uniform vec4 fg;\n" + }, + { + .location = glamor_program_location_bg, + .fs_vars = "uniform vec4 bg;\n" + }, + { + .location = glamor_program_location_fill, + .vs_vars = ("uniform vec2 fill_offset;\n" + "varying vec2 fill_pos;\n"), + .fs_vars = ("uniform sampler2D sampler;\n" + "uniform vec2 fill_size;\n" + "varying vec2 fill_pos;\n") + }, + { + .location = glamor_program_location_font, + .fs_vars = "uniform usampler2D font;\n", + }, +}; + +#define NUM_LOCATION_VARS (sizeof location_vars / sizeof location_vars[0]) + +static char * +add_var(char *cur, const char *add) +{ + char *new; + + if (!add) + return cur; + + new = realloc(cur, strlen(cur) + strlen(add) + 1); + if (!new) { + free(cur); + return NULL; + } + strcat(new, add); + return new; +} + +static char * +vs_location_vars(glamor_program_location locations) +{ + int l; + char *vars = strdup(""); + + for (l = 0; vars && l < NUM_LOCATION_VARS; l++) + if (locations & location_vars[l].location) + vars = add_var(vars, location_vars[l].vs_vars); + return vars; +} + +static char * +fs_location_vars(glamor_program_location locations) +{ + int l; + char *vars = strdup(""); + + for (l = 0; vars && l < NUM_LOCATION_VARS; l++) + if (locations & location_vars[l].location) + vars = add_var(vars, location_vars[l].fs_vars); + return vars; +} + +static const char vs_template[] = + "%s" /* version */ + "%s" /* prim vs_vars */ + "%s" /* fill vs_vars */ + "%s" /* location vs_vars */ + GLAMOR_DECLARE_MATRIX + "void main() {\n" + "%s" /* prim vs_exec, outputs 'pos' and gl_Position */ + "%s" /* fill vs_exec */ + "}\n"; + +static const char fs_template[] = + "%s" /* version */ + GLAMOR_DEFAULT_PRECISION + "%s" /* prim fs_vars */ + "%s" /* fill fs_vars */ + "%s" /* location fs_vars */ + "void main() {\n" + "%s" /* prim fs_exec */ + "%s" /* fill fs_exec */ + "}\n"; + +static const char * +str(const char *s) +{ + if (!s) + return ""; + return s; +} + +static const glamor_facet facet_null_fill = { + .name = "" +}; + +static GLint +glamor_get_uniform(glamor_program *prog, + glamor_program_location location, + const char *name) +{ + GLint uniform; + if (location && (prog->locations & location) == 0) + return -2; + uniform = glGetUniformLocation(prog->prog, name); +#if DBG + ErrorF("%s uniform %d\n", name, uniform); +#endif + return uniform; +} + +Bool +glamor_build_program(ScreenPtr screen, + glamor_program *prog, + const glamor_facet *prim, + const glamor_facet *fill) +{ + glamor_screen_private *glamor_priv = glamor_get_screen_private(screen); + + glamor_program_location locations = prim->locations; + glamor_program_flag flags = prim->flags; + + int version = prim->version; + char *version_string = NULL; + + char *fs_vars = NULL; + char *vs_vars = NULL; + + char *vs_prog_string; + char *fs_prog_string; + + GLint fs_prog, vs_prog; + + if (!fill) + fill = &facet_null_fill; + + locations |= fill->locations; + flags |= fill->flags; + version = MAX(version, fill->version); + + if (version >= 130) { + + /* Would be nice to have a cleaner test for GLSL 1.30 support, + * but for now this should suffice + */ + if (glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP || + epoxy_gl_version() < 30) { + goto fail; + } + } + + vs_vars = vs_location_vars(locations); + fs_vars = fs_location_vars(locations); + + if (!vs_vars) + goto fail; + if (!fs_vars) + goto fail; + + if (version) { + if (asprintf(&version_string, "#version %d\n", version) < 0) + version_string = NULL; + if (!version_string) + goto fail; + } + + if (asprintf(&vs_prog_string, + vs_template, + str(version_string), + str(prim->vs_vars), + str(fill->vs_vars), + vs_vars, + str(prim->vs_exec), + str(fill->vs_exec)) < 0) + vs_prog_string = NULL; + + if (asprintf(&fs_prog_string, + fs_template, + str(version_string), + str(prim->fs_vars), + str(fill->fs_vars), + fs_vars, + str(prim->fs_exec), + str(fill->fs_exec)) < 0) + fs_prog_string = NULL; + + if (!vs_prog_string || !fs_prog_string) + goto fail; + +#define DBG 0 +#if DBG + ErrorF("\nPrograms for %s %s\nVertex shader:\n\n%s\n\nFragment Shader:\n\n%s", + prim->name, fill->name, vs_prog_string, fs_prog_string); +#endif + + prog->prog = glCreateProgram(); + prog->flags = flags; + prog->locations = locations; + prog->prim_use = prim->use; + prog->fill_use = fill->use; + + vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_prog_string); + fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, fs_prog_string); + free(vs_prog_string); + free(fs_prog_string); + glAttachShader(prog->prog, vs_prog); + glDeleteShader(vs_prog); + glAttachShader(prog->prog, fs_prog); + glDeleteShader(fs_prog); + glBindAttribLocation(prog->prog, GLAMOR_VERTEX_POS, "primitive"); + + if (prim->source_name) { +#if DBG + ErrorF("Bind GLAMOR_VERTEX_SOURCE to %s\n", prim->source_name); +#endif + glBindAttribLocation(prog->prog, GLAMOR_VERTEX_SOURCE, prim->source_name); + } + + glamor_link_glsl_prog(screen, prog->prog, "%s_%s", prim->name, fill->name); + + prog->matrix_uniform = glamor_get_uniform(prog, glamor_program_location_none, "v_matrix"); + prog->fg_uniform = glamor_get_uniform(prog, glamor_program_location_fg, "fg"); + prog->bg_uniform = glamor_get_uniform(prog, glamor_program_location_bg, "bg"); + prog->fill_offset_uniform = glamor_get_uniform(prog, glamor_program_location_fill, "fill_offset"); + prog->fill_size_uniform = glamor_get_uniform(prog, glamor_program_location_fill, "fill_size"); + prog->font_uniform = glamor_get_uniform(prog, glamor_program_location_font, "font"); + + if (glGetError() != GL_NO_ERROR) + goto fail; + + free(version_string); + free(fs_vars); + free(vs_vars); + return TRUE; +fail: + prog->failed = 1; + if (prog->prog) { + glDeleteProgram(prog->prog); + prog->prog = 0; + } + free(version_string); + free(fs_vars); + free(vs_vars); + return FALSE; +} + +Bool +glamor_use_program(PixmapPtr pixmap, + GCPtr gc, + glamor_program *prog, + void *arg) +{ + glUseProgram(prog->prog); + + if (prog->prim_use && !prog->prim_use(pixmap, gc, prog, arg)) + return FALSE; + + if (prog->fill_use && !prog->fill_use(pixmap, gc, prog, arg)) + return FALSE; + + return TRUE; +} + +glamor_program * +glamor_use_program_fill(PixmapPtr pixmap, + GCPtr gc, + glamor_program_fill *program_fill, + const glamor_facet *prim) +{ + ScreenPtr screen = pixmap->drawable.pScreen; + glamor_program *prog = &program_fill->progs[gc->fillStyle]; + + int fill_style = gc->fillStyle; + const glamor_facet *fill; + + if (prog->failed) + return FALSE; + + if (!prog->prog) { + fill = glamor_facet_fill[fill_style]; + if (!fill) + return NULL; + + if (!glamor_build_program(screen, prog, prim, fill)) + return NULL; + } + + if (!glamor_use_program(pixmap, gc, prog, NULL)) + return NULL; + + return prog; +} diff --git a/xorg-server/glamor/glamor_program.h b/xorg-server/glamor/glamor_program.h new file mode 100644 index 000000000..88efc3593 --- /dev/null +++ b/xorg-server/glamor/glamor_program.h @@ -0,0 +1,94 @@ +/* + * Copyright © 2014 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 copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS 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. + */ + +#ifndef _GLAMOR_PROGRAM_H_ +#define _GLAMOR_PROGRAM_H_ + +typedef enum { + glamor_program_location_none = 0, + glamor_program_location_fg = 1, + glamor_program_location_bg = 2, + glamor_program_location_fill = 4, + glamor_program_location_font = 8, +} glamor_program_location; + +typedef enum { + glamor_program_flag_none = 0, +} glamor_program_flag; + +typedef struct _glamor_program glamor_program; + +typedef Bool (*glamor_use) (PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg); + +typedef struct { + const char *name; + const int version; + const char *vs_vars; + const char *vs_exec; + const char *fs_vars; + const char *fs_exec; + const glamor_program_location locations; + const glamor_program_flag flags; + const char *source_name; + glamor_use use; +} glamor_facet; + +struct _glamor_program { + GLint prog; + GLint failed; + GLint matrix_uniform; + GLint fg_uniform; + GLint bg_uniform; + GLint fill_size_uniform; + GLint fill_offset_uniform; + GLint font_uniform; + glamor_program_location locations; + glamor_program_flag flags; + glamor_use prim_use; + glamor_use fill_use; +}; + +typedef struct { + glamor_program progs[4]; +} glamor_program_fill; + +extern const glamor_facet glamor_fill_solid; + +Bool +glamor_build_program(ScreenPtr screen, + glamor_program *prog, + const glamor_facet *prim, + const glamor_facet *fill); + +Bool +glamor_use_program(PixmapPtr pixmap, + GCPtr gc, + glamor_program *prog, + void *arg); + +glamor_program * +glamor_use_program_fill(PixmapPtr pixmap, + GCPtr gc, + glamor_program_fill *program_fill, + const glamor_facet *prim); + +#endif /* _GLAMOR_PROGRAM_H_ */ diff --git a/xorg-server/glamor/glamor_render.c b/xorg-server/glamor/glamor_render.c index c0ee22c2f..cdf8effdc 100644 --- a/xorg-server/glamor/glamor_render.c +++ b/xorg-server/glamor/glamor_render.c @@ -412,29 +412,10 @@ glamor_init_composite_shaders(ScreenPtr screen) eb_size = GLAMOR_COMPOSITE_VBO_VERT_CNT * sizeof(short) * 2; - if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) { - glBufferData(GL_ELEMENT_ARRAY_BUFFER, eb_size, NULL, GL_STATIC_DRAW); - eb = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); - } - else { - eb = malloc(eb_size); - } - - if (eb == NULL) - FatalError - ("fatal error, fail to get element buffer. GL context may be not created correctly.\n"); + eb = XNFalloc(eb_size); glamor_init_eb(eb, GLAMOR_COMPOSITE_VBO_VERT_CNT); - - if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) { - glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - } - else { - glBufferData(GL_ELEMENT_ARRAY_BUFFER, eb_size, eb, GL_STATIC_DRAW); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - - free(eb); - } + glBufferData(GL_ELEMENT_ARRAY_BUFFER, eb_size, eb, GL_STATIC_DRAW); + free(eb); glamor_put_context(glamor_priv); } @@ -448,6 +429,7 @@ glamor_fini_composite_shaders(ScreenPtr screen) glamor_priv = glamor_get_screen_private(screen); glamor_get_context(glamor_priv); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glDeleteBuffers(1, &glamor_priv->ebo); for (i = 0; i < SHADER_SOURCE_COUNT; i++) @@ -706,8 +688,6 @@ glamor_setup_composite_vbo(ScreenPtr screen, int n_verts) glamor_get_context(glamor_priv); vb = glamor_get_vbo_space(screen, vert_size, &vbo_offset); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo); - glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE, glamor_priv->vb_stride, vbo_offset); glEnableVertexAttribArray(GLAMOR_VERTEX_POS); @@ -1329,7 +1309,6 @@ glamor_composite_with_shader(CARD8 op, } } - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glDisableVertexAttribArray(GLAMOR_VERTEX_POS); glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE); glDisableVertexAttribArray(GLAMOR_VERTEX_MASK); diff --git a/xorg-server/glamor/glamor_segment.c b/xorg-server/glamor/glamor_segment.c new file mode 100644 index 000000000..84b27acce --- /dev/null +++ b/xorg-server/glamor/glamor_segment.c @@ -0,0 +1,39 @@ +/* + * Copyright © 2014 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 copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS 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. + */ + +#include "glamor_priv.h" + +Bool +glamor_poly_segment_nf(DrawablePtr drawable, GCPtr gc, int nseg, + xSegment *seg) +{ + return FALSE; +} + +void +glamor_poly_segment(DrawablePtr drawable, GCPtr gc, int nseg, + xSegment *seg) +{ + if (glamor_poly_segment_nf(drawable, gc, nseg, seg)) + return; + miPolySegment(drawable, gc, nseg, seg); +} diff --git a/xorg-server/glamor/glamor_transform.c b/xorg-server/glamor/glamor_transform.c new file mode 100644 index 000000000..d6ba56421 --- /dev/null +++ b/xorg-server/glamor/glamor_transform.c @@ -0,0 +1,215 @@ +/* + * Copyright © 2014 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 copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS 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. + */ + +#include "glamor_priv.h" +#include "glamor_transform.h" + + +/* + * Set up rendering to target the specified drawable, computing an + * appropriate transform for the vertex shader to convert + * drawable-relative coordinates into pixmap-relative coordinates. If + * requested, the offset from pixmap origin coordinates back to window + * system coordinates will be returned in *p_off_x, *p_off_y so that + * clipping computations can be adjusted as appropriate + */ + +void +glamor_set_destination_drawable(DrawablePtr drawable, + int box_x, + int box_y, + Bool do_drawable_translate, + Bool center_offset, + GLint matrix_uniform_location, + int *p_off_x, + int *p_off_y) +{ + PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable); + glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); + int off_x, off_y; + BoxPtr box = glamor_pixmap_box_at(pixmap_priv, box_x, box_y); + int w = box->x2 - box->x1; + int h = box->y2 - box->y1; + float scale_x = 2.0f / (float) w; + float scale_y = 2.0f / (float) h; + float center_adjust = 0.0f; + + glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y); + + off_x -= box->x1; + off_y -= box->y1; + + if (p_off_x) { + *p_off_x = off_x; + *p_off_y = off_y; + } + + /* A tricky computation to find the right value for the two linear functions + * that transform rendering coordinates to pixmap coordinates + * + * pixmap_x = render_x + drawable->x + off_x + * pixmap_y = render_y + drawable->y + off_y + * + * gl_x = pixmap_x * 2 / width - 1 + * gl_y = pixmap_y * 2 / height - 1 + * + * gl_x = (render_x + drawable->x + off_x) * 2 / width - 1 + * + * gl_x = (render_x) * 2 / width + (drawable->x + off_x) * 2 / width - 1 + * + * I'll think about yInverted later, when I have some way to test + */ + + if (do_drawable_translate) { + off_x += drawable->x; + off_y += drawable->y; + } + + /* + * To get GL_POINTS drawn in the right spot, we need to adjust the + * coordinates by 1/2 a pixel. + */ + if (center_offset) + center_adjust = 0.5f; + + glUniform4f(matrix_uniform_location, + scale_x, (off_x + center_adjust) * scale_x - 1.0f, + scale_y, (off_y + center_adjust) * scale_y - 1.0f); + + glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo_at(pixmap_priv, box_x, box_y), + 0, 0, w, h); +} + +/* + * Set up for solid rendering to the specified pixmap using alu, fg and planemask + * from the specified GC. Load the target color into the specified uniform + */ + +void +glamor_set_color(PixmapPtr pixmap, + CARD32 pixel, + GLint uniform) +{ + float color[4]; + + glamor_get_rgba_from_pixel(pixel, + &color[0], &color[1], &color[2], &color[3], + format_for_pixmap(pixmap)); + + glUniform4fv(uniform, 1, color); +} + +Bool +glamor_set_solid(PixmapPtr pixmap, + GCPtr gc, + Bool use_alu, + GLint uniform) +{ + CARD32 pixel; + int alu = use_alu ? gc->alu : GXcopy; + + if (!glamor_set_planemask(pixmap, gc->planemask)) + return FALSE; + + pixel = gc->fgPixel; + + if (!glamor_set_alu(pixmap->drawable.pScreen, alu)) { + switch (gc->alu) { + case GXclear: + pixel = 0; + break; + case GXcopyInverted: + pixel = ~pixel; + break; + case GXset: + pixel = ~0 & gc->planemask; + break; + default: + return FALSE; + } + } + glamor_set_color(pixmap, gc->fgPixel, uniform); + + return TRUE; +} + +Bool +glamor_set_texture(PixmapPtr pixmap, + PixmapPtr texture, + int off_x, + int off_y, + GLint offset_uniform, + GLint size_uniform) +{ + glamor_pixmap_private *texture_priv; + + texture_priv = glamor_get_pixmap_private(texture); + + if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(texture_priv)) + return FALSE; + + if (texture_priv->type == GLAMOR_TEXTURE_LARGE) + return FALSE; + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, texture_priv->base.fbo->tex); + + glUniform2f(offset_uniform, off_x, off_y); + glUniform2f(size_uniform, texture->drawable.width, texture->drawable.height); + return TRUE; +} + +Bool +glamor_set_tiled(PixmapPtr pixmap, + GCPtr gc, + GLint offset_uniform, + GLint size_uniform) +{ + if (!glamor_set_alu(pixmap->drawable.pScreen, gc->alu)) + return FALSE; + + if (!glamor_set_planemask(pixmap, gc->planemask)) + return FALSE; + + return glamor_set_texture(pixmap, + gc->tile.pixmap, + -gc->patOrg.x, + -gc->patOrg.y, + offset_uniform, + size_uniform); +} + +Bool +glamor_set_stippled(PixmapPtr pixmap, + GCPtr gc, + GLint fg_uniform, + GLint offset_uniform, + GLint size_uniform) +{ + if (!glamor_set_solid(pixmap, gc, TRUE, fg_uniform)) + return FALSE; + + if (!glamor_set_texture(pixmap, gc->stipple, gc->patOrg.x, gc->patOrg.y, offset_uniform, size_uniform)) + return FALSE; + + return TRUE; +} diff --git a/xorg-server/glamor/glamor_transform.h b/xorg-server/glamor/glamor_transform.h new file mode 100644 index 000000000..36b789af8 --- /dev/null +++ b/xorg-server/glamor/glamor_transform.h @@ -0,0 +1,87 @@ +/* + * Copyright © 2014 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 copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS 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. + */ + +#ifndef _GLAMOR_TRANSFORM_H_ +#define _GLAMOR_TRANSFORM_H_ + +void +glamor_set_destination_drawable(DrawablePtr drawable, + int box_x, + int box_y, + Bool do_drawable_translate, + Bool center_offset, + GLint matrix_uniform_location, + int *p_off_x, + int *p_off_y); + +void +glamor_set_color(PixmapPtr pixmap, + CARD32 pixel, + GLint uniform); + +Bool +glamor_set_texture(PixmapPtr pixmap, + PixmapPtr texture, + int off_x, + int off_y, + GLint offset_uniform, + GLint size_uniform); + +Bool +glamor_set_solid(PixmapPtr pixmap, + GCPtr gc, + Bool use_alu, + GLint uniform); + +Bool +glamor_set_tiled(PixmapPtr pixmap, + GCPtr gc, + GLint offset_uniform, + GLint size_uniform); + +Bool +glamor_set_stippled(PixmapPtr pixmap, + GCPtr gc, + GLint fg_uniform, + GLint offset_uniform, + GLint size_uniform); + +/* + * Vertex shader bits that transform X coordinates to pixmap + * coordinates using the matrix computed above + */ + +#define GLAMOR_DECLARE_MATRIX "uniform vec4 v_matrix;\n" +#define GLAMOR_X_POS(x) #x " *v_matrix.x + v_matrix.y" +#define GLAMOR_Y_POS(y) #y " *v_matrix.z + v_matrix.w" +#if 0 +#define GLAMOR_POS(dst,src) \ + " " #dst ".x = " #src ".x * v_matrix.x + v_matrix.y;\n" \ + " " #dst ".y = " #src ".y * v_matrix.z + v_matrix.w;\n" \ + " " #dst ".z = 0.0;\n" \ + " " #dst ".w = 1.0;\n" +#endif +#define GLAMOR_POS(dst,src) \ + " " #dst ".xy = " #src ".xy * v_matrix.xz + v_matrix.yw;\n" \ + " " #dst ".zw = vec2(0.0,1.0);\n" + +#endif /* _GLAMOR_TRANSFORM_H_ */ diff --git a/xorg-server/glamor/glamor_trapezoid.c b/xorg-server/glamor/glamor_trapezoid.c index 969ab68bc..c76b8bb2a 100644 --- a/xorg-server/glamor/glamor_trapezoid.c +++ b/xorg-server/glamor/glamor_trapezoid.c @@ -637,8 +637,6 @@ glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts) vb = glamor_get_vbo_space(screen, vert_size, &vbo_offset); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo); - /* Set the vertex pointer. */ glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE, glamor_priv->vb_stride, @@ -977,7 +975,6 @@ _glamor_trapezoids_with_shader(CARD8 op, ret = TRUE; TRAPEZOID_RESET_GL: - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glDisableVertexAttribArray(GLAMOR_VERTEX_POS); glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE); glDisableVertexAttribArray(GLAMOR_VERTEX_MASK); @@ -1415,8 +1412,6 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture, pixmap_priv_get_dest_scale(pixmap_priv, (&xscale), (&yscale)); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - /* Now draw the Trapezoid mask. */ glUseProgram(trapezoid_prog); @@ -1562,7 +1557,6 @@ _glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture, } } - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBlendFunc(GL_ONE, GL_ZERO); glDisable(GL_BLEND); glDisableVertexAttribArray(GLAMOR_VERTEX_POS); diff --git a/xorg-server/glamor/glamor_vbo.c b/xorg-server/glamor/glamor_vbo.c index 5e98bfe47..2731692d6 100644 --- a/xorg-server/glamor/glamor_vbo.c +++ b/xorg-server/glamor/glamor_vbo.c @@ -96,7 +96,7 @@ glamor_get_vbo_space(ScreenPtr screen, unsigned size, char **vbo_offset) *vbo_offset = (void *)(uintptr_t)glamor_priv->vbo_offset; data = glamor_priv->vb + glamor_priv->vbo_offset; glamor_priv->vbo_offset += size; - } else if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) { + } else if (glamor_priv->has_map_buffer_range) { if (glamor_priv->vbo_size < glamor_priv->vbo_offset + size) { glamor_priv->vbo_size = MAX(GLAMOR_VBO_SIZE, size); glamor_priv->vbo_offset = 0; @@ -147,7 +147,7 @@ glamor_put_vbo_space(ScreenPtr screen) * persistent mapping, so we can leave it around until we * reach the end of the buffer. */ - } else if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) { + } else if (glamor_priv->has_map_buffer_range) { glUnmapBuffer(GL_ARRAY_BUFFER); } else { glBufferData(GL_ARRAY_BUFFER, glamor_priv->vbo_offset, @@ -179,7 +179,7 @@ glamor_fini_vbo(ScreenPtr screen) glamor_get_context(glamor_priv); glDeleteBuffers(1, &glamor_priv->vbo); - if (glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP) + if (!glamor_priv->has_map_buffer_range) free(glamor_priv->vb); glamor_put_context(glamor_priv); diff --git a/xorg-server/hw/dmx/dmxinit.c b/xorg-server/hw/dmx/dmxinit.c index 7adcba0bb..fd2ade0ef 100644 --- a/xorg-server/hw/dmx/dmxinit.c +++ b/xorg-server/hw/dmx/dmxinit.c @@ -597,10 +597,8 @@ static void dmxAddExtensions(Bool glxSupported) { GlxExtensionInit, "GLX", &glxSupported }, #endif }; - int i; - for (i = 0; i < ARRAY_SIZE(dmxExtensions); i++) - LoadExtension(&dmxExtensions[i], TRUE); + LoadExtensionList(dmxExtensions, ARRAY_SIZE(dmxExtensions), TRUE); } /** This routine is called in Xserver/dix/main.c from \a main(). */ diff --git a/xorg-server/hw/kdrive/ephyr/Makefile.am b/xorg-server/hw/kdrive/ephyr/Makefile.am index 040993ce0..00a53d0df 100644 --- a/xorg-server/hw/kdrive/ephyr/Makefile.am +++ b/xorg-server/hw/kdrive/ephyr/Makefile.am @@ -38,7 +38,7 @@ if GLAMOR GLAMOR_SRCS = \ ephyr_glamor_glx.c \ ephyr_glamor_glx.h \ - () + $() endif if DRI diff --git a/xorg-server/hw/kdrive/ephyr/ephyrinit.c b/xorg-server/hw/kdrive/ephyr/ephyrinit.c index 807e717b1..fac84cd13 100644 --- a/xorg-server/hw/kdrive/ephyr/ephyrinit.c +++ b/xorg-server/hw/kdrive/ephyr/ephyrinit.c @@ -65,10 +65,7 @@ static const ExtensionModule ephyrExtensions[] = { static void ephyrExtensionInit(void) { - int i; - - for (i = 0; i < ARRAY_SIZE(ephyrExtensions); i++) - LoadExtension(&ephyrExtensions[i], TRUE); + LoadExtensionList(ephyrExtensions, ARRAY_SIZE(ephyrExtensions), TRUE); } diff --git a/xorg-server/hw/kdrive/ephyr/hostx.c b/xorg-server/hw/kdrive/ephyr/hostx.c index 3260d9527..4f48770a6 100644 --- a/xorg-server/hw/kdrive/ephyr/hostx.c +++ b/xorg-server/hw/kdrive/ephyr/hostx.c @@ -710,6 +710,12 @@ hostx_screen_init(KdScreenInfo *screen, malloc(scrpriv->ximg->stride * buffer_height); } + { + uint32_t mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; + uint32_t values[2] = {width, height}; + xcb_configure_window(HostX.conn, scrpriv->win, mask, values); + } + if (scrpriv->win_pre_existing == None && !EphyrWantResize) { /* Ask the WM to keep our size static */ xcb_size_hints_t size_hints = {0}; @@ -1260,7 +1266,9 @@ ephyr_glamor_create_screen_resources(ScreenPtr pScreen) screen_pixmap = pScreen->CreatePixmap(pScreen, pScreen->width, pScreen->height, - pScreen->rootDepth, 0); + pScreen->rootDepth, + GLAMOR_CREATE_NO_LARGE); + pScreen->SetScreenPixmap(screen_pixmap); /* Tell the GLX code what to GL texture to read from. */ diff --git a/xorg-server/hw/kdrive/src/kxv.c b/xorg-server/hw/kdrive/src/kxv.c index 445eb605b..9cc0edd8a 100644 --- a/xorg-server/hw/kdrive/src/kxv.c +++ b/xorg-server/hw/kdrive/src/kxv.c @@ -385,28 +385,7 @@ KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr * infoPtr, int number) for (i = 0, pi = pImage, imagePtr = adaptorPtr->pImages; i < adaptorPtr->nImages; i++, pi++, imagePtr++) { - pi->id = imagePtr->id; - pi->type = imagePtr->type; - pi->byte_order = imagePtr->byte_order; - memcpy(pi->guid, imagePtr->guid, 16); - pi->bits_per_pixel = imagePtr->bits_per_pixel; - pi->format = imagePtr->format; - pi->num_planes = imagePtr->num_planes; - pi->depth = imagePtr->depth; - pi->red_mask = imagePtr->red_mask; - pi->green_mask = imagePtr->green_mask; - pi->blue_mask = imagePtr->blue_mask; - pi->y_sample_bits = imagePtr->y_sample_bits; - pi->u_sample_bits = imagePtr->u_sample_bits; - pi->v_sample_bits = imagePtr->v_sample_bits; - pi->horz_y_period = imagePtr->horz_y_period; - pi->horz_u_period = imagePtr->horz_u_period; - pi->horz_v_period = imagePtr->horz_v_period; - pi->vert_y_period = imagePtr->vert_y_period; - pi->vert_u_period = imagePtr->vert_u_period; - pi->vert_v_period = imagePtr->vert_v_period; - memcpy(pi->component_order, imagePtr->component_order, 32); - pi->scanline_order = imagePtr->scanline_order; + memcpy(pi, imagePtr, sizeof(*pi)); } pa->nImages = adaptorPtr->nImages; pa->pImages = pImage; @@ -417,9 +396,7 @@ KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr * infoPtr, int number) calloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec)))) { for (pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i = 0; i < adaptorPtr->nAttributes; pat++, i++, attributePtr++) { - pat->flags = attributePtr->flags; - pat->min_value = attributePtr->min_value; - pat->max_value = attributePtr->max_value; + memcpy(pat, attributePtr, sizeof(*pat)); pat->name = strdup(attributePtr->name); } pa->nAttributes = adaptorPtr->nAttributes; diff --git a/xorg-server/hw/kdrive/src/kxv.h b/xorg-server/hw/kdrive/src/kxv.h index 4f644c246..85a030ee9 100644 --- a/xorg-server/hw/kdrive/src/kxv.h +++ b/xorg-server/hw/kdrive/src/kxv.h @@ -56,34 +56,7 @@ of the copyright holder. #define VIDEO_OVERLAID_STILLS 0x00000008 #define VIDEO_CLIP_TO_VIEWPORT 0x00000010 -typedef struct { - int id; - int type; - int byte_order; - unsigned char guid[16]; - int bits_per_pixel; - int format; - int num_planes; - - /* for RGB formats only */ - int depth; - unsigned int red_mask; - unsigned int green_mask; - unsigned int blue_mask; - - /* for YUV formats only */ - unsigned int y_sample_bits; - unsigned int u_sample_bits; - unsigned int v_sample_bits; - unsigned int horz_y_period; - unsigned int horz_u_period; - unsigned int horz_v_period; - unsigned int vert_y_period; - unsigned int vert_u_period; - unsigned int vert_v_period; - char component_order[32]; - int scanline_order; -} KdImageRec, *KdImagePtr; +typedef XvImageRec KdImageRec, *KdImagePtr; typedef struct { KdScreenInfo *screen; @@ -158,12 +131,7 @@ typedef struct { short class; } KdVideoFormatRec, *KdVideoFormatPtr; -typedef struct { - int flags; - int min_value; - int max_value; - char *name; -} KdAttributeRec, *KdAttributePtr; +typedef XvAttributeRec KdAttributeRec, *KdAttributePtr; typedef struct { unsigned int type; diff --git a/xorg-server/hw/vfb/InitOutput.c b/xorg-server/hw/vfb/InitOutput.c index 2175ac685..9c4926462 100644 --- a/xorg-server/hw/vfb/InitOutput.c +++ b/xorg-server/hw/vfb/InitOutput.c @@ -892,10 +892,7 @@ static const ExtensionModule vfbExtensions[] = { static void vfbExtensionInit(void) { - int i; - - for (i = 0; i < ARRAY_SIZE(vfbExtensions); i++) - LoadExtension(&vfbExtensions[i], TRUE); + LoadExtensionList(vfbExtensions, ARRAY_SIZE(vfbExtensions), TRUE); } void diff --git a/xorg-server/hw/xfree86/Makefile.am b/xorg-server/hw/xfree86/Makefile.am index a315bbc17..18fa99b08 100644 --- a/xorg-server/hw/xfree86/Makefile.am +++ b/xorg-server/hw/xfree86/Makefile.am @@ -43,7 +43,7 @@ SUBDIRS = common ddc x86emu $(INT10_SUBDIR) os-support parser \ DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \ parser ramdac shadowfb vbe vgahw \ loader dixmods dri dri2 exa modes \ - utils doc man + utils doc man glamor_egl bin_PROGRAMS = Xorg nodist_Xorg_SOURCES = sdksyms.c diff --git a/xorg-server/hw/xfree86/common/xf86Extensions.c b/xorg-server/hw/xfree86/common/xf86Extensions.c index c80de34e6..25b2bc3d0 100644 --- a/xorg-server/hw/xfree86/common/xf86Extensions.c +++ b/xorg-server/hw/xfree86/common/xf86Extensions.c @@ -132,10 +132,7 @@ load_extension_config(void) void xf86ExtensionInit(void) { - int i; - load_extension_config(); - for (i = 0; i < ARRAY_SIZE(extensionModules); i++) - LoadExtension(&extensionModules[i], TRUE); + LoadExtensionList(extensionModules, ARRAY_SIZE(extensionModules), TRUE); } diff --git a/xorg-server/hw/xfree86/dixmods/glxmodule.c b/xorg-server/hw/xfree86/dixmods/glxmodule.c index bf7d182a2..d53c6652d 100644 --- a/xorg-server/hw/xfree86/dixmods/glxmodule.c +++ b/xorg-server/hw/xfree86/dixmods/glxmodule.c @@ -47,10 +47,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. static MODULESETUPPROTO(glxSetup); -static const ExtensionModule GLXExt = { - GlxExtensionInit, - "GLX", - &noGlxExtension +static const ExtensionModule GLXExt[] = { + { GlxExtensionInit, "GLX", &noGlxExtension }, }; static XF86ModuleVersionInfo VersRec = { @@ -90,7 +88,7 @@ glxSetup(void *module, void *opts, int *errmaj, int *errmin) GlxPushProvider(provider); } - LoadExtension(&GLXExt, FALSE); + LoadExtensionList(GLXExt, ARRAY_SIZE(GLXExt), FALSE); return module; } diff --git a/xorg-server/hw/xfree86/doc/ddxDesign.xml b/xorg-server/hw/xfree86/doc/ddxDesign.xml index 7c2c20ff3..d1fd9af7b 100644 --- a/xorg-server/hw/xfree86/doc/ddxDesign.xml +++ b/xorg-server/hw/xfree86/doc/ddxDesign.xml @@ -5920,10 +5920,10 @@ These may be moved out of the loader at some point. <blockquote><para> <programlisting> - void LoadExtension(ExtensionModule *ext); + void LoadExtensionList(const ExtensionModule ext[]); </programlisting> <blockquote><para> - This registers the entry points for the extension identified by + This registers the entry points for the extension array identified by <parameter>ext</parameter>. The <structname>ExtensionModule</structname> struct is defined as: diff --git a/xorg-server/hw/xquartz/quartz.c b/xorg-server/hw/xquartz/quartz.c index bc6c8d048..d7229cecb 100644 --- a/xorg-server/hw/xquartz/quartz.c +++ b/xorg-server/hw/xquartz/quartz.c @@ -164,10 +164,7 @@ static const ExtensionModule quartzExtensions[] = { */ static void QuartzExtensionInit(void) { - int i; - - for (i = 0; i < ARRAY_SIZE(quartzExtensions); i++) - LoadExtension(&quartzExtensions[i], TRUE); + LoadExtensionList(quartzExtensions, ARRAY_SIZE(quartzExtensions), TRUE); } /* diff --git a/xorg-server/hw/xwin/InitOutput.c b/xorg-server/hw/xwin/InitOutput.c index b3ff7c041..6b5c38d92 100644 --- a/xorg-server/hw/xwin/InitOutput.c +++ b/xorg-server/hw/xwin/InitOutput.c @@ -163,8 +163,6 @@ static const ExtensionModule xwinExtensions[] = { static void XwinExtensionInit(void) { - int i; - #ifdef XWIN_GLX_WINDOWS if (g_fNativeGl) { /* install the native GL provider */ @@ -172,8 +170,7 @@ void XwinExtensionInit(void) } #endif - for (i = 0; i < ARRAY_SIZE(xwinExtensions); i++) - LoadExtension(&xwinExtensions[i], TRUE); + LoadExtensionList(xwinExtensions, ARRAY_SIZE(xwinExtensions), TRUE); } #if defined(DDXBEFORERESET) diff --git a/xorg-server/include/extension.h b/xorg-server/include/extension.h index acc6addb7..7c09af150 100644 --- a/xorg-server/include/extension.h +++ b/xorg-server/include/extension.h @@ -97,6 +97,7 @@ extern _X_EXPORT void InitExtensions(int argc, char **argv); extern _X_EXPORT void CloseDownExtensions(void); -extern _X_EXPORT void LoadExtension(const ExtensionModule *ext, Bool external); +extern _X_EXPORT void LoadExtensionList(const ExtensionModule ext[], + int listSize, Bool external); #endif /* EXTENSION_H */ diff --git a/xorg-server/include/opaque.h b/xorg-server/include/opaque.h index 73d40c345..7ec1d850f 100644 --- a/xorg-server/include/opaque.h +++ b/xorg-server/include/opaque.h @@ -74,5 +74,6 @@ extern _X_EXPORT Bool whiteRoot; extern _X_EXPORT Bool bgNoneRoot; extern _X_EXPORT Bool CoreDump; +extern _X_EXPORT Bool NoListenAll; #endif /* OPAQUE_H */ diff --git a/xorg-server/include/os.h b/xorg-server/include/os.h index e5f86d67d..d26e399b6 100644 --- a/xorg-server/include/os.h +++ b/xorg-server/include/os.h @@ -166,9 +166,9 @@ extern _X_EXPORT void MakeClientGrabImpervious(ClientPtr /*client */ ); extern _X_EXPORT void MakeClientGrabPervious(ClientPtr /*client */ ); -#ifdef XQUARTZ -extern void ListenOnOpenFD(int /* fd */ , int /* noxauth */ ); -#endif +extern _X_EXPORT void ListenOnOpenFD(int /* fd */ , int /* noxauth */ ); + +extern _X_EXPORT Bool AddClientOnOpenFD(int /* fd */ ); extern _X_EXPORT CARD32 GetTimeInMillis(void); extern _X_EXPORT CARD64 GetTimeInMicros(void); diff --git a/xorg-server/include/xkbsrv.h b/xorg-server/include/xkbsrv.h index a80e11970..229de2194 100644 --- a/xorg-server/include/xkbsrv.h +++ b/xorg-server/include/xkbsrv.h @@ -824,6 +824,9 @@ extern _X_EXPORT void XkbSendNewKeyboardNotify(DeviceIntPtr /* kbd */ , extern Bool XkbCopyKeymap(XkbDescPtr /* dst */ , XkbDescPtr /* src */ ); +extern _X_EXPORT Bool XkbCopyDeviceKeymap(DeviceIntPtr /* dst */, + DeviceIntPtr /* src */); + extern _X_EXPORT Bool XkbDeviceApplyKeymap(DeviceIntPtr /* dst */ , XkbDescPtr /* src */ ); diff --git a/xorg-server/mi/mibitblt.c b/xorg-server/mi/mibitblt.c index b0d14ae55..3ed4ed1cc 100644 --- a/xorg-server/mi/mibitblt.c +++ b/xorg-server/mi/mibitblt.c @@ -730,7 +730,7 @@ miPutImage(DrawablePtr pDraw, GCPtr pGC, int depth, ChangeGC(NullClient, pGC, GCForeground | GCBackground, gcv); bytesPer = (long) h *BitmapBytePad(w + leftPad); - for (i = 1 << (depth - 1); i != 0; i >>= 1, pImage += bytesPer) { + for (i = (unsigned long) 1 << (depth - 1); i != 0; i >>= 1, pImage += bytesPer) { if (i & oldPlanemask) { gcv[0].val = (XID) i; ChangeGC(NullClient, pGC, GCPlaneMask, gcv); diff --git a/xorg-server/mi/miinitext.c b/xorg-server/mi/miinitext.c index 67511b8d0..5b45ab4c2 100644 --- a/xorg-server/mi/miinitext.c +++ b/xorg-server/mi/miinitext.c @@ -234,7 +234,7 @@ EnableDisableExtensionError(const char *name, Bool enable) } /* List of built-in (statically linked) extensions */ -static ExtensionModule staticExtensions[] = { +static const ExtensionModule staticExtensions[] = { {GEExtensionInit, "Generic Event Extension", &noGEExtension}, {ShapeExtensionInit, "SHAPE", NULL}, #ifdef MITSHM @@ -312,15 +312,13 @@ static void AddStaticExtensions(void) { static Bool listInitialised = FALSE; - int i; if (listInitialised) return; listInitialised = TRUE; /* Add built-in extensions to the list. */ - for (i = 0; i < ARRAY_SIZE(staticExtensions); i++) - LoadExtension(&staticExtensions[i], TRUE); + LoadExtensionList(staticExtensions, ARRAY_SIZE(staticExtensions), TRUE); } void @@ -331,7 +329,7 @@ InitExtensions(int argc, char *argv[]) AddStaticExtensions(); - for (i = 0; ExtensionModuleList[i].name != NULL; i++) { + for (i = 0; i < numExtensionModules; i++) { ext = &ExtensionModuleList[i]; if (ext->initFunc != NULL && (ext->disablePtr == NULL || !*ext->disablePtr)) { @@ -341,50 +339,52 @@ InitExtensions(int argc, char *argv[]) } static ExtensionModule * -NewExtensionModule(void) +NewExtensionModuleList(int size) { ExtensionModule *save = ExtensionModuleList; int n; - /* Make sure built-in extensions get added to the list before those - * in modules. */ - AddStaticExtensions(); - /* Sanity check */ if (!ExtensionModuleList) numExtensionModules = 0; - n = numExtensionModules + 1; + n = numExtensionModules + size; ExtensionModuleList = realloc(ExtensionModuleList, - (n + 1) * sizeof(ExtensionModule)); + n * sizeof(ExtensionModule)); if (ExtensionModuleList == NULL) { ExtensionModuleList = save; return NULL; } else { - numExtensionModules++; - ExtensionModuleList[numExtensionModules].name = NULL; - return ExtensionModuleList + (numExtensionModules - 1); + numExtensionModules += size; + return ExtensionModuleList + (numExtensionModules - size); } } void -LoadExtension(const ExtensionModule * e, Bool builtin) +LoadExtensionList(const ExtensionModule ext[], int size, Bool builtin) { ExtensionModule *newext; + const char *msg; + int i; - if (e == NULL || e->name == NULL) - return; + /* Make sure built-in extensions get added to the list before those + * in modules. */ + AddStaticExtensions(); - if (!(newext = NewExtensionModule())) + if (!(newext = NewExtensionModuleList(size))) return; if (builtin) - ErrorF("Initializing built-in extension %s\n", e->name); + msg = "Initializing built-in"; else - ErrorF("Loading extension %s\n", e->name); + msg = "Loading"; + + for (i = 0; i < size; i++, newext++) { + ErrorF("%s extension %s\n", msg, ext[i].name); - newext->name = e->name; - newext->initFunc = e->initFunc; - newext->disablePtr = e->disablePtr; + newext->name = ext[i].name; + newext->initFunc = ext[i].initFunc; + newext->disablePtr = ext[i].disablePtr; + } } diff --git a/xorg-server/os/connection.c b/xorg-server/os/connection.c index ddf4f0a3a..b3640b8e4 100644 --- a/xorg-server/os/connection.c +++ b/xorg-server/os/connection.c @@ -138,6 +138,7 @@ fd_set OutputPending; /* clients with reply/event data ready to go */ int MaxClients = 0; Bool NewOutputPending; /* not yet attempted to write some new output */ Bool AnyClientsWriteBlocked; /* true if some client blocked on write */ +Bool NoListenAll; /* Don't establish any listening sockets */ static Bool RunFromSmartParent; /* send SIGUSR1 to parent process */ Bool RunFromSigStopParent; /* send SIGSTOP to our own process; Upstart (or @@ -406,7 +407,10 @@ CreateWellKnownSockets(void) /* display is initialized to "0" by main(). It is then set to the display * number if specified on the command line, or to NULL when the -displayfd * option is used. */ - if (display) { + if (NoListenAll) { + ListenTransCount = 0; + } + else if (display) { if (TryCreateSocket(atoi(display), &partial) && ListenTransCount >= 1) if (!PartialNetwork && partial) @@ -440,9 +444,10 @@ CreateWellKnownSockets(void) DefineSelf (fd); } - if (!XFD_ANYSET(&WellKnownConnections)) + if (!XFD_ANYSET(&WellKnownConnections) && !NoListenAll) FatalError ("Cannot establish any listening sockets - Make sure an X server isn't already running"); + #if !defined(WIN32) OsSignal(SIGPIPE, SIG_IGN); OsSignal(SIGHUP, AutoResetServer); @@ -1253,8 +1258,7 @@ MakeClientGrabPervious(ClientPtr client) } } -#ifdef XQUARTZ -/* Add a fd (from launchd) to our listeners */ +/* Add a fd (from launchd or similar) to our listeners */ void ListenOnOpenFD(int fd, int noxauth) { @@ -1276,7 +1280,7 @@ ListenOnOpenFD(int fd, int noxauth) */ ciptr = _XSERVTransReopenCOTSServer(5, fd, port); if (ciptr == NULL) { - ErrorF("Got NULL while trying to Reopen launchd port.\n"); + ErrorF("Got NULL while trying to Reopen listen port.\n"); return; } @@ -1309,4 +1313,29 @@ ListenOnOpenFD(int fd, int noxauth) #endif } -#endif +/* based on TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) */ +Bool +AddClientOnOpenFD(int fd) +{ + XtransConnInfo ciptr; + CARD32 connect_time; + char port[20]; + + snprintf(port, sizeof(port), ":%d", atoi(display)); + ciptr = _XSERVTransReopenCOTSServer(5, fd, port); + if (ciptr == NULL) + return FALSE; + + _XSERVTransSetOption(ciptr, TRANS_NONBLOCKING, 1); + ciptr->flags |= TRANS_NOXAUTH; + + connect_time = GetTimeInMillis(); + + if (!AllocNewConnection(ciptr, fd, connect_time)) { + ErrorConnMax(ciptr); + _XSERVTransClose(ciptr); + return FALSE; + } + + return TRUE; +} diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c index 497779b52..c513968ad 100644 --- a/xorg-server/os/utils.c +++ b/xorg-server/os/utils.c @@ -270,7 +270,7 @@ LockServer(void) int len; char port[20]; - if (nolock) + if (nolock || NoListenAll) return; /* * Path names @@ -390,7 +390,7 @@ LockServer(void) void UnlockServer(void) { - if (nolock) + if (nolock || NoListenAll) return; if (!StillLocking) { diff --git a/xorg-server/test/Makefile.am b/xorg-server/test/Makefile.am index f8aa65950..88fb6aa96 100644 --- a/xorg-server/test/Makefile.am +++ b/xorg-server/test/Makefile.am @@ -30,7 +30,6 @@ endif xkb_LDADD=$(TEST_LDADD) input_LDADD=$(TEST_LDADD) xtest_LDADD=$(TEST_LDADD) -list_LDADD=$(TEST_LDADD) misc_LDADD=$(TEST_LDADD) fixes_LDADD=$(TEST_LDADD) xfree86_LDADD=$(TEST_LDADD) diff --git a/xorg-server/xkb/xkbUtils.c b/xorg-server/xkb/xkbUtils.c index 6cf6e79df..c14a790df 100644 --- a/xorg-server/xkb/xkbUtils.c +++ b/xorg-server/xkb/xkbUtils.c @@ -2027,6 +2027,12 @@ XkbDeviceApplyKeymap(DeviceIntPtr dst, XkbDescPtr desc) return ret; } +Bool +XkbCopyDeviceKeymap(DeviceIntPtr dst, DeviceIntPtr src) +{ + return XkbDeviceApplyKeymap(dst, src->key->xkbInfo->desc); +} + int XkbGetEffectiveGroup(XkbSrvInfoPtr xkbi, XkbStatePtr xkbState, CARD8 keycode) { |