diff options
86 files changed, 939 insertions, 683 deletions
diff --git a/fontconfig/doc/Makefile.am b/fontconfig/doc/Makefile.am index 2e7363cf6..80674df68 100644 --- a/fontconfig/doc/Makefile.am +++ b/fontconfig/doc/Makefile.am @@ -176,16 +176,11 @@ fonts-conf.5: local-fontconfig-user.sgml version.sgml confdir.sgml $(man3_MANS): func.refs func.refs: local-fontconfig-devel.sgml $(DOCS_DEPS) $(AM_V_GEN) $(RM) $@; \ - [ "x$(builddir)" != "x$(srcdir)" ] && \ - for f in $(DOC_FUNCS_SGML); do \ - $(RM) $(builddir)/$$f || :; \ - $(LN_S) $(srcdir)/$$f $(builddir)/$$f; \ - done || :; \ $(DOC2MAN) -o devel-man local-fontconfig-devel.sgml && \ mv devel-man/manpage.refs func.refs && \ mv devel-man/*.3 . && \ $(RM) devel-man/manpage.* && \ - rmdir devel-man + rmdir devel-man || rm $@ || : confdir.sgml: $(srcdir)/confdir.sgml.in $(AM_V_GEN) sed -e 's,@CONFDIR\@,${CONFDIR},' $(srcdir)/$@.in | awk '{if (NR > 1) printf("\n"); printf("%s", $$0);}' > $@ ## @@ -207,7 +202,7 @@ local-fontconfig-devel.sgml: $(srcdir)/fontconfig-devel.sgml all-local: $(BUILT_DOCS) $(HTML_DIR)/* clean-local: $(RM) -r $(HTML_DIR) devel-man - [ "x$(builddir)" != "x$(srcdir)" ] && $(RM) $(builddir)/fontconfig-user.sgml $(builddir)/fontconfig-devel.sgml || : + [ "x$(builddir)" != "x$(srcdir)" ] && $(RM) $(builddir)/*.sgml || : else htmldoc_DATA += $(srcdir)/$(HTML_DIR)/* all-local: diff --git a/fontconfig/fc-case/Makefile.am b/fontconfig/fc-case/Makefile.am index 691482468..6fe3a4484 100644 --- a/fontconfig/fc-case/Makefile.am +++ b/fontconfig/fc-case/Makefile.am @@ -45,7 +45,10 @@ if CROSS_COMPILING $(TARG): $(STMPL) fc-case.c $(SCASEFOLDING) @echo Warning: cannot rebuild $(TARG) when cross-compiling else -$(TARG): $(STMPL) fc-case$(EXEEXT) $(SCASEFOLDING) +## BUILT_SOURCES doesn't effect to 'distcheck' +## so $(ALIAS_FILES) has to be appeared prior to fc-case$(EXEEXT) +## to make sure availability. +$(TARG): $(STMPL) $(ALIAS_FILES) fc-case$(EXEEXT) $(SCASEFOLDING) $(AM_V_GEN) $(RM) $(TARG); \ ./fc-case$(EXEEXT) $(SCASEFOLDING) < $(STMPL) > $(TARG).tmp && \ mv $(TARG).tmp $(TARG) @@ -56,7 +59,7 @@ ALIAS_FILES = fcalias.h fcaliastail.h BUILT_SOURCES = $(ALIAS_FILES) $(ALIAS_FILES): - touch $(ALIAS_FILES) + $(AM_V_GEN) touch $@ CLEANFILES = $(ALIAS_FILES) diff --git a/fontconfig/fc-glyphname/Makefile.am b/fontconfig/fc-glyphname/Makefile.am index fdba146c9..e33b3ba6a 100644 --- a/fontconfig/fc-glyphname/Makefile.am +++ b/fontconfig/fc-glyphname/Makefile.am @@ -40,7 +40,10 @@ if CROSS_COMPILING $(TARG): $(STMPL) fc-glyphname.c $(SGLYPHNAME) @echo Warning: cannot rebuild $(TARG) when cross-compiling else -$(TARG): $(STMPL) fc-glyphname$(EXEEXT) $(SGLYPHNAME) +## BUILT_SOURCES doesn't effect to 'distcheck' +## so $(ALIAS_FILES) has to be appeared prior to fc-glyphname$(EXEEXT) +## to make sure availability. +$(TARG): $(STMPL) $(ALIAS_FILES) fc-glyphname$(EXEEXT) $(SGLYPHNAME) $(AM_V_GEN) $(RM) $(TARG); \ ./fc-glyphname$(EXEEXT) $(SGLYPHNAME) < $(STMPL) > $(TARG).tmp && \ mv $(TARG).tmp $(TARG) @@ -48,10 +51,10 @@ endif ALIAS_FILES = fcalias.h fcaliastail.h -BUILT_SOURCES = $(ALIAS_FILES) $(TARG) +BUILT_SOURCES = $(ALIAS_FILES) $(ALIAS_FILES): - touch $(ALIAS_FILES) + $(AM_V_GEN) touch $@ CLEANFILES = $(ALIAS_FILES) diff --git a/fontconfig/fc-lang/Makefile.am b/fontconfig/fc-lang/Makefile.am index 5c2d1bfe7..3336511bf 100644 --- a/fontconfig/fc-lang/Makefile.am +++ b/fontconfig/fc-lang/Makefile.am @@ -39,7 +39,10 @@ if CROSS_COMPILING $(TARG):$(ORTH) fc-lang.c $(STMPL) @echo Warning: cannot rebuild $(TARG) when cross-compiling else -$(TARG):$(ORTH) fc-lang${EXEEXT} $(STMPL) +## BUILT_SOURCES doesn't effect to 'distcheck' +## so $(ALIAS_FILES) has to be appeared prior to fc-lang$(EXEEXT) +## to make sure availability. +$(TARG):$(ORTH) $(ALIAS_FILES) fc-lang${EXEEXT} $(STMPL) $(AM_V_GEN) $(RM) $(TARG); \ ./fc-lang${EXEEXT} -d ${srcdir} $(ORTH) < $(STMPL) > $(TARG).tmp && \ mv $(TARG).tmp $(TARG) @@ -47,10 +50,10 @@ endif ALIAS_FILES = fcalias.h fcaliastail.h -BUILT_SOURCES = $(ALIAS_FILES) $(TARG) +BUILT_SOURCES = $(ALIAS_FILES) $(ALIAS_FILES): - touch $(ALIAS_FILES) + $(AM_V_GEN) touch $@ CLEANFILES = $(ALIAS_FILES) diff --git a/mesalib/configure.ac b/mesalib/configure.ac index 4fb454407..803c25649 100644 --- a/mesalib/configure.ac +++ b/mesalib/configure.ac @@ -1273,10 +1273,6 @@ if test "x$enable_egl" = xyes; then if test "$enable_static" != yes; then # build egl_glx when libGL is built - if test "x$enable_glx" = xyes; then - HAVE_EGL_DRIVER_GLX=1 - fi - PKG_CHECK_MODULES([LIBUDEV], [libudev > 150], [have_libudev=yes],[have_libudev=no]) if test "$have_libudev" = yes; then @@ -1534,8 +1530,7 @@ for plat in $egl_platforms; do ;; wayland) - PKG_CHECK_MODULES([WAYLAND], [wayland-client >= 0.99.0 wayland-server >= 0.99.0],, \ - [AC_MSG_ERROR([cannot find libwayland-client])]) + PKG_CHECK_MODULES([WAYLAND], [wayland-client >= 1.0.2 wayland-server >= 1.0.2]) GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/wayland" WAYLAND_PREFIX=`$PKG_CONFIG --variable=prefix wayland-client` @@ -1545,6 +1540,10 @@ for plat in $egl_platforms; do x11) PKG_CHECK_MODULES([XCB_DRI2], [x11-xcb xcb-dri2 >= 1.8 xcb-xfixes]) + + if test "x$enable_glx" = xyes; then + HAVE_EGL_DRIVER_GLX=1 + fi ;; drm) diff --git a/mesalib/include/GL/internal/dri_interface.h b/mesalib/include/GL/internal/dri_interface.h index 1e0f1d07b..568581d5b 100644 --- a/mesalib/include/GL/internal/dri_interface.h +++ b/mesalib/include/GL/internal/dri_interface.h @@ -267,7 +267,17 @@ struct __DRItexBufferExtensionRec { * Used by drivers that implement DRI2 */ #define __DRI2_FLUSH "DRI2_Flush" -#define __DRI2_FLUSH_VERSION 3 +#define __DRI2_FLUSH_VERSION 4 + +#define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */ +#define __DRI2_FLUSH_CONTEXT (1 << 1) /* glFlush should be called */ + +enum __DRI2throttleReason { + __DRI2_THROTTLE_SWAPBUFFER, + __DRI2_THROTTLE_COPYSUBBUFFER, + __DRI2_THROTTLE_FLUSHFRONT +}; + struct __DRI2flushExtensionRec { __DRIextension base; void (*flush)(__DRIdrawable *drawable); @@ -281,6 +291,27 @@ struct __DRI2flushExtensionRec { * \since 3 */ void (*invalidate)(__DRIdrawable *drawable); + + /** + * This function reduces the number of flushes in the driver by combining + * several operations into one call. + * + * It can: + * - throttle + * - flush a drawable + * - flush a context + * + * \param context the context + * \param drawable the drawable to flush + * \param flags a combination of _DRI2_FLUSH_xxx flags + * \param throttle_reason the reason for throttling, 0 = no throttling + * + * \since 4 + */ + void (*flush_with_flags)(__DRIcontext *ctx, + __DRIdrawable *drawable, + unsigned flags, + enum __DRI2throttleReason throttle_reason); }; @@ -292,12 +323,6 @@ struct __DRI2flushExtensionRec { #define __DRI2_THROTTLE "DRI2_Throttle" #define __DRI2_THROTTLE_VERSION 1 -enum __DRI2throttleReason { - __DRI2_THROTTLE_SWAPBUFFER, - __DRI2_THROTTLE_COPYSUBBUFFER, - __DRI2_THROTTLE_FLUSHFRONT -}; - struct __DRI2throttleExtensionRec { __DRIextension base; void (*throttle)(__DRIcontext *ctx, diff --git a/mesalib/src/gallium/auxiliary/util/u_format.c b/mesalib/src/gallium/auxiliary/util/u_format.c index ddce95601..8228de1f2 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format.c +++ b/mesalib/src/gallium/auxiliary/util/u_format.c @@ -134,47 +134,6 @@ util_format_is_pure_uint(enum pipe_format format) return (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED && desc->channel[i].pure_integer) ? TRUE : FALSE; } -boolean -util_format_is_array(const struct util_format_description *desc) -{ - unsigned chan; - - if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN || - desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB || - desc->block.width != 1 || - desc->block.height != 1) { - return FALSE; - } - - for (chan = 0; chan < desc->nr_channels; ++chan) { - if (desc->channel[chan].size != desc->channel[0].size) - return FALSE; - - if (desc->channel[chan].type == UTIL_FORMAT_TYPE_VOID && (chan + 1) == desc->nr_channels) - continue; - - if (desc->channel[chan].type != desc->channel[0].type) - return FALSE; - - if (desc->channel[chan].normalized != desc->channel[0].normalized) - return FALSE; - - if (desc->channel[chan].pure_integer != desc->channel[0].pure_integer) - return FALSE; - } - - if (desc->nr_channels == 4) { - if (desc->swizzle[3] < 3) - return FALSE; - } else { - for (chan = 0; chan < desc->nr_channels; ++chan) { - if (desc->swizzle[chan] != chan) - return FALSE; - } - } - - return TRUE; -} boolean util_format_is_luminance_alpha(enum pipe_format format) diff --git a/mesalib/src/gallium/auxiliary/util/u_format.h b/mesalib/src/gallium/auxiliary/util/u_format.h index 25bfd234b..024dabb07 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format.h +++ b/mesalib/src/gallium/auxiliary/util/u_format.h @@ -156,7 +156,7 @@ struct util_format_description unsigned nr_channels:3; /** - * Whether all channels have the same number of (whole) bytes. + * Whether all channels have the same number of (whole) bytes and type. */ unsigned is_array:1; @@ -591,16 +591,6 @@ boolean util_format_is_pure_uint(enum pipe_format format); /** - * Whether the format is a simple array format where all channels - * are of the same type and can be loaded from memory as a vector. - * - * If format is 4 channel it can be swizzled (eg BGRA) as long - * as the alpha is the 3rd channel. - */ -boolean -util_format_is_array(const struct util_format_description *desc); - -/** * Check if the src format can be blitted to the destination format with * a simple memcpy. For example, blitting from RGBA to RGBx is OK, but not * the reverse. diff --git a/mesalib/src/gallium/auxiliary/util/u_format_other.c b/mesalib/src/gallium/auxiliary/util/u_format_other.c index c23f4ee4a..85001c14f 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_other.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_other.c @@ -342,7 +342,7 @@ util_format_r8g8bx_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, int16_t r, g; #ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); + value = util_bswap16(value); #endif r = ((int16_t)(value << 8)) >> 8; @@ -374,7 +374,7 @@ util_format_r8g8bx_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_strid int16_t r, g; #ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); + value = util_bswap16(value); #endif r = ((int16_t)(value << 8)) >> 8; @@ -408,7 +408,7 @@ util_format_r8g8bx_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, value |= (uint16_t)((((int8_t)(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ; #ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); + value = util_bswap16(value); #endif *dst++ = value; @@ -438,7 +438,7 @@ util_format_r8g8bx_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, value |= (src[1] >> 1) << 8; #ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); + value = util_bswap16(value); #endif *dst++ = value; @@ -459,7 +459,7 @@ util_format_r8g8bx_snorm_fetch_rgba_float(float *dst, const uint8_t *src, int16_t r, g; #ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); + value = util_bswap16(value); #endif r = ((int16_t)(value << 8)) >> 8; diff --git a/mesalib/src/gallium/auxiliary/util/u_format_parse.py b/mesalib/src/gallium/auxiliary/util/u_format_parse.py index 3a39e5ba5..07052b996 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_parse.py +++ b/mesalib/src/gallium/auxiliary/util/u_format_parse.py @@ -144,9 +144,18 @@ class Format: if self.layout != PLAIN: return False ref_channel = self.channels[0] - for channel in self.channels[1:]: + if ref_channel.type == VOID: + ref_channel = self.channels[1] + for channel in self.channels: if channel.size and (channel.size != ref_channel.size or channel.size % 8): return False + if channel.type != VOID: + if channel.type != ref_channel.type: + return False + if channel.norm != ref_channel.norm: + return False + if channel.pure != ref_channel.pure: + return False return True def is_mixed(self): diff --git a/mesalib/src/gallium/auxiliary/util/u_inlines.h b/mesalib/src/gallium/auxiliary/util/u_inlines.h index 6ef5fecc6..cb06ee2e0 100644 --- a/mesalib/src/gallium/auxiliary/util/u_inlines.h +++ b/mesalib/src/gallium/auxiliary/util/u_inlines.h @@ -114,6 +114,22 @@ pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf) *ptr = surf; } +/** + * Similar to pipe_surface_reference() but always set the pointer to NULL + * and pass in an explicit context. The explicit context avoids the problem + * of using a deleted context's surface_destroy() method when freeing a surface + * that's shared by multiple contexts. + */ +static INLINE void +pipe_surface_release(struct pipe_context *pipe, struct pipe_surface **ptr) +{ + if (pipe_reference_described(&(*ptr)->reference, NULL, + (debug_reference_descriptor)debug_describe_surface)) + pipe->surface_destroy(pipe, *ptr); + *ptr = NULL; +} + + static INLINE void pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex) { diff --git a/mesalib/src/glsl/glcpp/README b/mesalib/src/glsl/glcpp/README index 0b5ef508c..0637935e2 100644 --- a/mesalib/src/glsl/glcpp/README +++ b/mesalib/src/glsl/glcpp/README @@ -20,13 +20,11 @@ to encounter and deal with the following preprocessor macros: #pragma #extension -All other macros will be handles according to the GLSL specification +All other macros will be handled according to the GLSL specification and will not appear in the output. Known limitations ----------------- -The __LINE__ and __FILE__ macros are not yet supported. - A file that ends with a function-like macro name as the last non-whitespace token will result in a parse error, (where it should be passed through as is).
\ No newline at end of file diff --git a/mesalib/src/glsl/glcpp/glcpp-parse.y b/mesalib/src/glsl/glcpp/glcpp-parse.y index b0537c3b0..e7daf7fea 100644 --- a/mesalib/src/glsl/glcpp/glcpp-parse.y +++ b/mesalib/src/glsl/glcpp/glcpp-parse.y @@ -1054,26 +1054,67 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other) return combined; } - /* Two string-valued tokens can usually just be mashed - * together. + /* Two string-valued (or integer) tokens can usually just be + * mashed together. (We also handle a string followed by an + * integer here as well.) * - * XXX: This isn't actually legitimate. Several things here - * should result in a diagnostic since the result cannot be a - * valid, single pre-processing token. For example, pasting - * "123" and "abc" is not legal, but we don't catch that - * here. */ - if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) && - (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING)) + * There are some exceptions here. Notably, if the first token + * is an integer (or a string representing an integer), then + * the second token must also be an integer or must be a + * string representing an integer that begins with a digit. + */ + if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING || token->type == INTEGER) && + (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING || other->type == INTEGER)) { char *str; + int combined_type; + + /* Check that pasting onto an integer doesn't create a + * non-integer, (that is, only digits can be + * pasted. */ + if (token->type == INTEGER_STRING || token->type == INTEGER) + { + switch (other->type) { + case INTEGER_STRING: + if (other->value.str[0] < '0' || + other->value.str[0] > '9') + goto FAIL; + break; + case INTEGER: + if (other->value.ival < 0) + goto FAIL; + break; + default: + goto FAIL; + } + } - str = ralloc_asprintf (token, "%s%s", token->value.str, - other->value.str); - combined = _token_create_str (token, token->type, str); + if (token->type == INTEGER) + str = ralloc_asprintf (token, "%" PRIiMAX, + token->value.ival); + else + str = ralloc_strdup (token, token->value.str); + + + if (other->type == INTEGER) + ralloc_asprintf_append (&str, "%" PRIiMAX, + other->value.ival); + else + ralloc_strcat (&str, other->value.str); + + /* New token is same type as original token, unless we + * started with an integer, in which case we will be + * creating an integer-string. */ + combined_type = token->type; + if (combined_type == INTEGER) + combined_type = INTEGER_STRING; + + combined = _token_create_str (token, combined_type, str); combined->location = token->location; return combined; } + FAIL: glcpp_error (&token->location, parser, ""); ralloc_asprintf_rewrite_tail (&parser->info_log, &parser->info_log_length, "Pasting \""); _token_print (&parser->info_log, &parser->info_log_length, token); @@ -1300,18 +1341,30 @@ _arguments_parse (argument_list_t *arguments, } static token_list_t * -_token_list_create_with_one_space (void *ctx) +_token_list_create_with_one_ival (void *ctx, int type, int ival) { token_list_t *list; - token_t *space; + token_t *node; list = _token_list_create (ctx); - space = _token_create_ival (list, SPACE, SPACE); - _token_list_append (list, space); + node = _token_create_ival (list, type, ival); + _token_list_append (list, node); return list; } +static token_list_t * +_token_list_create_with_one_space (void *ctx) +{ + return _token_list_create_with_one_ival (ctx, SPACE, SPACE); +} + +static token_list_t * +_token_list_create_with_one_integer (void *ctx, int ival) +{ + return _token_list_create_with_one_ival (ctx, INTEGER, ival); +} + /* Perform macro expansion on 'list', placing the resulting tokens * into a new list which is initialized with a first token of type * 'head_token_type'. Then begin lexing from the resulting list, @@ -1528,8 +1581,18 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser, return NULL; } - /* Look up this identifier in the hash table. */ + *last = node; identifier = token->value.str; + + /* Special handling for __LINE__ and __FILE__, (not through + * the hash table). */ + if (strcmp(identifier, "__LINE__") == 0) + return _token_list_create_with_one_integer (parser, node->token->location.first_line); + + if (strcmp(identifier, "__FILE__") == 0) + return _token_list_create_with_one_integer (parser, node->token->location.source); + + /* Look up this identifier in the hash table. */ macro = hash_table_find (parser->defines, identifier); /* Not a macro, so no expansion needed. */ @@ -1550,14 +1613,12 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser, final = _token_create_str (parser, OTHER, str); expansion = _token_list_create (parser); _token_list_append (expansion, final); - *last = node; return expansion; } if (! macro->is_function) { token_list_t *replacement; - *last = node; /* Replace a macro defined as empty with a SPACE token. */ if (macro->replacements == NULL) diff --git a/mesalib/src/glsl/glcpp/glcpp.c b/mesalib/src/glsl/glcpp/glcpp.c index 35db47087..7c2ded850 100644 --- a/mesalib/src/glsl/glcpp/glcpp.c +++ b/mesalib/src/glsl/glcpp/glcpp.c @@ -111,7 +111,7 @@ main (int argc, char *argv[]) if (shader == NULL) return 1; - ret = glcpp_preprocess(ctx, &shader, &info_log, NULL, API_OPENGL); + ret = glcpp_preprocess(ctx, &shader, &info_log, NULL, API_OPENGL_COMPAT); printf("%s", shader); fprintf(stderr, "%s", info_log); diff --git a/mesalib/src/glsl/ir_function_detect_recursion.cpp b/mesalib/src/glsl/ir_function_detect_recursion.cpp index 0a5e647cd..4b39f9724 100644 --- a/mesalib/src/glsl/ir_function_detect_recursion.cpp +++ b/mesalib/src/glsl/ir_function_detect_recursion.cpp @@ -173,6 +173,7 @@ public: has_recursion_visitor() : current(NULL) { + progress = false; this->mem_ctx = ralloc_context(NULL); this->function_hash = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); diff --git a/mesalib/src/glsl/ir_validate.cpp b/mesalib/src/glsl/ir_validate.cpp index af0b5768a..ad57a3149 100644 --- a/mesalib/src/glsl/ir_validate.cpp +++ b/mesalib/src/glsl/ir_validate.cpp @@ -120,7 +120,7 @@ ir_visitor_status ir_validate::visit_leave(ir_loop *ir) { if (ir->counter != NULL) { - if ((ir->from == NULL) || (ir->from == NULL) || (ir->increment == NULL)) { + if ((ir->from == NULL) || (ir->to == NULL) || (ir->increment == NULL)) { printf("ir_loop has invalid loop controls:\n" " counter: %p\n" " from: %p\n" @@ -136,7 +136,7 @@ ir_validate::visit_leave(ir_loop *ir) abort(); } } else { - if ((ir->from != NULL) || (ir->from != NULL) || (ir->increment != NULL)) { + if ((ir->from != NULL) || (ir->to != NULL) || (ir->increment != NULL)) { printf("ir_loop has invalid loop controls:\n" " counter: %p\n" " from: %p\n" diff --git a/mesalib/src/glsl/main.cpp b/mesalib/src/glsl/main.cpp index 04143ad43..33cd79c85 100644 --- a/mesalib/src/glsl/main.cpp +++ b/mesalib/src/glsl/main.cpp @@ -223,7 +223,7 @@ main(int argc, char **argv) if (argc <= optind) usage_fail(argv[0]); - initialize_context(ctx, (glsl_es) ? API_OPENGLES2 : API_OPENGL); + initialize_context(ctx, (glsl_es) ? API_OPENGLES2 : API_OPENGL_COMPAT); struct gl_shader_program *whole_program; diff --git a/mesalib/src/glsl/opt_constant_propagation.cpp b/mesalib/src/glsl/opt_constant_propagation.cpp index c5ae36b69..a03811999 100644 --- a/mesalib/src/glsl/opt_constant_propagation.cpp +++ b/mesalib/src/glsl/opt_constant_propagation.cpp @@ -92,6 +92,7 @@ public: ir_constant_propagation_visitor() { progress = false; + killed_all = false; mem_ctx = ralloc_context(0); this->acp = new(mem_ctx) exec_list; this->kills = new(mem_ctx) exec_list; diff --git a/mesalib/src/glsl/test_optpass.cpp b/mesalib/src/glsl/test_optpass.cpp index 5ed11702c..ce5df24d9 100644 --- a/mesalib/src/glsl/test_optpass.cpp +++ b/mesalib/src/glsl/test_optpass.cpp @@ -197,7 +197,7 @@ int test_optpass(int argc, char **argv) struct gl_context local_ctx; struct gl_context *ctx = &local_ctx; - initialize_context_to_defaults(ctx, API_OPENGL); + initialize_context_to_defaults(ctx, API_OPENGL_COMPAT); ctx->Driver.NewShader = _mesa_new_shader; diff --git a/mesalib/src/mapi/glapi/gen/gl_genexec.py b/mesalib/src/mapi/glapi/gen/gl_genexec.py index 9b716894c..593d1955b 100644 --- a/mesalib/src/mapi/glapi/gen/gl_genexec.py +++ b/mesalib/src/mapi/glapi/gen/gl_genexec.py @@ -166,7 +166,7 @@ class PrintCode(gl_XML.gl_print_base): condition_parts = [] if f.desktop: if f.deprecated: - condition_parts.append('ctx->API == API_OPENGL') + condition_parts.append('ctx->API == API_OPENGL_COMPAT') else: condition_parts.append('_mesa_is_desktop_gl(ctx)') if 'es1' in f.api_map: diff --git a/mesalib/src/mesa/Android.gen.mk b/mesalib/src/mesa/Android.gen.mk index 5f0d73cff..35f00da09 100644 --- a/mesalib/src/mesa/Android.gen.mk +++ b/mesalib/src/mesa/Android.gen.mk @@ -32,6 +32,7 @@ intermediates := $(call local-intermediates-dir) # This is the list of auto-generated files: sources and headers sources := \ main/enums.c \ + main/api_exec.c \ main/dispatch.h \ main/remap_helper.h \ main/get_hash.h diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index 7d58281c1..d5e8af3c0 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -567,7 +567,7 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) save->PolygonCull = ctx->Polygon.CullFlag; _mesa_PolygonMode(GL_FRONT_AND_BACK, GL_FILL); _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, GL_FALSE); - if (ctx->API == API_OPENGL) { + if (ctx->API == API_OPENGL_COMPAT) { _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, GL_FALSE); _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, GL_FALSE); } @@ -580,14 +580,14 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) } if (state & MESA_META_SHADER) { - if (ctx->API == API_OPENGL && ctx->Extensions.ARB_vertex_program) { + if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_vertex_program) { save->VertexProgramEnabled = ctx->VertexProgram.Enabled; _mesa_reference_vertprog(ctx, &save->VertexProgram, ctx->VertexProgram.Current); _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, GL_FALSE); } - if (ctx->API == API_OPENGL && ctx->Extensions.ARB_fragment_program) { + if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_fragment_program) { save->FragmentProgramEnabled = ctx->FragmentProgram.Enabled; _mesa_reference_fragprog(ctx, &save->FragmentProgram, ctx->FragmentProgram.Current); @@ -623,7 +623,7 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) save->EnvMode = ctx->Texture.Unit[0].EnvMode; /* Disable all texture units */ - if (ctx->API == API_OPENGL || ctx->API == API_OPENGLES) { + if (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES) { for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { save->TexEnabled[u] = ctx->Texture.Unit[u].Enabled; save->TexGenEnabled[u] = ctx->Texture.Unit[u].TexGenEnabled; @@ -636,7 +636,7 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) if (ctx->Extensions.OES_EGL_image_external) _mesa_set_enable(ctx, GL_TEXTURE_EXTERNAL_OES, GL_FALSE); - if (ctx->API == API_OPENGL) { + if (ctx->API == API_OPENGL_COMPAT) { _mesa_set_enable(ctx, GL_TEXTURE_1D, GL_FALSE); _mesa_set_enable(ctx, GL_TEXTURE_3D, GL_FALSE); if (ctx->Extensions.NV_texture_rectangle) @@ -661,7 +661,7 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) /* set defaults for unit[0] */ _mesa_ActiveTexture(GL_TEXTURE0); _mesa_ClientActiveTexture(GL_TEXTURE0); - if (ctx->API == API_OPENGL || ctx->API == API_OPENGLES) { + if (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES) { _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); } } @@ -684,11 +684,9 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) _mesa_LoadIdentity(); _mesa_MatrixMode(GL_PROJECTION); _mesa_LoadIdentity(); - if (ctx->DrawBuffer->Initialized) { - _mesa_Ortho(0.0, ctx->DrawBuffer->Width, - 0.0, ctx->DrawBuffer->Height, - -1.0, 1.0); - } + _mesa_Ortho(0.0, ctx->DrawBuffer->Width, + 0.0, ctx->DrawBuffer->Height, + -1.0, 1.0); } if (state & MESA_META_CLIP) { @@ -885,7 +883,7 @@ _mesa_meta_end(struct gl_context *ctx) _mesa_PolygonMode(GL_FRONT, save->FrontPolygonMode); _mesa_PolygonMode(GL_BACK, save->BackPolygonMode); } - if (ctx->API == API_OPENGL) { + if (ctx->API == API_OPENGL_COMPAT) { _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, save->PolygonStipple); _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, save->PolygonSmooth); } @@ -900,7 +898,7 @@ _mesa_meta_end(struct gl_context *ctx) } if (state & MESA_META_SHADER) { - if (ctx->API == API_OPENGL && ctx->Extensions.ARB_vertex_program) { + if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_vertex_program) { _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, save->VertexProgramEnabled); _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, @@ -908,7 +906,7 @@ _mesa_meta_end(struct gl_context *ctx) _mesa_reference_vertprog(ctx, &save->VertexProgram, NULL); } - if (ctx->API == API_OPENGL && ctx->Extensions.ARB_fragment_program) { + if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_fragment_program) { _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, save->FragmentProgramEnabled); _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, @@ -941,7 +939,7 @@ _mesa_meta_end(struct gl_context *ctx) _mesa_set_enable(ctx, GL_STENCIL_TEST, stencil->Enabled); _mesa_ClearStencil(stencil->Clear); - if (ctx->API == API_OPENGL && ctx->Extensions.EXT_stencil_two_side) { + if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_stencil_two_side) { _mesa_set_enable(ctx, GL_STENCIL_TEST_TWO_SIDE_EXT, stencil->TestTwoSide); _mesa_ActiveStencilFaceEXT(stencil->ActiveFace @@ -973,7 +971,7 @@ _mesa_meta_end(struct gl_context *ctx) ASSERT(ctx->Texture.CurrentUnit == 0); /* restore texenv for unit[0] */ - if (ctx->API == API_OPENGL || ctx->API == API_OPENGLES) { + if (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES) { _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, save->EnvMode); } @@ -988,7 +986,7 @@ _mesa_meta_end(struct gl_context *ctx) } /* Restore fixed function texture enables, texgen */ - if (ctx->API == API_OPENGL || ctx->API == API_OPENGLES) { + if (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES) { for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { if (ctx->Texture.Unit[u].Enabled != save->TexEnabled[u]) { FLUSH_VERTICES(ctx, _NEW_TEXTURE); @@ -3268,7 +3266,7 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, mipmap->FBO); - if (ctx->API == API_OPENGL || ctx->API == API_OPENGLES) + if (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES) _mesa_TexParameteri(target, GL_GENERATE_MIPMAP, GL_FALSE); else assert(!genMipmapSave); @@ -3687,6 +3685,7 @@ decompress_texture_image(struct gl_context *ctx, /* read pixels from renderbuffer */ { GLenum baseTexFormat = texImage->_BaseFormat; + GLenum destBaseFormat = _mesa_base_tex_format(ctx, destFormat); /* The pixel transfer state will be set to default values at this point * (see MESA_META_PIXEL_TRANSFER) so pixel transfer ops are effectively @@ -3695,9 +3694,19 @@ decompress_texture_image(struct gl_context *ctx, * returned as red and two-channel texture values are returned as * red/alpha. */ - if (baseTexFormat == GL_LUMINANCE || - baseTexFormat == GL_LUMINANCE_ALPHA || - baseTexFormat == GL_INTENSITY) { + if ((baseTexFormat == GL_LUMINANCE || + baseTexFormat == GL_LUMINANCE_ALPHA || + baseTexFormat == GL_INTENSITY) || + /* If we're reading back an RGB(A) texture (using glGetTexImage) as + * luminance then we need to return L=tex(R). + */ + ((baseTexFormat == GL_RGBA || + baseTexFormat == GL_RGB || + baseTexFormat == GL_RG) && + (destBaseFormat == GL_LUMINANCE || + destBaseFormat == GL_LUMINANCE_ALPHA || + destBaseFormat == GL_LUMINANCE_INTEGER_EXT || + destBaseFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT))) { /* Green and blue must be zero */ _mesa_PixelTransferf(GL_GREEN_SCALE, 0.0f); _mesa_PixelTransferf(GL_BLUE_SCALE, 0.0f); diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c index 917b9465b..9cebcea92 100644 --- a/mesalib/src/mesa/drivers/dri/common/dri_util.c +++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c @@ -183,7 +183,7 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api, switch (api) { case __DRI_API_OPENGL: - mesa_api = API_OPENGL; + mesa_api = API_OPENGL_COMPAT; break; case __DRI_API_GLES: mesa_api = API_OPENGLES; @@ -221,13 +221,13 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api, } /* Mesa does not support the GL_ARB_compatibilty extension or the - * compatibility profile. This means that we treat a API_OPENGL 3.1 as - * API_OPENGL_CORE and reject API_OPENGL 3.2+. + * compatibility profile. This means that we treat a API_OPENGL_COMPAT 3.1 as + * API_OPENGL_CORE and reject API_OPENGL_COMPAT 3.2+. */ - if (mesa_api == API_OPENGL && major_version == 3 && minor_version == 1) + if (mesa_api == API_OPENGL_COMPAT && major_version == 3 && minor_version == 1) mesa_api = API_OPENGL_CORE; - if (mesa_api == API_OPENGL + if (mesa_api == API_OPENGL_COMPAT && ((major_version > 3) || (major_version == 3 && minor_version >= 2))) { *error = __DRI_CTX_ERROR_BAD_API; @@ -244,7 +244,7 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api, * anything specific about this case. However, none of the known flags * have any meaning in an ES context, so this seems safe. */ - if (mesa_api != API_OPENGL + if (mesa_api != API_OPENGL_COMPAT && mesa_api != API_OPENGL_CORE && flags != 0) { *error = __DRI_CTX_ERROR_BAD_FLAG; diff --git a/mesalib/src/mesa/drivers/dri/common/drisw_util.c b/mesalib/src/mesa/drivers/dri/common/drisw_util.c index d69274854..8fdb05ec3 100644 --- a/mesalib/src/mesa/drivers/dri/common/drisw_util.c +++ b/mesalib/src/mesa/drivers/dri/common/drisw_util.c @@ -117,7 +117,7 @@ driCreateContextAttribs(__DRIscreen *screen, int api, switch (api) { case __DRI_API_OPENGL: - mesa_api = API_OPENGL; + mesa_api = API_OPENGL_COMPAT; break; case __DRI_API_GLES: mesa_api = API_OPENGLES; diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c index 45ef3c246..2474ed88f 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c @@ -251,14 +251,14 @@ choose_pixel_format(const struct gl_config *v) } static void -swrast_delete_renderbuffer(struct gl_renderbuffer *rb) +swrast_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) { struct dri_swrast_renderbuffer *xrb = dri_swrast_renderbuffer(rb); TRACE; free(xrb->Base.Buffer); - _mesa_delete_renderbuffer(rb); + _mesa_delete_renderbuffer(ctx, rb); } /* see bytes_per_line in libGL */ @@ -706,7 +706,7 @@ dri_create_context(gl_api api, (void) flags; switch (api) { - case API_OPENGL: + case API_OPENGL_COMPAT: if (major_version > 2 || (major_version == 2 && minor_version > 1)) { *error = __DRI_CTX_ERROR_BAD_VERSION; @@ -768,7 +768,7 @@ dri_create_context(gl_api api, switch (api) { case API_OPENGL_CORE: /* XXX fix me, fall-through for now */ - case API_OPENGL: + case API_OPENGL_COMPAT: _mesa_enable_1_3_extensions(mesaCtx); _mesa_enable_1_4_extensions(mesaCtx); _mesa_enable_1_5_extensions(mesaCtx); diff --git a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c index 5728d3aa4..50347cf77 100644 --- a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c +++ b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c @@ -426,9 +426,9 @@ static void clear(struct gl_context *ctx, GLbitfield mask) static void -wmesa_delete_renderbuffer(struct gl_renderbuffer *rb) +wmesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) { - free(rb); + _mesa_delete_renderbuffer(ctx, rb); } @@ -610,7 +610,7 @@ WMesaContext WMesaCreateContext(HDC hDC, /* initialize the Mesa context data */ ctx = &c->gl_ctx; - _mesa_initialize_context(ctx, API_OPENGL, visual, + _mesa_initialize_context(ctx, API_OPENGL_COMPAT, visual, NULL, &functions); /* visual no longer needed - it was copied by _mesa_initialize_context() */ diff --git a/mesalib/src/mesa/main/api_loopback.c b/mesalib/src/mesa/main/api_loopback.c index 6b66319a9..59d399b42 100644 --- a/mesalib/src/mesa/main/api_loopback.c +++ b/mesalib/src/mesa/main/api_loopback.c @@ -1507,7 +1507,7 @@ _mesa_loopback_init_api_table(const struct gl_context *ctx, SET_Color4ub(dest, _mesa_Color4ub); SET_Materialf(dest, _mesa_Materialf); } - if (ctx->API == API_OPENGL) { + if (ctx->API == API_OPENGL_COMPAT) { SET_Color3b(dest, _mesa_Color3b); SET_Color3d(dest, _mesa_Color3d); SET_Color3i(dest, _mesa_Color3i); @@ -1654,7 +1654,7 @@ _mesa_loopback_init_api_table(const struct gl_context *ctx, SET_FogCoorddv(dest, _mesa_FogCoorddv); } - if (ctx->API == API_OPENGL) { + if (ctx->API == API_OPENGL_COMPAT) { SET_VertexAttrib1sNV(dest, _mesa_VertexAttrib1sNV); SET_VertexAttrib1dNV(dest, _mesa_VertexAttrib1dNV); SET_VertexAttrib2sNV(dest, _mesa_VertexAttrib2sNV); diff --git a/mesalib/src/mesa/main/api_validate.c b/mesalib/src/mesa/main/api_validate.c index 6f0250800..e47db23e0 100644 --- a/mesalib/src/mesa/main/api_validate.c +++ b/mesalib/src/mesa/main/api_validate.c @@ -124,7 +124,7 @@ check_valid_to_render(struct gl_context *ctx, const char *function) return GL_FALSE; break; - case API_OPENGL: + case API_OPENGL_COMPAT: case API_OPENGL_CORE: { const struct gl_shader_program *vsProg = @@ -219,7 +219,7 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) case GL_QUADS: case GL_QUAD_STRIP: case GL_POLYGON: - valid_enum = (ctx->API == API_OPENGL); + valid_enum = (ctx->API == API_OPENGL_COMPAT); break; case GL_LINES_ADJACENCY: case GL_LINE_STRIP_ADJACENCY: diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c index acb33885a..a19d61054 100644 --- a/mesalib/src/mesa/main/attrib.c +++ b/mesalib/src/mesa/main/attrib.c @@ -1150,7 +1150,7 @@ _mesa_PopAttrib(void) _mesa_PointParameteri(GL_POINT_SPRITE_R_MODE_NV, ctx->Point.SpriteRMode); - if ((ctx->API == API_OPENGL && ctx->Version >= 20) + if ((ctx->API == API_OPENGL_COMPAT && ctx->Version >= 20) || ctx->API == API_OPENGL_CORE) _mesa_PointParameterf(GL_POINT_SPRITE_COORD_ORIGIN, (GLfloat)ctx->Point.SpriteOrigin); diff --git a/mesalib/src/mesa/main/buffers.c b/mesalib/src/mesa/main/buffers.c index fd430aad0..76f0d4671 100644 --- a/mesalib/src/mesa/main/buffers.c +++ b/mesalib/src/mesa/main/buffers.c @@ -353,7 +353,7 @@ updated_drawbuffers(struct gl_context *ctx) { FLUSH_VERTICES(ctx, _NEW_BUFFERS); - if (ctx->API == API_OPENGL && !ctx->Extensions.ARB_ES2_compatibility) { + if (ctx->API == API_OPENGL_COMPAT && !ctx->Extensions.ARB_ES2_compatibility) { struct gl_framebuffer *fb = ctx->DrawBuffer; /* Flag the FBO as requiring validation. */ diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index 0508378b7..fa552e818 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -963,7 +963,7 @@ _mesa_initialize_context(struct gl_context *ctx, sizeof(ctx->TextureFormatSupported)); switch (ctx->API) { - case API_OPENGL: + case API_OPENGL_COMPAT: ctx->Save = _mesa_create_save_table(ctx); if (!ctx->Save) { _mesa_reference_shared_state(ctx, &ctx->Shared, NULL); diff --git a/mesalib/src/mesa/main/context.h b/mesalib/src/mesa/main/context.h index a5f770a6e..063f2a381 100644 --- a/mesalib/src/mesa/main/context.h +++ b/mesalib/src/mesa/main/context.h @@ -296,7 +296,7 @@ do { \ static inline GLboolean _mesa_is_desktop_gl(const struct gl_context *ctx) { - return ctx->API == API_OPENGL || ctx->API == API_OPENGL_CORE; + return ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGL_CORE; } diff --git a/mesalib/src/mesa/main/enable.c b/mesalib/src/mesa/main/enable.c index c7114b73a..b48794f95 100644 --- a/mesalib/src/mesa/main/enable.c +++ b/mesalib/src/mesa/main/enable.c @@ -278,7 +278,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) switch (cap) { case GL_ALPHA_TEST: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; if (ctx->Color.AlphaEnabled == state) return; @@ -286,7 +286,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Color.AlphaEnabled = state; break; case GL_AUTO_NORMAL: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.AutoNormal == state) return; @@ -333,7 +333,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) } break; case GL_COLOR_MATERIAL: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; if (ctx->Light.ColorMaterialEnabled == state) return; @@ -369,7 +369,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Color.DitherFlag = state; break; case GL_FOG: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; if (ctx->Fog.Enabled == state) return; @@ -384,7 +384,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) case GL_LIGHT5: case GL_LIGHT6: case GL_LIGHT7: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) return; @@ -399,7 +399,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) } break; case GL_LIGHTING: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; if (ctx->Light.Enabled == state) return; @@ -420,7 +420,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->_TriangleCaps ^= DD_LINE_SMOOTH; break; case GL_LINE_STIPPLE: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Line.StippleFlag == state) return; @@ -429,7 +429,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->_TriangleCaps ^= DD_LINE_STIPPLE; break; case GL_INDEX_LOGIC_OP: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Color.IndexLogicOpEnabled == state) return; @@ -445,7 +445,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Color.ColorLogicOpEnabled = state; break; case GL_MAP1_COLOR_4: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map1Color4 == state) return; @@ -453,7 +453,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map1Color4 = state; break; case GL_MAP1_INDEX: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map1Index == state) return; @@ -461,7 +461,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map1Index = state; break; case GL_MAP1_NORMAL: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map1Normal == state) return; @@ -469,7 +469,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map1Normal = state; break; case GL_MAP1_TEXTURE_COORD_1: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map1TextureCoord1 == state) return; @@ -477,7 +477,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map1TextureCoord1 = state; break; case GL_MAP1_TEXTURE_COORD_2: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map1TextureCoord2 == state) return; @@ -485,7 +485,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map1TextureCoord2 = state; break; case GL_MAP1_TEXTURE_COORD_3: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map1TextureCoord3 == state) return; @@ -493,7 +493,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map1TextureCoord3 = state; break; case GL_MAP1_TEXTURE_COORD_4: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map1TextureCoord4 == state) return; @@ -501,7 +501,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map1TextureCoord4 = state; break; case GL_MAP1_VERTEX_3: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map1Vertex3 == state) return; @@ -509,7 +509,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map1Vertex3 = state; break; case GL_MAP1_VERTEX_4: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map1Vertex4 == state) return; @@ -517,7 +517,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map1Vertex4 = state; break; case GL_MAP2_COLOR_4: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map2Color4 == state) return; @@ -525,7 +525,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map2Color4 = state; break; case GL_MAP2_INDEX: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map2Index == state) return; @@ -533,7 +533,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map2Index = state; break; case GL_MAP2_NORMAL: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map2Normal == state) return; @@ -541,7 +541,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map2Normal = state; break; case GL_MAP2_TEXTURE_COORD_1: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map2TextureCoord1 == state) return; @@ -549,7 +549,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map2TextureCoord1 = state; break; case GL_MAP2_TEXTURE_COORD_2: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map2TextureCoord2 == state) return; @@ -557,7 +557,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map2TextureCoord2 = state; break; case GL_MAP2_TEXTURE_COORD_3: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map2TextureCoord3 == state) return; @@ -565,7 +565,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map2TextureCoord3 = state; break; case GL_MAP2_TEXTURE_COORD_4: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map2TextureCoord4 == state) return; @@ -573,7 +573,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map2TextureCoord4 = state; break; case GL_MAP2_VERTEX_3: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map2Vertex3 == state) return; @@ -581,7 +581,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map2Vertex3 = state; break; case GL_MAP2_VERTEX_4: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Eval.Map2Vertex4 == state) return; @@ -589,7 +589,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Eval.Map2Vertex4 = state; break; case GL_NORMALIZE: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; if (ctx->Transform.Normalize == state) return; @@ -597,7 +597,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Transform.Normalize = state; break; case GL_POINT_SMOOTH: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; if (ctx->Point.SmoothFlag == state) return; @@ -615,7 +615,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->_TriangleCaps ^= DD_TRI_SMOOTH; break; case GL_POLYGON_STIPPLE: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Polygon.StippleFlag == state) return; @@ -646,7 +646,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Polygon.OffsetFill = state; break; case GL_RESCALE_NORMAL_EXT: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; if (ctx->Transform.RescaleNormals == state) return; @@ -666,21 +666,21 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->Stencil.Enabled = state; break; case GL_TEXTURE_1D: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { return; } break; case GL_TEXTURE_2D: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { return; } break; case GL_TEXTURE_3D: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) { return; @@ -693,7 +693,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) { struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (texUnit) { @@ -745,7 +745,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) /* GL_ARB_texture_cube_map */ case GL_TEXTURE_CUBE_MAP_ARB: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; CHECK_EXTENSION(ARB_texture_cube_map, cap); if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { @@ -755,7 +755,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) /* GL_EXT_secondary_color */ case GL_COLOR_SUM_EXT: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program, cap); if (ctx->Fog.ColorSumEnabled == state) @@ -801,7 +801,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) /* GL_IBM_rasterpos_clip */ case GL_RASTER_POSITION_UNCLIPPED_IBM: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (ctx->Transform.RasterPositionUnclipped == state) return; @@ -811,7 +811,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) /* GL_NV_point_sprite */ case GL_POINT_SPRITE_NV: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap); if (ctx->Point.PointSprite == state) @@ -821,7 +821,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) break; case GL_VERTEX_PROGRAM_ARB: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(ARB_vertex_program, cap); if (ctx->VertexProgram.Enabled == state) @@ -842,7 +842,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) ctx->VertexProgram.PointSizeEnabled = state; break; case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(ARB_vertex_program, cap); if (ctx->VertexProgram.TwoSideEnabled == state) @@ -853,7 +853,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) /* GL_NV_texture_rectangle */ case GL_TEXTURE_RECTANGLE_NV: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(NV_texture_rectangle, cap); if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) { @@ -863,7 +863,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) /* GL_EXT_stencil_two_side */ case GL_STENCIL_TEST_TWO_SIDE_EXT: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(EXT_stencil_two_side, cap); if (ctx->Stencil.TestTwoSide == state) @@ -878,7 +878,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) break; case GL_FRAGMENT_PROGRAM_ARB: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(ARB_fragment_program, cap); if (ctx->FragmentProgram.Enabled == state) @@ -909,7 +909,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) break; case GL_FRAGMENT_SHADER_ATI: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(ATI_fragment_shader, cap); if (ctx->ATIFragmentShader.Enabled == state) @@ -920,7 +920,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) /* GL_MESA_texture_array */ case GL_TEXTURE_1D_ARRAY_EXT: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(MESA_texture_array, cap); if (!enable_texture(ctx, state, TEXTURE_1D_ARRAY_BIT)) { @@ -929,7 +929,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) break; case GL_TEXTURE_2D_ARRAY_EXT: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(MESA_texture_array, cap); if (!enable_texture(ctx, state, TEXTURE_2D_ARRAY_BIT)) { @@ -1154,11 +1154,11 @@ _mesa_IsEnabled( GLenum cap ) switch (cap) { case GL_ALPHA_TEST: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; return ctx->Color.AlphaEnabled; case GL_AUTO_NORMAL: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.AutoNormal; case GL_BLEND: @@ -1179,7 +1179,7 @@ _mesa_IsEnabled( GLenum cap ) return (ctx->Transform.ClipPlanesEnabled >> p) & 1; } case GL_COLOR_MATERIAL: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; return ctx->Light.ColorMaterialEnabled; case GL_CULL_FACE: @@ -1193,11 +1193,11 @@ _mesa_IsEnabled( GLenum cap ) case GL_DITHER: return ctx->Color.DitherFlag; case GL_FOG: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; return ctx->Fog.Enabled; case GL_LIGHTING: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; return ctx->Light.Enabled; case GL_LIGHT0: @@ -1208,7 +1208,7 @@ _mesa_IsEnabled( GLenum cap ) case GL_LIGHT5: case GL_LIGHT6: case GL_LIGHT7: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; return ctx->Light.Light[cap-GL_LIGHT0].Enabled; case GL_LINE_SMOOTH: @@ -1216,11 +1216,11 @@ _mesa_IsEnabled( GLenum cap ) goto invalid_enum_error; return ctx->Line.SmoothFlag; case GL_LINE_STIPPLE: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Line.StippleFlag; case GL_INDEX_LOGIC_OP: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Color.IndexLogicOpEnabled; case GL_COLOR_LOGIC_OP: @@ -1228,83 +1228,83 @@ _mesa_IsEnabled( GLenum cap ) goto invalid_enum_error; return ctx->Color.ColorLogicOpEnabled; case GL_MAP1_COLOR_4: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map1Color4; case GL_MAP1_INDEX: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map1Index; case GL_MAP1_NORMAL: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map1Normal; case GL_MAP1_TEXTURE_COORD_1: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map1TextureCoord1; case GL_MAP1_TEXTURE_COORD_2: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map1TextureCoord2; case GL_MAP1_TEXTURE_COORD_3: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map1TextureCoord3; case GL_MAP1_TEXTURE_COORD_4: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map1TextureCoord4; case GL_MAP1_VERTEX_3: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map1Vertex3; case GL_MAP1_VERTEX_4: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map1Vertex4; case GL_MAP2_COLOR_4: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map2Color4; case GL_MAP2_INDEX: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map2Index; case GL_MAP2_NORMAL: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map2Normal; case GL_MAP2_TEXTURE_COORD_1: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map2TextureCoord1; case GL_MAP2_TEXTURE_COORD_2: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map2TextureCoord2; case GL_MAP2_TEXTURE_COORD_3: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map2TextureCoord3; case GL_MAP2_TEXTURE_COORD_4: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map2TextureCoord4; case GL_MAP2_VERTEX_3: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map2Vertex3; case GL_MAP2_VERTEX_4: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Eval.Map2Vertex4; case GL_NORMALIZE: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; return ctx->Transform.Normalize; case GL_POINT_SMOOTH: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; return ctx->Point.SmoothFlag; case GL_POLYGON_SMOOTH: @@ -1312,7 +1312,7 @@ _mesa_IsEnabled( GLenum cap ) goto invalid_enum_error; return ctx->Polygon.SmoothFlag; case GL_POLYGON_STIPPLE: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Polygon.StippleFlag; case GL_POLYGON_OFFSET_POINT: @@ -1326,7 +1326,7 @@ _mesa_IsEnabled( GLenum cap ) case GL_POLYGON_OFFSET_FILL: return ctx->Polygon.OffsetFill; case GL_RESCALE_NORMAL_EXT: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; return ctx->Transform.RescaleNormals; case GL_SCISSOR_TEST: @@ -1334,15 +1334,15 @@ _mesa_IsEnabled( GLenum cap ) case GL_STENCIL_TEST: return ctx->Stencil.Enabled; case GL_TEXTURE_1D: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return is_texture_enabled(ctx, TEXTURE_1D_BIT); case GL_TEXTURE_2D: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; return is_texture_enabled(ctx, TEXTURE_2D_BIT); case GL_TEXTURE_3D: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; return is_texture_enabled(ctx, TEXTURE_3D_BIT); case GL_TEXTURE_GEN_S: @@ -1352,7 +1352,7 @@ _mesa_IsEnabled( GLenum cap ) { const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; if (texUnit) { @@ -1376,37 +1376,37 @@ _mesa_IsEnabled( GLenum cap ) /* client-side state */ case GL_VERTEX_ARRAY: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled != 0); case GL_NORMAL_ARRAY: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled != 0); case GL_COLOR_ARRAY: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled != 0); case GL_INDEX_ARRAY: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled != 0); case GL_TEXTURE_COORD_ARRAY: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)] .Enabled != 0); case GL_EDGE_FLAG_ARRAY: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled != 0); case GL_FOG_COORDINATE_ARRAY_EXT: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(EXT_fog_coord); return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled != 0); case GL_SECONDARY_COLOR_ARRAY_EXT: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(EXT_secondary_color); return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled != 0); @@ -1422,7 +1422,7 @@ _mesa_IsEnabled( GLenum cap ) /* GL_EXT_secondary_color */ case GL_COLOR_SUM_EXT: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program); return ctx->Fog.ColorSumEnabled; @@ -1447,19 +1447,19 @@ _mesa_IsEnabled( GLenum cap ) /* GL_IBM_rasterpos_clip */ case GL_RASTER_POSITION_UNCLIPPED_IBM: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->Transform.RasterPositionUnclipped; /* GL_NV_point_sprite */ case GL_POINT_SPRITE_NV: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite) return ctx->Point.PointSprite; case GL_VERTEX_PROGRAM_ARB: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(ARB_vertex_program); return ctx->VertexProgram.Enabled; @@ -1472,27 +1472,27 @@ _mesa_IsEnabled( GLenum cap ) CHECK_EXTENSION(ARB_vertex_program); return ctx->VertexProgram.PointSizeEnabled; case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(ARB_vertex_program); return ctx->VertexProgram.TwoSideEnabled; /* GL_NV_texture_rectangle */ case GL_TEXTURE_RECTANGLE_NV: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(NV_texture_rectangle); return is_texture_enabled(ctx, TEXTURE_RECT_BIT); /* GL_EXT_stencil_two_side */ case GL_STENCIL_TEST_TWO_SIDE_EXT: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(EXT_stencil_two_side); return ctx->Stencil.TestTwoSide; case GL_FRAGMENT_PROGRAM_ARB: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; return ctx->FragmentProgram.Enabled; @@ -1511,7 +1511,7 @@ _mesa_IsEnabled( GLenum cap ) return ctx->Transform.DepthClamp; case GL_FRAGMENT_SHADER_ATI: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; CHECK_EXTENSION(ATI_fragment_shader); return ctx->ATIFragmentShader.Enabled; @@ -1530,7 +1530,7 @@ _mesa_IsEnabled( GLenum cap ) /* GL_NV_primitive_restart */ case GL_PRIMITIVE_RESTART_NV: - if (ctx->API != API_OPENGL || !ctx->Extensions.NV_primitive_restart) { + if (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.NV_primitive_restart) { goto invalid_enum_error; } return ctx->Array.PrimitiveRestart; diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c index d5a7886c9..9e23a66d7 100644 --- a/mesalib/src/mesa/main/extensions.c +++ b/mesalib/src/mesa/main/extensions.c @@ -41,9 +41,9 @@ enum { DISABLE = 0, - GLL = 1 << API_OPENGL, /* GL Legacy / Compatibility */ + GLL = 1 << API_OPENGL_COMPAT, /* GL Legacy / Compatibility */ GLC = 1 << API_OPENGL_CORE, /* GL Core */ - GL = (1 << API_OPENGL) | (1 << API_OPENGL_CORE), + GL = (1 << API_OPENGL_COMPAT) | (1 << API_OPENGL_CORE), ES1 = 1 << API_OPENGLES, ES2 = 1 << API_OPENGLES2, }; diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c index 891ec5dce..9eec61de6 100644 --- a/mesalib/src/mesa/main/fbobject.c +++ b/mesalib/src/mesa/main/fbobject.c @@ -78,7 +78,7 @@ static struct gl_framebuffer IncompleteFramebuffer; static void -delete_dummy_renderbuffer(struct gl_renderbuffer *rb) +delete_dummy_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) { /* no op */ } @@ -1072,14 +1072,14 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) case GL_ALPHA8: case GL_ALPHA12: case GL_ALPHA16: - return ctx->API == API_OPENGL && ctx->Extensions.ARB_framebuffer_object + 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 && ctx->Extensions.ARB_framebuffer_object + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; case GL_LUMINANCE_ALPHA: case GL_LUMINANCE4_ALPHA4: @@ -1088,14 +1088,14 @@ _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 && ctx->Extensions.ARB_framebuffer_object + 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 && ctx->Extensions.ARB_framebuffer_object + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; case GL_RGB8: return GL_RGB; @@ -1146,11 +1146,11 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) ? GL_DEPTH_STENCIL_EXT : 0; case GL_DEPTH_COMPONENT32F: return ctx->Version >= 30 - || (ctx->API == API_OPENGL && 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 && 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: @@ -1169,7 +1169,7 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) /* signed normalized texture formats */ case GL_R8_SNORM: return ctx->Version >= 30 - || (ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm) + || (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_texture_snorm) ? GL_RED : 0; case GL_RED_SNORM: case GL_R16_SNORM: @@ -1177,7 +1177,7 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) ? GL_RED : 0; case GL_RG8_SNORM: return ctx->Version >= 30 - || (ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm) + || (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_texture_snorm) ? GL_RG : 0; case GL_RG_SNORM: case GL_RG16_SNORM: @@ -1185,7 +1185,7 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) ? GL_RG : 0; case GL_RGB8_SNORM: return ctx->Version >= 30 - || (ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm) + || (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_texture_snorm) ? GL_RGB : 0; case GL_RGB_SNORM: case GL_RGB16_SNORM: @@ -1193,7 +1193,7 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) ? GL_RGB : 0; case GL_RGBA8_SNORM: return ctx->Version >= 30 - || (ctx->API == API_OPENGL && ctx->Extensions.EXT_texture_snorm) + || (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_texture_snorm) ? GL_RGBA : 0; case GL_RGBA_SNORM: case GL_RGBA16_SNORM: @@ -1202,37 +1202,37 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) case GL_ALPHA_SNORM: case GL_ALPHA8_SNORM: case GL_ALPHA16_SNORM: - return ctx->API == API_OPENGL && + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_texture_snorm && ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; case GL_LUMINANCE_SNORM: case GL_LUMINANCE8_SNORM: case GL_LUMINANCE16_SNORM: - return ctx->API == API_OPENGL && + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_texture_snorm && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; case GL_LUMINANCE_ALPHA_SNORM: case GL_LUMINANCE8_ALPHA8_SNORM: case GL_LUMINANCE16_ALPHA16_SNORM: - return ctx->API == API_OPENGL && + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_texture_snorm && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; case GL_INTENSITY_SNORM: case GL_INTENSITY8_SNORM: case GL_INTENSITY16_SNORM: - return ctx->API == API_OPENGL && + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_texture_snorm && ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; case GL_R16F: case GL_R32F: return ctx->Version >= 30 - || (ctx->API == API_OPENGL && + || (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_texture_rg && ctx->Extensions.ARB_texture_float) ? GL_RED : 0; case GL_RG16F: case GL_RG32F: return ctx->Version >= 30 - || (ctx->API == API_OPENGL && + || (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_texture_rg && ctx->Extensions.ARB_texture_float) ? GL_RG : 0; case GL_RGB16F: @@ -1247,22 +1247,22 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) ? GL_RGBA : 0; case GL_ALPHA16F_ARB: case GL_ALPHA32F_ARB: - return ctx->API == API_OPENGL && + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_texture_float && ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; case GL_LUMINANCE16F_ARB: case GL_LUMINANCE32F_ARB: - return ctx->API == API_OPENGL && + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_texture_float && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; case GL_LUMINANCE_ALPHA16F_ARB: case GL_LUMINANCE_ALPHA32F_ARB: - return ctx->API == API_OPENGL && + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_texture_float && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; case GL_INTENSITY16F_ARB: case GL_INTENSITY32F_ARB: - return ctx->API == API_OPENGL && + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_texture_float && ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; case GL_RGB9_E5: @@ -1321,7 +1321,7 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) case GL_INTENSITY16UI_EXT: case GL_INTENSITY32I_EXT: case GL_INTENSITY32UI_EXT: - return ctx->API == API_OPENGL && + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_texture_integer && ctx->Extensions.ARB_framebuffer_object ? GL_INTENSITY : 0; @@ -1331,7 +1331,7 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) case GL_LUMINANCE16UI_EXT: case GL_LUMINANCE32I_EXT: case GL_LUMINANCE32UI_EXT: - return ctx->API == API_OPENGL && + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_texture_integer && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE : 0; @@ -1341,7 +1341,7 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) case GL_LUMINANCE_ALPHA16UI_EXT: case GL_LUMINANCE_ALPHA32I_EXT: case GL_LUMINANCE_ALPHA32UI_EXT: - return ctx->API == API_OPENGL && + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_texture_integer && ctx->Extensions.ARB_framebuffer_object ? GL_LUMINANCE_ALPHA : 0; @@ -1351,7 +1351,7 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat) case GL_ALPHA16UI_EXT: case GL_ALPHA32I_EXT: case GL_ALPHA32UI_EXT: - return ctx->API == API_OPENGL && + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_texture_integer && ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0; @@ -2498,7 +2498,7 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, } return; case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: - if ((ctx->API != API_OPENGL || !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; @@ -2716,127 +2716,16 @@ compatible_color_datatypes(gl_format srcFormat, gl_format dstFormat) } -/** - * Return the equivalent non-generic internal format. - * This is useful for comparing whether two internal formats are semantically - * equivalent. - */ -static GLenum -get_nongeneric_internalformat(GLenum format) -{ - switch (format) { - /* GL 1.1 formats. */ - case 4: - case GL_RGBA: - return GL_RGBA8; - - case 3: - case GL_RGB: - return GL_RGB8; - - case 2: - case GL_LUMINANCE_ALPHA: - return GL_LUMINANCE8_ALPHA8; - - case 1: - case GL_LUMINANCE: - return GL_LUMINANCE8; - - case GL_ALPHA: - return GL_ALPHA8; - - case GL_INTENSITY: - return GL_INTENSITY8; - - /* GL_ARB_texture_rg */ - case GL_RED: - return GL_R8; - - case GL_RG: - return GL_RG8; - - /* GL_EXT_texture_sRGB */ - case GL_SRGB: - return GL_SRGB8; - - case GL_SRGB_ALPHA: - return GL_SRGB8_ALPHA8; - - case GL_SLUMINANCE: - return GL_SLUMINANCE8; - - case GL_SLUMINANCE_ALPHA: - return GL_SLUMINANCE8_ALPHA8; - - /* GL_EXT_texture_snorm */ - case GL_RGBA_SNORM: - return GL_RGBA8_SNORM; - - case GL_RGB_SNORM: - return GL_RGB8_SNORM; - - case GL_RG_SNORM: - return GL_RG8_SNORM; - - case GL_RED_SNORM: - return GL_R8_SNORM; - - case GL_LUMINANCE_ALPHA_SNORM: - return GL_LUMINANCE8_ALPHA8_SNORM; - - case GL_LUMINANCE_SNORM: - return GL_LUMINANCE8_SNORM; - - case GL_ALPHA_SNORM: - return GL_ALPHA8_SNORM; - - case GL_INTENSITY_SNORM: - return GL_INTENSITY8_SNORM; - - default: - return format; - } -} - - -static GLenum -get_linear_internalformat(GLenum format) -{ - switch (format) { - case GL_SRGB: - return GL_RGB; - - case GL_SRGB_ALPHA: - return GL_RGBA; - - case GL_SRGB8: - return GL_RGB8; - - case GL_SRGB8_ALPHA8: - return GL_RGBA8; - - case GL_SLUMINANCE: - return GL_LUMINANCE8; - - case GL_SLUMINANCE_ALPHA: - return GL_LUMINANCE8_ALPHA8; - - default: - return format; - } -} - - static GLboolean -compatible_resolve_formats(const struct gl_renderbuffer *colorReadRb, - const struct gl_renderbuffer *colorDrawRb) +compatible_resolve_formats(const struct gl_renderbuffer *readRb, + const struct gl_renderbuffer *drawRb) { GLenum readFormat, drawFormat; /* The simple case where we know the backing Mesa formats are the same. */ - if (_mesa_get_srgb_format_linear(colorReadRb->Format) == - _mesa_get_srgb_format_linear(colorDrawRb->Format)) { + if (_mesa_get_srgb_format_linear(readRb->Format) == + _mesa_get_srgb_format_linear(drawRb->Format)) { return GL_TRUE; } @@ -2850,10 +2739,10 @@ compatible_resolve_formats(const struct gl_renderbuffer *colorReadRb, * * Blits between linear and sRGB formats are also allowed. */ - readFormat = get_nongeneric_internalformat(colorReadRb->InternalFormat); - drawFormat = get_nongeneric_internalformat(colorDrawRb->InternalFormat); - readFormat = get_linear_internalformat(readFormat); - drawFormat = get_linear_internalformat(drawFormat); + readFormat = _mesa_get_nongeneric_internalformat(readRb->InternalFormat); + drawFormat = _mesa_get_nongeneric_internalformat(drawRb->InternalFormat); + readFormat = _mesa_get_linear_internalformat(readFormat); + drawFormat = _mesa_get_linear_internalformat(drawFormat); if (readFormat == drawFormat) { return GL_TRUE; @@ -3153,7 +3042,7 @@ invalidate_framebuffer_storage(GLenum target, GLsizei numAttachments, /* Accumulation buffers and auxilary buffers were removed in * OpenGL 3.1, and they never existed in OpenGL ES. */ - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum; break; case GL_COLOR: diff --git a/mesalib/src/mesa/main/fog.c b/mesalib/src/mesa/main/fog.c index 07405fb4b..b37e95f08 100644 --- a/mesalib/src/mesa/main/fog.c +++ b/mesalib/src/mesa/main/fog.c @@ -141,7 +141,7 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params ) update_fog_scale(ctx); break; case GL_FOG_INDEX: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; if (ctx->Fog.Index == *params) return; @@ -163,7 +163,7 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params ) break; case GL_FOG_COORDINATE_SOURCE_EXT: { GLenum p = (GLenum) (GLint) *params; - if (ctx->API != API_OPENGL || !ctx->Extensions.EXT_fog_coord || + if (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.EXT_fog_coord || (p != GL_FOG_COORDINATE_EXT && p != GL_FRAGMENT_DEPTH_EXT)) { _mesa_error(ctx, GL_INVALID_ENUM, "glFog"); return; @@ -176,7 +176,7 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params ) } case GL_FOG_DISTANCE_MODE_NV: { GLenum p = (GLenum) (GLint) *params; - if (ctx->API != API_OPENGL || !ctx->Extensions.NV_fog_distance || + if (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.NV_fog_distance || (p != GL_EYE_RADIAL_NV && p != GL_EYE_PLANE && p != GL_EYE_PLANE_ABSOLUTE_NV)) { _mesa_error(ctx, GL_INVALID_ENUM, "glFog"); return; diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c index e1ebd1856..97dccd0ed 100644 --- a/mesalib/src/mesa/main/get.c +++ b/mesalib/src/mesa/main/get.c @@ -395,7 +395,7 @@ print_table_stats(int api) int i, j, collisions[11], count, hash, mask; const struct value_desc *d; const char *api_names[] = { - [API_OPENGL] = "GL", + [API_OPENGL_COMPAT] = "GL", [API_OPENGL_CORE] = "GL_CORE", [API_OPENGLES] = "GLES", [API_OPENGLES2] = "GLES2", diff --git a/mesalib/src/mesa/main/getstring.c b/mesalib/src/mesa/main/getstring.c index a04db0dc7..20e7a014d 100644 --- a/mesalib/src/mesa/main/getstring.c +++ b/mesalib/src/mesa/main/getstring.c @@ -40,7 +40,7 @@ static const GLubyte * shading_language_version(struct gl_context *ctx) { switch (ctx->API) { - case API_OPENGL: + case API_OPENGL_COMPAT: case API_OPENGL_CORE: if (!ctx->Extensions.ARB_shader_objects) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetString"); @@ -136,7 +136,7 @@ _mesa_GetString( GLenum name ) break; return shading_language_version(ctx); case GL_PROGRAM_ERROR_STRING_NV: - if (ctx->API == API_OPENGL && + if (ctx->API == API_OPENGL_COMPAT && (ctx->Extensions.ARB_fragment_program || ctx->Extensions.ARB_vertex_program)) { return (const GLubyte *) ctx->Program.ErrorString; @@ -205,52 +205,52 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params ) switch (pname) { case GL_VERTEX_ARRAY_POINTER: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_pname; *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Ptr; break; case GL_NORMAL_ARRAY_POINTER: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_pname; *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Ptr; break; case GL_COLOR_ARRAY_POINTER: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_pname; *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Ptr; break; case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Ptr; break; case GL_FOG_COORDINATE_ARRAY_POINTER_EXT: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_FOG].Ptr; break; case GL_INDEX_ARRAY_POINTER: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Ptr; break; case GL_TEXTURE_COORD_ARRAY_POINTER: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_pname; *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(clientUnit)].Ptr; break; case GL_EDGE_FLAG_ARRAY_POINTER: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; *params = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Ptr; break; case GL_FEEDBACK_BUFFER_POINTER: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; *params = ctx->Feedback.Buffer; break; case GL_SELECTION_BUFFER_POINTER: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; *params = ctx->Select.Buffer; break; diff --git a/mesalib/src/mesa/main/glformats.c b/mesalib/src/mesa/main/glformats.c index ba79f193b..69caef70b 100644 --- a/mesalib/src/mesa/main/glformats.c +++ b/mesalib/src/mesa/main/glformats.c @@ -821,10 +821,10 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: - return ctx->API == API_OPENGL + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_texture_compression_latc; case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI: - return ctx->API == API_OPENGL + return ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ATI_texture_compression_3dc; case GL_ETC1_RGB8_OES: return _mesa_is_gles(ctx) @@ -1008,6 +1008,119 @@ _mesa_generic_compressed_format_to_uncompressed_format(GLenum format) /** + * Return the equivalent non-generic internal format. + * This is useful for comparing whether two internal formats are equivalent. + */ +GLenum +_mesa_get_nongeneric_internalformat(GLenum format) +{ + switch (format) { + /* GL 1.1 formats. */ + case 4: + case GL_RGBA: + return GL_RGBA8; + + case 3: + case GL_RGB: + return GL_RGB8; + + case 2: + case GL_LUMINANCE_ALPHA: + return GL_LUMINANCE8_ALPHA8; + + case 1: + case GL_LUMINANCE: + return GL_LUMINANCE8; + + case GL_ALPHA: + return GL_ALPHA8; + + case GL_INTENSITY: + return GL_INTENSITY8; + + /* GL_ARB_texture_rg */ + case GL_RED: + return GL_R8; + + case GL_RG: + return GL_RG8; + + /* GL_EXT_texture_sRGB */ + case GL_SRGB: + return GL_SRGB8; + + case GL_SRGB_ALPHA: + return GL_SRGB8_ALPHA8; + + case GL_SLUMINANCE: + return GL_SLUMINANCE8; + + case GL_SLUMINANCE_ALPHA: + return GL_SLUMINANCE8_ALPHA8; + + /* GL_EXT_texture_snorm */ + case GL_RGBA_SNORM: + return GL_RGBA8_SNORM; + + case GL_RGB_SNORM: + return GL_RGB8_SNORM; + + case GL_RG_SNORM: + return GL_RG8_SNORM; + + case GL_RED_SNORM: + return GL_R8_SNORM; + + case GL_LUMINANCE_ALPHA_SNORM: + return GL_LUMINANCE8_ALPHA8_SNORM; + + case GL_LUMINANCE_SNORM: + return GL_LUMINANCE8_SNORM; + + case GL_ALPHA_SNORM: + return GL_ALPHA8_SNORM; + + case GL_INTENSITY_SNORM: + return GL_INTENSITY8_SNORM; + + default: + return format; + } +} + + +/** + * Convert an sRGB internal format to linear. + */ +GLenum +_mesa_get_linear_internalformat(GLenum format) +{ + switch (format) { + case GL_SRGB: + return GL_RGB; + + case GL_SRGB_ALPHA: + return GL_RGBA; + + case GL_SRGB8: + return GL_RGB8; + + case GL_SRGB8_ALPHA8: + return GL_RGBA8; + + case GL_SLUMINANCE: + return GL_LUMINANCE8; + + case GL_SLUMINANCE_ALPHA: + return GL_LUMINANCE8_ALPHA8; + + default: + return format; + } +} + + +/** * Do error checking of format/type combinations for glReadPixels, * glDrawPixels and glTex[Sub]Image. Note that depending on the format * and type values, we may either generate GL_INVALID_OPERATION or diff --git a/mesalib/src/mesa/main/glformats.h b/mesalib/src/mesa/main/glformats.h index e5b63a963..5d0995140 100644 --- a/mesalib/src/mesa/main/glformats.h +++ b/mesalib/src/mesa/main/glformats.h @@ -95,6 +95,12 @@ extern GLenum _mesa_generic_compressed_format_to_uncompressed_format(GLenum format); extern GLenum +_mesa_get_nongeneric_internalformat(GLenum format); + +extern GLenum +_mesa_get_linear_internalformat(GLenum format); + +extern GLenum _mesa_error_check_format_and_type(const struct gl_context *ctx, GLenum format, GLenum type); diff --git a/mesalib/src/mesa/main/hint.c b/mesalib/src/mesa/main/hint.c index 90130e3db..83d7966cd 100644 --- a/mesalib/src/mesa/main/hint.c +++ b/mesalib/src/mesa/main/hint.c @@ -51,7 +51,7 @@ _mesa_Hint( GLenum target, GLenum mode ) switch (target) { case GL_FOG_HINT: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_target; if (ctx->Hint.Fog == mode) return; @@ -67,7 +67,7 @@ _mesa_Hint( GLenum target, GLenum mode ) ctx->Hint.LineSmooth = mode; break; case GL_PERSPECTIVE_CORRECTION_HINT: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_target; if (ctx->Hint.PerspectiveCorrection == mode) return; @@ -75,7 +75,7 @@ _mesa_Hint( GLenum target, GLenum mode ) ctx->Hint.PerspectiveCorrection = mode; break; case GL_POINT_SMOOTH_HINT: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_target; if (ctx->Hint.PointSmooth == mode) return; @@ -93,7 +93,7 @@ _mesa_Hint( GLenum target, GLenum mode ) /* GL_EXT_clip_volume_hint */ case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_target; if (ctx->Hint.ClipVolumeClipping == mode) return; diff --git a/mesalib/src/mesa/main/light.c b/mesalib/src/mesa/main/light.c index b0a10e9ed..aae5d0ae9 100644 --- a/mesalib/src/mesa/main/light.c +++ b/mesalib/src/mesa/main/light.c @@ -466,7 +466,7 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params ) COPY_4V( ctx->Light.Model.Ambient, params ); break; case GL_LIGHT_MODEL_LOCAL_VIEWER: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; newbool = (params[0]!=0.0); if (ctx->Light.Model.LocalViewer == newbool) @@ -486,7 +486,7 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params ) ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; break; case GL_LIGHT_MODEL_COLOR_CONTROL: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; if (params[0] == (GLfloat) GL_SINGLE_COLOR) newenum = GL_SINGLE_COLOR; @@ -798,7 +798,7 @@ _mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params ) *params = mat[MAT_ATTRIB_SHININESS(f)][0]; break; case GL_COLOR_INDEXES: - if (ctx->API != API_OPENGL) { + if (ctx->API != API_OPENGL_COMPAT) { _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" ); return; } @@ -820,7 +820,7 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ) GLfloat (*mat)[4] = ctx->Light.Material.Attrib; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */ - ASSERT(ctx->API == API_OPENGL); + ASSERT(ctx->API == API_OPENGL_COMPAT); FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */ diff --git a/mesalib/src/mesa/main/matrix.c b/mesalib/src/mesa/main/matrix.c index 00b8e00b7..a4e576237 100644 --- a/mesalib/src/mesa/main/matrix.c +++ b/mesalib/src/mesa/main/matrix.c @@ -187,7 +187,7 @@ _mesa_MatrixMode( GLenum mode ) case GL_MATRIX5_ARB: case GL_MATRIX6_ARB: case GL_MATRIX7_ARB: - if (ctx->API == API_OPENGL + if (ctx->API == API_OPENGL_COMPAT && (ctx->Extensions.ARB_vertex_program || ctx->Extensions.ARB_fragment_program)) { const GLuint m = mode - GL_MATRIX0_ARB; diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index da72da9d1..5bfae69c8 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -2605,7 +2605,7 @@ struct gl_renderbuffer gl_format Format; /**< The actual renderbuffer memory format */ /** Delete this renderbuffer */ - void (*Delete)(struct gl_renderbuffer *rb); + void (*Delete)(struct gl_context *ctx, struct gl_renderbuffer *rb); /** Allocate new storage for this renderbuffer */ GLboolean (*AllocStorage)(struct gl_context *ctx, @@ -3315,7 +3315,7 @@ struct gl_debug_state */ typedef enum { - API_OPENGL, /* legacy / compatibility contexts */ + API_OPENGL_COMPAT, /* legacy / compatibility contexts */ API_OPENGLES, API_OPENGLES2, API_OPENGL_CORE, diff --git a/mesalib/src/mesa/main/points.c b/mesalib/src/mesa/main/points.c index 7d6e5a5e1..b5fc5d5bb 100644 --- a/mesalib/src/mesa/main/points.c +++ b/mesalib/src/mesa/main/points.c @@ -190,7 +190,7 @@ _mesa_PointParameterfv( GLenum pname, const GLfloat *params) /* GL_POINT_SPRITE_COORD_ORIGIN was added to point sprites when the * extension was merged into OpenGL 2.0. */ - if ((ctx->API == API_OPENGL && ctx->Version >= 20) + if ((ctx->API == API_OPENGL_COMPAT && ctx->Version >= 20) || ctx->API == API_OPENGL_CORE) { GLenum value = (GLenum) params[0]; if (value != GL_LOWER_LEFT && value != GL_UPPER_LEFT) { diff --git a/mesalib/src/mesa/main/queryobj.c b/mesalib/src/mesa/main/queryobj.c index fecbd3f12..b5023e260 100644 --- a/mesalib/src/mesa/main/queryobj.c +++ b/mesalib/src/mesa/main/queryobj.c @@ -321,7 +321,7 @@ _mesa_BeginQueryIndexed(GLenum target, GLuint index, GLuint id) q = _mesa_lookup_query_object(ctx, id); if (!q) { - if (ctx->API != API_OPENGL) { + if (ctx->API != API_OPENGL_COMPAT) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQuery{Indexed}(non-gen name)"); return; diff --git a/mesalib/src/mesa/main/renderbuffer.c b/mesalib/src/mesa/main/renderbuffer.c index 26f53d100..2f2844329 100644 --- a/mesalib/src/mesa/main/renderbuffer.c +++ b/mesalib/src/mesa/main/renderbuffer.c @@ -80,7 +80,7 @@ _mesa_new_renderbuffer(struct gl_context *ctx, GLuint name) * free the object in the end. */ void -_mesa_delete_renderbuffer(struct gl_renderbuffer *rb) +_mesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) { _glthread_DESTROY_MUTEX(rb->Mutex); free(rb); @@ -159,7 +159,11 @@ _mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr, _glthread_UNLOCK_MUTEX(oldRb->Mutex); if (deleteFlag) { - oldRb->Delete(oldRb); + GET_CURRENT_CONTEXT(ctx); + if (ctx) + oldRb->Delete(ctx, oldRb); + else + _mesa_problem(NULL, "Unable to delete renderbuffer, no context"); } *ptr = NULL; diff --git a/mesalib/src/mesa/main/renderbuffer.h b/mesalib/src/mesa/main/renderbuffer.h index 0934d85df..5495ae150 100644 --- a/mesalib/src/mesa/main/renderbuffer.h +++ b/mesalib/src/mesa/main/renderbuffer.h @@ -40,7 +40,7 @@ extern struct gl_renderbuffer * _mesa_new_renderbuffer(struct gl_context *ctx, GLuint name); extern void -_mesa_delete_renderbuffer(struct gl_renderbuffer *rb); +_mesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb); extern void _mesa_add_renderbuffer(struct gl_framebuffer *fb, diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c index 5c0a923e4..53e9d0486 100644 --- a/mesalib/src/mesa/main/shaderapi.c +++ b/mesalib/src/mesa/main/shaderapi.c @@ -452,7 +452,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param /* Is transform feedback available in this context? */ const bool has_xfb = - (ctx->API == API_OPENGL && ctx->Extensions.EXT_transform_feedback) + (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_transform_feedback) || ctx->API == API_OPENGL_CORE || _mesa_is_gles3(ctx); @@ -464,7 +464,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param /* Are uniform buffer objects available in this context? */ const bool has_ubo = - (ctx->API == API_OPENGL && ctx->Extensions.ARB_uniform_buffer_object) + (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_uniform_buffer_object) || ctx->API == API_OPENGL_CORE || _mesa_is_gles3(ctx); @@ -1728,7 +1728,7 @@ _mesa_init_shader_dispatch(const struct gl_context *ctx, SET_GetAttribLocation(exec, _mesa_GetAttribLocation); } - if (ctx->API == API_OPENGL) { + if (ctx->API == API_OPENGL_COMPAT) { SET_UseShaderProgramEXT(exec, _mesa_UseShaderProgramEXT); SET_ActiveProgramEXT(exec, _mesa_ActiveProgramEXT); SET_CreateShaderProgramEXT(exec, _mesa_CreateShaderProgramEXT); diff --git a/mesalib/src/mesa/main/shared.c b/mesalib/src/mesa/main/shared.c index ba82628f3..eaf9f8de1 100644 --- a/mesalib/src/mesa/main/shared.c +++ b/mesalib/src/mesa/main/shared.c @@ -253,10 +253,11 @@ delete_framebuffer_cb(GLuint id, void *data, void *userData) static void delete_renderbuffer_cb(GLuint id, void *data, void *userData) { + struct gl_context *ctx = (struct gl_context *) userData; struct gl_renderbuffer *rb = (struct gl_renderbuffer *) data; rb->RefCount = 0; /* see comment for FBOs above */ if (rb->Delete) - rb->Delete(rb); + rb->Delete(ctx, rb); } diff --git a/mesalib/src/mesa/main/texenv.c b/mesalib/src/mesa/main/texenv.c index f1064c5e3..e8f3af082 100644 --- a/mesalib/src/mesa/main/texenv.c +++ b/mesalib/src/mesa/main/texenv.c @@ -122,7 +122,7 @@ set_combiner_mode(struct gl_context *ctx, break; case GL_DOT3_RGB_EXT: case GL_DOT3_RGBA_EXT: - legal = (ctx->API == API_OPENGL && + legal = (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.EXT_texture_env_dot3 && pname == GL_COMBINE_RGB); break; @@ -134,11 +134,11 @@ set_combiner_mode(struct gl_context *ctx, case GL_MODULATE_ADD_ATI: case GL_MODULATE_SIGNED_ADD_ATI: case GL_MODULATE_SUBTRACT_ATI: - legal = (ctx->API == API_OPENGL && + legal = (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ATI_texture_env_combine3); break; case GL_BUMP_ENVMAP_ATI: - legal = (ctx->API == API_OPENGL && + legal = (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ATI_envmap_bumpmap && pname == GL_COMBINE_RGB); break; @@ -206,7 +206,7 @@ set_combiner_source(struct gl_context *ctx, return; } - if ((term == 3) && (ctx->API != API_OPENGL + if ((term == 3) && (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.NV_texture_env_combine4)) { TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); return; @@ -236,12 +236,12 @@ set_combiner_source(struct gl_context *ctx, param - GL_TEXTURE0 < ctx->Const.MaxTextureUnits); break; case GL_ZERO: - legal = (ctx->API == API_OPENGL && + legal = (ctx->API == API_OPENGL_COMPAT && (ctx->Extensions.ATI_texture_env_combine3 || ctx->Extensions.NV_texture_env_combine4)); break; case GL_ONE: - legal = (ctx->API == API_OPENGL && + legal = (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ATI_texture_env_combine3); break; default: @@ -293,7 +293,7 @@ set_combiner_operand(struct gl_context *ctx, return; } - if ((term == 3) && (ctx->API != API_OPENGL + if ((term == 3) && (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.NV_texture_env_combine4)) { TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); return; @@ -442,7 +442,7 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) set_combiner_scale(ctx, texUnit, pname, param[0]); break; case GL_BUMP_TARGET_ATI: - if (ctx->API != API_OPENGL || !ctx->Extensions.ATI_envmap_bumpmap) { + if (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.ATI_envmap_bumpmap) { _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname ); return; } @@ -588,7 +588,7 @@ get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit, return texUnit->Combine.SourceRGB[rgb_idx]; } case GL_SOURCE3_RGB_NV: - if (ctx->API == API_OPENGL && ctx->Extensions.NV_texture_env_combine4) { + if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.NV_texture_env_combine4) { return texUnit->Combine.SourceRGB[3]; } else { @@ -602,7 +602,7 @@ get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit, return texUnit->Combine.SourceA[alpha_idx]; } case GL_SOURCE3_ALPHA_NV: - if (ctx->API == API_OPENGL && ctx->Extensions.NV_texture_env_combine4) { + if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.NV_texture_env_combine4) { return texUnit->Combine.SourceA[3]; } else { @@ -616,7 +616,7 @@ get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit, return texUnit->Combine.OperandRGB[op_rgb]; } case GL_OPERAND3_RGB_NV: - if (ctx->API == API_OPENGL && ctx->Extensions.NV_texture_env_combine4) { + if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.NV_texture_env_combine4) { return texUnit->Combine.OperandRGB[3]; } else { @@ -630,7 +630,7 @@ get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit, return texUnit->Combine.OperandA[op_alpha]; } case GL_OPERAND3_ALPHA_NV: - if (ctx->API == API_OPENGL && ctx->Extensions.NV_texture_env_combine4) { + if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.NV_texture_env_combine4) { return texUnit->Combine.OperandA[3]; } else { @@ -643,7 +643,7 @@ get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit, return 1 << texUnit->Combine.ScaleShiftA; case GL_BUMP_TARGET_ATI: /* spec doesn't say so, but I think this should be queryable */ - if (ctx->API == API_OPENGL && ctx->Extensions.ATI_envmap_bumpmap) { + if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ATI_envmap_bumpmap) { return texUnit->BumpTarget; } else { diff --git a/mesalib/src/mesa/main/texgen.c b/mesalib/src/mesa/main/texgen.c index 7c9c2a760..fe5fc852d 100644 --- a/mesalib/src/mesa/main/texgen.c +++ b/mesalib/src/mesa/main/texgen.c @@ -129,7 +129,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); return; } - if (ctx->API != API_OPENGL + if (ctx->API != API_OPENGL_COMPAT && (bit & (TEXGEN_REFLECTION_MAP_NV | TEXGEN_NORMAL_MAP_NV)) == 0) { _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); return; @@ -143,7 +143,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) case GL_OBJECT_PLANE: { - if (ctx->API != API_OPENGL) { + if (ctx->API != API_OPENGL_COMPAT) { _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); return; } @@ -158,7 +158,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) { GLfloat tmp[4]; - if (ctx->API != API_OPENGL) { + if (ctx->API != API_OPENGL_COMPAT) { _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); return; } @@ -352,14 +352,14 @@ _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) params[0] = ENUM_TO_FLOAT(texgen->Mode); break; case GL_OBJECT_PLANE: - if (ctx->API != API_OPENGL) { + if (ctx->API != API_OPENGL_COMPAT) { _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(param)" ); return; } COPY_4V(params, texgen->ObjectPlane); break; case GL_EYE_PLANE: - if (ctx->API != API_OPENGL) { + if (ctx->API != API_OPENGL_COMPAT) { _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(param)" ); return; } @@ -398,7 +398,7 @@ _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) params[0] = texgen->Mode; break; case GL_OBJECT_PLANE: - if (ctx->API != API_OPENGL) { + if (ctx->API != API_OPENGL_COMPAT) { _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(param)" ); return; } @@ -408,7 +408,7 @@ _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) params[3] = (GLint) texgen->ObjectPlane[3]; break; case GL_EYE_PLANE: - if (ctx->API != API_OPENGL) { + if (ctx->API != API_OPENGL_COMPAT) { _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(param)" ); return; } diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c index 2ccdcebd9..69067df9f 100644 --- a/mesalib/src/mesa/main/texgetimage.c +++ b/mesalib/src/mesa/main/texgetimage.c @@ -229,6 +229,8 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint dimensions, const gl_format texFormat = _mesa_get_srgb_format_linear(texImage->TexFormat); const GLenum baseFormat = _mesa_get_format_base_format(texFormat); + const GLenum destBaseFormat = _mesa_base_tex_format(ctx, format); + GLenum rebaseFormat = GL_NONE; const GLuint width = texImage->Width; const GLuint height = texImage->Height; const GLuint depth = texImage->Depth; @@ -266,9 +268,31 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint dimensions, } if (baseFormat == GL_LUMINANCE || + baseFormat == GL_INTENSITY || baseFormat == GL_LUMINANCE_ALPHA) { + /* If a luminance (or intensity) texture is read back as RGB(A), the + * returned value should be (L,0,0,1), not (L,L,L,1). Set rebaseFormat + * here to get G=B=0. + */ + rebaseFormat = texImage->_BaseFormat; + } + else if ((baseFormat == GL_RGBA || + baseFormat == GL_RGB || + baseFormat == GL_RG) && + (destBaseFormat == GL_LUMINANCE || + destBaseFormat == GL_LUMINANCE_ALPHA || + destBaseFormat == GL_LUMINANCE_INTEGER_EXT || + destBaseFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT)) { + /* If we're reading back an RGB(A) texture as luminance then we need + * to return L=tex(R). Note, that's different from glReadPixels which + * returns L=R+G+B. + */ + rebaseFormat = GL_LUMINANCE_ALPHA; /* this covers GL_LUMINANCE too */ + } + + if (rebaseFormat) { _mesa_rebase_rgba_float(width * height, (GLfloat (*)[4]) tempImage, - baseFormat); + rebaseFormat); } srcRow = tempImage; @@ -332,7 +356,8 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, rebaseFormat = texImage->_BaseFormat; } else if ((texImage->_BaseFormat == GL_RGBA || - texImage->_BaseFormat == GL_RGB) && + texImage->_BaseFormat == GL_RGB || + texImage->_BaseFormat == GL_RG) && (destBaseFormat == GL_LUMINANCE || destBaseFormat == GL_LUMINANCE_ALPHA || destBaseFormat == GL_LUMINANCE_INTEGER_EXT || @@ -419,15 +444,6 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions, transferOps |= IMAGE_CLAMP_BIT; } } - /* This applies to RGB, RGBA textures. if the format is either LUMINANCE - * or LUMINANCE ALPHA, luminance (L) is computed as L=R+G+B .we need to - * clamp the sum to [0,1]. - */ - else if ((format == GL_LUMINANCE || - format == GL_LUMINANCE_ALPHA) && - dataType == GL_UNSIGNED_NORMALIZED) { - transferOps |= IMAGE_CLAMP_BIT; - } if (_mesa_is_format_compressed(texImage->TexFormat)) { get_tex_rgba_compressed(ctx, dimensions, format, type, diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index 7d5a574e4..a720c38b8 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -1853,7 +1853,7 @@ texture_error_check( struct gl_context *ctx, /* Check border */ if (border < 0 || border > 1 || - ((ctx->API != API_OPENGL || + ((ctx->API != API_OPENGL_COMPAT || target == GL_TEXTURE_RECTANGLE_NV || target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) { _mesa_error(ctx, GL_INVALID_VALUE, @@ -2353,7 +2353,7 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, /* Check border */ if (border < 0 || border > 1 || - ((ctx->API != API_OPENGL || + ((ctx->API != API_OPENGL_COMPAT || target == GL_TEXTURE_RECTANGLE_NV || target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) { _mesa_error(ctx, GL_INVALID_VALUE, diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c index 92c89102f..c2d161f9a 100644 --- a/mesalib/src/mesa/main/texparam.c +++ b/mesalib/src/mesa/main/texparam.c @@ -64,7 +64,7 @@ validate_texture_wrap_mode(struct gl_context * ctx, GLenum target, GLenum wrap) /* GL_CLAMP was removed in the core profile, and it has never existed in * OpenGL ES. */ - supported = (ctx->API == API_OPENGL) + supported = (ctx->API == API_OPENGL_COMPAT) && (target != GL_TEXTURE_EXTERNAL_OES); break; @@ -358,7 +358,7 @@ set_tex_parameteri(struct gl_context *ctx, return GL_TRUE; case GL_GENERATE_MIPMAP_SGIS: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_pname; if (params[0] && texObj->Target == GL_TEXTURE_EXTERNAL_OES) @@ -418,7 +418,7 @@ set_tex_parameteri(struct gl_context *ctx, /* GL_DEPTH_TEXTURE_MODE_ARB is removed in core-profile and it has never * existed in OpenGL ES. */ - if (ctx->API == API_OPENGL && ctx->Extensions.ARB_depth_texture) { + if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_depth_texture) { if (texObj->DepthMode == params[0]) return GL_FALSE; if (params[0] == GL_LUMINANCE || @@ -562,7 +562,7 @@ set_tex_parameterf(struct gl_context *ctx, return GL_TRUE; case GL_TEXTURE_PRIORITY: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; flush(ctx); @@ -595,7 +595,7 @@ set_tex_parameterf(struct gl_context *ctx, * It was removed in core-profile, and it has never existed in OpenGL * ES. */ - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; if (texObj->Sampler.LodBias != params[0]) { @@ -1328,13 +1328,13 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) } break; case GL_TEXTURE_RESIDENT: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; *params = 1.0F; break; case GL_TEXTURE_PRIORITY: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; *params = obj->Priority; @@ -1366,7 +1366,7 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) *params = obj->Sampler.MaxAnisotropy; break; case GL_GENERATE_MIPMAP_SGIS: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_pname; *params = (GLfloat) obj->GenerateMipmap; @@ -1387,12 +1387,12 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) /* GL_DEPTH_TEXTURE_MODE_ARB is removed in core-profile and it has * never existed in OpenGL ES. */ - if (ctx->API != API_OPENGL || !ctx->Extensions.ARB_depth_texture) + if (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.ARB_depth_texture) goto invalid_pname; *params = (GLfloat) obj->DepthMode; break; case GL_TEXTURE_LOD_BIAS: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; *params = obj->Sampler.LodBias; @@ -1510,13 +1510,13 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) } break; case GL_TEXTURE_RESIDENT: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; *params = 1; break; case GL_TEXTURE_PRIORITY: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; *params = FLOAT_TO_INT(obj->Priority); @@ -1548,7 +1548,7 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) *params = (GLint) obj->Sampler.MaxAnisotropy; break; case GL_GENERATE_MIPMAP_SGIS: - if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_pname; *params = (GLint) obj->GenerateMipmap; @@ -1566,12 +1566,12 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) *params = (GLint) obj->Sampler.CompareFunc; break; case GL_DEPTH_TEXTURE_MODE_ARB: - if (ctx->API != API_OPENGL || !ctx->Extensions.ARB_depth_texture) + if (ctx->API != API_OPENGL_COMPAT || !ctx->Extensions.ARB_depth_texture) goto invalid_pname; *params = (GLint) obj->DepthMode; break; case GL_TEXTURE_LOD_BIAS: - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; *params = (GLint) obj->Sampler.LodBias; diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c index fe7258894..eef8f437d 100644 --- a/mesalib/src/mesa/main/version.c +++ b/mesalib/src/mesa/main/version.c @@ -114,7 +114,7 @@ _mesa_override_gl_version(struct gl_context *ctx) } else if (ctx->Version >= 31) { ctx->API = API_OPENGL_CORE; } else { - ctx->API = API_OPENGL; + ctx->API = API_OPENGL_COMPAT; } create_version_string(ctx, ""); } @@ -344,7 +344,7 @@ _mesa_compute_version(struct gl_context *ctx) return; switch (ctx->API) { - case API_OPENGL: + case API_OPENGL_COMPAT: case API_OPENGL_CORE: compute_version(ctx); break; diff --git a/mesalib/src/mesa/main/vtxfmt.c b/mesalib/src/mesa/main/vtxfmt.c index 5891a5231..674edb5e1 100644 --- a/mesalib/src/mesa/main/vtxfmt.c +++ b/mesalib/src/mesa/main/vtxfmt.c @@ -50,7 +50,7 @@ install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, SET_Color4f(tab, vfmt->Color4f); } - if (ctx->API == API_OPENGL) { + if (ctx->API == API_OPENGL_COMPAT) { _mesa_install_arrayelt_vtxfmt(tab, vfmt); SET_Color3f(tab, vfmt->Color3f); SET_Color3fv(tab, vfmt->Color3fv); @@ -58,7 +58,7 @@ install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, SET_EdgeFlag(tab, vfmt->EdgeFlag); } - if (ctx->API == API_OPENGL) { + if (ctx->API == API_OPENGL_COMPAT) { _mesa_install_eval_vtxfmt(tab, vfmt); } @@ -68,7 +68,7 @@ install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, SET_Normal3f(tab, vfmt->Normal3f); } - if (ctx->API == API_OPENGL) { + if (ctx->API == API_OPENGL_COMPAT) { SET_FogCoordfEXT(tab, vfmt->FogCoordfEXT); SET_FogCoordfvEXT(tab, vfmt->FogCoordfvEXT); SET_Indexf(tab, vfmt->Indexf); @@ -83,7 +83,7 @@ install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, SET_Normal3fv(tab, vfmt->Normal3fv); } - if (ctx->API == API_OPENGL) { + if (ctx->API == API_OPENGL_COMPAT) { SET_SecondaryColor3fEXT(tab, vfmt->SecondaryColor3fEXT); SET_SecondaryColor3fvEXT(tab, vfmt->SecondaryColor3fvEXT); SET_TexCoord1f(tab, vfmt->TexCoord1f); @@ -102,7 +102,7 @@ install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, SET_Vertex4fv(tab, vfmt->Vertex4fv); } - if (ctx->API == API_OPENGL) { + if (ctx->API == API_OPENGL_COMPAT) { _mesa_install_dlist_vtxfmt(tab, vfmt); /* glCallList / glCallLists */ SET_Begin(tab, vfmt->Begin); @@ -145,7 +145,7 @@ install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, } /* Originally for GL_NV_vertex_program, this is also used by dlist.c */ - if (ctx->API == API_OPENGL) { + if (ctx->API == API_OPENGL_COMPAT) { SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV); SET_VertexAttrib1fvNV(tab, vfmt->VertexAttrib1fvNV); SET_VertexAttrib2fNV(tab, vfmt->VertexAttrib2fNV); @@ -189,7 +189,7 @@ install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab, SET_VertexAttribI4uivEXT(tab, vfmt->VertexAttribI4uiv); } - if (ctx->API == API_OPENGL) { + if (ctx->API == API_OPENGL_COMPAT) { /* GL_ARB_vertex_type_10_10_10_2_rev / GL 3.3 */ SET_VertexP2ui(tab, vfmt->VertexP2ui); SET_VertexP2uiv(tab, vfmt->VertexP2uiv); diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c index adee00bd2..04907c9f7 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c +++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c @@ -225,14 +225,16 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx, * gl_renderbuffer::Delete() */ static void -st_renderbuffer_delete(struct gl_renderbuffer *rb) +st_renderbuffer_delete(struct gl_context *ctx, struct gl_renderbuffer *rb) { struct st_renderbuffer *strb = st_renderbuffer(rb); - ASSERT(strb); - pipe_surface_reference(&strb->surface, NULL); + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; + + pipe_surface_release(pipe, &strb->surface); pipe_resource_reference(&strb->texture, NULL); free(strb->data); - _mesa_delete_renderbuffer(rb); + _mesa_delete_renderbuffer(ctx, rb); } @@ -434,7 +436,7 @@ st_render_texture(struct gl_context *ctx, pipe_resource_reference( &strb->texture, pt ); - pipe_surface_reference(&strb->surface, NULL); + pipe_surface_release(pipe, &strb->surface); assert(strb->rtt_level <= strb->texture->last_level); diff --git a/mesalib/src/mesa/state_tracker/st_cb_flush.c b/mesalib/src/mesa/state_tracker/st_cb_flush.c index b4372ae7c..7c9f91f1b 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_flush.c +++ b/mesalib/src/mesa/state_tracker/st_cb_flush.c @@ -79,6 +79,7 @@ display_front_buffer(struct st_context *st) void st_flush( struct st_context *st, struct pipe_fence_handle **fence ) { + FLUSH_VERTICES(st->ctx, 0); FLUSH_CURRENT(st->ctx, 0); st_flush_bitmap_cache(st); diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index 7570d6894..62a736bb6 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -527,7 +527,7 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.NV_texture_rectangle = GL_TRUE; ctx->Extensions.OES_EGL_image = GL_TRUE; - if (ctx->API != API_OPENGL) + if (ctx->API != API_OPENGL_COMPAT) ctx->Extensions.OES_EGL_image_external = GL_TRUE; ctx->Extensions.OES_draw_texture = GL_TRUE; diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c index 5576a0d6c..0b9add95e 100644 --- a/mesalib/src/mesa/state_tracker/st_manager.c +++ b/mesalib/src/mesa/state_tracker/st_manager.c @@ -615,7 +615,7 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi, switch (attribs->profile) { case ST_PROFILE_DEFAULT: - api = API_OPENGL; + api = API_OPENGL_COMPAT; break; case ST_PROFILE_OPENGL_ES1: api = API_OPENGLES; @@ -673,6 +673,8 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi, st->iface.copy = st_context_copy; st->iface.share = st_context_share; st->iface.st_context_private = (void *) smapi; + st->iface.cso_context = st->cso_context; + st->iface.pipe = st->pipe; *error = ST_CONTEXT_SUCCESS; return &st->iface; diff --git a/mesalib/src/mesa/swrast/s_renderbuffer.c b/mesalib/src/mesa/swrast/s_renderbuffer.c index b1fb57823..282b2c482 100644 --- a/mesalib/src/mesa/swrast/s_renderbuffer.c +++ b/mesalib/src/mesa/swrast/s_renderbuffer.c @@ -164,13 +164,13 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, * Called via gl_renderbuffer::Delete() */ static void -soft_renderbuffer_delete(struct gl_renderbuffer *rb) +soft_renderbuffer_delete(struct gl_context *ctx, struct gl_renderbuffer *rb) { struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); free(srb->Buffer); srb->Buffer = NULL; - _mesa_delete_renderbuffer(rb); + _mesa_delete_renderbuffer(ctx, rb); } diff --git a/mesalib/src/mesa/swrast/s_texrender.c b/mesalib/src/mesa/swrast/s_texrender.c index 140e4b50f..7b25a7b7d 100644 --- a/mesalib/src/mesa/swrast/s_texrender.c +++ b/mesalib/src/mesa/swrast/s_texrender.c @@ -16,7 +16,7 @@ static void -delete_texture_wrapper(struct gl_renderbuffer *rb) +delete_texture_wrapper(struct gl_context *ctx, struct gl_renderbuffer *rb) { ASSERT(rb->RefCount == 0); free(rb); diff --git a/mesalib/src/mesa/vbo/vbo_context.c b/mesalib/src/mesa/vbo/vbo_context.c index fd15fb6a9..7eda31e8f 100644 --- a/mesalib/src/mesa/vbo/vbo_context.c +++ b/mesalib/src/mesa/vbo/vbo_context.c @@ -189,7 +189,7 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx ) * vtxfmt mechanism can be removed now. */ vbo_exec_init( ctx ); - if (ctx->API == API_OPENGL) + if (ctx->API == API_OPENGL_COMPAT) vbo_save_init( ctx ); _math_init_eval(); @@ -221,7 +221,7 @@ void _vbo_DestroyContext( struct gl_context *ctx ) } vbo_exec_destroy(ctx); - if (ctx->API == API_OPENGL) + if (ctx->API == API_OPENGL_COMPAT) vbo_save_destroy(ctx); free(vbo); ctx->swtnl_im = NULL; diff --git a/mesalib/src/mesa/vbo/vbo_exec_api.c b/mesalib/src/mesa/vbo/vbo_exec_api.c index 75e549fc4..2aaa2895c 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_api.c +++ b/mesalib/src/mesa/vbo/vbo_exec_api.c @@ -465,10 +465,10 @@ vbo_Materialfv(GLenum face, GLenum pname, const GLfloat *params) updateMats = ALL_MATERIAL_BITS; } - if (ctx->API == API_OPENGL && face == GL_FRONT) { + if (ctx->API == API_OPENGL_COMPAT && face == GL_FRONT) { updateMats &= FRONT_MATERIAL_BITS; } - else if (ctx->API == API_OPENGL && face == GL_BACK) { + else if (ctx->API == API_OPENGL_COMPAT && face == GL_BACK) { updateMats &= BACK_MATERIAL_BITS; } else if (face != GL_FRONT_AND_BACK) { @@ -514,7 +514,7 @@ vbo_Materialfv(GLenum face, GLenum pname, const GLfloat *params) MAT_ATTR(VBO_ATTRIB_MAT_BACK_SHININESS, 1, params); break; case GL_COLOR_INDEXES: - if (ctx->API != API_OPENGL) { + if (ctx->API != API_OPENGL_COMPAT) { _mesa_error(ctx, GL_INVALID_ENUM, "glMaterialfv(pname)"); return; } diff --git a/pixman/pixman/pixman-bits-image.c b/pixman/pixman/pixman-bits-image.c index 085dd1606..7787ef1b8 100644 --- a/pixman/pixman/pixman-bits-image.c +++ b/pixman/pixman/pixman-bits-image.c @@ -413,10 +413,10 @@ bits_image_fetch_pixel_convolution (bits_image_t *image, } } - satot >>= 16; - srtot >>= 16; - sgtot >>= 16; - sbtot >>= 16; + satot = (satot + 0x8000) >> 16; + srtot = (srtot + 0x8000) >> 16; + sgtot = (sgtot + 0x8000) >> 16; + sbtot = (sbtot + 0x8000) >> 16; satot = CLIP (satot, 0, 0xff); srtot = CLIP (srtot, 0, 0xff); diff --git a/pixman/pixman/pixman-matrix.c b/pixman/pixman/pixman-matrix.c index d2ab609dc..cd2f1b5b8 100644 --- a/pixman/pixman/pixman-matrix.c +++ b/pixman/pixman/pixman-matrix.c @@ -62,7 +62,7 @@ pixman_transform_point_3d (const struct pixman_transform *transform, { partial = ((pixman_fixed_48_16_t) transform->matrix[j][i] * (pixman_fixed_48_16_t) vector->vector[i]); - v += partial >> 16; + v += (partial + 0x8000) >> 16; } if (v > pixman_max_fixed_48_16 || v < pixman_min_fixed_48_16) @@ -96,16 +96,16 @@ pixman_transform_point (const struct pixman_transform *transform, { partial = ((pixman_fixed_32_32_t) transform->matrix[j][i] * (pixman_fixed_32_32_t) vector->vector[i]); - v[j] += partial >> 2; + v[j] += (partial + 2) >> 2; } } - if (!(v[2] >> 16)) + if (!((v[2] + 0x8000) >> 16)) return FALSE; for (j = 0; j < 2; j++) { - quo = v[j] / (v[2] >> 16); + quo = v[j] / ((v[2] + 0x8000) >> 16); if (quo > pixman_max_fixed_48_16 || quo < pixman_min_fixed_48_16) return FALSE; vector->vector[j] = (pixman_fixed_t) quo; @@ -138,7 +138,7 @@ pixman_transform_multiply (struct pixman_transform * dst, (pixman_fixed_32_32_t) l->matrix[dy][o] * (pixman_fixed_32_32_t) r->matrix[o][dx]; - v += partial >> 16; + v += (partial + 0x8000) >> 16; } if (v > pixman_max_fixed_48_16 || v < pixman_min_fixed_48_16) diff --git a/pixman/pixman/rounding.txt b/pixman/pixman/rounding.txt new file mode 100644 index 000000000..1a19f450f --- /dev/null +++ b/pixman/pixman/rounding.txt @@ -0,0 +1,134 @@ +*** General notes about rounding + +Suppose a function is sampled at positions [k + o] where k is an +integer and o is a fractional offset 0 <= o < 1. + +To round a value to the nearest sample, breaking ties by rounding up, +we can do this: + + round(x) = floor(x - o + 0.5) + o + +That is, first subtract o to let us pretend that the samples are at +integer coordinates, then add 0.5 and floor to round to nearest +integer, then add the offset back in. + +To break ties by rounding down: + + round(x) = ceil(x - o - 0.5) + o + +or if we have an epsilon value: + + round(x) = floor(x - o + 0.5 - e) + o + +To always round *up* to the next sample: + + round_up(x) = ceil(x - o) + o + +To always round *down* to the previous sample: + + round_down(x) = floor(x - o) + o + +If a set of samples is stored in an array, you get from the sample +position to an index by subtracting the position of the first sample +in the array: + + index(s) = s - first_sample + + +*** Application to pixman + +In pixman, images are sampled with o = 0.5, that is, pixels are +located midways between integers. We usually break ties by rounding +down (i.e., "round towards north-west"). + + +-- NEAREST filtering: + +The NEAREST filter simply picks the closest pixel to the given +position: + + round(x) = floor(x - 0.5 + 0.5 - e) + 0.5 = floor (x - e) + 0.5 + +The first sample of a pixman image has position 0.5, so to find the +index in the pixel array, we have to subtract 0.5: + + floor (x - e) + 0.5 - 0.5 = floor (x - e). + +Therefore a 16.16 fixed-point image location is turned into a pixel +value with NEAREST filtering by doing this: + + pixels[((y - e) >> 16) * stride + ((x - e) >> 16)] + +where stride is the number of pixels allocated per scanline and e = +0x0001. + + +-- CONVOLUTION filtering: + +A convolution matrix is considered a sampling of a function f at +values surrounding 0. For example, this convolution matrix: + + [a, b, c, d] + +is interpreted as the values of a function f: + + a = f(-1.5) + b = f(-0.5) + c = f(0.5) + d = f(1.5) + +The sample offset in this case is o = 0.5 and the first sample has +position s0 = -1.5. If the matrix is: + + [a, b, c, d, e] + +the sample offset is o = 0 and the first sample has position s0 = +-2.0. In general we have + + s0 = (- width / 2.0 + 0.5). + +and + + o = frac (s0) + +To evaluate f at a position between the samples, we round to the +closest sample, and then we subtract the position of the first sample +to get the index in the matrix: + + f(t) = matrix[floor(t - o + 0.5) + o - s0] + +Note that in this case we break ties by rounding up. + +If we write s0 = m + o, where m is an integer, this is equivalent to + + f(t) = matrix[floor(t - o + 0.5) + o - (m + o)] + = matrix[floor(t - o + 0.5 - m) + o - o] + = matrix[floor(t - s0 + 0.5)] + +The convolution filter in pixman positions f such that 0 aligns with +the given position x. For a given pixel x0 in the image, the closest +sample of f is then computed by taking (x - x0) and rounding that to +the closest index: + + i = floor ((x0 - x) - s0 + 0.5) + +To perform the convolution, we have to find the first pixel x0 whose +corresponding sample has index 0. We can write x0 = k + 0.5, where k +is an integer: + + 0 = floor(k + 0.5 - x - s0 + 0.5) + + = k + floor(1 - x - s0) + + = k - ceil(x + s0 - 1) + + = k - floor(x + s0 - e) + + = k - floor(x - (width - 1) / 2.0 - e) + +And so the final formula for the index k of x0 in the image is: + + k = floor(x - (width - 1) / 2.0 - e) + +Computing the result is then simply a matter of convolving all the +pixels starting at k with all the samples in the matrix. diff --git a/pixman/test/affine-test.c b/pixman/test/affine-test.c index 7bc28b4cd..daa86c81d 100644 --- a/pixman/test/affine-test.c +++ b/pixman/test/affine-test.c @@ -310,11 +310,11 @@ test_composite (int testnum, } #if BILINEAR_INTERPOLATION_BITS == 8 -#define CHECKSUM 0x1EF2175A +#define CHECKSUM 0x344413F0 #elif BILINEAR_INTERPOLATION_BITS == 7 -#define CHECKSUM 0x74050F50 +#define CHECKSUM 0xC8181A76 #elif BILINEAR_INTERPOLATION_BITS == 4 -#define CHECKSUM 0x4362EAE8 +#define CHECKSUM 0xD672A457 #else #define CHECKSUM 0x00000000 #endif diff --git a/pixman/test/rotate-test.c b/pixman/test/rotate-test.c index d63a28947..a0488ef22 100644 --- a/pixman/test/rotate-test.c +++ b/pixman/test/rotate-test.c @@ -108,6 +108,6 @@ int main (int argc, const char *argv[]) { return fuzzer_test_main ("rotate", 15000, - 0x03A24D51, + 0x5236FD9F, test_transform, argc, argv); } diff --git a/pixman/test/scaling-test.c b/pixman/test/scaling-test.c index 273612395..035410333 100644 --- a/pixman/test/scaling-test.c +++ b/pixman/test/scaling-test.c @@ -380,11 +380,11 @@ test_composite (int testnum, } #if BILINEAR_INTERPOLATION_BITS == 8 -#define CHECKSUM 0x8D3A7539 +#define CHECKSUM 0x107B67ED #elif BILINEAR_INTERPOLATION_BITS == 7 -#define CHECKSUM 0x03A23E0C +#define CHECKSUM 0x30EC0CF0 #elif BILINEAR_INTERPOLATION_BITS == 4 -#define CHECKSUM 0xE96D1A5E +#define CHECKSUM 0x87B496BC #else #define CHECKSUM 0x00000000 #endif diff --git a/xorg-server/Xext/saver.c b/xorg-server/Xext/saver.c index ac4a633e7..f73e2a21f 100644 --- a/xorg-server/Xext/saver.c +++ b/xorg-server/Xext/saver.c @@ -393,6 +393,8 @@ ScreenSaverFreeSuspend(pointer value, XID id) UpdateCurrentTimeIf(); nt_list_for_each_entry(dev, inputInfo.devices, next) lastDeviceEventTime[dev->id] = currentTime; + lastDeviceEventTime[XIAllDevices] = currentTime; + lastDeviceEventTime[XIAllMasterDevices] = currentTime; SetScreenSaverTimer(); } } diff --git a/xorg-server/Xi/exevents.c b/xorg-server/Xi/exevents.c index 4248b9a86..2caf98c25 100644 --- a/xorg-server/Xi/exevents.c +++ b/xorg-server/Xi/exevents.c @@ -1066,24 +1066,14 @@ ActivateEarlyAccept(DeviceIntPtr dev, TouchPointInfoPtr ti) static void EmitTouchEnd(DeviceIntPtr dev, TouchPointInfoPtr ti, int flags, XID resource) { - InternalEvent *tel = InitEventList(GetMaximumEventsNum()); - ValuatorMask *mask = valuator_mask_new(2); - int i, nev; - - valuator_mask_set_double(mask, 0, - valuator_mask_get_double(ti->valuators, 0)); - valuator_mask_set_double(mask, 1, - valuator_mask_get_double(ti->valuators, 1)); + InternalEvent event; flags |= TOUCH_CLIENT_ID; if (ti->emulate_pointer) flags |= TOUCH_POINTER_EMULATED; - nev = GetTouchEvents(tel, dev, ti->client_id, XI_TouchEnd, flags, mask); - for (i = 0; i < nev; i++) - DeliverTouchEvents(dev, ti, tel + i, resource); - - valuator_mask_free(&mask); - FreeEventList(tel, GetMaximumEventsNum()); + TouchDeliverDeviceClassesChangedEvent(ti, GetTimeInMillis(), resource); + GetDixTouchEnd(&event, dev, ti, flags); + DeliverTouchEvents(dev, ti, &event, resource); } /** diff --git a/xorg-server/dix/getevents.c b/xorg-server/dix/getevents.c index 2a686e877..fa538d9f4 100644 --- a/xorg-server/dix/getevents.c +++ b/xorg-server/dix/getevents.c @@ -1833,10 +1833,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid, int i; int num_events = 0; RawDeviceEvent *raw; - union touch { - TouchPointInfoPtr dix_ti; - DDXTouchPointInfoPtr ti; - } touchpoint; + DDXTouchPointInfoPtr ti; int need_rawevent = TRUE; Bool emulate_pointer = FALSE; int client_id = 0; @@ -1855,37 +1852,15 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid, /* Find and/or create the DDX touch info */ - if (flags & TOUCH_CLIENT_ID) { /* A DIX-submitted TouchEnd */ - touchpoint.dix_ti = TouchFindByClientID(dev, ddx_touchid); - BUG_RETURN_VAL(!touchpoint.dix_ti, 0); - - if (!mask_in || - !valuator_mask_isset(mask_in, 0) || - !valuator_mask_isset(mask_in, 1)) { - ErrorF - ("[dix] dix-submitted events must have x/y valuator information.\n"); - return 0; - } - - need_rawevent = FALSE; - client_id = touchpoint.dix_ti->client_id; - } - else { /* a DDX-submitted touch */ - - touchpoint.ti = - TouchFindByDDXID(dev, ddx_touchid, (type == XI_TouchBegin)); - if (!touchpoint.ti) { - ErrorFSigSafe("[dix] %s: unable to %s touch point %u\n", dev->name, - type == XI_TouchBegin ? "begin" : "find", ddx_touchid); - return 0; - } - client_id = touchpoint.ti->client_id; + ti = TouchFindByDDXID(dev, ddx_touchid, (type == XI_TouchBegin)); + if (!ti) { + ErrorFSigSafe("[dix] %s: unable to %s touch point %u\n", dev->name, + type == XI_TouchBegin ? "begin" : "find", ddx_touchid); + return 0; } + client_id = ti->client_id; - if (!(flags & TOUCH_CLIENT_ID)) - emulate_pointer = touchpoint.ti->emulate_pointer; - else - emulate_pointer = ! !(flags & TOUCH_POINTER_EMULATED); + emulate_pointer = ti->emulate_pointer; if (!IsMaster(dev)) events = @@ -1905,11 +1880,6 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid, num_events++; init_device_event(event, dev, ms); - /* if submitted for master device, get the sourceid from there */ - if (flags & TOUCH_CLIENT_ID) { - event->sourceid = touchpoint.dix_ti->sourceid; - /* TOUCH_CLIENT_ID implies norawevent */ - } switch (type) { case XI_TouchBegin: @@ -1934,38 +1904,30 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid, event->type = ET_TouchEnd; /* We can end the DDX touch here, since we don't use the active * field below */ - if (!(flags & TOUCH_CLIENT_ID)) - TouchEndDDXTouch(dev, touchpoint.ti); + TouchEndDDXTouch(dev, ti); break; default: return 0; } - if (t->mode == XIDirectTouch && !(flags & TOUCH_CLIENT_ID)) { - if (!valuator_mask_isset(&mask, 0)) - valuator_mask_set_double(&mask, 0, - valuator_mask_get_double(touchpoint.ti-> - valuators, 0)); - if (!valuator_mask_isset(&mask, 1)) - valuator_mask_set_double(&mask, 1, - valuator_mask_get_double(touchpoint.ti-> - valuators, 1)); - } /* Get our screen event co-ordinates (root_x/root_y/event_x/event_y): * these come from the touchpoint in Absolute mode, or the sprite in * Relative. */ if (t->mode == XIDirectTouch) { - transformAbsolute(dev, &mask); - - if (!(flags & TOUCH_CLIENT_ID)) { - for (i = 0; i < valuator_mask_size(&mask); i++) { - double val; - - if (valuator_mask_fetch_double(&mask, i, &val)) - valuator_mask_set_double(touchpoint.ti->valuators, i, val); - } + for (i = 0; i < max(valuator_mask_size(&mask), 2); i++) { + double val; + + if (valuator_mask_fetch_double(&mask, i, &val)) + valuator_mask_set_double(ti->valuators, i, val); + /* If the device doesn't post new X and Y axis values, + * use the last values posted. + */ + else if (i < 2 && + valuator_mask_fetch_double(ti->valuators, i, &val)) + valuator_mask_set_double(&mask, i, val); } + transformAbsolute(dev, &mask); clipAbsolute(dev, &mask); } else { @@ -1994,6 +1956,14 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid, if (emulate_pointer) storeLastValuators(dev, &mask, 0, 1, devx, devy); + /* Update the MD's co-ordinates, which are always in desktop space. */ + if (emulate_pointer && !IsMaster(dev) && !IsFloating(dev)) { + DeviceIntPtr master = GetMaster(dev, MASTER_POINTER); + + master->last.valuators[0] = screenx; + master->last.valuators[1] = screeny; + } + event->root = scr->root->drawable.id; event_set_root_coordinates(event, screenx, screeny); @@ -2014,6 +1984,37 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid, return num_events; } +void +GetDixTouchEnd(InternalEvent *ievent, DeviceIntPtr dev, TouchPointInfoPtr ti, + uint32_t flags) +{ + ScreenPtr scr = dev->spriteInfo->sprite->hotPhys.pScreen; + DeviceEvent *event = &ievent->device_event; + CARD32 ms = GetTimeInMillis(); + + BUG_WARN(!dev->enabled); + + init_device_event(event, dev, ms); + + event->sourceid = ti->sourceid; + event->type = ET_TouchEnd; + + event->root = scr->root->drawable.id; + + /* Get screen event coordinates from the sprite. Is this really the best + * we can do? */ + event_set_root_coordinates(event, + dev->last.valuators[0], + dev->last.valuators[1]); + event->touchid = ti->client_id; + event->flags = flags; + + if (flags & TOUCH_POINTER_EMULATED) { + event->flags |= TOUCH_POINTER_EMULATED; + event->detail.button = 1; + } +} + /** * Synthesize a single motion event for the core pointer. * diff --git a/xorg-server/dix/inpututils.c b/xorg-server/dix/inpututils.c index f01e9a7cd..eb2222a07 100644 --- a/xorg-server/dix/inpututils.c +++ b/xorg-server/dix/inpututils.c @@ -910,11 +910,7 @@ input_option_set_value(InputOption *opt, const char *value) double fp1616_to_double(FP1616 in) { - double ret; - - ret = (double) (in >> 16); - ret += (double) (in & 0xffff) * (1.0 / (1UL << 16)); /* Optimized: ldexp((double)(in & 0xffff), -16); */ - return ret; + return pixman_fixed_to_double(in); } double @@ -930,20 +926,7 @@ fp3232_to_double(FP3232 in) FP1616 double_to_fp1616(double in) { - FP1616 ret; - int32_t integral; - double tmp; - uint32_t frac_d; - - tmp = floor(in); - integral = (int32_t) tmp; - - tmp = (in - integral) * (1UL << 16); /* Optimized: ldexp(in - integral, 16) */ - frac_d = (uint16_t) tmp; - - ret = integral << 16; - ret |= frac_d & 0xffff; - return ret; + return pixman_double_to_fixed(in); } FP3232 diff --git a/xorg-server/dix/touch.c b/xorg-server/dix/touch.c index 5f77be575..29ba17194 100644 --- a/xorg-server/dix/touch.c +++ b/xorg-server/dix/touch.c @@ -463,45 +463,14 @@ TouchEventHistoryPush(TouchPointInfoPtr ti, const DeviceEvent *ev) void TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev, XID resource) { - InternalEvent *tel; - ValuatorMask *mask; - int i, nev; - int flags; + int i; if (!ti->history) return; - tel = InitEventList(GetMaximumEventsNum()); - mask = valuator_mask_new(0); - - valuator_mask_set_double(mask, 0, ti->history[0].valuators.data[0]); - valuator_mask_set_double(mask, 1, ti->history[0].valuators.data[1]); - - flags = TOUCH_CLIENT_ID | TOUCH_REPLAYING; - if (ti->emulate_pointer) - flags |= TOUCH_POINTER_EMULATED; - /* Generate events based on a fake touch begin event to get DCCE events if - * needed */ - /* FIXME: This needs to be cleaned up */ - nev = GetTouchEvents(tel, dev, ti->client_id, XI_TouchBegin, flags, mask); - for (i = 0; i < nev; i++) { - /* Send saved touch begin event */ - if (tel[i].any.type == ET_TouchBegin) { - DeviceEvent *ev = &ti->history[0]; - ev->flags |= TOUCH_REPLAYING; - DeliverTouchEvents(dev, ti, (InternalEvent*)ev, resource); - } - else {/* Send DCCE event */ - tel[i].any.time = ti->history[0].time; - DeliverTouchEvents(dev, ti, tel + i, resource); - } - } - - valuator_mask_free(&mask); - FreeEventList(tel, GetMaximumEventsNum()); + TouchDeliverDeviceClassesChangedEvent(ti, ti->history[0].time, resource); - /* First event was TouchBegin, already replayed that one */ - for (i = 1; i < ti->history_elements; i++) { + for (i = 0; i < ti->history_elements; i++) { DeviceEvent *ev = &ti->history[i]; ev->flags |= TOUCH_REPLAYING; @@ -509,6 +478,30 @@ TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev, XID resource) } } +void +TouchDeliverDeviceClassesChangedEvent(TouchPointInfoPtr ti, Time time, + XID resource) +{ + DeviceIntPtr dev; + int num_events = 0; + InternalEvent dcce; + + dixLookupDevice(&dev, ti->sourceid, serverClient, DixWriteAccess); + + if (!dev) + return; + + /* UpdateFromMaster generates at most one event */ + UpdateFromMaster(&dcce, dev, DEVCHANGE_POINTER_EVENT, &num_events); + BUG_WARN(num_events > 1); + + if (num_events) { + dcce.any.time = time; + /* FIXME: This doesn't do anything */ + dev->public.processInputProc(&dcce, dev); + } +} + Bool TouchBuildDependentSpriteTrace(DeviceIntPtr dev, SpritePtr sprite) { diff --git a/xorg-server/dix/window.c b/xorg-server/dix/window.c index e70531af6..99b3e0a13 100644 --- a/xorg-server/dix/window.c +++ b/xorg-server/dix/window.c @@ -3095,6 +3095,8 @@ dixSaveScreens(ClientPtr client, int on, int mode) UpdateCurrentTimeIf(); nt_list_for_each_entry(dev, inputInfo.devices, next) lastDeviceEventTime[dev->id] = currentTime; + lastDeviceEventTime[XIAllDevices] = currentTime; + lastDeviceEventTime[XIAllMasterDevices] = currentTime; } SetScreenSaverTimer(); } diff --git a/xorg-server/hw/dmx/dmxcursor.c b/xorg-server/hw/dmx/dmxcursor.c index 1a77c7d78..35aca81b4 100644 --- a/xorg-server/hw/dmx/dmxcursor.c +++ b/xorg-server/hw/dmx/dmxcursor.c @@ -346,6 +346,8 @@ dmxComputeScreenOrigins(void) screenInfo.screens[i]->y -= minY; } } + + update_desktop_dimensions(); } /** Recompute origin information in the #dmxScreens list. This is diff --git a/xorg-server/include/input.h b/xorg-server/include/input.h index f8459b8c8..2387dbf4a 100644 --- a/xorg-server/include/input.h +++ b/xorg-server/include/input.h @@ -465,6 +465,11 @@ extern int GetTouchOwnershipEvents(InternalEvent *events, TouchPointInfoPtr ti, uint8_t mode, XID resource, uint32_t flags); +extern void GetDixTouchEnd(InternalEvent *ievent, + DeviceIntPtr dev, + TouchPointInfoPtr ti, + uint32_t flags); + extern _X_EXPORT int GetProximityEvents(InternalEvent *events, DeviceIntPtr pDev, int type, const ValuatorMask *mask); @@ -580,6 +585,8 @@ extern int TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti, extern int TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode, uint32_t touchid, Window grab_window, XID *error); extern void TouchEndPhysicallyActiveTouches(DeviceIntPtr dev); +extern void TouchDeliverDeviceClassesChangedEvent(TouchPointInfoPtr ti, + Time time, XID resource); /* misc event helpers */ extern Mask GetEventMask(DeviceIntPtr dev, xEvent *ev, InputClientsPtr clients); diff --git a/xorg-server/include/inputstr.h b/xorg-server/include/inputstr.h index 5a38924de..bb0a77963 100644 --- a/xorg-server/include/inputstr.h +++ b/xorg-server/include/inputstr.h @@ -331,7 +331,7 @@ typedef struct _DDXTouchPointInfo { uint32_t ddx_id; /* touch ID given by the DDX */ Bool emulate_pointer; - ValuatorMask *valuators; /* last recorded axis values */ + ValuatorMask *valuators; /* last axis values as posted, pre-transform */ } DDXTouchPointInfoRec; typedef struct _TouchClassRec { diff --git a/xorg-server/include/xkbsrv.h b/xorg-server/include/xkbsrv.h index 2b926a980..45e2e8c47 100644 --- a/xorg-server/include/xkbsrv.h +++ b/xorg-server/include/xkbsrv.h @@ -171,6 +171,7 @@ typedef struct _XkbSrvInfo { KeyCode mouseKey; KeyCode inactiveKey; KeyCode slowKey; + KeyCode slowKeyEnableKey; KeyCode repeatKey; CARD8 krgTimerActive; CARD8 beepType; diff --git a/xorg-server/randr/randr.c b/xorg-server/randr/randr.c index da48c3f06..f0decfc6c 100644 --- a/xorg-server/randr/randr.c +++ b/xorg-server/randr/randr.c @@ -264,6 +264,8 @@ RRInit(void) return FALSE; if (!RROutputInit()) return FALSE; + if (!RRProviderInit()) + return FALSE; RRGeneration = serverGeneration; } if (!dixRegisterPrivateKey(&rrPrivKeyRec, PRIVATE_SCREEN, 0)) diff --git a/xorg-server/xfixes/cursor.c b/xorg-server/xfixes/cursor.c index bd175b40f..ffee4d6ab 100644 --- a/xorg-server/xfixes/cursor.c +++ b/xorg-server/xfixes/cursor.c @@ -1093,7 +1093,11 @@ barrier_is_blocking(const struct PointerBarrier * barrier, if (dir & BarrierNegativeX && x1 == (barrier->x1 - 1)) return FALSE; /* startpoint adjacent to barrier, moving towards -> block */ - if (x1 == barrier->x1 && y1 >= barrier->y1 && y1 <= barrier->y2) { + if (dir & BarrierPositiveX && x1 == (barrier->x1 - 1) && y1 >= barrier->y1 && y1 <= barrier->y2) { + *distance = 0; + return TRUE; + } + if (dir & BarrierNegativeX && x1 == barrier->x1 && y1 >= barrier->y1 && y1 <= barrier->y2) { *distance = 0; return TRUE; } @@ -1105,7 +1109,11 @@ barrier_is_blocking(const struct PointerBarrier * barrier, if (dir & BarrierNegativeY && y1 == (barrier->y1 - 1)) return FALSE; /* startpoint adjacent to barrier, moving towards -> block */ - if (y1 == barrier->y1 && x1 >= barrier->x1 && x1 <= barrier->x2) { + if (dir & BarrierPositiveY && y1 == (barrier->y1 - 1) && x1 >= barrier->x1 && x1 <= barrier->x2) { + *distance = 0; + return TRUE; + } + if (dir & BarrierNegativeY && y1 == barrier->y1 && x1 >= barrier->x1 && x1 <= barrier->x2) { *distance = 0; return TRUE; } diff --git a/xorg-server/xkb/xkbAccessX.c b/xorg-server/xkb/xkbAccessX.c index c1af32eb9..21df85d94 100644 --- a/xorg-server/xkb/xkbAccessX.c +++ b/xorg-server/xkb/xkbAccessX.c @@ -291,8 +291,8 @@ AccessXKRGExpire(OsTimerPtr timer, CARD32 now, pointer arg) return 4000; } xkbi->krgTimerActive = _OFF_TIMER; - cn.keycode = 0; - cn.eventType = 0; + cn.keycode = xkbi->slowKeyEnableKey; + cn.eventType = KeyPress; cn.requestMajor = 0; cn.requestMinor = 0; if (xkbi->desc->ctrls->enabled_ctrls & XkbSlowKeysMask) { @@ -304,6 +304,7 @@ AccessXKRGExpire(OsTimerPtr timer, CARD32 now, pointer arg) LogMessage(X_INFO, "XKB SlowKeys are now enabled. Hold shift to disable.\n"); } + xkbi->slowKeyEnableKey = 0; return 0; } @@ -462,6 +463,7 @@ AccessXFilterPressEvent(DeviceEvent *event, DeviceIntPtr keybd) if (ctrls->enabled_ctrls & XkbAccessXKeysMask) { /* check for magic sequences */ if ((sym[0] == XK_Shift_R) || (sym[0] == XK_Shift_L)) { + xkbi->slowKeyEnableKey = key; if (XkbAX_NeedFeedback(ctrls, XkbAX_SlowWarnFBMask)) { xkbi->krgTimerActive = _KRG_WARN_TIMER; xkbi->krgTimer = TimerSet(xkbi->krgTimer, 0, 4000, diff --git a/xorg-server/xkeyboard-config/symbols/level3 b/xorg-server/xkeyboard-config/symbols/level3 index 9d495550a..8bf83bbf3 100644 --- a/xorg-server/xkeyboard-config/symbols/level3 +++ b/xorg-server/xkeyboard-config/symbols/level3 @@ -2,6 +2,19 @@ // the third shift level can be reached // +// Ensure a mapping to a real modifier for LevelThree +partial modifier_keys +xkb_symbols "modifier_mapping" { + key.type[Group1] = "ONE_LEVEL"; + + replace key <LVL3> { + vmods = LevelThree, + symbols[Group1] = [ ISO_Level3_Shift ], + actions[Group1] = [ SetMods(modifiers=LevelThree) ] + }; + modifier_map Mod5 { <LVL3> }; +}; + // the default behavior is for the right Alt key (AltGr) to generate the // third engraved symbol default partial modifier_keys @@ -10,7 +23,7 @@ xkb_symbols "ralt_switch" { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift ] }; - modifier_map Mod5 { ISO_Level3_Shift }; + include "level3(modifier_mapping)" }; // Right Alt key never chooses 3rd level. @@ -38,6 +51,7 @@ xkb_symbols "ralt_switch_multikey" { type[Group1]="TWO_LEVEL", symbols[Group1] = [ ISO_Level3_Shift, Multi_key ] }; + include "level3(modifier_mapping)" }; // special case or right Alt switch - for use with grp:alts_toggle @@ -55,7 +69,7 @@ xkb_symbols "ralt_switch_for_alts_toggle" { symbols[Group1] = [ ISO_Level3_Shift, ISO_Next_Group ], virtualMods= AltGr }; - modifier_map Mod5 { ISO_Level3_Shift }; + include "level3(modifier_mapping)" }; // using the level(alt_switch) map, either Alt key temporarily chooses @@ -72,7 +86,7 @@ xkb_symbols "lalt_switch" { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift ] }; - modifier_map Mod5 { <LALT> }; + include "level3(modifier_mapping)" }; // using the level(switch) map, the right Control key temporarily @@ -83,7 +97,7 @@ xkb_symbols "switch" { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift ] }; - modifier_map Mod5 { ISO_Level3_Shift }; + include "level3(modifier_mapping)" }; // using the level(menu_switch) map, the Menu key temporarily @@ -94,7 +108,7 @@ xkb_symbols "menu_switch" { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift ] }; - modifier_map Mod5 { ISO_Level3_Shift }; + include "level3(modifier_mapping)" }; // using the level3(win_switch) map, the either Windows' logo key @@ -113,7 +127,7 @@ xkb_symbols "lwin_switch" { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift ] }; - modifier_map Mod5 { ISO_Level3_Shift }; + include "level3(modifier_mapping)" }; // using the level(rwin_switch) map, the right Windows' logo key @@ -126,7 +140,7 @@ xkb_symbols "rwin_switch" { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift ] }; - modifier_map Mod5 { ISO_Level3_Shift }; + include "level3(modifier_mapping)" }; // using the level3(enter_switch) map, the Enter key on the keypad @@ -138,7 +152,7 @@ xkb_symbols "enter_switch" { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift ] }; - modifier_map Mod5 { ISO_Level3_Shift }; + include "level3(modifier_mapping)" }; partial modifier_keys @@ -147,7 +161,7 @@ xkb_symbols "caps_switch" { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift ] }; - modifier_map Mod5 { ISO_Level3_Shift }; + include "level3(modifier_mapping)" }; partial modifier_keys @@ -156,7 +170,7 @@ xkb_symbols "bksl_switch" { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift ] }; - modifier_map Mod5 { ISO_Level3_Shift }; + include "level3(modifier_mapping)" }; partial modifier_keys @@ -165,7 +179,7 @@ xkb_symbols "lsgt_switch" { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift ] }; - modifier_map Mod5 { ISO_Level3_Shift }; + include "level3(modifier_mapping)" }; partial modifier_keys @@ -174,7 +188,7 @@ xkb_symbols "caps_switch_latch" { type[Group1]="THREE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift, ISO_Level3_Shift, ISO_Level3_Latch ] }; - modifier_map Mod5 { ISO_Level3_Shift }; + include "level3(modifier_mapping)" }; partial modifier_keys @@ -183,7 +197,7 @@ xkb_symbols "bksl_switch_latch" { type[Group1]="THREE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift, ISO_Level3_Shift, ISO_Level3_Latch ] }; - modifier_map Mod5 { ISO_Level3_Shift }; + include "level3(modifier_mapping)" }; partial modifier_keys @@ -192,5 +206,5 @@ xkb_symbols "lsgt_switch_latch" { type[Group1]="THREE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift, ISO_Level3_Shift, ISO_Level3_Latch ] }; - modifier_map Mod5 { ISO_Level3_Shift }; + include "level3(modifier_mapping)" }; diff --git a/xorg-server/xkeyboard-config/symbols/level5 b/xorg-server/xkeyboard-config/symbols/level5 index ce219b5bf..f5ecb620e 100644 --- a/xorg-server/xkeyboard-config/symbols/level5 +++ b/xorg-server/xkeyboard-config/symbols/level5 @@ -2,6 +2,19 @@ // the third shift level can be reached // +// Ensure a mapping to a real modifier for LevelFive +partial modifier_keys +xkb_symbols "modifier_mapping" { + key.type[Group1] = "ONE_LEVEL"; + + replace key <MDSW> { + vmods = LevelFive, + symbols[Group1] = [ ISO_Level5_Shift ], + actions[Group1] = [ SetMods(modifiers=LevelFive) ] + }; + modifier_map Mod3 { <MDSW> }; +}; + // using the level(switch) map, the right Control key temporarily // chooses the fifth shift level (until it is released). partial modifier_keys @@ -10,7 +23,7 @@ xkb_symbols "rctrl_switch" { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level5_Shift ] }; - modifier_map Mod3 { ISO_Level5_Shift }; + include "level5(modifier_mapping)" }; partial modifier_keys @@ -19,7 +32,7 @@ xkb_symbols "lsgt_switch" { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level5_Shift ] }; - modifier_map Mod3 { ISO_Level5_Shift }; + include "level5(modifier_mapping)" }; partial modifier_keys @@ -28,7 +41,7 @@ xkb_symbols "ralt_switch" { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level5_Shift ] }; - modifier_map Mod3 { ISO_Level5_Shift }; + include "level5(modifier_mapping)" }; @@ -43,12 +56,7 @@ xkb_symbols "lock" { // See also: compat/level5(level5_lock) key.type[Group1] = "ONE_LEVEL"; - replace key <MDSW> { - vmods = LevelFive, - symbols[Group1] = [ ISO_Level5_Shift ], - actions[Group1] = [ SetMods(modifiers=LevelFive) ] - }; - modifier_map Mod3 { <MDSW> }; + include "level5(modifier_mapping)" replace key <HYPR> { vmods = NumLock, |