From feee2b5ceb37101bd1c4162e49805e6ad63e28ae Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 28 Feb 2011 06:37:03 +0000 Subject: xserver libX11 Xextproto mesa Git update 28 Feb 2011 --- X11/extensions/Makefile.in | 856 -- X11/extensions/configure.ac | 36 +- libX11/specs/i18n/localedb/localedb.xml | 1554 ++-- libX11/specs/i18n/trans/trans.xml | 3958 ++++----- libXext/src/Xge.c | 730 +- mesalib/docs/GL3.txt | 2 +- mesalib/docs/MESA_multithread_makecurrent.spec | 158 + mesalib/docs/relnotes-7.11.html | 119 +- mesalib/src/glsl/Makefile | 426 +- mesalib/src/mesa/main/extensions.c | 1831 ++--- mesalib/src/mesa/main/formats.c | 3276 ++++---- mesalib/src/mesa/main/formats.h | 480 +- mesalib/src/mesa/main/texcompress.c | 518 +- mesalib/src/mesa/main/texcompress_rgtc.c | 1122 +++ mesalib/src/mesa/main/texcompress_rgtc.h | 60 + mesalib/src/mesa/main/texfetch.c | 1815 ++-- mesalib/src/mesa/main/texformat.c | 19 + mesalib/src/mesa/main/texstore.c | 9572 +++++++++++----------- mesalib/src/mesa/main/texstore.h | 445 +- mesalib/src/mesa/sources.mak | 737 +- mesalib/src/mesa/state_tracker/st_draw.c | 2 + mesalib/src/mesa/state_tracker/st_extensions.c | 980 +-- mesalib/src/mesa/state_tracker/st_format.c | 17 + mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c | 2 +- xorg-server/configure.ac | 7 +- xorg-server/dix/devices.c | 5206 ++++++------ xorg-server/hw/dmx/doc/Makefile.am | 63 +- xorg-server/hw/dmx/doc/doxygen.conf | 1053 --- xorg-server/hw/dmx/doc/doxygen.conf.in | 1053 +++ xorg-server/hw/xfree86/loader/Makefile.am | 59 +- xorg-server/hw/xwin/glx/Makefile.am | 120 +- xorg-server/xkeyboard-config/rules/base.o_s.part | 285 +- xorg-server/xkeyboard-config/rules/base.xml.in | 10 +- xorg-server/xkeyboard-config/symbols/af | 794 +- xorg-server/xkeyboard-config/symbols/capslock | 136 +- xorg-server/xkeyboard-config/symbols/et | 146 +- xorg-server/xkeyboard-config/symbols/mn | 162 +- xorg-server/xkeyboard-config/symbols/np | 241 +- 38 files changed, 19372 insertions(+), 18678 deletions(-) delete mode 100644 X11/extensions/Makefile.in create mode 100644 mesalib/docs/MESA_multithread_makecurrent.spec create mode 100644 mesalib/src/mesa/main/texcompress_rgtc.c create mode 100644 mesalib/src/mesa/main/texcompress_rgtc.h delete mode 100644 xorg-server/hw/dmx/doc/doxygen.conf create mode 100644 xorg-server/hw/dmx/doc/doxygen.conf.in diff --git a/X11/extensions/Makefile.in b/X11/extensions/Makefile.in deleted file mode 100644 index 81eaffd2a..000000000 --- a/X11/extensions/Makefile.in +++ /dev/null @@ -1,856 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = . -DIST_COMMON = README $(am__configure_deps) $(compat_HEADERS) \ - $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(srcdir)/xextproto.pc.in $(top_srcdir)/configure \ - $(xext_HEADERS) COPYING ChangeLog INSTALL config.guess \ - config.sub install-sh missing -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ - configure.lineno config.status.lineno -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = xextproto.pc -CONFIG_CLEAN_VPATH_FILES = -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) -am__v_at_0 = @ -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-dvi-recursive install-exec-recursive \ - install-html-recursive install-info-recursive \ - install-pdf-recursive install-ps-recursive install-recursive \ - installcheck-recursive installdirs-recursive pdf-recursive \ - ps-recursive uninstall-recursive -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__installdirs = "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(compatdir)" \ - "$(DESTDIR)$(xextdir)" -DATA = $(pkgconfig_DATA) -HEADERS = $(compat_HEADERS) $(xext_HEADERS) -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ - $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ - distdir dist dist-all distcheck -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -distdir = $(PACKAGE)-$(VERSION) -top_distdir = $(distdir) -am__remove_distdir = \ - { test ! -d "$(distdir)" \ - || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -fr "$(distdir)"; }; } -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.bz2 -GZIP_ENV = --best -distuninstallcheck_listfiles = find . -type f -print -distcleancheck_listfiles = find . -type f -print -ACLOCAL = @ACLOCAL@ -ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ -ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -APP_MAN_DIR = @APP_MAN_DIR@ -APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CHANGELOG_CMD = @CHANGELOG_CMD@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CWARNFLAGS = @CWARNFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ -DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FILE_MAN_DIR = @FILE_MAN_DIR@ -FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ -FOP = @FOP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_CMD = @INSTALL_CMD@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIB_MAN_DIR = @LIB_MAN_DIR@ -LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ -LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MAN_SUBSTS = @MAN_SUBSTS@ -MISC_MAN_DIR = @MISC_MAN_DIR@ -MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ -MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -STYLESHEET_SRCDIR = @STYLESHEET_SRCDIR@ -VERSION = @VERSION@ -XMLTO = @XMLTO@ -XORG_MAN_PAGE = @XORG_MAN_PAGE@ -XORG_SGML_PATH = @XORG_SGML_PATH@ -XSL_STYLESHEET = @XSL_STYLESHEET@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -SUBDIRS = specs -xextdir = $(includedir)/X11/extensions -xext_HEADERS = \ - dpmsconst.h \ - dpmsproto.h \ - ge.h \ - geproto.h \ - lbx.h \ - lbxproto.h \ - mitmiscconst.h \ - mitmiscproto.h \ - multibufconst.h \ - multibufproto.h \ - secur.h \ - securproto.h \ - shapeconst.h \ - shapeproto.h \ - shm.h \ - shmproto.h \ - syncconst.h \ - syncproto.h \ - ag.h \ - agproto.h \ - cup.h \ - cupproto.h \ - dbe.h \ - dbeproto.h \ - EVI.h \ - EVIproto.h \ - xtestext1proto.h \ - xtestext1const.h \ - xtestconst.h \ - xtestproto.h - - -# -# These headers allow old servers to be built with -# new headers -# -compatdir = $(xextdir) -compat_HEADERS = \ - shapestr.h \ - shmstr.h \ - syncstr.h - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = xextproto.pc -MAINTAINERCLEANFILES = ChangeLog INSTALL -all: all-recursive - -.SUFFIXES: -am--refresh: - @: -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ - $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - echo ' $(SHELL) ./config.status'; \ - $(SHELL) ./config.status;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - $(am__cd) $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -$(am__aclocal_m4_deps): -xextproto.pc: $(top_builddir)/config.status $(srcdir)/xextproto.pc.in - cd $(top_builddir) && $(SHELL) ./config.status $@ -install-pkgconfigDATA: $(pkgconfig_DATA) - @$(NORMAL_INSTALL) - test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" - @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ - done - -uninstall-pkgconfigDATA: - @$(NORMAL_UNINSTALL) - @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files -install-compatHEADERS: $(compat_HEADERS) - @$(NORMAL_INSTALL) - test -z "$(compatdir)" || $(MKDIR_P) "$(DESTDIR)$(compatdir)" - @list='$(compat_HEADERS)'; test -n "$(compatdir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(compatdir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(compatdir)" || exit $$?; \ - done - -uninstall-compatHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(compat_HEADERS)'; test -n "$(compatdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(compatdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(compatdir)" && rm -f $$files -install-xextHEADERS: $(xext_HEADERS) - @$(NORMAL_INSTALL) - test -z "$(xextdir)" || $(MKDIR_P) "$(DESTDIR)$(xextdir)" - @list='$(xext_HEADERS)'; test -n "$(xextdir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(xextdir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(xextdir)" || exit $$?; \ - done - -uninstall-xextHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(xext_HEADERS)'; test -n "$(xextdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(xextdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(xextdir)" && rm -f $$files - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @fail= failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -$(RECURSIVE_CLEAN_TARGETS): - @fail= failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - $(am__remove_distdir) - test -d "$(distdir)" || mkdir "$(distdir)" - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$(top_distdir)" distdir="$(distdir)" \ - dist-hook - -test -n "$(am__skip_mode_fix)" \ - || find "$(distdir)" -type d ! -perm -755 \ - -exec chmod u+rwx,go+rx {} \; -o \ - ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ - || chmod -R a+r "$(distdir)" -dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) -dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) - -dist-lzma: distdir - tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma - $(am__remove_distdir) - -dist-xz: distdir - tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz - $(am__remove_distdir) - -dist-tarZ: distdir - tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__remove_distdir) - -dist-shar: distdir - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__remove_distdir) - -dist-zip: distdir - -rm -f $(distdir).zip - zip -rq $(distdir).zip $(distdir) - $(am__remove_distdir) - -dist dist-all: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) - -# This target untars the dist file and tries a VPATH configuration. Then -# it guarantees that the distribution is self-contained by making another -# tarfile. -distcheck: dist - case '$(DIST_ARCHIVES)' in \ - *.tar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ - *.tar.bz2*) \ - bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.lzma*) \ - lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ - *.tar.xz*) \ - xz -dc $(distdir).tar.xz | $(am__untar) ;;\ - *.tar.Z*) \ - uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ - *.shar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ - *.zip*) \ - unzip $(distdir).zip ;;\ - esac - chmod -R a-w $(distdir); chmod a+w $(distdir) - mkdir $(distdir)/_build - mkdir $(distdir)/_inst - chmod a-w $(distdir) - test -d $(distdir)/_build || exit 0; \ - dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ - && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ - && am__cwd=`pwd` \ - && $(am__cd) $(distdir)/_build \ - && ../configure --srcdir=.. --prefix="$$dc_install_base" \ - $(DISTCHECK_CONFIGURE_FLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ - && $(MAKE) $(AM_MAKEFLAGS) install \ - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ - && $(MAKE) $(AM_MAKEFLAGS) uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ - distuninstallcheck \ - && chmod -R a-w "$$dc_install_base" \ - && ({ \ - (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ - distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ - } || { rm -rf "$$dc_destdir"; exit 1; }) \ - && rm -rf "$$dc_destdir" \ - && $(MAKE) $(AM_MAKEFLAGS) dist \ - && rm -rf $(DIST_ARCHIVES) \ - && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ - && cd "$$am__cwd" \ - || exit 1 - $(am__remove_distdir) - @(echo "$(distdir) archives ready for distribution: "; \ - list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ - sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' -distuninstallcheck: - @$(am__cd) '$(distuninstallcheck_dir)' \ - && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ - || { echo "ERROR: files left after uninstall:" ; \ - if test -n "$(DESTDIR)"; then \ - echo " (check DESTDIR support)"; \ - fi ; \ - $(distuninstallcheck_listfiles) ; \ - exit 1; } >&2 -distcleancheck: distclean - @if test '$(srcdir)' = . ; then \ - echo "ERROR: distcleancheck can only run from a VPATH build" ; \ - exit 1 ; \ - fi - @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ - || { echo "ERROR: files left in build directory after distclean:" ; \ - $(distcleancheck_listfiles) ; \ - exit 1; } >&2 -check-am: all-am -check: check-recursive -all-am: Makefile $(DATA) $(HEADERS) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(compatdir)" "$(DESTDIR)$(xextdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." - -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) -clean: clean-recursive - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: install-compatHEADERS install-pkgconfigDATA \ - install-xextHEADERS - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf $(top_srcdir)/autom4te.cache - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-compatHEADERS uninstall-pkgconfigDATA \ - uninstall-xextHEADERS - -.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ - install-am install-strip tags-recursive - -.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ - all all-am am--refresh check check-am clean clean-generic \ - ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ - dist-hook dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ - distcheck distclean distclean-generic distclean-tags \ - distcleancheck distdir distuninstallcheck dvi dvi-am html \ - html-am info info-am install install-am install-compatHEADERS \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-pkgconfigDATA install-ps install-ps-am \ - install-strip install-xextHEADERS installcheck installcheck-am \ - installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ - pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ - uninstall-compatHEADERS uninstall-pkgconfigDATA \ - uninstall-xextHEADERS - - -.PHONY: ChangeLog INSTALL - -INSTALL: - $(INSTALL_CMD) - -ChangeLog: - $(CHANGELOG_CMD) - -dist-hook: ChangeLog INSTALL - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/X11/extensions/configure.ac b/X11/extensions/configure.ac index 92d49d9d7..dd30292e3 100644 --- a/X11/extensions/configure.ac +++ b/X11/extensions/configure.ac @@ -1,18 +1,18 @@ -AC_PREREQ([2.60]) -AC_INIT([XExtProto], [7.1.99.0], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg]) -AM_INIT_AUTOMAKE([foreign dist-bzip2]) -AM_MAINTAINER_MODE - -# Require xorg-macros minimum of 1.10 for DocBook XML documentation -m4_ifndef([XORG_MACROS_VERSION], - [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])]) -XORG_MACROS_VERSION(1.10) -XORG_DEFAULT_OPTIONS -XORG_ENABLE_SPECS -XORG_WITH_XMLTO(0.0.20) -XORG_WITH_FOP -XORG_CHECK_SGML_DOCTOOLS(1.5) - -AC_OUTPUT([Makefile - specs/Makefile - xextproto.pc]) +AC_PREREQ([2.60]) +AC_INIT([XExtProto], [7.2.0], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg]) +AM_INIT_AUTOMAKE([foreign dist-bzip2]) +AM_MAINTAINER_MODE + +# Require xorg-macros minimum of 1.10 for DocBook XML documentation +m4_ifndef([XORG_MACROS_VERSION], + [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])]) +XORG_MACROS_VERSION(1.10) +XORG_DEFAULT_OPTIONS +XORG_ENABLE_SPECS +XORG_WITH_XMLTO(0.0.20) +XORG_WITH_FOP +XORG_CHECK_SGML_DOCTOOLS(1.5) + +AC_OUTPUT([Makefile + specs/Makefile + xextproto.pc]) diff --git a/libX11/specs/i18n/localedb/localedb.xml b/libX11/specs/i18n/localedb/localedb.xml index e5b96ab84..c4f6d1377 100644 --- a/libX11/specs/i18n/localedb/localedb.xml +++ b/libX11/specs/i18n/localedb/localedb.xml @@ -1,777 +1,777 @@ - - - - - - - X Locale Database Specification - - - YoshioHoriuchi - IBM Japan - - - 1994IBM Corporation - 1994X Consortium - - - - - -License to use, copy, modify, and distribute this software and its documentation for -any purpose and without fee is hereby granted, provided that the above copyright notice -appear in all copies and that both that copyright notice and this permission notice -appear in supporting documentation, and that the name of IBM not be used in advertising -or publicity pertaining to distribution of the software without specific, written -prior permission. - - -IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED -WARRANTIES OF MERCHANTABILITY, FITNESS, AND NONINFRINGEMENT OF THIRD PARTY RIGHTS, -IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES -OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN -AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files -(the “Software”), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to permit -persons to whom the Software is furnished to do so, subject to the following -conditions: - - - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - - - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - - - -Except as contained in this notice, the name of The Open Group shall not -be used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from X Consortium. - - -X Window System is a trademark of The Open Group. - - - - - -LocaleDB - - -General - -An X Locale Database contains the subset of a user's environment that -depends on language, in X Window System. It is made up from one or more -categories. Each category consists of some classes and sub-classes. - - - -It is provided as a plain ASCII text file, so a user can change its -contents easily. It allows a user to customize the behavior of -internationalized portion of Xlib without changing Xlib itself. - - - -This document describes; - - - - - -Database Format Definition - - - - -Contents of Database in sample implementation - - - - - - -Since it is hard to define the set of required information for all -platforms, only the flexible database format is defined. -The available entries in database are implementation dependent. - - - - -Database Format Definition - -The X Locale Database contains one or more category definitions. -This section describes the format of each category definition. - - - -The category definition consists of one or more class definitions. -Each class definition has a pair of class name and class value, or -has several subclasses which are enclosed by the left brace ({) and -the right brace (}). - - - -Comments can be placed by using the number sign character (#). -Putting the number sign character on the top of the line indicates -that the entire line is comment. Also, putting any whitespace character -followed by the number sign character indicates that a part of the line -(from the number sign to the end of the line) is comment. -A line can be continued by placing backslash (\) character as the -last character on the line; this continuation character will be -discarded from the input. Comment lines cannot be continued on -a subsequent line using an escaped new line character. - - - -X Locale Database only accepts XPCS, the X Portable Character Set. -The reserved symbols are; the quotation mark("), the number sign (#), -the semicolon(;), the backslash(\), the left brace({) and -the right brace(}). - - - -The format of category definition is; - - - - - - - - - - CategoryDefinition - ::= - CategoryHeader CategorySpec CategoryTrailer - - - CategoryHeader - ::= - CategoryName NL - - - CategorySpec - ::= - { ClassSpec } - - - CategoryTrailer - ::= - "END" Delimiter CategoryName NL - - - CategoryName - ::= - String - - - ClassSpec - ::= - ClassName Delimiter ClassValue NL - - - ClassName - ::= - String - - - ClassValue - ::= - ValueList | "{" NL { ClassSpec } "}" - - - ValueList - ::= - Value | Value ";" ValueList - - - Value - ::= - ValuePiece | ValuePiece Value - - - ValuePiece - ::= - String | QuotedString | NumericString - - - String - ::= - Char { Char } - - - QuotedString - ::= - """ QuotedChar { QuotedChar } """ - - - NumericString - ::= - "\\o" OctDigit { OctDigit } - - - - | - "\\d" DecDigit { DecDigit } - - - - | - "\\x" HexDigit { HexDigit } - - - Char - ::= - <XPCS except NL, Space or unescaped reserved symbols> - - - QuotedChar - ::= - <XPCS except unescaped """> - - - OctDigit - ::= - <character in the range of "0" - "7"> - - - DecDigit - ::= - <character in the range of "0" - "9"> - - - HexDigit - ::= - <character in the range of "0" - "9", "a" - "f", "A" - "F"> - - - Delimiter - ::= - Space { Space } - - - Space - ::= - <space> | <horizontal tab> - - - NL - ::= - <newline> - - - - - - -Elements separated by vertical bar (|) are alternatives. Curly -braces ({...}) indicate zero or more repetitions of the enclosed -elements. Square brackets ([...]) indicate that the enclosed element -is optional. Quotes ("...") are used around literal characters. - - - -The backslash, which is not the top character of the NumericString, is -recognized as an escape character, so that the next one character is -treated as a literal character. For example, the two-character -sequence, ""\"""(the backslash followed by the quotation mark) is -recognized and replaced with a quotation mark character. -Any whitespace character, that is not the Delimiter, unquoted and -unescaped, is ignored. - - - - -Contents of Database - -The available categories and classes depend on implementation, because -different platform will require different information set. -For example, some platform have system locale but some platform don't. -Furthermore, there might be a difference in functionality even if the -platform has system locale. - - - -In current sample implementation, categories listed below are available. - - - - - - - - - XLC_FONTSET:XFontSet relative information - - - XLC_XLOCALE:Character classification and conversion information - - - - - - - -XLC_FONTSET Category - -The XLC_FONTSET category defines the XFontSet relative information. -It contains the CHARSET_REGISTRY-CHARSET_ENCODING name and character -mapping side (GL, GR, etc), and is used in Output Method (OM). - - - - - - - - - - class - super class - description - - - - - fsN - - Nth fontset (N=0,1,2, ...) - - - charset - fsN - list of encoding name - - - font - fsN - list of font encoding name - - - - - - - - fsN - - -Includes an encoding information for Nth charset, where N is -the index number (0,1,2,...). If there are 4 charsets available -in current locale, 4 fontsets, fs0, fs1, fs2 and fs3, should be -defined. -This class has two subclasses, 'charset' and 'font'. - - - - - charset - - -Specifies an encoding information to be used internally in Xlib -for this fontset. The format of value is; - - - - - - - - - EncodingInfo - ::= - EncodingName [ ":" EncodingSide ] - - - EncodingName - ::= - CHARSET_REGISTRY-CHARSET_ENCODING - - - EncodingSide - ::= - "GL" | "GR" - - - - - - -For detail definition of CHARSET_REGISTRY-CHARSET_ENCODING, refer -"X Logical Font Descriptions" document. - - -example: - ISO8859-1:GL - - - - - font - - -Specifies a list of encoding information which is used for searching -appropriate font for this fontset. The left most entry has highest -priority. - - - - - - - -XLC_XLOCALE Category - -The XLC_XLOCALE category defines character classification, conversion -and other character attributes. - - - - - - - - - - class - super class - description - - - - - encoding_name - - codeset name - - - mb_cur_max - - MB_CUR_MAX - - - state_depend_encoding - - state dependent or not - - - wc_encoding_mask - - for parsing wc string - - - wc_shift_bits - - for conversion between wc and mb - - - csN - - Nth charset (N=0,1,2,...) - - - side - csN - mapping side (GL, etc) - - - length - csN - length of a character - - - mb_encoding - csN - for parsing mb string - - - wc_encoding - csN - for parsing wc string - - - ct_encoding - csN - list of encoding name for ct - - - - - - - - encoding_name - - -Specifies a codeset name of current locale. - - - - - mb_cur_max - - -Specifies a maximum allowable number of bytes in a multi-byte character. -It is corresponding to MB_CUR_MAX of "ISO/IEC 9899:1990 C Language Standard". - - - - - state_depend_encoding - - -Indicates a current locale is state dependent. The value should be -specified "True" or "False". - - - - - wc_encoding_mask - - -Specifies a bit-mask for parsing wide-char string. Each wide character is -applied bit-and operation with this bit-mask, then is classified into -the unique charset, by using 'wc_encoding'. - - - - - wc_shift_bits - - -Specifies a number of bit to be shifted for converting from a multi-byte -character to a wide character, and vice-versa. - - - - - csN - - - -Includes a character set information for Nth charset, where N is the -index number (0,1,2,...). If there are 4 charsets available in current -locale, cs0, cs1, cs2 and cs3 should be defined. This class has five -subclasses, 'side', 'length', 'mb_encoding' 'wc_encoding' and 'ct_encoding'. - - - - - side - - -Specifies a mapping side of this charset. The format of this value is; - - - Side ::= EncodingSide[":Default"] - - -The suffix ":Default" can be specified. It indicates that a character -belongs to the specified side is mapped to this charset in initial state. - - - - - length - - - -Specifies a number of bytes of a multi-byte character of this charset. -It should not contain the length of any single-shift sequence. - - - - - mb_encoding - - -Specifies a list of shift sequence for parsing multi-byte string. -The format of this value is; - - - - - - - - - MBEncoding - ::= - ShiftType ShiftSequence - - - - | - ShiftType ShiftSequence ";" MBEncoding - - - ShiftType - ::= - "<SS>"|"<LSL>"|"<LSR>" - - - ShiftSequence - ::= - SequenceValue|SequenceValue ShiftSequence - - - SequenceValue - ::= - NumericString - - - - - - -example: - <LSL> \x1b \x28 \x4a; <LSL> \x1b \x28 \x42 - - - - - wc_encoding - - -Specifies an integer value for parsing wide-char string. -It is used to determine the charset for each wide character, after -applying bit-and operation using 'wc_encoding_mask'. -This value should be unique in all csN classes. - - - - - ct_encoding - - -Specifies a list of encoding information that can be used for Compound -Text. - - - - - - - -Sample of X Locale Database - -The following is sample X Locale Database file. - - - -# XLocale Database Sample for ja_JP.euc -# - -# -# XLC_FONTSET category -# -XLC_FONTSET -# fs0 class (7 bit ASCII) -fs0 { - charset ISO8859-1:GL - font ISO8859-1:GL; JISX0201.1976-0:GL -} -# fs1 class (Kanji) -fs1 { - charset JISX0208.1983-0:GL - font JISX0208.1983-0:GL -} -# fs2 class (Half Kana) -fs2 { - charset JISX0201.1976-0:GR - font JISX0201.1976-0:GR -} -# fs3 class (User Defined Character) -# fs3 { -# charset JISX0212.1990-0:GL -# font JISX0212.1990-0:GL -# } -END XLC_FONTSET - -# -# XLC_XLOCALE category -# -XLC_XLOCALE - -encoding_name ja.euc -mb_cur_max 3 -state_depend_encoding False - -wc_encoding_mask \x00008080 -wc_shift_bits 8 - -# cs0 class -cs0 { - side GL:Default - length 1 - wc_encoding \x00000000 - ct_encoding ISO8859-1:GL; JISX0201.1976-0:GL -} -# cs1 class -cs1 { - side GR:Default - length 2 - - wc_encoding \x00008080 - - ct_encoding JISX0208.1983-0:GL; JISX0208.1983-0:GR;\ - JISX0208.1983-1:GL; JISX0208.1983-1:GR -} - -# cs2 class -cs2 { - side GR - length 1 - mb_encoding <SS> \x8e - - wc_encoding \x00000080 - - ct_encoding JISX0201.1976-0:GR -} - -# cs3 class -# cs3 { -# side GL -# length 2 -# mb_encoding <SS> \x8f -# #if HasWChar32 -# wc_encoding \x20000000 -# #else -# wc_encoding \x00008000 -# #endif -# ct_encoding JISX0212.1990-0:GL; JISX0212.1990-0:GR -# } - -END XLC_XLOCALE - - - - -Reference - -[1] ISO/IEC 9899:1990 C Language Standard - - -[2] X Logical Font Descriptions - - - - - + + + + + + + X Locale Database Specification + + + YoshioHoriuchi + IBM Japan + + + 1994IBM Corporation + 1994X Consortium + + + + + +License to use, copy, modify, and distribute this software and its documentation for +any purpose and without fee is hereby granted, provided that the above copyright notice +appear in all copies and that both that copyright notice and this permission notice +appear in supporting documentation, and that the name of IBM not be used in advertising +or publicity pertaining to distribution of the software without specific, written +prior permission. + + +IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY, FITNESS, AND NONINFRINGEMENT OF THIRD PARTY RIGHTS, +IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES +OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN +AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files +(the “Software”), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the following +conditions: + + + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + + + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + + +Except as contained in this notice, the name of The Open Group shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from X Consortium. + + +X Window System is a trademark of The Open Group. + + + + + +LocaleDB + + +General + +An X Locale Database contains the subset of a user's environment that +depends on language, in X Window System. It is made up from one or more +categories. Each category consists of some classes and sub-classes. + + + +It is provided as a plain ASCII text file, so a user can change its +contents easily. It allows a user to customize the behavior of +internationalized portion of Xlib without changing Xlib itself. + + + +This document describes; + + + + + +Database Format Definition + + + + +Contents of Database in sample implementation + + + + + + +Since it is hard to define the set of required information for all +platforms, only the flexible database format is defined. +The available entries in database are implementation dependent. + + + + +Database Format Definition + +The X Locale Database contains one or more category definitions. +This section describes the format of each category definition. + + + +The category definition consists of one or more class definitions. +Each class definition has a pair of class name and class value, or +has several subclasses which are enclosed by the left brace ({) and +the right brace (}). + + + +Comments can be placed by using the number sign character (#). +Putting the number sign character on the top of the line indicates +that the entire line is comment. Also, putting any whitespace character +followed by the number sign character indicates that a part of the line +(from the number sign to the end of the line) is comment. +A line can be continued by placing backslash (\) character as the +last character on the line; this continuation character will be +discarded from the input. Comment lines cannot be continued on +a subsequent line using an escaped new line character. + + + +X Locale Database only accepts XPCS, the X Portable Character Set. +The reserved symbols are; the quotation mark("), the number sign (#), +the semicolon(;), the backslash(\), the left brace({) and +the right brace(}). + + + +The format of category definition is; + + + + + + + + + + CategoryDefinition + ::= + CategoryHeader CategorySpec CategoryTrailer + + + CategoryHeader + ::= + CategoryName NL + + + CategorySpec + ::= + { ClassSpec } + + + CategoryTrailer + ::= + "END" Delimiter CategoryName NL + + + CategoryName + ::= + String + + + ClassSpec + ::= + ClassName Delimiter ClassValue NL + + + ClassName + ::= + String + + + ClassValue + ::= + ValueList | "{" NL { ClassSpec } "}" + + + ValueList + ::= + Value | Value ";" ValueList + + + Value + ::= + ValuePiece | ValuePiece Value + + + ValuePiece + ::= + String | QuotedString | NumericString + + + String + ::= + Char { Char } + + + QuotedString + ::= + """ QuotedChar { QuotedChar } """ + + + NumericString + ::= + "\\o" OctDigit { OctDigit } + + + + | + "\\d" DecDigit { DecDigit } + + + + | + "\\x" HexDigit { HexDigit } + + + Char + ::= + <XPCS except NL, Space or unescaped reserved symbols> + + + QuotedChar + ::= + <XPCS except unescaped """> + + + OctDigit + ::= + <character in the range of "0" - "7"> + + + DecDigit + ::= + <character in the range of "0" - "9"> + + + HexDigit + ::= + <character in the range of "0" - "9", "a" - "f", "A" - "F"> + + + Delimiter + ::= + Space { Space } + + + Space + ::= + <space> | <horizontal tab> + + + NL + ::= + <newline> + + + + + + +Elements separated by vertical bar (|) are alternatives. Curly +braces ({...}) indicate zero or more repetitions of the enclosed +elements. Square brackets ([...]) indicate that the enclosed element +is optional. Quotes ("...") are used around literal characters. + + + +The backslash, which is not the top character of the NumericString, is +recognized as an escape character, so that the next one character is +treated as a literal character. For example, the two-character +sequence, ""\"""(the backslash followed by the quotation mark) is +recognized and replaced with a quotation mark character. +Any whitespace character, that is not the Delimiter, unquoted and +unescaped, is ignored. + + + + +Contents of Database + +The available categories and classes depend on implementation, because +different platform will require different information set. +For example, some platform have system locale but some platform don't. +Furthermore, there might be a difference in functionality even if the +platform has system locale. + + + +In current sample implementation, categories listed below are available. + + + + + + + + + XLC_FONTSET:XFontSet relative information + + + XLC_XLOCALE:Character classification and conversion information + + + + + + + +XLC_FONTSET Category + +The XLC_FONTSET category defines the XFontSet relative information. +It contains the CHARSET_REGISTRY-CHARSET_ENCODING name and character +mapping side (GL, GR, etc), and is used in Output Method (OM). + + + + + + + + + + class + super class + description + + + + + fsN + + Nth fontset (N=0,1,2, ...) + + + charset + fsN + list of encoding name + + + font + fsN + list of font encoding name + + + + + + + + fsN + + +Includes an encoding information for Nth charset, where N is +the index number (0,1,2,...). If there are 4 charsets available +in current locale, 4 fontsets, fs0, fs1, fs2 and fs3, should be +defined. +This class has two subclasses, 'charset' and 'font'. + + + + + charset + + +Specifies an encoding information to be used internally in Xlib +for this fontset. The format of value is; + + + + + + + + + EncodingInfo + ::= + EncodingName [ ":" EncodingSide ] + + + EncodingName + ::= + CHARSET_REGISTRY-CHARSET_ENCODING + + + EncodingSide + ::= + "GL" | "GR" + + + + + + +For detail definition of CHARSET_REGISTRY-CHARSET_ENCODING, refer +"X Logical Font Descriptions" document. + + +example: + ISO8859-1:GL + + + + + font + + +Specifies a list of encoding information which is used for searching +appropriate font for this fontset. The left most entry has highest +priority. + + + + + + + +XLC_XLOCALE Category + +The XLC_XLOCALE category defines character classification, conversion +and other character attributes. + + + + + + + + + + class + super class + description + + + + + encoding_name + + codeset name + + + mb_cur_max + + MB_CUR_MAX + + + state_depend_encoding + + state dependent or not + + + wc_encoding_mask + + for parsing wc string + + + wc_shift_bits + + for conversion between wc and mb + + + csN + + Nth charset (N=0,1,2,...) + + + side + csN + mapping side (GL, etc) + + + length + csN + length of a character + + + mb_encoding + csN + for parsing mb string + + + wc_encoding + csN + for parsing wc string + + + ct_encoding + csN + list of encoding name for ct + + + + + + + + encoding_name + + +Specifies a codeset name of current locale. + + + + + mb_cur_max + + +Specifies a maximum allowable number of bytes in a multi-byte character. +It is corresponding to MB_CUR_MAX of "ISO/IEC 9899:1990 C Language Standard". + + + + + state_depend_encoding + + +Indicates a current locale is state dependent. The value should be +specified "True" or "False". + + + + + wc_encoding_mask + + +Specifies a bit-mask for parsing wide-char string. Each wide character is +applied bit-and operation with this bit-mask, then is classified into +the unique charset, by using 'wc_encoding'. + + + + + wc_shift_bits + + +Specifies a number of bit to be shifted for converting from a multi-byte +character to a wide character, and vice-versa. + + + + + csN + + + +Includes a character set information for Nth charset, where N is the +index number (0,1,2,...). If there are 4 charsets available in current +locale, cs0, cs1, cs2 and cs3 should be defined. This class has five +subclasses, 'side', 'length', 'mb_encoding' 'wc_encoding' and 'ct_encoding'. + + + + + side + + +Specifies a mapping side of this charset. The format of this value is; + + + Side ::= EncodingSide[":Default"] + + +The suffix ":Default" can be specified. It indicates that a character +belongs to the specified side is mapped to this charset in initial state. + + + + + length + + + +Specifies a number of bytes of a multi-byte character of this charset. +It should not contain the length of any single-shift sequence. + + + + + mb_encoding + + +Specifies a list of shift sequence for parsing multi-byte string. +The format of this value is; + + + + + + + + + MBEncoding + ::= + ShiftType ShiftSequence + + + + | + ShiftType ShiftSequence ";" MBEncoding + + + ShiftType + ::= + "<SS>"|"<LSL>"|"<LSR>" + + + ShiftSequence + ::= + SequenceValue|SequenceValue ShiftSequence + + + SequenceValue + ::= + NumericString + + + + + + +example: + <LSL> \x1b \x28 \x4a; <LSL> \x1b \x28 \x42 + + + + + wc_encoding + + +Specifies an integer value for parsing wide-char string. +It is used to determine the charset for each wide character, after +applying bit-and operation using 'wc_encoding_mask'. +This value should be unique in all csN classes. + + + + + ct_encoding + + +Specifies a list of encoding information that can be used for Compound +Text. + + + + + + + +Sample of X Locale Database + +The following is sample X Locale Database file. + + + +# XLocale Database Sample for ja_JP.euc +# + +# +# XLC_FONTSET category +# +XLC_FONTSET +# fs0 class (7 bit ASCII) +fs0 { + charset ISO8859-1:GL + font ISO8859-1:GL; JISX0201.1976-0:GL +} +# fs1 class (Kanji) +fs1 { + charset JISX0208.1983-0:GL + font JISX0208.1983-0:GL +} +# fs2 class (Half Kana) +fs2 { + charset JISX0201.1976-0:GR + font JISX0201.1976-0:GR +} +# fs3 class (User Defined Character) +# fs3 { +# charset JISX0212.1990-0:GL +# font JISX0212.1990-0:GL +# } +END XLC_FONTSET + +# +# XLC_XLOCALE category +# +XLC_XLOCALE + +encoding_name ja.euc +mb_cur_max 3 +state_depend_encoding False + +wc_encoding_mask \x00008080 +wc_shift_bits 8 + +# cs0 class +cs0 { + side GL:Default + length 1 + wc_encoding \x00000000 + ct_encoding ISO8859-1:GL; JISX0201.1976-0:GL +} +# cs1 class +cs1 { + side GR:Default + length 2 + + wc_encoding \x00008080 + + ct_encoding JISX0208.1983-0:GL; JISX0208.1983-0:GR;\ + JISX0208.1983-1:GL; JISX0208.1983-1:GR +} + +# cs2 class +cs2 { + side GR + length 1 + mb_encoding <SS> \x8e + + wc_encoding \x00000080 + + ct_encoding JISX0201.1976-0:GR +} + +# cs3 class +# cs3 { +# side GL +# length 2 +# mb_encoding <SS> \x8f +# #if HasWChar32 +# wc_encoding \x20000000 +# #else +# wc_encoding \x00008000 +# #endif +# ct_encoding JISX0212.1990-0:GL; JISX0212.1990-0:GR +# } + +END XLC_XLOCALE + + + + +Reference + +[1] ISO/IEC 9899:1990 C Language Standard + + +[2] X Logical Font Descriptions + + + + + diff --git a/libX11/specs/i18n/trans/trans.xml b/libX11/specs/i18n/trans/trans.xml index 9a01d97f6..c8447f934 100644 --- a/libX11/specs/i18n/trans/trans.xml +++ b/libX11/specs/i18n/trans/trans.xml @@ -1,1979 +1,1979 @@ - - - - - - - The XIM Transport Specification - Revision 0.1 - X Version 11, Release 7 - - - TakashiFujiwara - FUJITSU LIMITED - - - 1994FUJITSU LIMITED - 1994X Consortium - - Revision 0.1 - - - - -This specification describes the transport layer interfaces between Xlib and IM Server, -which makes various channels usable such as X protocol or TCP/IP, DECnet and etc. - - - - - - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files -(the “Software”), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to permit -persons to whom the Software is furnished to do so, subject to the following -conditions: - - - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - - - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - - - -Except as contained in this notice, the name of The Open Group shall not -be used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from X Consortium. - - -X Window System is a trademark of The Open Group. - - - - - -X Transport Specification - - -Introduction - - - - - -The Xlib XIM implementation is layered into three functions, a protocol -layer, an interface layer and a transport layer. The purpose of this -layering is to make the protocol independent of transport implementation. -Each function of these layers are: - - - - - The protocol layer - - -implements overall function of XIM and calls the interface layer -functions when it needs to communicate to IM Server. - - - - - The interface layer - - -separates the implementation of the transport layer from the protocol -layer, in other words, it provides implementation independent hook for -the transport layer functions. - - - - - - The transport layer - - -handles actual data communication with IM Server. It is done by a set -of several functions named transporters. - - - - - - -This specification describes the interface layer and the transport -layer, which makes various communication channels usable such as -X protocol or, TCP/IP, DECnet, STREAM, etc., and provides -the information needed for adding another new transport layer. -In addition, sample implementations for the transporter using the -X connection is described in section 4. - - - - -Initialization - - -Registering structure to initialize - - -The structure typed as TransportSW contains the list of the transport -layer the specific implementations supports. - - - -typedef struct { - char *transport_name; - Bool (*config); -} TransportSW; - - - - - - - - - transport_name - name of transportRefer to "The Input Method Protocol: Appendix B - - - config - initial configuration function - - - - - - -A sample entry for the Xlib supporting transporters is shown below: - - - -TransportSW _XimTransportRec[] = { -/* char *: - * transport_name, Bool (*config)() - */ - "X", _XimXConf, - "tcp", _XimTransConf, - "local", _XimTransConf, - "decnet", _XimTransConf, - "streams", _XimTransConf, - (char *)NULL, (Bool (*)())NULL, -}; - - - - -Initialization function - - - - -The following function will be called once when Xlib configures the -transporter functions. - - - - - Bool (*config) - XIM im - char *transport_data - - - - - - - im - - - -Specifies XIM structure address. - - - - - - transport_data - - - -Specifies the data specific to the transporter, in IM Server address.Refer to "The Input Method Protocol: Appendix B - - - - - - -This function must setup the transporter function pointers. - - - - -The actual config function will be chosen by IM Server at the -pre-connection time, matching by the transport_name specified -in the _XimTransportRec array; The specific members of XimProto -structure listed below must be initialized so that point they -appropriate transporter functions. - - - -If the specified transporter has been configured successfully, this -function returns True. There is no Alternative Entry for config -function itself. - - - -The structure XimProto contains the following function pointers: - - - -Bool (*connect)(); /* Open connection */ -Bool (*shutdown)(); /* Close connection */ -Bool (*write)(); /* Write data */ -Bool (*read)(); /* Read data */ -Bool (*flush)(); /* Flush data buffer */ -Bool (*register_dispatcher)(); /* Register asynchronous data handler */ -Bool (*call_dispatcher)(); /* Call dispatcher */ - - - -These functions are called when Xlib needs to communicate the -IM Server. These functions must process the appropriate procedure -described below. - - - - - -The interface/transport layer functions - -Following functions are used for the transport interface. - - - - The Transport Layer Functions - - - - - - - Alternate Entry (Interface Layer) - XimProto member (Transport Layer) - Section - - - - - _XimConnect - connect - 3.1 - - - _XimShutdown - shutdown - 3.2 - - - _XimWrite - write - 3.3 - - - _XimRead - read - 3.4 - - - _XimFlush - flush - 3.5 - - - _XimRegisterDispatcher - register_dispatcher - 3.6 - - - _XimCallDispatcher - call_dispatcher - 3.7 - - - -
- - -The Protocol layer calls the above functions using the Alternative -Entry in the left column. The transport implementation defines -XimProto member function in the right column. The Alternative Entry is -provided so as to make easier to implement the Protocol Layer. - - - -Opening connection - - -When XOpenIM is called, the following function is called to connect -with the IM Server. - - - - - Bool (*connect) - XIM im - - - - - - - im - - - -Specifies XIM structure address. - - - - - - -This function must establishes the connection to the IM Server. If the -connection is established successfully, this function returns True. -The Alternative Entry for this function is: - - - - - Bool _XimConnect - XIM im - - - - - - - im - - - -Specifies XIM structure address. - - - - - - - -Closing connection - - - - - -When XCloseIM is called, the following function is called to -disconnect the connection with the IM Server. The Alternative Entry -for this function is: - - - - - Bool (*shutdown) - XIM im - - - - - - - im - - - -Specifies XIM structure address. - - - - - - - -This function must close connection with the IM Server. If the -connection is closed successfully, this function returns True. The -Alternative Entry for this function is: - - - - - Bool _XimShutdown - XIM im - - - - - - - im - - - -Specifies XIM structure address. - - - - - - - - -Writing data - -The following function is called, when Xlib needs to write data to the -IM Server. - - - - - Bool _XimWrite - XIM im - INT16 len - XPointer data - - - - - - - im - - - -Specifies XIM structure address. - - - - - - len - - - -Specifies the length of writing data. - - - - - - data - - - -Specifies the writing data. - - - - - - -This function writes the data to the IM Server, regardless -of the contents. The number of bytes is passed to len. The -writing data is passed to data. If data is sent successfully, -the function returns True. Refer to "The Input Method Protocol" for -the contents of the writing data. The Alternative Entry for this -function is: - - - - - Bool _XimWrite - XIM im - INT16 len - XPointer data - - - - - - - im - - - -Specifies XIM structure address. - - - - - - len - - - -Specifies the length of writing data. - - - - - - data - - - -Specifies the writing data. - - - - - - - -Reading data - -The following function is called when Xlib waits for response from IM -server synchronously. - - - - - Bool _XimRead - XIM im - XPointer read_buf - int buf_len - int *ret_len - - - - - - - im - - - -Specifies XIM structure address. - - - - - - read_buf - - - -Specifies the buffer to store data. - - - - - - buf_len - - - -Specifies the size of the buffer - - - - - - ret_len - - - -Specifies the length of stored data. - - - - - - -This function stores the read data in read_buf, which size is -specified as buf_len. The size of data is set to ret_len. -This function return True, if the data is read normally or reading -data is completed. - - -The Alternative Entry for this function is: - - - - - Bool _XimRead - XIM im - INT16 *ret_len - XPointer buf - int buf_len - Bool (*predicate)() - XPointer predicate_arg - - - - - - - im - - - -Specifies XIM structure address. - - - - - - ret_len - - - -Specifies the size of the data buffer. - - - - - - buf - - - -Specifies the buffer to store data. - - - - - - buf_len - - - -Specifies the length of buffer. - - - - - - predicate - - - -Specifies the predicate for the XIM data. - - - - - - predicate_arg - - - -Specifies the predicate specific data. - - - - - - - -The predicate procedure indicates whether the data is for the -XIM or not. len -This function stores the read data in buf, which size -is specified as buf_len. The size of data is set to -ret_len. If preedicate() -returns True, this function returns True. If not, it calls the registered callback function. - - - -The procedure and its arguments are: - - - - - - void (*predicate) - XIM im - INT16 len - XPointer data - XPointer predicate_arg - - - - - - - im - - - -Specifies XIM structure address. - - - - - - len - - - -Specifies the size of the data buffer. - - - - - - data - - - -Specifies the buffer to store data. - - - - - - predicate_arg - - - -Specifies the predicate specific data. - - - - - - - -Flushing buffer - -The following function is called when Xlib needs to flush the data. - - - - - void (*flush) - XIM im - - - - - - - im - - - -Specifies XIM structure address. - - - - - - -This function must flush the data stored in internal buffer on the -transport layer. If data transfer is completed, the function returns -True. The Alternative Entry for this function is: - - - - - void _XimFlush - XIM im - - - - - - - im - - - -Specifies XIM structure address. - - - - - - - -Registering asynchronous data handler - -Xlib needs to handle asynchronous response from IM Server. This is -because some of the XIM data occur asynchronously to X events. - - - -Those data will be handled in the Filter, -and the Filter -will call asynchronous data handler in the protocol layer. Then it -calls dispatchers in the transport layer. The dispatchers are -implemented by the protocol layer. This function must store the -information and prepare for later call of the dispatchers using -_XimCallDispatcher. - - - -When multiple dispatchers are registered, they will be called -sequentially in order of registration, on arrival of asynchronous -data. The register_dispatcher is declared as following: - - - - - Bool (*register_dispatcher) - XIM im - Bool (*dispatcher)() - XPointer call_data - - - - - - - im - - - -Specifies XIM structure address. - - - - - - dispatcher - - - -Specifies the dispatcher function to register. - - - - - - call_data - - - -Specifies a parameter for the dispatcher. - - - - - - -The dispatcher is a function of the following type: - - - - - Bool (*dispatcher) - XIM im - INT16 len - XPointer data - XPointer call_data - - - - - - - im - - - -Specifies XIM structure address. - - - - - - len - - - -Specifies the size of the data buffer. - - - - - - data - - - -Specifies the buffer to store data. - - - - - - call_data - - - -Specifies a parameter passed to the register_dispatcher. - - - - - - -The dispatcher is provided by the protocol layer. They are called once -for every asynchronous data, in order of registration. If the data is -used, it must return True. otherwise, it must return False. - - - -If the dispatcher function returns True, the Transport Layer assume -that the data has been processed by the upper layer. The Alternative -Entry for this function is: - - - - - Bool _XimRegisterDispatcher - XIM im - Bool (*dispatcher)() - XPointer call_data - - - - - - - im - - - -Specifies XIM structure address. - - - - - - dispatcher - - - -Specifies the dispatcher function to register. - - - - - - call_data - - - -Specifies a parameter for the dispatcher. - - - - - - - -Calling dispatcher - -The following function is used to call the registered dispatcher -function, when the asynchronous response from IM Server has arrived. - - - - - Bool (*call_dispatcher) - XIM im - INT16 len - XPointer data - - - - - - - im - - - -Specifies XIM structure address. - - - - - - len - - - -Specifies the size of data buffer. - - - - - - data - - - -Specifies the buffer to store data. - - - - - - -The call_dispatcher must call the dispatcher function, in order of -their registration. len and data are the data passed to -register_dispatcher. - - - -The return values are checked at each invocation, and if it finds -True, it immediately return with true for its return value. - - - -It is depend on the upper layer whether the read data is XIM -Protocol packet unit or not. -The Alternative Entry for this function is: - - - - - Bool _XimCallDispatcher - XIM im - INT16 len - XPointer call_data - - - - -
- -Sample implementations for the Transport Layer - -Sample implementations for the transporter using the X connection is -described here. - - - -X Transport - -At the beginning of the X Transport connection for the XIM transport -mechanism, two different windows must be created either in an Xlib XIM -or in an IM Server, with which the Xlib and the IM Server exchange the -XIM transports by using the ClientMessage events and Window Properties. -In the following, the window created by the Xlib is referred as the -"client communication window", and on the other hand, the window created -by the IM Server is referred as the "IMS communication window". - - - -Connection - -In order to establish a connection, a communication window is created. -A ClientMessage in the following event's format is sent to the owner -window of XIM_SERVER selection, which the IM Server has created. - - - - -Refer to "The Input Method Protocol" for the XIM_SERVER atom. - - - - The ClientMessage sent to the IMS window. - - - - - - - - Structure Member - Contents - - - - - int - type - ClientMessage - - - u_long - serial - Set by the X Window System - - - Bool - send_event - Set by the X Window System - - - Display - *display - The display to which connects - - - Window - window - IMS Window ID - - - Atom - message_type - XInternAtom(display, "_XIM_CONNECT", false) - - - int - format - 32 - - - long - data.1[0] - client communication window ID - - - long - data.1[1] - client-major-transport-version(*1) - - - long - data.1[2] - client-major-transport-version(*1) - - - -
- - -In order to establish the connection (to notify the IM Server communication -window), the IM Server sends a ClientMessage in the following event's -format to the client communication window. - - - - The ClientMessage sent by IM Server. - - - - - - - - Structure Member - Contents - - - - - int - type - ClientMessage - - - u_long - serial - Set by the X Window System - - - Bool - send_event - Set by the X Window System - - - Display - *display - The display to which connects - - - Window - window - IMS Window ID - - - Atom - message_type - XInternAtom(display, "_XIM_CONNECT", false) - - - int - format - 32 - - - long - data.1[0] - client communication window ID - - - long - data.1[1] - client-major-transport-version(*1) - - - long - data.1[2] - client-major-transport-version(*1) - - - long - data.1[3] - dividing size between ClientMessage and Property(*2) - - - -
- - -(*1) major/minor-transport-version - - - -The read/write method is decided by the combination of -major/minor-transport-version, as follows: - - - -The read/write method and the major/minor-transport-version - - - - - - - - Transport-version - read/write - - - major - minor - - - - - - 0 - 0 - only-CM & Property-with-CM - - - 1 - only-CM & multi-CM - - - 2 - only-CM & multi-CM & Property-with-CM - - - 1 - 0 - PropertyNotify - - - 2 - 0 - only-CM & PropertyNotify - - - 1 - only-CM & multi-CM & PropertyNotify - - - -
- - -only-CM : data is sent via a ClientMessage -multi-CM : data is sent via multiple ClientMessages -Property-with-CM : data is written in Property, and its Atom - is send via ClientMessage -PropertyNotify : data is written in Property, and its Atom - is send via PropertyNotify - - - - - -The method to decide major/minor-transport-version is as follows: - - - - - -The client sends 0 as major/minor-transport-version to the IM Server. -The client must support all methods in Table 4-3. -The client may send another number as major/minor-transport-version to -use other method than the above in the future. - - - - -The IM Server sends its major/minor-transport-version number to -the client. The client sends data using the method specified by the -IM Server. - - - - -If major/minor-transport-version number is not available, it is regarded -as 0. - - - - - -(*2) dividing size between ClientMessage and Property - - - -If data is sent via both of multi-CM and Property, specify the dividing -size between ClientMessage and Property. The data, which is smaller than -this size, is sent via multi-CM (or only-CM), and the data, which is -lager than this size, is sent via Property. - - -
- - -read/write - -The data is transferred via either ClientMessage or Window Property in -the X Window System. - - - -Format for the data from the Client to the IM Server - -ClientMessage - - - -If data is sent via ClientMessage event, the format is as follows: - - - - The ClientMessage event's format (first or middle) - - - - - - - - Structure Member - Contents - - - - - int - type - ClientMessage - - - u_long - serial - Set by the X Window System - - - Bool - send_event - Set by the X Window System - - - Display - *display - The display to which connects - - - Window - window - IMS Window ID - - - Atom - message_type - XInternAtom(display, "_XIM_MOREDATA", False) - - - int - format - 8 - - - char - data.b[20] - (read/write DATA : 20 byte) - - - -
- - - - - The ClientMessage event's format (only or last) - - - - - - - - Structure Member - Contents - - - - - int - type - ClientMessage - - - u_long - serial - Set by the X Window System - - - Bool - send_event - Set by the X Window System - - - Display - *display - The display to which connects - - - Window - window - IMS Window ID - - - Atom - message_type - XInternAtom(display, "_XIM_PROTOCOL", False) - - - int - format - 8 - - - char - data.b[20] - (read/write DATA : MAX 20 byte) -If the data is smaller -than 20 bytes, all data other than available data must be 0. - - - - - -
- - -Property - - - -In the case of large data, data will be sent via the Window Property -for the efficiency. There are the following two methods to notify -Property, and transport-version is decided which method is used. - - - - - -The XChangeProperty function is used to store data in the client -communication window, and Atom of the stored data is notified to the -IM Server via ClientMessage event. - - - - -The XChangeProperty function is used to store data in the client -communication window, and Atom of the stored data is notified to the -IM Server via PropertyNotify event. - - - - - -The arguments of the XChangeProperty are as follows: - - - - - The XChangeProperty event's format - - - - - - - - Argument - Contents - - - - - Display - *display - The display to which connects - - - Window - window - IMS communication window ID - - - Atom - property - read/write property Atom (*1) - - - int - format - 8 - - - int - mode - PropModeAppend - - - u_char - *data - read/write DATA - - - int - nelements - length of DATA - - - -
- - -(*1) The read/write property ATOM allocates the following strings by -XInternAtom. -"_clientXXX" - - - -The client changes the property with the mode of PropModeAppend and -the IM Server will read it with the delete mode i.e. (delete = True). - - - -If Atom is notified via ClientMessage event, the format of the ClientMessage -is as follows: - - - - The ClientMessage event's format to send Atom of property - - - - - - - - Structure Member - Contents - - - - - int - type - ClientMessage - - - u_long - serial - Set by the X Window System - - - Bool - send_event - Set by the X Window System - - - Display - *display - The display to which connects - - - Window - window - IMS Window ID - - - Atom - message_type - XInternAtom(display, "_XIM_PROTOCOL", False) - - - int - format - 8 - - - long - data.1[0] - length of read/write property Atom - - - long - data.1[1] - read/write property Atom - - - -
-
- - -Format for the data from the IM Server to the Client - -ClientMessage - - - -The format of the ClientMessage is as follows: - - - - The ClientMessage event's format (first or middle) - - - - - - - - Structure Member - Contents - - - - - int - type - ClientMessage - - - u_long - serial - Set by the X Window System - - - Bool - send_event - Set by the X Window System - - - Display - *display - The display to which connects - - - Window - window - IMS Window ID - - - Atom - message_type - XInternAtom(display, "_XIM_MOREDATA", False) - - - int - format - 8 - - - char - data.b[20] - (read/write DATA : 20 byte) - - - -
- - - - - - - The ClientMessage event's format (only or last) - - - - - - - - Structure Member - Contents - - - - - int - type - ClientMessage - - - u_long - serial - Set by the X Window System - - - Bool - send_event - Set by the X Window System - - - Display - *display - The display to which connects - - - Window - window - IMS Window ID - - - Atom - message_type - XInternAtom(display, "_XIM_PROTOCOL", False) - - - int - format - 8 - - - char - data.b[20] - (read/write DATA : MAX 20 byte) (*1) - - - -
- - -(*1) If the data size is smaller than 20 bytes, all data other than available -data must be 0. - - - -Property - - - -In the case of large data, data will be sent via the Window Property -for the efficiency. There are the following two methods to notify -Property, and transport-version is decided which method is used. - - - - - -The XChangeProperty function is used to store data in the IMS -communication window, and Atom of the property is sent via the -ClientMessage event. - - - - -The XChangeProperty function is used to store data in the IMS -communication window, and Atom of the property is sent via -PropertyNotify event. - - - - - -The arguments of the XChangeProperty are as follows: - - - - The XChangeProperty event's format - - - - - - - - Argument - Contents - - - - - Display - *display - The display to which connects - - - Window - window - IMS communication window ID - - - Atom - property - read/write property Atom (*1) - - - int - format - 8 - - - int - mode - PropModeAppend - - - u_char - *data - read/write DATA - - - int - nelements - length of DATA - - - -
- - -(*1) The read/write property ATOM allocates some strings, which are not -allocated by the client, by XInternAtom. - - - -The IM Server changes the property with the mode of PropModeAppend and -the client reads it with the delete mode, i.e. (delete = True). - - - -If Atom is notified via ClientMessage event, the format of the ClientMessage -is as follows: - - - - The ClientMessage event's format to send Atom of property - - - - - - - - Structure Member - Contents - - - - - int - type - ClientMessage - - - u_long - serial - Set by the X Window System - - - Bool - send_event - Set by the X Window System - - - Display - *display - The display to which connects - - - Window - window - IMS Window ID - - - Atom - message_type - XInternAtom(display, "_XIM_PROTOCOL", False) - - - int - format - 8 - - - long - data.1[0] - length of read/write property Atom - - - long - data.1[1] - read/write property Atom - - - -
- -
-
- -Closing Connection - - -If the client disconnect with the IM Server, shutdown function should -free the communication window properties and etc.. - - - -
-
- - -References - -[1] Masahiko Narita and Hideki Hiura, "The Input Method Protocol" - - - -
-
+ + + + + + + The XIM Transport Specification + Revision 0.1 + X Version 11, Release 7 + + + TakashiFujiwara + FUJITSU LIMITED + + + 1994FUJITSU LIMITED + 1994X Consortium + + Revision 0.1 + + + + +This specification describes the transport layer interfaces between Xlib and IM Server, +which makes various channels usable such as X protocol or TCP/IP, DECnet and etc. + + + + + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files +(the “Software”), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the following +conditions: + + + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + + + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + + +Except as contained in this notice, the name of The Open Group shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from X Consortium. + + +X Window System is a trademark of The Open Group. + + + + + +X Transport Specification + + +Introduction + + + + + +The Xlib XIM implementation is layered into three functions, a protocol +layer, an interface layer and a transport layer. The purpose of this +layering is to make the protocol independent of transport implementation. +Each function of these layers are: + + + + + The protocol layer + + +implements overall function of XIM and calls the interface layer +functions when it needs to communicate to IM Server. + + + + + The interface layer + + +separates the implementation of the transport layer from the protocol +layer, in other words, it provides implementation independent hook for +the transport layer functions. + + + + + + The transport layer + + +handles actual data communication with IM Server. It is done by a set +of several functions named transporters. + + + + + + +This specification describes the interface layer and the transport +layer, which makes various communication channels usable such as +X protocol or, TCP/IP, DECnet, STREAM, etc., and provides +the information needed for adding another new transport layer. +In addition, sample implementations for the transporter using the +X connection is described in section 4. + + + + +Initialization + + +Registering structure to initialize + + +The structure typed as TransportSW contains the list of the transport +layer the specific implementations supports. + + + +typedef struct { + char *transport_name; + Bool (*config); +} TransportSW; + + + + + + + + + transport_name + name of transportRefer to "The Input Method Protocol: Appendix B + + + config + initial configuration function + + + + + + +A sample entry for the Xlib supporting transporters is shown below: + + + +TransportSW _XimTransportRec[] = { +/* char *: + * transport_name, Bool (*config)() + */ + "X", _XimXConf, + "tcp", _XimTransConf, + "local", _XimTransConf, + "decnet", _XimTransConf, + "streams", _XimTransConf, + (char *)NULL, (Bool (*)())NULL, +}; + + + + +Initialization function + + + + +The following function will be called once when Xlib configures the +transporter functions. + + + + + Bool (*config) + XIM im + char *transport_data + + + + + + + im + + + +Specifies XIM structure address. + + + + + + transport_data + + + +Specifies the data specific to the transporter, in IM Server address.Refer to "The Input Method Protocol: Appendix B + + + + + + +This function must setup the transporter function pointers. + + + + +The actual config function will be chosen by IM Server at the +pre-connection time, matching by the transport_name specified +in the _XimTransportRec array; The specific members of XimProto +structure listed below must be initialized so that point they +appropriate transporter functions. + + + +If the specified transporter has been configured successfully, this +function returns True. There is no Alternative Entry for config +function itself. + + + +The structure XimProto contains the following function pointers: + + + +Bool (*connect)(); /* Open connection */ +Bool (*shutdown)(); /* Close connection */ +Bool (*write)(); /* Write data */ +Bool (*read)(); /* Read data */ +Bool (*flush)(); /* Flush data buffer */ +Bool (*register_dispatcher)(); /* Register asynchronous data handler */ +Bool (*call_dispatcher)(); /* Call dispatcher */ + + + +These functions are called when Xlib needs to communicate the +IM Server. These functions must process the appropriate procedure +described below. + + + + + +The interface/transport layer functions + +Following functions are used for the transport interface. + + + + The Transport Layer Functions + + + + + + + Alternate Entry (Interface Layer) + XimProto member (Transport Layer) + Section + + + + + _XimConnect + connect + 3.1 + + + _XimShutdown + shutdown + 3.2 + + + _XimWrite + write + 3.3 + + + _XimRead + read + 3.4 + + + _XimFlush + flush + 3.5 + + + _XimRegisterDispatcher + register_dispatcher + 3.6 + + + _XimCallDispatcher + call_dispatcher + 3.7 + + + +
+ + +The Protocol layer calls the above functions using the Alternative +Entry in the left column. The transport implementation defines +XimProto member function in the right column. The Alternative Entry is +provided so as to make easier to implement the Protocol Layer. + + + +Opening connection + + +When XOpenIM is called, the following function is called to connect +with the IM Server. + + + + + Bool (*connect) + XIM im + + + + + + + im + + + +Specifies XIM structure address. + + + + + + +This function must establishes the connection to the IM Server. If the +connection is established successfully, this function returns True. +The Alternative Entry for this function is: + + + + + Bool _XimConnect + XIM im + + + + + + + im + + + +Specifies XIM structure address. + + + + + + + +Closing connection + + + + + +When XCloseIM is called, the following function is called to +disconnect the connection with the IM Server. The Alternative Entry +for this function is: + + + + + Bool (*shutdown) + XIM im + + + + + + + im + + + +Specifies XIM structure address. + + + + + + + +This function must close connection with the IM Server. If the +connection is closed successfully, this function returns True. The +Alternative Entry for this function is: + + + + + Bool _XimShutdown + XIM im + + + + + + + im + + + +Specifies XIM structure address. + + + + + + + + +Writing data + +The following function is called, when Xlib needs to write data to the +IM Server. + + + + + Bool _XimWrite + XIM im + INT16 len + XPointer data + + + + + + + im + + + +Specifies XIM structure address. + + + + + + len + + + +Specifies the length of writing data. + + + + + + data + + + +Specifies the writing data. + + + + + + +This function writes the data to the IM Server, regardless +of the contents. The number of bytes is passed to len. The +writing data is passed to data. If data is sent successfully, +the function returns True. Refer to "The Input Method Protocol" for +the contents of the writing data. The Alternative Entry for this +function is: + + + + + Bool _XimWrite + XIM im + INT16 len + XPointer data + + + + + + + im + + + +Specifies XIM structure address. + + + + + + len + + + +Specifies the length of writing data. + + + + + + data + + + +Specifies the writing data. + + + + + + + +Reading data + +The following function is called when Xlib waits for response from IM +server synchronously. + + + + + Bool _XimRead + XIM im + XPointer read_buf + int buf_len + int *ret_len + + + + + + + im + + + +Specifies XIM structure address. + + + + + + read_buf + + + +Specifies the buffer to store data. + + + + + + buf_len + + + +Specifies the size of the buffer + + + + + + ret_len + + + +Specifies the length of stored data. + + + + + + +This function stores the read data in read_buf, which size is +specified as buf_len. The size of data is set to ret_len. +This function return True, if the data is read normally or reading +data is completed. + + +The Alternative Entry for this function is: + + + + + Bool _XimRead + XIM im + INT16 *ret_len + XPointer buf + int buf_len + Bool (*predicate)() + XPointer predicate_arg + + + + + + + im + + + +Specifies XIM structure address. + + + + + + ret_len + + + +Specifies the size of the data buffer. + + + + + + buf + + + +Specifies the buffer to store data. + + + + + + buf_len + + + +Specifies the length of buffer. + + + + + + predicate + + + +Specifies the predicate for the XIM data. + + + + + + predicate_arg + + + +Specifies the predicate specific data. + + + + + + + +The predicate procedure indicates whether the data is for the +XIM or not. len +This function stores the read data in buf, which size +is specified as buf_len. The size of data is set to +ret_len. If preedicate() +returns True, this function returns True. If not, it calls the registered callback function. + + + +The procedure and its arguments are: + + + + + + void (*predicate) + XIM im + INT16 len + XPointer data + XPointer predicate_arg + + + + + + + im + + + +Specifies XIM structure address. + + + + + + len + + + +Specifies the size of the data buffer. + + + + + + data + + + +Specifies the buffer to store data. + + + + + + predicate_arg + + + +Specifies the predicate specific data. + + + + + + + +Flushing buffer + +The following function is called when Xlib needs to flush the data. + + + + + void (*flush) + XIM im + + + + + + + im + + + +Specifies XIM structure address. + + + + + + +This function must flush the data stored in internal buffer on the +transport layer. If data transfer is completed, the function returns +True. The Alternative Entry for this function is: + + + + + void _XimFlush + XIM im + + + + + + + im + + + +Specifies XIM structure address. + + + + + + + +Registering asynchronous data handler + +Xlib needs to handle asynchronous response from IM Server. This is +because some of the XIM data occur asynchronously to X events. + + + +Those data will be handled in the Filter, +and the Filter +will call asynchronous data handler in the protocol layer. Then it +calls dispatchers in the transport layer. The dispatchers are +implemented by the protocol layer. This function must store the +information and prepare for later call of the dispatchers using +_XimCallDispatcher. + + + +When multiple dispatchers are registered, they will be called +sequentially in order of registration, on arrival of asynchronous +data. The register_dispatcher is declared as following: + + + + + Bool (*register_dispatcher) + XIM im + Bool (*dispatcher)() + XPointer call_data + + + + + + + im + + + +Specifies XIM structure address. + + + + + + dispatcher + + + +Specifies the dispatcher function to register. + + + + + + call_data + + + +Specifies a parameter for the dispatcher. + + + + + + +The dispatcher is a function of the following type: + + + + + Bool (*dispatcher) + XIM im + INT16 len + XPointer data + XPointer call_data + + + + + + + im + + + +Specifies XIM structure address. + + + + + + len + + + +Specifies the size of the data buffer. + + + + + + data + + + +Specifies the buffer to store data. + + + + + + call_data + + + +Specifies a parameter passed to the register_dispatcher. + + + + + + +The dispatcher is provided by the protocol layer. They are called once +for every asynchronous data, in order of registration. If the data is +used, it must return True. otherwise, it must return False. + + + +If the dispatcher function returns True, the Transport Layer assume +that the data has been processed by the upper layer. The Alternative +Entry for this function is: + + + + + Bool _XimRegisterDispatcher + XIM im + Bool (*dispatcher)() + XPointer call_data + + + + + + + im + + + +Specifies XIM structure address. + + + + + + dispatcher + + + +Specifies the dispatcher function to register. + + + + + + call_data + + + +Specifies a parameter for the dispatcher. + + + + + + + +Calling dispatcher + +The following function is used to call the registered dispatcher +function, when the asynchronous response from IM Server has arrived. + + + + + Bool (*call_dispatcher) + XIM im + INT16 len + XPointer data + + + + + + + im + + + +Specifies XIM structure address. + + + + + + len + + + +Specifies the size of data buffer. + + + + + + data + + + +Specifies the buffer to store data. + + + + + + +The call_dispatcher must call the dispatcher function, in order of +their registration. len and data are the data passed to +register_dispatcher. + + + +The return values are checked at each invocation, and if it finds +True, it immediately return with true for its return value. + + + +It is depend on the upper layer whether the read data is XIM +Protocol packet unit or not. +The Alternative Entry for this function is: + + + + + Bool _XimCallDispatcher + XIM im + INT16 len + XPointer call_data + + + + +
+ +Sample implementations for the Transport Layer + +Sample implementations for the transporter using the X connection is +described here. + + + +X Transport + +At the beginning of the X Transport connection for the XIM transport +mechanism, two different windows must be created either in an Xlib XIM +or in an IM Server, with which the Xlib and the IM Server exchange the +XIM transports by using the ClientMessage events and Window Properties. +In the following, the window created by the Xlib is referred as the +"client communication window", and on the other hand, the window created +by the IM Server is referred as the "IMS communication window". + + + +Connection + +In order to establish a connection, a communication window is created. +A ClientMessage in the following event's format is sent to the owner +window of XIM_SERVER selection, which the IM Server has created. + + + + +Refer to "The Input Method Protocol" for the XIM_SERVER atom. + + + + The ClientMessage sent to the IMS window. + + + + + + + + Structure Member + Contents + + + + + int + type + ClientMessage + + + u_long + serial + Set by the X Window System + + + Bool + send_event + Set by the X Window System + + + Display + *display + The display to which connects + + + Window + window + IMS Window ID + + + Atom + message_type + XInternAtom(display, "_XIM_CONNECT", false) + + + int + format + 32 + + + long + data.1[0] + client communication window ID + + + long + data.1[1] + client-major-transport-version(*1) + + + long + data.1[2] + client-major-transport-version(*1) + + + +
+ + +In order to establish the connection (to notify the IM Server communication +window), the IM Server sends a ClientMessage in the following event's +format to the client communication window. + + + + The ClientMessage sent by IM Server. + + + + + + + + Structure Member + Contents + + + + + int + type + ClientMessage + + + u_long + serial + Set by the X Window System + + + Bool + send_event + Set by the X Window System + + + Display + *display + The display to which connects + + + Window + window + IMS Window ID + + + Atom + message_type + XInternAtom(display, "_XIM_CONNECT", false) + + + int + format + 32 + + + long + data.1[0] + client communication window ID + + + long + data.1[1] + client-major-transport-version(*1) + + + long + data.1[2] + client-major-transport-version(*1) + + + long + data.1[3] + dividing size between ClientMessage and Property(*2) + + + +
+ + +(*1) major/minor-transport-version + + + +The read/write method is decided by the combination of +major/minor-transport-version, as follows: + + + +The read/write method and the major/minor-transport-version + + + + + + + + Transport-version + read/write + + + major + minor + + + + + + 0 + 0 + only-CM & Property-with-CM + + + 1 + only-CM & multi-CM + + + 2 + only-CM & multi-CM & Property-with-CM + + + 1 + 0 + PropertyNotify + + + 2 + 0 + only-CM & PropertyNotify + + + 1 + only-CM & multi-CM & PropertyNotify + + + +
+ + +only-CM : data is sent via a ClientMessage +multi-CM : data is sent via multiple ClientMessages +Property-with-CM : data is written in Property, and its Atom + is send via ClientMessage +PropertyNotify : data is written in Property, and its Atom + is send via PropertyNotify + + + + + +The method to decide major/minor-transport-version is as follows: + + + + + +The client sends 0 as major/minor-transport-version to the IM Server. +The client must support all methods in Table 4-3. +The client may send another number as major/minor-transport-version to +use other method than the above in the future. + + + + +The IM Server sends its major/minor-transport-version number to +the client. The client sends data using the method specified by the +IM Server. + + + + +If major/minor-transport-version number is not available, it is regarded +as 0. + + + + + +(*2) dividing size between ClientMessage and Property + + + +If data is sent via both of multi-CM and Property, specify the dividing +size between ClientMessage and Property. The data, which is smaller than +this size, is sent via multi-CM (or only-CM), and the data, which is +lager than this size, is sent via Property. + + +
+ + +read/write + +The data is transferred via either ClientMessage or Window Property in +the X Window System. + + + +Format for the data from the Client to the IM Server + +ClientMessage + + + +If data is sent via ClientMessage event, the format is as follows: + + + + The ClientMessage event's format (first or middle) + + + + + + + + Structure Member + Contents + + + + + int + type + ClientMessage + + + u_long + serial + Set by the X Window System + + + Bool + send_event + Set by the X Window System + + + Display + *display + The display to which connects + + + Window + window + IMS Window ID + + + Atom + message_type + XInternAtom(display, "_XIM_MOREDATA", False) + + + int + format + 8 + + + char + data.b[20] + (read/write DATA : 20 byte) + + + +
+ + + + + The ClientMessage event's format (only or last) + + + + + + + + Structure Member + Contents + + + + + int + type + ClientMessage + + + u_long + serial + Set by the X Window System + + + Bool + send_event + Set by the X Window System + + + Display + *display + The display to which connects + + + Window + window + IMS Window ID + + + Atom + message_type + XInternAtom(display, "_XIM_PROTOCOL", False) + + + int + format + 8 + + + char + data.b[20] + (read/write DATA : MAX 20 byte) +If the data is smaller +than 20 bytes, all data other than available data must be 0. + + + + + +
+ + +Property + + + +In the case of large data, data will be sent via the Window Property +for the efficiency. There are the following two methods to notify +Property, and transport-version is decided which method is used. + + + + + +The XChangeProperty function is used to store data in the client +communication window, and Atom of the stored data is notified to the +IM Server via ClientMessage event. + + + + +The XChangeProperty function is used to store data in the client +communication window, and Atom of the stored data is notified to the +IM Server via PropertyNotify event. + + + + + +The arguments of the XChangeProperty are as follows: + + + + + The XChangeProperty event's format + + + + + + + + Argument + Contents + + + + + Display + *display + The display to which connects + + + Window + window + IMS communication window ID + + + Atom + property + read/write property Atom (*1) + + + int + format + 8 + + + int + mode + PropModeAppend + + + u_char + *data + read/write DATA + + + int + nelements + length of DATA + + + +
+ + +(*1) The read/write property ATOM allocates the following strings by +XInternAtom. +"_clientXXX" + + + +The client changes the property with the mode of PropModeAppend and +the IM Server will read it with the delete mode i.e. (delete = True). + + + +If Atom is notified via ClientMessage event, the format of the ClientMessage +is as follows: + + + + The ClientMessage event's format to send Atom of property + + + + + + + + Structure Member + Contents + + + + + int + type + ClientMessage + + + u_long + serial + Set by the X Window System + + + Bool + send_event + Set by the X Window System + + + Display + *display + The display to which connects + + + Window + window + IMS Window ID + + + Atom + message_type + XInternAtom(display, "_XIM_PROTOCOL", False) + + + int + format + 8 + + + long + data.1[0] + length of read/write property Atom + + + long + data.1[1] + read/write property Atom + + + +
+
+ + +Format for the data from the IM Server to the Client + +ClientMessage + + + +The format of the ClientMessage is as follows: + + + + The ClientMessage event's format (first or middle) + + + + + + + + Structure Member + Contents + + + + + int + type + ClientMessage + + + u_long + serial + Set by the X Window System + + + Bool + send_event + Set by the X Window System + + + Display + *display + The display to which connects + + + Window + window + IMS Window ID + + + Atom + message_type + XInternAtom(display, "_XIM_MOREDATA", False) + + + int + format + 8 + + + char + data.b[20] + (read/write DATA : 20 byte) + + + +
+ + + + + + + The ClientMessage event's format (only or last) + + + + + + + + Structure Member + Contents + + + + + int + type + ClientMessage + + + u_long + serial + Set by the X Window System + + + Bool + send_event + Set by the X Window System + + + Display + *display + The display to which connects + + + Window + window + IMS Window ID + + + Atom + message_type + XInternAtom(display, "_XIM_PROTOCOL", False) + + + int + format + 8 + + + char + data.b[20] + (read/write DATA : MAX 20 byte) (*1) + + + +
+ + +(*1) If the data size is smaller than 20 bytes, all data other than available +data must be 0. + + + +Property + + + +In the case of large data, data will be sent via the Window Property +for the efficiency. There are the following two methods to notify +Property, and transport-version is decided which method is used. + + + + + +The XChangeProperty function is used to store data in the IMS +communication window, and Atom of the property is sent via the +ClientMessage event. + + + + +The XChangeProperty function is used to store data in the IMS +communication window, and Atom of the property is sent via +PropertyNotify event. + + + + + +The arguments of the XChangeProperty are as follows: + + + + The XChangeProperty event's format + + + + + + + + Argument + Contents + + + + + Display + *display + The display to which connects + + + Window + window + IMS communication window ID + + + Atom + property + read/write property Atom (*1) + + + int + format + 8 + + + int + mode + PropModeAppend + + + u_char + *data + read/write DATA + + + int + nelements + length of DATA + + + +
+ + +(*1) The read/write property ATOM allocates some strings, which are not +allocated by the client, by XInternAtom. + + + +The IM Server changes the property with the mode of PropModeAppend and +the client reads it with the delete mode, i.e. (delete = True). + + + +If Atom is notified via ClientMessage event, the format of the ClientMessage +is as follows: + + + + The ClientMessage event's format to send Atom of property + + + + + + + + Structure Member + Contents + + + + + int + type + ClientMessage + + + u_long + serial + Set by the X Window System + + + Bool + send_event + Set by the X Window System + + + Display + *display + The display to which connects + + + Window + window + IMS Window ID + + + Atom + message_type + XInternAtom(display, "_XIM_PROTOCOL", False) + + + int + format + 8 + + + long + data.1[0] + length of read/write property Atom + + + long + data.1[1] + read/write property Atom + + + +
+ +
+
+ +Closing Connection + + +If the client disconnect with the IM Server, shutdown function should +free the communication window properties and etc.. + + + +
+
+ + +References + +[1] Masahiko Narita and Hideki Hiura, "The Input Method Protocol" + + + +
+
diff --git a/libXext/src/Xge.c b/libXext/src/Xge.c index 724011eab..d28a4f052 100644 --- a/libXext/src/Xge.c +++ b/libXext/src/Xge.c @@ -1,365 +1,365 @@ -/* - * Copyright © 2007-2008 Peter Hutterer - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: Peter Hutterer, University of South Australia, NICTA - */ - -/* - * XGE is an extension to re-use a single opcode for multiple events, - * depending on the extension. XGE allows events >32 bytes. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -/***********************************************************************/ -/* internal data structures */ -/***********************************************************************/ - -typedef struct { - int present; - short major_version; - short minor_version; -} XGEVersionRec; - -/* NULL terminated list of registered extensions. */ -typedef struct _XGEExtNode { - int extension; - XExtensionHooks* hooks; - struct _XGEExtNode* next; -} XGEExtNode, *XGEExtList; - -/* Internal data for GE extension */ -typedef struct _XGEData { - XEvent data; - XGEVersionRec *vers; - XGEExtList extensions; -} XGEData; - - -/* forward declarations */ -static XExtDisplayInfo* _xgeFindDisplay(Display*); -static Bool _xgeWireToEvent(Display*, XEvent*, xEvent*); -static Status _xgeEventToWire(Display*, XEvent*, xEvent*); -static int _xgeDpyClose(Display*, XExtCodes*); -static XGEVersionRec* _xgeGetExtensionVersion(Display*, - _Xconst char*, - XExtDisplayInfo*); -static Bool _xgeCheckExtension(Display* dpy, XExtDisplayInfo* info); - -/* main extension information data */ -static XExtensionInfo *xge_info; -static char xge_extension_name[] = GE_NAME; -static XExtensionHooks xge_extension_hooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - _xgeDpyClose, /* close_display */ - _xgeWireToEvent, /* wire_to_event */ - _xgeEventToWire, /* event_to_wire */ - NULL, /* error */ - NULL, /* error_string */ -}; - - -static XExtDisplayInfo *_xgeFindDisplay(Display *dpy) -{ - XExtDisplayInfo *dpyinfo; - if (!xge_info) - { - if (!(xge_info = XextCreateExtension())) - return NULL; - } - if (!(dpyinfo = XextFindDisplay (xge_info, dpy))) - { - dpyinfo = XextAddDisplay (xge_info, - dpy, - xge_extension_name, - &xge_extension_hooks, - 0 /* no events, see below */, - NULL); - /* We don't use an extension opcode, so we have to set the handlers - * directly. If GenericEvent would be > 64, the job would be done by - * XExtAddDisplay */ - XESetWireToEvent (dpy, - GenericEvent, - xge_extension_hooks.wire_to_event); - XESetEventToWire (dpy, - GenericEvent, - xge_extension_hooks.event_to_wire); - } - return dpyinfo; -} - -/* - * Check extension is set up and internal data fields are filled. - */ -static Bool -_xgeCheckExtInit(Display* dpy, XExtDisplayInfo* info) -{ - LockDisplay(dpy); - if(!_xgeCheckExtension(dpy, info)) - { - goto cleanup; - } - - if (!info->data) - { - XGEData* data = (XGEData*)Xmalloc(sizeof(XGEData)); - if (!data) { - goto cleanup; - } - /* get version from server */ - data->vers = - _xgeGetExtensionVersion(dpy, "Generic Event Extension", info); - data->extensions = NULL; - info->data = (XPointer)data; - } - - UnlockDisplay(dpy); - return True; - -cleanup: - UnlockDisplay(dpy); - return False; -} - -/* Return 1 if XGE extension exists, 0 otherwise. */ -static Bool -_xgeCheckExtension(Display* dpy, XExtDisplayInfo* info) -{ - return XextHasExtension(info); -} - - -/* Retrieve XGE version number from server. */ -static XGEVersionRec* -_xgeGetExtensionVersion(Display* dpy, - _Xconst char* name, - XExtDisplayInfo*info) -{ - xGEQueryVersionReply rep; - xGEQueryVersionReq *req; - XGEVersionRec *vers; - - GetReq(GEQueryVersion, req); - req->reqType = info->codes->major_opcode; - req->ReqType = X_GEQueryVersion; - req->majorVersion = GE_MAJOR; - req->minorVersion = GE_MINOR; - - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) - { - Xfree(info); - return NULL; - } - - vers = (XGEVersionRec*)Xmalloc(sizeof(XGEVersionRec)); - vers->major_version = rep.majorVersion; - vers->minor_version = rep.minorVersion; - return vers; -} - -/* - * Display closing routine. - */ - -static int -_xgeDpyClose(Display* dpy, XExtCodes* codes) -{ - XExtDisplayInfo *info = _xgeFindDisplay(dpy); - - if (info->data != NULL) { - XGEData* xge_data = (XGEData*)info->data; - - if (xge_data->extensions) - { - XGEExtList current, next; - current = xge_data->extensions; - while(current) - { - next = current->next; - Xfree(current); - current = next; - } - } - - XFree(xge_data->vers); - XFree(xge_data); - } - - return XextRemoveDisplay(xge_info, dpy); -} - -/* - * protocol to Xlib event conversion routine. - */ -static Bool -_xgeWireToEvent(Display* dpy, XEvent* re, xEvent *event) -{ - int extension; - XGEExtList it; - XExtDisplayInfo* info = _xgeFindDisplay(dpy); - if (!info) - return False; - /* - _xgeCheckExtInit() calls LockDisplay, leading to a SIGABRT. - Well, I guess we don't need the data we get in CheckExtInit anyway - if (!_xgeCheckExtInit(dpy, info)) - return False; - */ - - extension = ((xGenericEvent*)event)->extension; - - it = ((XGEData*)info->data)->extensions; - while(it) - { - if (it->extension == extension) - { - return (it->hooks->wire_to_event(dpy, re, event)); - } - it = it->next; - } - - fprintf(stderr, - "_xgeWireToEvent: Unknown extension %d, this should never happen.\n", - extension); - return False; -} - -/* - * xlib event to protocol conversion routine. - */ -static Status -_xgeEventToWire(Display* dpy, XEvent* re, xEvent* event) -{ - int extension; - XGEExtList it; - XExtDisplayInfo* info = _xgeFindDisplay(dpy); - if (!info) - return 1; /* error! */ - - extension = ((XGenericEvent*)re)->extension; - - it = ((XGEData*)info->data)->extensions; - while(it) - { - if (it->extension == extension) - { - return (it->hooks->event_to_wire(dpy, re, event)); - } - it = it->next; - } - - fprintf(stderr, - "_xgeEventToWire: Unknown extension %d, this should never happen.\n", - extension); - - return Success; -} - -/* - * Extensions need to register callbacks for their events. - */ -Bool -xgeExtRegister(Display* dpy, int offset, XExtensionHooks* callbacks) -{ - XGEExtNode* newExt; - XGEData* xge_data; - - XExtDisplayInfo* info = _xgeFindDisplay(dpy); - if (!info) - return False; /* error! */ - - if (!_xgeCheckExtInit(dpy, info)) - return False; - - xge_data = (XGEData*)info->data; - - newExt = (XGEExtNode*)Xmalloc(sizeof(XGEExtNode)); - if (!newExt) - { - fprintf(stderr, "xgeExtRegister: Failed to alloc memory.\n"); - return False; - } - - newExt->extension = offset; - newExt->hooks = callbacks; - newExt->next = xge_data->extensions; - xge_data->extensions = newExt; - - return True; -} - -/***********************************************************************/ -/* Client interfaces */ -/***********************************************************************/ - -/* Set event_base and error_base to the matching values for XGE. - * Note that since XGE doesn't use any errors and events, the actual return - * value is of limited use. - */ -Bool -XGEQueryExtension(Display* dpy, int* event_base, int* error_base) -{ - XExtDisplayInfo* info = _xgeFindDisplay(dpy); - if (!_xgeCheckExtInit(dpy, info)) - return False; - - *event_base = info->codes->first_event; - *error_base = info->codes->first_error; - return True; -} - -/* Get XGE version number. - * Doesn't actually get it from server, that should have been done beforehand - * already - */ -Bool -XGEQueryVersion(Display* dpy, - int *major_version, - int *minor_version) -{ - XExtDisplayInfo* info = _xgeFindDisplay(dpy); - if (!info) - return False; - - if (!_xgeCheckExtInit(dpy, info)) - return False; - - *major_version = ((XGEData*)info->data)->vers->major_version; - *minor_version = ((XGEData*)info->data)->vers->minor_version; - - return True; -} - +/* + * Copyright © 2007-2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: Peter Hutterer, University of South Australia, NICTA + */ + +/* + * XGE is an extension to re-use a single opcode for multiple events, + * depending on the extension. XGE allows events >32 bytes. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include + +/***********************************************************************/ +/* internal data structures */ +/***********************************************************************/ + +typedef struct { + int present; + short major_version; + short minor_version; +} XGEVersionRec; + +/* NULL terminated list of registered extensions. */ +typedef struct _XGEExtNode { + int extension; + XExtensionHooks* hooks; + struct _XGEExtNode* next; +} XGEExtNode, *XGEExtList; + +/* Internal data for GE extension */ +typedef struct _XGEData { + XEvent data; + XGEVersionRec *vers; + XGEExtList extensions; +} XGEData; + + +/* forward declarations */ +static XExtDisplayInfo* _xgeFindDisplay(Display*); +static Bool _xgeWireToEvent(Display*, XEvent*, xEvent*); +static Status _xgeEventToWire(Display*, XEvent*, xEvent*); +static int _xgeDpyClose(Display*, XExtCodes*); +static XGEVersionRec* _xgeGetExtensionVersion(Display*, + _Xconst char*, + XExtDisplayInfo*); +static Bool _xgeCheckExtension(Display* dpy, XExtDisplayInfo* info); + +/* main extension information data */ +static XExtensionInfo *xge_info; +static char xge_extension_name[] = GE_NAME; +static XExtensionHooks xge_extension_hooks = { + NULL, /* create_gc */ + NULL, /* copy_gc */ + NULL, /* flush_gc */ + NULL, /* free_gc */ + NULL, /* create_font */ + NULL, /* free_font */ + _xgeDpyClose, /* close_display */ + _xgeWireToEvent, /* wire_to_event */ + _xgeEventToWire, /* event_to_wire */ + NULL, /* error */ + NULL, /* error_string */ +}; + + +static XExtDisplayInfo *_xgeFindDisplay(Display *dpy) +{ + XExtDisplayInfo *dpyinfo; + if (!xge_info) + { + if (!(xge_info = XextCreateExtension())) + return NULL; + } + if (!(dpyinfo = XextFindDisplay (xge_info, dpy))) + { + dpyinfo = XextAddDisplay (xge_info, + dpy, + xge_extension_name, + &xge_extension_hooks, + 0 /* no events, see below */, + NULL); + /* We don't use an extension opcode, so we have to set the handlers + * directly. If GenericEvent would be > 64, the job would be done by + * XExtAddDisplay */ + XESetWireToEvent (dpy, + GenericEvent, + xge_extension_hooks.wire_to_event); + XESetEventToWire (dpy, + GenericEvent, + xge_extension_hooks.event_to_wire); + } + return dpyinfo; +} + +/* + * Check extension is set up and internal data fields are filled. + */ +static Bool +_xgeCheckExtInit(Display* dpy, XExtDisplayInfo* info) +{ + LockDisplay(dpy); + if(!_xgeCheckExtension(dpy, info)) + { + goto cleanup; + } + + if (!info->data) + { + XGEData* data = (XGEData*)Xmalloc(sizeof(XGEData)); + if (!data) { + goto cleanup; + } + /* get version from server */ + data->vers = + _xgeGetExtensionVersion(dpy, "Generic Event Extension", info); + data->extensions = NULL; + info->data = (XPointer)data; + } + + UnlockDisplay(dpy); + return True; + +cleanup: + UnlockDisplay(dpy); + return False; +} + +/* Return 1 if XGE extension exists, 0 otherwise. */ +static Bool +_xgeCheckExtension(Display* dpy, XExtDisplayInfo* info) +{ + return XextHasExtension(info); +} + + +/* Retrieve XGE version number from server. */ +static XGEVersionRec* +_xgeGetExtensionVersion(Display* dpy, + _Xconst char* name, + XExtDisplayInfo*info) +{ + xGEQueryVersionReply rep; + xGEQueryVersionReq *req; + XGEVersionRec *vers; + + GetReq(GEQueryVersion, req); + req->reqType = info->codes->major_opcode; + req->ReqType = X_GEQueryVersion; + req->majorVersion = GE_MAJOR; + req->minorVersion = GE_MINOR; + + if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) + { + Xfree(info); + return NULL; + } + + vers = (XGEVersionRec*)Xmalloc(sizeof(XGEVersionRec)); + vers->major_version = rep.majorVersion; + vers->minor_version = rep.minorVersion; + return vers; +} + +/* + * Display closing routine. + */ + +static int +_xgeDpyClose(Display* dpy, XExtCodes* codes) +{ + XExtDisplayInfo *info = _xgeFindDisplay(dpy); + + if (info->data != NULL) { + XGEData* xge_data = (XGEData*)info->data; + + if (xge_data->extensions) + { + XGEExtList current, next; + current = xge_data->extensions; + while(current) + { + next = current->next; + Xfree(current); + current = next; + } + } + + XFree(xge_data->vers); + XFree(xge_data); + } + + return XextRemoveDisplay(xge_info, dpy); +} + +/* + * protocol to Xlib event conversion routine. + */ +static Bool +_xgeWireToEvent(Display* dpy, XEvent* re, xEvent *event) +{ + int extension; + XGEExtList it; + XExtDisplayInfo* info = _xgeFindDisplay(dpy); + if (!info) + return False; + /* + _xgeCheckExtInit() calls LockDisplay, leading to a SIGABRT. + Well, I guess we don't need the data we get in CheckExtInit anyway + if (!_xgeCheckExtInit(dpy, info)) + return False; + */ + + extension = ((xGenericEvent*)event)->extension; + + it = ((XGEData*)info->data)->extensions; + while(it) + { + if (it->extension == extension) + { + return (it->hooks->wire_to_event(dpy, re, event)); + } + it = it->next; + } + + fprintf(stderr, + "_xgeWireToEvent: Unknown extension %d, this should never happen.\n", + extension); + return False; +} + +/* + * xlib event to protocol conversion routine. + */ +static Status +_xgeEventToWire(Display* dpy, XEvent* re, xEvent* event) +{ + int extension; + XGEExtList it; + XExtDisplayInfo* info = _xgeFindDisplay(dpy); + if (!info) + return 1; /* error! */ + + extension = ((XGenericEvent*)re)->extension; + + it = ((XGEData*)info->data)->extensions; + while(it) + { + if (it->extension == extension) + { + return (it->hooks->event_to_wire(dpy, re, event)); + } + it = it->next; + } + + fprintf(stderr, + "_xgeEventToWire: Unknown extension %d, this should never happen.\n", + extension); + + return Success; +} + +/* + * Extensions need to register callbacks for their events. + */ +Bool +_X_HIDDEN xgeExtRegister(Display* dpy, int offset, XExtensionHooks* callbacks) +{ + XGEExtNode* newExt; + XGEData* xge_data; + + XExtDisplayInfo* info = _xgeFindDisplay(dpy); + if (!info) + return False; /* error! */ + + if (!_xgeCheckExtInit(dpy, info)) + return False; + + xge_data = (XGEData*)info->data; + + newExt = (XGEExtNode*)Xmalloc(sizeof(XGEExtNode)); + if (!newExt) + { + fprintf(stderr, "xgeExtRegister: Failed to alloc memory.\n"); + return False; + } + + newExt->extension = offset; + newExt->hooks = callbacks; + newExt->next = xge_data->extensions; + xge_data->extensions = newExt; + + return True; +} + +/***********************************************************************/ +/* Client interfaces */ +/***********************************************************************/ + +/* Set event_base and error_base to the matching values for XGE. + * Note that since XGE doesn't use any errors and events, the actual return + * value is of limited use. + */ +Bool +XGEQueryExtension(Display* dpy, int* event_base, int* error_base) +{ + XExtDisplayInfo* info = _xgeFindDisplay(dpy); + if (!_xgeCheckExtInit(dpy, info)) + return False; + + *event_base = info->codes->first_event; + *error_base = info->codes->first_error; + return True; +} + +/* Get XGE version number. + * Doesn't actually get it from server, that should have been done beforehand + * already + */ +Bool +XGEQueryVersion(Display* dpy, + int *major_version, + int *minor_version) +{ + XExtDisplayInfo* info = _xgeFindDisplay(dpy); + if (!info) + return False; + + if (!_xgeCheckExtInit(dpy, info)) + return False; + + *major_version = ((XGEData*)info->data)->vers->major_version; + *minor_version = ((XGEData*)info->data)->vers->minor_version; + + return True; +} + diff --git a/mesalib/docs/GL3.txt b/mesalib/docs/GL3.txt index 9ff25a952..0c53bc42d 100644 --- a/mesalib/docs/GL3.txt +++ b/mesalib/docs/GL3.txt @@ -27,7 +27,7 @@ Non-normalized Integer texture/framebuffer formats ~50% done 1D/2D Texture arrays core Mesa, swrast done Packed depth/stencil formats DONE Per-buffer blend and masks (GL_EXT_draw_buffers2) DONE -GL_EXT_texture_compression_rgtc not started +GL_EXT_texture_compression_rgtc DONE (swrast, gallium r600) Red and red/green texture formats DONE (swrast, i965, gallium) Transform feedback (GL_EXT_transform_feedback) ~50% done glBindFragDataLocation, glGetFragDataLocation, diff --git a/mesalib/docs/MESA_multithread_makecurrent.spec b/mesalib/docs/MESA_multithread_makecurrent.spec new file mode 100644 index 000000000..5065c2fc0 --- /dev/null +++ b/mesalib/docs/MESA_multithread_makecurrent.spec @@ -0,0 +1,158 @@ +Name + + MESA_multithread_makecurrent + +Name Strings + + GLX_MESA_multithread_makecurrent + +Contact + + Eric Anholt (eric@anholt.net) + +Status + + Not shipping. + +Version + + Last Modified Date: 21 February 2011 + +Number + + TBD + +Dependencies + + OpenGL 1.0 or later is required. + GLX 1.3 or later is required. + +Overview + + The GLX context setup encourages multithreaded applications to + create a context per thread which each operate on their own + objects in parallel, and leaves synchronization for write access + to shared objects up to the application. + + For some applications, maintaining per-thread contexts and + ensuring that the glFlush happens in one thread before another + thread starts working on that object is difficult. For them, + using the same context across multiple threads and protecting its + usage with a mutex is both higher performance and easier to + implement. This extension gives those applications that option by + relaxing the context binding requirements. + + This new behavior matches the requirements of AGL, while providing + a feature not specified in WGL. + +IP Status + + Open-source; freely implementable. + +Issues + + None. + +New Procedures and Functions + + None. + +New Tokens + + None. + +Changes to Chapter 2 of the GLX 1.3 Specification (Functions and Errors) + + Replace the following sentence from section 2.2 Rendering Contexts: + In addition, a rendering context can be current for only one + thread at a time. + with: + In addition, an indirect rendering context can be current for + only one thread at a time. A direct rendering context may be + current to multiple threads, with synchronization of access to + the context thruogh the GL managed by the application through + mutexes. + +Changes to Chapter 3 of the GLX 1.3 Specification (Functions and Errors) + + Replace the following sentence from section 3.3.7 Rendering Contexts: + If ctx is current to some other thread, then + glXMakeContextCurrent will generate a BadAccess error. + with: + If ctx is an indirect context current to some other thread, + then glXMakeContextCurrent will generate a BadAccess error. + + Replace the following sentence from section 3.5 Rendering Contexts: + If ctx is current to some other thread, then + glXMakeCurrent will generate a BadAccess error. + with: + If ctx is an indirect context current to some other thread, + then glXMakeCurrent will generate a BadAccess error. + +GLX Protocol + + None. The GLX extension only extends to direct rendering contexts. + +Errors + + None. + +New State + + None. + +Issues + + (1) What happens if the app binds a context/drawable in multiple + threads, then binds a different context/thread in one of them? + + As with binding a new context from the current thread, the old + context's refcount is reduced and the new context's refcount is + increased. + + (2) What happens if the app binds a context/drawable in multiple + threads, then binds None/None in one of them? + + The GLX context is unreferenced from that thread, and the other + threads retain their GLX context binding. + + (3) What happens if the app binds a context/drawable in 7 threads, + then destroys the context in one of them? + + As with GLX context destruction previously, the XID is destroyed + but the context remains usable by threads that have the context + current. + + (4) What happens if the app binds a new drawable/readable with + glXMakeCurrent() when it is already bound to another thread? + + The context becomes bound to the new drawable/readable, and + further rendering in either thread will use the new + drawable/readable. + + (5) What requirements should be placed on the user managing contexts + from multiple threads? + + The intention is to allow multithreaded access to the GL at the + minimal performance cost, so requiring that the GL do general + synchronization (beyond that already required by context sharing) + is not an option, and synchronizing of GL's access to the GL + context between multiple threads is left to the application to do + across GL calls. However, it would be unfortunate for a library + doing multithread_makecurrent to require that other libraries + share in synchronization for binding of their own contexts, so the + refcounting of the contexts is required to be threadsafe. + + (6) Does this apply to indirect contexts? + + This was ignored in the initial revision of the spec. Behavior + for indirect contexts is left as-is. + +Revision History + + 20 November 2009 Eric Anholt - initial specification + 22 November 2009 Eric Anholt - added issues from Ian Romanick. + 3 February 2011 Eric Anholt - updated with resolution to issues 1-3 + 3 February 2011 Eric Anholt - added issue 4, 5 + 21 February 2011 Eric Anholt - Include glXMakeCurrent() sentence + along with glXMakeContextCurrent() for removal. diff --git a/mesalib/docs/relnotes-7.11.html b/mesalib/docs/relnotes-7.11.html index 8bc3e2997..4b1730b17 100644 --- a/mesalib/docs/relnotes-7.11.html +++ b/mesalib/docs/relnotes-7.11.html @@ -1,59 +1,60 @@ - - - -Mesa Release Notes - - - - - - - - -

Mesa 7.11 Release Notes / (release date TBD)

- -

-Mesa 7.11 is a new development release. -People who are concerned with stability and reliability should stick -with a previous release or wait for Mesa 7.11.1. -

-

-Mesa 7.11 implements the OpenGL 2.1 API, but the version reported by -glGetString(GL_VERSION) depends on the particular driver being used. -Some drivers don't support all the features required in OpenGL 2.1. -

-

-See the Compiling/Installing page for prerequisites -for DRI hardware acceleration. -

- - -

MD5 checksums

-
-tbd
-
- - -

New features

-
    -
  • GL_ARB_draw_instanced extension (gallium drivers, swrast) -
  • GL_ARB_instanced_arrays extension (gallium drivers) -
  • GL_ARB_draw_buffers_blend (gallium) -
  • GL_EXT_texture_sRGB_decode (gallium drivers, swrast, i965) -
- - -

Bug fixes

-
    -
- - -

Changes

-
    -
  • The Windows MSVC project files have been removed. They haven't been maintained -in quite a while. Building with SCons is an alterantive. -
- - - - + + + +Mesa Release Notes + + + + + + + + +

Mesa 7.11 Release Notes / (release date TBD)

+ +

+Mesa 7.11 is a new development release. +People who are concerned with stability and reliability should stick +with a previous release or wait for Mesa 7.11.1. +

+

+Mesa 7.11 implements the OpenGL 2.1 API, but the version reported by +glGetString(GL_VERSION) depends on the particular driver being used. +Some drivers don't support all the features required in OpenGL 2.1. +

+

+See the Compiling/Installing page for prerequisites +for DRI hardware acceleration. +

+ + +

MD5 checksums

+
+tbd
+
+ + +

New features

+
    +
  • GL_ARB_draw_instanced extension (gallium drivers, swrast) +
  • GL_ARB_instanced_arrays extension (gallium drivers) +
  • GL_ARB_texture_compression_rgtc (gallium r600, swrast) +
  • GL_ARB_draw_buffers_blend (gallium) +
  • GL_EXT_texture_sRGB_decode (gallium drivers, swrast, i965) +
+ + +

Bug fixes

+
    +
+ + +

Changes

+
    +
  • The Windows MSVC project files have been removed. They haven't been maintained +in quite a while. Building with SCons is an alterantive. +
+ + + + diff --git a/mesalib/src/glsl/Makefile b/mesalib/src/glsl/Makefile index f964b7487..df031d2d5 100644 --- a/mesalib/src/glsl/Makefile +++ b/mesalib/src/glsl/Makefile @@ -1,213 +1,213 @@ - -#src/glsl/pp/Makefile - -TOP = ../.. - -include $(TOP)/configs/current - -LIBNAME = glsl - -LIBGLCPP_SOURCES = \ - glcpp/glcpp-lex.c \ - glcpp/glcpp-parse.c \ - glcpp/pp.c - -GLCPP_SOURCES = \ - $(LIBGLCPP_SOURCES) \ - ralloc.c \ - glcpp/glcpp.c - -C_SOURCES = \ - strtod.c \ - ralloc.c \ - $(LIBGLCPP_SOURCES) - -CXX_SOURCES = \ - ast_expr.cpp \ - ast_function.cpp \ - ast_to_hir.cpp \ - ast_type.cpp \ - glsl_lexer.cpp \ - glsl_parser.cpp \ - glsl_parser_extras.cpp \ - glsl_types.cpp \ - glsl_symbol_table.cpp \ - hir_field_selection.cpp \ - ir_basic_block.cpp \ - ir_clone.cpp \ - ir_constant_expression.cpp \ - ir.cpp \ - ir_expression_flattening.cpp \ - ir_function_can_inline.cpp \ - ir_function.cpp \ - ir_hierarchical_visitor.cpp \ - ir_hv_accept.cpp \ - ir_import_prototypes.cpp \ - ir_print_visitor.cpp \ - ir_reader.cpp \ - ir_rvalue_visitor.cpp \ - ir_set_program_inouts.cpp \ - ir_validate.cpp \ - ir_variable.cpp \ - ir_variable_refcount.cpp \ - linker.cpp \ - link_functions.cpp \ - loop_analysis.cpp \ - loop_controls.cpp \ - loop_unroll.cpp \ - lower_discard.cpp \ - lower_if_to_cond_assign.cpp \ - lower_instructions.cpp \ - lower_jumps.cpp \ - lower_mat_op_to_vec.cpp \ - lower_noise.cpp \ - lower_texture_projection.cpp \ - lower_variable_index_to_cond_assign.cpp \ - lower_vec_index_to_cond_assign.cpp \ - lower_vec_index_to_swizzle.cpp \ - lower_vector.cpp \ - opt_algebraic.cpp \ - opt_constant_folding.cpp \ - opt_constant_propagation.cpp \ - opt_constant_variable.cpp \ - opt_copy_propagation.cpp \ - opt_copy_propagation_elements.cpp \ - opt_dead_code.cpp \ - opt_dead_code_local.cpp \ - opt_dead_functions.cpp \ - opt_discard_simplification.cpp \ - opt_function_inlining.cpp \ - opt_if_simplification.cpp \ - opt_noop_swizzle.cpp \ - opt_redundant_jumps.cpp \ - opt_structure_splitting.cpp \ - opt_swizzle_swizzle.cpp \ - opt_tree_grafting.cpp \ - s_expression.cpp - -LIBS = \ - $(TOP)/src/glsl/libglsl.a - -APPS = glsl_compiler glcpp/glcpp - -GLSL2_C_SOURCES = \ - ../mesa/program/hash_table.c \ - ../mesa/program/symbol_table.c -GLSL2_CXX_SOURCES = \ - main.cpp - -GLSL2_OBJECTS = \ - $(GLSL2_C_SOURCES:.c=.o) \ - $(GLSL2_CXX_SOURCES:.cpp=.o) - -### Basic defines ### - -DEFINES += \ - $(LIBRARY_DEFINES) \ - $(API_DEFINES) - -GLCPP_OBJECTS = \ - $(GLCPP_SOURCES:.c=.o) \ - ../mesa/program/hash_table.o - -OBJECTS = \ - $(C_SOURCES:.c=.o) \ - $(CXX_SOURCES:.cpp=.o) - -DRICORE_OBJ_DIR = obj-visible -OBJECTS_DRICORE = $(addprefix $(DRICORE_OBJ_DIR)/,$(OBJECTS)) - -INCLUDES = \ - -I. \ - -I../mesa \ - -I../mapi \ - -I../../include \ - $(LIBRARY_INCLUDES) - -ALL_SOURCES = \ - $(C_SOURCES) \ - $(CXX_SOURCES) \ - $(GLSL2_CXX_SOURCES) \ - $(GLSL2_C_SOURCES) - -##### TARGETS ##### - -default: depend lib$(LIBNAME).a $(APPS) $(DRICORE_GLSL_LIBS) - -$(TOP)/$(LIB_DIR)/libglsl.so: $(OBJECTS_DRICORE) builtin_function.o Makefile $(TOP)/src/glsl/Makefile.template - $(MKLIB) -o $@ -linker '$(CXX)' -ldflags '$(LDFLAGS)' \ - -cplusplus -noprefix \ - -install $(TOP)/$(LIB_DIR) -id $(INSTALL_LIB_DIR)/$@.dylib \ - $(OBJECTS_DRICORE) builtin_function.o - -lib$(LIBNAME).a: $(OBJECTS) builtin_function.o Makefile $(TOP)/src/glsl/Makefile.template - $(MKLIB) -cplusplus -o $(LIBNAME) -static $(OBJECTS) builtin_function.o - -depend: $(ALL_SOURCES) Makefile - rm -f depend - touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(ALL_SOURCES) 2> /dev/null - -# Remove .o and backup files -clean: clean-dricore - rm -f $(GLCPP_OBJECTS) $(GLSL2_OBJECTS) $(OBJECTS) lib$(LIBNAME).a depend depend.bak builtin_function.cpp builtin_function.o builtin_stubs.o builtin_compiler - -rm -f $(APPS) - -clean-dricore: - -rm -f $(DRICORE_OBJ_DIR) $(TOP)/$(LIB_DIR)/libglsl.so libglsl.so - -ifneq (,$(DRICORE_GLSL_LIBS)) -DRICORE_INSTALL_TARGET = install-dricore -endif - -# Dummy target -install: $(DRICORE_INSTALL_TARGET) - @echo -n "" - -install-dricore: default - $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) - $(INSTALL) -m 755 $(DRICORE_GLSL_LIBS) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) - -##### RULES ##### - -glsl_compiler: $(GLSL2_OBJECTS) libglsl.a builtin_stubs.o - $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLSL2_OBJECTS) builtin_stubs.o $(LIBS) -o $@ - -glcpp: glcpp/glcpp -glcpp/glcpp: $(GLCPP_OBJECTS) - $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLCPP_OBJECTS) -o $@ - -.cpp.o: - $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< -o $@ - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ - -$(DRICORE_OBJ_DIR)/%.o : %.cpp - @mkdir -p $(dir $@) - $(CXX) -c $(INCLUDES) $(DRI_CXXFLAGS) $(DEFINES) $< -o $@ - -$(DRICORE_OBJ_DIR)/%.o : %.c - @mkdir -p $(dir $@) - $(CC) -c $(INCLUDES) $(DRI_CFLAGS) $(DEFINES) $< -o $@ - -glsl_lexer.cpp: glsl_lexer.lpp - flex --nounistd -o$@ $< - -glsl_parser.cpp: glsl_parser.ypp - bison -v -o "$@" -p "_mesa_glsl_" --defines=glsl_parser.h $< - -glcpp/glcpp-lex.c: glcpp/glcpp-lex.l - flex --nounistd -o$@ $< - -glcpp/glcpp-parse.c: glcpp/glcpp-parse.y - bison -v -o "$@" --defines=glcpp/glcpp-parse.h $< - -builtin_compiler: $(GLSL2_OBJECTS) $(OBJECTS) builtin_stubs.o - $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(GLSL2_OBJECTS) builtin_stubs.o -o $@ - -builtin_function.cpp: builtins/profiles/* builtins/ir/* builtins/tools/generate_builtins.py builtins/tools/texture_builtins.py builtin_compiler - @echo Regenerating builtin_function.cpp... - $(PYTHON2) $(PYTHON_FLAGS) builtins/tools/generate_builtins.py ./builtin_compiler > builtin_function.cpp - --include depend + +#src/glsl/pp/Makefile + +TOP = ../.. + +include $(TOP)/configs/current + +LIBNAME = glsl + +LIBGLCPP_SOURCES = \ + glcpp/glcpp-lex.c \ + glcpp/glcpp-parse.c \ + glcpp/pp.c + +GLCPP_SOURCES = \ + $(LIBGLCPP_SOURCES) \ + ralloc.c \ + glcpp/glcpp.c + +C_SOURCES = \ + strtod.c \ + ralloc.c \ + $(LIBGLCPP_SOURCES) + +CXX_SOURCES = \ + ast_expr.cpp \ + ast_function.cpp \ + ast_to_hir.cpp \ + ast_type.cpp \ + glsl_lexer.cpp \ + glsl_parser.cpp \ + glsl_parser_extras.cpp \ + glsl_types.cpp \ + glsl_symbol_table.cpp \ + hir_field_selection.cpp \ + ir_basic_block.cpp \ + ir_clone.cpp \ + ir_constant_expression.cpp \ + ir.cpp \ + ir_expression_flattening.cpp \ + ir_function_can_inline.cpp \ + ir_function.cpp \ + ir_hierarchical_visitor.cpp \ + ir_hv_accept.cpp \ + ir_import_prototypes.cpp \ + ir_print_visitor.cpp \ + ir_reader.cpp \ + ir_rvalue_visitor.cpp \ + ir_set_program_inouts.cpp \ + ir_validate.cpp \ + ir_variable.cpp \ + ir_variable_refcount.cpp \ + linker.cpp \ + link_functions.cpp \ + loop_analysis.cpp \ + loop_controls.cpp \ + loop_unroll.cpp \ + lower_discard.cpp \ + lower_if_to_cond_assign.cpp \ + lower_instructions.cpp \ + lower_jumps.cpp \ + lower_mat_op_to_vec.cpp \ + lower_noise.cpp \ + lower_texture_projection.cpp \ + lower_variable_index_to_cond_assign.cpp \ + lower_vec_index_to_cond_assign.cpp \ + lower_vec_index_to_swizzle.cpp \ + lower_vector.cpp \ + opt_algebraic.cpp \ + opt_constant_folding.cpp \ + opt_constant_propagation.cpp \ + opt_constant_variable.cpp \ + opt_copy_propagation.cpp \ + opt_copy_propagation_elements.cpp \ + opt_dead_code.cpp \ + opt_dead_code_local.cpp \ + opt_dead_functions.cpp \ + opt_discard_simplification.cpp \ + opt_function_inlining.cpp \ + opt_if_simplification.cpp \ + opt_noop_swizzle.cpp \ + opt_redundant_jumps.cpp \ + opt_structure_splitting.cpp \ + opt_swizzle_swizzle.cpp \ + opt_tree_grafting.cpp \ + s_expression.cpp + +LIBS = \ + $(TOP)/src/glsl/libglsl.a + +APPS = glsl_compiler glcpp/glcpp + +GLSL2_C_SOURCES = \ + ../mesa/program/hash_table.c \ + ../mesa/program/symbol_table.c +GLSL2_CXX_SOURCES = \ + main.cpp + +GLSL2_OBJECTS = \ + $(GLSL2_C_SOURCES:.c=.o) \ + $(GLSL2_CXX_SOURCES:.cpp=.o) + +### Basic defines ### + +DEFINES += \ + $(LIBRARY_DEFINES) \ + $(API_DEFINES) + +GLCPP_OBJECTS = \ + $(GLCPP_SOURCES:.c=.o) \ + ../mesa/program/hash_table.o + +OBJECTS = \ + $(C_SOURCES:.c=.o) \ + $(CXX_SOURCES:.cpp=.o) + +DRICORE_OBJ_DIR = obj-visible +OBJECTS_DRICORE = $(addprefix $(DRICORE_OBJ_DIR)/,$(OBJECTS)) + +INCLUDES = \ + -I. \ + -I../mesa \ + -I../mapi \ + -I../../include \ + $(LIBRARY_INCLUDES) + +ALL_SOURCES = \ + $(C_SOURCES) \ + $(CXX_SOURCES) \ + $(GLSL2_CXX_SOURCES) \ + $(GLSL2_C_SOURCES) + +##### TARGETS ##### + +default: depend lib$(LIBNAME).a $(APPS) $(DRICORE_GLSL_LIBS) + +$(TOP)/$(LIB_DIR)/libglsl.so: $(OBJECTS_DRICORE) builtin_function.o Makefile $(TOP)/src/glsl/Makefile.template + $(MKLIB) -o $@ -linker '$(CXX)' -ldflags '$(LDFLAGS)' \ + -cplusplus -noprefix \ + -install $(TOP)/$(LIB_DIR) -id $(INSTALL_LIB_DIR)/$@.dylib \ + $(OBJECTS_DRICORE) builtin_function.o + +lib$(LIBNAME).a: $(OBJECTS) builtin_function.o Makefile $(TOP)/src/glsl/Makefile.template + $(MKLIB) -cplusplus -o $(LIBNAME) -static $(OBJECTS) builtin_function.o + +depend: $(ALL_SOURCES) Makefile + rm -f depend + touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(ALL_SOURCES) 2> /dev/null + +# Remove .o and backup files +clean: clean-dricore + rm -f $(GLCPP_OBJECTS) $(GLSL2_OBJECTS) $(OBJECTS) lib$(LIBNAME).a depend depend.bak builtin_function.cpp builtin_function.o builtin_stubs.o builtin_compiler + -rm -f $(APPS) + +clean-dricore: + -rm -f $(DRICORE_OBJ_DIR) $(TOP)/$(LIB_DIR)/libglsl.so libglsl.so + +ifneq (,$(DRICORE_GLSL_LIBS)) +DRICORE_INSTALL_TARGET = install-dricore +endif + +# Dummy target +install: $(DRICORE_INSTALL_TARGET) + @echo -n "" + +install-dricore: default + $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + $(INSTALL) -m 755 $(DRICORE_GLSL_LIBS) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + +##### RULES ##### + +glsl_compiler: $(GLSL2_OBJECTS) libglsl.a builtin_stubs.o + $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLSL2_OBJECTS) builtin_stubs.o $(LIBS) -o $@ + +glcpp: glcpp/glcpp +glcpp/glcpp: $(GLCPP_OBJECTS) + $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLCPP_OBJECTS) -o $@ + +.cpp.o: + $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< -o $@ + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +$(DRICORE_OBJ_DIR)/%.o : %.cpp + @mkdir -p $(dir $@) + $(CXX) -c $(INCLUDES) $(DRI_CXXFLAGS) $(DEFINES) $< -o $@ + +$(DRICORE_OBJ_DIR)/%.o : %.c + @mkdir -p $(dir $@) + $(CC) -c $(INCLUDES) $(DRI_CFLAGS) $(DEFINES) $< -o $@ + +glsl_lexer.cpp: glsl_lexer.lpp + flex --nounistd -o$@ $< + +glsl_parser.cpp: glsl_parser.ypp + bison -v -o "$@" -p "_mesa_glsl_" --defines=glsl_parser.h $< + +glcpp/glcpp-lex.c: glcpp/glcpp-lex.l + flex --nounistd -o$@ $< + +glcpp/glcpp-parse.c: glcpp/glcpp-parse.y + bison -v -o "$@" --defines=glcpp/glcpp-parse.h $< + +builtin_compiler: $(GLSL2_OBJECTS) $(OBJECTS) builtin_stubs.o + $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(GLSL2_OBJECTS) builtin_stubs.o -o $@ + +builtin_function.cpp: builtins/profiles/* builtins/ir/* builtins/tools/generate_builtins.py builtins/tools/texture_builtins.py builtin_compiler + @echo Regenerating builtin_function.cpp... + $(PYTHON2) $(PYTHON_FLAGS) builtins/tools/generate_builtins.py ./builtin_compiler > builtin_function.cpp || rm -f builtin_function.cpp + +-include depend diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c index 9f58b45e2..310740b0d 100644 --- a/mesalib/src/mesa/main/extensions.c +++ b/mesalib/src/mesa/main/extensions.c @@ -1,915 +1,916 @@ -/* - * Mesa 3-D graphics library - * Version: 7.6 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file - * \brief Extension handling - */ - - -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "extensions.h" -#include "mfeatures.h" -#include "mtypes.h" - -enum { - DISABLE = 0, - GL = 1 << API_OPENGL, - ES1 = 1 << API_OPENGLES, - ES2 = 1 << API_OPENGLES2, -}; - -/** - * \brief An element of the \c extension_table. - */ -struct extension { - /** Name of extension, such as "GL_ARB_depth_clamp". */ - const char *name; - - /** Offset (in bytes) of the corresponding member in struct gl_extensions. */ - size_t offset; - - /** Set of API's in which the extension exists, as a bitset. */ - uint8_t api_set; -}; - - -/** - * Given a member \c x of struct gl_extensions, return offset of - * \c x in bytes. - */ -#define o(x) offsetof(struct gl_extensions, x) - - -/** - * \brief Table of supported OpenGL extensions for all API's. - * - * Note: The GL_MESAX_* extensions are placeholders for future ARB extensions. - */ -static const struct extension extension_table[] = { - /* ARB Extensions */ - { "GL_ARB_ES2_compatibility", o(ARB_ES2_compatibility), GL }, - { "GL_ARB_blend_func_extended", o(ARB_blend_func_extended), GL }, - { "GL_ARB_copy_buffer", o(ARB_copy_buffer), GL }, - { "GL_ARB_depth_buffer_float", o(ARB_depth_buffer_float), GL }, - { "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL }, - { "GL_ARB_depth_texture", o(ARB_depth_texture), GL }, - { "GL_ARB_draw_buffers", o(ARB_draw_buffers), GL }, - { "GL_ARB_draw_buffers_blend", o(ARB_draw_buffers_blend), GL }, - { "GL_ARB_draw_elements_base_vertex", o(ARB_draw_elements_base_vertex), GL }, - { "GL_ARB_draw_instanced", o(ARB_draw_instanced), GL }, - { "GL_ARB_explicit_attrib_location", o(ARB_explicit_attrib_location), GL }, - { "GL_ARB_fragment_coord_conventions", o(ARB_fragment_coord_conventions), GL }, - { "GL_ARB_fragment_program", o(ARB_fragment_program), GL }, - { "GL_ARB_fragment_program_shadow", o(ARB_fragment_program_shadow), GL }, - { "GL_ARB_fragment_shader", o(ARB_fragment_shader), GL }, - { "GL_ARB_framebuffer_object", o(ARB_framebuffer_object), GL }, - { "GL_ARB_framebuffer_sRGB", o(EXT_framebuffer_sRGB), GL }, - { "GL_ARB_half_float_pixel", o(ARB_half_float_pixel), GL }, - { "GL_ARB_half_float_vertex", o(ARB_half_float_vertex), GL }, - { "GL_ARB_instanced_arrays", o(ARB_instanced_arrays), GL }, - { "GL_ARB_map_buffer_range", o(ARB_map_buffer_range), GL }, - { "GL_ARB_multisample", o(ARB_multisample), GL }, - { "GL_ARB_multitexture", o(ARB_multitexture), GL }, - { "GL_ARB_occlusion_query2", o(ARB_occlusion_query2), GL }, - { "GL_ARB_occlusion_query", o(ARB_occlusion_query), GL }, - { "GL_ARB_pixel_buffer_object", o(EXT_pixel_buffer_object), GL }, - { "GL_ARB_point_parameters", o(EXT_point_parameters), GL }, - { "GL_ARB_point_sprite", o(ARB_point_sprite), GL }, - { "GL_ARB_provoking_vertex", o(EXT_provoking_vertex), GL }, - { "GL_ARB_sampler_objects", o(ARB_sampler_objects), GL }, - { "GL_ARB_seamless_cube_map", o(ARB_seamless_cube_map), GL }, - { "GL_ARB_shader_objects", o(ARB_shader_objects), GL }, - { "GL_ARB_shader_stencil_export", o(ARB_shader_stencil_export), GL }, - { "GL_ARB_shading_language_100", o(ARB_shading_language_100), GL }, - { "GL_ARB_shadow_ambient", o(ARB_shadow_ambient), GL }, - { "GL_ARB_shadow", o(ARB_shadow), GL }, - { "GL_ARB_sync", o(ARB_sync), GL }, - { "GL_ARB_texture_border_clamp", o(ARB_texture_border_clamp), GL }, - { "GL_ARB_texture_buffer_object", o(ARB_texture_buffer_object), GL }, - { "GL_ARB_texture_compression", o(ARB_texture_compression), GL }, - { "GL_ARB_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL }, - { "GL_ARB_texture_cube_map", o(ARB_texture_cube_map), GL }, - { "GL_ARB_texture_env_add", o(EXT_texture_env_add), GL }, - { "GL_ARB_texture_env_combine", o(ARB_texture_env_combine), GL }, - { "GL_ARB_texture_env_crossbar", o(ARB_texture_env_crossbar), GL }, - { "GL_ARB_texture_env_dot3", o(ARB_texture_env_dot3), GL }, - { "GL_ARB_texture_mirrored_repeat", o(ARB_texture_mirrored_repeat), GL }, - { "GL_ARB_texture_multisample", o(ARB_texture_multisample), GL }, - { "GL_ARB_texture_non_power_of_two", o(ARB_texture_non_power_of_two), GL }, - { "GL_ARB_texture_rectangle", o(NV_texture_rectangle), GL }, - { "GL_ARB_texture_rgb10_a2ui", o(ARB_texture_rgb10_a2ui), GL }, - { "GL_ARB_texture_rg", o(ARB_texture_rg), GL }, - { "GL_ARB_texture_swizzle", o(EXT_texture_swizzle), GL }, - { "GL_ARB_transform_feedback2", o(ARB_transform_feedback2), GL }, - { "GL_ARB_transpose_matrix", o(ARB_transpose_matrix), GL }, - { "GL_ARB_uniform_buffer_object", o(ARB_uniform_buffer_object), GL }, - { "GL_ARB_vertex_array_bgra", o(EXT_vertex_array_bgra), GL }, - { "GL_ARB_vertex_array_object", o(ARB_vertex_array_object), GL }, - { "GL_ARB_vertex_buffer_object", o(ARB_vertex_buffer_object), GL }, - { "GL_ARB_vertex_program", o(ARB_vertex_program), GL }, - { "GL_ARB_vertex_shader", o(ARB_vertex_shader), GL }, - { "GL_ARB_vertex_type_2_10_10_10_rev", o(ARB_vertex_type_2_10_10_10_rev), GL }, - { "GL_ARB_window_pos", o(ARB_window_pos), GL }, - - /* EXT extensions */ - { "GL_EXT_abgr", o(EXT_abgr), GL }, - { "GL_EXT_bgra", o(EXT_bgra), GL }, - { "GL_EXT_blend_color", o(EXT_blend_color), GL }, - { "GL_EXT_blend_equation_separate", o(EXT_blend_equation_separate), GL }, - { "GL_EXT_blend_func_separate", o(EXT_blend_func_separate), GL }, - { "GL_EXT_blend_logic_op", o(EXT_blend_logic_op), GL }, - { "GL_EXT_blend_minmax", o(EXT_blend_minmax), GL | ES1 | ES2 }, - { "GL_EXT_blend_subtract", o(EXT_blend_subtract), GL }, - { "GL_EXT_clip_volume_hint", o(EXT_clip_volume_hint), GL }, - { "GL_EXT_compiled_vertex_array", o(EXT_compiled_vertex_array), GL }, - { "GL_EXT_copy_texture", o(EXT_copy_texture), GL }, - { "GL_EXT_depth_bounds_test", o(EXT_depth_bounds_test), GL }, - { "GL_EXT_draw_buffers2", o(EXT_draw_buffers2), GL }, - { "GL_EXT_draw_instanced", o(ARB_draw_instanced), GL }, - { "GL_EXT_draw_range_elements", o(EXT_draw_range_elements), GL }, - { "GL_EXT_fog_coord", o(EXT_fog_coord), GL }, - { "GL_EXT_framebuffer_blit", o(EXT_framebuffer_blit), GL }, - { "GL_EXT_framebuffer_multisample", o(EXT_framebuffer_multisample), GL }, - { "GL_EXT_framebuffer_object", o(EXT_framebuffer_object), GL }, - { "GL_EXT_framebuffer_sRGB", o(EXT_framebuffer_sRGB), GL }, - { "GL_EXT_gpu_program_parameters", o(EXT_gpu_program_parameters), GL }, - { "GL_EXT_gpu_shader4", o(EXT_gpu_shader4), GL }, - { "GL_EXT_multi_draw_arrays", o(EXT_multi_draw_arrays), GL | ES1 | ES2 }, - { "GL_EXT_packed_depth_stencil", o(EXT_packed_depth_stencil), GL }, - { "GL_EXT_packed_float", o(EXT_packed_float), GL }, - { "GL_EXT_packed_pixels", o(EXT_packed_pixels), GL }, - { "GL_EXT_paletted_texture", o(EXT_paletted_texture), GL }, - { "GL_EXT_pixel_buffer_object", o(EXT_pixel_buffer_object), GL }, - { "GL_EXT_point_parameters", o(EXT_point_parameters), GL }, - { "GL_EXT_polygon_offset", o(EXT_polygon_offset), GL }, - { "GL_EXT_provoking_vertex", o(EXT_provoking_vertex), GL }, - { "GL_EXT_rescale_normal", o(EXT_rescale_normal), GL }, - { "GL_EXT_secondary_color", o(EXT_secondary_color), GL }, - { "GL_EXT_separate_shader_objects", o(EXT_separate_shader_objects), GL }, - { "GL_EXT_separate_specular_color", o(EXT_separate_specular_color), GL }, - { "GL_EXT_shadow_funcs", o(EXT_shadow_funcs), GL }, - { "GL_EXT_shared_texture_palette", o(EXT_shared_texture_palette), GL }, - { "GL_EXT_stencil_two_side", o(EXT_stencil_two_side), GL }, - { "GL_EXT_stencil_wrap", o(EXT_stencil_wrap), GL }, - { "GL_EXT_subtexture", o(EXT_subtexture), GL }, - { "GL_EXT_texture3D", o(EXT_texture3D), GL }, - { "GL_EXT_texture_array", o(EXT_texture_array), GL }, - { "GL_EXT_texture_compression_dxt1", o(EXT_texture_compression_s3tc), GL | ES1 | ES2 }, - { "GL_EXT_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL }, - { "GL_EXT_texture_compression_s3tc", o(EXT_texture_compression_s3tc), GL }, - { "GL_EXT_texture_cube_map", o(ARB_texture_cube_map), GL }, - { "GL_EXT_texture_edge_clamp", o(SGIS_texture_edge_clamp), GL }, - { "GL_EXT_texture_env_add", o(EXT_texture_env_add), GL }, - { "GL_EXT_texture_env_combine", o(EXT_texture_env_combine), GL }, - { "GL_EXT_texture_env_dot3", o(EXT_texture_env_dot3), GL }, - { "GL_EXT_texture_filter_anisotropic", o(EXT_texture_filter_anisotropic), GL | ES1 | ES2 }, - { "GL_EXT_texture_format_BGRA8888", o(EXT_texture_format_BGRA8888), ES1 | ES2 }, - { "GL_EXT_texture_integer", o(EXT_texture_integer), GL }, - { "GL_EXT_texture_lod_bias", o(EXT_texture_lod_bias), GL | ES1 }, - { "GL_EXT_texture_mirror_clamp", o(EXT_texture_mirror_clamp), GL }, - { "GL_EXT_texture_object", o(EXT_texture_object), GL }, - { "GL_EXT_texture", o(EXT_texture), GL }, - { "GL_EXT_texture_rectangle", o(NV_texture_rectangle), GL }, - { "GL_EXT_texture_shared_exponent", o(EXT_texture_shared_exponent), GL }, - { "GL_EXT_texture_sRGB", o(EXT_texture_sRGB), GL }, - { "GL_EXT_texture_sRGB_decode", o(EXT_texture_sRGB_decode), GL }, - { "GL_EXT_texture_swizzle", o(EXT_texture_swizzle), GL }, - { "GL_EXT_texture_type_2_10_10_10_REV", o(dummy_true), ES2 }, - { "GL_EXT_timer_query", o(EXT_timer_query), GL }, - { "GL_EXT_transform_feedback", o(EXT_transform_feedback), GL }, - { "GL_EXT_vertex_array_bgra", o(EXT_vertex_array_bgra), GL }, - { "GL_EXT_vertex_array", o(EXT_vertex_array), GL }, - { "GL_EXT_vertex_array_set", o(EXT_vertex_array_set), GL }, - - /* OES extensions */ - { "GL_OES_blend_equation_separate", o(EXT_blend_equation_separate), ES1 }, - { "GL_OES_blend_func_separate", o(EXT_blend_func_separate), ES1 }, - { "GL_OES_blend_subtract", o(EXT_blend_subtract), ES1 }, - { "GL_OES_byte_coordinates", o(dummy_true), ES1 }, - { "GL_OES_compressed_paletted_texture", o(dummy_false), DISABLE }, - { "GL_OES_depth24", o(EXT_framebuffer_object), ES1 | ES2 }, - { "GL_OES_depth32", o(dummy_false), DISABLE }, - { "GL_OES_depth_texture", o(ARB_depth_texture), ES2 }, -#if FEATURE_OES_draw_texture - { "GL_OES_draw_texture", o(OES_draw_texture), ES1 | ES2 }, -#endif -#if FEATURE_OES_EGL_image - /* FIXME: Mesa expects GL_OES_EGL_image to be available in OpenGL contexts. */ - { "GL_OES_EGL_image", o(OES_EGL_image), GL | ES1 | ES2 }, -#endif - { "GL_OES_element_index_uint", o(EXT_vertex_array), ES1 | ES2 }, - { "GL_OES_fbo_render_mipmap", o(EXT_framebuffer_object), ES1 | ES2 }, - { "GL_OES_fixed_point", o(dummy_true), ES1 }, - { "GL_OES_framebuffer_object", o(EXT_framebuffer_object), ES1 }, - { "GL_OES_mapbuffer", o(ARB_vertex_buffer_object), ES1 | ES2 }, - { "GL_OES_matrix_get", o(dummy_true), ES1 }, - { "GL_OES_packed_depth_stencil", o(EXT_packed_depth_stencil), ES1 | ES2 }, - { "GL_OES_point_size_array", o(dummy_true), ES1 }, - { "GL_OES_point_sprite", o(ARB_point_sprite), ES1 }, - { "GL_OES_query_matrix", o(dummy_true), ES1 }, - { "GL_OES_read_format", o(OES_read_format), GL | ES1 }, - { "GL_OES_rgb8_rgba8", o(EXT_framebuffer_object), ES1 | ES2 }, - { "GL_OES_single_precision", o(dummy_true), ES1 }, - { "GL_OES_standard_derivatives", o(OES_standard_derivatives), ES2 }, - { "GL_OES_stencil1", o(dummy_false), DISABLE }, - { "GL_OES_stencil4", o(dummy_false), DISABLE }, - { "GL_OES_stencil8", o(EXT_framebuffer_object), ES1 | ES2 }, - { "GL_OES_stencil_wrap", o(EXT_stencil_wrap), ES1 }, - /* GL_OES_texture_3D is disabled due to missing GLSL support. */ - { "GL_OES_texture_3D", o(EXT_texture3D), DISABLE }, - { "GL_OES_texture_cube_map", o(ARB_texture_cube_map), ES1 }, - { "GL_OES_texture_env_crossbar", o(ARB_texture_env_crossbar), ES1 }, - { "GL_OES_texture_mirrored_repeat", o(ARB_texture_mirrored_repeat), ES1 }, - { "GL_OES_texture_npot", o(ARB_texture_non_power_of_two), ES2 }, - - /* Vendor extensions */ - { "GL_3DFX_texture_compression_FXT1", o(TDFX_texture_compression_FXT1), GL }, - { "GL_AMD_conservative_depth", o(AMD_conservative_depth), GL }, - { "GL_APPLE_client_storage", o(APPLE_client_storage), GL }, - { "GL_APPLE_object_purgeable", o(APPLE_object_purgeable), GL }, - { "GL_APPLE_packed_pixels", o(APPLE_packed_pixels), GL }, - { "GL_APPLE_vertex_array_object", o(APPLE_vertex_array_object), GL }, - { "GL_ATI_blend_equation_separate", o(EXT_blend_equation_separate), GL }, - { "GL_ATI_envmap_bumpmap", o(ATI_envmap_bumpmap), GL }, - { "GL_ATI_fragment_shader", o(ATI_fragment_shader), GL }, - { "GL_ATI_separate_stencil", o(ATI_separate_stencil), GL }, - { "GL_ATI_texture_env_combine3", o(ATI_texture_env_combine3), GL }, - { "GL_ATI_texture_mirror_once", o(ATI_texture_mirror_once), GL }, - { "GL_IBM_multimode_draw_arrays", o(IBM_multimode_draw_arrays), GL }, - { "GL_IBM_rasterpos_clip", o(IBM_rasterpos_clip), GL }, - { "GL_IBM_texture_mirrored_repeat", o(ARB_texture_mirrored_repeat), GL }, - { "GL_INGR_blend_func_separate", o(EXT_blend_func_separate), GL }, - { "GL_MESA_pack_invert", o(MESA_pack_invert), GL }, - { "GL_MESA_resize_buffers", o(MESA_resize_buffers), GL }, - { "GL_MESA_texture_array", o(MESA_texture_array), GL }, - { "GL_MESA_texture_signed_rgba", o(MESA_texture_signed_rgba), GL }, - { "GL_MESA_window_pos", o(ARB_window_pos), GL }, - { "GL_MESAX_texture_float", o(ARB_texture_float), GL }, - { "GL_MESA_ycbcr_texture", o(MESA_ycbcr_texture), GL }, - { "GL_NV_blend_square", o(NV_blend_square), GL }, - { "GL_NV_conditional_render", o(NV_conditional_render), GL }, - { "GL_NV_depth_clamp", o(ARB_depth_clamp), GL }, - { "GL_NV_fragment_program", o(NV_fragment_program), GL }, - { "GL_NV_fragment_program_option", o(NV_fragment_program_option), GL }, - { "GL_NV_light_max_exponent", o(NV_light_max_exponent), GL }, - { "GL_NV_packed_depth_stencil", o(EXT_packed_depth_stencil), GL }, - { "GL_NV_point_sprite", o(NV_point_sprite), GL }, - { "GL_NV_primitive_restart", o(NV_primitive_restart), GL }, - { "GL_NV_texgen_reflection", o(NV_texgen_reflection), GL }, - { "GL_NV_texture_env_combine4", o(NV_texture_env_combine4), GL }, - { "GL_NV_texture_rectangle", o(NV_texture_rectangle), GL }, - { "GL_NV_vertex_program1_1", o(NV_vertex_program1_1), GL }, - { "GL_NV_vertex_program", o(NV_vertex_program), GL }, - { "GL_S3_s3tc", o(S3_s3tc), GL }, - { "GL_SGIS_generate_mipmap", o(SGIS_generate_mipmap), GL }, - { "GL_SGIS_texture_border_clamp", o(ARB_texture_border_clamp), GL }, - { "GL_SGIS_texture_edge_clamp", o(SGIS_texture_edge_clamp), GL }, - { "GL_SGIS_texture_lod", o(SGIS_texture_lod), GL }, - { "GL_SGI_texture_color_table", o(SGI_texture_color_table), GL }, - { "GL_SUN_multi_draw_arrays", o(EXT_multi_draw_arrays), GL }, - - { 0, 0, 0 }, -}; - - -/** - * Given an extension name, lookup up the corresponding member of struct - * gl_extensions and return that member's offset (in bytes). If the name is - * not found in the \c extension_table, return 0. - * - * \param name Name of extension. - * \return Offset of member in struct gl_extensions. - */ -static size_t -name_to_offset(const char* name) -{ - const struct extension *i; - - if (name == 0) - return 0; - - for (i = extension_table; i->name != 0; ++i) { - if (strcmp(name, i->name) == 0) - return i->offset; - } - - return 0; -} - - -/** - * \brief Extensions enabled by default. - * - * These extensions are enabled by _mesa_init_extensions(). - * - * XXX: Should these defaults also apply to GLES? - */ -static const size_t default_extensions[] = { - o(ARB_copy_buffer), - o(ARB_draw_buffers), - o(ARB_multisample), - o(ARB_texture_compression), - o(ARB_transpose_matrix), - o(ARB_vertex_buffer_object), - o(ARB_window_pos), - - o(EXT_abgr), - o(EXT_bgra), - o(EXT_compiled_vertex_array), - o(EXT_copy_texture), - o(EXT_draw_range_elements), - o(EXT_multi_draw_arrays), - o(EXT_packed_pixels), - o(EXT_polygon_offset), - o(EXT_rescale_normal), - o(EXT_separate_specular_color), - o(EXT_subtexture), - o(EXT_texture), - o(EXT_texture3D), - o(EXT_texture_object), - o(EXT_vertex_array), - - o(OES_read_format), - o(OES_standard_derivatives), - - /* Vendor Extensions */ - o(APPLE_packed_pixels), - o(IBM_multimode_draw_arrays), - o(IBM_rasterpos_clip), - o(NV_light_max_exponent), - o(NV_texgen_reflection), - o(SGIS_generate_mipmap), - o(SGIS_texture_edge_clamp), - o(SGIS_texture_lod), - - 0, -}; - - -/** - * Enable all extensions suitable for a software-only renderer. - * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc. - */ -void -_mesa_enable_sw_extensions(struct gl_context *ctx) -{ - /*ctx->Extensions.ARB_copy_buffer = GL_TRUE;*/ - ctx->Extensions.ARB_depth_clamp = GL_TRUE; - ctx->Extensions.ARB_depth_texture = GL_TRUE; - /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/ - ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE; - ctx->Extensions.ARB_draw_instanced = GL_TRUE; - ctx->Extensions.ARB_explicit_attrib_location = GL_TRUE; - ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; -#if FEATURE_ARB_fragment_program - ctx->Extensions.ARB_fragment_program = GL_TRUE; - ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE; -#endif -#if FEATURE_ARB_fragment_shader - ctx->Extensions.ARB_fragment_shader = GL_TRUE; -#endif -#if FEATURE_ARB_framebuffer_object - ctx->Extensions.ARB_framebuffer_object = GL_TRUE; -#endif -#if FEATURE_ARB_geometry_shader4 && 0 - /* XXX re-enable when GLSL compiler again supports geometry shaders */ - ctx->Extensions.ARB_geometry_shader4 = GL_TRUE; -#endif - ctx->Extensions.ARB_half_float_pixel = GL_TRUE; - ctx->Extensions.ARB_half_float_vertex = GL_TRUE; - ctx->Extensions.ARB_map_buffer_range = GL_TRUE; - ctx->Extensions.ARB_multitexture = GL_TRUE; -#if FEATURE_queryobj - ctx->Extensions.ARB_occlusion_query = GL_TRUE; - ctx->Extensions.ARB_occlusion_query2 = GL_TRUE; -#endif - ctx->Extensions.ARB_point_sprite = GL_TRUE; -#if FEATURE_ARB_shader_objects - ctx->Extensions.ARB_shader_objects = GL_TRUE; - ctx->Extensions.EXT_separate_shader_objects = GL_TRUE; -#endif -#if FEATURE_ARB_shading_language_100 - ctx->Extensions.ARB_shading_language_100 = GL_TRUE; -#endif - ctx->Extensions.ARB_shadow = GL_TRUE; - ctx->Extensions.ARB_shadow_ambient = GL_TRUE; - ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; - ctx->Extensions.ARB_texture_cube_map = GL_TRUE; - ctx->Extensions.ARB_texture_env_combine = GL_TRUE; - ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; - ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; - /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/ - ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; - ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; - ctx->Extensions.ARB_texture_rg = GL_TRUE; - ctx->Extensions.ARB_vertex_array_object = GL_TRUE; -#if FEATURE_ARB_vertex_program - ctx->Extensions.ARB_vertex_program = GL_TRUE; -#endif -#if FEATURE_ARB_vertex_shader - ctx->Extensions.ARB_vertex_shader = GL_TRUE; -#endif -#if FEATURE_ARB_vertex_buffer_object - /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ -#endif -#if FEATURE_ARB_sync - ctx->Extensions.ARB_sync = GL_TRUE; -#endif - ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; -#if FEATURE_APPLE_object_purgeable - ctx->Extensions.APPLE_object_purgeable = GL_TRUE; -#endif - ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE; -#if FEATURE_ATI_fragment_shader - ctx->Extensions.ATI_fragment_shader = GL_TRUE; -#endif - ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE; - ctx->Extensions.ATI_texture_mirror_once = GL_TRUE; - ctx->Extensions.ATI_separate_stencil = GL_TRUE; - ctx->Extensions.EXT_blend_color = GL_TRUE; - ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; - ctx->Extensions.EXT_blend_func_separate = GL_TRUE; - ctx->Extensions.EXT_blend_logic_op = GL_TRUE; - ctx->Extensions.EXT_blend_minmax = GL_TRUE; - ctx->Extensions.EXT_blend_subtract = GL_TRUE; - ctx->Extensions.EXT_depth_bounds_test = GL_TRUE; - ctx->Extensions.EXT_draw_buffers2 = GL_TRUE; - ctx->Extensions.EXT_fog_coord = GL_TRUE; -#if FEATURE_EXT_framebuffer_object - ctx->Extensions.EXT_framebuffer_object = GL_TRUE; -#endif -#if FEATURE_EXT_framebuffer_blit - ctx->Extensions.EXT_framebuffer_blit = GL_TRUE; -#endif -#if FEATURE_ARB_framebuffer_object - ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE; -#endif - /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/ - ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; - ctx->Extensions.EXT_paletted_texture = GL_TRUE; -#if FEATURE_EXT_pixel_buffer_object - ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; -#endif - ctx->Extensions.EXT_point_parameters = GL_TRUE; - ctx->Extensions.EXT_provoking_vertex = GL_TRUE; - ctx->Extensions.EXT_shadow_funcs = GL_TRUE; - ctx->Extensions.EXT_secondary_color = GL_TRUE; - ctx->Extensions.EXT_shared_texture_palette = GL_TRUE; - ctx->Extensions.EXT_stencil_wrap = GL_TRUE; - ctx->Extensions.EXT_stencil_two_side = GL_TRUE; - ctx->Extensions.EXT_texture_array = GL_TRUE; - ctx->Extensions.EXT_texture_env_add = GL_TRUE; - ctx->Extensions.EXT_texture_env_combine = GL_TRUE; - ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE; - ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE; - ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; -#if FEATURE_EXT_texture_sRGB - ctx->Extensions.EXT_texture_sRGB = GL_TRUE; - ctx->Extensions.EXT_texture_sRGB_decode = GL_TRUE; -#endif - ctx->Extensions.EXT_texture_swizzle = GL_TRUE; -#if FEATURE_EXT_transform_feedback - /*ctx->Extensions.EXT_transform_feedback = GL_TRUE;*/ -#endif - ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; - /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/ - ctx->Extensions.MESA_pack_invert = GL_TRUE; - ctx->Extensions.MESA_resize_buffers = GL_TRUE; - ctx->Extensions.MESA_texture_array = GL_TRUE; - ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; - ctx->Extensions.NV_blend_square = GL_TRUE; - ctx->Extensions.NV_conditional_render = GL_TRUE; - /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/ - ctx->Extensions.NV_point_sprite = GL_TRUE; - ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; - ctx->Extensions.NV_texture_rectangle = GL_TRUE; - /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/ -#if FEATURE_NV_vertex_program - ctx->Extensions.NV_vertex_program = GL_TRUE; - ctx->Extensions.NV_vertex_program1_1 = GL_TRUE; -#endif -#if FEATURE_NV_fragment_program - ctx->Extensions.NV_fragment_program = GL_TRUE; -#endif -#if FEATURE_NV_fragment_program && FEATURE_ARB_fragment_program - ctx->Extensions.NV_fragment_program_option = GL_TRUE; -#endif - ctx->Extensions.SGI_texture_color_table = GL_TRUE; - /*ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;*/ - ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE; -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE; -#endif -#if FEATURE_texture_fxt1 - _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1"); -#endif -#if FEATURE_texture_s3tc - if (ctx->Mesa_DXTn) { - _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); - _mesa_enable_extension(ctx, "GL_S3_s3tc"); - } -#endif -} - - -/** - * Enable common EXT extensions in the ARB_imaging subset. - */ -void -_mesa_enable_imaging_extensions(struct gl_context *ctx) -{ - ctx->Extensions.EXT_blend_color = GL_TRUE; - ctx->Extensions.EXT_blend_logic_op = GL_TRUE; - ctx->Extensions.EXT_blend_minmax = GL_TRUE; - ctx->Extensions.EXT_blend_subtract = GL_TRUE; -} - - - -/** - * Enable all OpenGL 1.3 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_1_3_extensions(struct gl_context *ctx) -{ - /*ctx->Extensions.ARB_multisample = GL_TRUE;*/ - ctx->Extensions.ARB_multitexture = GL_TRUE; - ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; - /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/ - ctx->Extensions.ARB_texture_cube_map = GL_TRUE; - ctx->Extensions.ARB_texture_env_combine = GL_TRUE; - ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; - ctx->Extensions.EXT_texture_env_add = GL_TRUE; - /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/ -} - - - -/** - * Enable all OpenGL 1.4 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_1_4_extensions(struct gl_context *ctx) -{ - ctx->Extensions.ARB_depth_texture = GL_TRUE; - ctx->Extensions.ARB_shadow = GL_TRUE; - ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; - ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; - ctx->Extensions.ARB_window_pos = GL_TRUE; - ctx->Extensions.EXT_blend_color = GL_TRUE; - ctx->Extensions.EXT_blend_func_separate = GL_TRUE; - ctx->Extensions.EXT_blend_minmax = GL_TRUE; - ctx->Extensions.EXT_blend_subtract = GL_TRUE; - ctx->Extensions.EXT_fog_coord = GL_TRUE; - /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/ - ctx->Extensions.EXT_point_parameters = GL_TRUE; - ctx->Extensions.EXT_secondary_color = GL_TRUE; - ctx->Extensions.EXT_stencil_wrap = GL_TRUE; - ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; - /*ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;*/ -} - - -/** - * Enable all OpenGL 1.5 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_1_5_extensions(struct gl_context *ctx) -{ - ctx->Extensions.ARB_occlusion_query = GL_TRUE; - /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ - ctx->Extensions.EXT_shadow_funcs = GL_TRUE; -} - - -/** - * Enable all OpenGL 2.0 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_2_0_extensions(struct gl_context *ctx) -{ - /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/ -#if FEATURE_ARB_fragment_shader - ctx->Extensions.ARB_fragment_shader = GL_TRUE; -#endif - ctx->Extensions.ARB_point_sprite = GL_TRUE; - ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; - ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; -#if FEATURE_ARB_shader_objects - ctx->Extensions.ARB_shader_objects = GL_TRUE; -#endif -#if FEATURE_ARB_shading_language_100 - ctx->Extensions.ARB_shading_language_100 = GL_TRUE; -#endif - ctx->Extensions.EXT_stencil_two_side = GL_TRUE; -#if FEATURE_ARB_vertex_shader - ctx->Extensions.ARB_vertex_shader = GL_TRUE; -#endif -} - - -/** - * Enable all OpenGL 2.1 features and extensions. - * A convenience function to be called by drivers. - */ -void -_mesa_enable_2_1_extensions(struct gl_context *ctx) -{ -#if FEATURE_EXT_pixel_buffer_object - ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; -#endif -#if FEATURE_EXT_texture_sRGB - ctx->Extensions.EXT_texture_sRGB = GL_TRUE; -#endif -} - - -/** - * Either enable or disable the named extension. - * \return GL_TRUE for success, GL_FALSE if invalid extension name - */ -static GLboolean -set_extension( struct gl_context *ctx, const char *name, GLboolean state ) -{ - size_t offset; - - if (ctx->Extensions.String) { - /* The string was already queried - can't change it now! */ - _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name); - return GL_FALSE; - } - - offset = name_to_offset(name); - if (offset == 0) { - _mesa_problem(ctx, "Trying to enable/disable unknown extension %s", - name); - return GL_FALSE; - } else if (offset == o(dummy_true) && state == GL_FALSE) { - _mesa_problem(ctx, "Trying to disable a permanently enabled extension: " - "%s", name); - return GL_FALSE; - } else { - GLboolean *base = (GLboolean *) &ctx->Extensions; - base[offset] = state; - return GL_TRUE; - } -} - - -/** - * Enable the named extension. - * Typically called by drivers. - */ -void -_mesa_enable_extension( struct gl_context *ctx, const char *name ) -{ - if (!set_extension(ctx, name, GL_TRUE)) - _mesa_problem(ctx, "Trying to enable unknown extension: %s", name); -} - - -/** - * Disable the named extension. - * XXX is this really needed??? - */ -void -_mesa_disable_extension( struct gl_context *ctx, const char *name ) -{ - if (!set_extension(ctx, name, GL_FALSE)) - _mesa_problem(ctx, "Trying to disable unknown extension: %s", name); -} - - -/** - * Test if the named extension is enabled in this context. - */ -GLboolean -_mesa_extension_is_enabled( struct gl_context *ctx, const char *name ) -{ - size_t offset; - GLboolean *base; - - if (name == 0) - return GL_FALSE; - - offset = name_to_offset(name); - if (offset == 0) - return GL_FALSE; - base = (GLboolean *) &ctx->Extensions; - return base[offset]; -} - - -/** - * \brief Apply the \c MESA_EXTENSION_OVERRIDE environment variable. - * - * \c MESA_EXTENSION_OVERRIDE is a space-separated list of extensions to - * enable or disable. The list is processed thus: - * - Enable recognized extension names that are prefixed with '+'. - * - Disable recognized extension names that are prefixed with '-'. - * - Enable recognized extension names that are not prefixed. - * - Collect unrecognized extension names in a new string. - * - * \return Space-separated list of unrecognized extension names (which must - * be freed). Does not return \c NULL. - */ -static char * -get_extension_override( struct gl_context *ctx ) -{ - const char *env_const= _mesa_getenv("MESA_EXTENSION_OVERRIDE"); - char *env; - char *ext; - char *extra_exts; - int len; - - if (env_const == NULL) { - /* Return the empty string rather than NULL. This simplifies the logic - * of client functions. */ - return calloc(1, sizeof(char)); - } - - /* extra_exts: List of unrecognized extensions. */ - extra_exts = calloc(strlen(env_const), sizeof(char)); - - /* Copy env_const because strtok() is destructive. */ - env = strdup(env_const); - for (ext = strtok(env, " "); ext != NULL; ext = strtok(NULL, " ")) { - int enable; - int recognized; - switch (ext[0]) { - case '+': - enable = 1; - ++ext; - break; - case '-': - enable = 0; - ++ext; - break; - default: - enable = 1; - break; - } - recognized = set_extension(ctx, ext, enable); - if (!recognized) { - strcat(extra_exts, ext); - strcat(extra_exts, " "); - } - } - - /* Remove trailing space. */ - len = strlen(extra_exts); - if (extra_exts[len - 1] == ' ') - extra_exts[len - 1] = '\0'; - - return extra_exts; -} - - -/** - * \brief Initialize extension tables and enable default extensions. - * - * This should be called during context initialization. - * Note: Sets gl_extensions.dummy_true to true. - */ -void -_mesa_init_extensions( struct gl_context *ctx ) -{ - GLboolean *base = (GLboolean *) &ctx->Extensions; - GLboolean *sentinel = base + o(extension_sentinel); - GLboolean *i; - const size_t *j; - - /* First, turn all extensions off. */ - for (i = base; i != sentinel; ++i) - *i = GL_FALSE; - - /* Then, selectively turn default extensions on. */ - ctx->Extensions.dummy_true = GL_TRUE; - for (j = default_extensions; *j != 0; ++j) - base[*j] = GL_TRUE; -} - - -/** - * Construct the GL_EXTENSIONS string. Called the first time that - * glGetString(GL_EXTENSIONS) is called. - */ -GLubyte* -_mesa_make_extension_string(struct gl_context *ctx) -{ - /* The extension string. */ - char *exts = 0; - /* Length of extension string. */ - size_t length = 0; - /* String of extra extensions. */ - char *extra_extensions = get_extension_override(ctx); - GLboolean *base = (GLboolean *) &ctx->Extensions; - const struct extension *i; - - /* Compute length of the extension string. */ - for (i = extension_table; i->name != 0; ++i) { - if (base[i->offset] && (i->api_set & (1 << ctx->API))) { - length += strlen(i->name) + 1; /* +1 for space */ - } - } - if (extra_extensions != NULL) - length += 1 + strlen(extra_extensions); /* +1 for space */ - - exts = (char *) calloc(length + 1, sizeof(char)); - if (exts == NULL) { - free(extra_extensions); - return NULL; - } - - /* Build the extension string.*/ - for (i = extension_table; i->name != 0; ++i) { - if (base[i->offset] && (i->api_set & (1 << ctx->API))) { - strcat(exts, i->name); - strcat(exts, " "); - } - } - if (extra_extensions != 0) { - strcat(exts, extra_extensions); - free(extra_extensions); - } - - return (GLubyte *) exts; -} - -/** - * Return number of enabled extensions. - */ -GLuint -_mesa_get_extension_count(struct gl_context *ctx) -{ - GLboolean *base; - const struct extension *i; - - /* only count once */ - if (ctx->Extensions.Count != 0) - return ctx->Extensions.Count; - - base = (GLboolean *) &ctx->Extensions; - for (i = extension_table; i->name != 0; ++i) { - if (base[i->offset]) { - ctx->Extensions.Count++; - } - } - return ctx->Extensions.Count; -} - -/** - * Return name of i-th enabled extension - */ -const GLubyte * -_mesa_get_enabled_extension(struct gl_context *ctx, GLuint index) -{ - const GLboolean *base; - size_t n; - const struct extension *i; - - if (index < 0) - return NULL; - - base = (GLboolean*) &ctx->Extensions; - n = 0; - for (i = extension_table; i->name != 0; ++i) { - if (n == index && base[i->offset]) { - return (GLubyte*) i->name; - } else if (base[i->offset]) { - ++n; - } - } - - return NULL; -} +/* + * Mesa 3-D graphics library + * Version: 7.6 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file + * \brief Extension handling + */ + + +#include "glheader.h" +#include "imports.h" +#include "context.h" +#include "extensions.h" +#include "mfeatures.h" +#include "mtypes.h" + +enum { + DISABLE = 0, + GL = 1 << API_OPENGL, + ES1 = 1 << API_OPENGLES, + ES2 = 1 << API_OPENGLES2, +}; + +/** + * \brief An element of the \c extension_table. + */ +struct extension { + /** Name of extension, such as "GL_ARB_depth_clamp". */ + const char *name; + + /** Offset (in bytes) of the corresponding member in struct gl_extensions. */ + size_t offset; + + /** Set of API's in which the extension exists, as a bitset. */ + uint8_t api_set; +}; + + +/** + * Given a member \c x of struct gl_extensions, return offset of + * \c x in bytes. + */ +#define o(x) offsetof(struct gl_extensions, x) + + +/** + * \brief Table of supported OpenGL extensions for all API's. + * + * Note: The GL_MESAX_* extensions are placeholders for future ARB extensions. + */ +static const struct extension extension_table[] = { + /* ARB Extensions */ + { "GL_ARB_ES2_compatibility", o(ARB_ES2_compatibility), GL }, + { "GL_ARB_blend_func_extended", o(ARB_blend_func_extended), GL }, + { "GL_ARB_copy_buffer", o(ARB_copy_buffer), GL }, + { "GL_ARB_depth_buffer_float", o(ARB_depth_buffer_float), GL }, + { "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL }, + { "GL_ARB_depth_texture", o(ARB_depth_texture), GL }, + { "GL_ARB_draw_buffers", o(ARB_draw_buffers), GL }, + { "GL_ARB_draw_buffers_blend", o(ARB_draw_buffers_blend), GL }, + { "GL_ARB_draw_elements_base_vertex", o(ARB_draw_elements_base_vertex), GL }, + { "GL_ARB_draw_instanced", o(ARB_draw_instanced), GL }, + { "GL_ARB_explicit_attrib_location", o(ARB_explicit_attrib_location), GL }, + { "GL_ARB_fragment_coord_conventions", o(ARB_fragment_coord_conventions), GL }, + { "GL_ARB_fragment_program", o(ARB_fragment_program), GL }, + { "GL_ARB_fragment_program_shadow", o(ARB_fragment_program_shadow), GL }, + { "GL_ARB_fragment_shader", o(ARB_fragment_shader), GL }, + { "GL_ARB_framebuffer_object", o(ARB_framebuffer_object), GL }, + { "GL_ARB_framebuffer_sRGB", o(EXT_framebuffer_sRGB), GL }, + { "GL_ARB_half_float_pixel", o(ARB_half_float_pixel), GL }, + { "GL_ARB_half_float_vertex", o(ARB_half_float_vertex), GL }, + { "GL_ARB_instanced_arrays", o(ARB_instanced_arrays), GL }, + { "GL_ARB_map_buffer_range", o(ARB_map_buffer_range), GL }, + { "GL_ARB_multisample", o(ARB_multisample), GL }, + { "GL_ARB_multitexture", o(ARB_multitexture), GL }, + { "GL_ARB_occlusion_query2", o(ARB_occlusion_query2), GL }, + { "GL_ARB_occlusion_query", o(ARB_occlusion_query), GL }, + { "GL_ARB_pixel_buffer_object", o(EXT_pixel_buffer_object), GL }, + { "GL_ARB_point_parameters", o(EXT_point_parameters), GL }, + { "GL_ARB_point_sprite", o(ARB_point_sprite), GL }, + { "GL_ARB_provoking_vertex", o(EXT_provoking_vertex), GL }, + { "GL_ARB_sampler_objects", o(ARB_sampler_objects), GL }, + { "GL_ARB_seamless_cube_map", o(ARB_seamless_cube_map), GL }, + { "GL_ARB_shader_objects", o(ARB_shader_objects), GL }, + { "GL_ARB_shader_stencil_export", o(ARB_shader_stencil_export), GL }, + { "GL_ARB_shading_language_100", o(ARB_shading_language_100), GL }, + { "GL_ARB_shadow_ambient", o(ARB_shadow_ambient), GL }, + { "GL_ARB_shadow", o(ARB_shadow), GL }, + { "GL_ARB_sync", o(ARB_sync), GL }, + { "GL_ARB_texture_border_clamp", o(ARB_texture_border_clamp), GL }, + { "GL_ARB_texture_buffer_object", o(ARB_texture_buffer_object), GL }, + { "GL_ARB_texture_compression", o(ARB_texture_compression), GL }, + { "GL_ARB_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL }, + { "GL_ARB_texture_cube_map", o(ARB_texture_cube_map), GL }, + { "GL_ARB_texture_env_add", o(EXT_texture_env_add), GL }, + { "GL_ARB_texture_env_combine", o(ARB_texture_env_combine), GL }, + { "GL_ARB_texture_env_crossbar", o(ARB_texture_env_crossbar), GL }, + { "GL_ARB_texture_env_dot3", o(ARB_texture_env_dot3), GL }, + { "GL_ARB_texture_mirrored_repeat", o(ARB_texture_mirrored_repeat), GL }, + { "GL_ARB_texture_multisample", o(ARB_texture_multisample), GL }, + { "GL_ARB_texture_non_power_of_two", o(ARB_texture_non_power_of_two), GL }, + { "GL_ARB_texture_rectangle", o(NV_texture_rectangle), GL }, + { "GL_ARB_texture_rgb10_a2ui", o(ARB_texture_rgb10_a2ui), GL }, + { "GL_ARB_texture_rg", o(ARB_texture_rg), GL }, + { "GL_ARB_texture_swizzle", o(EXT_texture_swizzle), GL }, + { "GL_ARB_transform_feedback2", o(ARB_transform_feedback2), GL }, + { "GL_ARB_transpose_matrix", o(ARB_transpose_matrix), GL }, + { "GL_ARB_uniform_buffer_object", o(ARB_uniform_buffer_object), GL }, + { "GL_ARB_vertex_array_bgra", o(EXT_vertex_array_bgra), GL }, + { "GL_ARB_vertex_array_object", o(ARB_vertex_array_object), GL }, + { "GL_ARB_vertex_buffer_object", o(ARB_vertex_buffer_object), GL }, + { "GL_ARB_vertex_program", o(ARB_vertex_program), GL }, + { "GL_ARB_vertex_shader", o(ARB_vertex_shader), GL }, + { "GL_ARB_vertex_type_2_10_10_10_rev", o(ARB_vertex_type_2_10_10_10_rev), GL }, + { "GL_ARB_window_pos", o(ARB_window_pos), GL }, + + /* EXT extensions */ + { "GL_EXT_abgr", o(EXT_abgr), GL }, + { "GL_EXT_bgra", o(EXT_bgra), GL }, + { "GL_EXT_blend_color", o(EXT_blend_color), GL }, + { "GL_EXT_blend_equation_separate", o(EXT_blend_equation_separate), GL }, + { "GL_EXT_blend_func_separate", o(EXT_blend_func_separate), GL }, + { "GL_EXT_blend_logic_op", o(EXT_blend_logic_op), GL }, + { "GL_EXT_blend_minmax", o(EXT_blend_minmax), GL | ES1 | ES2 }, + { "GL_EXT_blend_subtract", o(EXT_blend_subtract), GL }, + { "GL_EXT_clip_volume_hint", o(EXT_clip_volume_hint), GL }, + { "GL_EXT_compiled_vertex_array", o(EXT_compiled_vertex_array), GL }, + { "GL_EXT_copy_texture", o(EXT_copy_texture), GL }, + { "GL_EXT_depth_bounds_test", o(EXT_depth_bounds_test), GL }, + { "GL_EXT_draw_buffers2", o(EXT_draw_buffers2), GL }, + { "GL_EXT_draw_instanced", o(ARB_draw_instanced), GL }, + { "GL_EXT_draw_range_elements", o(EXT_draw_range_elements), GL }, + { "GL_EXT_fog_coord", o(EXT_fog_coord), GL }, + { "GL_EXT_framebuffer_blit", o(EXT_framebuffer_blit), GL }, + { "GL_EXT_framebuffer_multisample", o(EXT_framebuffer_multisample), GL }, + { "GL_EXT_framebuffer_object", o(EXT_framebuffer_object), GL }, + { "GL_EXT_framebuffer_sRGB", o(EXT_framebuffer_sRGB), GL }, + { "GL_EXT_gpu_program_parameters", o(EXT_gpu_program_parameters), GL }, + { "GL_EXT_gpu_shader4", o(EXT_gpu_shader4), GL }, + { "GL_EXT_multi_draw_arrays", o(EXT_multi_draw_arrays), GL | ES1 | ES2 }, + { "GL_EXT_packed_depth_stencil", o(EXT_packed_depth_stencil), GL }, + { "GL_EXT_packed_float", o(EXT_packed_float), GL }, + { "GL_EXT_packed_pixels", o(EXT_packed_pixels), GL }, + { "GL_EXT_paletted_texture", o(EXT_paletted_texture), GL }, + { "GL_EXT_pixel_buffer_object", o(EXT_pixel_buffer_object), GL }, + { "GL_EXT_point_parameters", o(EXT_point_parameters), GL }, + { "GL_EXT_polygon_offset", o(EXT_polygon_offset), GL }, + { "GL_EXT_provoking_vertex", o(EXT_provoking_vertex), GL }, + { "GL_EXT_rescale_normal", o(EXT_rescale_normal), GL }, + { "GL_EXT_secondary_color", o(EXT_secondary_color), GL }, + { "GL_EXT_separate_shader_objects", o(EXT_separate_shader_objects), GL }, + { "GL_EXT_separate_specular_color", o(EXT_separate_specular_color), GL }, + { "GL_EXT_shadow_funcs", o(EXT_shadow_funcs), GL }, + { "GL_EXT_shared_texture_palette", o(EXT_shared_texture_palette), GL }, + { "GL_EXT_stencil_two_side", o(EXT_stencil_two_side), GL }, + { "GL_EXT_stencil_wrap", o(EXT_stencil_wrap), GL }, + { "GL_EXT_subtexture", o(EXT_subtexture), GL }, + { "GL_EXT_texture3D", o(EXT_texture3D), GL }, + { "GL_EXT_texture_array", o(EXT_texture_array), GL }, + { "GL_EXT_texture_compression_dxt1", o(EXT_texture_compression_s3tc), GL | ES1 | ES2 }, + { "GL_EXT_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL }, + { "GL_EXT_texture_compression_s3tc", o(EXT_texture_compression_s3tc), GL }, + { "GL_EXT_texture_cube_map", o(ARB_texture_cube_map), GL }, + { "GL_EXT_texture_edge_clamp", o(SGIS_texture_edge_clamp), GL }, + { "GL_EXT_texture_env_add", o(EXT_texture_env_add), GL }, + { "GL_EXT_texture_env_combine", o(EXT_texture_env_combine), GL }, + { "GL_EXT_texture_env_dot3", o(EXT_texture_env_dot3), GL }, + { "GL_EXT_texture_filter_anisotropic", o(EXT_texture_filter_anisotropic), GL | ES1 | ES2 }, + { "GL_EXT_texture_format_BGRA8888", o(EXT_texture_format_BGRA8888), ES1 | ES2 }, + { "GL_EXT_texture_integer", o(EXT_texture_integer), GL }, + { "GL_EXT_texture_lod_bias", o(EXT_texture_lod_bias), GL | ES1 }, + { "GL_EXT_texture_mirror_clamp", o(EXT_texture_mirror_clamp), GL }, + { "GL_EXT_texture_object", o(EXT_texture_object), GL }, + { "GL_EXT_texture", o(EXT_texture), GL }, + { "GL_EXT_texture_rectangle", o(NV_texture_rectangle), GL }, + { "GL_EXT_texture_shared_exponent", o(EXT_texture_shared_exponent), GL }, + { "GL_EXT_texture_sRGB", o(EXT_texture_sRGB), GL }, + { "GL_EXT_texture_sRGB_decode", o(EXT_texture_sRGB_decode), GL }, + { "GL_EXT_texture_swizzle", o(EXT_texture_swizzle), GL }, + { "GL_EXT_texture_type_2_10_10_10_REV", o(dummy_true), ES2 }, + { "GL_EXT_timer_query", o(EXT_timer_query), GL }, + { "GL_EXT_transform_feedback", o(EXT_transform_feedback), GL }, + { "GL_EXT_vertex_array_bgra", o(EXT_vertex_array_bgra), GL }, + { "GL_EXT_vertex_array", o(EXT_vertex_array), GL }, + { "GL_EXT_vertex_array_set", o(EXT_vertex_array_set), GL }, + + /* OES extensions */ + { "GL_OES_blend_equation_separate", o(EXT_blend_equation_separate), ES1 }, + { "GL_OES_blend_func_separate", o(EXT_blend_func_separate), ES1 }, + { "GL_OES_blend_subtract", o(EXT_blend_subtract), ES1 }, + { "GL_OES_byte_coordinates", o(dummy_true), ES1 }, + { "GL_OES_compressed_paletted_texture", o(dummy_false), DISABLE }, + { "GL_OES_depth24", o(EXT_framebuffer_object), ES1 | ES2 }, + { "GL_OES_depth32", o(dummy_false), DISABLE }, + { "GL_OES_depth_texture", o(ARB_depth_texture), ES2 }, +#if FEATURE_OES_draw_texture + { "GL_OES_draw_texture", o(OES_draw_texture), ES1 | ES2 }, +#endif +#if FEATURE_OES_EGL_image + /* FIXME: Mesa expects GL_OES_EGL_image to be available in OpenGL contexts. */ + { "GL_OES_EGL_image", o(OES_EGL_image), GL | ES1 | ES2 }, +#endif + { "GL_OES_element_index_uint", o(EXT_vertex_array), ES1 | ES2 }, + { "GL_OES_fbo_render_mipmap", o(EXT_framebuffer_object), ES1 | ES2 }, + { "GL_OES_fixed_point", o(dummy_true), ES1 }, + { "GL_OES_framebuffer_object", o(EXT_framebuffer_object), ES1 }, + { "GL_OES_mapbuffer", o(ARB_vertex_buffer_object), ES1 | ES2 }, + { "GL_OES_matrix_get", o(dummy_true), ES1 }, + { "GL_OES_packed_depth_stencil", o(EXT_packed_depth_stencil), ES1 | ES2 }, + { "GL_OES_point_size_array", o(dummy_true), ES1 }, + { "GL_OES_point_sprite", o(ARB_point_sprite), ES1 }, + { "GL_OES_query_matrix", o(dummy_true), ES1 }, + { "GL_OES_read_format", o(OES_read_format), GL | ES1 }, + { "GL_OES_rgb8_rgba8", o(EXT_framebuffer_object), ES1 | ES2 }, + { "GL_OES_single_precision", o(dummy_true), ES1 }, + { "GL_OES_standard_derivatives", o(OES_standard_derivatives), ES2 }, + { "GL_OES_stencil1", o(dummy_false), DISABLE }, + { "GL_OES_stencil4", o(dummy_false), DISABLE }, + { "GL_OES_stencil8", o(EXT_framebuffer_object), ES1 | ES2 }, + { "GL_OES_stencil_wrap", o(EXT_stencil_wrap), ES1 }, + /* GL_OES_texture_3D is disabled due to missing GLSL support. */ + { "GL_OES_texture_3D", o(EXT_texture3D), DISABLE }, + { "GL_OES_texture_cube_map", o(ARB_texture_cube_map), ES1 }, + { "GL_OES_texture_env_crossbar", o(ARB_texture_env_crossbar), ES1 }, + { "GL_OES_texture_mirrored_repeat", o(ARB_texture_mirrored_repeat), ES1 }, + { "GL_OES_texture_npot", o(ARB_texture_non_power_of_two), ES2 }, + + /* Vendor extensions */ + { "GL_3DFX_texture_compression_FXT1", o(TDFX_texture_compression_FXT1), GL }, + { "GL_AMD_conservative_depth", o(AMD_conservative_depth), GL }, + { "GL_APPLE_client_storage", o(APPLE_client_storage), GL }, + { "GL_APPLE_object_purgeable", o(APPLE_object_purgeable), GL }, + { "GL_APPLE_packed_pixels", o(APPLE_packed_pixels), GL }, + { "GL_APPLE_vertex_array_object", o(APPLE_vertex_array_object), GL }, + { "GL_ATI_blend_equation_separate", o(EXT_blend_equation_separate), GL }, + { "GL_ATI_envmap_bumpmap", o(ATI_envmap_bumpmap), GL }, + { "GL_ATI_fragment_shader", o(ATI_fragment_shader), GL }, + { "GL_ATI_separate_stencil", o(ATI_separate_stencil), GL }, + { "GL_ATI_texture_env_combine3", o(ATI_texture_env_combine3), GL }, + { "GL_ATI_texture_mirror_once", o(ATI_texture_mirror_once), GL }, + { "GL_IBM_multimode_draw_arrays", o(IBM_multimode_draw_arrays), GL }, + { "GL_IBM_rasterpos_clip", o(IBM_rasterpos_clip), GL }, + { "GL_IBM_texture_mirrored_repeat", o(ARB_texture_mirrored_repeat), GL }, + { "GL_INGR_blend_func_separate", o(EXT_blend_func_separate), GL }, + { "GL_MESA_pack_invert", o(MESA_pack_invert), GL }, + { "GL_MESA_resize_buffers", o(MESA_resize_buffers), GL }, + { "GL_MESA_texture_array", o(MESA_texture_array), GL }, + { "GL_MESA_texture_signed_rgba", o(MESA_texture_signed_rgba), GL }, + { "GL_MESA_window_pos", o(ARB_window_pos), GL }, + { "GL_MESAX_texture_float", o(ARB_texture_float), GL }, + { "GL_MESA_ycbcr_texture", o(MESA_ycbcr_texture), GL }, + { "GL_NV_blend_square", o(NV_blend_square), GL }, + { "GL_NV_conditional_render", o(NV_conditional_render), GL }, + { "GL_NV_depth_clamp", o(ARB_depth_clamp), GL }, + { "GL_NV_fragment_program", o(NV_fragment_program), GL }, + { "GL_NV_fragment_program_option", o(NV_fragment_program_option), GL }, + { "GL_NV_light_max_exponent", o(NV_light_max_exponent), GL }, + { "GL_NV_packed_depth_stencil", o(EXT_packed_depth_stencil), GL }, + { "GL_NV_point_sprite", o(NV_point_sprite), GL }, + { "GL_NV_primitive_restart", o(NV_primitive_restart), GL }, + { "GL_NV_texgen_reflection", o(NV_texgen_reflection), GL }, + { "GL_NV_texture_env_combine4", o(NV_texture_env_combine4), GL }, + { "GL_NV_texture_rectangle", o(NV_texture_rectangle), GL }, + { "GL_NV_vertex_program1_1", o(NV_vertex_program1_1), GL }, + { "GL_NV_vertex_program", o(NV_vertex_program), GL }, + { "GL_S3_s3tc", o(S3_s3tc), GL }, + { "GL_SGIS_generate_mipmap", o(SGIS_generate_mipmap), GL }, + { "GL_SGIS_texture_border_clamp", o(ARB_texture_border_clamp), GL }, + { "GL_SGIS_texture_edge_clamp", o(SGIS_texture_edge_clamp), GL }, + { "GL_SGIS_texture_lod", o(SGIS_texture_lod), GL }, + { "GL_SGI_texture_color_table", o(SGI_texture_color_table), GL }, + { "GL_SUN_multi_draw_arrays", o(EXT_multi_draw_arrays), GL }, + + { 0, 0, 0 }, +}; + + +/** + * Given an extension name, lookup up the corresponding member of struct + * gl_extensions and return that member's offset (in bytes). If the name is + * not found in the \c extension_table, return 0. + * + * \param name Name of extension. + * \return Offset of member in struct gl_extensions. + */ +static size_t +name_to_offset(const char* name) +{ + const struct extension *i; + + if (name == 0) + return 0; + + for (i = extension_table; i->name != 0; ++i) { + if (strcmp(name, i->name) == 0) + return i->offset; + } + + return 0; +} + + +/** + * \brief Extensions enabled by default. + * + * These extensions are enabled by _mesa_init_extensions(). + * + * XXX: Should these defaults also apply to GLES? + */ +static const size_t default_extensions[] = { + o(ARB_copy_buffer), + o(ARB_draw_buffers), + o(ARB_multisample), + o(ARB_texture_compression), + o(ARB_transpose_matrix), + o(ARB_vertex_buffer_object), + o(ARB_window_pos), + + o(EXT_abgr), + o(EXT_bgra), + o(EXT_compiled_vertex_array), + o(EXT_copy_texture), + o(EXT_draw_range_elements), + o(EXT_multi_draw_arrays), + o(EXT_packed_pixels), + o(EXT_polygon_offset), + o(EXT_rescale_normal), + o(EXT_separate_specular_color), + o(EXT_subtexture), + o(EXT_texture), + o(EXT_texture3D), + o(EXT_texture_object), + o(EXT_vertex_array), + + o(OES_read_format), + o(OES_standard_derivatives), + + /* Vendor Extensions */ + o(APPLE_packed_pixels), + o(IBM_multimode_draw_arrays), + o(IBM_rasterpos_clip), + o(NV_light_max_exponent), + o(NV_texgen_reflection), + o(SGIS_generate_mipmap), + o(SGIS_texture_edge_clamp), + o(SGIS_texture_lod), + + 0, +}; + + +/** + * Enable all extensions suitable for a software-only renderer. + * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc. + */ +void +_mesa_enable_sw_extensions(struct gl_context *ctx) +{ + /*ctx->Extensions.ARB_copy_buffer = GL_TRUE;*/ + ctx->Extensions.ARB_depth_clamp = GL_TRUE; + ctx->Extensions.ARB_depth_texture = GL_TRUE; + /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/ + ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE; + ctx->Extensions.ARB_draw_instanced = GL_TRUE; + ctx->Extensions.ARB_explicit_attrib_location = GL_TRUE; + ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; +#if FEATURE_ARB_fragment_program + ctx->Extensions.ARB_fragment_program = GL_TRUE; + ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE; +#endif +#if FEATURE_ARB_fragment_shader + ctx->Extensions.ARB_fragment_shader = GL_TRUE; +#endif +#if FEATURE_ARB_framebuffer_object + ctx->Extensions.ARB_framebuffer_object = GL_TRUE; +#endif +#if FEATURE_ARB_geometry_shader4 && 0 + /* XXX re-enable when GLSL compiler again supports geometry shaders */ + ctx->Extensions.ARB_geometry_shader4 = GL_TRUE; +#endif + ctx->Extensions.ARB_half_float_pixel = GL_TRUE; + ctx->Extensions.ARB_half_float_vertex = GL_TRUE; + ctx->Extensions.ARB_map_buffer_range = GL_TRUE; + ctx->Extensions.ARB_multitexture = GL_TRUE; +#if FEATURE_queryobj + ctx->Extensions.ARB_occlusion_query = GL_TRUE; + ctx->Extensions.ARB_occlusion_query2 = GL_TRUE; +#endif + ctx->Extensions.ARB_point_sprite = GL_TRUE; +#if FEATURE_ARB_shader_objects + ctx->Extensions.ARB_shader_objects = GL_TRUE; + ctx->Extensions.EXT_separate_shader_objects = GL_TRUE; +#endif +#if FEATURE_ARB_shading_language_100 + ctx->Extensions.ARB_shading_language_100 = GL_TRUE; +#endif + ctx->Extensions.ARB_shadow = GL_TRUE; + ctx->Extensions.ARB_shadow_ambient = GL_TRUE; + ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; + ctx->Extensions.ARB_texture_cube_map = GL_TRUE; + ctx->Extensions.ARB_texture_env_combine = GL_TRUE; + ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; + ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; + /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/ + ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; + ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; + ctx->Extensions.ARB_texture_rg = GL_TRUE; + ctx->Extensions.ARB_texture_compression_rgtc = GL_TRUE; + ctx->Extensions.ARB_vertex_array_object = GL_TRUE; +#if FEATURE_ARB_vertex_program + ctx->Extensions.ARB_vertex_program = GL_TRUE; +#endif +#if FEATURE_ARB_vertex_shader + ctx->Extensions.ARB_vertex_shader = GL_TRUE; +#endif +#if FEATURE_ARB_vertex_buffer_object + /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ +#endif +#if FEATURE_ARB_sync + ctx->Extensions.ARB_sync = GL_TRUE; +#endif + ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; +#if FEATURE_APPLE_object_purgeable + ctx->Extensions.APPLE_object_purgeable = GL_TRUE; +#endif + ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE; +#if FEATURE_ATI_fragment_shader + ctx->Extensions.ATI_fragment_shader = GL_TRUE; +#endif + ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE; + ctx->Extensions.ATI_texture_mirror_once = GL_TRUE; + ctx->Extensions.ATI_separate_stencil = GL_TRUE; + ctx->Extensions.EXT_blend_color = GL_TRUE; + ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; + ctx->Extensions.EXT_blend_func_separate = GL_TRUE; + ctx->Extensions.EXT_blend_logic_op = GL_TRUE; + ctx->Extensions.EXT_blend_minmax = GL_TRUE; + ctx->Extensions.EXT_blend_subtract = GL_TRUE; + ctx->Extensions.EXT_depth_bounds_test = GL_TRUE; + ctx->Extensions.EXT_draw_buffers2 = GL_TRUE; + ctx->Extensions.EXT_fog_coord = GL_TRUE; +#if FEATURE_EXT_framebuffer_object + ctx->Extensions.EXT_framebuffer_object = GL_TRUE; +#endif +#if FEATURE_EXT_framebuffer_blit + ctx->Extensions.EXT_framebuffer_blit = GL_TRUE; +#endif +#if FEATURE_ARB_framebuffer_object + ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE; +#endif + /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/ + ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; + ctx->Extensions.EXT_paletted_texture = GL_TRUE; +#if FEATURE_EXT_pixel_buffer_object + ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; +#endif + ctx->Extensions.EXT_point_parameters = GL_TRUE; + ctx->Extensions.EXT_provoking_vertex = GL_TRUE; + ctx->Extensions.EXT_shadow_funcs = GL_TRUE; + ctx->Extensions.EXT_secondary_color = GL_TRUE; + ctx->Extensions.EXT_shared_texture_palette = GL_TRUE; + ctx->Extensions.EXT_stencil_wrap = GL_TRUE; + ctx->Extensions.EXT_stencil_two_side = GL_TRUE; + ctx->Extensions.EXT_texture_array = GL_TRUE; + ctx->Extensions.EXT_texture_env_add = GL_TRUE; + ctx->Extensions.EXT_texture_env_combine = GL_TRUE; + ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE; + ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE; + ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; +#if FEATURE_EXT_texture_sRGB + ctx->Extensions.EXT_texture_sRGB = GL_TRUE; + ctx->Extensions.EXT_texture_sRGB_decode = GL_TRUE; +#endif + ctx->Extensions.EXT_texture_swizzle = GL_TRUE; +#if FEATURE_EXT_transform_feedback + /*ctx->Extensions.EXT_transform_feedback = GL_TRUE;*/ +#endif + ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; + /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/ + ctx->Extensions.MESA_pack_invert = GL_TRUE; + ctx->Extensions.MESA_resize_buffers = GL_TRUE; + ctx->Extensions.MESA_texture_array = GL_TRUE; + ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; + ctx->Extensions.NV_blend_square = GL_TRUE; + ctx->Extensions.NV_conditional_render = GL_TRUE; + /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/ + ctx->Extensions.NV_point_sprite = GL_TRUE; + ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; + ctx->Extensions.NV_texture_rectangle = GL_TRUE; + /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/ +#if FEATURE_NV_vertex_program + ctx->Extensions.NV_vertex_program = GL_TRUE; + ctx->Extensions.NV_vertex_program1_1 = GL_TRUE; +#endif +#if FEATURE_NV_fragment_program + ctx->Extensions.NV_fragment_program = GL_TRUE; +#endif +#if FEATURE_NV_fragment_program && FEATURE_ARB_fragment_program + ctx->Extensions.NV_fragment_program_option = GL_TRUE; +#endif + ctx->Extensions.SGI_texture_color_table = GL_TRUE; + /*ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;*/ + ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE; +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE; +#endif +#if FEATURE_texture_fxt1 + _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1"); +#endif +#if FEATURE_texture_s3tc + if (ctx->Mesa_DXTn) { + _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); + _mesa_enable_extension(ctx, "GL_S3_s3tc"); + } +#endif +} + + +/** + * Enable common EXT extensions in the ARB_imaging subset. + */ +void +_mesa_enable_imaging_extensions(struct gl_context *ctx) +{ + ctx->Extensions.EXT_blend_color = GL_TRUE; + ctx->Extensions.EXT_blend_logic_op = GL_TRUE; + ctx->Extensions.EXT_blend_minmax = GL_TRUE; + ctx->Extensions.EXT_blend_subtract = GL_TRUE; +} + + + +/** + * Enable all OpenGL 1.3 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_1_3_extensions(struct gl_context *ctx) +{ + /*ctx->Extensions.ARB_multisample = GL_TRUE;*/ + ctx->Extensions.ARB_multitexture = GL_TRUE; + ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; + /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/ + ctx->Extensions.ARB_texture_cube_map = GL_TRUE; + ctx->Extensions.ARB_texture_env_combine = GL_TRUE; + ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; + ctx->Extensions.EXT_texture_env_add = GL_TRUE; + /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/ +} + + + +/** + * Enable all OpenGL 1.4 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_1_4_extensions(struct gl_context *ctx) +{ + ctx->Extensions.ARB_depth_texture = GL_TRUE; + ctx->Extensions.ARB_shadow = GL_TRUE; + ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; + ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; + ctx->Extensions.ARB_window_pos = GL_TRUE; + ctx->Extensions.EXT_blend_color = GL_TRUE; + ctx->Extensions.EXT_blend_func_separate = GL_TRUE; + ctx->Extensions.EXT_blend_minmax = GL_TRUE; + ctx->Extensions.EXT_blend_subtract = GL_TRUE; + ctx->Extensions.EXT_fog_coord = GL_TRUE; + /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/ + ctx->Extensions.EXT_point_parameters = GL_TRUE; + ctx->Extensions.EXT_secondary_color = GL_TRUE; + ctx->Extensions.EXT_stencil_wrap = GL_TRUE; + ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; + /*ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;*/ +} + + +/** + * Enable all OpenGL 1.5 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_1_5_extensions(struct gl_context *ctx) +{ + ctx->Extensions.ARB_occlusion_query = GL_TRUE; + /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/ + ctx->Extensions.EXT_shadow_funcs = GL_TRUE; +} + + +/** + * Enable all OpenGL 2.0 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_2_0_extensions(struct gl_context *ctx) +{ + /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/ +#if FEATURE_ARB_fragment_shader + ctx->Extensions.ARB_fragment_shader = GL_TRUE; +#endif + ctx->Extensions.ARB_point_sprite = GL_TRUE; + ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; + ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; +#if FEATURE_ARB_shader_objects + ctx->Extensions.ARB_shader_objects = GL_TRUE; +#endif +#if FEATURE_ARB_shading_language_100 + ctx->Extensions.ARB_shading_language_100 = GL_TRUE; +#endif + ctx->Extensions.EXT_stencil_two_side = GL_TRUE; +#if FEATURE_ARB_vertex_shader + ctx->Extensions.ARB_vertex_shader = GL_TRUE; +#endif +} + + +/** + * Enable all OpenGL 2.1 features and extensions. + * A convenience function to be called by drivers. + */ +void +_mesa_enable_2_1_extensions(struct gl_context *ctx) +{ +#if FEATURE_EXT_pixel_buffer_object + ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; +#endif +#if FEATURE_EXT_texture_sRGB + ctx->Extensions.EXT_texture_sRGB = GL_TRUE; +#endif +} + + +/** + * Either enable or disable the named extension. + * \return GL_TRUE for success, GL_FALSE if invalid extension name + */ +static GLboolean +set_extension( struct gl_context *ctx, const char *name, GLboolean state ) +{ + size_t offset; + + if (ctx->Extensions.String) { + /* The string was already queried - can't change it now! */ + _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name); + return GL_FALSE; + } + + offset = name_to_offset(name); + if (offset == 0) { + _mesa_problem(ctx, "Trying to enable/disable unknown extension %s", + name); + return GL_FALSE; + } else if (offset == o(dummy_true) && state == GL_FALSE) { + _mesa_problem(ctx, "Trying to disable a permanently enabled extension: " + "%s", name); + return GL_FALSE; + } else { + GLboolean *base = (GLboolean *) &ctx->Extensions; + base[offset] = state; + return GL_TRUE; + } +} + + +/** + * Enable the named extension. + * Typically called by drivers. + */ +void +_mesa_enable_extension( struct gl_context *ctx, const char *name ) +{ + if (!set_extension(ctx, name, GL_TRUE)) + _mesa_problem(ctx, "Trying to enable unknown extension: %s", name); +} + + +/** + * Disable the named extension. + * XXX is this really needed??? + */ +void +_mesa_disable_extension( struct gl_context *ctx, const char *name ) +{ + if (!set_extension(ctx, name, GL_FALSE)) + _mesa_problem(ctx, "Trying to disable unknown extension: %s", name); +} + + +/** + * Test if the named extension is enabled in this context. + */ +GLboolean +_mesa_extension_is_enabled( struct gl_context *ctx, const char *name ) +{ + size_t offset; + GLboolean *base; + + if (name == 0) + return GL_FALSE; + + offset = name_to_offset(name); + if (offset == 0) + return GL_FALSE; + base = (GLboolean *) &ctx->Extensions; + return base[offset]; +} + + +/** + * \brief Apply the \c MESA_EXTENSION_OVERRIDE environment variable. + * + * \c MESA_EXTENSION_OVERRIDE is a space-separated list of extensions to + * enable or disable. The list is processed thus: + * - Enable recognized extension names that are prefixed with '+'. + * - Disable recognized extension names that are prefixed with '-'. + * - Enable recognized extension names that are not prefixed. + * - Collect unrecognized extension names in a new string. + * + * \return Space-separated list of unrecognized extension names (which must + * be freed). Does not return \c NULL. + */ +static char * +get_extension_override( struct gl_context *ctx ) +{ + const char *env_const= _mesa_getenv("MESA_EXTENSION_OVERRIDE"); + char *env; + char *ext; + char *extra_exts; + int len; + + if (env_const == NULL) { + /* Return the empty string rather than NULL. This simplifies the logic + * of client functions. */ + return calloc(1, sizeof(char)); + } + + /* extra_exts: List of unrecognized extensions. */ + extra_exts = calloc(strlen(env_const), sizeof(char)); + + /* Copy env_const because strtok() is destructive. */ + env = strdup(env_const); + for (ext = strtok(env, " "); ext != NULL; ext = strtok(NULL, " ")) { + int enable; + int recognized; + switch (ext[0]) { + case '+': + enable = 1; + ++ext; + break; + case '-': + enable = 0; + ++ext; + break; + default: + enable = 1; + break; + } + recognized = set_extension(ctx, ext, enable); + if (!recognized) { + strcat(extra_exts, ext); + strcat(extra_exts, " "); + } + } + + /* Remove trailing space. */ + len = strlen(extra_exts); + if (extra_exts[len - 1] == ' ') + extra_exts[len - 1] = '\0'; + + return extra_exts; +} + + +/** + * \brief Initialize extension tables and enable default extensions. + * + * This should be called during context initialization. + * Note: Sets gl_extensions.dummy_true to true. + */ +void +_mesa_init_extensions( struct gl_context *ctx ) +{ + GLboolean *base = (GLboolean *) &ctx->Extensions; + GLboolean *sentinel = base + o(extension_sentinel); + GLboolean *i; + const size_t *j; + + /* First, turn all extensions off. */ + for (i = base; i != sentinel; ++i) + *i = GL_FALSE; + + /* Then, selectively turn default extensions on. */ + ctx->Extensions.dummy_true = GL_TRUE; + for (j = default_extensions; *j != 0; ++j) + base[*j] = GL_TRUE; +} + + +/** + * Construct the GL_EXTENSIONS string. Called the first time that + * glGetString(GL_EXTENSIONS) is called. + */ +GLubyte* +_mesa_make_extension_string(struct gl_context *ctx) +{ + /* The extension string. */ + char *exts = 0; + /* Length of extension string. */ + size_t length = 0; + /* String of extra extensions. */ + char *extra_extensions = get_extension_override(ctx); + GLboolean *base = (GLboolean *) &ctx->Extensions; + const struct extension *i; + + /* Compute length of the extension string. */ + for (i = extension_table; i->name != 0; ++i) { + if (base[i->offset] && (i->api_set & (1 << ctx->API))) { + length += strlen(i->name) + 1; /* +1 for space */ + } + } + if (extra_extensions != NULL) + length += 1 + strlen(extra_extensions); /* +1 for space */ + + exts = (char *) calloc(length + 1, sizeof(char)); + if (exts == NULL) { + free(extra_extensions); + return NULL; + } + + /* Build the extension string.*/ + for (i = extension_table; i->name != 0; ++i) { + if (base[i->offset] && (i->api_set & (1 << ctx->API))) { + strcat(exts, i->name); + strcat(exts, " "); + } + } + if (extra_extensions != 0) { + strcat(exts, extra_extensions); + free(extra_extensions); + } + + return (GLubyte *) exts; +} + +/** + * Return number of enabled extensions. + */ +GLuint +_mesa_get_extension_count(struct gl_context *ctx) +{ + GLboolean *base; + const struct extension *i; + + /* only count once */ + if (ctx->Extensions.Count != 0) + return ctx->Extensions.Count; + + base = (GLboolean *) &ctx->Extensions; + for (i = extension_table; i->name != 0; ++i) { + if (base[i->offset]) { + ctx->Extensions.Count++; + } + } + return ctx->Extensions.Count; +} + +/** + * Return name of i-th enabled extension + */ +const GLubyte * +_mesa_get_enabled_extension(struct gl_context *ctx, GLuint index) +{ + const GLboolean *base; + size_t n; + const struct extension *i; + + if (index < 0) + return NULL; + + base = (GLboolean*) &ctx->Extensions; + n = 0; + for (i = extension_table; i->name != 0; ++i) { + if (n == index && base[i->offset]) { + return (GLubyte*) i->name; + } else if (base[i->offset]) { + ++n; + } + } + + return NULL; +} diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c index 5c9b3068e..947db84a6 100644 --- a/mesalib/src/mesa/main/formats.c +++ b/mesalib/src/mesa/main/formats.c @@ -1,1618 +1,1658 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "imports.h" -#include "formats.h" -#include "mfeatures.h" - - -/** - * Information about texture formats. - */ -struct gl_format_info -{ - gl_format Name; - - /** text name for debugging */ - const char *StrName; - - /** - * Base format is one of GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_ALPHA, - * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA, - * GL_COLOR_INDEX, GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, - * GL_DEPTH_STENCIL, GL_DUDV_ATI. - */ - GLenum BaseFormat; - - /** - * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALED, - * GL_UNSIGNED_INT, GL_INT, GL_FLOAT. - */ - GLenum DataType; - - GLubyte RedBits; - GLubyte GreenBits; - GLubyte BlueBits; - GLubyte AlphaBits; - GLubyte LuminanceBits; - GLubyte IntensityBits; - GLubyte IndexBits; - GLubyte DepthBits; - GLubyte StencilBits; - - /** - * To describe compressed formats. If not compressed, Width=Height=1. - */ - GLubyte BlockWidth, BlockHeight; - GLubyte BytesPerBlock; -}; - - -/** - * Info about each format. - * These must be in the same order as the MESA_FORMAT_* enums so that - * we can do lookups without searching. - */ -static struct gl_format_info format_info[MESA_FORMAT_COUNT] = -{ - { - MESA_FORMAT_NONE, /* Name */ - "MESA_FORMAT_NONE", /* StrName */ - GL_NONE, /* BaseFormat */ - GL_NONE, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 0, 0, 0 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGBA8888, /* Name */ - "MESA_FORMAT_RGBA8888", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGBA8888_REV, /* Name */ - "MESA_FORMAT_RGBA8888_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB8888, /* Name */ - "MESA_FORMAT_ARGB8888", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB8888_REV, /* Name */ - "MESA_FORMAT_ARGB8888_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_XRGB8888, /* Name */ - "MESA_FORMAT_XRGB8888", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_XRGB8888_REV, /* Name */ - "MESA_FORMAT_XRGB8888_REV", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB888, /* Name */ - "MESA_FORMAT_RGB888", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 3 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_BGR888, /* Name */ - "MESA_FORMAT_BGR888", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 3 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB565, /* Name */ - "MESA_FORMAT_RGB565", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB565_REV, /* Name */ - "MESA_FORMAT_RGB565_REV", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB4444, /* Name */ - "MESA_FORMAT_ARGB4444", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB4444_REV, /* Name */ - "MESA_FORMAT_ARGB4444_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGBA5551, /* Name */ - "MESA_FORMAT_RGBA5551", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB1555, /* Name */ - "MESA_FORMAT_ARGB1555", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_ARGB1555_REV, /* Name */ - "MESA_FORMAT_ARGB1555_REV", /* StrName */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL44, /* Name */ - "MESA_FORMAT_AL44", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 4, /* Red/Green/Blue/AlphaBits */ - 4, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL88, /* Name */ - "MESA_FORMAT_AL88", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ - 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL88_REV, /* Name */ - "MESA_FORMAT_AL88_REV", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ - 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL1616, /* Name */ - "MESA_FORMAT_AL1616", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ - 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_AL1616_REV, /* Name */ - "MESA_FORMAT_AL1616_REV", /* StrName */ - GL_LUMINANCE_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ - 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_RGB332, /* Name */ - "MESA_FORMAT_RGB332", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 3, 3, 2, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_A8, /* Name */ - "MESA_FORMAT_A8", /* StrName */ - GL_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_A16, /* Name */ - "MESA_FORMAT_A16", /* StrName */ - GL_ALPHA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_L8, /* Name */ - "MESA_FORMAT_L8", /* StrName */ - GL_LUMINANCE, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_L16, /* Name */ - "MESA_FORMAT_L16", /* StrName */ - GL_LUMINANCE, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_I8, /* Name */ - "MESA_FORMAT_I8", /* StrName */ - GL_INTENSITY, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_I16, /* Name */ - "MESA_FORMAT_I16", /* StrName */ - GL_INTENSITY, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 16, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_CI8, /* Name */ - "MESA_FORMAT_CI8", /* StrName */ - GL_COLOR_INDEX, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 8, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_YCBCR, /* Name */ - "MESA_FORMAT_YCBCR", /* StrName */ - GL_YCBCR_MESA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_YCBCR_REV, /* Name */ - "MESA_FORMAT_YCBCR_REV", /* StrName */ - GL_YCBCR_MESA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_R8, - "MESA_FORMAT_R8", - GL_RED, - GL_UNSIGNED_NORMALIZED, - 8, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 1 - }, - { - MESA_FORMAT_RG88, - "MESA_FORMAT_RG88", - GL_RG, - GL_UNSIGNED_NORMALIZED, - 8, 8, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_RG88_REV, - "MESA_FORMAT_RG88_REV", - GL_RG, - GL_UNSIGNED_NORMALIZED, - 8, 8, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_R16, - "MESA_FORMAT_R16", - GL_RED, - GL_UNSIGNED_NORMALIZED, - 16, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_RG1616, - "MESA_FORMAT_RG1616", - GL_RG, - GL_UNSIGNED_NORMALIZED, - 16, 16, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_RG1616_REV, - "MESA_FORMAT_RG1616_REV", - GL_RG, - GL_UNSIGNED_NORMALIZED, - 16, 16, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_ARGB2101010, - "MESA_FORMAT_ARGB2101010", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 10, 10, 10, 2, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_Z24_S8, /* Name */ - "MESA_FORMAT_Z24_S8", /* StrName */ - GL_DEPTH_STENCIL, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_S8_Z24, /* Name */ - "MESA_FORMAT_S8_Z24", /* StrName */ - GL_DEPTH_STENCIL, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_Z16, /* Name */ - "MESA_FORMAT_Z16", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 2 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_X8_Z24, /* Name */ - "MESA_FORMAT_X8_Z24", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_Z24_X8, /* Name */ - "MESA_FORMAT_Z24_X8", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_Z32, /* Name */ - "MESA_FORMAT_Z32", /* StrName */ - GL_DEPTH_COMPONENT, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_S8, /* Name */ - "MESA_FORMAT_S8", /* StrName */ - GL_STENCIL_INDEX, /* BaseFormat */ - GL_UNSIGNED_INT, /* DataType */ - 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_SRGB8, - "MESA_FORMAT_SRGB8", - GL_RGB, - GL_UNSIGNED_NORMALIZED, - 8, 8, 8, 0, - 0, 0, 0, 0, 0, - 1, 1, 3 - }, - { - MESA_FORMAT_SRGBA8, - "MESA_FORMAT_SRGBA8", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_SARGB8, - "MESA_FORMAT_SARGB8", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_SL8, - "MESA_FORMAT_SL8", - GL_LUMINANCE, - GL_UNSIGNED_NORMALIZED, - 0, 0, 0, 0, - 8, 0, 0, 0, 0, - 1, 1, 1 - }, - { - MESA_FORMAT_SLA8, - "MESA_FORMAT_SLA8", - GL_LUMINANCE_ALPHA, - GL_UNSIGNED_NORMALIZED, - 0, 0, 0, 8, - 8, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_SRGB_DXT1, /* Name */ - "MESA_FORMAT_SRGB_DXT1", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_SRGBA_DXT1, - "MESA_FORMAT_SRGBA_DXT1", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_SRGBA_DXT3, - "MESA_FORMAT_SRGBA_DXT3", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - { - MESA_FORMAT_SRGBA_DXT5, - "MESA_FORMAT_SRGBA_DXT5", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - - { - MESA_FORMAT_RGB_FXT1, - "MESA_FORMAT_RGB_FXT1", - GL_RGB, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 0, /* approx Red/Green/BlueBits */ - 0, 0, 0, 0, 0, - 8, 4, 16 /* 16 bytes per 8x4 block */ - }, - { - MESA_FORMAT_RGBA_FXT1, - "MESA_FORMAT_RGBA_FXT1", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 1, /* approx Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, - 8, 4, 16 /* 16 bytes per 8x4 block */ - }, - - { - MESA_FORMAT_RGB_DXT1, /* Name */ - "MESA_FORMAT_RGB_DXT1", /* StrName */ - GL_RGB, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED, /* DataType */ - 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_RGBA_DXT1, - "MESA_FORMAT_RGBA_DXT1", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 8 /* 8 bytes per 4x4 block */ - }, - { - MESA_FORMAT_RGBA_DXT3, - "MESA_FORMAT_RGBA_DXT3", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - { - MESA_FORMAT_RGBA_DXT5, - "MESA_FORMAT_RGBA_DXT5", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 4, 4, 4, 4, - 0, 0, 0, 0, 0, - 4, 4, 16 /* 16 bytes per 4x4 block */ - }, - { - MESA_FORMAT_RGBA_FLOAT32, - "MESA_FORMAT_RGBA_FLOAT32", - GL_RGBA, - GL_FLOAT, - 32, 32, 32, 32, - 0, 0, 0, 0, 0, - 1, 1, 16 - }, - { - MESA_FORMAT_RGBA_FLOAT16, - "MESA_FORMAT_RGBA_FLOAT16", - GL_RGBA, - GL_FLOAT, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGB_FLOAT32, - "MESA_FORMAT_RGB_FLOAT32", - GL_RGB, - GL_FLOAT, - 32, 32, 32, 0, - 0, 0, 0, 0, 0, - 1, 1, 12 - }, - { - MESA_FORMAT_RGB_FLOAT16, - "MESA_FORMAT_RGB_FLOAT16", - GL_RGB, - GL_FLOAT, - 16, 16, 16, 0, - 0, 0, 0, 0, 0, - 1, 1, 6 - }, - { - MESA_FORMAT_ALPHA_FLOAT32, - "MESA_FORMAT_ALPHA_FLOAT32", - GL_ALPHA, - GL_FLOAT, - 0, 0, 0, 32, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_ALPHA_FLOAT16, - "MESA_FORMAT_ALPHA_FLOAT16", - GL_ALPHA, - GL_FLOAT, - 0, 0, 0, 16, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_LUMINANCE_FLOAT32, - "MESA_FORMAT_LUMINANCE_FLOAT32", - GL_ALPHA, - GL_FLOAT, - 0, 0, 0, 0, - 32, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_LUMINANCE_FLOAT16, - "MESA_FORMAT_LUMINANCE_FLOAT16", - GL_ALPHA, - GL_FLOAT, - 0, 0, 0, 0, - 16, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, - "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32", - GL_LUMINANCE_ALPHA, - GL_FLOAT, - 0, 0, 0, 32, - 32, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, - "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16", - GL_LUMINANCE_ALPHA, - GL_FLOAT, - 0, 0, 0, 16, - 16, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_INTENSITY_FLOAT32, - "MESA_FORMAT_INTENSITY_FLOAT32", - GL_INTENSITY, - GL_FLOAT, - 0, 0, 0, 0, - 0, 32, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_INTENSITY_FLOAT16, - "MESA_FORMAT_INTENSITY_FLOAT16", - GL_INTENSITY, - GL_FLOAT, - 0, 0, 0, 0, - 0, 16, 0, 0, 0, - 1, 1, 2 - }, - - /* unnormalized signed int formats */ - { - MESA_FORMAT_RGBA_INT8, - "MESA_FORMAT_RGBA_INT8", - GL_RGBA, - GL_INT, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_RGBA_INT16, - "MESA_FORMAT_RGBA_INT16", - GL_RGBA, - GL_INT, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGBA_INT32, - "MESA_FORMAT_RGBA_INT32", - GL_RGBA, - GL_INT, - 32, 32, 32, 32, - 0, 0, 0, 0, 0, - 1, 1, 16 - }, - - /* unnormalized unsigned int formats */ - { - MESA_FORMAT_RGBA_UINT8, - "MESA_FORMAT_RGBA_UINT8", - GL_RGBA, - GL_UNSIGNED_INT, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_RGBA_UINT16, - "MESA_FORMAT_RGBA_UINT16", - GL_RGBA, - GL_UNSIGNED_INT, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGBA_UINT32, - "MESA_FORMAT_RGBA_UINT32", - GL_RGBA, - GL_UNSIGNED_INT, - 32, 32, 32, 32, - 0, 0, 0, 0, 0, - 1, 1, 16 - }, - - - { - MESA_FORMAT_DUDV8, - "MESA_FORMAT_DUDV8", - GL_DUDV_ATI, - GL_SIGNED_NORMALIZED, - 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - - /* Signed 8 bits / channel */ - { - MESA_FORMAT_SIGNED_R8, /* Name */ - "MESA_FORMAT_SIGNED_R8", /* StrName */ - GL_RED, /* BaseFormat */ - GL_SIGNED_NORMALIZED, /* DataType */ - 8, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ - 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ - 1, 1, 1 /* BlockWidth/Height,Bytes */ - }, - { - MESA_FORMAT_SIGNED_RG88, - "MESA_FORMAT_SIGNED_RG88", - GL_RG, - GL_SIGNED_NORMALIZED, - 8, 8, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_SIGNED_RGBX8888, - "MESA_FORMAT_SIGNED_RGBX8888", - GL_RGB, - GL_SIGNED_NORMALIZED, - 8, 8, 8, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 /* 4 bpp, but no alpha */ - }, - { - MESA_FORMAT_SIGNED_RGBA8888, - "MESA_FORMAT_SIGNED_RGBA8888", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_SIGNED_RGBA8888_REV, - "MESA_FORMAT_SIGNED_RGBA8888_REV", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - - /* Signed 16 bits / channel */ - { - MESA_FORMAT_SIGNED_R_16, - "MESA_FORMAT_SIGNED_R_16", - GL_RED, - GL_SIGNED_NORMALIZED, - 16, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_SIGNED_RG_16, - "MESA_FORMAT_SIGNED_RG_16", - GL_RG, - GL_SIGNED_NORMALIZED, - 16, 16, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_SIGNED_RGB_16, - "MESA_FORMAT_SIGNED_RGB_16", - GL_RGB, - GL_SIGNED_NORMALIZED, - 16, 16, 16, 0, - 0, 0, 0, 0, 0, - 1, 1, 6 - }, - { - MESA_FORMAT_SIGNED_RGBA_16, - "MESA_FORMAT_SIGNED_RGBA_16", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGBA_16, - "MESA_FORMAT_RGBA_16", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - } -}; - - - -static const struct gl_format_info * -_mesa_get_format_info(gl_format format) -{ - const struct gl_format_info *info = &format_info[format]; - assert(info->Name == format); - return info; -} - - -/** Return string name of format (for debugging) */ -const char * -_mesa_get_format_name(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return info->StrName; -} - - - -/** - * Return bytes needed to store a block of pixels in the given format. - * Normally, a block is 1x1 (a single pixel). But for compressed formats - * a block may be 4x4 or 8x4, etc. - */ -GLuint -_mesa_get_format_bytes(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - ASSERT(info->BytesPerBlock); - return info->BytesPerBlock; -} - - -/** - * Return bits per component for the given format. - * \param format one of MESA_FORMAT_x - * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc. - */ -GLint -_mesa_get_format_bits(gl_format format, GLenum pname) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - - switch (pname) { - case GL_RED_BITS: - case GL_TEXTURE_RED_SIZE: - case GL_RENDERBUFFER_RED_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: - return info->RedBits; - case GL_GREEN_BITS: - case GL_TEXTURE_GREEN_SIZE: - case GL_RENDERBUFFER_GREEN_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: - return info->GreenBits; - case GL_BLUE_BITS: - case GL_TEXTURE_BLUE_SIZE: - case GL_RENDERBUFFER_BLUE_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: - return info->BlueBits; - case GL_ALPHA_BITS: - case GL_TEXTURE_ALPHA_SIZE: - case GL_RENDERBUFFER_ALPHA_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: - return info->AlphaBits; - case GL_TEXTURE_INTENSITY_SIZE: - return info->IntensityBits; - case GL_TEXTURE_LUMINANCE_SIZE: - return info->LuminanceBits; - case GL_INDEX_BITS: - case GL_TEXTURE_INDEX_SIZE_EXT: - return info->IndexBits; - case GL_DEPTH_BITS: - case GL_TEXTURE_DEPTH_SIZE_ARB: - case GL_RENDERBUFFER_DEPTH_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: - return info->DepthBits; - case GL_STENCIL_BITS: - case GL_TEXTURE_STENCIL_SIZE_EXT: - case GL_RENDERBUFFER_STENCIL_SIZE_EXT: - case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: - return info->StencilBits; - default: - _mesa_problem(NULL, "bad pname in _mesa_get_format_bits()"); - return 0; - } -} - - -/** - * Return the data type (or more specifically, the data representation) - * for the given format. - * The return value will be one of: - * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1] - * GL_SIGNED_NORMALIZED = signed int representing [-1, 1] - * GL_UNSIGNED_INT = an ordinary unsigned integer - * GL_INT = an ordinary signed integer - * GL_FLOAT = an ordinary float - */ -GLenum -_mesa_get_format_datatype(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return info->DataType; -} - - -/** - * Return the basic format for the given type. The result will be - * one of GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, - * GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX, GL_DEPTH_COMPONENT, - * GL_STENCIL_INDEX, GL_DEPTH_STENCIL. - */ -GLenum -_mesa_get_format_base_format(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return info->BaseFormat; -} - - -/** - * Return the block size (in pixels) for the given format. Normally - * the block size is 1x1. But compressed formats will have block sizes - * of 4x4 or 8x4 pixels, etc. - * \param bw returns block width in pixels - * \param bh returns block height in pixels - */ -void -_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - *bw = info->BlockWidth; - *bh = info->BlockHeight; -} - - -/** Is the given format a compressed format? */ -GLboolean -_mesa_is_format_compressed(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return info->BlockWidth > 1 || info->BlockHeight > 1; -} - - -/** - * Determine if the given format represents a packed depth/stencil buffer. - */ -GLboolean -_mesa_is_format_packed_depth_stencil(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - - return info->BaseFormat == GL_DEPTH_STENCIL; -} - - -/** - * Is the given format a signed/unsigned integer color format? - */ -GLboolean -_mesa_is_format_integer_color(gl_format format) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - return (info->DataType == GL_INT || info->DataType == GL_UNSIGNED_INT) && - info->BaseFormat != GL_DEPTH_COMPONENT && - info->BaseFormat != GL_DEPTH_STENCIL && - info->BaseFormat != GL_STENCIL_INDEX; -} - - -/** - * Return color encoding for given format. - * \return GL_LINEAR or GL_SRGB - */ -GLenum -_mesa_get_format_color_encoding(gl_format format) -{ - /* XXX this info should be encoded in gl_format_info */ - switch (format) { - case MESA_FORMAT_SRGB8: - case MESA_FORMAT_SRGBA8: - case MESA_FORMAT_SARGB8: - case MESA_FORMAT_SL8: - case MESA_FORMAT_SLA8: - case MESA_FORMAT_SRGB_DXT1: - case MESA_FORMAT_SRGBA_DXT1: - case MESA_FORMAT_SRGBA_DXT3: - case MESA_FORMAT_SRGBA_DXT5: - return GL_SRGB; - default: - return GL_LINEAR; - } -} - - -/** - * For an sRGB format, return the corresponding linear color space format. - * For non-sRGB formats, return the format as-is. - */ -gl_format -_mesa_get_srgb_format_linear(gl_format format) -{ - switch (format) { - case MESA_FORMAT_SRGB8: - format = MESA_FORMAT_RGB888; - break; - case MESA_FORMAT_SRGBA8: - format = MESA_FORMAT_RGBA8888; - break; - case MESA_FORMAT_SARGB8: - format = MESA_FORMAT_ARGB8888; - break; - case MESA_FORMAT_SL8: - format = MESA_FORMAT_L8; - break; - case MESA_FORMAT_SLA8: - format = MESA_FORMAT_AL88; - break; - case MESA_FORMAT_SRGB_DXT1: - format = MESA_FORMAT_RGB_DXT1; - break; - case MESA_FORMAT_SRGBA_DXT1: - format = MESA_FORMAT_RGBA_DXT1; - break; - case MESA_FORMAT_SRGBA_DXT3: - format = MESA_FORMAT_RGBA_DXT3; - break; - case MESA_FORMAT_SRGBA_DXT5: - format = MESA_FORMAT_RGBA_DXT5; - break; - default: - break; - } - return format; -} - - -/** - * Return number of bytes needed to store an image of the given size - * in the given format. - */ -GLuint -_mesa_format_image_size(gl_format format, GLsizei width, - GLsizei height, GLsizei depth) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - /* Strictly speaking, a conditional isn't needed here */ - if (info->BlockWidth > 1 || info->BlockHeight > 1) { - /* compressed format (2D only for now) */ - const GLuint bw = info->BlockWidth, bh = info->BlockHeight; - const GLuint wblocks = (width + bw - 1) / bw; - const GLuint hblocks = (height + bh - 1) / bh; - const GLuint sz = wblocks * hblocks * info->BytesPerBlock; - assert(depth == 1); - return sz; - } - else { - /* non-compressed */ - const GLuint sz = width * height * depth * info->BytesPerBlock; - return sz; - } -} - - -/** - * Same as _mesa_format_image_size() but returns a 64-bit value to - * accomodate very large textures. - */ -uint64_t -_mesa_format_image_size64(gl_format format, GLsizei width, - GLsizei height, GLsizei depth) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - /* Strictly speaking, a conditional isn't needed here */ - if (info->BlockWidth > 1 || info->BlockHeight > 1) { - /* compressed format (2D only for now) */ - const uint64_t bw = info->BlockWidth, bh = info->BlockHeight; - const uint64_t wblocks = (width + bw - 1) / bw; - const uint64_t hblocks = (height + bh - 1) / bh; - const uint64_t sz = wblocks * hblocks * info->BytesPerBlock; - assert(depth == 1); - return sz; - } - else { - /* non-compressed */ - const uint64_t sz = ((uint64_t) width * - (uint64_t) height * - (uint64_t) depth * - info->BytesPerBlock); - return sz; - } -} - - - -GLint -_mesa_format_row_stride(gl_format format, GLsizei width) -{ - const struct gl_format_info *info = _mesa_get_format_info(format); - /* Strictly speaking, a conditional isn't needed here */ - if (info->BlockWidth > 1 || info->BlockHeight > 1) { - /* compressed format */ - const GLuint bw = info->BlockWidth; - const GLuint wblocks = (width + bw - 1) / bw; - const GLint stride = wblocks * info->BytesPerBlock; - return stride; - } - else { - const GLint stride = width * info->BytesPerBlock; - return stride; - } -} - - -/** - * Debug/test: check that all formats are handled in the - * _mesa_format_to_type_and_comps() function. When new pixel formats - * are added to Mesa, that function needs to be updated. - * This is a no-op after the first call. - */ -static void -check_format_to_type_and_comps(void) -{ - gl_format f; - - for (f = MESA_FORMAT_NONE + 1; f < MESA_FORMAT_COUNT; f++) { - GLenum datatype = 0; - GLuint comps = 0; - /* This function will emit a problem/warning if the format is - * not handled. - */ - _mesa_format_to_type_and_comps(f, &datatype, &comps); - } -} - - -/** - * Do sanity checking of the format info table. - */ -void -_mesa_test_formats(void) -{ - GLuint i; - - assert(Elements(format_info) == MESA_FORMAT_COUNT); - - for (i = 0; i < MESA_FORMAT_COUNT; i++) { - const struct gl_format_info *info = _mesa_get_format_info(i); - assert(info); - - assert(info->Name == i); - - if (info->Name == MESA_FORMAT_NONE) - continue; - - if (info->BlockWidth == 1 && info->BlockHeight == 1) { - if (info->RedBits > 0) { - GLuint t = info->RedBits + info->GreenBits - + info->BlueBits + info->AlphaBits; - assert(t / 8 <= info->BytesPerBlock); - (void) t; - } - } - - assert(info->DataType == GL_UNSIGNED_NORMALIZED || - info->DataType == GL_SIGNED_NORMALIZED || - info->DataType == GL_UNSIGNED_INT || - info->DataType == GL_INT || - info->DataType == GL_FLOAT); - - if (info->BaseFormat == GL_RGB) { - assert(info->RedBits > 0); - assert(info->GreenBits > 0); - assert(info->BlueBits > 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_RGBA) { - assert(info->RedBits > 0); - assert(info->GreenBits > 0); - assert(info->BlueBits > 0); - assert(info->AlphaBits > 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_RG) { - assert(info->RedBits > 0); - assert(info->GreenBits > 0); - assert(info->BlueBits == 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_RED) { - assert(info->RedBits > 0); - assert(info->GreenBits == 0); - assert(info->BlueBits == 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_LUMINANCE) { - assert(info->RedBits == 0); - assert(info->GreenBits == 0); - assert(info->BlueBits == 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits > 0); - assert(info->IntensityBits == 0); - } - else if (info->BaseFormat == GL_INTENSITY) { - assert(info->RedBits == 0); - assert(info->GreenBits == 0); - assert(info->BlueBits == 0); - assert(info->AlphaBits == 0); - assert(info->LuminanceBits == 0); - assert(info->IntensityBits > 0); - } - } - - check_format_to_type_and_comps(); -} - - - -/** - * Return datatype and number of components per texel for the given gl_format. - * Only used for mipmap generation code. - */ -void -_mesa_format_to_type_and_comps(gl_format format, - GLenum *datatype, GLuint *comps) -{ - switch (format) { - case MESA_FORMAT_RGBA8888: - case MESA_FORMAT_RGBA8888_REV: - case MESA_FORMAT_ARGB8888: - case MESA_FORMAT_ARGB8888_REV: - case MESA_FORMAT_XRGB8888: - case MESA_FORMAT_XRGB8888_REV: - *datatype = GL_UNSIGNED_BYTE; - *comps = 4; - return; - case MESA_FORMAT_RGB888: - case MESA_FORMAT_BGR888: - *datatype = GL_UNSIGNED_BYTE; - *comps = 3; - return; - case MESA_FORMAT_RGB565: - case MESA_FORMAT_RGB565_REV: - *datatype = GL_UNSIGNED_SHORT_5_6_5; - *comps = 3; - return; - - case MESA_FORMAT_ARGB4444: - case MESA_FORMAT_ARGB4444_REV: - *datatype = GL_UNSIGNED_SHORT_4_4_4_4; - *comps = 4; - return; - - case MESA_FORMAT_ARGB1555: - case MESA_FORMAT_ARGB1555_REV: - *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV; - *comps = 4; - return; - - case MESA_FORMAT_ARGB2101010: - *datatype = GL_UNSIGNED_INT_2_10_10_10_REV; - *comps = 4; - return; - - case MESA_FORMAT_RGBA5551: - *datatype = GL_UNSIGNED_SHORT_5_5_5_1; - *comps = 4; - return; - - case MESA_FORMAT_AL44: - *datatype = MESA_UNSIGNED_BYTE_4_4; - *comps = 2; - return; - - case MESA_FORMAT_AL88: - case MESA_FORMAT_AL88_REV: - case MESA_FORMAT_RG88: - case MESA_FORMAT_RG88_REV: - *datatype = GL_UNSIGNED_BYTE; - *comps = 2; - return; - - case MESA_FORMAT_AL1616: - case MESA_FORMAT_AL1616_REV: - case MESA_FORMAT_RG1616: - case MESA_FORMAT_RG1616_REV: - *datatype = GL_UNSIGNED_SHORT; - *comps = 2; - return; - - case MESA_FORMAT_R16: - case MESA_FORMAT_A16: - case MESA_FORMAT_L16: - case MESA_FORMAT_I16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 1; - return; - - case MESA_FORMAT_RGB332: - *datatype = GL_UNSIGNED_BYTE_3_3_2; - *comps = 3; - return; - - case MESA_FORMAT_A8: - case MESA_FORMAT_L8: - case MESA_FORMAT_I8: - case MESA_FORMAT_CI8: - case MESA_FORMAT_R8: - case MESA_FORMAT_S8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 1; - return; - - case MESA_FORMAT_YCBCR: - case MESA_FORMAT_YCBCR_REV: - *datatype = GL_UNSIGNED_SHORT; - *comps = 2; - return; - - case MESA_FORMAT_Z24_S8: - *datatype = GL_UNSIGNED_INT; - *comps = 1; /* XXX OK? */ - return; - - case MESA_FORMAT_S8_Z24: - *datatype = GL_UNSIGNED_INT; - *comps = 1; /* XXX OK? */ - return; - - case MESA_FORMAT_Z16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 1; - return; - - case MESA_FORMAT_X8_Z24: - *datatype = GL_UNSIGNED_INT; - *comps = 1; - return; - - case MESA_FORMAT_Z24_X8: - *datatype = GL_UNSIGNED_INT; - *comps = 1; - return; - - case MESA_FORMAT_Z32: - *datatype = GL_UNSIGNED_INT; - *comps = 1; - return; - - case MESA_FORMAT_DUDV8: - *datatype = GL_BYTE; - *comps = 2; - return; - - case MESA_FORMAT_SIGNED_R8: - *datatype = GL_BYTE; - *comps = 1; - return; - case MESA_FORMAT_SIGNED_RG88: - *datatype = GL_BYTE; - *comps = 2; - return; - case MESA_FORMAT_SIGNED_RGBA8888: - case MESA_FORMAT_SIGNED_RGBA8888_REV: - case MESA_FORMAT_SIGNED_RGBX8888: - *datatype = GL_BYTE; - *comps = 4; - return; - - case MESA_FORMAT_RGBA_16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 4; - return; - - case MESA_FORMAT_SIGNED_R_16: - *datatype = GL_SHORT; - *comps = 1; - return; - case MESA_FORMAT_SIGNED_RG_16: - *datatype = GL_SHORT; - *comps = 2; - return; - case MESA_FORMAT_SIGNED_RGB_16: - *datatype = GL_SHORT; - *comps = 3; - return; - case MESA_FORMAT_SIGNED_RGBA_16: - *datatype = GL_SHORT; - *comps = 4; - return; - -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGB8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 3; - return; - case MESA_FORMAT_SRGBA8: - case MESA_FORMAT_SARGB8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 4; - return; - case MESA_FORMAT_SL8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 1; - return; - case MESA_FORMAT_SLA8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 2; - return; -#endif - -#if FEATURE_texture_fxt1 - case MESA_FORMAT_RGB_FXT1: - case MESA_FORMAT_RGBA_FXT1: -#endif -#if FEATURE_texture_s3tc - case MESA_FORMAT_RGB_DXT1: - case MESA_FORMAT_RGBA_DXT1: - case MESA_FORMAT_RGBA_DXT3: - case MESA_FORMAT_RGBA_DXT5: -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGB_DXT1: - case MESA_FORMAT_SRGBA_DXT1: - case MESA_FORMAT_SRGBA_DXT3: - case MESA_FORMAT_SRGBA_DXT5: -#endif -#endif - /* XXX generate error instead? */ - *datatype = GL_UNSIGNED_BYTE; - *comps = 0; - return; - - case MESA_FORMAT_RGBA_FLOAT32: - *datatype = GL_FLOAT; - *comps = 4; - return; - case MESA_FORMAT_RGBA_FLOAT16: - *datatype = GL_HALF_FLOAT_ARB; - *comps = 4; - return; - case MESA_FORMAT_RGB_FLOAT32: - *datatype = GL_FLOAT; - *comps = 3; - return; - case MESA_FORMAT_RGB_FLOAT16: - *datatype = GL_HALF_FLOAT_ARB; - *comps = 3; - return; - case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32: - *datatype = GL_FLOAT; - *comps = 2; - return; - case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16: - *datatype = GL_HALF_FLOAT_ARB; - *comps = 2; - return; - case MESA_FORMAT_ALPHA_FLOAT32: - case MESA_FORMAT_LUMINANCE_FLOAT32: - case MESA_FORMAT_INTENSITY_FLOAT32: - *datatype = GL_FLOAT; - *comps = 1; - return; - case MESA_FORMAT_ALPHA_FLOAT16: - case MESA_FORMAT_LUMINANCE_FLOAT16: - case MESA_FORMAT_INTENSITY_FLOAT16: - *datatype = GL_HALF_FLOAT_ARB; - *comps = 1; - return; - - case MESA_FORMAT_RGBA_INT8: - *datatype = GL_BYTE; - *comps = 4; - return; - case MESA_FORMAT_RGBA_INT16: - *datatype = GL_SHORT; - *comps = 4; - return; - case MESA_FORMAT_RGBA_INT32: - *datatype = GL_INT; - *comps = 4; - return; - - /** - * \name Non-normalized unsigned integer formats. - */ - case MESA_FORMAT_RGBA_UINT8: - *datatype = GL_UNSIGNED_BYTE; - *comps = 4; - return; - case MESA_FORMAT_RGBA_UINT16: - *datatype = GL_UNSIGNED_SHORT; - *comps = 4; - return; - case MESA_FORMAT_RGBA_UINT32: - *datatype = GL_UNSIGNED_INT; - *comps = 4; - return; - - case MESA_FORMAT_COUNT: - assert(0); - return; - - case MESA_FORMAT_NONE: - /* For debug builds, warn if any formats are not handled */ -#ifdef DEBUG - default: -#endif - _mesa_problem(NULL, "bad format %s in _mesa_format_to_type_and_comps", - _mesa_get_format_name(format)); - *datatype = 0; - *comps = 1; - } -} +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#include "imports.h" +#include "formats.h" +#include "mfeatures.h" + + +/** + * Information about texture formats. + */ +struct gl_format_info +{ + gl_format Name; + + /** text name for debugging */ + const char *StrName; + + /** + * Base format is one of GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_ALPHA, + * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA, + * GL_COLOR_INDEX, GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, + * GL_DEPTH_STENCIL, GL_DUDV_ATI. + */ + GLenum BaseFormat; + + /** + * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALED, + * GL_UNSIGNED_INT, GL_INT, GL_FLOAT. + */ + GLenum DataType; + + GLubyte RedBits; + GLubyte GreenBits; + GLubyte BlueBits; + GLubyte AlphaBits; + GLubyte LuminanceBits; + GLubyte IntensityBits; + GLubyte IndexBits; + GLubyte DepthBits; + GLubyte StencilBits; + + /** + * To describe compressed formats. If not compressed, Width=Height=1. + */ + GLubyte BlockWidth, BlockHeight; + GLubyte BytesPerBlock; +}; + + +/** + * Info about each format. + * These must be in the same order as the MESA_FORMAT_* enums so that + * we can do lookups without searching. + */ +static struct gl_format_info format_info[MESA_FORMAT_COUNT] = +{ + { + MESA_FORMAT_NONE, /* Name */ + "MESA_FORMAT_NONE", /* StrName */ + GL_NONE, /* BaseFormat */ + GL_NONE, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 0, 0, 0 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGBA8888, /* Name */ + "MESA_FORMAT_RGBA8888", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGBA8888_REV, /* Name */ + "MESA_FORMAT_RGBA8888_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB8888, /* Name */ + "MESA_FORMAT_ARGB8888", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB8888_REV, /* Name */ + "MESA_FORMAT_ARGB8888_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_XRGB8888, /* Name */ + "MESA_FORMAT_XRGB8888", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_XRGB8888_REV, /* Name */ + "MESA_FORMAT_XRGB8888_REV", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB888, /* Name */ + "MESA_FORMAT_RGB888", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 3 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_BGR888, /* Name */ + "MESA_FORMAT_BGR888", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 3 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB565, /* Name */ + "MESA_FORMAT_RGB565", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB565_REV, /* Name */ + "MESA_FORMAT_RGB565_REV", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB4444, /* Name */ + "MESA_FORMAT_ARGB4444", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB4444_REV, /* Name */ + "MESA_FORMAT_ARGB4444_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGBA5551, /* Name */ + "MESA_FORMAT_RGBA5551", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB1555, /* Name */ + "MESA_FORMAT_ARGB1555", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_ARGB1555_REV, /* Name */ + "MESA_FORMAT_ARGB1555_REV", /* StrName */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL44, /* Name */ + "MESA_FORMAT_AL44", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 4, /* Red/Green/Blue/AlphaBits */ + 4, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL88, /* Name */ + "MESA_FORMAT_AL88", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ + 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL88_REV, /* Name */ + "MESA_FORMAT_AL88_REV", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ + 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL1616, /* Name */ + "MESA_FORMAT_AL1616", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ + 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_AL1616_REV, /* Name */ + "MESA_FORMAT_AL1616_REV", /* StrName */ + GL_LUMINANCE_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ + 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_RGB332, /* Name */ + "MESA_FORMAT_RGB332", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 3, 3, 2, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_A8, /* Name */ + "MESA_FORMAT_A8", /* StrName */ + GL_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_A16, /* Name */ + "MESA_FORMAT_A16", /* StrName */ + GL_ALPHA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_L8, /* Name */ + "MESA_FORMAT_L8", /* StrName */ + GL_LUMINANCE, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_L16, /* Name */ + "MESA_FORMAT_L16", /* StrName */ + GL_LUMINANCE, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_I8, /* Name */ + "MESA_FORMAT_I8", /* StrName */ + GL_INTENSITY, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_I16, /* Name */ + "MESA_FORMAT_I16", /* StrName */ + GL_INTENSITY, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 16, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_CI8, /* Name */ + "MESA_FORMAT_CI8", /* StrName */ + GL_COLOR_INDEX, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 8, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_YCBCR, /* Name */ + "MESA_FORMAT_YCBCR", /* StrName */ + GL_YCBCR_MESA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_YCBCR_REV, /* Name */ + "MESA_FORMAT_YCBCR_REV", /* StrName */ + GL_YCBCR_MESA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_R8, + "MESA_FORMAT_R8", + GL_RED, + GL_UNSIGNED_NORMALIZED, + 8, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 1 + }, + { + MESA_FORMAT_RG88, + "MESA_FORMAT_RG88", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 8, 8, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_RG88_REV, + "MESA_FORMAT_RG88_REV", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 8, 8, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_R16, + "MESA_FORMAT_R16", + GL_RED, + GL_UNSIGNED_NORMALIZED, + 16, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_RG1616, + "MESA_FORMAT_RG1616", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 16, 16, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_RG1616_REV, + "MESA_FORMAT_RG1616_REV", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 16, 16, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_ARGB2101010, + "MESA_FORMAT_ARGB2101010", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 10, 10, 10, 2, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_Z24_S8, /* Name */ + "MESA_FORMAT_Z24_S8", /* StrName */ + GL_DEPTH_STENCIL, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_S8_Z24, /* Name */ + "MESA_FORMAT_S8_Z24", /* StrName */ + GL_DEPTH_STENCIL, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_Z16, /* Name */ + "MESA_FORMAT_Z16", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 2 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_X8_Z24, /* Name */ + "MESA_FORMAT_X8_Z24", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_Z24_X8, /* Name */ + "MESA_FORMAT_Z24_X8", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_Z32, /* Name */ + "MESA_FORMAT_Z32", /* StrName */ + GL_DEPTH_COMPONENT, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 4 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_S8, /* Name */ + "MESA_FORMAT_S8", /* StrName */ + GL_STENCIL_INDEX, /* BaseFormat */ + GL_UNSIGNED_INT, /* DataType */ + 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_SRGB8, + "MESA_FORMAT_SRGB8", + GL_RGB, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 0, + 0, 0, 0, 0, 0, + 1, 1, 3 + }, + { + MESA_FORMAT_SRGBA8, + "MESA_FORMAT_SRGBA8", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SARGB8, + "MESA_FORMAT_SARGB8", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SL8, + "MESA_FORMAT_SL8", + GL_LUMINANCE, + GL_UNSIGNED_NORMALIZED, + 0, 0, 0, 0, + 8, 0, 0, 0, 0, + 1, 1, 1 + }, + { + MESA_FORMAT_SLA8, + "MESA_FORMAT_SLA8", + GL_LUMINANCE_ALPHA, + GL_UNSIGNED_NORMALIZED, + 0, 0, 0, 8, + 8, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SRGB_DXT1, /* Name */ + "MESA_FORMAT_SRGB_DXT1", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SRGBA_DXT1, + "MESA_FORMAT_SRGBA_DXT1", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SRGBA_DXT3, + "MESA_FORMAT_SRGBA_DXT3", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SRGBA_DXT5, + "MESA_FORMAT_SRGBA_DXT5", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + + { + MESA_FORMAT_RGB_FXT1, + "MESA_FORMAT_RGB_FXT1", + GL_RGB, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 0, /* approx Red/Green/BlueBits */ + 0, 0, 0, 0, 0, + 8, 4, 16 /* 16 bytes per 8x4 block */ + }, + { + MESA_FORMAT_RGBA_FXT1, + "MESA_FORMAT_RGBA_FXT1", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 1, /* approx Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, + 8, 4, 16 /* 16 bytes per 8x4 block */ + }, + + { + MESA_FORMAT_RGB_DXT1, /* Name */ + "MESA_FORMAT_RGB_DXT1", /* StrName */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED, /* DataType */ + 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_DXT1, + "MESA_FORMAT_RGBA_DXT1", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_DXT3, + "MESA_FORMAT_RGBA_DXT3", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_DXT5, + "MESA_FORMAT_RGBA_DXT5", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 4, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RGBA_FLOAT32, + "MESA_FORMAT_RGBA_FLOAT32", + GL_RGBA, + GL_FLOAT, + 32, 32, 32, 32, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, + { + MESA_FORMAT_RGBA_FLOAT16, + "MESA_FORMAT_RGBA_FLOAT16", + GL_RGBA, + GL_FLOAT, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGB_FLOAT32, + "MESA_FORMAT_RGB_FLOAT32", + GL_RGB, + GL_FLOAT, + 32, 32, 32, 0, + 0, 0, 0, 0, 0, + 1, 1, 12 + }, + { + MESA_FORMAT_RGB_FLOAT16, + "MESA_FORMAT_RGB_FLOAT16", + GL_RGB, + GL_FLOAT, + 16, 16, 16, 0, + 0, 0, 0, 0, 0, + 1, 1, 6 + }, + { + MESA_FORMAT_ALPHA_FLOAT32, + "MESA_FORMAT_ALPHA_FLOAT32", + GL_ALPHA, + GL_FLOAT, + 0, 0, 0, 32, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_ALPHA_FLOAT16, + "MESA_FORMAT_ALPHA_FLOAT16", + GL_ALPHA, + GL_FLOAT, + 0, 0, 0, 16, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT32, + "MESA_FORMAT_LUMINANCE_FLOAT32", + GL_ALPHA, + GL_FLOAT, + 0, 0, 0, 0, + 32, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT16, + "MESA_FORMAT_LUMINANCE_FLOAT16", + GL_ALPHA, + GL_FLOAT, + 0, 0, 0, 0, + 16, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, + "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32", + GL_LUMINANCE_ALPHA, + GL_FLOAT, + 0, 0, 0, 32, + 32, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, + "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16", + GL_LUMINANCE_ALPHA, + GL_FLOAT, + 0, 0, 0, 16, + 16, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_INTENSITY_FLOAT32, + "MESA_FORMAT_INTENSITY_FLOAT32", + GL_INTENSITY, + GL_FLOAT, + 0, 0, 0, 0, + 0, 32, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_INTENSITY_FLOAT16, + "MESA_FORMAT_INTENSITY_FLOAT16", + GL_INTENSITY, + GL_FLOAT, + 0, 0, 0, 0, + 0, 16, 0, 0, 0, + 1, 1, 2 + }, + + /* unnormalized signed int formats */ + { + MESA_FORMAT_RGBA_INT8, + "MESA_FORMAT_RGBA_INT8", + GL_RGBA, + GL_INT, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_RGBA_INT16, + "MESA_FORMAT_RGBA_INT16", + GL_RGBA, + GL_INT, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGBA_INT32, + "MESA_FORMAT_RGBA_INT32", + GL_RGBA, + GL_INT, + 32, 32, 32, 32, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, + + /* unnormalized unsigned int formats */ + { + MESA_FORMAT_RGBA_UINT8, + "MESA_FORMAT_RGBA_UINT8", + GL_RGBA, + GL_UNSIGNED_INT, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_RGBA_UINT16, + "MESA_FORMAT_RGBA_UINT16", + GL_RGBA, + GL_UNSIGNED_INT, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGBA_UINT32, + "MESA_FORMAT_RGBA_UINT32", + GL_RGBA, + GL_UNSIGNED_INT, + 32, 32, 32, 32, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, + + + { + MESA_FORMAT_DUDV8, + "MESA_FORMAT_DUDV8", + GL_DUDV_ATI, + GL_SIGNED_NORMALIZED, + 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + + /* Signed 8 bits / channel */ + { + MESA_FORMAT_SIGNED_R8, /* Name */ + "MESA_FORMAT_SIGNED_R8", /* StrName */ + GL_RED, /* BaseFormat */ + GL_SIGNED_NORMALIZED, /* DataType */ + 8, 0, 0, 0, /* Red/Green/Blue/AlphaBits */ + 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ + 1, 1, 1 /* BlockWidth/Height,Bytes */ + }, + { + MESA_FORMAT_SIGNED_RG88, + "MESA_FORMAT_SIGNED_RG88", + GL_RG, + GL_SIGNED_NORMALIZED, + 8, 8, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_RGBX8888, + "MESA_FORMAT_SIGNED_RGBX8888", + GL_RGB, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 /* 4 bpp, but no alpha */ + }, + { + MESA_FORMAT_SIGNED_RGBA8888, + "MESA_FORMAT_SIGNED_RGBA8888", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SIGNED_RGBA8888_REV, + "MESA_FORMAT_SIGNED_RGBA8888_REV", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + + /* Signed 16 bits / channel */ + { + MESA_FORMAT_SIGNED_R_16, + "MESA_FORMAT_SIGNED_R_16", + GL_RED, + GL_SIGNED_NORMALIZED, + 16, 0, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_SIGNED_RG_16, + "MESA_FORMAT_SIGNED_RG_16", + GL_RG, + GL_SIGNED_NORMALIZED, + 16, 16, 0, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_SIGNED_RGB_16, + "MESA_FORMAT_SIGNED_RGB_16", + GL_RGB, + GL_SIGNED_NORMALIZED, + 16, 16, 16, 0, + 0, 0, 0, 0, 0, + 1, 1, 6 + }, + { + MESA_FORMAT_SIGNED_RGBA_16, + "MESA_FORMAT_SIGNED_RGBA_16", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RGBA_16, + "MESA_FORMAT_RGBA_16", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_RED_RGTC1, + "MESA_FORMAT_RED_RGTC1", + GL_RED, + GL_UNSIGNED_NORMALIZED, + 4, 0, 0, 0, + 0, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SIGNED_RED_RGTC1, + "MESA_FORMAT_SIGNED_RED_RGTC1", + GL_RED, + GL_SIGNED_NORMALIZED, + 4, 0, 0, 0, + 0, 0, 0, 0, 0, + 4, 4, 8 /* 8 bytes per 4x4 block */ + }, + { + MESA_FORMAT_RG_RGTC2, + "MESA_FORMAT_RG_RGTC2", + GL_RG, + GL_UNSIGNED_NORMALIZED, + 4, 4, 0, 0, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, + { + MESA_FORMAT_SIGNED_RG_RGTC2, + "MESA_FORMAT_SIGNED_RG_RGTC2", + GL_RG, + GL_SIGNED_NORMALIZED, + 4, 4, 0, 0, + 0, 0, 0, 0, 0, + 4, 4, 16 /* 16 bytes per 4x4 block */ + }, +}; + + + +static const struct gl_format_info * +_mesa_get_format_info(gl_format format) +{ + const struct gl_format_info *info = &format_info[format]; + assert(info->Name == format); + return info; +} + + +/** Return string name of format (for debugging) */ +const char * +_mesa_get_format_name(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->StrName; +} + + + +/** + * Return bytes needed to store a block of pixels in the given format. + * Normally, a block is 1x1 (a single pixel). But for compressed formats + * a block may be 4x4 or 8x4, etc. + */ +GLuint +_mesa_get_format_bytes(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + ASSERT(info->BytesPerBlock); + return info->BytesPerBlock; +} + + +/** + * Return bits per component for the given format. + * \param format one of MESA_FORMAT_x + * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc. + */ +GLint +_mesa_get_format_bits(gl_format format, GLenum pname) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + + switch (pname) { + case GL_RED_BITS: + case GL_TEXTURE_RED_SIZE: + case GL_RENDERBUFFER_RED_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: + return info->RedBits; + case GL_GREEN_BITS: + case GL_TEXTURE_GREEN_SIZE: + case GL_RENDERBUFFER_GREEN_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: + return info->GreenBits; + case GL_BLUE_BITS: + case GL_TEXTURE_BLUE_SIZE: + case GL_RENDERBUFFER_BLUE_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: + return info->BlueBits; + case GL_ALPHA_BITS: + case GL_TEXTURE_ALPHA_SIZE: + case GL_RENDERBUFFER_ALPHA_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: + return info->AlphaBits; + case GL_TEXTURE_INTENSITY_SIZE: + return info->IntensityBits; + case GL_TEXTURE_LUMINANCE_SIZE: + return info->LuminanceBits; + case GL_INDEX_BITS: + case GL_TEXTURE_INDEX_SIZE_EXT: + return info->IndexBits; + case GL_DEPTH_BITS: + case GL_TEXTURE_DEPTH_SIZE_ARB: + case GL_RENDERBUFFER_DEPTH_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: + return info->DepthBits; + case GL_STENCIL_BITS: + case GL_TEXTURE_STENCIL_SIZE_EXT: + case GL_RENDERBUFFER_STENCIL_SIZE_EXT: + case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: + return info->StencilBits; + default: + _mesa_problem(NULL, "bad pname in _mesa_get_format_bits()"); + return 0; + } +} + + +/** + * Return the data type (or more specifically, the data representation) + * for the given format. + * The return value will be one of: + * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1] + * GL_SIGNED_NORMALIZED = signed int representing [-1, 1] + * GL_UNSIGNED_INT = an ordinary unsigned integer + * GL_INT = an ordinary signed integer + * GL_FLOAT = an ordinary float + */ +GLenum +_mesa_get_format_datatype(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->DataType; +} + + +/** + * Return the basic format for the given type. The result will be + * one of GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, + * GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX, GL_DEPTH_COMPONENT, + * GL_STENCIL_INDEX, GL_DEPTH_STENCIL. + */ +GLenum +_mesa_get_format_base_format(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->BaseFormat; +} + + +/** + * Return the block size (in pixels) for the given format. Normally + * the block size is 1x1. But compressed formats will have block sizes + * of 4x4 or 8x4 pixels, etc. + * \param bw returns block width in pixels + * \param bh returns block height in pixels + */ +void +_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + *bw = info->BlockWidth; + *bh = info->BlockHeight; +} + + +/** Is the given format a compressed format? */ +GLboolean +_mesa_is_format_compressed(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->BlockWidth > 1 || info->BlockHeight > 1; +} + + +/** + * Determine if the given format represents a packed depth/stencil buffer. + */ +GLboolean +_mesa_is_format_packed_depth_stencil(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + + return info->BaseFormat == GL_DEPTH_STENCIL; +} + + +/** + * Is the given format a signed/unsigned integer color format? + */ +GLboolean +_mesa_is_format_integer_color(gl_format format) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + return (info->DataType == GL_INT || info->DataType == GL_UNSIGNED_INT) && + info->BaseFormat != GL_DEPTH_COMPONENT && + info->BaseFormat != GL_DEPTH_STENCIL && + info->BaseFormat != GL_STENCIL_INDEX; +} + + +/** + * Return color encoding for given format. + * \return GL_LINEAR or GL_SRGB + */ +GLenum +_mesa_get_format_color_encoding(gl_format format) +{ + /* XXX this info should be encoded in gl_format_info */ + switch (format) { + case MESA_FORMAT_SRGB8: + case MESA_FORMAT_SRGBA8: + case MESA_FORMAT_SARGB8: + case MESA_FORMAT_SL8: + case MESA_FORMAT_SLA8: + case MESA_FORMAT_SRGB_DXT1: + case MESA_FORMAT_SRGBA_DXT1: + case MESA_FORMAT_SRGBA_DXT3: + case MESA_FORMAT_SRGBA_DXT5: + return GL_SRGB; + default: + return GL_LINEAR; + } +} + + +/** + * For an sRGB format, return the corresponding linear color space format. + * For non-sRGB formats, return the format as-is. + */ +gl_format +_mesa_get_srgb_format_linear(gl_format format) +{ + switch (format) { + case MESA_FORMAT_SRGB8: + format = MESA_FORMAT_RGB888; + break; + case MESA_FORMAT_SRGBA8: + format = MESA_FORMAT_RGBA8888; + break; + case MESA_FORMAT_SARGB8: + format = MESA_FORMAT_ARGB8888; + break; + case MESA_FORMAT_SL8: + format = MESA_FORMAT_L8; + break; + case MESA_FORMAT_SLA8: + format = MESA_FORMAT_AL88; + break; + case MESA_FORMAT_SRGB_DXT1: + format = MESA_FORMAT_RGB_DXT1; + break; + case MESA_FORMAT_SRGBA_DXT1: + format = MESA_FORMAT_RGBA_DXT1; + break; + case MESA_FORMAT_SRGBA_DXT3: + format = MESA_FORMAT_RGBA_DXT3; + break; + case MESA_FORMAT_SRGBA_DXT5: + format = MESA_FORMAT_RGBA_DXT5; + break; + default: + break; + } + return format; +} + + +/** + * Return number of bytes needed to store an image of the given size + * in the given format. + */ +GLuint +_mesa_format_image_size(gl_format format, GLsizei width, + GLsizei height, GLsizei depth) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + /* Strictly speaking, a conditional isn't needed here */ + if (info->BlockWidth > 1 || info->BlockHeight > 1) { + /* compressed format (2D only for now) */ + const GLuint bw = info->BlockWidth, bh = info->BlockHeight; + const GLuint wblocks = (width + bw - 1) / bw; + const GLuint hblocks = (height + bh - 1) / bh; + const GLuint sz = wblocks * hblocks * info->BytesPerBlock; + assert(depth == 1); + return sz; + } + else { + /* non-compressed */ + const GLuint sz = width * height * depth * info->BytesPerBlock; + return sz; + } +} + + +/** + * Same as _mesa_format_image_size() but returns a 64-bit value to + * accomodate very large textures. + */ +uint64_t +_mesa_format_image_size64(gl_format format, GLsizei width, + GLsizei height, GLsizei depth) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + /* Strictly speaking, a conditional isn't needed here */ + if (info->BlockWidth > 1 || info->BlockHeight > 1) { + /* compressed format (2D only for now) */ + const uint64_t bw = info->BlockWidth, bh = info->BlockHeight; + const uint64_t wblocks = (width + bw - 1) / bw; + const uint64_t hblocks = (height + bh - 1) / bh; + const uint64_t sz = wblocks * hblocks * info->BytesPerBlock; + assert(depth == 1); + return sz; + } + else { + /* non-compressed */ + const uint64_t sz = ((uint64_t) width * + (uint64_t) height * + (uint64_t) depth * + info->BytesPerBlock); + return sz; + } +} + + + +GLint +_mesa_format_row_stride(gl_format format, GLsizei width) +{ + const struct gl_format_info *info = _mesa_get_format_info(format); + /* Strictly speaking, a conditional isn't needed here */ + if (info->BlockWidth > 1 || info->BlockHeight > 1) { + /* compressed format */ + const GLuint bw = info->BlockWidth; + const GLuint wblocks = (width + bw - 1) / bw; + const GLint stride = wblocks * info->BytesPerBlock; + return stride; + } + else { + const GLint stride = width * info->BytesPerBlock; + return stride; + } +} + + +/** + * Debug/test: check that all formats are handled in the + * _mesa_format_to_type_and_comps() function. When new pixel formats + * are added to Mesa, that function needs to be updated. + * This is a no-op after the first call. + */ +static void +check_format_to_type_and_comps(void) +{ + gl_format f; + + for (f = MESA_FORMAT_NONE + 1; f < MESA_FORMAT_COUNT; f++) { + GLenum datatype = 0; + GLuint comps = 0; + /* This function will emit a problem/warning if the format is + * not handled. + */ + _mesa_format_to_type_and_comps(f, &datatype, &comps); + } +} + + +/** + * Do sanity checking of the format info table. + */ +void +_mesa_test_formats(void) +{ + GLuint i; + + assert(Elements(format_info) == MESA_FORMAT_COUNT); + + for (i = 0; i < MESA_FORMAT_COUNT; i++) { + const struct gl_format_info *info = _mesa_get_format_info(i); + assert(info); + + assert(info->Name == i); + + if (info->Name == MESA_FORMAT_NONE) + continue; + + if (info->BlockWidth == 1 && info->BlockHeight == 1) { + if (info->RedBits > 0) { + GLuint t = info->RedBits + info->GreenBits + + info->BlueBits + info->AlphaBits; + assert(t / 8 <= info->BytesPerBlock); + (void) t; + } + } + + assert(info->DataType == GL_UNSIGNED_NORMALIZED || + info->DataType == GL_SIGNED_NORMALIZED || + info->DataType == GL_UNSIGNED_INT || + info->DataType == GL_INT || + info->DataType == GL_FLOAT); + + if (info->BaseFormat == GL_RGB) { + assert(info->RedBits > 0); + assert(info->GreenBits > 0); + assert(info->BlueBits > 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_RGBA) { + assert(info->RedBits > 0); + assert(info->GreenBits > 0); + assert(info->BlueBits > 0); + assert(info->AlphaBits > 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_RG) { + assert(info->RedBits > 0); + assert(info->GreenBits > 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_RED) { + assert(info->RedBits > 0); + assert(info->GreenBits == 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_LUMINANCE) { + assert(info->RedBits == 0); + assert(info->GreenBits == 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits > 0); + assert(info->IntensityBits == 0); + } + else if (info->BaseFormat == GL_INTENSITY) { + assert(info->RedBits == 0); + assert(info->GreenBits == 0); + assert(info->BlueBits == 0); + assert(info->AlphaBits == 0); + assert(info->LuminanceBits == 0); + assert(info->IntensityBits > 0); + } + } + + check_format_to_type_and_comps(); +} + + + +/** + * Return datatype and number of components per texel for the given gl_format. + * Only used for mipmap generation code. + */ +void +_mesa_format_to_type_and_comps(gl_format format, + GLenum *datatype, GLuint *comps) +{ + switch (format) { + case MESA_FORMAT_RGBA8888: + case MESA_FORMAT_RGBA8888_REV: + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_ARGB8888_REV: + case MESA_FORMAT_XRGB8888: + case MESA_FORMAT_XRGB8888_REV: + *datatype = GL_UNSIGNED_BYTE; + *comps = 4; + return; + case MESA_FORMAT_RGB888: + case MESA_FORMAT_BGR888: + *datatype = GL_UNSIGNED_BYTE; + *comps = 3; + return; + case MESA_FORMAT_RGB565: + case MESA_FORMAT_RGB565_REV: + *datatype = GL_UNSIGNED_SHORT_5_6_5; + *comps = 3; + return; + + case MESA_FORMAT_ARGB4444: + case MESA_FORMAT_ARGB4444_REV: + *datatype = GL_UNSIGNED_SHORT_4_4_4_4; + *comps = 4; + return; + + case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_ARGB1555_REV: + *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV; + *comps = 4; + return; + + case MESA_FORMAT_ARGB2101010: + *datatype = GL_UNSIGNED_INT_2_10_10_10_REV; + *comps = 4; + return; + + case MESA_FORMAT_RGBA5551: + *datatype = GL_UNSIGNED_SHORT_5_5_5_1; + *comps = 4; + return; + + case MESA_FORMAT_AL44: + *datatype = MESA_UNSIGNED_BYTE_4_4; + *comps = 2; + return; + + case MESA_FORMAT_AL88: + case MESA_FORMAT_AL88_REV: + case MESA_FORMAT_RG88: + case MESA_FORMAT_RG88_REV: + *datatype = GL_UNSIGNED_BYTE; + *comps = 2; + return; + + case MESA_FORMAT_AL1616: + case MESA_FORMAT_AL1616_REV: + case MESA_FORMAT_RG1616: + case MESA_FORMAT_RG1616_REV: + *datatype = GL_UNSIGNED_SHORT; + *comps = 2; + return; + + case MESA_FORMAT_R16: + case MESA_FORMAT_A16: + case MESA_FORMAT_L16: + case MESA_FORMAT_I16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 1; + return; + + case MESA_FORMAT_RGB332: + *datatype = GL_UNSIGNED_BYTE_3_3_2; + *comps = 3; + return; + + case MESA_FORMAT_A8: + case MESA_FORMAT_L8: + case MESA_FORMAT_I8: + case MESA_FORMAT_CI8: + case MESA_FORMAT_R8: + case MESA_FORMAT_S8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 1; + return; + + case MESA_FORMAT_YCBCR: + case MESA_FORMAT_YCBCR_REV: + *datatype = GL_UNSIGNED_SHORT; + *comps = 2; + return; + + case MESA_FORMAT_Z24_S8: + *datatype = GL_UNSIGNED_INT; + *comps = 1; /* XXX OK? */ + return; + + case MESA_FORMAT_S8_Z24: + *datatype = GL_UNSIGNED_INT; + *comps = 1; /* XXX OK? */ + return; + + case MESA_FORMAT_Z16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 1; + return; + + case MESA_FORMAT_X8_Z24: + *datatype = GL_UNSIGNED_INT; + *comps = 1; + return; + + case MESA_FORMAT_Z24_X8: + *datatype = GL_UNSIGNED_INT; + *comps = 1; + return; + + case MESA_FORMAT_Z32: + *datatype = GL_UNSIGNED_INT; + *comps = 1; + return; + + case MESA_FORMAT_DUDV8: + *datatype = GL_BYTE; + *comps = 2; + return; + + case MESA_FORMAT_SIGNED_R8: + *datatype = GL_BYTE; + *comps = 1; + return; + case MESA_FORMAT_SIGNED_RG88: + *datatype = GL_BYTE; + *comps = 2; + return; + case MESA_FORMAT_SIGNED_RGBA8888: + case MESA_FORMAT_SIGNED_RGBA8888_REV: + case MESA_FORMAT_SIGNED_RGBX8888: + *datatype = GL_BYTE; + *comps = 4; + return; + + case MESA_FORMAT_RGBA_16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 4; + return; + + case MESA_FORMAT_SIGNED_R_16: + *datatype = GL_SHORT; + *comps = 1; + return; + case MESA_FORMAT_SIGNED_RG_16: + *datatype = GL_SHORT; + *comps = 2; + return; + case MESA_FORMAT_SIGNED_RGB_16: + *datatype = GL_SHORT; + *comps = 3; + return; + case MESA_FORMAT_SIGNED_RGBA_16: + *datatype = GL_SHORT; + *comps = 4; + return; + +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SRGB8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 3; + return; + case MESA_FORMAT_SRGBA8: + case MESA_FORMAT_SARGB8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 4; + return; + case MESA_FORMAT_SL8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 1; + return; + case MESA_FORMAT_SLA8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 2; + return; +#endif + +#if FEATURE_texture_fxt1 + case MESA_FORMAT_RGB_FXT1: + case MESA_FORMAT_RGBA_FXT1: +#endif +#if FEATURE_texture_s3tc + case MESA_FORMAT_RGB_DXT1: + case MESA_FORMAT_RGBA_DXT1: + case MESA_FORMAT_RGBA_DXT3: + case MESA_FORMAT_RGBA_DXT5: +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SRGB_DXT1: + case MESA_FORMAT_SRGBA_DXT1: + case MESA_FORMAT_SRGBA_DXT3: + case MESA_FORMAT_SRGBA_DXT5: +#endif +#endif + case MESA_FORMAT_RED_RGTC1: + case MESA_FORMAT_SIGNED_RED_RGTC1: + case MESA_FORMAT_RG_RGTC2: + case MESA_FORMAT_SIGNED_RG_RGTC2: + /* XXX generate error instead? */ + *datatype = GL_UNSIGNED_BYTE; + *comps = 0; + return; + + case MESA_FORMAT_RGBA_FLOAT32: + *datatype = GL_FLOAT; + *comps = 4; + return; + case MESA_FORMAT_RGBA_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 4; + return; + case MESA_FORMAT_RGB_FLOAT32: + *datatype = GL_FLOAT; + *comps = 3; + return; + case MESA_FORMAT_RGB_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 3; + return; + case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32: + *datatype = GL_FLOAT; + *comps = 2; + return; + case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 2; + return; + case MESA_FORMAT_ALPHA_FLOAT32: + case MESA_FORMAT_LUMINANCE_FLOAT32: + case MESA_FORMAT_INTENSITY_FLOAT32: + *datatype = GL_FLOAT; + *comps = 1; + return; + case MESA_FORMAT_ALPHA_FLOAT16: + case MESA_FORMAT_LUMINANCE_FLOAT16: + case MESA_FORMAT_INTENSITY_FLOAT16: + *datatype = GL_HALF_FLOAT_ARB; + *comps = 1; + return; + + case MESA_FORMAT_RGBA_INT8: + *datatype = GL_BYTE; + *comps = 4; + return; + case MESA_FORMAT_RGBA_INT16: + *datatype = GL_SHORT; + *comps = 4; + return; + case MESA_FORMAT_RGBA_INT32: + *datatype = GL_INT; + *comps = 4; + return; + + /** + * \name Non-normalized unsigned integer formats. + */ + case MESA_FORMAT_RGBA_UINT8: + *datatype = GL_UNSIGNED_BYTE; + *comps = 4; + return; + case MESA_FORMAT_RGBA_UINT16: + *datatype = GL_UNSIGNED_SHORT; + *comps = 4; + return; + case MESA_FORMAT_RGBA_UINT32: + *datatype = GL_UNSIGNED_INT; + *comps = 4; + return; + + case MESA_FORMAT_COUNT: + assert(0); + return; + + case MESA_FORMAT_NONE: + /* For debug builds, warn if any formats are not handled */ +#ifdef DEBUG + default: +#endif + _mesa_problem(NULL, "bad format %s in _mesa_format_to_type_and_comps", + _mesa_get_format_name(format)); + *datatype = 0; + *comps = 1; + } +} diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h index cd7e0e25e..e21967e2b 100644 --- a/mesalib/src/mesa/main/formats.h +++ b/mesalib/src/mesa/main/formats.h @@ -1,237 +1,243 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Authors: - * Brian Paul - */ - - -#ifndef FORMATS_H -#define FORMATS_H - - -#include - -/* OpenGL doesn't have GL_UNSIGNED_BYTE_4_4, so we must define our own type - * for GL_LUMINANCE4_ALPHA4. */ -#define MESA_UNSIGNED_BYTE_4_4 (GL_UNSIGNED_BYTE<<1) - - -/** - * Mesa texture/renderbuffer image formats. - */ -typedef enum -{ - MESA_FORMAT_NONE = 0, - - /** - * \name Basic hardware formats - */ - /*@{*/ - /* msb <------ TEXEL BITS -----------> lsb */ - /* ---- ---- ---- ---- ---- ---- ---- ---- */ - MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ - MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ - MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ - MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */ - MESA_FORMAT_XRGB8888, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */ - MESA_FORMAT_XRGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */ - MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */ - MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */ - MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */ - MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */ - MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */ - MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */ - MESA_FORMAT_RGBA5551, /* RRRR RGGG GGBB BBBA */ - MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */ - MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */ - MESA_FORMAT_AL44, /* AAAA LLLL */ - MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */ - MESA_FORMAT_AL88_REV, /* LLLL LLLL AAAA AAAA */ - MESA_FORMAT_AL1616, /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */ - MESA_FORMAT_AL1616_REV, /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */ - MESA_FORMAT_RGB332, /* RRRG GGBB */ - MESA_FORMAT_A8, /* AAAA AAAA */ - MESA_FORMAT_A16, /* AAAA AAAA AAAA AAAA */ - MESA_FORMAT_L8, /* LLLL LLLL */ - MESA_FORMAT_L16, /* LLLL LLLL LLLL LLLL */ - MESA_FORMAT_I8, /* IIII IIII */ - MESA_FORMAT_I16, /* IIII IIII IIII IIII */ - MESA_FORMAT_CI8, /* CCCC CCCC */ - MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */ - MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */ - MESA_FORMAT_R8, /* RRRR RRRR */ - MESA_FORMAT_RG88, /* RRRR RRRR GGGG GGGG */ - MESA_FORMAT_RG88_REV, /* GGGG GGGG RRRR RRRR */ - MESA_FORMAT_R16, /* RRRR RRRR RRRR RRRR */ - MESA_FORMAT_RG1616, /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */ - MESA_FORMAT_RG1616_REV, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */ - MESA_FORMAT_ARGB2101010, /* AARR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */ - MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */ - MESA_FORMAT_S8_Z24, /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_Z16, /* ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_X8_Z24, /* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_Z24_X8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ xxxx xxxx */ - MESA_FORMAT_Z32, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ - MESA_FORMAT_S8, /* SSSS SSSS */ - /*@}*/ - - /** - * \name 8-bit/channel sRGB formats - */ - /*@{*/ - MESA_FORMAT_SRGB8, - MESA_FORMAT_SRGBA8, - MESA_FORMAT_SARGB8, - MESA_FORMAT_SL8, - MESA_FORMAT_SLA8, - MESA_FORMAT_SRGB_DXT1, - MESA_FORMAT_SRGBA_DXT1, - MESA_FORMAT_SRGBA_DXT3, - MESA_FORMAT_SRGBA_DXT5, - /*@}*/ - - /** - * \name Compressed texture formats. - */ - /*@{*/ - MESA_FORMAT_RGB_FXT1, - MESA_FORMAT_RGBA_FXT1, - MESA_FORMAT_RGB_DXT1, - MESA_FORMAT_RGBA_DXT1, - MESA_FORMAT_RGBA_DXT3, - MESA_FORMAT_RGBA_DXT5, - /*@}*/ - - /** - * \name Floating point texture formats. - */ - /*@{*/ - MESA_FORMAT_RGBA_FLOAT32, - MESA_FORMAT_RGBA_FLOAT16, - MESA_FORMAT_RGB_FLOAT32, - MESA_FORMAT_RGB_FLOAT16, - MESA_FORMAT_ALPHA_FLOAT32, - MESA_FORMAT_ALPHA_FLOAT16, - MESA_FORMAT_LUMINANCE_FLOAT32, - MESA_FORMAT_LUMINANCE_FLOAT16, - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, - MESA_FORMAT_INTENSITY_FLOAT32, - MESA_FORMAT_INTENSITY_FLOAT16, - /*@}*/ - - /** - * \name Non-normalized signed integer formats. - * XXX Note: these are just stand-ins for some better hardware - * formats TBD such as BGRA or ARGB. - */ - MESA_FORMAT_RGBA_INT8, - MESA_FORMAT_RGBA_INT16, - MESA_FORMAT_RGBA_INT32, - - /** - * \name Non-normalized unsigned integer formats. - */ - MESA_FORMAT_RGBA_UINT8, - MESA_FORMAT_RGBA_UINT16, - MESA_FORMAT_RGBA_UINT32, - - /* msb <------ TEXEL BITS -----------> lsb */ - /* ---- ---- ---- ---- ---- ---- ---- ---- */ - /** - * \name Signed fixed point texture formats. - */ - /*@{*/ - MESA_FORMAT_DUDV8, /* DUDU DUDU DVDV DVDV */ - MESA_FORMAT_SIGNED_R8, /* RRRR RRRR */ - MESA_FORMAT_SIGNED_RG88, /* RRRR RRRR GGGG GGGG */ - MESA_FORMAT_SIGNED_RGBX8888, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */ - MESA_FORMAT_SIGNED_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ - MESA_FORMAT_SIGNED_RGBA8888_REV,/*AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ - MESA_FORMAT_SIGNED_R_16, /* ushort[0]=R */ - MESA_FORMAT_SIGNED_RG_16, /* ushort[0]=R, ushort[1]=G */ - MESA_FORMAT_SIGNED_RGB_16, /* ushort[0]=R, ushort[1]=G, ushort[2]=B */ - MESA_FORMAT_SIGNED_RGBA_16, /* ... */ - MESA_FORMAT_RGBA_16, /* ... */ - /*@}*/ - - MESA_FORMAT_COUNT -} gl_format; - - -extern const char * -_mesa_get_format_name(gl_format format); - -extern GLuint -_mesa_get_format_bytes(gl_format format); - -extern GLint -_mesa_get_format_bits(gl_format format, GLenum pname); - -extern GLenum -_mesa_get_format_datatype(gl_format format); - -extern GLenum -_mesa_get_format_base_format(gl_format format); - -extern void -_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh); - -extern GLboolean -_mesa_is_format_compressed(gl_format format); - -extern GLboolean -_mesa_is_format_packed_depth_stencil(gl_format format); - -extern GLboolean -_mesa_is_format_integer_color(gl_format format); - -extern GLenum -_mesa_get_format_color_encoding(gl_format format); - -extern GLuint -_mesa_format_image_size(gl_format format, GLsizei width, - GLsizei height, GLsizei depth); - -extern uint64_t -_mesa_format_image_size64(gl_format format, GLsizei width, - GLsizei height, GLsizei depth); - -extern GLint -_mesa_format_row_stride(gl_format format, GLsizei width); - -extern void -_mesa_format_to_type_and_comps(gl_format format, - GLenum *datatype, GLuint *comps); - -extern void -_mesa_test_formats(void); - -extern gl_format -_mesa_get_srgb_format_linear(gl_format format); - -#endif /* FORMATS_H */ +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Brian Paul + */ + + +#ifndef FORMATS_H +#define FORMATS_H + + +#include + +/* OpenGL doesn't have GL_UNSIGNED_BYTE_4_4, so we must define our own type + * for GL_LUMINANCE4_ALPHA4. */ +#define MESA_UNSIGNED_BYTE_4_4 (GL_UNSIGNED_BYTE<<1) + + +/** + * Mesa texture/renderbuffer image formats. + */ +typedef enum +{ + MESA_FORMAT_NONE = 0, + + /** + * \name Basic hardware formats + */ + /*@{*/ + /* msb <------ TEXEL BITS -----------> lsb */ + /* ---- ---- ---- ---- ---- ---- ---- ---- */ + MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ + MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */ + MESA_FORMAT_XRGB8888, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_XRGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */ + MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */ + MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */ + MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */ + MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */ + MESA_FORMAT_RGBA5551, /* RRRR RGGG GGBB BBBA */ + MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */ + MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */ + MESA_FORMAT_AL44, /* AAAA LLLL */ + MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */ + MESA_FORMAT_AL88_REV, /* LLLL LLLL AAAA AAAA */ + MESA_FORMAT_AL1616, /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */ + MESA_FORMAT_AL1616_REV, /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */ + MESA_FORMAT_RGB332, /* RRRG GGBB */ + MESA_FORMAT_A8, /* AAAA AAAA */ + MESA_FORMAT_A16, /* AAAA AAAA AAAA AAAA */ + MESA_FORMAT_L8, /* LLLL LLLL */ + MESA_FORMAT_L16, /* LLLL LLLL LLLL LLLL */ + MESA_FORMAT_I8, /* IIII IIII */ + MESA_FORMAT_I16, /* IIII IIII IIII IIII */ + MESA_FORMAT_CI8, /* CCCC CCCC */ + MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */ + MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */ + MESA_FORMAT_R8, /* RRRR RRRR */ + MESA_FORMAT_RG88, /* RRRR RRRR GGGG GGGG */ + MESA_FORMAT_RG88_REV, /* GGGG GGGG RRRR RRRR */ + MESA_FORMAT_R16, /* RRRR RRRR RRRR RRRR */ + MESA_FORMAT_RG1616, /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */ + MESA_FORMAT_RG1616_REV, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */ + MESA_FORMAT_ARGB2101010, /* AARR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */ + MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */ + MESA_FORMAT_S8_Z24, /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_Z16, /* ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_X8_Z24, /* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_Z24_X8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ xxxx xxxx */ + MESA_FORMAT_Z32, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ + MESA_FORMAT_S8, /* SSSS SSSS */ + /*@}*/ + + /** + * \name 8-bit/channel sRGB formats + */ + /*@{*/ + MESA_FORMAT_SRGB8, + MESA_FORMAT_SRGBA8, + MESA_FORMAT_SARGB8, + MESA_FORMAT_SL8, + MESA_FORMAT_SLA8, + MESA_FORMAT_SRGB_DXT1, + MESA_FORMAT_SRGBA_DXT1, + MESA_FORMAT_SRGBA_DXT3, + MESA_FORMAT_SRGBA_DXT5, + /*@}*/ + + /** + * \name Compressed texture formats. + */ + /*@{*/ + MESA_FORMAT_RGB_FXT1, + MESA_FORMAT_RGBA_FXT1, + MESA_FORMAT_RGB_DXT1, + MESA_FORMAT_RGBA_DXT1, + MESA_FORMAT_RGBA_DXT3, + MESA_FORMAT_RGBA_DXT5, + /*@}*/ + + /** + * \name Floating point texture formats. + */ + /*@{*/ + MESA_FORMAT_RGBA_FLOAT32, + MESA_FORMAT_RGBA_FLOAT16, + MESA_FORMAT_RGB_FLOAT32, + MESA_FORMAT_RGB_FLOAT16, + MESA_FORMAT_ALPHA_FLOAT32, + MESA_FORMAT_ALPHA_FLOAT16, + MESA_FORMAT_LUMINANCE_FLOAT32, + MESA_FORMAT_LUMINANCE_FLOAT16, + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, + MESA_FORMAT_INTENSITY_FLOAT32, + MESA_FORMAT_INTENSITY_FLOAT16, + /*@}*/ + + /** + * \name Non-normalized signed integer formats. + * XXX Note: these are just stand-ins for some better hardware + * formats TBD such as BGRA or ARGB. + */ + MESA_FORMAT_RGBA_INT8, + MESA_FORMAT_RGBA_INT16, + MESA_FORMAT_RGBA_INT32, + + /** + * \name Non-normalized unsigned integer formats. + */ + MESA_FORMAT_RGBA_UINT8, + MESA_FORMAT_RGBA_UINT16, + MESA_FORMAT_RGBA_UINT32, + + /* msb <------ TEXEL BITS -----------> lsb */ + /* ---- ---- ---- ---- ---- ---- ---- ---- */ + /** + * \name Signed fixed point texture formats. + */ + /*@{*/ + MESA_FORMAT_DUDV8, /* DUDU DUDU DVDV DVDV */ + MESA_FORMAT_SIGNED_R8, /* RRRR RRRR */ + MESA_FORMAT_SIGNED_RG88, /* RRRR RRRR GGGG GGGG */ + MESA_FORMAT_SIGNED_RGBX8888, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */ + MESA_FORMAT_SIGNED_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ + MESA_FORMAT_SIGNED_RGBA8888_REV,/*AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_SIGNED_R_16, /* ushort[0]=R */ + MESA_FORMAT_SIGNED_RG_16, /* ushort[0]=R, ushort[1]=G */ + MESA_FORMAT_SIGNED_RGB_16, /* ushort[0]=R, ushort[1]=G, ushort[2]=B */ + MESA_FORMAT_SIGNED_RGBA_16, /* ... */ + MESA_FORMAT_RGBA_16, /* ... */ + /*@}*/ + + /*@{*/ + MESA_FORMAT_RED_RGTC1, + MESA_FORMAT_SIGNED_RED_RGTC1, + MESA_FORMAT_RG_RGTC2, + MESA_FORMAT_SIGNED_RG_RGTC2, + /*@}*/ + MESA_FORMAT_COUNT +} gl_format; + + +extern const char * +_mesa_get_format_name(gl_format format); + +extern GLuint +_mesa_get_format_bytes(gl_format format); + +extern GLint +_mesa_get_format_bits(gl_format format, GLenum pname); + +extern GLenum +_mesa_get_format_datatype(gl_format format); + +extern GLenum +_mesa_get_format_base_format(gl_format format); + +extern void +_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh); + +extern GLboolean +_mesa_is_format_compressed(gl_format format); + +extern GLboolean +_mesa_is_format_packed_depth_stencil(gl_format format); + +extern GLboolean +_mesa_is_format_integer_color(gl_format format); + +extern GLenum +_mesa_get_format_color_encoding(gl_format format); + +extern GLuint +_mesa_format_image_size(gl_format format, GLsizei width, + GLsizei height, GLsizei depth); + +extern uint64_t +_mesa_format_image_size64(gl_format format, GLsizei width, + GLsizei height, GLsizei depth); + +extern GLint +_mesa_format_row_stride(gl_format format, GLsizei width); + +extern void +_mesa_format_to_type_and_comps(gl_format format, + GLenum *datatype, GLuint *comps); + +extern void +_mesa_test_formats(void); + +extern gl_format +_mesa_get_srgb_format_linear(gl_format format); + +#endif /* FORMATS_H */ diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c index eaebb06d3..82d02ed0e 100644 --- a/mesalib/src/mesa/main/texcompress.c +++ b/mesalib/src/mesa/main/texcompress.c @@ -1,249 +1,269 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * Copyright (c) 2008 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file texcompress.c - * Helper functions for texture compression. - */ - - -#include "glheader.h" -#include "imports.h" -#include "colormac.h" -#include "formats.h" -#include "mfeatures.h" -#include "mtypes.h" -#include "texcompress.h" - - -/** - * Return list of (and count of) all specific texture compression - * formats that are supported. - * - * \param ctx the GL context - * \param formats the resulting format list (may be NULL). - * \param all if true return all formats, even those with some kind - * of restrictions/limitations (See GL_ARB_texture_compression - * spec for more info). - * - * \return number of formats. - */ -GLuint -_mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats, GLboolean all) -{ - GLuint n = 0; - if (ctx->Extensions.TDFX_texture_compression_FXT1) { - if (formats) { - formats[n++] = GL_COMPRESSED_RGB_FXT1_3DFX; - formats[n++] = GL_COMPRESSED_RGBA_FXT1_3DFX; - } - else { - n += 2; - } - } - if (ctx->Extensions.EXT_texture_compression_s3tc) { - if (formats) { - formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; - /* This format has some restrictions/limitations and so should - * not be returned via the GL_COMPRESSED_TEXTURE_FORMATS query. - * Specifically, all transparent pixels become black. NVIDIA - * omits this format too. - */ - if (all) - formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - } - else { - n += 3; - if (all) - n += 1; - } - } - if (ctx->Extensions.S3_s3tc) { - if (formats) { - formats[n++] = GL_RGB_S3TC; - formats[n++] = GL_RGB4_S3TC; - formats[n++] = GL_RGBA_S3TC; - formats[n++] = GL_RGBA4_S3TC; - } - else { - n += 4; - } - } -#if FEATURE_EXT_texture_sRGB - if (ctx->Extensions.EXT_texture_sRGB) { - if (formats) { - formats[n++] = GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; - formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; - formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; - formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; - } - else { - n += 4; - } - } -#endif /* FEATURE_EXT_texture_sRGB */ - return n; - -#if FEATURE_ES1 || FEATURE_ES2 - if (formats) { - formats[n++] = GL_PALETTE4_RGB8_OES; - formats[n++] = GL_PALETTE4_RGBA8_OES; - formats[n++] = GL_PALETTE4_R5_G6_B5_OES; - formats[n++] = GL_PALETTE4_RGBA4_OES; - formats[n++] = GL_PALETTE4_RGB5_A1_OES; - formats[n++] = GL_PALETTE8_RGB8_OES; - formats[n++] = GL_PALETTE8_RGBA8_OES; - formats[n++] = GL_PALETTE8_R5_G6_B5_OES; - formats[n++] = GL_PALETTE8_RGBA4_OES; - formats[n++] = GL_PALETTE8_RGB5_A1_OES; - } - else { - n += 10; - } -#endif -} - - -/** - * Convert a compressed MESA_FORMAT_x to a GLenum. - */ -gl_format -_mesa_glenum_to_compressed_format(GLenum format) -{ - switch (format) { - case GL_COMPRESSED_RGB_FXT1_3DFX: - return MESA_FORMAT_RGB_FXT1; - case GL_COMPRESSED_RGBA_FXT1_3DFX: - return MESA_FORMAT_RGBA_FXT1; - - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_RGB_S3TC: - return MESA_FORMAT_RGB_DXT1; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_RGB4_S3TC: - return MESA_FORMAT_RGBA_DXT1; - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_RGBA_S3TC: - return MESA_FORMAT_RGBA_DXT3; - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - case GL_RGBA4_S3TC: - return MESA_FORMAT_RGBA_DXT5; - - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: - return MESA_FORMAT_SRGB_DXT1; - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - return MESA_FORMAT_SRGBA_DXT1; - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: - return MESA_FORMAT_SRGBA_DXT3; - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - return MESA_FORMAT_SRGBA_DXT5; - - default: - return MESA_FORMAT_NONE; - } -} - - -/** - * Given a compressed MESA_FORMAT_x value, return the corresponding - * GLenum for that format. - * This is needed for glGetTexLevelParameter(GL_TEXTURE_INTERNAL_FORMAT) - * which must return the specific texture format used when the user might - * have originally specified a generic compressed format in their - * glTexImage2D() call. - * For non-compressed textures, we always return the user-specified - * internal format unchanged. - */ -GLenum -_mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat) -{ - switch (mesaFormat) { -#if FEATURE_texture_fxt1 - case MESA_FORMAT_RGB_FXT1: - return GL_COMPRESSED_RGB_FXT1_3DFX; - case MESA_FORMAT_RGBA_FXT1: - return GL_COMPRESSED_RGBA_FXT1_3DFX; -#endif -#if FEATURE_texture_s3tc - case MESA_FORMAT_RGB_DXT1: - return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; - case MESA_FORMAT_RGBA_DXT1: - return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - case MESA_FORMAT_RGBA_DXT3: - return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - case MESA_FORMAT_RGBA_DXT5: - return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; -#if FEATURE_EXT_texture_sRGB - case MESA_FORMAT_SRGB_DXT1: - return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; - case MESA_FORMAT_SRGBA_DXT1: - return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; - case MESA_FORMAT_SRGBA_DXT3: - return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; - case MESA_FORMAT_SRGBA_DXT5: - return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; -#endif -#endif - default: - _mesa_problem(ctx, "Unexpected mesa texture format in" - " _mesa_compressed_format_to_glenum()"); - return 0; - } -} - - -/* - * Return the address of the pixel at (col, row, img) in a - * compressed texture image. - * \param col, row, img - image position (3D), should be a multiple of the - * format's block size. - * \param format - compressed image format - * \param width - image width (stride) in pixels - * \param image - the image address - * \return address of pixel at (row, col, img) - */ -GLubyte * -_mesa_compressed_image_address(GLint col, GLint row, GLint img, - gl_format mesaFormat, - GLsizei width, const GLubyte *image) -{ - /* XXX only 2D images implemented, not 3D */ - const GLuint blockSize = _mesa_get_format_bytes(mesaFormat); - GLuint bw, bh; - GLint offset; - - _mesa_get_format_block_size(mesaFormat, &bw, &bh); - - ASSERT(col % bw == 0); - ASSERT(row % bh == 0); - - offset = ((width + bw - 1) / bw) * (row / bh) + col / bw; - offset *= blockSize; - - return (GLubyte *) image + offset; -} +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (c) 2008 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file texcompress.c + * Helper functions for texture compression. + */ + + +#include "glheader.h" +#include "imports.h" +#include "colormac.h" +#include "formats.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "texcompress.h" + + +/** + * Return list of (and count of) all specific texture compression + * formats that are supported. + * + * \param ctx the GL context + * \param formats the resulting format list (may be NULL). + * \param all if true return all formats, even those with some kind + * of restrictions/limitations (See GL_ARB_texture_compression + * spec for more info). + * + * \return number of formats. + */ +GLuint +_mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats, GLboolean all) +{ + GLuint n = 0; + if (ctx->Extensions.TDFX_texture_compression_FXT1) { + if (formats) { + formats[n++] = GL_COMPRESSED_RGB_FXT1_3DFX; + formats[n++] = GL_COMPRESSED_RGBA_FXT1_3DFX; + } + else { + n += 2; + } + } + /* don't return RGTC - ARB_texture_compression_rgtc query 19 */ + if (ctx->Extensions.EXT_texture_compression_s3tc) { + if (formats) { + formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; + /* This format has some restrictions/limitations and so should + * not be returned via the GL_COMPRESSED_TEXTURE_FORMATS query. + * Specifically, all transparent pixels become black. NVIDIA + * omits this format too. + */ + if (all) + formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + } + else { + n += 3; + if (all) + n += 1; + } + } + if (ctx->Extensions.S3_s3tc) { + if (formats) { + formats[n++] = GL_RGB_S3TC; + formats[n++] = GL_RGB4_S3TC; + formats[n++] = GL_RGBA_S3TC; + formats[n++] = GL_RGBA4_S3TC; + } + else { + n += 4; + } + } +#if FEATURE_EXT_texture_sRGB + if (ctx->Extensions.EXT_texture_sRGB) { + if (formats) { + formats[n++] = GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; + formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + formats[n++] = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; + } + else { + n += 4; + } + } +#endif /* FEATURE_EXT_texture_sRGB */ + return n; + +#if FEATURE_ES1 || FEATURE_ES2 + if (formats) { + formats[n++] = GL_PALETTE4_RGB8_OES; + formats[n++] = GL_PALETTE4_RGBA8_OES; + formats[n++] = GL_PALETTE4_R5_G6_B5_OES; + formats[n++] = GL_PALETTE4_RGBA4_OES; + formats[n++] = GL_PALETTE4_RGB5_A1_OES; + formats[n++] = GL_PALETTE8_RGB8_OES; + formats[n++] = GL_PALETTE8_RGBA8_OES; + formats[n++] = GL_PALETTE8_R5_G6_B5_OES; + formats[n++] = GL_PALETTE8_RGBA4_OES; + formats[n++] = GL_PALETTE8_RGB5_A1_OES; + } + else { + n += 10; + } +#endif +} + + +/** + * Convert a compressed MESA_FORMAT_x to a GLenum. + */ +gl_format +_mesa_glenum_to_compressed_format(GLenum format) +{ + switch (format) { + case GL_COMPRESSED_RGB_FXT1_3DFX: + return MESA_FORMAT_RGB_FXT1; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return MESA_FORMAT_RGBA_FXT1; + + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_RGB_S3TC: + return MESA_FORMAT_RGB_DXT1; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_RGB4_S3TC: + return MESA_FORMAT_RGBA_DXT1; + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_RGBA_S3TC: + return MESA_FORMAT_RGBA_DXT3; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + case GL_RGBA4_S3TC: + return MESA_FORMAT_RGBA_DXT5; + + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + return MESA_FORMAT_SRGB_DXT1; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + return MESA_FORMAT_SRGBA_DXT1; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + return MESA_FORMAT_SRGBA_DXT3; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return MESA_FORMAT_SRGBA_DXT5; + + case GL_COMPRESSED_RED_RGTC1: + return MESA_FORMAT_RED_RGTC1; + case GL_COMPRESSED_SIGNED_RED_RGTC1: + return MESA_FORMAT_SIGNED_RED_RGTC1; + case GL_COMPRESSED_RG_RGTC2: + return MESA_FORMAT_RG_RGTC2; + case GL_COMPRESSED_SIGNED_RG_RGTC2: + return MESA_FORMAT_SIGNED_RG_RGTC2; + + default: + return MESA_FORMAT_NONE; + } +} + + +/** + * Given a compressed MESA_FORMAT_x value, return the corresponding + * GLenum for that format. + * This is needed for glGetTexLevelParameter(GL_TEXTURE_INTERNAL_FORMAT) + * which must return the specific texture format used when the user might + * have originally specified a generic compressed format in their + * glTexImage2D() call. + * For non-compressed textures, we always return the user-specified + * internal format unchanged. + */ +GLenum +_mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat) +{ + switch (mesaFormat) { +#if FEATURE_texture_fxt1 + case MESA_FORMAT_RGB_FXT1: + return GL_COMPRESSED_RGB_FXT1_3DFX; + case MESA_FORMAT_RGBA_FXT1: + return GL_COMPRESSED_RGBA_FXT1_3DFX; +#endif +#if FEATURE_texture_s3tc + case MESA_FORMAT_RGB_DXT1: + return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; + case MESA_FORMAT_RGBA_DXT1: + return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + case MESA_FORMAT_RGBA_DXT3: + return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + case MESA_FORMAT_RGBA_DXT5: + return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SRGB_DXT1: + return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; + case MESA_FORMAT_SRGBA_DXT1: + return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + case MESA_FORMAT_SRGBA_DXT3: + return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + case MESA_FORMAT_SRGBA_DXT5: + return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; +#endif +#endif + + case MESA_FORMAT_RED_RGTC1: + return GL_COMPRESSED_RED_RGTC1; + case MESA_FORMAT_SIGNED_RED_RGTC1: + return GL_COMPRESSED_SIGNED_RED_RGTC1; + case MESA_FORMAT_RG_RGTC2: + return GL_COMPRESSED_RG_RGTC2; + case MESA_FORMAT_SIGNED_RG_RGTC2: + return GL_COMPRESSED_SIGNED_RG_RGTC2; + + default: + _mesa_problem(ctx, "Unexpected mesa texture format in" + " _mesa_compressed_format_to_glenum()"); + return 0; + } +} + + +/* + * Return the address of the pixel at (col, row, img) in a + * compressed texture image. + * \param col, row, img - image position (3D), should be a multiple of the + * format's block size. + * \param format - compressed image format + * \param width - image width (stride) in pixels + * \param image - the image address + * \return address of pixel at (row, col, img) + */ +GLubyte * +_mesa_compressed_image_address(GLint col, GLint row, GLint img, + gl_format mesaFormat, + GLsizei width, const GLubyte *image) +{ + /* XXX only 2D images implemented, not 3D */ + const GLuint blockSize = _mesa_get_format_bytes(mesaFormat); + GLuint bw, bh; + GLint offset; + + _mesa_get_format_block_size(mesaFormat, &bw, &bh); + + ASSERT(col % bw == 0); + ASSERT(row % bh == 0); + + offset = ((width + bw - 1) / bw) * (row / bh) + col / bw; + offset *= blockSize; + + return (GLubyte *) image + offset; +} diff --git a/mesalib/src/mesa/main/texcompress_rgtc.c b/mesalib/src/mesa/main/texcompress_rgtc.c new file mode 100644 index 000000000..b7725f4a9 --- /dev/null +++ b/mesalib/src/mesa/main/texcompress_rgtc.c @@ -0,0 +1,1122 @@ +/* + * Copyright (C) 2011 Red Hat Inc. + * + * block compression parts are: + * Copyright (C) 2004 Roland Scheidegger All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: + * Dave Airlie + */ + +/** + * \file texcompress_rgtc.c + * GL_EXT_texture_compression_rgtc support. + */ + + +#include "glheader.h" +#include "imports.h" +#include "colormac.h" +#include "image.h" +#include "macros.h" +#include "mfeatures.h" +#include "mipmap.h" +#include "texcompress.h" +#include "texcompress_rgtc.h" +#include "texstore.h" + +#define RGTC_DEBUG 0 + +static void encode_rgtc_chan_u(GLubyte *blkaddr, GLubyte srccolors[4][4], + GLint numxpixels, GLint numypixels); +static void encode_rgtc_chan_s(GLbyte *blkaddr, GLbyte srccolors[4][4], + GLint numxpixels, GLint numypixels); + +static void extractsrc_u( GLubyte srcpixels[4][4], const GLchan *srcaddr, + GLint srcRowStride, GLint numxpixels, GLint numypixels, GLint comps) +{ + GLubyte i, j; + const GLchan *curaddr; + for (j = 0; j < numypixels; j++) { + curaddr = srcaddr + j * srcRowStride * comps; + for (i = 0; i < numxpixels; i++) { + srcpixels[j][i] = *curaddr / (CHAN_MAX / 255); + curaddr += comps; + } + } +} + +static void extractsrc_s( GLbyte srcpixels[4][4], const GLfloat *srcaddr, + GLint srcRowStride, GLint numxpixels, GLint numypixels, GLint comps) +{ + GLubyte i, j; + const GLfloat *curaddr; + for (j = 0; j < numypixels; j++) { + curaddr = srcaddr + j * srcRowStride * comps; + for (i = 0; i < numxpixels; i++) { + srcpixels[j][i] = FLOAT_TO_BYTE_TEX(*curaddr); + curaddr += comps; + } + } +} + + +GLboolean +_mesa_texstore_red_rgtc1(TEXSTORE_PARAMS) +{ + GLubyte *dst; + const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ + const GLchan *tempImage = NULL; + int i, j; + int numxpixels, numypixels; + const void *srcaddr; + GLubyte srcpixels[4][4]; + GLubyte *blkaddr; + GLint dstRowDiff; + ASSERT(dstFormat == MESA_FORMAT_RED_RGTC1); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + + blkaddr = dst; + dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0; + for (j = 0; j < srcHeight; j+=4) { + if (srcHeight > j + 3) numypixels = 4; + else numypixels = srcHeight - j; + srcaddr = tempImage + j * srcWidth; + for (i = 0; i < srcWidth; i += 4) { + if (srcWidth > i + 3) numxpixels = 4; + else numxpixels = srcWidth - i; + extractsrc_u(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 1); + encode_rgtc_chan_u(blkaddr, srcpixels, numxpixels, numypixels); + srcaddr += numxpixels; + blkaddr += 8; + } + blkaddr += dstRowDiff; + } + if (tempImage) + free((void *) tempImage); + + return GL_TRUE; +} + +GLboolean +_mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS) +{ + GLbyte *dst; + const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ + const GLfloat *tempImage = NULL; + int i, j; + int numxpixels, numypixels; + const GLfloat *srcaddr; + GLbyte srcpixels[4][4]; + GLbyte *blkaddr; + GLint dstRowDiff; + ASSERT(dstFormat == MESA_FORMAT_SIGNED_RED_RGTC1); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, 0x0); + if (!tempImage) + return GL_FALSE; /* out of memory */ + + dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + + blkaddr = dst; + dstRowDiff = dstRowStride >= (srcWidth * 4) ? dstRowStride - (((srcWidth + 3) & ~3) * 4) : 0; + for (j = 0; j < srcHeight; j+=4) { + if (srcHeight > j + 3) numypixels = 4; + else numypixels = srcHeight - j; + srcaddr = tempImage + j * srcWidth; + for (i = 0; i < srcWidth; i += 4) { + if (srcWidth > i + 3) numxpixels = 4; + else numxpixels = srcWidth - i; + extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 1); + encode_rgtc_chan_s(blkaddr, srcpixels, numxpixels, numypixels); + srcaddr += numxpixels; + blkaddr += 8; + } + blkaddr += dstRowDiff; + } + if (tempImage) + free((void *) tempImage); + + return GL_TRUE; +} + +GLboolean +_mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS) +{ + GLubyte *dst; + const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ + const GLchan *tempImage = NULL; + int i, j; + int numxpixels, numypixels; + const void *srcaddr; + GLubyte srcpixels[4][4]; + GLubyte *blkaddr; + GLint dstRowDiff; + + ASSERT(dstFormat == MESA_FORMAT_RG_RGTC2); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + if (!tempImage) + return GL_FALSE; /* out of memory */ + + dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + + blkaddr = dst; + dstRowDiff = dstRowStride >= (srcWidth * 8) ? dstRowStride - (((srcWidth + 7) & ~7) * 8) : 0; + for (j = 0; j < srcHeight; j+=4) { + if (srcHeight > j + 3) numypixels = 4; + else numypixels = srcHeight - j; + srcaddr = tempImage + j * srcWidth * 2; + for (i = 0; i < srcWidth; i += 4) { + if (srcWidth > i + 3) numxpixels = 4; + else numxpixels = srcWidth - i; + extractsrc_u(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 2); + encode_rgtc_chan_u(blkaddr, srcpixels, numxpixels, numypixels); + + blkaddr += 8; + extractsrc_u(srcpixels, (GLchan *)srcaddr + 1, srcWidth, numxpixels, numypixels, 2); + encode_rgtc_chan_u(blkaddr, srcpixels, numxpixels, numypixels); + + blkaddr += 8; + + srcaddr += numxpixels * 2; + } + blkaddr += dstRowDiff; + } + if (tempImage) + free((void *) tempImage); + + return GL_TRUE; +} + +GLboolean +_mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS) +{ + GLbyte *dst; + const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ + const GLfloat *tempImage = NULL; + int i, j; + int numxpixels, numypixels; + const GLfloat *srcaddr; + GLbyte srcpixels[4][4]; + GLbyte *blkaddr; + GLint dstRowDiff; + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG_RGTC2); + ASSERT(dstXoffset % 4 == 0); + ASSERT(dstYoffset % 4 == 0); + ASSERT(dstZoffset % 4 == 0); + (void) dstZoffset; + (void) dstImageOffsets; + + tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + _mesa_get_format_base_format(dstFormat), + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, 0x0); + if (!tempImage) + return GL_FALSE; /* out of memory */ + + dst = (GLbyte *)_mesa_compressed_image_address(dstXoffset, dstYoffset, 0, + dstFormat, + texWidth, (GLubyte *) dstAddr); + + blkaddr = dst; + dstRowDiff = dstRowStride >= (srcWidth * 8) ? dstRowStride - (((srcWidth + 7) & ~7) * 8) : 0; + for (j = 0; j < srcHeight; j += 4) { + if (srcHeight > j + 3) numypixels = 4; + else numypixels = srcHeight - j; + srcaddr = tempImage + j * srcWidth * 2; + for (i = 0; i < srcWidth; i += 4) { + if (srcWidth > i + 3) numxpixels = 4; + else numxpixels = srcWidth - i; + + extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 2); + encode_rgtc_chan_s(blkaddr, srcpixels, numxpixels, numypixels); + blkaddr += 8; + + extractsrc_s(srcpixels, srcaddr + 1, srcWidth, numxpixels, numypixels, 2); + encode_rgtc_chan_s(blkaddr, srcpixels, numxpixels, numypixels); + blkaddr += 8; + + srcaddr += numxpixels * 2; + + } + blkaddr += dstRowDiff; + } + if (tempImage) + free((void *) tempImage); + + return GL_TRUE; +} + +static void _fetch_texel_rgtc_u(GLint srcRowStride, const GLubyte *pixdata, + GLint i, GLint j, GLchan *value, int comps) +{ + GLchan decode; + const GLubyte *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 8 * comps); + const GLubyte alpha0 = blksrc[0]; + const GLubyte alpha1 = blksrc[1]; + const GLubyte bit_pos = ((j&3) * 4 + (i&3)) * 3; + const GLubyte acodelow = blksrc[2 + bit_pos / 8]; + const GLubyte acodehigh = blksrc[3 + bit_pos / 8]; + const GLubyte code = (acodelow >> (bit_pos & 0x7) | + (acodehigh << (8 - (bit_pos & 0x7)))) & 0x7; + + if (code == 0) + decode = UBYTE_TO_CHAN( alpha0 ); + else if (code == 1) + decode = UBYTE_TO_CHAN( alpha1 ); + else if (alpha0 > alpha1) + decode = UBYTE_TO_CHAN( ((alpha0 * (8 - code) + (alpha1 * (code - 1))) / 7) ); + else if (code < 6) + decode = UBYTE_TO_CHAN( ((alpha0 * (6 - code) + (alpha1 * (code - 1))) / 5) ); + else if (code == 6) + decode = 0; + else + decode = CHAN_MAX; + + *value = decode; +} + + +static void _fetch_texel_rgtc_s(GLint srcRowStride, const GLbyte *pixdata, + GLint i, GLint j, GLbyte *value, int comps) +{ + GLbyte decode; + const GLbyte *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 8 * comps); + const GLbyte alpha0 = blksrc[0]; + const GLbyte alpha1 = blksrc[1]; + const GLbyte bit_pos = ((j&3) * 4 + (i&3)) * 3; + const GLbyte acodelow = blksrc[2 + bit_pos / 8]; + const GLbyte acodehigh = blksrc[3 + bit_pos / 8]; + const GLbyte code = (acodelow >> (bit_pos & 0x7) | + (acodehigh << (8 - (bit_pos & 0x7)))) & 0x7; + + if (code == 0) + decode = alpha0; + else if (code == 1) + decode = alpha1; + else if (alpha0 > alpha1) + decode = ((alpha0 * (8 - code) + (alpha1 * (code - 1))) / 7); + else if (code < 6) + decode = ((alpha0 * (6 - code) + (alpha1 * (code - 1))) / 5); + else if (code == 6) + decode = -128; + else + decode = 127; + + *value = decode; +} + +void +_mesa_fetch_texel_2d_f_red_rgtc1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + GLchan red; + _fetch_texel_rgtc_u(texImage->RowStride, (GLubyte *)(texImage->Data), + i, j, &red, 1); + texel[RCOMP] = CHAN_TO_FLOAT(red); + texel[GCOMP] = 0.0; + texel[BCOMP] = 0.0; + texel[ACOMP] = 1.0; +} + +void +_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + GLbyte red; + _fetch_texel_rgtc_s(texImage->RowStride, (GLbyte *)(texImage->Data), + i, j, &red, 1); + texel[RCOMP] = BYTE_TO_FLOAT_TEX(red); + texel[GCOMP] = 0.0; + texel[BCOMP] = 0.0; + texel[ACOMP] = 1.0; +} + +void +_mesa_fetch_texel_2d_f_rg_rgtc2(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + GLchan red, green; + _fetch_texel_rgtc_u(texImage->RowStride, (GLubyte *)(texImage->Data), + i, j, &red, 2); + _fetch_texel_rgtc_u(texImage->RowStride, (GLubyte *)(texImage->Data) + 8, + i, j, &green, 2); + texel[RCOMP] = CHAN_TO_FLOAT(red); + texel[GCOMP] = CHAN_TO_FLOAT(green); + texel[BCOMP] = 0.0; + texel[ACOMP] = 1.0; +} + +void +_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + GLbyte red, green; + _fetch_texel_rgtc_s(texImage->RowStride, (GLbyte *)(texImage->Data), + i, j, &red, 2); + _fetch_texel_rgtc_s(texImage->RowStride, (GLbyte *)(texImage->Data) + 8, + i, j, &green, 2); + texel[RCOMP] = BYTE_TO_FLOAT_TEX(red); + texel[GCOMP] = BYTE_TO_FLOAT_TEX(green); + texel[BCOMP] = 0.0; + texel[ACOMP] = 1.0; +} + +static void write_rgtc_encoded_channel(GLubyte *blkaddr, + GLubyte alphabase1, + GLubyte alphabase2, + GLubyte alphaenc[16]) +{ + *blkaddr++ = alphabase1; + *blkaddr++ = alphabase2; + *blkaddr++ = alphaenc[0] | (alphaenc[1] << 3) | ((alphaenc[2] & 3) << 6); + *blkaddr++ = (alphaenc[2] >> 2) | (alphaenc[3] << 1) | (alphaenc[4] << 4) | ((alphaenc[5] & 1) << 7); + *blkaddr++ = (alphaenc[5] >> 1) | (alphaenc[6] << 2) | (alphaenc[7] << 5); + *blkaddr++ = alphaenc[8] | (alphaenc[9] << 3) | ((alphaenc[10] & 3) << 6); + *blkaddr++ = (alphaenc[10] >> 2) | (alphaenc[11] << 1) | (alphaenc[12] << 4) | ((alphaenc[13] & 1) << 7); + *blkaddr++ = (alphaenc[13] >> 1) | (alphaenc[14] << 2) | (alphaenc[15] << 5); +} + +static void encode_rgtc_chan_u(GLubyte *blkaddr, GLubyte srccolors[4][4], + GLint numxpixels, GLint numypixels) +{ + GLubyte alphabase[2], alphause[2]; + GLshort alphatest[2] = { 0 }; + GLuint alphablockerror1, alphablockerror2, alphablockerror3; + GLubyte i, j, aindex, acutValues[7]; + GLubyte alphaenc1[16], alphaenc2[16], alphaenc3[16]; + GLboolean alphaabsmin = GL_FALSE; + GLboolean alphaabsmax = GL_FALSE; + GLshort alphadist; + + /* find lowest and highest alpha value in block, alphabase[0] lowest, alphabase[1] highest */ + alphabase[0] = 0xff; alphabase[1] = 0x0; + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if (srccolors[j][i] == 0) + alphaabsmin = GL_TRUE; + else if (srccolors[j][i] == 255) + alphaabsmax = GL_TRUE; + else { + if (srccolors[j][i] > alphabase[1]) + alphabase[1] = srccolors[j][i]; + if (srccolors[j][i] < alphabase[0]) + alphabase[0] = srccolors[j][i]; + } + } + } + + + if ((alphabase[0] > alphabase[1]) && !(alphaabsmin && alphaabsmax)) { /* one color, either max or min */ + /* shortcut here since it is a very common case (and also avoids later problems) */ + /* || (alphabase[0] == alphabase[1] && !alphaabsmin && !alphaabsmax) */ + /* could also thest for alpha0 == alpha1 (and not min/max), but probably not common, so don't bother */ + + *blkaddr++ = srccolors[0][0]; + blkaddr++; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; +#if RGTC_DEBUG + fprintf(stderr, "enc0 used\n"); +#endif + return; + } + + /* find best encoding for alpha0 > alpha1 */ + /* it's possible this encoding is better even if both alphaabsmin and alphaabsmax are true */ + alphablockerror1 = 0x0; + alphablockerror2 = 0xffffffff; + alphablockerror3 = 0xffffffff; + if (alphaabsmin) alphause[0] = 0; + else alphause[0] = alphabase[0]; + if (alphaabsmax) alphause[1] = 255; + else alphause[1] = alphabase[1]; + /* calculate the 7 cut values, just the middle between 2 of the computed alpha values */ + for (aindex = 0; aindex < 7; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphause[0] * (2*aindex + 1) + alphause[1] * (14 - (2*aindex + 1))) / 14; + } + + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] > acutValues[0]) { + alphaenc1[4*j + i] = 0; + alphadist = srccolors[j][i] - alphause[1]; + } + else if (srccolors[j][i] > acutValues[1]) { + alphaenc1[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphause[1] * 6 + alphause[0] * 1) / 7; + } + else if (srccolors[j][i] > acutValues[2]) { + alphaenc1[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphause[1] * 5 + alphause[0] * 2) / 7; + } + else if (srccolors[j][i] > acutValues[3]) { + alphaenc1[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphause[1] * 4 + alphause[0] * 3) / 7; + } + else if (srccolors[j][i] > acutValues[4]) { + alphaenc1[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphause[1] * 3 + alphause[0] * 4) / 7; + } + else if (srccolors[j][i] > acutValues[5]) { + alphaenc1[4*j + i] = 6; + alphadist = srccolors[j][i] - (alphause[1] * 2 + alphause[0] * 5) / 7; + } + else if (srccolors[j][i] > acutValues[6]) { + alphaenc1[4*j + i] = 7; + alphadist = srccolors[j][i] - (alphause[1] * 1 + alphause[0] * 6) / 7; + } + else { + alphaenc1[4*j + i] = 1; + alphadist = srccolors[j][i] - alphause[0]; + } + alphablockerror1 += alphadist * alphadist; + } + } + +#if RGTC_DEBUG + for (i = 0; i < 16; i++) { + fprintf(stderr, "%d ", alphaenc1[i]); + } + fprintf(stderr, "cutVals "); + for (i = 0; i < 8; i++) { + fprintf(stderr, "%d ", acutValues[i]); + } + fprintf(stderr, "srcVals "); + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + fprintf(stderr, "%d ", srccolors[j][i]); + } + } + fprintf(stderr, "\n"); +#endif + + /* it's not very likely this encoding is better if both alphaabsmin and alphaabsmax + are false but try it anyway */ + if (alphablockerror1 >= 32) { + + /* don't bother if encoding is already very good, this condition should also imply + we have valid alphabase colors which we absolutely need (alphabase[0] <= alphabase[1]) */ + alphablockerror2 = 0; + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphabase[0] * (10 - (2*aindex + 1)) + alphabase[1] * (2*aindex + 1)) / 10; + } + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] == 0) { + alphaenc2[4*j + i] = 6; + alphadist = 0; + } + else if (srccolors[j][i] == 255) { + alphaenc2[4*j + i] = 7; + alphadist = 0; + } + else if (srccolors[j][i] <= acutValues[0]) { + alphaenc2[4*j + i] = 0; + alphadist = srccolors[j][i] - alphabase[0]; + } + else if (srccolors[j][i] <= acutValues[1]) { + alphaenc2[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphabase[0] * 4 + alphabase[1] * 1) / 5; + } + else if (srccolors[j][i] <= acutValues[2]) { + alphaenc2[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphabase[0] * 3 + alphabase[1] * 2) / 5; + } + else if (srccolors[j][i] <= acutValues[3]) { + alphaenc2[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphabase[0] * 2 + alphabase[1] * 3) / 5; + } + else if (srccolors[j][i] <= acutValues[4]) { + alphaenc2[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphabase[0] * 1 + alphabase[1] * 4) / 5; + } + else { + alphaenc2[4*j + i] = 1; + alphadist = srccolors[j][i] - alphabase[1]; + } + alphablockerror2 += alphadist * alphadist; + } + } + + + /* skip this if the error is already very small + this encoding is MUCH better on average than #2 though, but expensive! */ + if ((alphablockerror2 > 96) && (alphablockerror1 > 96)) { + GLshort blockerrlin1 = 0; + GLshort blockerrlin2 = 0; + GLubyte nralphainrangelow = 0; + GLubyte nralphainrangehigh = 0; + alphatest[0] = 0xff; + alphatest[1] = 0x0; + /* if we have large range it's likely there are values close to 0/255, try to map them to 0/255 */ + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if ((srccolors[j][i] > alphatest[1]) && (srccolors[j][i] < (255 -(alphabase[1] - alphabase[0]) / 28))) + alphatest[1] = srccolors[j][i]; + if ((srccolors[j][i] < alphatest[0]) && (srccolors[j][i] > (alphabase[1] - alphabase[0]) / 28)) + alphatest[0] = srccolors[j][i]; + } + } + /* shouldn't happen too often, don't really care about those degenerated cases */ + if (alphatest[1] <= alphatest[0]) { + alphatest[0] = 1; + alphatest[1] = 254; + } + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; + } + + /* find the "average" difference between the alpha values and the next encoded value. + This is then used to calculate new base values. + Should there be some weighting, i.e. those values closer to alphatest[x] have more weight, + since they will see more improvement, and also because the values in the middle are somewhat + likely to get no improvement at all (because the base values might move in different directions)? + OTOH it would mean the values in the middle are even less likely to get an improvement + */ + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if (srccolors[j][i] <= alphatest[0] / 2) { + } + else if (srccolors[j][i] > ((255 + alphatest[1]) / 2)) { + } + else if (srccolors[j][i] <= acutValues[0]) { + blockerrlin1 += (srccolors[j][i] - alphatest[0]); + nralphainrangelow += 1; + } + else if (srccolors[j][i] <= acutValues[1]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[2]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[3]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[4]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else { + blockerrlin2 += (srccolors[j][i] - alphatest[1]); + nralphainrangehigh += 1; + } + } + } + /* shouldn't happen often, needed to avoid div by zero */ + if (nralphainrangelow == 0) nralphainrangelow = 1; + if (nralphainrangehigh == 0) nralphainrangehigh = 1; + alphatest[0] = alphatest[0] + (blockerrlin1 / nralphainrangelow); +#if RGTC_DEBUG + fprintf(stderr, "block err lin low %d, nr %d\n", blockerrlin1, nralphainrangelow); + fprintf(stderr, "block err lin high %d, nr %d\n", blockerrlin2, nralphainrangehigh); +#endif + /* again shouldn't really happen often... */ + if (alphatest[0] < 0) { + alphatest[0] = 0; + } + alphatest[1] = alphatest[1] + (blockerrlin2 / nralphainrangehigh); + if (alphatest[1] > 255) { + alphatest[1] = 255; + } + + alphablockerror3 = 0; + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; + } + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] <= alphatest[0] / 2) { + alphaenc3[4*j + i] = 6; + alphadist = srccolors[j][i]; + } + else if (srccolors[j][i] > ((255 + alphatest[1]) / 2)) { + alphaenc3[4*j + i] = 7; + alphadist = 255 - srccolors[j][i]; + } + else if (srccolors[j][i] <= acutValues[0]) { + alphaenc3[4*j + i] = 0; + alphadist = srccolors[j][i] - alphatest[0]; + } + else if (srccolors[j][i] <= acutValues[1]) { + alphaenc3[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5; + } + else if (srccolors[j][i] <= acutValues[2]) { + alphaenc3[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5; + } + else if (srccolors[j][i] <= acutValues[3]) { + alphaenc3[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5; + } + else if (srccolors[j][i] <= acutValues[4]) { + alphaenc3[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5; + } + else { + alphaenc3[4*j + i] = 1; + alphadist = srccolors[j][i] - alphatest[1]; + } + alphablockerror3 += alphadist * alphadist; + } + } + } + } + /* write the alpha values and encoding back. */ + if ((alphablockerror1 <= alphablockerror2) && (alphablockerror1 <= alphablockerror3)) { +#if RGTC_DEBUG + if (alphablockerror1 > 96) fprintf(stderr, "enc1 used, error %d\n", alphablockerror1); +#endif + write_rgtc_encoded_channel( blkaddr, alphause[1], alphause[0], alphaenc1 ); + } + else if (alphablockerror2 <= alphablockerror3) { +#if RGTC_DEBUG + if (alphablockerror2 > 96) fprintf(stderr, "enc2 used, error %d\n", alphablockerror2); +#endif + write_rgtc_encoded_channel( blkaddr, alphabase[0], alphabase[1], alphaenc2 ); + } + else { +#if RGTC_DEBUG + fprintf(stderr, "enc3 used, error %d\n", alphablockerror3); +#endif + write_rgtc_encoded_channel( blkaddr, (GLubyte)alphatest[0], (GLubyte)alphatest[1], alphaenc3 ); + } +} + + +static void write_rgtc_encoded_channel_s(GLbyte *blkaddr, + GLbyte alphabase1, + GLbyte alphabase2, + GLbyte alphaenc[16]) +{ + *blkaddr++ = alphabase1; + *blkaddr++ = alphabase2; + *blkaddr++ = alphaenc[0] | (alphaenc[1] << 3) | ((alphaenc[2] & 3) << 6); + *blkaddr++ = (alphaenc[2] >> 2) | (alphaenc[3] << 1) | (alphaenc[4] << 4) | ((alphaenc[5] & 1) << 7); + *blkaddr++ = (alphaenc[5] >> 1) | (alphaenc[6] << 2) | (alphaenc[7] << 5); + *blkaddr++ = alphaenc[8] | (alphaenc[9] << 3) | ((alphaenc[10] & 3) << 6); + *blkaddr++ = (alphaenc[10] >> 2) | (alphaenc[11] << 1) | (alphaenc[12] << 4) | ((alphaenc[13] & 1) << 7); + *blkaddr++ = (alphaenc[13] >> 1) | (alphaenc[14] << 2) | (alphaenc[15] << 5); +} + +static void encode_rgtc_chan_s(GLbyte *blkaddr, GLbyte srccolors[4][4], + GLint numxpixels, GLint numypixels) +{ + GLbyte alphabase[2], alphause[2]; + GLshort alphatest[2] = { 0 }; + GLuint alphablockerror1, alphablockerror2, alphablockerror3; + GLbyte i, j, aindex, acutValues[7]; + GLbyte alphaenc1[16], alphaenc2[16], alphaenc3[16]; + GLboolean alphaabsmin = GL_FALSE; + GLboolean alphaabsmax = GL_FALSE; + GLshort alphadist; + + /* find lowest and highest alpha value in block, alphabase[0] lowest, alphabase[1] highest */ + alphabase[0] = 0xff; alphabase[1] = 0x0; + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if (srccolors[j][i] == 0) + alphaabsmin = GL_TRUE; + else if (srccolors[j][i] == 255) + alphaabsmax = GL_TRUE; + else { + if (srccolors[j][i] > alphabase[1]) + alphabase[1] = srccolors[j][i]; + if (srccolors[j][i] < alphabase[0]) + alphabase[0] = srccolors[j][i]; + } + } + } + + + if ((alphabase[0] > alphabase[1]) && !(alphaabsmin && alphaabsmax)) { /* one color, either max or min */ + /* shortcut here since it is a very common case (and also avoids later problems) */ + /* || (alphabase[0] == alphabase[1] && !alphaabsmin && !alphaabsmax) */ + /* could also thest for alpha0 == alpha1 (and not min/max), but probably not common, so don't bother */ + + *blkaddr++ = srccolors[0][0]; + blkaddr++; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; + *blkaddr++ = 0; +#if RGTC_DEBUG + fprintf(stderr, "enc0 used\n"); +#endif + return; + } + + /* find best encoding for alpha0 > alpha1 */ + /* it's possible this encoding is better even if both alphaabsmin and alphaabsmax are true */ + alphablockerror1 = 0x0; + alphablockerror2 = 0xffffffff; + alphablockerror3 = 0xffffffff; + if (alphaabsmin) alphause[0] = 0; + else alphause[0] = alphabase[0]; + if (alphaabsmax) alphause[1] = 255; + else alphause[1] = alphabase[1]; + /* calculate the 7 cut values, just the middle between 2 of the computed alpha values */ + for (aindex = 0; aindex < 7; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphause[0] * (2*aindex + 1) + alphause[1] * (14 - (2*aindex + 1))) / 14; + } + + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] > acutValues[0]) { + alphaenc1[4*j + i] = 0; + alphadist = srccolors[j][i] - alphause[1]; + } + else if (srccolors[j][i] > acutValues[1]) { + alphaenc1[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphause[1] * 6 + alphause[0] * 1) / 7; + } + else if (srccolors[j][i] > acutValues[2]) { + alphaenc1[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphause[1] * 5 + alphause[0] * 2) / 7; + } + else if (srccolors[j][i] > acutValues[3]) { + alphaenc1[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphause[1] * 4 + alphause[0] * 3) / 7; + } + else if (srccolors[j][i] > acutValues[4]) { + alphaenc1[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphause[1] * 3 + alphause[0] * 4) / 7; + } + else if (srccolors[j][i] > acutValues[5]) { + alphaenc1[4*j + i] = 6; + alphadist = srccolors[j][i] - (alphause[1] * 2 + alphause[0] * 5) / 7; + } + else if (srccolors[j][i] > acutValues[6]) { + alphaenc1[4*j + i] = 7; + alphadist = srccolors[j][i] - (alphause[1] * 1 + alphause[0] * 6) / 7; + } + else { + alphaenc1[4*j + i] = 1; + alphadist = srccolors[j][i] - alphause[0]; + } + alphablockerror1 += alphadist * alphadist; + } + } +#if RGTC_DEBUG + for (i = 0; i < 16; i++) { + fprintf(stderr, "%d ", alphaenc1[i]); + } + fprintf(stderr, "cutVals "); + for (i = 0; i < 8; i++) { + fprintf(stderr, "%d ", acutValues[i]); + } + fprintf(stderr, "srcVals "); + for (j = 0; j < numypixels; j++) + for (i = 0; i < numxpixels; i++) { + fprintf(stderr, "%d ", srccolors[j][i]); + } + + fprintf(stderr, "\n"); +#endif + + /* it's not very likely this encoding is better if both alphaabsmin and alphaabsmax + are false but try it anyway */ + if (alphablockerror1 >= 32) { + + /* don't bother if encoding is already very good, this condition should also imply + we have valid alphabase colors which we absolutely need (alphabase[0] <= alphabase[1]) */ + alphablockerror2 = 0; + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphabase[0] * (10 - (2*aindex + 1)) + alphabase[1] * (2*aindex + 1)) / 10; + } + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] == 0) { + alphaenc2[4*j + i] = 6; + alphadist = 0; + } + else if (srccolors[j][i] == 255) { + alphaenc2[4*j + i] = 7; + alphadist = 0; + } + else if (srccolors[j][i] <= acutValues[0]) { + alphaenc2[4*j + i] = 0; + alphadist = srccolors[j][i] - alphabase[0]; + } + else if (srccolors[j][i] <= acutValues[1]) { + alphaenc2[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphabase[0] * 4 + alphabase[1] * 1) / 5; + } + else if (srccolors[j][i] <= acutValues[2]) { + alphaenc2[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphabase[0] * 3 + alphabase[1] * 2) / 5; + } + else if (srccolors[j][i] <= acutValues[3]) { + alphaenc2[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphabase[0] * 2 + alphabase[1] * 3) / 5; + } + else if (srccolors[j][i] <= acutValues[4]) { + alphaenc2[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphabase[0] * 1 + alphabase[1] * 4) / 5; + } + else { + alphaenc2[4*j + i] = 1; + alphadist = srccolors[j][i] - alphabase[1]; + } + alphablockerror2 += alphadist * alphadist; + } + } + + + /* skip this if the error is already very small + this encoding is MUCH better on average than #2 though, but expensive! */ + if ((alphablockerror2 > 96) && (alphablockerror1 > 96)) { + GLshort blockerrlin1 = 0; + GLshort blockerrlin2 = 0; + GLubyte nralphainrangelow = 0; + GLubyte nralphainrangehigh = 0; + alphatest[0] = 0xff; + alphatest[1] = 0x0; + /* if we have large range it's likely there are values close to 0/255, try to map them to 0/255 */ + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if ((srccolors[j][i] > alphatest[1]) && (srccolors[j][i] < (255 -(alphabase[1] - alphabase[0]) / 28))) + alphatest[1] = srccolors[j][i]; + if ((srccolors[j][i] < alphatest[0]) && (srccolors[j][i] > (alphabase[1] - alphabase[0]) / 28)) + alphatest[0] = srccolors[j][i]; + } + } + /* shouldn't happen too often, don't really care about those degenerated cases */ + if (alphatest[1] <= alphatest[0]) { + alphatest[0] = 1; + alphatest[1] = 254; + } + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; + } + + /* find the "average" difference between the alpha values and the next encoded value. + This is then used to calculate new base values. + Should there be some weighting, i.e. those values closer to alphatest[x] have more weight, + since they will see more improvement, and also because the values in the middle are somewhat + likely to get no improvement at all (because the base values might move in different directions)? + OTOH it would mean the values in the middle are even less likely to get an improvement + */ + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + if (srccolors[j][i] <= alphatest[0] / 2) { + } + else if (srccolors[j][i] > ((255 + alphatest[1]) / 2)) { + } + else if (srccolors[j][i] <= acutValues[0]) { + blockerrlin1 += (srccolors[j][i] - alphatest[0]); + nralphainrangelow += 1; + } + else if (srccolors[j][i] <= acutValues[1]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[2]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[3]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else if (srccolors[j][i] <= acutValues[4]) { + blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); + blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); + nralphainrangelow += 1; + nralphainrangehigh += 1; + } + else { + blockerrlin2 += (srccolors[j][i] - alphatest[1]); + nralphainrangehigh += 1; + } + } + } + /* shouldn't happen often, needed to avoid div by zero */ + if (nralphainrangelow == 0) nralphainrangelow = 1; + if (nralphainrangehigh == 0) nralphainrangehigh = 1; + alphatest[0] = alphatest[0] + (blockerrlin1 / nralphainrangelow); +#if RGTC_DEBUG + fprintf(stderr, "block err lin low %d, nr %d\n", blockerrlin1, nralphainrangelow); + fprintf(stderr, "block err lin high %d, nr %d\n", blockerrlin2, nralphainrangehigh); +#endif + /* again shouldn't really happen often... */ + if (alphatest[0] < 0) { + alphatest[0] = 0; + } + alphatest[1] = alphatest[1] + (blockerrlin2 / nralphainrangehigh); + if (alphatest[1] > 255) { + alphatest[1] = 255; + } + + alphablockerror3 = 0; + for (aindex = 0; aindex < 5; aindex++) { + /* don't forget here is always rounded down */ + acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; + } + for (j = 0; j < numypixels; j++) { + for (i = 0; i < numxpixels; i++) { + /* maybe it's overkill to have the most complicated calculation just for the error + calculation which we only need to figure out if encoding1 or encoding2 is better... */ + if (srccolors[j][i] <= alphatest[0] / 2) { + alphaenc3[4*j + i] = 6; + alphadist = srccolors[j][i]; + } + else if (srccolors[j][i] > ((255 + alphatest[1]) / 2)) { + alphaenc3[4*j + i] = 7; + alphadist = 255 - srccolors[j][i]; + } + else if (srccolors[j][i] <= acutValues[0]) { + alphaenc3[4*j + i] = 0; + alphadist = srccolors[j][i] - alphatest[0]; + } + else if (srccolors[j][i] <= acutValues[1]) { + alphaenc3[4*j + i] = 2; + alphadist = srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5; + } + else if (srccolors[j][i] <= acutValues[2]) { + alphaenc3[4*j + i] = 3; + alphadist = srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5; + } + else if (srccolors[j][i] <= acutValues[3]) { + alphaenc3[4*j + i] = 4; + alphadist = srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5; + } + else if (srccolors[j][i] <= acutValues[4]) { + alphaenc3[4*j + i] = 5; + alphadist = srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5; + } + else { + alphaenc3[4*j + i] = 1; + alphadist = srccolors[j][i] - alphatest[1]; + } + alphablockerror3 += alphadist * alphadist; + } + } + } + } + /* write the alpha values and encoding back. */ + if ((alphablockerror1 <= alphablockerror2) && (alphablockerror1 <= alphablockerror3)) { +#if RGTC_DEBUG + if (alphablockerror1 > 96) fprintf(stderr, "enc1 used, error %d\n", alphablockerror1); +#endif + write_rgtc_encoded_channel_s( blkaddr, alphause[1], alphause[0], alphaenc1 ); + } + else if (alphablockerror2 <= alphablockerror3) { +#if RGTC_DEBUG + if (alphablockerror2 > 96) fprintf(stderr, "enc2 used, error %d\n", alphablockerror2); +#endif + write_rgtc_encoded_channel_s( blkaddr, alphabase[0], alphabase[1], alphaenc2 ); + } + else { +#if RGTC_DEBUG + fprintf(stderr, "enc3 used, error %d\n", alphablockerror3); +#endif + write_rgtc_encoded_channel_s( blkaddr, (GLubyte)alphatest[0], (GLubyte)alphatest[1], alphaenc3 ); + } +} diff --git a/mesalib/src/mesa/main/texcompress_rgtc.h b/mesalib/src/mesa/main/texcompress_rgtc.h new file mode 100644 index 000000000..424edc458 --- /dev/null +++ b/mesalib/src/mesa/main/texcompress_rgtc.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2011 Red Hat Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef TEXCOMPRESS_RGTC_H +#define TEXCOMPRESS_RGTC_H + +#include "glheader.h" +#include "mfeatures.h" +#include "texstore.h" + +struct gl_texture_image; + +extern GLboolean +_mesa_texstore_red_rgtc1(TEXSTORE_PARAMS); + +extern GLboolean +_mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS); + +extern GLboolean +_mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS); + +extern GLboolean +_mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS); + +extern void +_mesa_fetch_texel_2d_f_red_rgtc1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_rg_rgtc2(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); + +extern void +_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); +#endif diff --git a/mesalib/src/mesa/main/texfetch.c b/mesalib/src/mesa/main/texfetch.c index 1e7ea9480..550597e1c 100644 --- a/mesalib/src/mesa/main/texfetch.c +++ b/mesalib/src/mesa/main/texfetch.c @@ -1,893 +1,922 @@ -/* - * Mesa 3-D graphics library - * Version: 7.7 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file texfetch.c - * - * Texel fetch/store functions - * - * \author Gareth Hughes - */ - - -#include "colormac.h" -#include "macros.h" -#include "texcompress.h" -#include "texcompress_fxt1.h" -#include "texcompress_s3tc.h" -#include "texfetch.h" -#include "teximage.h" - - -/** - * Convert an 8-bit sRGB value from non-linear space to a - * linear RGB value in [0, 1]. - * Implemented with a 256-entry lookup table. - */ -static INLINE GLfloat -nonlinear_to_linear(GLubyte cs8) -{ - static GLfloat table[256]; - static GLboolean tableReady = GL_FALSE; - if (!tableReady) { - /* compute lookup table now */ - GLuint i; - for (i = 0; i < 256; i++) { - const GLfloat cs = UBYTE_TO_FLOAT(i); - if (cs <= 0.04045) { - table[i] = cs / 12.92f; - } - else { - table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4); - } - } - tableReady = GL_TRUE; - } - return table[cs8]; -} - - - -/* Texel fetch routines for all supported formats - */ -#define DIM 1 -#include "texfetch_tmp.h" - -#define DIM 2 -#include "texfetch_tmp.h" - -#define DIM 3 -#include "texfetch_tmp.h" - -/** - * Null texel fetch function. - * - * Have to have this so the FetchTexel function pointer is never NULL. - */ -static void fetch_null_texelf( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) -{ - (void) texImage; (void) i; (void) j; (void) k; - texel[RCOMP] = 0.0; - texel[GCOMP] = 0.0; - texel[BCOMP] = 0.0; - texel[ACOMP] = 0.0; - _mesa_warning(NULL, "fetch_null_texelf() called!"); -} - -static void store_null_texel(struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, const void *texel) -{ - (void) texImage; - (void) i; - (void) j; - (void) k; - (void) texel; - /* no-op */ -} - - - -/** - * Table to map MESA_FORMAT_ to texel fetch/store funcs. - * XXX this is somewhat temporary. - */ -static struct { - gl_format Name; - FetchTexelFuncF Fetch1D; - FetchTexelFuncF Fetch2D; - FetchTexelFuncF Fetch3D; - StoreTexelFunc StoreTexel; -} -texfetch_funcs[MESA_FORMAT_COUNT] = -{ - { - MESA_FORMAT_NONE, - fetch_null_texelf, - fetch_null_texelf, - fetch_null_texelf, - store_null_texel - }, - - { - MESA_FORMAT_RGBA8888, - fetch_texel_1d_f_rgba8888, - fetch_texel_2d_f_rgba8888, - fetch_texel_3d_f_rgba8888, - store_texel_rgba8888 - }, - { - MESA_FORMAT_RGBA8888_REV, - fetch_texel_1d_f_rgba8888_rev, - fetch_texel_2d_f_rgba8888_rev, - fetch_texel_3d_f_rgba8888_rev, - store_texel_rgba8888_rev - }, - { - MESA_FORMAT_ARGB8888, - fetch_texel_1d_f_argb8888, - fetch_texel_2d_f_argb8888, - fetch_texel_3d_f_argb8888, - store_texel_argb8888 - }, - { - MESA_FORMAT_ARGB8888_REV, - fetch_texel_1d_f_argb8888_rev, - fetch_texel_2d_f_argb8888_rev, - fetch_texel_3d_f_argb8888_rev, - store_texel_argb8888_rev - }, - { - MESA_FORMAT_XRGB8888, - fetch_texel_1d_f_xrgb8888, - fetch_texel_2d_f_xrgb8888, - fetch_texel_3d_f_xrgb8888, - store_texel_xrgb8888 - }, - { - MESA_FORMAT_XRGB8888_REV, - fetch_texel_1d_f_xrgb8888_rev, - fetch_texel_2d_f_xrgb8888_rev, - fetch_texel_3d_f_xrgb8888_rev, - store_texel_xrgb8888_rev, - }, - { - MESA_FORMAT_RGB888, - fetch_texel_1d_f_rgb888, - fetch_texel_2d_f_rgb888, - fetch_texel_3d_f_rgb888, - store_texel_rgb888 - }, - { - MESA_FORMAT_BGR888, - fetch_texel_1d_f_bgr888, - fetch_texel_2d_f_bgr888, - fetch_texel_3d_f_bgr888, - store_texel_bgr888 - }, - { - MESA_FORMAT_RGB565, - fetch_texel_1d_f_rgb565, - fetch_texel_2d_f_rgb565, - fetch_texel_3d_f_rgb565, - store_texel_rgb565 - }, - { - MESA_FORMAT_RGB565_REV, - fetch_texel_1d_f_rgb565_rev, - fetch_texel_2d_f_rgb565_rev, - fetch_texel_3d_f_rgb565_rev, - store_texel_rgb565_rev - }, - { - MESA_FORMAT_ARGB4444, - fetch_texel_1d_f_argb4444, - fetch_texel_2d_f_argb4444, - fetch_texel_3d_f_argb4444, - store_texel_argb4444 - }, - { - MESA_FORMAT_ARGB4444_REV, - fetch_texel_1d_f_argb4444_rev, - fetch_texel_2d_f_argb4444_rev, - fetch_texel_3d_f_argb4444_rev, - store_texel_argb4444_rev - }, - { - MESA_FORMAT_RGBA5551, - fetch_texel_1d_f_rgba5551, - fetch_texel_2d_f_rgba5551, - fetch_texel_3d_f_rgba5551, - store_texel_rgba5551 - }, - { - MESA_FORMAT_ARGB1555, - fetch_texel_1d_f_argb1555, - fetch_texel_2d_f_argb1555, - fetch_texel_3d_f_argb1555, - store_texel_argb1555 - }, - { - MESA_FORMAT_ARGB1555_REV, - fetch_texel_1d_f_argb1555_rev, - fetch_texel_2d_f_argb1555_rev, - fetch_texel_3d_f_argb1555_rev, - store_texel_argb1555_rev - }, - { - MESA_FORMAT_AL44, - fetch_texel_1d_f_al44, - fetch_texel_2d_f_al44, - fetch_texel_3d_f_al44, - store_texel_al44 - }, - { - MESA_FORMAT_AL88, - fetch_texel_1d_f_al88, - fetch_texel_2d_f_al88, - fetch_texel_3d_f_al88, - store_texel_al88 - }, - { - MESA_FORMAT_AL88_REV, - fetch_texel_1d_f_al88_rev, - fetch_texel_2d_f_al88_rev, - fetch_texel_3d_f_al88_rev, - store_texel_al88_rev - }, - { - MESA_FORMAT_AL1616, - fetch_texel_1d_f_al1616, - fetch_texel_2d_f_al1616, - fetch_texel_3d_f_al1616, - store_texel_al1616 - }, - { - MESA_FORMAT_AL1616_REV, - fetch_texel_1d_f_al1616_rev, - fetch_texel_2d_f_al1616_rev, - fetch_texel_3d_f_al1616_rev, - store_texel_al1616_rev - }, - { - MESA_FORMAT_RGB332, - fetch_texel_1d_f_rgb332, - fetch_texel_2d_f_rgb332, - fetch_texel_3d_f_rgb332, - store_texel_rgb332 - }, - { - MESA_FORMAT_A8, - fetch_texel_1d_f_a8, - fetch_texel_2d_f_a8, - fetch_texel_3d_f_a8, - store_texel_a8 - }, - { - MESA_FORMAT_A16, - fetch_texel_1d_f_a16, - fetch_texel_2d_f_a16, - fetch_texel_3d_f_a16, - store_texel_a16 - }, - { - MESA_FORMAT_L8, - fetch_texel_1d_f_l8, - fetch_texel_2d_f_l8, - fetch_texel_3d_f_l8, - store_texel_l8 - }, - { - MESA_FORMAT_L16, - fetch_texel_1d_f_l16, - fetch_texel_2d_f_l16, - fetch_texel_3d_f_l16, - store_texel_l16 - }, - { - MESA_FORMAT_I8, - fetch_texel_1d_f_i8, - fetch_texel_2d_f_i8, - fetch_texel_3d_f_i8, - store_texel_i8 - }, - { - MESA_FORMAT_I16, - fetch_texel_1d_f_i16, - fetch_texel_2d_f_i16, - fetch_texel_3d_f_i16, - store_texel_i16 - }, - { - MESA_FORMAT_CI8, - fetch_texel_1d_f_ci8, - fetch_texel_2d_f_ci8, - fetch_texel_3d_f_ci8, - store_texel_ci8 - }, - { - MESA_FORMAT_YCBCR, - fetch_texel_1d_f_ycbcr, - fetch_texel_2d_f_ycbcr, - fetch_texel_3d_f_ycbcr, - store_texel_ycbcr - }, - { - MESA_FORMAT_YCBCR_REV, - fetch_texel_1d_f_ycbcr_rev, - fetch_texel_2d_f_ycbcr_rev, - fetch_texel_3d_f_ycbcr_rev, - store_texel_ycbcr_rev - }, - { - MESA_FORMAT_R8, - fetch_texel_1d_f_r8, - fetch_texel_2d_f_r8, - fetch_texel_3d_f_r8, - store_texel_r8, - }, - { - MESA_FORMAT_RG88, - fetch_texel_1d_f_rg88, - fetch_texel_2d_f_rg88, - fetch_texel_3d_f_rg88, - store_texel_rg88, - }, - { - MESA_FORMAT_RG88_REV, - fetch_texel_1d_f_rg88_rev, - fetch_texel_2d_f_rg88_rev, - fetch_texel_3d_f_rg88_rev, - store_texel_rg88_rev, - }, - { - MESA_FORMAT_R16, - fetch_texel_1d_f_r16, - fetch_texel_2d_f_r16, - fetch_texel_3d_f_r16, - store_texel_r16, - }, - { - MESA_FORMAT_RG1616, - fetch_texel_1d_f_rg1616, - fetch_texel_2d_f_rg1616, - fetch_texel_3d_f_rg1616, - store_texel_rg1616, - }, - { - MESA_FORMAT_RG1616_REV, - fetch_texel_1d_f_rg1616_rev, - fetch_texel_2d_f_rg1616_rev, - fetch_texel_3d_f_rg1616_rev, - store_texel_rg1616_rev, - }, - { - MESA_FORMAT_ARGB2101010, - fetch_texel_1d_f_argb2101010, - fetch_texel_2d_f_argb2101010, - fetch_texel_3d_f_argb2101010, - store_texel_argb2101010 - }, - { - MESA_FORMAT_Z24_S8, - fetch_texel_1d_f_z24_s8, - fetch_texel_2d_f_z24_s8, - fetch_texel_3d_f_z24_s8, - store_texel_z24_s8 - }, - { - MESA_FORMAT_S8_Z24, - fetch_texel_1d_f_s8_z24, - fetch_texel_2d_f_s8_z24, - fetch_texel_3d_f_s8_z24, - store_texel_s8_z24 - }, - { - MESA_FORMAT_Z16, - fetch_texel_1d_f_z16, - fetch_texel_2d_f_z16, - fetch_texel_3d_f_z16, - store_texel_z16 - }, - { - MESA_FORMAT_X8_Z24, - fetch_texel_1d_f_s8_z24, - fetch_texel_2d_f_s8_z24, - fetch_texel_3d_f_s8_z24, - store_texel_s8_z24 - }, - { - MESA_FORMAT_Z24_X8, - fetch_texel_1d_f_z24_s8, - fetch_texel_2d_f_z24_s8, - fetch_texel_3d_f_z24_s8, - store_texel_z24_s8 - }, - { - MESA_FORMAT_Z32, - fetch_texel_1d_f_z32, - fetch_texel_2d_f_z32, - fetch_texel_3d_f_z32, - store_texel_z32 - }, - { - MESA_FORMAT_S8, - NULL, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_SRGB8, - fetch_texel_1d_srgb8, - fetch_texel_2d_srgb8, - fetch_texel_3d_srgb8, - store_texel_srgb8 - }, - { - MESA_FORMAT_SRGBA8, - fetch_texel_1d_srgba8, - fetch_texel_2d_srgba8, - fetch_texel_3d_srgba8, - store_texel_srgba8 - }, - { - MESA_FORMAT_SARGB8, - fetch_texel_1d_sargb8, - fetch_texel_2d_sargb8, - fetch_texel_3d_sargb8, - store_texel_sargb8 - }, - { - MESA_FORMAT_SL8, - fetch_texel_1d_sl8, - fetch_texel_2d_sl8, - fetch_texel_3d_sl8, - store_texel_sl8 - }, - { - MESA_FORMAT_SLA8, - fetch_texel_1d_sla8, - fetch_texel_2d_sla8, - fetch_texel_3d_sla8, - store_texel_sla8 - }, - { - MESA_FORMAT_SRGB_DXT1, - NULL, - _mesa_fetch_texel_2d_f_srgb_dxt1, - NULL, - NULL - }, - { - MESA_FORMAT_SRGBA_DXT1, - NULL, - _mesa_fetch_texel_2d_f_srgba_dxt1, - NULL, - NULL - }, - { - MESA_FORMAT_SRGBA_DXT3, - NULL, - _mesa_fetch_texel_2d_f_srgba_dxt3, - NULL, - NULL - }, - { - MESA_FORMAT_SRGBA_DXT5, - NULL, - _mesa_fetch_texel_2d_f_srgba_dxt5, - NULL, - NULL - }, - - { - MESA_FORMAT_RGB_FXT1, - NULL, - _mesa_fetch_texel_2d_f_rgb_fxt1, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_FXT1, - NULL, - _mesa_fetch_texel_2d_f_rgba_fxt1, - NULL, - NULL - }, - { - MESA_FORMAT_RGB_DXT1, - NULL, - _mesa_fetch_texel_2d_f_rgb_dxt1, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_DXT1, - NULL, - _mesa_fetch_texel_2d_f_rgba_dxt1, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_DXT3, - NULL, - _mesa_fetch_texel_2d_f_rgba_dxt3, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_DXT5, - NULL, - _mesa_fetch_texel_2d_f_rgba_dxt5, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_FLOAT32, - fetch_texel_1d_f_rgba_f32, - fetch_texel_2d_f_rgba_f32, - fetch_texel_3d_f_rgba_f32, - store_texel_rgba_f32 - }, - { - MESA_FORMAT_RGBA_FLOAT16, - fetch_texel_1d_f_rgba_f16, - fetch_texel_2d_f_rgba_f16, - fetch_texel_3d_f_rgba_f16, - store_texel_rgba_f16 - }, - { - MESA_FORMAT_RGB_FLOAT32, - fetch_texel_1d_f_rgb_f32, - fetch_texel_2d_f_rgb_f32, - fetch_texel_3d_f_rgb_f32, - store_texel_rgb_f32 - }, - { - MESA_FORMAT_RGB_FLOAT16, - fetch_texel_1d_f_rgb_f16, - fetch_texel_2d_f_rgb_f16, - fetch_texel_3d_f_rgb_f16, - store_texel_rgb_f16 - }, - { - MESA_FORMAT_ALPHA_FLOAT32, - fetch_texel_1d_f_alpha_f32, - fetch_texel_2d_f_alpha_f32, - fetch_texel_3d_f_alpha_f32, - store_texel_alpha_f32 - }, - { - MESA_FORMAT_ALPHA_FLOAT16, - fetch_texel_1d_f_alpha_f16, - fetch_texel_2d_f_alpha_f16, - fetch_texel_3d_f_alpha_f16, - store_texel_alpha_f16 - }, - { - MESA_FORMAT_LUMINANCE_FLOAT32, - fetch_texel_1d_f_luminance_f32, - fetch_texel_2d_f_luminance_f32, - fetch_texel_3d_f_luminance_f32, - store_texel_luminance_f32 - }, - { - MESA_FORMAT_LUMINANCE_FLOAT16, - fetch_texel_1d_f_luminance_f16, - fetch_texel_2d_f_luminance_f16, - fetch_texel_3d_f_luminance_f16, - store_texel_luminance_f16 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, - fetch_texel_1d_f_luminance_alpha_f32, - fetch_texel_2d_f_luminance_alpha_f32, - fetch_texel_3d_f_luminance_alpha_f32, - store_texel_luminance_alpha_f32 - }, - { - MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, - fetch_texel_1d_f_luminance_alpha_f16, - fetch_texel_2d_f_luminance_alpha_f16, - fetch_texel_3d_f_luminance_alpha_f16, - store_texel_luminance_alpha_f16 - }, - { - MESA_FORMAT_INTENSITY_FLOAT32, - fetch_texel_1d_f_intensity_f32, - fetch_texel_2d_f_intensity_f32, - fetch_texel_3d_f_intensity_f32, - store_texel_intensity_f32 - }, - { - MESA_FORMAT_INTENSITY_FLOAT16, - fetch_texel_1d_f_intensity_f16, - fetch_texel_2d_f_intensity_f16, - fetch_texel_3d_f_intensity_f16, - store_texel_intensity_f16 - }, - - /* non-normalized, signed int */ - { - MESA_FORMAT_RGBA_INT8, - fetch_texel_1d_rgba_int8, - fetch_texel_2d_rgba_int8, - fetch_texel_3d_rgba_int8, - store_texel_rgba_int8 - }, - { - MESA_FORMAT_RGBA_INT16, - fetch_texel_1d_rgba_int16, - fetch_texel_2d_rgba_int16, - fetch_texel_3d_rgba_int16, - store_texel_rgba_int16 - }, - { - MESA_FORMAT_RGBA_INT32, - fetch_texel_1d_rgba_int32, - fetch_texel_2d_rgba_int32, - fetch_texel_3d_rgba_int32, - store_texel_rgba_int32 - }, - - /* non-normalized, unsigned int */ - { - MESA_FORMAT_RGBA_UINT8, - fetch_texel_1d_rgba_uint8, - fetch_texel_2d_rgba_uint8, - fetch_texel_3d_rgba_uint8, - store_texel_rgba_uint8 - }, - { - MESA_FORMAT_RGBA_UINT16, - fetch_texel_1d_rgba_uint16, - fetch_texel_2d_rgba_uint16, - fetch_texel_3d_rgba_uint16, - store_texel_rgba_uint16 - }, - { - MESA_FORMAT_RGBA_UINT32, - fetch_texel_1d_rgba_uint32, - fetch_texel_2d_rgba_uint32, - fetch_texel_3d_rgba_uint32, - store_texel_rgba_uint32 - }, - - /* dudv */ - { - MESA_FORMAT_DUDV8, - fetch_texel_1d_dudv8, - fetch_texel_2d_dudv8, - fetch_texel_3d_dudv8, - NULL - }, - - /* signed, normalized */ - { - MESA_FORMAT_SIGNED_R8, - fetch_texel_1d_signed_r8, - fetch_texel_2d_signed_r8, - fetch_texel_3d_signed_r8, - store_texel_signed_r8 - }, - { - MESA_FORMAT_SIGNED_RG88, - fetch_texel_1d_signed_rg88, - fetch_texel_2d_signed_rg88, - fetch_texel_3d_signed_rg88, - store_texel_signed_rg88 - }, - { - MESA_FORMAT_SIGNED_RGBX8888, - fetch_texel_1d_signed_rgbx8888, - fetch_texel_2d_signed_rgbx8888, - fetch_texel_3d_signed_rgbx8888, - store_texel_signed_rgbx8888 - }, - { - MESA_FORMAT_SIGNED_RGBA8888, - fetch_texel_1d_signed_rgba8888, - fetch_texel_2d_signed_rgba8888, - fetch_texel_3d_signed_rgba8888, - store_texel_signed_rgba8888 - }, - { - MESA_FORMAT_SIGNED_RGBA8888_REV, - fetch_texel_1d_signed_rgba8888_rev, - fetch_texel_2d_signed_rgba8888_rev, - fetch_texel_3d_signed_rgba8888_rev, - store_texel_signed_rgba8888_rev - }, - { - MESA_FORMAT_SIGNED_R_16, - fetch_texel_1d_signed_r_16, - fetch_texel_2d_signed_r_16, - fetch_texel_3d_signed_r_16, - store_texel_signed_r_16 - }, - { - MESA_FORMAT_SIGNED_RG_16, - fetch_texel_1d_signed_rg_16, - fetch_texel_2d_signed_rg_16, - fetch_texel_3d_signed_rg_16, - store_texel_signed_rg_16 - }, - { - MESA_FORMAT_SIGNED_RGB_16, - fetch_texel_1d_signed_rgb_16, - fetch_texel_2d_signed_rgb_16, - fetch_texel_3d_signed_rgb_16, - store_texel_signed_rgb_16 - }, - { - MESA_FORMAT_SIGNED_RGBA_16, - fetch_texel_1d_signed_rgba_16, - fetch_texel_2d_signed_rgba_16, - fetch_texel_3d_signed_rgba_16, - store_texel_signed_rgba_16 - }, - { - MESA_FORMAT_RGBA_16, - fetch_texel_1d_rgba_16, - fetch_texel_2d_rgba_16, - fetch_texel_3d_rgba_16, - store_texel_rgba_16 - } -}; - - -FetchTexelFuncF -_mesa_get_texel_fetch_func(gl_format format, GLuint dims) -{ -#ifdef DEBUG - /* check that the table entries are sorted by format name */ - gl_format fmt; - for (fmt = 0; fmt < MESA_FORMAT_COUNT; fmt++) { - assert(texfetch_funcs[fmt].Name == fmt); - } -#endif - - assert(Elements(texfetch_funcs) == MESA_FORMAT_COUNT); - assert(format < MESA_FORMAT_COUNT); - - switch (dims) { - case 1: - return texfetch_funcs[format].Fetch1D; - case 2: - return texfetch_funcs[format].Fetch2D; - case 3: - return texfetch_funcs[format].Fetch3D; - default: - assert(0 && "bad dims in _mesa_get_texel_fetch_func"); - return NULL; - } -} - - -StoreTexelFunc -_mesa_get_texel_store_func(gl_format format) -{ - assert(format < MESA_FORMAT_COUNT); - return texfetch_funcs[format].StoreTexel; -} - - -/** - * Adaptor for fetching a GLchan texel from a float-valued texture. - */ -static void -fetch_texel_float_to_chan(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texelOut) -{ - GLfloat temp[4]; - GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat); - - ASSERT(texImage->FetchTexelf); - texImage->FetchTexelf(texImage, i, j, k, temp); - if (baseFormat == GL_DEPTH_COMPONENT || - baseFormat == GL_DEPTH_STENCIL_EXT) { - /* just one channel */ - UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]); - } - else { - /* four channels */ - UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]); - UNCLAMPED_FLOAT_TO_CHAN(texelOut[1], temp[1]); - UNCLAMPED_FLOAT_TO_CHAN(texelOut[2], temp[2]); - UNCLAMPED_FLOAT_TO_CHAN(texelOut[3], temp[3]); - } -} - - -#if 0 -/** - * Adaptor for fetching a float texel from a GLchan-valued texture. - */ -static void -fetch_texel_chan_to_float(const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texelOut) -{ - GLchan temp[4]; - GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat); - - ASSERT(texImage->FetchTexelc); - texImage->FetchTexelc(texImage, i, j, k, temp); - if (baseFormat == GL_DEPTH_COMPONENT || - baseFormat == GL_DEPTH_STENCIL_EXT) { - /* just one channel */ - texelOut[0] = CHAN_TO_FLOAT(temp[0]); - } - else { - /* four channels */ - texelOut[0] = CHAN_TO_FLOAT(temp[0]); - texelOut[1] = CHAN_TO_FLOAT(temp[1]); - texelOut[2] = CHAN_TO_FLOAT(temp[2]); - texelOut[3] = CHAN_TO_FLOAT(temp[3]); - } -} -#endif - - -/** - * Initialize the texture image's FetchTexelc and FetchTexelf methods. - */ -void -_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims) -{ - gl_format format = texImage->TexFormat; - - ASSERT(dims == 1 || dims == 2 || dims == 3); - - if (texImage->TexObject->sRGBDecode == GL_SKIP_DECODE_EXT && - _mesa_get_format_color_encoding(format) == GL_SRGB) { - format = _mesa_get_srgb_format_linear(format); - } - - texImage->FetchTexelf = _mesa_get_texel_fetch_func(format, dims); - - texImage->FetchTexelc = fetch_texel_float_to_chan; - - ASSERT(texImage->FetchTexelc); - ASSERT(texImage->FetchTexelf); -} - -void -_mesa_update_fetch_functions(struct gl_texture_object *texObj) -{ - GLuint face, i; - GLuint dims; - - dims = _mesa_get_texture_dimensions(texObj->Target); - - for (face = 0; face < 6; face++) { - for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { - if (texObj->Image[face][i]) { - _mesa_set_fetch_functions(texObj->Image[face][i], dims); - } - } - } -} +/* + * Mesa 3-D graphics library + * Version: 7.7 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2009 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file texfetch.c + * + * Texel fetch/store functions + * + * \author Gareth Hughes + */ + + +#include "colormac.h" +#include "macros.h" +#include "texcompress.h" +#include "texcompress_fxt1.h" +#include "texcompress_s3tc.h" +#include "texcompress_rgtc.h" +#include "texfetch.h" +#include "teximage.h" + + +/** + * Convert an 8-bit sRGB value from non-linear space to a + * linear RGB value in [0, 1]. + * Implemented with a 256-entry lookup table. + */ +static INLINE GLfloat +nonlinear_to_linear(GLubyte cs8) +{ + static GLfloat table[256]; + static GLboolean tableReady = GL_FALSE; + if (!tableReady) { + /* compute lookup table now */ + GLuint i; + for (i = 0; i < 256; i++) { + const GLfloat cs = UBYTE_TO_FLOAT(i); + if (cs <= 0.04045) { + table[i] = cs / 12.92f; + } + else { + table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4); + } + } + tableReady = GL_TRUE; + } + return table[cs8]; +} + + + +/* Texel fetch routines for all supported formats + */ +#define DIM 1 +#include "texfetch_tmp.h" + +#define DIM 2 +#include "texfetch_tmp.h" + +#define DIM 3 +#include "texfetch_tmp.h" + +/** + * Null texel fetch function. + * + * Have to have this so the FetchTexel function pointer is never NULL. + */ +static void fetch_null_texelf( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + (void) texImage; (void) i; (void) j; (void) k; + texel[RCOMP] = 0.0; + texel[GCOMP] = 0.0; + texel[BCOMP] = 0.0; + texel[ACOMP] = 0.0; + _mesa_warning(NULL, "fetch_null_texelf() called!"); +} + +static void store_null_texel(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + (void) texImage; + (void) i; + (void) j; + (void) k; + (void) texel; + /* no-op */ +} + + + +/** + * Table to map MESA_FORMAT_ to texel fetch/store funcs. + * XXX this is somewhat temporary. + */ +static struct { + gl_format Name; + FetchTexelFuncF Fetch1D; + FetchTexelFuncF Fetch2D; + FetchTexelFuncF Fetch3D; + StoreTexelFunc StoreTexel; +} +texfetch_funcs[MESA_FORMAT_COUNT] = +{ + { + MESA_FORMAT_NONE, + fetch_null_texelf, + fetch_null_texelf, + fetch_null_texelf, + store_null_texel + }, + + { + MESA_FORMAT_RGBA8888, + fetch_texel_1d_f_rgba8888, + fetch_texel_2d_f_rgba8888, + fetch_texel_3d_f_rgba8888, + store_texel_rgba8888 + }, + { + MESA_FORMAT_RGBA8888_REV, + fetch_texel_1d_f_rgba8888_rev, + fetch_texel_2d_f_rgba8888_rev, + fetch_texel_3d_f_rgba8888_rev, + store_texel_rgba8888_rev + }, + { + MESA_FORMAT_ARGB8888, + fetch_texel_1d_f_argb8888, + fetch_texel_2d_f_argb8888, + fetch_texel_3d_f_argb8888, + store_texel_argb8888 + }, + { + MESA_FORMAT_ARGB8888_REV, + fetch_texel_1d_f_argb8888_rev, + fetch_texel_2d_f_argb8888_rev, + fetch_texel_3d_f_argb8888_rev, + store_texel_argb8888_rev + }, + { + MESA_FORMAT_XRGB8888, + fetch_texel_1d_f_xrgb8888, + fetch_texel_2d_f_xrgb8888, + fetch_texel_3d_f_xrgb8888, + store_texel_xrgb8888 + }, + { + MESA_FORMAT_XRGB8888_REV, + fetch_texel_1d_f_xrgb8888_rev, + fetch_texel_2d_f_xrgb8888_rev, + fetch_texel_3d_f_xrgb8888_rev, + store_texel_xrgb8888_rev, + }, + { + MESA_FORMAT_RGB888, + fetch_texel_1d_f_rgb888, + fetch_texel_2d_f_rgb888, + fetch_texel_3d_f_rgb888, + store_texel_rgb888 + }, + { + MESA_FORMAT_BGR888, + fetch_texel_1d_f_bgr888, + fetch_texel_2d_f_bgr888, + fetch_texel_3d_f_bgr888, + store_texel_bgr888 + }, + { + MESA_FORMAT_RGB565, + fetch_texel_1d_f_rgb565, + fetch_texel_2d_f_rgb565, + fetch_texel_3d_f_rgb565, + store_texel_rgb565 + }, + { + MESA_FORMAT_RGB565_REV, + fetch_texel_1d_f_rgb565_rev, + fetch_texel_2d_f_rgb565_rev, + fetch_texel_3d_f_rgb565_rev, + store_texel_rgb565_rev + }, + { + MESA_FORMAT_ARGB4444, + fetch_texel_1d_f_argb4444, + fetch_texel_2d_f_argb4444, + fetch_texel_3d_f_argb4444, + store_texel_argb4444 + }, + { + MESA_FORMAT_ARGB4444_REV, + fetch_texel_1d_f_argb4444_rev, + fetch_texel_2d_f_argb4444_rev, + fetch_texel_3d_f_argb4444_rev, + store_texel_argb4444_rev + }, + { + MESA_FORMAT_RGBA5551, + fetch_texel_1d_f_rgba5551, + fetch_texel_2d_f_rgba5551, + fetch_texel_3d_f_rgba5551, + store_texel_rgba5551 + }, + { + MESA_FORMAT_ARGB1555, + fetch_texel_1d_f_argb1555, + fetch_texel_2d_f_argb1555, + fetch_texel_3d_f_argb1555, + store_texel_argb1555 + }, + { + MESA_FORMAT_ARGB1555_REV, + fetch_texel_1d_f_argb1555_rev, + fetch_texel_2d_f_argb1555_rev, + fetch_texel_3d_f_argb1555_rev, + store_texel_argb1555_rev + }, + { + MESA_FORMAT_AL44, + fetch_texel_1d_f_al44, + fetch_texel_2d_f_al44, + fetch_texel_3d_f_al44, + store_texel_al44 + }, + { + MESA_FORMAT_AL88, + fetch_texel_1d_f_al88, + fetch_texel_2d_f_al88, + fetch_texel_3d_f_al88, + store_texel_al88 + }, + { + MESA_FORMAT_AL88_REV, + fetch_texel_1d_f_al88_rev, + fetch_texel_2d_f_al88_rev, + fetch_texel_3d_f_al88_rev, + store_texel_al88_rev + }, + { + MESA_FORMAT_AL1616, + fetch_texel_1d_f_al1616, + fetch_texel_2d_f_al1616, + fetch_texel_3d_f_al1616, + store_texel_al1616 + }, + { + MESA_FORMAT_AL1616_REV, + fetch_texel_1d_f_al1616_rev, + fetch_texel_2d_f_al1616_rev, + fetch_texel_3d_f_al1616_rev, + store_texel_al1616_rev + }, + { + MESA_FORMAT_RGB332, + fetch_texel_1d_f_rgb332, + fetch_texel_2d_f_rgb332, + fetch_texel_3d_f_rgb332, + store_texel_rgb332 + }, + { + MESA_FORMAT_A8, + fetch_texel_1d_f_a8, + fetch_texel_2d_f_a8, + fetch_texel_3d_f_a8, + store_texel_a8 + }, + { + MESA_FORMAT_A16, + fetch_texel_1d_f_a16, + fetch_texel_2d_f_a16, + fetch_texel_3d_f_a16, + store_texel_a16 + }, + { + MESA_FORMAT_L8, + fetch_texel_1d_f_l8, + fetch_texel_2d_f_l8, + fetch_texel_3d_f_l8, + store_texel_l8 + }, + { + MESA_FORMAT_L16, + fetch_texel_1d_f_l16, + fetch_texel_2d_f_l16, + fetch_texel_3d_f_l16, + store_texel_l16 + }, + { + MESA_FORMAT_I8, + fetch_texel_1d_f_i8, + fetch_texel_2d_f_i8, + fetch_texel_3d_f_i8, + store_texel_i8 + }, + { + MESA_FORMAT_I16, + fetch_texel_1d_f_i16, + fetch_texel_2d_f_i16, + fetch_texel_3d_f_i16, + store_texel_i16 + }, + { + MESA_FORMAT_CI8, + fetch_texel_1d_f_ci8, + fetch_texel_2d_f_ci8, + fetch_texel_3d_f_ci8, + store_texel_ci8 + }, + { + MESA_FORMAT_YCBCR, + fetch_texel_1d_f_ycbcr, + fetch_texel_2d_f_ycbcr, + fetch_texel_3d_f_ycbcr, + store_texel_ycbcr + }, + { + MESA_FORMAT_YCBCR_REV, + fetch_texel_1d_f_ycbcr_rev, + fetch_texel_2d_f_ycbcr_rev, + fetch_texel_3d_f_ycbcr_rev, + store_texel_ycbcr_rev + }, + { + MESA_FORMAT_R8, + fetch_texel_1d_f_r8, + fetch_texel_2d_f_r8, + fetch_texel_3d_f_r8, + store_texel_r8, + }, + { + MESA_FORMAT_RG88, + fetch_texel_1d_f_rg88, + fetch_texel_2d_f_rg88, + fetch_texel_3d_f_rg88, + store_texel_rg88, + }, + { + MESA_FORMAT_RG88_REV, + fetch_texel_1d_f_rg88_rev, + fetch_texel_2d_f_rg88_rev, + fetch_texel_3d_f_rg88_rev, + store_texel_rg88_rev, + }, + { + MESA_FORMAT_R16, + fetch_texel_1d_f_r16, + fetch_texel_2d_f_r16, + fetch_texel_3d_f_r16, + store_texel_r16, + }, + { + MESA_FORMAT_RG1616, + fetch_texel_1d_f_rg1616, + fetch_texel_2d_f_rg1616, + fetch_texel_3d_f_rg1616, + store_texel_rg1616, + }, + { + MESA_FORMAT_RG1616_REV, + fetch_texel_1d_f_rg1616_rev, + fetch_texel_2d_f_rg1616_rev, + fetch_texel_3d_f_rg1616_rev, + store_texel_rg1616_rev, + }, + { + MESA_FORMAT_ARGB2101010, + fetch_texel_1d_f_argb2101010, + fetch_texel_2d_f_argb2101010, + fetch_texel_3d_f_argb2101010, + store_texel_argb2101010 + }, + { + MESA_FORMAT_Z24_S8, + fetch_texel_1d_f_z24_s8, + fetch_texel_2d_f_z24_s8, + fetch_texel_3d_f_z24_s8, + store_texel_z24_s8 + }, + { + MESA_FORMAT_S8_Z24, + fetch_texel_1d_f_s8_z24, + fetch_texel_2d_f_s8_z24, + fetch_texel_3d_f_s8_z24, + store_texel_s8_z24 + }, + { + MESA_FORMAT_Z16, + fetch_texel_1d_f_z16, + fetch_texel_2d_f_z16, + fetch_texel_3d_f_z16, + store_texel_z16 + }, + { + MESA_FORMAT_X8_Z24, + fetch_texel_1d_f_s8_z24, + fetch_texel_2d_f_s8_z24, + fetch_texel_3d_f_s8_z24, + store_texel_s8_z24 + }, + { + MESA_FORMAT_Z24_X8, + fetch_texel_1d_f_z24_s8, + fetch_texel_2d_f_z24_s8, + fetch_texel_3d_f_z24_s8, + store_texel_z24_s8 + }, + { + MESA_FORMAT_Z32, + fetch_texel_1d_f_z32, + fetch_texel_2d_f_z32, + fetch_texel_3d_f_z32, + store_texel_z32 + }, + { + MESA_FORMAT_S8, + NULL, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_SRGB8, + fetch_texel_1d_srgb8, + fetch_texel_2d_srgb8, + fetch_texel_3d_srgb8, + store_texel_srgb8 + }, + { + MESA_FORMAT_SRGBA8, + fetch_texel_1d_srgba8, + fetch_texel_2d_srgba8, + fetch_texel_3d_srgba8, + store_texel_srgba8 + }, + { + MESA_FORMAT_SARGB8, + fetch_texel_1d_sargb8, + fetch_texel_2d_sargb8, + fetch_texel_3d_sargb8, + store_texel_sargb8 + }, + { + MESA_FORMAT_SL8, + fetch_texel_1d_sl8, + fetch_texel_2d_sl8, + fetch_texel_3d_sl8, + store_texel_sl8 + }, + { + MESA_FORMAT_SLA8, + fetch_texel_1d_sla8, + fetch_texel_2d_sla8, + fetch_texel_3d_sla8, + store_texel_sla8 + }, + { + MESA_FORMAT_SRGB_DXT1, + NULL, + _mesa_fetch_texel_2d_f_srgb_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_SRGBA_DXT1, + NULL, + _mesa_fetch_texel_2d_f_srgba_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_SRGBA_DXT3, + NULL, + _mesa_fetch_texel_2d_f_srgba_dxt3, + NULL, + NULL + }, + { + MESA_FORMAT_SRGBA_DXT5, + NULL, + _mesa_fetch_texel_2d_f_srgba_dxt5, + NULL, + NULL + }, + + { + MESA_FORMAT_RGB_FXT1, + NULL, + _mesa_fetch_texel_2d_f_rgb_fxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_FXT1, + NULL, + _mesa_fetch_texel_2d_f_rgba_fxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGB_DXT1, + NULL, + _mesa_fetch_texel_2d_f_rgb_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_DXT1, + NULL, + _mesa_fetch_texel_2d_f_rgba_dxt1, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_DXT3, + NULL, + _mesa_fetch_texel_2d_f_rgba_dxt3, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_DXT5, + NULL, + _mesa_fetch_texel_2d_f_rgba_dxt5, + NULL, + NULL + }, + { + MESA_FORMAT_RGBA_FLOAT32, + fetch_texel_1d_f_rgba_f32, + fetch_texel_2d_f_rgba_f32, + fetch_texel_3d_f_rgba_f32, + store_texel_rgba_f32 + }, + { + MESA_FORMAT_RGBA_FLOAT16, + fetch_texel_1d_f_rgba_f16, + fetch_texel_2d_f_rgba_f16, + fetch_texel_3d_f_rgba_f16, + store_texel_rgba_f16 + }, + { + MESA_FORMAT_RGB_FLOAT32, + fetch_texel_1d_f_rgb_f32, + fetch_texel_2d_f_rgb_f32, + fetch_texel_3d_f_rgb_f32, + store_texel_rgb_f32 + }, + { + MESA_FORMAT_RGB_FLOAT16, + fetch_texel_1d_f_rgb_f16, + fetch_texel_2d_f_rgb_f16, + fetch_texel_3d_f_rgb_f16, + store_texel_rgb_f16 + }, + { + MESA_FORMAT_ALPHA_FLOAT32, + fetch_texel_1d_f_alpha_f32, + fetch_texel_2d_f_alpha_f32, + fetch_texel_3d_f_alpha_f32, + store_texel_alpha_f32 + }, + { + MESA_FORMAT_ALPHA_FLOAT16, + fetch_texel_1d_f_alpha_f16, + fetch_texel_2d_f_alpha_f16, + fetch_texel_3d_f_alpha_f16, + store_texel_alpha_f16 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT32, + fetch_texel_1d_f_luminance_f32, + fetch_texel_2d_f_luminance_f32, + fetch_texel_3d_f_luminance_f32, + store_texel_luminance_f32 + }, + { + MESA_FORMAT_LUMINANCE_FLOAT16, + fetch_texel_1d_f_luminance_f16, + fetch_texel_2d_f_luminance_f16, + fetch_texel_3d_f_luminance_f16, + store_texel_luminance_f16 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, + fetch_texel_1d_f_luminance_alpha_f32, + fetch_texel_2d_f_luminance_alpha_f32, + fetch_texel_3d_f_luminance_alpha_f32, + store_texel_luminance_alpha_f32 + }, + { + MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, + fetch_texel_1d_f_luminance_alpha_f16, + fetch_texel_2d_f_luminance_alpha_f16, + fetch_texel_3d_f_luminance_alpha_f16, + store_texel_luminance_alpha_f16 + }, + { + MESA_FORMAT_INTENSITY_FLOAT32, + fetch_texel_1d_f_intensity_f32, + fetch_texel_2d_f_intensity_f32, + fetch_texel_3d_f_intensity_f32, + store_texel_intensity_f32 + }, + { + MESA_FORMAT_INTENSITY_FLOAT16, + fetch_texel_1d_f_intensity_f16, + fetch_texel_2d_f_intensity_f16, + fetch_texel_3d_f_intensity_f16, + store_texel_intensity_f16 + }, + + /* non-normalized, signed int */ + { + MESA_FORMAT_RGBA_INT8, + fetch_texel_1d_rgba_int8, + fetch_texel_2d_rgba_int8, + fetch_texel_3d_rgba_int8, + store_texel_rgba_int8 + }, + { + MESA_FORMAT_RGBA_INT16, + fetch_texel_1d_rgba_int16, + fetch_texel_2d_rgba_int16, + fetch_texel_3d_rgba_int16, + store_texel_rgba_int16 + }, + { + MESA_FORMAT_RGBA_INT32, + fetch_texel_1d_rgba_int32, + fetch_texel_2d_rgba_int32, + fetch_texel_3d_rgba_int32, + store_texel_rgba_int32 + }, + + /* non-normalized, unsigned int */ + { + MESA_FORMAT_RGBA_UINT8, + fetch_texel_1d_rgba_uint8, + fetch_texel_2d_rgba_uint8, + fetch_texel_3d_rgba_uint8, + store_texel_rgba_uint8 + }, + { + MESA_FORMAT_RGBA_UINT16, + fetch_texel_1d_rgba_uint16, + fetch_texel_2d_rgba_uint16, + fetch_texel_3d_rgba_uint16, + store_texel_rgba_uint16 + }, + { + MESA_FORMAT_RGBA_UINT32, + fetch_texel_1d_rgba_uint32, + fetch_texel_2d_rgba_uint32, + fetch_texel_3d_rgba_uint32, + store_texel_rgba_uint32 + }, + + /* dudv */ + { + MESA_FORMAT_DUDV8, + fetch_texel_1d_dudv8, + fetch_texel_2d_dudv8, + fetch_texel_3d_dudv8, + NULL + }, + + /* signed, normalized */ + { + MESA_FORMAT_SIGNED_R8, + fetch_texel_1d_signed_r8, + fetch_texel_2d_signed_r8, + fetch_texel_3d_signed_r8, + store_texel_signed_r8 + }, + { + MESA_FORMAT_SIGNED_RG88, + fetch_texel_1d_signed_rg88, + fetch_texel_2d_signed_rg88, + fetch_texel_3d_signed_rg88, + store_texel_signed_rg88 + }, + { + MESA_FORMAT_SIGNED_RGBX8888, + fetch_texel_1d_signed_rgbx8888, + fetch_texel_2d_signed_rgbx8888, + fetch_texel_3d_signed_rgbx8888, + store_texel_signed_rgbx8888 + }, + { + MESA_FORMAT_SIGNED_RGBA8888, + fetch_texel_1d_signed_rgba8888, + fetch_texel_2d_signed_rgba8888, + fetch_texel_3d_signed_rgba8888, + store_texel_signed_rgba8888 + }, + { + MESA_FORMAT_SIGNED_RGBA8888_REV, + fetch_texel_1d_signed_rgba8888_rev, + fetch_texel_2d_signed_rgba8888_rev, + fetch_texel_3d_signed_rgba8888_rev, + store_texel_signed_rgba8888_rev + }, + { + MESA_FORMAT_SIGNED_R_16, + fetch_texel_1d_signed_r_16, + fetch_texel_2d_signed_r_16, + fetch_texel_3d_signed_r_16, + store_texel_signed_r_16 + }, + { + MESA_FORMAT_SIGNED_RG_16, + fetch_texel_1d_signed_rg_16, + fetch_texel_2d_signed_rg_16, + fetch_texel_3d_signed_rg_16, + store_texel_signed_rg_16 + }, + { + MESA_FORMAT_SIGNED_RGB_16, + fetch_texel_1d_signed_rgb_16, + fetch_texel_2d_signed_rgb_16, + fetch_texel_3d_signed_rgb_16, + store_texel_signed_rgb_16 + }, + { + MESA_FORMAT_SIGNED_RGBA_16, + fetch_texel_1d_signed_rgba_16, + fetch_texel_2d_signed_rgba_16, + fetch_texel_3d_signed_rgba_16, + store_texel_signed_rgba_16 + }, + { + MESA_FORMAT_RGBA_16, + fetch_texel_1d_rgba_16, + fetch_texel_2d_rgba_16, + fetch_texel_3d_rgba_16, + store_texel_rgba_16 + }, + { + MESA_FORMAT_RED_RGTC1, + NULL, + _mesa_fetch_texel_2d_f_red_rgtc1, + NULL, + NULL + }, + { + MESA_FORMAT_SIGNED_RED_RGTC1, + NULL, + _mesa_fetch_texel_2d_f_signed_red_rgtc1, + NULL, + NULL + }, + { + MESA_FORMAT_RG_RGTC2, + NULL, + _mesa_fetch_texel_2d_f_rg_rgtc2, + NULL, + NULL + }, + { + MESA_FORMAT_SIGNED_RG_RGTC2, + NULL, + _mesa_fetch_texel_2d_f_signed_rg_rgtc2, + NULL, + NULL + }, +}; + + +FetchTexelFuncF +_mesa_get_texel_fetch_func(gl_format format, GLuint dims) +{ +#ifdef DEBUG + /* check that the table entries are sorted by format name */ + gl_format fmt; + for (fmt = 0; fmt < MESA_FORMAT_COUNT; fmt++) { + assert(texfetch_funcs[fmt].Name == fmt); + } +#endif + + assert(Elements(texfetch_funcs) == MESA_FORMAT_COUNT); + assert(format < MESA_FORMAT_COUNT); + + switch (dims) { + case 1: + return texfetch_funcs[format].Fetch1D; + case 2: + return texfetch_funcs[format].Fetch2D; + case 3: + return texfetch_funcs[format].Fetch3D; + default: + assert(0 && "bad dims in _mesa_get_texel_fetch_func"); + return NULL; + } +} + + +StoreTexelFunc +_mesa_get_texel_store_func(gl_format format) +{ + assert(format < MESA_FORMAT_COUNT); + return texfetch_funcs[format].StoreTexel; +} + + +/** + * Adaptor for fetching a GLchan texel from a float-valued texture. + */ +static void +fetch_texel_float_to_chan(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texelOut) +{ + GLfloat temp[4]; + GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat); + + ASSERT(texImage->FetchTexelf); + texImage->FetchTexelf(texImage, i, j, k, temp); + if (baseFormat == GL_DEPTH_COMPONENT || + baseFormat == GL_DEPTH_STENCIL_EXT) { + /* just one channel */ + UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]); + } + else { + /* four channels */ + UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]); + UNCLAMPED_FLOAT_TO_CHAN(texelOut[1], temp[1]); + UNCLAMPED_FLOAT_TO_CHAN(texelOut[2], temp[2]); + UNCLAMPED_FLOAT_TO_CHAN(texelOut[3], temp[3]); + } +} + + +#if 0 +/** + * Adaptor for fetching a float texel from a GLchan-valued texture. + */ +static void +fetch_texel_chan_to_float(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texelOut) +{ + GLchan temp[4]; + GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat); + + ASSERT(texImage->FetchTexelc); + texImage->FetchTexelc(texImage, i, j, k, temp); + if (baseFormat == GL_DEPTH_COMPONENT || + baseFormat == GL_DEPTH_STENCIL_EXT) { + /* just one channel */ + texelOut[0] = CHAN_TO_FLOAT(temp[0]); + } + else { + /* four channels */ + texelOut[0] = CHAN_TO_FLOAT(temp[0]); + texelOut[1] = CHAN_TO_FLOAT(temp[1]); + texelOut[2] = CHAN_TO_FLOAT(temp[2]); + texelOut[3] = CHAN_TO_FLOAT(temp[3]); + } +} +#endif + + +/** + * Initialize the texture image's FetchTexelc and FetchTexelf methods. + */ +void +_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims) +{ + gl_format format = texImage->TexFormat; + + ASSERT(dims == 1 || dims == 2 || dims == 3); + + if (texImage->TexObject->sRGBDecode == GL_SKIP_DECODE_EXT && + _mesa_get_format_color_encoding(format) == GL_SRGB) { + format = _mesa_get_srgb_format_linear(format); + } + + texImage->FetchTexelf = _mesa_get_texel_fetch_func(format, dims); + + texImage->FetchTexelc = fetch_texel_float_to_chan; + + ASSERT(texImage->FetchTexelc); + ASSERT(texImage->FetchTexelf); +} + +void +_mesa_update_fetch_functions(struct gl_texture_object *texObj) +{ + GLuint face, i; + GLuint dims; + + dims = _mesa_get_texture_dimensions(texObj->Target); + + for (face = 0; face < 6; face++) { + for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { + if (texObj->Image[face][i]) { + _mesa_set_fetch_functions(texObj->Image[face][i], dims); + } + } + } +} diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c index 2542cea85..72025cf82 100644 --- a/mesalib/src/mesa/main/texformat.c +++ b/mesalib/src/mesa/main/texformat.c @@ -602,6 +602,25 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, } } + if (ctx->Extensions.ARB_texture_compression_rgtc) { + switch (internalFormat) { + case GL_COMPRESSED_RED_RGTC1: + RETURN_IF_SUPPORTED(MESA_FORMAT_RED_RGTC1); + break; + case GL_COMPRESSED_SIGNED_RED_RGTC1: + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RED_RGTC1); + break; + case GL_COMPRESSED_RG_RGTC2: + RETURN_IF_SUPPORTED(MESA_FORMAT_RG_RGTC2); + break; + case GL_COMPRESSED_SIGNED_RG_RGTC2: + RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_RG_RGTC2); + break; + default: + ; /* fallthrough */ + } + } + _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()"); return MESA_FORMAT_NONE; } diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c index 1947d32e6..8a3e5f779 100644 --- a/mesalib/src/mesa/main/texstore.c +++ b/mesalib/src/mesa/main/texstore.c @@ -1,4783 +1,4789 @@ -/* - * Mesa 3-D graphics library - * Version: 7.5 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (c) 2008-2009 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Authors: - * Brian Paul - */ - -/** - * The GL texture image functions in teximage.c basically just do - * error checking and data structure allocation. They in turn call - * device driver functions which actually copy/convert/store the user's - * texture image data. - * - * However, most device drivers will be able to use the fallback functions - * in this file. That is, most drivers will have the following bit of - * code: - * ctx->Driver.TexImage1D = _mesa_store_teximage1d; - * ctx->Driver.TexImage2D = _mesa_store_teximage2d; - * ctx->Driver.TexImage3D = _mesa_store_teximage3d; - * etc... - * - * Texture image processing is actually kind of complicated. We have to do: - * Format/type conversions - * pixel unpacking - * pixel transfer (scale, bais, lookup, etc) - * - * These functions can handle most everything, including processing full - * images and sub-images. - */ - - -#include "glheader.h" -#include "bufferobj.h" -#include "colormac.h" -#include "image.h" -#include "macros.h" -#include "mipmap.h" -#include "mfeatures.h" -#include "mtypes.h" -#include "pack.h" -#include "imports.h" -#include "pack.h" -#include "texcompress.h" -#include "texcompress_fxt1.h" -#include "texcompress_s3tc.h" -#include "teximage.h" -#include "texstore.h" -#include "enums.h" - - -enum { - ZERO = 4, - ONE = 5 -}; - - -/** - * Texture image storage function. - */ -typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS); - - -/** - * Return GL_TRUE if the given image format is one that be converted - * to another format by swizzling. - */ -static GLboolean -can_swizzle(GLenum logicalBaseFormat) -{ - switch (logicalBaseFormat) { - case GL_RGBA: - case GL_RGB: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_BGR: - case GL_BGRA: - case GL_ABGR_EXT: - case GL_RG: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - - -enum { - IDX_LUMINANCE = 0, - IDX_ALPHA, - IDX_INTENSITY, - IDX_LUMINANCE_ALPHA, - IDX_RGB, - IDX_RGBA, - IDX_RED, - IDX_GREEN, - IDX_BLUE, - IDX_BGR, - IDX_BGRA, - IDX_ABGR, - IDX_RG, - MAX_IDX -}; - -#define MAP1(x) MAP4(x, ZERO, ZERO, ZERO) -#define MAP2(x,y) MAP4(x, y, ZERO, ZERO) -#define MAP3(x,y,z) MAP4(x, y, z, ZERO) -#define MAP4(x,y,z,w) { x, y, z, w, ZERO, ONE } - - -static const struct { - GLubyte format_idx; - GLubyte to_rgba[6]; - GLubyte from_rgba[6]; -} mappings[MAX_IDX] = -{ - { - IDX_LUMINANCE, - MAP4(0,0,0,ONE), - MAP1(0) - }, - - { - IDX_ALPHA, - MAP4(ZERO, ZERO, ZERO, 0), - MAP1(3) - }, - - { - IDX_INTENSITY, - MAP4(0, 0, 0, 0), - MAP1(0), - }, - - { - IDX_LUMINANCE_ALPHA, - MAP4(0,0,0,1), - MAP2(0,3) - }, - - { - IDX_RGB, - MAP4(0,1,2,ONE), - MAP3(0,1,2) - }, - - { - IDX_RGBA, - MAP4(0,1,2,3), - MAP4(0,1,2,3), - }, - - { - IDX_RED, - MAP4(0, ZERO, ZERO, ONE), - MAP1(0), - }, - - { - IDX_GREEN, - MAP4(ZERO, 0, ZERO, ONE), - MAP1(1), - }, - - { - IDX_BLUE, - MAP4(ZERO, ZERO, 0, ONE), - MAP1(2), - }, - - { - IDX_BGR, - MAP4(2,1,0,ONE), - MAP3(2,1,0) - }, - - { - IDX_BGRA, - MAP4(2,1,0,3), - MAP4(2,1,0,3) - }, - - { - IDX_ABGR, - MAP4(3,2,1,0), - MAP4(3,2,1,0) - }, - - { - IDX_RG, - MAP4(0, 1, ZERO, ONE), - MAP2(0, 1) - }, -}; - - - -/** - * Convert a GL image format enum to an IDX_* value (see above). - */ -static int -get_map_idx(GLenum value) -{ - switch (value) { - case GL_LUMINANCE: return IDX_LUMINANCE; - case GL_ALPHA: return IDX_ALPHA; - case GL_INTENSITY: return IDX_INTENSITY; - case GL_LUMINANCE_ALPHA: return IDX_LUMINANCE_ALPHA; - case GL_RGB: return IDX_RGB; - case GL_RGBA: return IDX_RGBA; - case GL_RED: return IDX_RED; - case GL_GREEN: return IDX_GREEN; - case GL_BLUE: return IDX_BLUE; - case GL_BGR: return IDX_BGR; - case GL_BGRA: return IDX_BGRA; - case GL_ABGR_EXT: return IDX_ABGR; - case GL_RG: return IDX_RG; - default: - _mesa_problem(NULL, "Unexpected inFormat"); - return 0; - } -} - - -/** - * When promoting texture formats (see below) we need to compute the - * mapping of dest components back to source components. - * This function does that. - * \param inFormat the incoming format of the texture - * \param outFormat the final texture format - * \return map[6] a full 6-component map - */ -static void -compute_component_mapping(GLenum inFormat, GLenum outFormat, - GLubyte *map) -{ - const int inFmt = get_map_idx(inFormat); - const int outFmt = get_map_idx(outFormat); - const GLubyte *in2rgba = mappings[inFmt].to_rgba; - const GLubyte *rgba2out = mappings[outFmt].from_rgba; - int i; - - for (i = 0; i < 4; i++) - map[i] = in2rgba[rgba2out[i]]; - - map[ZERO] = ZERO; - map[ONE] = ONE; - -#if 0 - printf("from %x/%s to %x/%s map %d %d %d %d %d %d\n", - inFormat, _mesa_lookup_enum_by_nr(inFormat), - outFormat, _mesa_lookup_enum_by_nr(outFormat), - map[0], - map[1], - map[2], - map[3], - map[4], - map[5]); -#endif -} - - -/** - * Make a temporary (color) texture image with GLfloat components. - * Apply all needed pixel unpacking and pixel transfer operations. - * Note that there are both logicalBaseFormat and textureBaseFormat parameters. - * Suppose the user specifies GL_LUMINANCE as the internal texture format - * but the graphics hardware doesn't support luminance textures. So, we might - * use an RGB hardware format instead. - * If logicalBaseFormat != textureBaseFormat we have some extra work to do. - * - * \param ctx the rendering context - * \param dims image dimensions: 1, 2 or 3 - * \param logicalBaseFormat basic texture derived from the user's - * internal texture format value - * \param textureBaseFormat the actual basic format of the texture - * \param srcWidth source image width - * \param srcHeight source image height - * \param srcDepth source image depth - * \param srcFormat source image format - * \param srcType source image type - * \param srcAddr source image address - * \param srcPacking source image pixel packing - * \return resulting image with format = textureBaseFormat and type = GLfloat. - */ -static GLfloat * -make_temp_float_image(struct gl_context *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking, - GLbitfield transferOps) -{ - GLfloat *tempImage; - const GLint components = _mesa_components_in_format(logicalBaseFormat); - const GLint srcStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLfloat *dst; - GLint img, row; - - ASSERT(dims >= 1 && dims <= 3); - - ASSERT(logicalBaseFormat == GL_RGBA || - logicalBaseFormat == GL_RGB || - logicalBaseFormat == GL_RG || - logicalBaseFormat == GL_RED || - logicalBaseFormat == GL_LUMINANCE_ALPHA || - logicalBaseFormat == GL_LUMINANCE || - logicalBaseFormat == GL_ALPHA || - logicalBaseFormat == GL_INTENSITY || - logicalBaseFormat == GL_COLOR_INDEX || - logicalBaseFormat == GL_DEPTH_COMPONENT); - - ASSERT(textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_RGB || - textureBaseFormat == GL_RG || - textureBaseFormat == GL_RED || - textureBaseFormat == GL_LUMINANCE_ALPHA || - textureBaseFormat == GL_LUMINANCE || - textureBaseFormat == GL_ALPHA || - textureBaseFormat == GL_INTENSITY || - textureBaseFormat == GL_COLOR_INDEX || - textureBaseFormat == GL_DEPTH_COMPONENT); - - tempImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth - * components * sizeof(GLfloat)); - if (!tempImage) - return NULL; - - dst = tempImage; - for (img = 0; img < srcDepth; img++) { - const GLubyte *src - = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - _mesa_unpack_color_span_float(ctx, srcWidth, logicalBaseFormat, - dst, srcFormat, srcType, src, - srcPacking, transferOps); - dst += srcWidth * components; - src += srcStride; - } - } - - if (logicalBaseFormat != textureBaseFormat) { - /* more work */ - GLint texComponents = _mesa_components_in_format(textureBaseFormat); - GLint logComponents = _mesa_components_in_format(logicalBaseFormat); - GLfloat *newImage; - GLint i, n; - GLubyte map[6]; - - /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ - ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_LUMINANCE_ALPHA); - - /* The actual texture format should have at least as many components - * as the logical texture format. - */ - ASSERT(texComponents >= logComponents); - - newImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth - * texComponents * sizeof(GLfloat)); - if (!newImage) { - free(tempImage); - return NULL; - } - - compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); - - n = srcWidth * srcHeight * srcDepth; - for (i = 0; i < n; i++) { - GLint k; - for (k = 0; k < texComponents; k++) { - GLint j = map[k]; - if (j == ZERO) - newImage[i * texComponents + k] = 0.0F; - else if (j == ONE) - newImage[i * texComponents + k] = 1.0F; - else - newImage[i * texComponents + k] = tempImage[i * logComponents + j]; - } - } - - free(tempImage); - tempImage = newImage; - } - - return tempImage; -} - - -/** - * Make temporary image with uint pixel values. Used for unsigned - * integer-valued textures. - */ -static GLuint * -make_temp_uint_image(struct gl_context *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking) -{ - GLuint *tempImage; - const GLint components = _mesa_components_in_format(logicalBaseFormat); - const GLint srcStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLuint *dst; - GLint img, row; - - ASSERT(dims >= 1 && dims <= 3); - - ASSERT(logicalBaseFormat == GL_RGBA || - logicalBaseFormat == GL_RGB || - logicalBaseFormat == GL_RG || - logicalBaseFormat == GL_RED || - logicalBaseFormat == GL_LUMINANCE_ALPHA || - logicalBaseFormat == GL_LUMINANCE || - logicalBaseFormat == GL_INTENSITY || - logicalBaseFormat == GL_ALPHA); - - ASSERT(textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_RGB || - textureBaseFormat == GL_RG || - textureBaseFormat == GL_RED || - textureBaseFormat == GL_LUMINANCE_ALPHA || - textureBaseFormat == GL_LUMINANCE || - textureBaseFormat == GL_ALPHA); - - tempImage = (GLuint *) malloc(srcWidth * srcHeight * srcDepth - * components * sizeof(GLuint)); - if (!tempImage) - return NULL; - - dst = tempImage; - for (img = 0; img < srcDepth; img++) { - const GLubyte *src - = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - _mesa_unpack_color_span_uint(ctx, srcWidth, logicalBaseFormat, - dst, srcFormat, srcType, src, - srcPacking); - dst += srcWidth * components; - src += srcStride; - } - } - - if (logicalBaseFormat != textureBaseFormat) { - /* more work */ - GLint texComponents = _mesa_components_in_format(textureBaseFormat); - GLint logComponents = _mesa_components_in_format(logicalBaseFormat); - GLuint *newImage; - GLint i, n; - GLubyte map[6]; - - /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ - ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_LUMINANCE_ALPHA); - - /* The actual texture format should have at least as many components - * as the logical texture format. - */ - ASSERT(texComponents >= logComponents); - - newImage = (GLuint *) malloc(srcWidth * srcHeight * srcDepth - * texComponents * sizeof(GLuint)); - if (!newImage) { - free(tempImage); - return NULL; - } - - compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); - - n = srcWidth * srcHeight * srcDepth; - for (i = 0; i < n; i++) { - GLint k; - for (k = 0; k < texComponents; k++) { - GLint j = map[k]; - if (j == ZERO) - newImage[i * texComponents + k] = 0.0F; - else if (j == ONE) - newImage[i * texComponents + k] = 1.0F; - else - newImage[i * texComponents + k] = tempImage[i * logComponents + j]; - } - } - - free(tempImage); - tempImage = newImage; - } - - return tempImage; -} - - - -/** - * Make a temporary (color) texture image with GLchan components. - * Apply all needed pixel unpacking and pixel transfer operations. - * Note that there are both logicalBaseFormat and textureBaseFormat parameters. - * Suppose the user specifies GL_LUMINANCE as the internal texture format - * but the graphics hardware doesn't support luminance textures. So, we might - * use an RGB hardware format instead. - * If logicalBaseFormat != textureBaseFormat we have some extra work to do. - * - * \param ctx the rendering context - * \param dims image dimensions: 1, 2 or 3 - * \param logicalBaseFormat basic texture derived from the user's - * internal texture format value - * \param textureBaseFormat the actual basic format of the texture - * \param srcWidth source image width - * \param srcHeight source image height - * \param srcDepth source image depth - * \param srcFormat source image format - * \param srcType source image type - * \param srcAddr source image address - * \param srcPacking source image pixel packing - * \return resulting image with format = textureBaseFormat and type = GLchan. - */ -GLchan * -_mesa_make_temp_chan_image(struct gl_context *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking) -{ - GLuint transferOps = ctx->_ImageTransferState; - const GLint components = _mesa_components_in_format(logicalBaseFormat); - GLint img, row; - GLchan *tempImage, *dst; - - ASSERT(dims >= 1 && dims <= 3); - - ASSERT(logicalBaseFormat == GL_RGBA || - logicalBaseFormat == GL_RGB || - logicalBaseFormat == GL_RG || - logicalBaseFormat == GL_RED || - logicalBaseFormat == GL_LUMINANCE_ALPHA || - logicalBaseFormat == GL_LUMINANCE || - logicalBaseFormat == GL_ALPHA || - logicalBaseFormat == GL_INTENSITY); - - ASSERT(textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_RGB || - textureBaseFormat == GL_RG || - textureBaseFormat == GL_RED || - textureBaseFormat == GL_LUMINANCE_ALPHA || - textureBaseFormat == GL_LUMINANCE || - textureBaseFormat == GL_ALPHA || - textureBaseFormat == GL_INTENSITY); - - /* unpack and transfer the source image */ - tempImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth - * components * sizeof(GLchan)); - if (!tempImage) { - return NULL; - } - - dst = tempImage; - for (img = 0; img < srcDepth; img++) { - const GLint srcStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - const GLubyte *src = - (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - _mesa_unpack_color_span_chan(ctx, srcWidth, logicalBaseFormat, dst, - srcFormat, srcType, src, srcPacking, - transferOps); - dst += srcWidth * components; - src += srcStride; - } - } - - if (logicalBaseFormat != textureBaseFormat) { - /* one more conversion step */ - GLint texComponents = _mesa_components_in_format(textureBaseFormat); - GLint logComponents = _mesa_components_in_format(logicalBaseFormat); - GLchan *newImage; - GLint i, n; - GLubyte map[6]; - - /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ - ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || - textureBaseFormat == GL_LUMINANCE_ALPHA); - - /* The actual texture format should have at least as many components - * as the logical texture format. - */ - ASSERT(texComponents >= logComponents); - - newImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth - * texComponents * sizeof(GLchan)); - if (!newImage) { - free(tempImage); - return NULL; - } - - compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); - - n = srcWidth * srcHeight * srcDepth; - for (i = 0; i < n; i++) { - GLint k; - for (k = 0; k < texComponents; k++) { - GLint j = map[k]; - if (j == ZERO) - newImage[i * texComponents + k] = 0; - else if (j == ONE) - newImage[i * texComponents + k] = CHAN_MAX; - else - newImage[i * texComponents + k] = tempImage[i * logComponents + j]; - } - } - - free(tempImage); - tempImage = newImage; - } - - return tempImage; -} - - -/** - * Copy GLubyte pixels from to with swizzling. - * \param dst destination pixels - * \param dstComponents number of color components in destination pixels - * \param src source pixels - * \param srcComponents number of color components in source pixels - * \param map the swizzle mapping. map[X] says where to find the X component - * in the source image's pixels. For example, if the source image - * is GL_BGRA and X = red, map[0] yields 2. - * \param count number of pixels to copy/swizzle. - */ -static void -swizzle_copy(GLubyte *dst, GLuint dstComponents, const GLubyte *src, - GLuint srcComponents, const GLubyte *map, GLuint count) -{ -#define SWZ_CPY(dst, src, count, dstComps, srcComps) \ - do { \ - GLuint i; \ - for (i = 0; i < count; i++) { \ - GLuint j; \ - if (srcComps == 4) { \ - COPY_4UBV(tmp, src); \ - } \ - else { \ - for (j = 0; j < srcComps; j++) { \ - tmp[j] = src[j]; \ - } \ - } \ - src += srcComps; \ - for (j = 0; j < dstComps; j++) { \ - dst[j] = tmp[map[j]]; \ - } \ - dst += dstComps; \ - } \ - } while (0) - - GLubyte tmp[6]; - - tmp[ZERO] = 0x0; - tmp[ONE] = 0xff; - - ASSERT(srcComponents <= 4); - ASSERT(dstComponents <= 4); - - switch (dstComponents) { - case 4: - switch (srcComponents) { - case 4: - SWZ_CPY(dst, src, count, 4, 4); - break; - case 3: - SWZ_CPY(dst, src, count, 4, 3); - break; - case 2: - SWZ_CPY(dst, src, count, 4, 2); - break; - case 1: - SWZ_CPY(dst, src, count, 4, 1); - break; - default: - ; - } - break; - case 3: - switch (srcComponents) { - case 4: - SWZ_CPY(dst, src, count, 3, 4); - break; - case 3: - SWZ_CPY(dst, src, count, 3, 3); - break; - case 2: - SWZ_CPY(dst, src, count, 3, 2); - break; - case 1: - SWZ_CPY(dst, src, count, 3, 1); - break; - default: - ; - } - break; - case 2: - switch (srcComponents) { - case 4: - SWZ_CPY(dst, src, count, 2, 4); - break; - case 3: - SWZ_CPY(dst, src, count, 2, 3); - break; - case 2: - SWZ_CPY(dst, src, count, 2, 2); - break; - case 1: - SWZ_CPY(dst, src, count, 2, 1); - break; - default: - ; - } - break; - case 1: - switch (srcComponents) { - case 4: - SWZ_CPY(dst, src, count, 1, 4); - break; - case 3: - SWZ_CPY(dst, src, count, 1, 3); - break; - case 2: - SWZ_CPY(dst, src, count, 1, 2); - break; - case 1: - SWZ_CPY(dst, src, count, 1, 1); - break; - default: - ; - } - break; - default: - ; - } -#undef SWZ_CPY -} - - - -static const GLubyte map_identity[6] = { 0, 1, 2, 3, ZERO, ONE }; -static const GLubyte map_3210[6] = { 3, 2, 1, 0, ZERO, ONE }; - - -/** - * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a - * mapping array depending on endianness. - */ -static const GLubyte * -type_mapping( GLenum srcType ) -{ - switch (srcType) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - return map_identity; - case GL_UNSIGNED_INT_8_8_8_8: - return _mesa_little_endian() ? map_3210 : map_identity; - case GL_UNSIGNED_INT_8_8_8_8_REV: - return _mesa_little_endian() ? map_identity : map_3210; - default: - return NULL; - } -} - - -/** - * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a - * mapping array depending on pixelstore byte swapping state. - */ -static const GLubyte * -byteswap_mapping( GLboolean swapBytes, - GLenum srcType ) -{ - if (!swapBytes) - return map_identity; - - switch (srcType) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - return map_identity; - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - return map_3210; - default: - return NULL; - } -} - - - -/** - * Transfer a GLubyte texture image with component swizzling. - */ -static void -_mesa_swizzle_ubyte_image(struct gl_context *ctx, - GLuint dimensions, - GLenum srcFormat, - GLenum srcType, - - GLenum baseInternalFormat, - - const GLubyte *rgba2dst, - GLuint dstComponents, - - GLvoid *dstAddr, - GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, - GLint dstRowStride, - const GLuint *dstImageOffsets, - - GLint srcWidth, GLint srcHeight, GLint srcDepth, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking ) -{ - GLint srcComponents = _mesa_components_in_format(srcFormat); - const GLubyte *srctype2ubyte, *swap; - GLubyte map[4], src2base[6], base2rgba[6]; - GLint i; - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, - srcFormat, GL_UNSIGNED_BYTE); - const GLint srcImageStride - = _mesa_image_image_stride(srcPacking, srcWidth, srcHeight, srcFormat, - GL_UNSIGNED_BYTE); - const GLubyte *srcImage - = (const GLubyte *) _mesa_image_address(dimensions, srcPacking, srcAddr, - srcWidth, srcHeight, srcFormat, - GL_UNSIGNED_BYTE, 0, 0, 0); - - (void) ctx; - - /* Translate from src->baseInternal->GL_RGBA->dst. This will - * correctly deal with RGBA->RGB->RGBA conversions where the final - * A value must be 0xff regardless of the incoming alpha values. - */ - compute_component_mapping(srcFormat, baseInternalFormat, src2base); - compute_component_mapping(baseInternalFormat, GL_RGBA, base2rgba); - swap = byteswap_mapping(srcPacking->SwapBytes, srcType); - srctype2ubyte = type_mapping(srcType); - - - for (i = 0; i < 4; i++) - map[i] = srctype2ubyte[swap[src2base[base2rgba[rgba2dst[i]]]]]; - -/* printf("map %d %d %d %d\n", map[0], map[1], map[2], map[3]); */ - - if (srcComponents == dstComponents && - srcRowStride == dstRowStride && - srcRowStride == srcWidth * srcComponents && - dimensions < 3) { - /* 1 and 2D images only */ - GLubyte *dstImage = (GLubyte *) dstAddr - + dstYoffset * dstRowStride - + dstXoffset * dstComponents; - swizzle_copy(dstImage, dstComponents, srcImage, srcComponents, map, - srcWidth * srcHeight); - } - else { - GLint img, row; - for (img = 0; img < srcDepth; img++) { - const GLubyte *srcRow = srcImage; - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * dstComponents - + dstYoffset * dstRowStride - + dstXoffset * dstComponents; - for (row = 0; row < srcHeight; row++) { - swizzle_copy(dstRow, dstComponents, srcRow, srcComponents, map, srcWidth); - dstRow += dstRowStride; - srcRow += srcRowStride; - } - srcImage += srcImageStride; - } - } -} - - -/** - * Teximage storage routine for when a simple memcpy will do. - * No pixel transfer operations or special texel encodings allowed. - * 1D, 2D and 3D images supported. - */ -static void -memcpy_texture(struct gl_context *ctx, - GLuint dimensions, - gl_format dstFormat, - GLvoid *dstAddr, - GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, - GLint dstRowStride, - const GLuint *dstImageOffsets, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking) -{ - const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, - srcFormat, srcType); - const GLint srcImageStride = _mesa_image_image_stride(srcPacking, - srcWidth, srcHeight, srcFormat, srcType); - const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(dimensions, - srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLint bytesPerRow = srcWidth * texelBytes; - -#if 0 - /* XXX update/re-enable for dstImageOffsets array */ - const GLint bytesPerImage = srcHeight * bytesPerRow; - const GLint bytesPerTexture = srcDepth * bytesPerImage; - GLubyte *dstImage = (GLubyte *) dstAddr - + dstZoffset * dstImageStride - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - - if (dstRowStride == srcRowStride && - dstRowStride == bytesPerRow && - ((dstImageStride == srcImageStride && - dstImageStride == bytesPerImage) || - (srcDepth == 1))) { - /* one big memcpy */ - ctx->Driver.TextureMemCpy(dstImage, srcImage, bytesPerTexture); - } - else - { - GLint img, row; - for (img = 0; img < srcDepth; img++) { - const GLubyte *srcRow = srcImage; - GLubyte *dstRow = dstImage; - for (row = 0; row < srcHeight; row++) { - ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow); - dstRow += dstRowStride; - srcRow += srcRowStride; - } - srcImage += srcImageStride; - dstImage += dstImageStride; - } - } -#endif - - GLint img, row; - for (img = 0; img < srcDepth; img++) { - const GLubyte *srcRow = srcImage; - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow); - dstRow += dstRowStride; - srcRow += srcRowStride; - } - srcImage += srcImageStride; - } -} - - - -/** - * Store a 32-bit integer depth component texture image. - */ -static GLboolean -_mesa_texstore_z32(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffffffff; - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - (void) dims; - ASSERT(dstFormat == MESA_FORMAT_Z32); - ASSERT(texelBytes == sizeof(GLuint)); - - if (ctx->Pixel.DepthScale == 1.0f && - ctx->Pixel.DepthBias == 0.0f && - !srcPacking->SwapBytes && - baseInternalFormat == GL_DEPTH_COMPONENT && - srcFormat == GL_DEPTH_COMPONENT && - srcType == GL_UNSIGNED_INT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_INT, (GLuint *) dstRow, - depthScale, srcType, src, srcPacking); - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - - -/** - * Store a 24-bit integer depth component texture image. - */ -static GLboolean -_mesa_texstore_x8_z24(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffffff; - const GLuint texelBytes = 4; - - (void) dims; - ASSERT(dstFormat == MESA_FORMAT_X8_Z24); - - { - /* general path */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_INT, (GLuint *) dstRow, - depthScale, srcType, src, srcPacking); - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - - -/** - * Store a 24-bit integer depth component texture image. - */ -static GLboolean -_mesa_texstore_z24_x8(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffffff; - const GLuint texelBytes = 4; - - (void) dims; - ASSERT(dstFormat == MESA_FORMAT_Z24_X8); - - { - /* general path */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - GLuint *dst = (GLuint *) dstRow; - GLint i; - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_INT, dst, - depthScale, srcType, src, srcPacking); - for (i = 0; i < srcWidth; i++) - dst[i] <<= 8; - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - - -/** - * Store a 16-bit integer depth component texture image. - */ -static GLboolean -_mesa_texstore_z16(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffff; - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - (void) dims; - ASSERT(dstFormat == MESA_FORMAT_Z16); - ASSERT(texelBytes == sizeof(GLushort)); - - if (ctx->Pixel.DepthScale == 1.0f && - ctx->Pixel.DepthBias == 0.0f && - !srcPacking->SwapBytes && - baseInternalFormat == GL_DEPTH_COMPONENT && - srcFormat == GL_DEPTH_COMPONENT && - srcType == GL_UNSIGNED_SHORT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - GLushort *dst16 = (GLushort *) dstRow; - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_SHORT, dst16, depthScale, - srcType, src, srcPacking); - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - - -/** - * Store an rgb565 or rgb565_rev texture image. - */ -static GLboolean -_mesa_texstore_rgb565(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGB565 || - dstFormat == MESA_FORMAT_RGB565_REV); - ASSERT(texelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_RGB565 && - baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && - srcType == GL_UNSIGNED_SHORT_5_6_5) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && - srcType == GL_UNSIGNED_BYTE && - dims == 2) { - /* do optimized tex store */ - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - const GLubyte *src = (const GLubyte *) - _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, - srcFormat, srcType, 0, 0, 0); - GLubyte *dst = (GLubyte *) dstAddr - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - GLint row, col; - for (row = 0; row < srcHeight; row++) { - const GLubyte *srcUB = (const GLubyte *) src; - GLushort *dstUS = (GLushort *) dst; - /* check for byteswapped format */ - if (dstFormat == MESA_FORMAT_RGB565) { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] ); - srcUB += 3; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_565_REV( srcUB[0], srcUB[1], srcUB[2] ); - srcUB += 3; - } - } - dst += dstRowStride; - src += srcRowStride; - } - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - /* check for byteswapped format */ - if (dstFormat == MESA_FORMAT_RGB565) { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 3; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_565_REV( CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 3; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Store a texture in MESA_FORMAT_RGBA8888 or MESA_FORMAT_RGBA8888_REV. - */ -static GLboolean -_mesa_texstore_rgba8888(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA8888 || - dstFormat == MESA_FORMAT_RGBA8888_REV); - ASSERT(texelBytes == 4); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_RGBA8888 && - baseInternalFormat == GL_RGBA && - ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) || - (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) || - (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) || - (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian))) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_RGBA8888_REV && - baseInternalFormat == GL_RGBA && - ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) || - (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) || - (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) || - (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian))) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - (srcType == GL_UNSIGNED_BYTE || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV) && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if ((littleEndian && dstFormat == MESA_FORMAT_RGBA8888) || - (!littleEndian && dstFormat == MESA_FORMAT_RGBA8888_REV)) { - dstmap[3] = 0; - dstmap[2] = 1; - dstmap[1] = 2; - dstmap[0] = 3; - } - else { - dstmap[3] = 3; - dstmap[2] = 2; - dstmap[1] = 1; - dstmap[0] = 0; - } - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 4, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - if (dstFormat == MESA_FORMAT_RGBA8888) { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]), - CHAN_TO_UBYTE(src[ACOMP]) ); - src += 4; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]), - CHAN_TO_UBYTE(src[ACOMP]) ); - src += 4; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_argb8888(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = GL_RGBA; - - ASSERT(dstFormat == MESA_FORMAT_ARGB8888 || - dstFormat == MESA_FORMAT_ARGB8888_REV || - dstFormat == MESA_FORMAT_XRGB8888 || - dstFormat == MESA_FORMAT_XRGB8888_REV ); - ASSERT(texelBytes == 4); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_ARGB8888 || - dstFormat == MESA_FORMAT_XRGB8888) && - baseInternalFormat == GL_RGBA && - srcFormat == GL_BGRA && - ((srcType == GL_UNSIGNED_BYTE && littleEndian) || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) { - /* simple memcpy path (little endian) */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_ARGB8888_REV || - dstFormat == MESA_FORMAT_XRGB8888_REV) && - baseInternalFormat == GL_RGBA && - srcFormat == GL_BGRA && - ((srcType == GL_UNSIGNED_BYTE && !littleEndian) || - srcType == GL_UNSIGNED_INT_8_8_8_8)) { - /* simple memcpy path (big endian) */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_ARGB8888 || - dstFormat == MESA_FORMAT_XRGB8888) && - srcFormat == GL_RGB && - (baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB) && - srcType == GL_UNSIGNED_BYTE) { - int img, row, col; - for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *d4 = (GLuint *) dstRow; - for (col = 0; col < srcWidth; col++) { - d4[col] = PACK_COLOR_8888(0xff, - srcRow[col * 3 + RCOMP], - srcRow[col * 3 + GCOMP], - srcRow[col * 3 + BCOMP]); - } - dstRow += dstRowStride; - srcRow += srcRowStride; - } - } - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_ARGB8888 && - srcFormat == GL_RGBA && - baseInternalFormat == GL_RGBA && - srcType == GL_UNSIGNED_BYTE) { - /* same as above case, but src data has alpha too */ - GLint img, row, col; - /* For some reason, streaming copies to write-combined regions - * are extremely sensitive to the characteristics of how the - * source data is retrieved. By reordering the source reads to - * be in-order, the speed of this operation increases by half. - * Strangely the same isn't required for the RGB path, above. - */ - for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *d4 = (GLuint *) dstRow; - for (col = 0; col < srcWidth; col++) { - d4[col] = PACK_COLOR_8888(srcRow[col * 4 + ACOMP], - srcRow[col * 4 + RCOMP], - srcRow[col * 4 + GCOMP], - srcRow[col * 4 + BCOMP]); - } - dstRow += dstRowStride; - srcRow += srcRowStride; - } - } - } - else if (!ctx->_ImageTransferState && - (srcType == GL_UNSIGNED_BYTE || - srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV) && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if ((littleEndian && dstFormat == MESA_FORMAT_ARGB8888) || - (littleEndian && dstFormat == MESA_FORMAT_XRGB8888) || - (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) || - (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV)) { - dstmap[3] = 3; /* alpha */ - dstmap[2] = 0; /* red */ - dstmap[1] = 1; /* green */ - dstmap[0] = 2; /* blue */ - } - else { - assert((littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) || - (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888) || - (littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV) || - (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888)); - dstmap[3] = 2; - dstmap[2] = 1; - dstmap[1] = 0; - dstmap[0] = 3; - } - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 4, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - if (dstFormat == MESA_FORMAT_ARGB8888) { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[ACOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - } - else if (dstFormat == MESA_FORMAT_XRGB8888) { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888( 0xff, - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[ACOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_rgb888(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGB888); - ASSERT(texelBytes == 3); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGB && - srcFormat == GL_BGR && - srcType == GL_UNSIGNED_BYTE && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - srcFormat == GL_RGBA && - srcType == GL_UNSIGNED_BYTE) { - /* extract RGB from RGBA */ - GLint img, row, col; - for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP]; - dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP]; - dstRow[col * 3 + 2] = srcRow[col * 4 + RCOMP]; - } - dstRow += dstRowStride; - srcRow += srcRowStride; - } - } - } - else if (!ctx->_ImageTransferState && - srcType == GL_UNSIGNED_BYTE && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - dstmap[0] = 2; - dstmap[1] = 1; - dstmap[2] = 0; - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 3, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = (const GLchan *) tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { -#if 0 - if (littleEndian) { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]); - dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); - dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]); - srcUB += 3; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = srcUB[BCOMP]; - dstRow[col * 3 + 1] = srcUB[GCOMP]; - dstRow[col * 3 + 2] = srcUB[RCOMP]; - srcUB += 3; - } - } -#else - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[BCOMP]); - dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); - dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[RCOMP]); - src += 3; - } -#endif - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_bgr888(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_BGR888); - ASSERT(texelBytes == 3); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && - srcType == GL_UNSIGNED_BYTE && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - srcFormat == GL_RGBA && - srcType == GL_UNSIGNED_BYTE) { - /* extract BGR from RGBA */ - int img, row, col; - for (img = 0; img < srcDepth; img++) { - const GLint srcRowStride = - _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); - GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP]; - dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP]; - dstRow[col * 3 + 2] = srcRow[col * 4 + BCOMP]; - } - dstRow += dstRowStride; - srcRow += srcRowStride; - } - } - } - else if (!ctx->_ImageTransferState && - srcType == GL_UNSIGNED_BYTE && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - dstmap[0] = 0; - dstmap[1] = 1; - dstmap[2] = 2; - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 3, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = (const GLchan *) tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]); - dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); - dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]); - src += 3; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_argb4444(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_ARGB4444 || - dstFormat == MESA_FORMAT_ARGB4444_REV); - ASSERT(texelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_ARGB4444 && - baseInternalFormat == GL_RGBA && - srcFormat == GL_BGRA && - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - if (dstFormat == MESA_FORMAT_ARGB4444) { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[ACOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_4444_REV( CHAN_TO_UBYTE(src[ACOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - -static GLboolean -_mesa_texstore_rgba5551(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA5551); - ASSERT(texelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_RGBA5551 && - baseInternalFormat == GL_RGBA && - srcFormat == GL_RGBA && - srcType == GL_UNSIGNED_SHORT_5_5_5_1) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src =tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_5551( CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]), - CHAN_TO_UBYTE(src[ACOMP]) ); - src += 4; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - -static GLboolean -_mesa_texstore_argb1555(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_ARGB1555 || - dstFormat == MESA_FORMAT_ARGB1555_REV); - ASSERT(texelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_ARGB1555 && - baseInternalFormat == GL_RGBA && - srcFormat == GL_BGRA && - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src =tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - if (dstFormat == MESA_FORMAT_ARGB1555) { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_1555( CHAN_TO_UBYTE(src[ACOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_1555_REV( CHAN_TO_UBYTE(src[ACOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_argb2101010(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_ARGB2101010); - ASSERT(texelBytes == 4); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_ARGB2101010 && - srcFormat == GL_BGRA && - srcType == GL_UNSIGNED_INT_2_10_10_10_REV && - baseInternalFormat == GL_RGBA) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - if (baseInternalFormat == GL_RGBA) { - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - for (col = 0; col < srcWidth; col++) { - GLushort a,r,g,b; - - UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]); - UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]); - dstUI[col] = PACK_COLOR_2101010_US(a, r, g, b); - src += 4; - } - dstRow += dstRowStride; - } - } else if (baseInternalFormat == GL_RGB) { - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - for (col = 0; col < srcWidth; col++) { - GLushort r,g,b; - - UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]); - UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]); - dstUI[col] = PACK_COLOR_2101010_US(0xffff, r, g, b); - src += 4; - } - dstRow += dstRowStride; - } - } else { - ASSERT(0); - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Do texstore for 2-channel, 4-bit/channel, unsigned normalized formats. - */ -static GLboolean -_mesa_texstore_unorm44(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_AL44); - ASSERT(texelBytes == 1); - - { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLubyte *dstUS = (GLubyte *) dstRow; - for (col = 0; col < srcWidth; col++) { - /* src[0] is luminance, src[1] is alpha */ - dstUS[col] = PACK_COLOR_44( CHAN_TO_UBYTE(src[1]), - CHAN_TO_UBYTE(src[0]) ); - src += 2; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Do texstore for 2-channel, 8-bit/channel, unsigned normalized formats. - */ -static GLboolean -_mesa_texstore_unorm88(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_AL88 || - dstFormat == MESA_FORMAT_AL88_REV || - dstFormat == MESA_FORMAT_RG88 || - dstFormat == MESA_FORMAT_RG88_REV); - ASSERT(texelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_AL88 || dstFormat == MESA_FORMAT_RG88) && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_BYTE && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - littleEndian && - srcType == GL_UNSIGNED_BYTE && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if (dstFormat == MESA_FORMAT_AL88 || dstFormat == MESA_FORMAT_AL88_REV) { - if ((littleEndian && dstFormat == MESA_FORMAT_AL88) || - (!littleEndian && dstFormat == MESA_FORMAT_AL88_REV)) { - dstmap[0] = 0; - dstmap[1] = 3; - } - else { - dstmap[0] = 3; - dstmap[1] = 0; - } - } - else { - if ((littleEndian && dstFormat == MESA_FORMAT_RG88) || - (!littleEndian && dstFormat == MESA_FORMAT_RG88_REV)) { - dstmap[0] = 0; - dstmap[1] = 1; - } - else { - dstmap[0] = 1; - dstmap[1] = 0; - } - } - dstmap[2] = ZERO; /* ? */ - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 2, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - if (dstFormat == MESA_FORMAT_AL88 || - dstFormat == MESA_FORMAT_RG88) { - for (col = 0; col < srcWidth; col++) { - /* src[0] is luminance, src[1] is alpha */ - dstUS[col] = PACK_COLOR_88( CHAN_TO_UBYTE(src[1]), - CHAN_TO_UBYTE(src[0]) ); - src += 2; - } - } - else { - for (col = 0; col < srcWidth; col++) { - /* src[0] is luminance, src[1] is alpha */ - dstUS[col] = PACK_COLOR_88_REV( CHAN_TO_UBYTE(src[1]), - CHAN_TO_UBYTE(src[0]) ); - src += 2; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Do texstore for 2-channel, 16-bit/channel, unsigned normalized formats. - */ -static GLboolean -_mesa_texstore_unorm1616(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_AL1616 || - dstFormat == MESA_FORMAT_AL1616_REV || - dstFormat == MESA_FORMAT_RG1616 || - dstFormat == MESA_FORMAT_RG1616_REV); - ASSERT(texelBytes == 4); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - (dstFormat == MESA_FORMAT_AL1616 || dstFormat == MESA_FORMAT_RG1616) && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_SHORT && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - if (dstFormat == MESA_FORMAT_AL1616 || - dstFormat == MESA_FORMAT_RG1616) { - for (col = 0; col < srcWidth; col++) { - GLushort l, a; - - UNCLAMPED_FLOAT_TO_USHORT(l, src[0]); - UNCLAMPED_FLOAT_TO_USHORT(a, src[1]); - dstUI[col] = PACK_COLOR_1616(a, l); - src += 2; - } - } - else { - for (col = 0; col < srcWidth; col++) { - GLushort l, a; - - UNCLAMPED_FLOAT_TO_USHORT(l, src[0]); - UNCLAMPED_FLOAT_TO_USHORT(a, src[1]); - dstUI[col] = PACK_COLOR_1616_REV(a, l); - src += 2; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* Texstore for R16, A16, L16, I16. */ -static GLboolean -_mesa_texstore_unorm16(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_R16 || - dstFormat == MESA_FORMAT_A16 || - dstFormat == MESA_FORMAT_L16 || - dstFormat == MESA_FORMAT_I16); - ASSERT(texelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_SHORT && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - GLushort r; - - UNCLAMPED_FLOAT_TO_USHORT(r, src[0]); - dstUS[col] = r; - src += 1; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_rgba_16(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_16); - ASSERT(texelBytes == 8); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGBA && - srcFormat == GL_RGBA && - srcType == GL_UNSIGNED_SHORT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - GLushort r, g, b, a; - - UNCLAMPED_FLOAT_TO_USHORT(r, src[0]); - UNCLAMPED_FLOAT_TO_USHORT(g, src[1]); - UNCLAMPED_FLOAT_TO_USHORT(b, src[2]); - UNCLAMPED_FLOAT_TO_USHORT(a, src[3]); - dstUS[col*4+0] = r; - dstUS[col*4+1] = g; - dstUS[col*4+2] = b; - dstUS[col*4+3] = a; - src += 4; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_SIGNED_R_16 || - dstFormat == MESA_FORMAT_SIGNED_RG_16 || - dstFormat == MESA_FORMAT_SIGNED_RGB_16 || - dstFormat == MESA_FORMAT_SIGNED_RGBA_16); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGBA && - dstFormat == MESA_FORMAT_SIGNED_RGBA_16 && - srcFormat == GL_RGBA && - srcType == GL_SHORT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *src = tempImage; - const GLuint comps = _mesa_get_format_bytes(dstFormat) / 2; - GLint img, row, col; - - if (!tempImage) - return GL_FALSE; - - /* Note: tempImage is always float[4] / RGBA. We convert to 1, 2, - * 3 or 4 components/pixel here. - */ - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLshort *dstRowS = (GLshort *) dstRow; - for (col = 0; col < srcWidth; col++) { - GLuint c; - for (c = 0; c < comps; c++) { - GLshort p; - UNCLAMPED_FLOAT_TO_SHORT(p, src[col * 4 + c]); - dstRowS[col * comps + c] = p; - } - } - dstRow += dstRowStride; - src += 4 * srcWidth; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -static GLboolean -_mesa_texstore_rgb332(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGB332); - ASSERT(texelBytes == 1); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col] = PACK_COLOR_332( CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 3; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8. - */ -static GLboolean -_mesa_texstore_a8(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_A8 || - dstFormat == MESA_FORMAT_L8 || - dstFormat == MESA_FORMAT_I8 || - dstFormat == MESA_FORMAT_R8); - ASSERT(texelBytes == 1); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_BYTE) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - srcType == GL_UNSIGNED_BYTE && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if (dstFormat == MESA_FORMAT_A8) { - dstmap[0] = 3; - } - else { - dstmap[0] = 0; - } - dstmap[1] = ZERO; /* ? */ - dstmap[2] = ZERO; /* ? */ - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 1, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking); - const GLchan *src = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - for (col = 0; col < srcWidth; col++) { - dstRow[col] = CHAN_TO_UBYTE(src[col]); - } - dstRow += dstRowStride; - src += srcWidth; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - - -static GLboolean -_mesa_texstore_ci8(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - - (void) dims; (void) baseInternalFormat; - ASSERT(dstFormat == MESA_FORMAT_CI8); - ASSERT(texelBytes == 1); - ASSERT(baseInternalFormat == GL_COLOR_INDEX); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - srcFormat == GL_COLOR_INDEX && - srcType == GL_UNSIGNED_BYTE) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - const GLvoid *src = _mesa_image_address(dims, srcPacking, - srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); - _mesa_unpack_index_span(ctx, srcWidth, GL_UNSIGNED_BYTE, dstRow, - srcType, src, srcPacking, - ctx->_ImageTransferState); - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - - -/** - * Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_REV. - */ -static GLboolean -_mesa_texstore_ycbcr(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - - (void) ctx; (void) dims; (void) baseInternalFormat; - - ASSERT((dstFormat == MESA_FORMAT_YCBCR) || - (dstFormat == MESA_FORMAT_YCBCR_REV)); - ASSERT(texelBytes == 2); - ASSERT(ctx->Extensions.MESA_ycbcr_texture); - ASSERT(srcFormat == GL_YCBCR_MESA); - ASSERT((srcType == GL_UNSIGNED_SHORT_8_8_MESA) || - (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA)); - ASSERT(baseInternalFormat == GL_YCBCR_MESA); - - /* always just memcpy since no pixel transfer ops apply */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - - /* Check if we need byte swapping */ - /* XXX the logic here _might_ be wrong */ - if (srcPacking->SwapBytes ^ - (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA) ^ - (dstFormat == MESA_FORMAT_YCBCR_REV) ^ - !littleEndian) { - GLint img, row; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - _mesa_swap2((GLushort *) dstRow, srcWidth); - dstRow += dstRowStride; - } - } - } - return GL_TRUE; -} - -static GLboolean -_mesa_texstore_dudv8(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_DUDV8); - ASSERT(texelBytes == 2); - ASSERT(ctx->Extensions.ATI_envmap_bumpmap); - ASSERT((srcFormat == GL_DU8DV8_ATI) || - (srcFormat == GL_DUDV_ATI)); - ASSERT(baseInternalFormat == GL_DUDV_ATI); - - if (!srcPacking->SwapBytes && srcType == GL_BYTE && - littleEndian) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (srcType == GL_BYTE) { - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if (littleEndian) { - dstmap[0] = 0; - dstmap[1] = 3; - } - else { - dstmap[0] = 3; - dstmap[1] = 0; - } - dstmap[2] = ZERO; /* ? */ - dstmap[3] = ONE; /* ? */ - - _mesa_swizzle_ubyte_image(ctx, dims, - GL_LUMINANCE_ALPHA, /* hack */ - GL_UNSIGNED_BYTE, /* hack */ - GL_LUMINANCE_ALPHA, /* hack */ - dstmap, 2, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path - note this is defined for 2d textures only */ - const GLint components = _mesa_components_in_format(baseInternalFormat); - const GLint srcStride = _mesa_image_row_stride(srcPacking, srcWidth, - srcFormat, srcType); - GLbyte *tempImage, *dst, *src; - GLint row; - - tempImage = (GLbyte *) malloc(srcWidth * srcHeight * srcDepth - * components * sizeof(GLbyte)); - if (!tempImage) - return GL_FALSE; - - src = (GLbyte *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - 0, 0, 0); - - dst = tempImage; - for (row = 0; row < srcHeight; row++) { - _mesa_unpack_dudv_span_byte(ctx, srcWidth, baseInternalFormat, - dst, srcFormat, srcType, src, - srcPacking, 0); - dst += srcWidth * components; - src += srcStride; - } - - src = tempImage; - dst = (GLbyte *) dstAddr - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - memcpy(dst, src, srcWidth * texelBytes); - dst += dstRowStride; - src += srcWidth * texelBytes; - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Store a texture in MESA_FORMAT_SIGNED_R8 format. - */ -static GLboolean -_mesa_texstore_signed_r8(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_SIGNED_R8); - ASSERT(texelBytes == 1); - - /* XXX look at adding optimized paths */ - { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *srcRow = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLubyte *dstB = (GLubyte *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstB[col] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]); - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Store a texture in MESA_FORMAT_SIGNED_RG88 format. - */ -static GLboolean -_mesa_texstore_signed_rg88(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG88); - ASSERT(texelBytes == 1); - - /* XXX look at adding optimized paths */ - { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *srcRow = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstUS = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_88(FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[GCOMP])); - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Store a texture in MESA_FORMAT_SIGNED_RGBX8888. - */ -static GLboolean -_mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBX8888); - ASSERT(texelBytes == 4); - - { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *srcRow = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), - 0xff ); - srcRow += 4; - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - - -/** - * Store a texture in MESA_FORMAT_SIGNED_RGBA8888 or - * MESA_FORMAT_SIGNED_RGBA8888_REV - */ -static GLboolean -_mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS) -{ - const GLboolean littleEndian = _mesa_little_endian(); - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBA8888 || - dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV); - ASSERT(texelBytes == 4); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_SIGNED_RGBA8888 && - baseInternalFormat == GL_RGBA && - ((srcFormat == GL_RGBA && srcType == GL_BYTE && !littleEndian) || - (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && littleEndian))) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV && - baseInternalFormat == GL_RGBA && - ((srcFormat == GL_RGBA && srcType == GL_BYTE && littleEndian) || - (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && !littleEndian))) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - (srcType == GL_BYTE) && - can_swizzle(baseInternalFormat) && - can_swizzle(srcFormat)) { - - GLubyte dstmap[4]; - - /* dstmap - how to swizzle from RGBA to dst format: - */ - if ((littleEndian && dstFormat == MESA_FORMAT_SIGNED_RGBA8888) || - (!littleEndian && dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV)) { - dstmap[3] = 0; - dstmap[2] = 1; - dstmap[1] = 2; - dstmap[0] = 3; - } - else { - dstmap[3] = 3; - dstmap[2] = 2; - dstmap[1] = 1; - dstmap[0] = 0; - } - - _mesa_swizzle_ubyte_image(ctx, dims, - srcFormat, - srcType, - baseInternalFormat, - dstmap, 4, - dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcAddr, - srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *srcRow = tempImage; - GLint img, row, col; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *dstUI = (GLuint *) dstRow; - if (dstFormat == MESA_FORMAT_SIGNED_RGBA8888) { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[ACOMP]) ); - srcRow += 4; - } - } - else { - for (col = 0; col < srcWidth; col++) { - dstUI[col] = PACK_COLOR_8888_REV( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), - FLOAT_TO_BYTE_TEX(srcRow[ACOMP]) ); - srcRow += 4; - } - } - dstRow += dstRowStride; - } - } - free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Store a combined depth/stencil texture image. - */ -static GLboolean -_mesa_texstore_z24_s8(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffffff; - const GLint srcRowStride - = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) - / sizeof(GLuint); - GLint img, row; - - ASSERT(dstFormat == MESA_FORMAT_Z24_S8); - ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT); - ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT); - - if (srcFormat != GL_DEPTH_COMPONENT && ctx->Pixel.DepthScale == 1.0f && - ctx->Pixel.DepthBias == 0.0f && - !srcPacking->SwapBytes) { - /* simple path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (srcFormat == GL_DEPTH_COMPONENT) { - /* In case we only upload depth we need to preserve the stencil */ - for (img = 0; img < srcDepth; img++) { - GLuint *dstRow = (GLuint *) dstAddr - + dstImageOffsets[dstZoffset + img] - + dstYoffset * dstRowStride / sizeof(GLuint) - + dstXoffset; - const GLuint *src - = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - GLuint depth[MAX_WIDTH]; - GLubyte stencil[MAX_WIDTH]; - GLint i; - GLboolean keepdepth = GL_FALSE, keepstencil = GL_FALSE; - - if (srcFormat == GL_DEPTH_COMPONENT) { /* preserve stencil */ - keepstencil = GL_TRUE; - } - else if (srcFormat == GL_STENCIL_INDEX) { /* preserve depth */ - keepdepth = GL_TRUE; - } - - if (keepdepth == GL_FALSE) - /* the 24 depth bits will be in the low position: */ - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_INT, /* dst type */ - keepstencil ? depth : dstRow, /* dst addr */ - depthScale, - srcType, src, srcPacking); - - if (keepstencil == GL_FALSE) - /* get the 8-bit stencil values */ - _mesa_unpack_stencil_span(ctx, srcWidth, - GL_UNSIGNED_BYTE, /* dst type */ - stencil, /* dst addr */ - srcType, src, srcPacking, - ctx->_ImageTransferState); - - for (i = 0; i < srcWidth; i++) { - if (keepstencil) - dstRow[i] = depth[i] << 8 | (dstRow[i] & 0x000000FF); - else - dstRow[i] = (dstRow[i] & 0xFFFFFF00) | (stencil[i] & 0xFF); - } - - src += srcRowStride; - dstRow += dstRowStride / sizeof(GLuint); - } - } - } - return GL_TRUE; -} - - -/** - * Store a combined depth/stencil texture image. - */ -static GLboolean -_mesa_texstore_s8_z24(TEXSTORE_PARAMS) -{ - const GLuint depthScale = 0xffffff; - const GLint srcRowStride - = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) - / sizeof(GLuint); - GLint img, row; - - ASSERT(dstFormat == MESA_FORMAT_S8_Z24); - ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || - srcFormat == GL_DEPTH_COMPONENT || - srcFormat == GL_STENCIL_INDEX); - ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || - srcType == GL_UNSIGNED_INT_24_8_EXT); - - for (img = 0; img < srcDepth; img++) { - GLuint *dstRow = (GLuint *) dstAddr - + dstImageOffsets[dstZoffset + img] - + dstYoffset * dstRowStride / sizeof(GLuint) - + dstXoffset; - const GLuint *src - = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - GLuint depth[MAX_WIDTH]; - GLubyte stencil[MAX_WIDTH]; - GLint i; - GLboolean keepdepth = GL_FALSE, keepstencil = GL_FALSE; - - if (srcFormat == GL_DEPTH_COMPONENT) { /* preserve stencil */ - keepstencil = GL_TRUE; - } - else if (srcFormat == GL_STENCIL_INDEX) { /* preserve depth */ - keepdepth = GL_TRUE; - } - - if (keepdepth == GL_FALSE) - /* the 24 depth bits will be in the low position: */ - _mesa_unpack_depth_span(ctx, srcWidth, - GL_UNSIGNED_INT, /* dst type */ - keepstencil ? depth : dstRow, /* dst addr */ - depthScale, - srcType, src, srcPacking); - - if (keepstencil == GL_FALSE) - /* get the 8-bit stencil values */ - _mesa_unpack_stencil_span(ctx, srcWidth, - GL_UNSIGNED_BYTE, /* dst type */ - stencil, /* dst addr */ - srcType, src, srcPacking, - ctx->_ImageTransferState); - - /* merge stencil values into depth values */ - for (i = 0; i < srcWidth; i++) { - if (keepstencil) - dstRow[i] = depth[i] | (dstRow[i] & 0xFF000000); - else - dstRow[i] = (dstRow[i] & 0xFFFFFF) | (stencil[i] << 24); - - } - src += srcRowStride; - dstRow += dstRowStride / sizeof(GLuint); - } - } - return GL_TRUE; -} - - -/** - * Store simple 8-bit/value stencil texture data. - */ -static GLboolean -_mesa_texstore_s8(TEXSTORE_PARAMS) -{ - ASSERT(dstFormat == MESA_FORMAT_S8); - ASSERT(srcFormat == GL_STENCIL_INDEX); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_BYTE) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - const GLint srcRowStride - = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) - / sizeof(GLuint); - GLint img, row; - - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] - + dstYoffset * dstRowStride / sizeof(GLuint) - + dstXoffset; - const GLuint *src - = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, - srcWidth, srcHeight, - srcFormat, srcType, - img, 0, 0); - for (row = 0; row < srcHeight; row++) { - GLubyte stencil[MAX_WIDTH]; - GLint i; - - /* get the 8-bit stencil values */ - _mesa_unpack_stencil_span(ctx, srcWidth, - GL_UNSIGNED_BYTE, /* dst type */ - stencil, /* dst addr */ - srcType, src, srcPacking, - ctx->_ImageTransferState); - /* merge stencil values into depth values */ - for (i = 0; i < srcWidth; i++) - dstRow[i] = stencil[i]; - - src += srcRowStride; - dstRow += dstRowStride / sizeof(GLubyte); - } - } - - } - - return GL_TRUE; -} - - -/** - * Store an image in any of the formats: - * _mesa_texformat_rgba_float32 - * _mesa_texformat_rgb_float32 - * _mesa_texformat_alpha_float32 - * _mesa_texformat_luminance_float32 - * _mesa_texformat_luminance_alpha_float32 - * _mesa_texformat_intensity_float32 - */ -static GLboolean -_mesa_texstore_rgba_float32(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT32 || - dstFormat == MESA_FORMAT_RGB_FLOAT32 || - dstFormat == MESA_FORMAT_ALPHA_FLOAT32 || - dstFormat == MESA_FORMAT_LUMINANCE_FLOAT32 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32 || - dstFormat == MESA_FORMAT_INTENSITY_FLOAT32); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLfloat)); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_FLOAT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *srcRow = tempImage; - GLint bytesPerRow; - GLint img, row; - if (!tempImage) - return GL_FALSE; - bytesPerRow = srcWidth * components * sizeof(GLfloat); - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - memcpy(dstRow, srcRow, bytesPerRow); - dstRow += dstRowStride; - srcRow += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - - -/** - * As above, but store 16-bit floats. - */ -static GLboolean -_mesa_texstore_rgba_float16(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT16 || - dstFormat == MESA_FORMAT_RGB_FLOAT16 || - dstFormat == MESA_FORMAT_ALPHA_FLOAT16 || - dstFormat == MESA_FORMAT_LUMINANCE_FLOAT16 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16 || - dstFormat == MESA_FORMAT_INTENSITY_FLOAT16); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLhalfARB)); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_HALF_FLOAT_ARB) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, - ctx->_ImageTransferState); - const GLfloat *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLhalfARB *dstTexel = (GLhalfARB *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = _mesa_float_to_half(src[i]); - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, signed int8 */ -static GLboolean -_mesa_texstore_rgba_int8(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_INT8); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLbyte)); - - /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply - * to integer formats. - */ - if (!srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_BYTE) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, 0x0); - const GLfloat *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLbyte *dstTexel = (GLbyte *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLbyte) src[i]; - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, signed int16 */ -static GLboolean -_mesa_texstore_rgba_int16(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_INT16); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLshort)); - - /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply - * to integer formats. - */ - if (!srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_SHORT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, 0x0); - const GLfloat *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLshort *dstTexel = (GLshort *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLint) src[i]; - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, signed int32 */ -static GLboolean -_mesa_texstore_rgba_int32(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_INT32); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLint)); - - /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply - * to integer formats. - */ - if (!srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_INT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLfloat *tempImage = make_temp_float_image(ctx, dims, - baseInternalFormat, - baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, - srcPacking, 0x0); - const GLfloat *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLint *dstTexel = (GLint *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLint) src[i]; - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, unsigned int8 */ -static GLboolean -_mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT8); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLubyte)); - - /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply - * to integer formats. - */ - if (!srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_BYTE) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLuint *tempImage = - make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, srcPacking); - const GLuint *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLubyte *dstTexel = (GLubyte *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLubyte) CLAMP(src[i], 0, 0xff); - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, unsigned int16 */ -static GLboolean -_mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT16); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLushort)); - - /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply - * to integer formats. - */ - if (!srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_SHORT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLuint *tempImage = - make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, srcPacking); - const GLuint *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLushort *dstTexel = (GLushort *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLushort) CLAMP(src[i], 0, 0xffff); - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - -/* non-normalized, unsigned int32 */ -static GLboolean -_mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) -{ - const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT32); - ASSERT(baseInternalFormat == GL_RGBA || - baseInternalFormat == GL_RGB || - baseInternalFormat == GL_ALPHA || - baseInternalFormat == GL_LUMINANCE || - baseInternalFormat == GL_LUMINANCE_ALPHA || - baseInternalFormat == GL_INTENSITY); - ASSERT(texelBytes == components * sizeof(GLuint)); - - /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply - * to integer formats. - */ - if (!srcPacking->SwapBytes && - baseInternalFormat == srcFormat && - srcType == GL_UNSIGNED_INT) { - /* simple memcpy path */ - memcpy_texture(ctx, dims, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, - dstImageOffsets, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLuint *tempImage = - make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, srcPacking); - const GLuint *src = tempImage; - GLint img, row; - if (!tempImage) - return GL_FALSE; - for (img = 0; img < srcDepth; img++) { - GLubyte *dstRow = (GLubyte *) dstAddr - + dstImageOffsets[dstZoffset + img] * texelBytes - + dstYoffset * dstRowStride - + dstXoffset * texelBytes; - for (row = 0; row < srcHeight; row++) { - GLuint *dstTexel = (GLuint *) dstRow; - GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = src[i]; - } - dstRow += dstRowStride; - src += srcWidth * components; - } - } - - free((void *) tempImage); - } - return GL_TRUE; -} - - - - -#if FEATURE_EXT_texture_sRGB -static GLboolean -_mesa_texstore_srgb8(TEXSTORE_PARAMS) -{ - gl_format newDstFormat; - GLboolean k; - - ASSERT(dstFormat == MESA_FORMAT_SRGB8); - - /* reuse normal rgb texstore code */ - newDstFormat = MESA_FORMAT_RGB888; - - k = _mesa_texstore_rgb888(ctx, dims, baseInternalFormat, - newDstFormat, dstAddr, - dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, srcPacking); - return k; -} - - -static GLboolean -_mesa_texstore_srgba8(TEXSTORE_PARAMS) -{ - gl_format newDstFormat; - GLboolean k; - - ASSERT(dstFormat == MESA_FORMAT_SRGBA8); - - /* reuse normal rgba texstore code */ - newDstFormat = MESA_FORMAT_RGBA8888; - k = _mesa_texstore_rgba8888(ctx, dims, baseInternalFormat, - newDstFormat, dstAddr, - dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, srcPacking); - return k; -} - - -static GLboolean -_mesa_texstore_sargb8(TEXSTORE_PARAMS) -{ - gl_format newDstFormat; - GLboolean k; - - ASSERT(dstFormat == MESA_FORMAT_SARGB8); - - /* reuse normal rgba texstore code */ - newDstFormat = MESA_FORMAT_ARGB8888; - - k = _mesa_texstore_argb8888(ctx, dims, baseInternalFormat, - newDstFormat, dstAddr, - dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, srcPacking); - return k; -} - - -static GLboolean -_mesa_texstore_sl8(TEXSTORE_PARAMS) -{ - gl_format newDstFormat; - GLboolean k; - - ASSERT(dstFormat == MESA_FORMAT_SL8); - - newDstFormat = MESA_FORMAT_L8; - - /* _mesa_textore_a8 handles luminance8 too */ - k = _mesa_texstore_a8(ctx, dims, baseInternalFormat, - newDstFormat, dstAddr, - dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, srcPacking); - return k; -} - - -static GLboolean -_mesa_texstore_sla8(TEXSTORE_PARAMS) -{ - gl_format newDstFormat; - GLboolean k; - - ASSERT(dstFormat == MESA_FORMAT_SLA8); - - /* reuse normal luminance/alpha texstore code */ - newDstFormat = MESA_FORMAT_AL88; - - k = _mesa_texstore_unorm88(ctx, dims, baseInternalFormat, - newDstFormat, dstAddr, - dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, - srcAddr, srcPacking); - return k; -} - -#else - -/* these are used only in texstore_funcs[] below */ -#define _mesa_texstore_srgb8 NULL -#define _mesa_texstore_srgba8 NULL -#define _mesa_texstore_sargb8 NULL -#define _mesa_texstore_sl8 NULL -#define _mesa_texstore_sla8 NULL - -#endif /* FEATURE_EXT_texture_sRGB */ - - - - -/** - * Table mapping MESA_FORMAT_* to _mesa_texstore_*() - * XXX this is somewhat temporary. - */ -static const struct { - gl_format Name; - StoreTexImageFunc Store; -} -texstore_funcs[MESA_FORMAT_COUNT] = -{ - { MESA_FORMAT_NONE, NULL }, - { MESA_FORMAT_RGBA8888, _mesa_texstore_rgba8888 }, - { MESA_FORMAT_RGBA8888_REV, _mesa_texstore_rgba8888 }, - { MESA_FORMAT_ARGB8888, _mesa_texstore_argb8888 }, - { MESA_FORMAT_ARGB8888_REV, _mesa_texstore_argb8888 }, - { MESA_FORMAT_XRGB8888, _mesa_texstore_argb8888 }, - { MESA_FORMAT_XRGB8888_REV, _mesa_texstore_argb8888 }, - { MESA_FORMAT_RGB888, _mesa_texstore_rgb888 }, - { MESA_FORMAT_BGR888, _mesa_texstore_bgr888 }, - { MESA_FORMAT_RGB565, _mesa_texstore_rgb565 }, - { MESA_FORMAT_RGB565_REV, _mesa_texstore_rgb565 }, - { MESA_FORMAT_ARGB4444, _mesa_texstore_argb4444 }, - { MESA_FORMAT_ARGB4444_REV, _mesa_texstore_argb4444 }, - { MESA_FORMAT_RGBA5551, _mesa_texstore_rgba5551 }, - { MESA_FORMAT_ARGB1555, _mesa_texstore_argb1555 }, - { MESA_FORMAT_ARGB1555_REV, _mesa_texstore_argb1555 }, - { MESA_FORMAT_AL44, _mesa_texstore_unorm44 }, - { MESA_FORMAT_AL88, _mesa_texstore_unorm88 }, - { MESA_FORMAT_AL88_REV, _mesa_texstore_unorm88 }, - { MESA_FORMAT_AL1616, _mesa_texstore_unorm1616 }, - { MESA_FORMAT_AL1616_REV, _mesa_texstore_unorm1616 }, - { MESA_FORMAT_RGB332, _mesa_texstore_rgb332 }, - { MESA_FORMAT_A8, _mesa_texstore_a8 }, - { MESA_FORMAT_A16, _mesa_texstore_unorm16 }, - { MESA_FORMAT_L8, _mesa_texstore_a8 }, - { MESA_FORMAT_L16, _mesa_texstore_unorm16 }, - { MESA_FORMAT_I8, _mesa_texstore_a8 }, - { MESA_FORMAT_I16, _mesa_texstore_unorm16 }, - { MESA_FORMAT_CI8, _mesa_texstore_ci8 }, - { MESA_FORMAT_YCBCR, _mesa_texstore_ycbcr }, - { MESA_FORMAT_YCBCR_REV, _mesa_texstore_ycbcr }, - { MESA_FORMAT_R8, _mesa_texstore_a8 }, - { MESA_FORMAT_RG88, _mesa_texstore_unorm88 }, - { MESA_FORMAT_RG88_REV, _mesa_texstore_unorm88 }, - { MESA_FORMAT_R16, _mesa_texstore_unorm16 }, - { MESA_FORMAT_RG1616, _mesa_texstore_unorm1616 }, - { MESA_FORMAT_RG1616_REV, _mesa_texstore_unorm1616 }, - { MESA_FORMAT_ARGB2101010, _mesa_texstore_argb2101010 }, - { MESA_FORMAT_Z24_S8, _mesa_texstore_z24_s8 }, - { MESA_FORMAT_S8_Z24, _mesa_texstore_s8_z24 }, - { MESA_FORMAT_Z16, _mesa_texstore_z16 }, - { MESA_FORMAT_X8_Z24, _mesa_texstore_x8_z24 }, - { MESA_FORMAT_Z24_X8, _mesa_texstore_z24_x8 }, - { MESA_FORMAT_Z32, _mesa_texstore_z32 }, - { MESA_FORMAT_S8, _mesa_texstore_s8 }, - { MESA_FORMAT_SRGB8, _mesa_texstore_srgb8 }, - { MESA_FORMAT_SRGBA8, _mesa_texstore_srgba8 }, - { MESA_FORMAT_SARGB8, _mesa_texstore_sargb8 }, - { MESA_FORMAT_SL8, _mesa_texstore_sl8 }, - { MESA_FORMAT_SLA8, _mesa_texstore_sla8 }, - { MESA_FORMAT_SRGB_DXT1, _mesa_texstore_rgb_dxt1 }, - { MESA_FORMAT_SRGBA_DXT1, _mesa_texstore_rgba_dxt1 }, - { MESA_FORMAT_SRGBA_DXT3, _mesa_texstore_rgba_dxt3 }, - { MESA_FORMAT_SRGBA_DXT5, _mesa_texstore_rgba_dxt5 }, - { MESA_FORMAT_RGB_FXT1, _mesa_texstore_rgb_fxt1 }, - { MESA_FORMAT_RGBA_FXT1, _mesa_texstore_rgba_fxt1 }, - { MESA_FORMAT_RGB_DXT1, _mesa_texstore_rgb_dxt1 }, - { MESA_FORMAT_RGBA_DXT1, _mesa_texstore_rgba_dxt1 }, - { MESA_FORMAT_RGBA_DXT3, _mesa_texstore_rgba_dxt3 }, - { MESA_FORMAT_RGBA_DXT5, _mesa_texstore_rgba_dxt5 }, - { MESA_FORMAT_RGBA_FLOAT32, _mesa_texstore_rgba_float32 }, - { MESA_FORMAT_RGBA_FLOAT16, _mesa_texstore_rgba_float16 }, - { MESA_FORMAT_RGB_FLOAT32, _mesa_texstore_rgba_float32 }, - { MESA_FORMAT_RGB_FLOAT16, _mesa_texstore_rgba_float16 }, - { MESA_FORMAT_ALPHA_FLOAT32, _mesa_texstore_rgba_float32 }, - { MESA_FORMAT_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 }, - { MESA_FORMAT_LUMINANCE_FLOAT32, _mesa_texstore_rgba_float32 }, - { MESA_FORMAT_LUMINANCE_FLOAT16, _mesa_texstore_rgba_float16 }, - { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, _mesa_texstore_rgba_float32 }, - { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 }, - { MESA_FORMAT_INTENSITY_FLOAT32, _mesa_texstore_rgba_float32 }, - { MESA_FORMAT_INTENSITY_FLOAT16, _mesa_texstore_rgba_float16 }, - - { MESA_FORMAT_RGBA_INT8, _mesa_texstore_rgba_int8 }, - { MESA_FORMAT_RGBA_INT16, _mesa_texstore_rgba_int16 }, - { MESA_FORMAT_RGBA_INT32, _mesa_texstore_rgba_int32 }, - { MESA_FORMAT_RGBA_UINT8, _mesa_texstore_rgba_uint8 }, - { MESA_FORMAT_RGBA_UINT16, _mesa_texstore_rgba_uint16 }, - { MESA_FORMAT_RGBA_UINT32, _mesa_texstore_rgba_uint32 }, - - { MESA_FORMAT_DUDV8, _mesa_texstore_dudv8 }, - - { MESA_FORMAT_SIGNED_R8, _mesa_texstore_signed_r8 }, - { MESA_FORMAT_SIGNED_RG88, _mesa_texstore_signed_rg88 }, - { MESA_FORMAT_SIGNED_RGBX8888, _mesa_texstore_signed_rgbx8888 }, - - { MESA_FORMAT_SIGNED_RGBA8888, _mesa_texstore_signed_rgba8888 }, - { MESA_FORMAT_SIGNED_RGBA8888_REV, _mesa_texstore_signed_rgba8888 }, - - { MESA_FORMAT_SIGNED_R_16, _mesa_texstore_signed_rgba_16 }, - { MESA_FORMAT_SIGNED_RG_16, _mesa_texstore_signed_rgba_16 }, - { MESA_FORMAT_SIGNED_RGB_16, _mesa_texstore_signed_rgba_16 }, - { MESA_FORMAT_SIGNED_RGBA_16, _mesa_texstore_signed_rgba_16 }, - { MESA_FORMAT_RGBA_16, _mesa_texstore_rgba_16 } -}; - - -static GLboolean -_mesa_texstore_null(TEXSTORE_PARAMS) -{ - (void) ctx; (void) dims; - (void) baseInternalFormat; - (void) dstFormat; - (void) dstAddr; - (void) dstXoffset; (void) dstYoffset; (void) dstZoffset; - (void) dstRowStride; (void) dstImageOffsets; - (void) srcWidth; (void) srcHeight; (void) srcDepth; - (void) srcFormat; (void) srcType; - (void) srcAddr; - (void) srcPacking; - - /* should never happen */ - _mesa_problem(NULL, "_mesa_texstore_null() is called"); - return GL_FALSE; -} - - -/** - * Return the StoreTexImageFunc pointer to store an image in the given format. - */ -static StoreTexImageFunc -_mesa_get_texstore_func(gl_format format) -{ -#ifdef DEBUG - GLuint i; - for (i = 0; i < MESA_FORMAT_COUNT; i++) { - ASSERT(texstore_funcs[i].Name == i); - } -#endif - ASSERT(texstore_funcs[format].Name == format); - - if (texstore_funcs[format].Store) - return texstore_funcs[format].Store; - else - return _mesa_texstore_null; -} - - -/** - * Store user data into texture memory. - * Called via glTex[Sub]Image1/2/3D() - */ -GLboolean -_mesa_texstore(TEXSTORE_PARAMS) -{ - StoreTexImageFunc storeImage; - GLboolean success; - - storeImage = _mesa_get_texstore_func(dstFormat); - - success = storeImage(ctx, dims, baseInternalFormat, - dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageOffsets, - srcWidth, srcHeight, srcDepth, - srcFormat, srcType, srcAddr, srcPacking); - return success; -} - - -/** - * Check if an unpack PBO is active prior to fetching a texture image. - * If so, do bounds checking and map the buffer into main memory. - * Any errors detected will be recorded. - * The caller _must_ call _mesa_unmap_teximage_pbo() too! - */ -const GLvoid * -_mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *unpack, - const char *funcName) -{ - GLubyte *buf; - - if (!_mesa_is_bufferobj(unpack->BufferObj)) { - /* no PBO */ - return pixels; - } - if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, - format, type, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)"); - return NULL; - } - - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, unpack->BufferObj); - if (!buf) { - _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped)"); - return NULL; - } - - return ADD_POINTERS(buf, pixels); -} - - -/** - * Check if an unpack PBO is active prior to fetching a compressed texture - * image. - * If so, do bounds checking and map the buffer into main memory. - * Any errors detected will be recorded. - * The caller _must_ call _mesa_unmap_teximage_pbo() too! - */ -const GLvoid * -_mesa_validate_pbo_compressed_teximage(struct gl_context *ctx, - GLsizei imageSize, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - const char *funcName) -{ - GLubyte *buf; - - if (!_mesa_is_bufferobj(packing->BufferObj)) { - /* not using a PBO - return pointer unchanged */ - return pixels; - } - if ((const GLubyte *) pixels + imageSize > - ((const GLubyte *) 0) + packing->BufferObj->Size) { - /* out of bounds read! */ - _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)"); - return NULL; - } - - buf = (GLubyte*) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, packing->BufferObj); - if (!buf) { - _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped"); - return NULL; - } - - return ADD_POINTERS(buf, pixels); -} - - -/** - * This function must be called after either of the validate_pbo_*_teximage() - * functions. It unmaps the PBO buffer if it was mapped earlier. - */ -void -_mesa_unmap_teximage_pbo(struct gl_context *ctx, - const struct gl_pixelstore_attrib *unpack) -{ - if (_mesa_is_bufferobj(unpack->BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - unpack->BufferObj); - } -} - - -/** Return texture size in bytes */ -static GLuint -texture_size(const struct gl_texture_image *texImage) -{ - GLuint sz = _mesa_format_image_size(texImage->TexFormat, texImage->Width, - texImage->Height, texImage->Depth); - return sz; -} - - -/** Return row stride in bytes */ -static GLuint -texture_row_stride(const struct gl_texture_image *texImage) -{ - GLuint stride = _mesa_format_row_stride(texImage->TexFormat, - texImage->Width); - return stride; -} - - - -/** - * This is the software fallback for Driver.TexImage1D() - * and Driver.CopyTexImage1D(). - * \sa _mesa_store_teximage2d() - */ -void -_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - GLuint sizeInBytes; - (void) border; - - /* allocate memory */ - sizeInBytes = texture_size(texImage); - texImage->Data = _mesa_alloc_texmemory(sizeInBytes); - if (!texImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); - return; - } - - pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, - pixels, packing, "glTexImage1D"); - if (!pixels) { - /* Note: we check for a NULL image pointer here, _after_ we allocated - * memory for the texture. That's what the GL spec calls for. - */ - return; - } - else { - const GLint dstRowStride = 0; - GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstRowStride, - texImage->ImageOffsets, - width, 1, 1, - format, type, pixels, packing); - if (!success) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); - } - } - - _mesa_unmap_teximage_pbo(ctx, packing); -} - - -/** - * This is the software fallback for Driver.TexImage2D() - * and Driver.CopyTexImage2D(). - * - * This function is oriented toward storing images in main memory, rather - * than VRAM. Device driver's can easily plug in their own replacement. - */ -void -_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - GLuint sizeInBytes; - (void) border; - - /* allocate memory */ - sizeInBytes = texture_size(texImage); - texImage->Data = _mesa_alloc_texmemory(sizeInBytes); - if (!texImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - return; - } - - pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type, - pixels, packing, "glTexImage2D"); - if (!pixels) { - /* Note: we check for a NULL image pointer here, _after_ we allocated - * memory for the texture. That's what the GL spec calls for. - */ - return; - } - else { - GLint dstRowStride = texture_row_stride(texImage); - GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstRowStride, - texImage->ImageOffsets, - width, height, 1, - format, type, pixels, packing); - if (!success) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); - } - } - - _mesa_unmap_teximage_pbo(ctx, packing); -} - - - -/** - * This is the software fallback for Driver.TexImage3D() - * and Driver.CopyTexImage3D(). - * \sa _mesa_store_teximage2d() - */ -void -_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, GLint border, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - GLuint sizeInBytes; - (void) border; - - /* allocate memory */ - sizeInBytes = texture_size(texImage); - texImage->Data = _mesa_alloc_texmemory(sizeInBytes); - if (!texImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D"); - return; - } - - pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format, - type, pixels, packing, "glTexImage3D"); - if (!pixels) { - /* Note: we check for a NULL image pointer here, _after_ we allocated - * memory for the texture. That's what the GL spec calls for. - */ - return; - } - else { - GLint dstRowStride = texture_row_stride(texImage); - GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - 0, 0, 0, /* dstX/Y/Zoffset */ - dstRowStride, - texImage->ImageOffsets, - width, height, depth, - format, type, pixels, packing); - if (!success) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D"); - } - } - - _mesa_unmap_teximage_pbo(ctx, packing); -} - - - - -/* - * This is the software fallback for Driver.TexSubImage1D() - * and Driver.CopyTexSubImage1D(). - */ -void -_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint width, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* get pointer to src pixels (may be in a pbo which we'll map here) */ - pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, - pixels, packing, "glTexSubImage1D"); - if (!pixels) - return; - - { - const GLint dstRowStride = 0; - GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - xoffset, 0, 0, /* offsets */ - dstRowStride, - texImage->ImageOffsets, - width, 1, 1, - format, type, pixels, packing); - if (!success) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D"); - } - } - - _mesa_unmap_teximage_pbo(ctx, packing); -} - - - -/** - * This is the software fallback for Driver.TexSubImage2D() - * and Driver.CopyTexSubImage2D(). - */ -void -_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint width, GLint height, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* get pointer to src pixels (may be in a pbo which we'll map here) */ - pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type, - pixels, packing, "glTexSubImage2D"); - if (!pixels) - return; - - { - GLint dstRowStride = texture_row_stride(texImage); - GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - xoffset, yoffset, 0, - dstRowStride, - texImage->ImageOffsets, - width, height, 1, - format, type, pixels, packing); - if (!success) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D"); - } - } - - _mesa_unmap_teximage_pbo(ctx, packing); -} - - -/* - * This is the software fallback for Driver.TexSubImage3D(). - * and Driver.CopyTexSubImage3D(). - */ -void -_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type, const void *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* get pointer to src pixels (may be in a pbo which we'll map here) */ - pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format, - type, pixels, packing, - "glTexSubImage3D"); - if (!pixels) - return; - - { - GLint dstRowStride = texture_row_stride(texImage); - GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, - xoffset, yoffset, zoffset, - dstRowStride, - texImage->ImageOffsets, - width, height, depth, - format, type, pixels, packing); - if (!success) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D"); - } - } - - _mesa_unmap_teximage_pbo(ctx, packing); -} - - -/* - * Fallback for Driver.CompressedTexImage1D() - */ -void -_mesa_store_compressed_teximage1d(struct gl_context *ctx, - GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* this space intentionally left blank */ - (void) ctx; - (void) target; (void) level; - (void) internalFormat; - (void) width; (void) border; - (void) imageSize; (void) data; - (void) texObj; - (void) texImage; -} - - - -/** - * Fallback for Driver.CompressedTexImage2D() - */ -void -_mesa_store_compressed_teximage2d(struct gl_context *ctx, - GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - (void) width; (void) height; (void) border; - - /* This is pretty simple, basically just do a memcpy without worrying - * about the usual image unpacking or image transfer operations. - */ - ASSERT(texObj); - ASSERT(texImage); - ASSERT(texImage->Width > 0); - ASSERT(texImage->Height > 0); - ASSERT(texImage->Depth == 1); - ASSERT(texImage->Data == NULL); /* was freed in glCompressedTexImage2DARB */ - - /* allocate storage */ - texImage->Data = _mesa_alloc_texmemory(imageSize); - if (!texImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); - return; - } - - data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data, - &ctx->Unpack, - "glCompressedTexImage2D"); - if (!data) - return; - - /* copy the data */ - memcpy(texImage->Data, data, imageSize); - - _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack); -} - - - -/* - * Fallback for Driver.CompressedTexImage3D() - */ -void -_mesa_store_compressed_teximage3d(struct gl_context *ctx, - GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, - GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* this space intentionally left blank */ - (void) ctx; - (void) target; (void) level; - (void) internalFormat; - (void) width; (void) height; (void) depth; - (void) border; - (void) imageSize; (void) data; - (void) texObj; - (void) texImage; -} - - - -/** - * Fallback for Driver.CompressedTexSubImage1D() - */ -void -_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target, - GLint level, - GLint xoffset, GLsizei width, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* there are no compressed 1D texture formats yet */ - (void) ctx; - (void) target; (void) level; - (void) xoffset; (void) width; - (void) format; - (void) imageSize; (void) data; - (void) texObj; - (void) texImage; -} - - -/** - * Fallback for Driver.CompressedTexSubImage2D() - */ -void -_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target, - GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - GLint bytesPerRow, destRowStride, srcRowStride; - GLint i, rows; - GLubyte *dest; - const GLubyte *src; - const gl_format texFormat = texImage->TexFormat; - const GLint destWidth = texImage->Width; - GLuint bw, bh; - - _mesa_get_format_block_size(texFormat, &bw, &bh); - - (void) level; - (void) format; - - /* these should have been caught sooner */ - ASSERT((width % bw) == 0 || width == 2 || width == 1); - ASSERT((height % bh) == 0 || height == 2 || height == 1); - ASSERT((xoffset % bw) == 0); - ASSERT((yoffset % bh) == 0); - - /* get pointer to src pixels (may be in a pbo which we'll map here) */ - data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data, - &ctx->Unpack, - "glCompressedTexSubImage2D"); - if (!data) - return; - - srcRowStride = _mesa_format_row_stride(texFormat, width); - src = (const GLubyte *) data; - - destRowStride = _mesa_format_row_stride(texFormat, destWidth); - dest = _mesa_compressed_image_address(xoffset, yoffset, 0, - texFormat, destWidth, - (GLubyte *) texImage->Data); - - bytesPerRow = srcRowStride; /* bytes per row of blocks */ - rows = height / bh; /* rows in blocks */ - - /* copy rows of blocks */ - for (i = 0; i < rows; i++) { - memcpy(dest, src, bytesPerRow); - dest += destRowStride; - src += srcRowStride; - } - - _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack); -} - - -/** - * Fallback for Driver.CompressedTexSubImage3D() - */ -void -_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target, - GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - /* there are no compressed 3D texture formats yet */ - (void) ctx; - (void) target; (void) level; - (void) xoffset; (void) yoffset; (void) zoffset; - (void) width; (void) height; (void) depth; - (void) format; - (void) imageSize; (void) data; - (void) texObj; - (void) texImage; -} +/* + * Mesa 3-D graphics library + * Version: 7.5 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (c) 2008-2009 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Authors: + * Brian Paul + */ + +/** + * The GL texture image functions in teximage.c basically just do + * error checking and data structure allocation. They in turn call + * device driver functions which actually copy/convert/store the user's + * texture image data. + * + * However, most device drivers will be able to use the fallback functions + * in this file. That is, most drivers will have the following bit of + * code: + * ctx->Driver.TexImage1D = _mesa_store_teximage1d; + * ctx->Driver.TexImage2D = _mesa_store_teximage2d; + * ctx->Driver.TexImage3D = _mesa_store_teximage3d; + * etc... + * + * Texture image processing is actually kind of complicated. We have to do: + * Format/type conversions + * pixel unpacking + * pixel transfer (scale, bais, lookup, etc) + * + * These functions can handle most everything, including processing full + * images and sub-images. + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "colormac.h" +#include "image.h" +#include "macros.h" +#include "mipmap.h" +#include "mfeatures.h" +#include "mtypes.h" +#include "pack.h" +#include "imports.h" +#include "pack.h" +#include "texcompress.h" +#include "texcompress_fxt1.h" +#include "texcompress_rgtc.h" +#include "texcompress_s3tc.h" +#include "teximage.h" +#include "texstore.h" +#include "enums.h" + + +enum { + ZERO = 4, + ONE = 5 +}; + + +/** + * Texture image storage function. + */ +typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS); + + +/** + * Return GL_TRUE if the given image format is one that be converted + * to another format by swizzling. + */ +static GLboolean +can_swizzle(GLenum logicalBaseFormat) +{ + switch (logicalBaseFormat) { + case GL_RGBA: + case GL_RGB: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_BGR: + case GL_BGRA: + case GL_ABGR_EXT: + case GL_RG: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + + +enum { + IDX_LUMINANCE = 0, + IDX_ALPHA, + IDX_INTENSITY, + IDX_LUMINANCE_ALPHA, + IDX_RGB, + IDX_RGBA, + IDX_RED, + IDX_GREEN, + IDX_BLUE, + IDX_BGR, + IDX_BGRA, + IDX_ABGR, + IDX_RG, + MAX_IDX +}; + +#define MAP1(x) MAP4(x, ZERO, ZERO, ZERO) +#define MAP2(x,y) MAP4(x, y, ZERO, ZERO) +#define MAP3(x,y,z) MAP4(x, y, z, ZERO) +#define MAP4(x,y,z,w) { x, y, z, w, ZERO, ONE } + + +static const struct { + GLubyte format_idx; + GLubyte to_rgba[6]; + GLubyte from_rgba[6]; +} mappings[MAX_IDX] = +{ + { + IDX_LUMINANCE, + MAP4(0,0,0,ONE), + MAP1(0) + }, + + { + IDX_ALPHA, + MAP4(ZERO, ZERO, ZERO, 0), + MAP1(3) + }, + + { + IDX_INTENSITY, + MAP4(0, 0, 0, 0), + MAP1(0), + }, + + { + IDX_LUMINANCE_ALPHA, + MAP4(0,0,0,1), + MAP2(0,3) + }, + + { + IDX_RGB, + MAP4(0,1,2,ONE), + MAP3(0,1,2) + }, + + { + IDX_RGBA, + MAP4(0,1,2,3), + MAP4(0,1,2,3), + }, + + { + IDX_RED, + MAP4(0, ZERO, ZERO, ONE), + MAP1(0), + }, + + { + IDX_GREEN, + MAP4(ZERO, 0, ZERO, ONE), + MAP1(1), + }, + + { + IDX_BLUE, + MAP4(ZERO, ZERO, 0, ONE), + MAP1(2), + }, + + { + IDX_BGR, + MAP4(2,1,0,ONE), + MAP3(2,1,0) + }, + + { + IDX_BGRA, + MAP4(2,1,0,3), + MAP4(2,1,0,3) + }, + + { + IDX_ABGR, + MAP4(3,2,1,0), + MAP4(3,2,1,0) + }, + + { + IDX_RG, + MAP4(0, 1, ZERO, ONE), + MAP2(0, 1) + }, +}; + + + +/** + * Convert a GL image format enum to an IDX_* value (see above). + */ +static int +get_map_idx(GLenum value) +{ + switch (value) { + case GL_LUMINANCE: return IDX_LUMINANCE; + case GL_ALPHA: return IDX_ALPHA; + case GL_INTENSITY: return IDX_INTENSITY; + case GL_LUMINANCE_ALPHA: return IDX_LUMINANCE_ALPHA; + case GL_RGB: return IDX_RGB; + case GL_RGBA: return IDX_RGBA; + case GL_RED: return IDX_RED; + case GL_GREEN: return IDX_GREEN; + case GL_BLUE: return IDX_BLUE; + case GL_BGR: return IDX_BGR; + case GL_BGRA: return IDX_BGRA; + case GL_ABGR_EXT: return IDX_ABGR; + case GL_RG: return IDX_RG; + default: + _mesa_problem(NULL, "Unexpected inFormat"); + return 0; + } +} + + +/** + * When promoting texture formats (see below) we need to compute the + * mapping of dest components back to source components. + * This function does that. + * \param inFormat the incoming format of the texture + * \param outFormat the final texture format + * \return map[6] a full 6-component map + */ +static void +compute_component_mapping(GLenum inFormat, GLenum outFormat, + GLubyte *map) +{ + const int inFmt = get_map_idx(inFormat); + const int outFmt = get_map_idx(outFormat); + const GLubyte *in2rgba = mappings[inFmt].to_rgba; + const GLubyte *rgba2out = mappings[outFmt].from_rgba; + int i; + + for (i = 0; i < 4; i++) + map[i] = in2rgba[rgba2out[i]]; + + map[ZERO] = ZERO; + map[ONE] = ONE; + +#if 0 + printf("from %x/%s to %x/%s map %d %d %d %d %d %d\n", + inFormat, _mesa_lookup_enum_by_nr(inFormat), + outFormat, _mesa_lookup_enum_by_nr(outFormat), + map[0], + map[1], + map[2], + map[3], + map[4], + map[5]); +#endif +} + + +/** + * Make a temporary (color) texture image with GLfloat components. + * Apply all needed pixel unpacking and pixel transfer operations. + * Note that there are both logicalBaseFormat and textureBaseFormat parameters. + * Suppose the user specifies GL_LUMINANCE as the internal texture format + * but the graphics hardware doesn't support luminance textures. So, we might + * use an RGB hardware format instead. + * If logicalBaseFormat != textureBaseFormat we have some extra work to do. + * + * \param ctx the rendering context + * \param dims image dimensions: 1, 2 or 3 + * \param logicalBaseFormat basic texture derived from the user's + * internal texture format value + * \param textureBaseFormat the actual basic format of the texture + * \param srcWidth source image width + * \param srcHeight source image height + * \param srcDepth source image depth + * \param srcFormat source image format + * \param srcType source image type + * \param srcAddr source image address + * \param srcPacking source image pixel packing + * \return resulting image with format = textureBaseFormat and type = GLfloat. + */ +GLfloat * +_mesa_make_temp_float_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps) +{ + GLfloat *tempImage; + const GLint components = _mesa_components_in_format(logicalBaseFormat); + const GLint srcStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLfloat *dst; + GLint img, row; + + ASSERT(dims >= 1 && dims <= 3); + + ASSERT(logicalBaseFormat == GL_RGBA || + logicalBaseFormat == GL_RGB || + logicalBaseFormat == GL_RG || + logicalBaseFormat == GL_RED || + logicalBaseFormat == GL_LUMINANCE_ALPHA || + logicalBaseFormat == GL_LUMINANCE || + logicalBaseFormat == GL_ALPHA || + logicalBaseFormat == GL_INTENSITY || + logicalBaseFormat == GL_COLOR_INDEX || + logicalBaseFormat == GL_DEPTH_COMPONENT); + + ASSERT(textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_RGB || + textureBaseFormat == GL_RG || + textureBaseFormat == GL_RED || + textureBaseFormat == GL_LUMINANCE_ALPHA || + textureBaseFormat == GL_LUMINANCE || + textureBaseFormat == GL_ALPHA || + textureBaseFormat == GL_INTENSITY || + textureBaseFormat == GL_COLOR_INDEX || + textureBaseFormat == GL_DEPTH_COMPONENT); + + tempImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth + * components * sizeof(GLfloat)); + if (!tempImage) + return NULL; + + dst = tempImage; + for (img = 0; img < srcDepth; img++) { + const GLubyte *src + = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + _mesa_unpack_color_span_float(ctx, srcWidth, logicalBaseFormat, + dst, srcFormat, srcType, src, + srcPacking, transferOps); + dst += srcWidth * components; + src += srcStride; + } + } + + if (logicalBaseFormat != textureBaseFormat) { + /* more work */ + GLint texComponents = _mesa_components_in_format(textureBaseFormat); + GLint logComponents = _mesa_components_in_format(logicalBaseFormat); + GLfloat *newImage; + GLint i, n; + GLubyte map[6]; + + /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ + ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_LUMINANCE_ALPHA); + + /* The actual texture format should have at least as many components + * as the logical texture format. + */ + ASSERT(texComponents >= logComponents); + + newImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth + * texComponents * sizeof(GLfloat)); + if (!newImage) { + free(tempImage); + return NULL; + } + + compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); + + n = srcWidth * srcHeight * srcDepth; + for (i = 0; i < n; i++) { + GLint k; + for (k = 0; k < texComponents; k++) { + GLint j = map[k]; + if (j == ZERO) + newImage[i * texComponents + k] = 0.0F; + else if (j == ONE) + newImage[i * texComponents + k] = 1.0F; + else + newImage[i * texComponents + k] = tempImage[i * logComponents + j]; + } + } + + free(tempImage); + tempImage = newImage; + } + + return tempImage; +} + + +/** + * Make temporary image with uint pixel values. Used for unsigned + * integer-valued textures. + */ +static GLuint * +make_temp_uint_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking) +{ + GLuint *tempImage; + const GLint components = _mesa_components_in_format(logicalBaseFormat); + const GLint srcStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLuint *dst; + GLint img, row; + + ASSERT(dims >= 1 && dims <= 3); + + ASSERT(logicalBaseFormat == GL_RGBA || + logicalBaseFormat == GL_RGB || + logicalBaseFormat == GL_RG || + logicalBaseFormat == GL_RED || + logicalBaseFormat == GL_LUMINANCE_ALPHA || + logicalBaseFormat == GL_LUMINANCE || + logicalBaseFormat == GL_INTENSITY || + logicalBaseFormat == GL_ALPHA); + + ASSERT(textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_RGB || + textureBaseFormat == GL_RG || + textureBaseFormat == GL_RED || + textureBaseFormat == GL_LUMINANCE_ALPHA || + textureBaseFormat == GL_LUMINANCE || + textureBaseFormat == GL_ALPHA); + + tempImage = (GLuint *) malloc(srcWidth * srcHeight * srcDepth + * components * sizeof(GLuint)); + if (!tempImage) + return NULL; + + dst = tempImage; + for (img = 0; img < srcDepth; img++) { + const GLubyte *src + = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + _mesa_unpack_color_span_uint(ctx, srcWidth, logicalBaseFormat, + dst, srcFormat, srcType, src, + srcPacking); + dst += srcWidth * components; + src += srcStride; + } + } + + if (logicalBaseFormat != textureBaseFormat) { + /* more work */ + GLint texComponents = _mesa_components_in_format(textureBaseFormat); + GLint logComponents = _mesa_components_in_format(logicalBaseFormat); + GLuint *newImage; + GLint i, n; + GLubyte map[6]; + + /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ + ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_LUMINANCE_ALPHA); + + /* The actual texture format should have at least as many components + * as the logical texture format. + */ + ASSERT(texComponents >= logComponents); + + newImage = (GLuint *) malloc(srcWidth * srcHeight * srcDepth + * texComponents * sizeof(GLuint)); + if (!newImage) { + free(tempImage); + return NULL; + } + + compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); + + n = srcWidth * srcHeight * srcDepth; + for (i = 0; i < n; i++) { + GLint k; + for (k = 0; k < texComponents; k++) { + GLint j = map[k]; + if (j == ZERO) + newImage[i * texComponents + k] = 0.0F; + else if (j == ONE) + newImage[i * texComponents + k] = 1.0F; + else + newImage[i * texComponents + k] = tempImage[i * logComponents + j]; + } + } + + free(tempImage); + tempImage = newImage; + } + + return tempImage; +} + + + +/** + * Make a temporary (color) texture image with GLchan components. + * Apply all needed pixel unpacking and pixel transfer operations. + * Note that there are both logicalBaseFormat and textureBaseFormat parameters. + * Suppose the user specifies GL_LUMINANCE as the internal texture format + * but the graphics hardware doesn't support luminance textures. So, we might + * use an RGB hardware format instead. + * If logicalBaseFormat != textureBaseFormat we have some extra work to do. + * + * \param ctx the rendering context + * \param dims image dimensions: 1, 2 or 3 + * \param logicalBaseFormat basic texture derived from the user's + * internal texture format value + * \param textureBaseFormat the actual basic format of the texture + * \param srcWidth source image width + * \param srcHeight source image height + * \param srcDepth source image depth + * \param srcFormat source image format + * \param srcType source image type + * \param srcAddr source image address + * \param srcPacking source image pixel packing + * \return resulting image with format = textureBaseFormat and type = GLchan. + */ +GLchan * +_mesa_make_temp_chan_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking) +{ + GLuint transferOps = ctx->_ImageTransferState; + const GLint components = _mesa_components_in_format(logicalBaseFormat); + GLint img, row; + GLchan *tempImage, *dst; + + ASSERT(dims >= 1 && dims <= 3); + + ASSERT(logicalBaseFormat == GL_RGBA || + logicalBaseFormat == GL_RGB || + logicalBaseFormat == GL_RG || + logicalBaseFormat == GL_RED || + logicalBaseFormat == GL_LUMINANCE_ALPHA || + logicalBaseFormat == GL_LUMINANCE || + logicalBaseFormat == GL_ALPHA || + logicalBaseFormat == GL_INTENSITY); + + ASSERT(textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_RGB || + textureBaseFormat == GL_RG || + textureBaseFormat == GL_RED || + textureBaseFormat == GL_LUMINANCE_ALPHA || + textureBaseFormat == GL_LUMINANCE || + textureBaseFormat == GL_ALPHA || + textureBaseFormat == GL_INTENSITY); + + /* unpack and transfer the source image */ + tempImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth + * components * sizeof(GLchan)); + if (!tempImage) { + return NULL; + } + + dst = tempImage; + for (img = 0; img < srcDepth; img++) { + const GLint srcStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + const GLubyte *src = + (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + _mesa_unpack_color_span_chan(ctx, srcWidth, logicalBaseFormat, dst, + srcFormat, srcType, src, srcPacking, + transferOps); + dst += srcWidth * components; + src += srcStride; + } + } + + if (logicalBaseFormat != textureBaseFormat) { + /* one more conversion step */ + GLint texComponents = _mesa_components_in_format(textureBaseFormat); + GLint logComponents = _mesa_components_in_format(logicalBaseFormat); + GLchan *newImage; + GLint i, n; + GLubyte map[6]; + + /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */ + ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA || + textureBaseFormat == GL_LUMINANCE_ALPHA); + + /* The actual texture format should have at least as many components + * as the logical texture format. + */ + ASSERT(texComponents >= logComponents); + + newImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth + * texComponents * sizeof(GLchan)); + if (!newImage) { + free(tempImage); + return NULL; + } + + compute_component_mapping(logicalBaseFormat, textureBaseFormat, map); + + n = srcWidth * srcHeight * srcDepth; + for (i = 0; i < n; i++) { + GLint k; + for (k = 0; k < texComponents; k++) { + GLint j = map[k]; + if (j == ZERO) + newImage[i * texComponents + k] = 0; + else if (j == ONE) + newImage[i * texComponents + k] = CHAN_MAX; + else + newImage[i * texComponents + k] = tempImage[i * logComponents + j]; + } + } + + free(tempImage); + tempImage = newImage; + } + + return tempImage; +} + + +/** + * Copy GLubyte pixels from to with swizzling. + * \param dst destination pixels + * \param dstComponents number of color components in destination pixels + * \param src source pixels + * \param srcComponents number of color components in source pixels + * \param map the swizzle mapping. map[X] says where to find the X component + * in the source image's pixels. For example, if the source image + * is GL_BGRA and X = red, map[0] yields 2. + * \param count number of pixels to copy/swizzle. + */ +static void +swizzle_copy(GLubyte *dst, GLuint dstComponents, const GLubyte *src, + GLuint srcComponents, const GLubyte *map, GLuint count) +{ +#define SWZ_CPY(dst, src, count, dstComps, srcComps) \ + do { \ + GLuint i; \ + for (i = 0; i < count; i++) { \ + GLuint j; \ + if (srcComps == 4) { \ + COPY_4UBV(tmp, src); \ + } \ + else { \ + for (j = 0; j < srcComps; j++) { \ + tmp[j] = src[j]; \ + } \ + } \ + src += srcComps; \ + for (j = 0; j < dstComps; j++) { \ + dst[j] = tmp[map[j]]; \ + } \ + dst += dstComps; \ + } \ + } while (0) + + GLubyte tmp[6]; + + tmp[ZERO] = 0x0; + tmp[ONE] = 0xff; + + ASSERT(srcComponents <= 4); + ASSERT(dstComponents <= 4); + + switch (dstComponents) { + case 4: + switch (srcComponents) { + case 4: + SWZ_CPY(dst, src, count, 4, 4); + break; + case 3: + SWZ_CPY(dst, src, count, 4, 3); + break; + case 2: + SWZ_CPY(dst, src, count, 4, 2); + break; + case 1: + SWZ_CPY(dst, src, count, 4, 1); + break; + default: + ; + } + break; + case 3: + switch (srcComponents) { + case 4: + SWZ_CPY(dst, src, count, 3, 4); + break; + case 3: + SWZ_CPY(dst, src, count, 3, 3); + break; + case 2: + SWZ_CPY(dst, src, count, 3, 2); + break; + case 1: + SWZ_CPY(dst, src, count, 3, 1); + break; + default: + ; + } + break; + case 2: + switch (srcComponents) { + case 4: + SWZ_CPY(dst, src, count, 2, 4); + break; + case 3: + SWZ_CPY(dst, src, count, 2, 3); + break; + case 2: + SWZ_CPY(dst, src, count, 2, 2); + break; + case 1: + SWZ_CPY(dst, src, count, 2, 1); + break; + default: + ; + } + break; + case 1: + switch (srcComponents) { + case 4: + SWZ_CPY(dst, src, count, 1, 4); + break; + case 3: + SWZ_CPY(dst, src, count, 1, 3); + break; + case 2: + SWZ_CPY(dst, src, count, 1, 2); + break; + case 1: + SWZ_CPY(dst, src, count, 1, 1); + break; + default: + ; + } + break; + default: + ; + } +#undef SWZ_CPY +} + + + +static const GLubyte map_identity[6] = { 0, 1, 2, 3, ZERO, ONE }; +static const GLubyte map_3210[6] = { 3, 2, 1, 0, ZERO, ONE }; + + +/** + * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a + * mapping array depending on endianness. + */ +static const GLubyte * +type_mapping( GLenum srcType ) +{ + switch (srcType) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + return map_identity; + case GL_UNSIGNED_INT_8_8_8_8: + return _mesa_little_endian() ? map_3210 : map_identity; + case GL_UNSIGNED_INT_8_8_8_8_REV: + return _mesa_little_endian() ? map_identity : map_3210; + default: + return NULL; + } +} + + +/** + * For 1-byte/pixel formats (or 8_8_8_8 packed formats), return a + * mapping array depending on pixelstore byte swapping state. + */ +static const GLubyte * +byteswap_mapping( GLboolean swapBytes, + GLenum srcType ) +{ + if (!swapBytes) + return map_identity; + + switch (srcType) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + return map_identity; + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + return map_3210; + default: + return NULL; + } +} + + + +/** + * Transfer a GLubyte texture image with component swizzling. + */ +static void +_mesa_swizzle_ubyte_image(struct gl_context *ctx, + GLuint dimensions, + GLenum srcFormat, + GLenum srcType, + + GLenum baseInternalFormat, + + const GLubyte *rgba2dst, + GLuint dstComponents, + + GLvoid *dstAddr, + GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, + GLint dstRowStride, + const GLuint *dstImageOffsets, + + GLint srcWidth, GLint srcHeight, GLint srcDepth, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking ) +{ + GLint srcComponents = _mesa_components_in_format(srcFormat); + const GLubyte *srctype2ubyte, *swap; + GLubyte map[4], src2base[6], base2rgba[6]; + GLint i; + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, + srcFormat, GL_UNSIGNED_BYTE); + const GLint srcImageStride + = _mesa_image_image_stride(srcPacking, srcWidth, srcHeight, srcFormat, + GL_UNSIGNED_BYTE); + const GLubyte *srcImage + = (const GLubyte *) _mesa_image_address(dimensions, srcPacking, srcAddr, + srcWidth, srcHeight, srcFormat, + GL_UNSIGNED_BYTE, 0, 0, 0); + + (void) ctx; + + /* Translate from src->baseInternal->GL_RGBA->dst. This will + * correctly deal with RGBA->RGB->RGBA conversions where the final + * A value must be 0xff regardless of the incoming alpha values. + */ + compute_component_mapping(srcFormat, baseInternalFormat, src2base); + compute_component_mapping(baseInternalFormat, GL_RGBA, base2rgba); + swap = byteswap_mapping(srcPacking->SwapBytes, srcType); + srctype2ubyte = type_mapping(srcType); + + + for (i = 0; i < 4; i++) + map[i] = srctype2ubyte[swap[src2base[base2rgba[rgba2dst[i]]]]]; + +/* printf("map %d %d %d %d\n", map[0], map[1], map[2], map[3]); */ + + if (srcComponents == dstComponents && + srcRowStride == dstRowStride && + srcRowStride == srcWidth * srcComponents && + dimensions < 3) { + /* 1 and 2D images only */ + GLubyte *dstImage = (GLubyte *) dstAddr + + dstYoffset * dstRowStride + + dstXoffset * dstComponents; + swizzle_copy(dstImage, dstComponents, srcImage, srcComponents, map, + srcWidth * srcHeight); + } + else { + GLint img, row; + for (img = 0; img < srcDepth; img++) { + const GLubyte *srcRow = srcImage; + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * dstComponents + + dstYoffset * dstRowStride + + dstXoffset * dstComponents; + for (row = 0; row < srcHeight; row++) { + swizzle_copy(dstRow, dstComponents, srcRow, srcComponents, map, srcWidth); + dstRow += dstRowStride; + srcRow += srcRowStride; + } + srcImage += srcImageStride; + } + } +} + + +/** + * Teximage storage routine for when a simple memcpy will do. + * No pixel transfer operations or special texel encodings allowed. + * 1D, 2D and 3D images supported. + */ +static void +memcpy_texture(struct gl_context *ctx, + GLuint dimensions, + gl_format dstFormat, + GLvoid *dstAddr, + GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, + GLint dstRowStride, + const GLuint *dstImageOffsets, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking) +{ + const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, + srcFormat, srcType); + const GLint srcImageStride = _mesa_image_image_stride(srcPacking, + srcWidth, srcHeight, srcFormat, srcType); + const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(dimensions, + srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLint bytesPerRow = srcWidth * texelBytes; + +#if 0 + /* XXX update/re-enable for dstImageOffsets array */ + const GLint bytesPerImage = srcHeight * bytesPerRow; + const GLint bytesPerTexture = srcDepth * bytesPerImage; + GLubyte *dstImage = (GLubyte *) dstAddr + + dstZoffset * dstImageStride + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + + if (dstRowStride == srcRowStride && + dstRowStride == bytesPerRow && + ((dstImageStride == srcImageStride && + dstImageStride == bytesPerImage) || + (srcDepth == 1))) { + /* one big memcpy */ + ctx->Driver.TextureMemCpy(dstImage, srcImage, bytesPerTexture); + } + else + { + GLint img, row; + for (img = 0; img < srcDepth; img++) { + const GLubyte *srcRow = srcImage; + GLubyte *dstRow = dstImage; + for (row = 0; row < srcHeight; row++) { + ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow); + dstRow += dstRowStride; + srcRow += srcRowStride; + } + srcImage += srcImageStride; + dstImage += dstImageStride; + } + } +#endif + + GLint img, row; + for (img = 0; img < srcDepth; img++) { + const GLubyte *srcRow = srcImage; + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow); + dstRow += dstRowStride; + srcRow += srcRowStride; + } + srcImage += srcImageStride; + } +} + + + +/** + * Store a 32-bit integer depth component texture image. + */ +static GLboolean +_mesa_texstore_z32(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffffff; + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + (void) dims; + ASSERT(dstFormat == MESA_FORMAT_Z32); + ASSERT(texelBytes == sizeof(GLuint)); + + if (ctx->Pixel.DepthScale == 1.0f && + ctx->Pixel.DepthBias == 0.0f && + !srcPacking->SwapBytes && + baseInternalFormat == GL_DEPTH_COMPONENT && + srcFormat == GL_DEPTH_COMPONENT && + srcType == GL_UNSIGNED_INT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, (GLuint *) dstRow, + depthScale, srcType, src, srcPacking); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Store a 24-bit integer depth component texture image. + */ +static GLboolean +_mesa_texstore_x8_z24(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffff; + const GLuint texelBytes = 4; + + (void) dims; + ASSERT(dstFormat == MESA_FORMAT_X8_Z24); + + { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, (GLuint *) dstRow, + depthScale, srcType, src, srcPacking); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Store a 24-bit integer depth component texture image. + */ +static GLboolean +_mesa_texstore_z24_x8(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffff; + const GLuint texelBytes = 4; + + (void) dims; + ASSERT(dstFormat == MESA_FORMAT_Z24_X8); + + { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + GLuint *dst = (GLuint *) dstRow; + GLint i; + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, dst, + depthScale, srcType, src, srcPacking); + for (i = 0; i < srcWidth; i++) + dst[i] <<= 8; + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Store a 16-bit integer depth component texture image. + */ +static GLboolean +_mesa_texstore_z16(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffff; + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + (void) dims; + ASSERT(dstFormat == MESA_FORMAT_Z16); + ASSERT(texelBytes == sizeof(GLushort)); + + if (ctx->Pixel.DepthScale == 1.0f && + ctx->Pixel.DepthBias == 0.0f && + !srcPacking->SwapBytes && + baseInternalFormat == GL_DEPTH_COMPONENT && + srcFormat == GL_DEPTH_COMPONENT && + srcType == GL_UNSIGNED_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + GLushort *dst16 = (GLushort *) dstRow; + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_SHORT, dst16, depthScale, + srcType, src, srcPacking); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Store an rgb565 or rgb565_rev texture image. + */ +static GLboolean +_mesa_texstore_rgb565(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGB565 || + dstFormat == MESA_FORMAT_RGB565_REV); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_RGB565 && + baseInternalFormat == GL_RGB && + srcFormat == GL_RGB && + srcType == GL_UNSIGNED_SHORT_5_6_5) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGB && + srcFormat == GL_RGB && + srcType == GL_UNSIGNED_BYTE && + dims == 2) { + /* do optimized tex store */ + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + const GLubyte *src = (const GLubyte *) + _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight, + srcFormat, srcType, 0, 0, 0); + GLubyte *dst = (GLubyte *) dstAddr + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + GLint row, col; + for (row = 0; row < srcHeight; row++) { + const GLubyte *srcUB = (const GLubyte *) src; + GLushort *dstUS = (GLushort *) dst; + /* check for byteswapped format */ + if (dstFormat == MESA_FORMAT_RGB565) { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] ); + srcUB += 3; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_565_REV( srcUB[0], srcUB[1], srcUB[2] ); + srcUB += 3; + } + } + dst += dstRowStride; + src += srcRowStride; + } + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + /* check for byteswapped format */ + if (dstFormat == MESA_FORMAT_RGB565) { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 3; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_565_REV( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 3; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a texture in MESA_FORMAT_RGBA8888 or MESA_FORMAT_RGBA8888_REV. + */ +static GLboolean +_mesa_texstore_rgba8888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA8888 || + dstFormat == MESA_FORMAT_RGBA8888_REV); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_RGBA8888 && + baseInternalFormat == GL_RGBA && + ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) || + (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) || + (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) || + (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian))) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_RGBA8888_REV && + baseInternalFormat == GL_RGBA && + ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) || + (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) || + (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) || + (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian))) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + (srcType == GL_UNSIGNED_BYTE || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV) && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if ((littleEndian && dstFormat == MESA_FORMAT_RGBA8888) || + (!littleEndian && dstFormat == MESA_FORMAT_RGBA8888_REV)) { + dstmap[3] = 0; + dstmap[2] = 1; + dstmap[1] = 2; + dstmap[0] = 3; + } + else { + dstmap[3] = 3; + dstmap[2] = 2; + dstmap[1] = 1; + dstmap[0] = 0; + } + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 4, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + if (dstFormat == MESA_FORMAT_RGBA8888) { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]), + CHAN_TO_UBYTE(src[ACOMP]) ); + src += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]), + CHAN_TO_UBYTE(src[ACOMP]) ); + src += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_argb8888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = GL_RGBA; + + ASSERT(dstFormat == MESA_FORMAT_ARGB8888 || + dstFormat == MESA_FORMAT_ARGB8888_REV || + dstFormat == MESA_FORMAT_XRGB8888 || + dstFormat == MESA_FORMAT_XRGB8888_REV ); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_ARGB8888 || + dstFormat == MESA_FORMAT_XRGB8888) && + baseInternalFormat == GL_RGBA && + srcFormat == GL_BGRA && + ((srcType == GL_UNSIGNED_BYTE && littleEndian) || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) { + /* simple memcpy path (little endian) */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_ARGB8888_REV || + dstFormat == MESA_FORMAT_XRGB8888_REV) && + baseInternalFormat == GL_RGBA && + srcFormat == GL_BGRA && + ((srcType == GL_UNSIGNED_BYTE && !littleEndian) || + srcType == GL_UNSIGNED_INT_8_8_8_8)) { + /* simple memcpy path (big endian) */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_ARGB8888 || + dstFormat == MESA_FORMAT_XRGB8888) && + srcFormat == GL_RGB && + (baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB) && + srcType == GL_UNSIGNED_BYTE) { + int img, row, col; + for (img = 0; img < srcDepth; img++) { + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *d4 = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + d4[col] = PACK_COLOR_8888(0xff, + srcRow[col * 3 + RCOMP], + srcRow[col * 3 + GCOMP], + srcRow[col * 3 + BCOMP]); + } + dstRow += dstRowStride; + srcRow += srcRowStride; + } + } + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_ARGB8888 && + srcFormat == GL_RGBA && + baseInternalFormat == GL_RGBA && + srcType == GL_UNSIGNED_BYTE) { + /* same as above case, but src data has alpha too */ + GLint img, row, col; + /* For some reason, streaming copies to write-combined regions + * are extremely sensitive to the characteristics of how the + * source data is retrieved. By reordering the source reads to + * be in-order, the speed of this operation increases by half. + * Strangely the same isn't required for the RGB path, above. + */ + for (img = 0; img < srcDepth; img++) { + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *d4 = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + d4[col] = PACK_COLOR_8888(srcRow[col * 4 + ACOMP], + srcRow[col * 4 + RCOMP], + srcRow[col * 4 + GCOMP], + srcRow[col * 4 + BCOMP]); + } + dstRow += dstRowStride; + srcRow += srcRowStride; + } + } + } + else if (!ctx->_ImageTransferState && + (srcType == GL_UNSIGNED_BYTE || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV) && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if ((littleEndian && dstFormat == MESA_FORMAT_ARGB8888) || + (littleEndian && dstFormat == MESA_FORMAT_XRGB8888) || + (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) || + (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV)) { + dstmap[3] = 3; /* alpha */ + dstmap[2] = 0; /* red */ + dstmap[1] = 1; /* green */ + dstmap[0] = 2; /* blue */ + } + else { + assert((littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) || + (!littleEndian && dstFormat == MESA_FORMAT_ARGB8888) || + (littleEndian && dstFormat == MESA_FORMAT_XRGB8888_REV) || + (!littleEndian && dstFormat == MESA_FORMAT_XRGB8888)); + dstmap[3] = 2; + dstmap[2] = 1; + dstmap[1] = 0; + dstmap[0] = 3; + } + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 4, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + if (dstFormat == MESA_FORMAT_ARGB8888) { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + else if (dstFormat == MESA_FORMAT_XRGB8888) { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( 0xff, + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_rgb888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGB888); + ASSERT(texelBytes == 3); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGB && + srcFormat == GL_BGR && + srcType == GL_UNSIGNED_BYTE && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + srcFormat == GL_RGBA && + srcType == GL_UNSIGNED_BYTE) { + /* extract RGB from RGBA */ + GLint img, row, col; + for (img = 0; img < srcDepth; img++) { + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP]; + dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP]; + dstRow[col * 3 + 2] = srcRow[col * 4 + RCOMP]; + } + dstRow += dstRowStride; + srcRow += srcRowStride; + } + } + } + else if (!ctx->_ImageTransferState && + srcType == GL_UNSIGNED_BYTE && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + dstmap[0] = 2; + dstmap[1] = 1; + dstmap[2] = 0; + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 3, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = (const GLchan *) tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { +#if 0 + if (littleEndian) { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]); + dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); + dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]); + srcUB += 3; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = srcUB[BCOMP]; + dstRow[col * 3 + 1] = srcUB[GCOMP]; + dstRow[col * 3 + 2] = srcUB[RCOMP]; + srcUB += 3; + } + } +#else + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[BCOMP]); + dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); + dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[RCOMP]); + src += 3; + } +#endif + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_bgr888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_BGR888); + ASSERT(texelBytes == 3); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGB && + srcFormat == GL_RGB && + srcType == GL_UNSIGNED_BYTE && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + srcFormat == GL_RGBA && + srcType == GL_UNSIGNED_BYTE) { + /* extract BGR from RGBA */ + int img, row, col; + for (img = 0; img < srcDepth; img++) { + const GLint srcRowStride = + _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP]; + dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP]; + dstRow[col * 3 + 2] = srcRow[col * 4 + BCOMP]; + } + dstRow += dstRowStride; + srcRow += srcRowStride; + } + } + } + else if (!ctx->_ImageTransferState && + srcType == GL_UNSIGNED_BYTE && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + dstmap[0] = 0; + dstmap[1] = 1; + dstmap[2] = 2; + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 3, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = (const GLchan *) tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]); + dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]); + dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]); + src += 3; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_argb4444(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_ARGB4444 || + dstFormat == MESA_FORMAT_ARGB4444_REV); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_ARGB4444 && + baseInternalFormat == GL_RGBA && + srcFormat == GL_BGRA && + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + if (dstFormat == MESA_FORMAT_ARGB4444) { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_4444_REV( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + +static GLboolean +_mesa_texstore_rgba5551(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA5551); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_RGBA5551 && + baseInternalFormat == GL_RGBA && + srcFormat == GL_RGBA && + srcType == GL_UNSIGNED_SHORT_5_5_5_1) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src =tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_5551( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]), + CHAN_TO_UBYTE(src[ACOMP]) ); + src += 4; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + +static GLboolean +_mesa_texstore_argb1555(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_ARGB1555 || + dstFormat == MESA_FORMAT_ARGB1555_REV); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_ARGB1555 && + baseInternalFormat == GL_RGBA && + srcFormat == GL_BGRA && + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src =tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + if (dstFormat == MESA_FORMAT_ARGB1555) { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_1555( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_1555_REV( CHAN_TO_UBYTE(src[ACOMP]), + CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_argb2101010(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_ARGB2101010); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_ARGB2101010 && + srcFormat == GL_BGRA && + srcType == GL_UNSIGNED_INT_2_10_10_10_REV && + baseInternalFormat == GL_RGBA) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + if (baseInternalFormat == GL_RGBA) { + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLushort a,r,g,b; + + UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]); + UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]); + dstUI[col] = PACK_COLOR_2101010_US(a, r, g, b); + src += 4; + } + dstRow += dstRowStride; + } + } else if (baseInternalFormat == GL_RGB) { + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLushort r,g,b; + + UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]); + dstUI[col] = PACK_COLOR_2101010_US(0xffff, r, g, b); + src += 4; + } + dstRow += dstRowStride; + } + } else { + ASSERT(0); + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Do texstore for 2-channel, 4-bit/channel, unsigned normalized formats. + */ +static GLboolean +_mesa_texstore_unorm44(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_AL44); + ASSERT(texelBytes == 1); + + { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLubyte *dstUS = (GLubyte *) dstRow; + for (col = 0; col < srcWidth; col++) { + /* src[0] is luminance, src[1] is alpha */ + dstUS[col] = PACK_COLOR_44( CHAN_TO_UBYTE(src[1]), + CHAN_TO_UBYTE(src[0]) ); + src += 2; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Do texstore for 2-channel, 8-bit/channel, unsigned normalized formats. + */ +static GLboolean +_mesa_texstore_unorm88(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_AL88 || + dstFormat == MESA_FORMAT_AL88_REV || + dstFormat == MESA_FORMAT_RG88 || + dstFormat == MESA_FORMAT_RG88_REV); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_AL88 || dstFormat == MESA_FORMAT_RG88) && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_BYTE && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + littleEndian && + srcType == GL_UNSIGNED_BYTE && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if (dstFormat == MESA_FORMAT_AL88 || dstFormat == MESA_FORMAT_AL88_REV) { + if ((littleEndian && dstFormat == MESA_FORMAT_AL88) || + (!littleEndian && dstFormat == MESA_FORMAT_AL88_REV)) { + dstmap[0] = 0; + dstmap[1] = 3; + } + else { + dstmap[0] = 3; + dstmap[1] = 0; + } + } + else { + if ((littleEndian && dstFormat == MESA_FORMAT_RG88) || + (!littleEndian && dstFormat == MESA_FORMAT_RG88_REV)) { + dstmap[0] = 0; + dstmap[1] = 1; + } + else { + dstmap[0] = 1; + dstmap[1] = 0; + } + } + dstmap[2] = ZERO; /* ? */ + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 2, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + if (dstFormat == MESA_FORMAT_AL88 || + dstFormat == MESA_FORMAT_RG88) { + for (col = 0; col < srcWidth; col++) { + /* src[0] is luminance, src[1] is alpha */ + dstUS[col] = PACK_COLOR_88( CHAN_TO_UBYTE(src[1]), + CHAN_TO_UBYTE(src[0]) ); + src += 2; + } + } + else { + for (col = 0; col < srcWidth; col++) { + /* src[0] is luminance, src[1] is alpha */ + dstUS[col] = PACK_COLOR_88_REV( CHAN_TO_UBYTE(src[1]), + CHAN_TO_UBYTE(src[0]) ); + src += 2; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Do texstore for 2-channel, 16-bit/channel, unsigned normalized formats. + */ +static GLboolean +_mesa_texstore_unorm1616(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_AL1616 || + dstFormat == MESA_FORMAT_AL1616_REV || + dstFormat == MESA_FORMAT_RG1616 || + dstFormat == MESA_FORMAT_RG1616_REV); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + (dstFormat == MESA_FORMAT_AL1616 || dstFormat == MESA_FORMAT_RG1616) && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_SHORT && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + if (dstFormat == MESA_FORMAT_AL1616 || + dstFormat == MESA_FORMAT_RG1616) { + for (col = 0; col < srcWidth; col++) { + GLushort l, a; + + UNCLAMPED_FLOAT_TO_USHORT(l, src[0]); + UNCLAMPED_FLOAT_TO_USHORT(a, src[1]); + dstUI[col] = PACK_COLOR_1616(a, l); + src += 2; + } + } + else { + for (col = 0; col < srcWidth; col++) { + GLushort l, a; + + UNCLAMPED_FLOAT_TO_USHORT(l, src[0]); + UNCLAMPED_FLOAT_TO_USHORT(a, src[1]); + dstUI[col] = PACK_COLOR_1616_REV(a, l); + src += 2; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* Texstore for R16, A16, L16, I16. */ +static GLboolean +_mesa_texstore_unorm16(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_R16 || + dstFormat == MESA_FORMAT_A16 || + dstFormat == MESA_FORMAT_L16 || + dstFormat == MESA_FORMAT_I16); + ASSERT(texelBytes == 2); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_SHORT && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLushort r; + + UNCLAMPED_FLOAT_TO_USHORT(r, src[0]); + dstUS[col] = r; + src += 1; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_rgba_16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_16); + ASSERT(texelBytes == 8); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGBA && + srcFormat == GL_RGBA && + srcType == GL_UNSIGNED_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLushort r, g, b, a; + + UNCLAMPED_FLOAT_TO_USHORT(r, src[0]); + UNCLAMPED_FLOAT_TO_USHORT(g, src[1]); + UNCLAMPED_FLOAT_TO_USHORT(b, src[2]); + UNCLAMPED_FLOAT_TO_USHORT(a, src[3]); + dstUS[col*4+0] = r; + dstUS[col*4+1] = g; + dstUS[col*4+2] = b; + dstUS[col*4+3] = a; + src += 4; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_R_16 || + dstFormat == MESA_FORMAT_SIGNED_RG_16 || + dstFormat == MESA_FORMAT_SIGNED_RGB_16 || + dstFormat == MESA_FORMAT_SIGNED_RGBA_16); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGBA && + dstFormat == MESA_FORMAT_SIGNED_RGBA_16 && + srcFormat == GL_RGBA && + srcType == GL_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + const GLuint comps = _mesa_get_format_bytes(dstFormat) / 2; + GLint img, row, col; + + if (!tempImage) + return GL_FALSE; + + /* Note: tempImage is always float[4] / RGBA. We convert to 1, 2, + * 3 or 4 components/pixel here. + */ + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLshort *dstRowS = (GLshort *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLuint c; + for (c = 0; c < comps; c++) { + GLshort p; + UNCLAMPED_FLOAT_TO_SHORT(p, src[col * 4 + c]); + dstRowS[col * comps + c] = p; + } + } + dstRow += dstRowStride; + src += 4 * srcWidth; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_rgb332(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGB332); + ASSERT(texelBytes == 1); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGB && + srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col] = PACK_COLOR_332( CHAN_TO_UBYTE(src[RCOMP]), + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); + src += 3; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8. + */ +static GLboolean +_mesa_texstore_a8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_A8 || + dstFormat == MESA_FORMAT_L8 || + dstFormat == MESA_FORMAT_I8 || + dstFormat == MESA_FORMAT_R8); + ASSERT(texelBytes == 1); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + srcType == GL_UNSIGNED_BYTE && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if (dstFormat == MESA_FORMAT_A8) { + dstmap[0] = 3; + } + else { + dstmap[0] = 0; + } + dstmap[1] = ZERO; /* ? */ + dstmap[2] = ZERO; /* ? */ + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 1, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLchan *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + dstRow[col] = CHAN_TO_UBYTE(src[col]); + } + dstRow += dstRowStride; + src += srcWidth; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + + +static GLboolean +_mesa_texstore_ci8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + + (void) dims; (void) baseInternalFormat; + ASSERT(dstFormat == MESA_FORMAT_CI8); + ASSERT(texelBytes == 1); + ASSERT(baseInternalFormat == GL_COLOR_INDEX); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + srcFormat == GL_COLOR_INDEX && + srcType == GL_UNSIGNED_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + const GLvoid *src = _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0); + _mesa_unpack_index_span(ctx, srcWidth, GL_UNSIGNED_BYTE, dstRow, + srcType, src, srcPacking, + ctx->_ImageTransferState); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + + +/** + * Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_REV. + */ +static GLboolean +_mesa_texstore_ycbcr(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + + (void) ctx; (void) dims; (void) baseInternalFormat; + + ASSERT((dstFormat == MESA_FORMAT_YCBCR) || + (dstFormat == MESA_FORMAT_YCBCR_REV)); + ASSERT(texelBytes == 2); + ASSERT(ctx->Extensions.MESA_ycbcr_texture); + ASSERT(srcFormat == GL_YCBCR_MESA); + ASSERT((srcType == GL_UNSIGNED_SHORT_8_8_MESA) || + (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA)); + ASSERT(baseInternalFormat == GL_YCBCR_MESA); + + /* always just memcpy since no pixel transfer ops apply */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + + /* Check if we need byte swapping */ + /* XXX the logic here _might_ be wrong */ + if (srcPacking->SwapBytes ^ + (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA) ^ + (dstFormat == MESA_FORMAT_YCBCR_REV) ^ + !littleEndian) { + GLint img, row; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + _mesa_swap2((GLushort *) dstRow, srcWidth); + dstRow += dstRowStride; + } + } + } + return GL_TRUE; +} + +static GLboolean +_mesa_texstore_dudv8(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_DUDV8); + ASSERT(texelBytes == 2); + ASSERT(ctx->Extensions.ATI_envmap_bumpmap); + ASSERT((srcFormat == GL_DU8DV8_ATI) || + (srcFormat == GL_DUDV_ATI)); + ASSERT(baseInternalFormat == GL_DUDV_ATI); + + if (!srcPacking->SwapBytes && srcType == GL_BYTE && + littleEndian) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (srcType == GL_BYTE) { + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if (littleEndian) { + dstmap[0] = 0; + dstmap[1] = 3; + } + else { + dstmap[0] = 3; + dstmap[1] = 0; + } + dstmap[2] = ZERO; /* ? */ + dstmap[3] = ONE; /* ? */ + + _mesa_swizzle_ubyte_image(ctx, dims, + GL_LUMINANCE_ALPHA, /* hack */ + GL_UNSIGNED_BYTE, /* hack */ + GL_LUMINANCE_ALPHA, /* hack */ + dstmap, 2, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path - note this is defined for 2d textures only */ + const GLint components = _mesa_components_in_format(baseInternalFormat); + const GLint srcStride = _mesa_image_row_stride(srcPacking, srcWidth, + srcFormat, srcType); + GLbyte *tempImage, *dst, *src; + GLint row; + + tempImage = (GLbyte *) malloc(srcWidth * srcHeight * srcDepth + * components * sizeof(GLbyte)); + if (!tempImage) + return GL_FALSE; + + src = (GLbyte *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + 0, 0, 0); + + dst = tempImage; + for (row = 0; row < srcHeight; row++) { + _mesa_unpack_dudv_span_byte(ctx, srcWidth, baseInternalFormat, + dst, srcFormat, srcType, src, + srcPacking, 0); + dst += srcWidth * components; + src += srcStride; + } + + src = tempImage; + dst = (GLbyte *) dstAddr + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + memcpy(dst, src, srcWidth * texelBytes); + dst += dstRowStride; + src += srcWidth * texelBytes; + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a texture in MESA_FORMAT_SIGNED_R8 format. + */ +static GLboolean +_mesa_texstore_signed_r8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_R8); + ASSERT(texelBytes == 1); + + /* XXX look at adding optimized paths */ + { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLubyte *dstB = (GLubyte *) dstRow; + for (col = 0; col < srcWidth; col++) { + dstB[col] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]); + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a texture in MESA_FORMAT_SIGNED_RG88 format. + */ +static GLboolean +_mesa_texstore_signed_rg88(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG88); + ASSERT(texelBytes == 1); + + /* XXX look at adding optimized paths */ + { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + for (col = 0; col < srcWidth; col++) { + dstUS[col] = PACK_COLOR_88(FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[GCOMP])); + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a texture in MESA_FORMAT_SIGNED_RGBX8888. + */ +static GLboolean +_mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBX8888); + ASSERT(texelBytes == 4); + + { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), + 0xff ); + srcRow += 4; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + + +/** + * Store a texture in MESA_FORMAT_SIGNED_RGBA8888 or + * MESA_FORMAT_SIGNED_RGBA8888_REV + */ +static GLboolean +_mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS) +{ + const GLboolean littleEndian = _mesa_little_endian(); + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBA8888 || + dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV); + ASSERT(texelBytes == 4); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_SIGNED_RGBA8888 && + baseInternalFormat == GL_RGBA && + ((srcFormat == GL_RGBA && srcType == GL_BYTE && !littleEndian) || + (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && littleEndian))) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV && + baseInternalFormat == GL_RGBA && + ((srcFormat == GL_RGBA && srcType == GL_BYTE && littleEndian) || + (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && !littleEndian))) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (!ctx->_ImageTransferState && + (srcType == GL_BYTE) && + can_swizzle(baseInternalFormat) && + can_swizzle(srcFormat)) { + + GLubyte dstmap[4]; + + /* dstmap - how to swizzle from RGBA to dst format: + */ + if ((littleEndian && dstFormat == MESA_FORMAT_SIGNED_RGBA8888) || + (!littleEndian && dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV)) { + dstmap[3] = 0; + dstmap[2] = 1; + dstmap[1] = 2; + dstmap[0] = 3; + } + else { + dstmap[3] = 3; + dstmap[2] = 2; + dstmap[1] = 1; + dstmap[0] = 0; + } + + _mesa_swizzle_ubyte_image(ctx, dims, + srcFormat, + srcType, + baseInternalFormat, + dstmap, 4, + dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcAddr, + srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstUI = (GLuint *) dstRow; + if (dstFormat == MESA_FORMAT_SIGNED_RGBA8888) { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[ACOMP]) ); + srcRow += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dstUI[col] = PACK_COLOR_8888_REV( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[GCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[BCOMP]), + FLOAT_TO_BYTE_TEX(srcRow[ACOMP]) ); + srcRow += 4; + } + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +/** + * Store a combined depth/stencil texture image. + */ +static GLboolean +_mesa_texstore_z24_s8(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffff; + const GLint srcRowStride + = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) + / sizeof(GLuint); + GLint img, row; + + ASSERT(dstFormat == MESA_FORMAT_Z24_S8); + ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT); + ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT); + + if (srcFormat != GL_DEPTH_COMPONENT && ctx->Pixel.DepthScale == 1.0f && + ctx->Pixel.DepthBias == 0.0f && + !srcPacking->SwapBytes) { + /* simple path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else if (srcFormat == GL_DEPTH_COMPONENT) { + /* In case we only upload depth we need to preserve the stencil */ + for (img = 0; img < srcDepth; img++) { + GLuint *dstRow = (GLuint *) dstAddr + + dstImageOffsets[dstZoffset + img] + + dstYoffset * dstRowStride / sizeof(GLuint) + + dstXoffset; + const GLuint *src + = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + GLuint depth[MAX_WIDTH]; + GLubyte stencil[MAX_WIDTH]; + GLint i; + GLboolean keepdepth = GL_FALSE, keepstencil = GL_FALSE; + + if (srcFormat == GL_DEPTH_COMPONENT) { /* preserve stencil */ + keepstencil = GL_TRUE; + } + else if (srcFormat == GL_STENCIL_INDEX) { /* preserve depth */ + keepdepth = GL_TRUE; + } + + if (keepdepth == GL_FALSE) + /* the 24 depth bits will be in the low position: */ + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, /* dst type */ + keepstencil ? depth : dstRow, /* dst addr */ + depthScale, + srcType, src, srcPacking); + + if (keepstencil == GL_FALSE) + /* get the 8-bit stencil values */ + _mesa_unpack_stencil_span(ctx, srcWidth, + GL_UNSIGNED_BYTE, /* dst type */ + stencil, /* dst addr */ + srcType, src, srcPacking, + ctx->_ImageTransferState); + + for (i = 0; i < srcWidth; i++) { + if (keepstencil) + dstRow[i] = depth[i] << 8 | (dstRow[i] & 0x000000FF); + else + dstRow[i] = (dstRow[i] & 0xFFFFFF00) | (stencil[i] & 0xFF); + } + + src += srcRowStride; + dstRow += dstRowStride / sizeof(GLuint); + } + } + } + return GL_TRUE; +} + + +/** + * Store a combined depth/stencil texture image. + */ +static GLboolean +_mesa_texstore_s8_z24(TEXSTORE_PARAMS) +{ + const GLuint depthScale = 0xffffff; + const GLint srcRowStride + = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) + / sizeof(GLuint); + GLint img, row; + + ASSERT(dstFormat == MESA_FORMAT_S8_Z24); + ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || + srcFormat == GL_DEPTH_COMPONENT || + srcFormat == GL_STENCIL_INDEX); + ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || + srcType == GL_UNSIGNED_INT_24_8_EXT); + + for (img = 0; img < srcDepth; img++) { + GLuint *dstRow = (GLuint *) dstAddr + + dstImageOffsets[dstZoffset + img] + + dstYoffset * dstRowStride / sizeof(GLuint) + + dstXoffset; + const GLuint *src + = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + GLuint depth[MAX_WIDTH]; + GLubyte stencil[MAX_WIDTH]; + GLint i; + GLboolean keepdepth = GL_FALSE, keepstencil = GL_FALSE; + + if (srcFormat == GL_DEPTH_COMPONENT) { /* preserve stencil */ + keepstencil = GL_TRUE; + } + else if (srcFormat == GL_STENCIL_INDEX) { /* preserve depth */ + keepdepth = GL_TRUE; + } + + if (keepdepth == GL_FALSE) + /* the 24 depth bits will be in the low position: */ + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, /* dst type */ + keepstencil ? depth : dstRow, /* dst addr */ + depthScale, + srcType, src, srcPacking); + + if (keepstencil == GL_FALSE) + /* get the 8-bit stencil values */ + _mesa_unpack_stencil_span(ctx, srcWidth, + GL_UNSIGNED_BYTE, /* dst type */ + stencil, /* dst addr */ + srcType, src, srcPacking, + ctx->_ImageTransferState); + + /* merge stencil values into depth values */ + for (i = 0; i < srcWidth; i++) { + if (keepstencil) + dstRow[i] = depth[i] | (dstRow[i] & 0xFF000000); + else + dstRow[i] = (dstRow[i] & 0xFFFFFF) | (stencil[i] << 24); + + } + src += srcRowStride; + dstRow += dstRowStride / sizeof(GLuint); + } + } + return GL_TRUE; +} + + +/** + * Store simple 8-bit/value stencil texture data. + */ +static GLboolean +_mesa_texstore_s8(TEXSTORE_PARAMS) +{ + ASSERT(dstFormat == MESA_FORMAT_S8); + ASSERT(srcFormat == GL_STENCIL_INDEX); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + const GLint srcRowStride + = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) + / sizeof(GLuint); + GLint img, row; + + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] + + dstYoffset * dstRowStride / sizeof(GLuint) + + dstXoffset; + const GLuint *src + = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + GLubyte stencil[MAX_WIDTH]; + GLint i; + + /* get the 8-bit stencil values */ + _mesa_unpack_stencil_span(ctx, srcWidth, + GL_UNSIGNED_BYTE, /* dst type */ + stencil, /* dst addr */ + srcType, src, srcPacking, + ctx->_ImageTransferState); + /* merge stencil values into depth values */ + for (i = 0; i < srcWidth; i++) + dstRow[i] = stencil[i]; + + src += srcRowStride; + dstRow += dstRowStride / sizeof(GLubyte); + } + } + + } + + return GL_TRUE; +} + + +/** + * Store an image in any of the formats: + * _mesa_texformat_rgba_float32 + * _mesa_texformat_rgb_float32 + * _mesa_texformat_alpha_float32 + * _mesa_texformat_luminance_float32 + * _mesa_texformat_luminance_alpha_float32 + * _mesa_texformat_intensity_float32 + */ +static GLboolean +_mesa_texstore_rgba_float32(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT32 || + dstFormat == MESA_FORMAT_RGB_FLOAT32 || + dstFormat == MESA_FORMAT_ALPHA_FLOAT32 || + dstFormat == MESA_FORMAT_LUMINANCE_FLOAT32 || + dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32 || + dstFormat == MESA_FORMAT_INTENSITY_FLOAT32); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLfloat)); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_FLOAT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *srcRow = tempImage; + GLint bytesPerRow; + GLint img, row; + if (!tempImage) + return GL_FALSE; + bytesPerRow = srcWidth * components * sizeof(GLfloat); + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + memcpy(dstRow, srcRow, bytesPerRow); + dstRow += dstRowStride; + srcRow += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + + +/** + * As above, but store 16-bit floats. + */ +static GLboolean +_mesa_texstore_rgba_float16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT16 || + dstFormat == MESA_FORMAT_RGB_FLOAT16 || + dstFormat == MESA_FORMAT_ALPHA_FLOAT16 || + dstFormat == MESA_FORMAT_LUMINANCE_FLOAT16 || + dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16 || + dstFormat == MESA_FORMAT_INTENSITY_FLOAT16); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLhalfARB)); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_HALF_FLOAT_ARB) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, + ctx->_ImageTransferState); + const GLfloat *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLhalfARB *dstTexel = (GLhalfARB *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = _mesa_float_to_half(src[i]); + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, signed int8 */ +static GLboolean +_mesa_texstore_rgba_int8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_INT8); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLbyte)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, 0x0); + const GLfloat *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLbyte *dstTexel = (GLbyte *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLbyte) src[i]; + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, signed int16 */ +static GLboolean +_mesa_texstore_rgba_int16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_INT16); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLshort)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, 0x0); + const GLfloat *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLshort *dstTexel = (GLshort *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLint) src[i]; + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, signed int32 */ +static GLboolean +_mesa_texstore_rgba_int32(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_INT32); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLint)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_INT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking, 0x0); + const GLfloat *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLint *dstTexel = (GLint *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLint) src[i]; + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, unsigned int8 */ +static GLboolean +_mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT8); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLubyte)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_BYTE) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLuint *tempImage = + make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, srcPacking); + const GLuint *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLubyte *dstTexel = (GLubyte *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLubyte) CLAMP(src[i], 0, 0xff); + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, unsigned int16 */ +static GLboolean +_mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT16); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLushort)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLuint *tempImage = + make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, srcPacking); + const GLuint *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstTexel = (GLushort *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLushort) CLAMP(src[i], 0, 0xffff); + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + +/* non-normalized, unsigned int32 */ +static GLboolean +_mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + const GLint components = _mesa_components_in_format(baseFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_UINT32); + ASSERT(baseInternalFormat == GL_RGBA || + baseInternalFormat == GL_RGB || + baseInternalFormat == GL_ALPHA || + baseInternalFormat == GL_LUMINANCE || + baseInternalFormat == GL_LUMINANCE_ALPHA || + baseInternalFormat == GL_INTENSITY); + ASSERT(texelBytes == components * sizeof(GLuint)); + + /* Note: Pixel transfer ops (scale, bias, table lookup) do not apply + * to integer formats. + */ + if (!srcPacking->SwapBytes && + baseInternalFormat == srcFormat && + srcType == GL_UNSIGNED_INT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLuint *tempImage = + make_temp_uint_image(ctx, dims, baseInternalFormat, baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, srcPacking); + const GLuint *src = tempImage; + GLint img, row; + if (!tempImage) + return GL_FALSE; + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLuint *dstTexel = (GLuint *) dstRow; + GLint i; + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = src[i]; + } + dstRow += dstRowStride; + src += srcWidth * components; + } + } + + free((void *) tempImage); + } + return GL_TRUE; +} + + + + +#if FEATURE_EXT_texture_sRGB +static GLboolean +_mesa_texstore_srgb8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SRGB8); + + /* reuse normal rgb texstore code */ + newDstFormat = MESA_FORMAT_RGB888; + + k = _mesa_texstore_rgb888(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + + +static GLboolean +_mesa_texstore_srgba8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SRGBA8); + + /* reuse normal rgba texstore code */ + newDstFormat = MESA_FORMAT_RGBA8888; + k = _mesa_texstore_rgba8888(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + + +static GLboolean +_mesa_texstore_sargb8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SARGB8); + + /* reuse normal rgba texstore code */ + newDstFormat = MESA_FORMAT_ARGB8888; + + k = _mesa_texstore_argb8888(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + + +static GLboolean +_mesa_texstore_sl8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SL8); + + newDstFormat = MESA_FORMAT_L8; + + /* _mesa_textore_a8 handles luminance8 too */ + k = _mesa_texstore_a8(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + + +static GLboolean +_mesa_texstore_sla8(TEXSTORE_PARAMS) +{ + gl_format newDstFormat; + GLboolean k; + + ASSERT(dstFormat == MESA_FORMAT_SLA8); + + /* reuse normal luminance/alpha texstore code */ + newDstFormat = MESA_FORMAT_AL88; + + k = _mesa_texstore_unorm88(ctx, dims, baseInternalFormat, + newDstFormat, dstAddr, + dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, + srcAddr, srcPacking); + return k; +} + +#else + +/* these are used only in texstore_funcs[] below */ +#define _mesa_texstore_srgb8 NULL +#define _mesa_texstore_srgba8 NULL +#define _mesa_texstore_sargb8 NULL +#define _mesa_texstore_sl8 NULL +#define _mesa_texstore_sla8 NULL + +#endif /* FEATURE_EXT_texture_sRGB */ + + + + +/** + * Table mapping MESA_FORMAT_* to _mesa_texstore_*() + * XXX this is somewhat temporary. + */ +static const struct { + gl_format Name; + StoreTexImageFunc Store; +} +texstore_funcs[MESA_FORMAT_COUNT] = +{ + { MESA_FORMAT_NONE, NULL }, + { MESA_FORMAT_RGBA8888, _mesa_texstore_rgba8888 }, + { MESA_FORMAT_RGBA8888_REV, _mesa_texstore_rgba8888 }, + { MESA_FORMAT_ARGB8888, _mesa_texstore_argb8888 }, + { MESA_FORMAT_ARGB8888_REV, _mesa_texstore_argb8888 }, + { MESA_FORMAT_XRGB8888, _mesa_texstore_argb8888 }, + { MESA_FORMAT_XRGB8888_REV, _mesa_texstore_argb8888 }, + { MESA_FORMAT_RGB888, _mesa_texstore_rgb888 }, + { MESA_FORMAT_BGR888, _mesa_texstore_bgr888 }, + { MESA_FORMAT_RGB565, _mesa_texstore_rgb565 }, + { MESA_FORMAT_RGB565_REV, _mesa_texstore_rgb565 }, + { MESA_FORMAT_ARGB4444, _mesa_texstore_argb4444 }, + { MESA_FORMAT_ARGB4444_REV, _mesa_texstore_argb4444 }, + { MESA_FORMAT_RGBA5551, _mesa_texstore_rgba5551 }, + { MESA_FORMAT_ARGB1555, _mesa_texstore_argb1555 }, + { MESA_FORMAT_ARGB1555_REV, _mesa_texstore_argb1555 }, + { MESA_FORMAT_AL44, _mesa_texstore_unorm44 }, + { MESA_FORMAT_AL88, _mesa_texstore_unorm88 }, + { MESA_FORMAT_AL88_REV, _mesa_texstore_unorm88 }, + { MESA_FORMAT_AL1616, _mesa_texstore_unorm1616 }, + { MESA_FORMAT_AL1616_REV, _mesa_texstore_unorm1616 }, + { MESA_FORMAT_RGB332, _mesa_texstore_rgb332 }, + { MESA_FORMAT_A8, _mesa_texstore_a8 }, + { MESA_FORMAT_A16, _mesa_texstore_unorm16 }, + { MESA_FORMAT_L8, _mesa_texstore_a8 }, + { MESA_FORMAT_L16, _mesa_texstore_unorm16 }, + { MESA_FORMAT_I8, _mesa_texstore_a8 }, + { MESA_FORMAT_I16, _mesa_texstore_unorm16 }, + { MESA_FORMAT_CI8, _mesa_texstore_ci8 }, + { MESA_FORMAT_YCBCR, _mesa_texstore_ycbcr }, + { MESA_FORMAT_YCBCR_REV, _mesa_texstore_ycbcr }, + { MESA_FORMAT_R8, _mesa_texstore_a8 }, + { MESA_FORMAT_RG88, _mesa_texstore_unorm88 }, + { MESA_FORMAT_RG88_REV, _mesa_texstore_unorm88 }, + { MESA_FORMAT_R16, _mesa_texstore_unorm16 }, + { MESA_FORMAT_RG1616, _mesa_texstore_unorm1616 }, + { MESA_FORMAT_RG1616_REV, _mesa_texstore_unorm1616 }, + { MESA_FORMAT_ARGB2101010, _mesa_texstore_argb2101010 }, + { MESA_FORMAT_Z24_S8, _mesa_texstore_z24_s8 }, + { MESA_FORMAT_S8_Z24, _mesa_texstore_s8_z24 }, + { MESA_FORMAT_Z16, _mesa_texstore_z16 }, + { MESA_FORMAT_X8_Z24, _mesa_texstore_x8_z24 }, + { MESA_FORMAT_Z24_X8, _mesa_texstore_z24_x8 }, + { MESA_FORMAT_Z32, _mesa_texstore_z32 }, + { MESA_FORMAT_S8, _mesa_texstore_s8 }, + { MESA_FORMAT_SRGB8, _mesa_texstore_srgb8 }, + { MESA_FORMAT_SRGBA8, _mesa_texstore_srgba8 }, + { MESA_FORMAT_SARGB8, _mesa_texstore_sargb8 }, + { MESA_FORMAT_SL8, _mesa_texstore_sl8 }, + { MESA_FORMAT_SLA8, _mesa_texstore_sla8 }, + { MESA_FORMAT_SRGB_DXT1, _mesa_texstore_rgb_dxt1 }, + { MESA_FORMAT_SRGBA_DXT1, _mesa_texstore_rgba_dxt1 }, + { MESA_FORMAT_SRGBA_DXT3, _mesa_texstore_rgba_dxt3 }, + { MESA_FORMAT_SRGBA_DXT5, _mesa_texstore_rgba_dxt5 }, + { MESA_FORMAT_RGB_FXT1, _mesa_texstore_rgb_fxt1 }, + { MESA_FORMAT_RGBA_FXT1, _mesa_texstore_rgba_fxt1 }, + { MESA_FORMAT_RGB_DXT1, _mesa_texstore_rgb_dxt1 }, + { MESA_FORMAT_RGBA_DXT1, _mesa_texstore_rgba_dxt1 }, + { MESA_FORMAT_RGBA_DXT3, _mesa_texstore_rgba_dxt3 }, + { MESA_FORMAT_RGBA_DXT5, _mesa_texstore_rgba_dxt5 }, + { MESA_FORMAT_RGBA_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_RGBA_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_RGB_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_RGB_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_ALPHA_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_LUMINANCE_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_LUMINANCE_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, _mesa_texstore_rgba_float16 }, + { MESA_FORMAT_INTENSITY_FLOAT32, _mesa_texstore_rgba_float32 }, + { MESA_FORMAT_INTENSITY_FLOAT16, _mesa_texstore_rgba_float16 }, + + { MESA_FORMAT_RGBA_INT8, _mesa_texstore_rgba_int8 }, + { MESA_FORMAT_RGBA_INT16, _mesa_texstore_rgba_int16 }, + { MESA_FORMAT_RGBA_INT32, _mesa_texstore_rgba_int32 }, + { MESA_FORMAT_RGBA_UINT8, _mesa_texstore_rgba_uint8 }, + { MESA_FORMAT_RGBA_UINT16, _mesa_texstore_rgba_uint16 }, + { MESA_FORMAT_RGBA_UINT32, _mesa_texstore_rgba_uint32 }, + + { MESA_FORMAT_DUDV8, _mesa_texstore_dudv8 }, + + { MESA_FORMAT_SIGNED_R8, _mesa_texstore_signed_r8 }, + { MESA_FORMAT_SIGNED_RG88, _mesa_texstore_signed_rg88 }, + { MESA_FORMAT_SIGNED_RGBX8888, _mesa_texstore_signed_rgbx8888 }, + + { MESA_FORMAT_SIGNED_RGBA8888, _mesa_texstore_signed_rgba8888 }, + { MESA_FORMAT_SIGNED_RGBA8888_REV, _mesa_texstore_signed_rgba8888 }, + + { MESA_FORMAT_SIGNED_R_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_SIGNED_RG_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_SIGNED_RGB_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_SIGNED_RGBA_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_RGBA_16, _mesa_texstore_rgba_16 }, + + { MESA_FORMAT_RED_RGTC1, _mesa_texstore_red_rgtc1 }, + { MESA_FORMAT_SIGNED_RED_RGTC1, _mesa_texstore_signed_red_rgtc1 }, + { MESA_FORMAT_RG_RGTC2, _mesa_texstore_rg_rgtc2 }, + { MESA_FORMAT_SIGNED_RG_RGTC2, _mesa_texstore_signed_rg_rgtc2 } +}; + + +static GLboolean +_mesa_texstore_null(TEXSTORE_PARAMS) +{ + (void) ctx; (void) dims; + (void) baseInternalFormat; + (void) dstFormat; + (void) dstAddr; + (void) dstXoffset; (void) dstYoffset; (void) dstZoffset; + (void) dstRowStride; (void) dstImageOffsets; + (void) srcWidth; (void) srcHeight; (void) srcDepth; + (void) srcFormat; (void) srcType; + (void) srcAddr; + (void) srcPacking; + + /* should never happen */ + _mesa_problem(NULL, "_mesa_texstore_null() is called"); + return GL_FALSE; +} + + +/** + * Return the StoreTexImageFunc pointer to store an image in the given format. + */ +static StoreTexImageFunc +_mesa_get_texstore_func(gl_format format) +{ +#ifdef DEBUG + GLuint i; + for (i = 0; i < MESA_FORMAT_COUNT; i++) { + ASSERT(texstore_funcs[i].Name == i); + } +#endif + ASSERT(texstore_funcs[format].Name == format); + + if (texstore_funcs[format].Store) + return texstore_funcs[format].Store; + else + return _mesa_texstore_null; +} + + +/** + * Store user data into texture memory. + * Called via glTex[Sub]Image1/2/3D() + */ +GLboolean +_mesa_texstore(TEXSTORE_PARAMS) +{ + StoreTexImageFunc storeImage; + GLboolean success; + + storeImage = _mesa_get_texstore_func(dstFormat); + + success = storeImage(ctx, dims, baseInternalFormat, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, dstImageOffsets, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, srcPacking); + return success; +} + + +/** + * Check if an unpack PBO is active prior to fetching a texture image. + * If so, do bounds checking and map the buffer into main memory. + * Any errors detected will be recorded. + * The caller _must_ call _mesa_unmap_teximage_pbo() too! + */ +const GLvoid * +_mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *unpack, + const char *funcName) +{ + GLubyte *buf; + + if (!_mesa_is_bufferobj(unpack->BufferObj)) { + /* no PBO */ + return pixels; + } + if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, + format, type, pixels)) { + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)"); + return NULL; + } + + buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + GL_READ_ONLY_ARB, unpack->BufferObj); + if (!buf) { + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped)"); + return NULL; + } + + return ADD_POINTERS(buf, pixels); +} + + +/** + * Check if an unpack PBO is active prior to fetching a compressed texture + * image. + * If so, do bounds checking and map the buffer into main memory. + * Any errors detected will be recorded. + * The caller _must_ call _mesa_unmap_teximage_pbo() too! + */ +const GLvoid * +_mesa_validate_pbo_compressed_teximage(struct gl_context *ctx, + GLsizei imageSize, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + const char *funcName) +{ + GLubyte *buf; + + if (!_mesa_is_bufferobj(packing->BufferObj)) { + /* not using a PBO - return pointer unchanged */ + return pixels; + } + if ((const GLubyte *) pixels + imageSize > + ((const GLubyte *) 0) + packing->BufferObj->Size) { + /* out of bounds read! */ + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access)"); + return NULL; + } + + buf = (GLubyte*) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + GL_READ_ONLY_ARB, packing->BufferObj); + if (!buf) { + _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped"); + return NULL; + } + + return ADD_POINTERS(buf, pixels); +} + + +/** + * This function must be called after either of the validate_pbo_*_teximage() + * functions. It unmaps the PBO buffer if it was mapped earlier. + */ +void +_mesa_unmap_teximage_pbo(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack) +{ + if (_mesa_is_bufferobj(unpack->BufferObj)) { + ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, + unpack->BufferObj); + } +} + + +/** Return texture size in bytes */ +static GLuint +texture_size(const struct gl_texture_image *texImage) +{ + GLuint sz = _mesa_format_image_size(texImage->TexFormat, texImage->Width, + texImage->Height, texImage->Depth); + return sz; +} + + +/** Return row stride in bytes */ +static GLuint +texture_row_stride(const struct gl_texture_image *texImage) +{ + GLuint stride = _mesa_format_row_stride(texImage->TexFormat, + texImage->Width); + return stride; +} + + + +/** + * This is the software fallback for Driver.TexImage1D() + * and Driver.CopyTexImage1D(). + * \sa _mesa_store_teximage2d() + */ +void +_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + GLuint sizeInBytes; + (void) border; + + /* allocate memory */ + sizeInBytes = texture_size(texImage); + texImage->Data = _mesa_alloc_texmemory(sizeInBytes); + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); + return; + } + + pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, + pixels, packing, "glTexImage1D"); + if (!pixels) { + /* Note: we check for a NULL image pointer here, _after_ we allocated + * memory for the texture. That's what the GL spec calls for. + */ + return; + } + else { + const GLint dstRowStride = 0; + GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + 0, 0, 0, /* dstX/Y/Zoffset */ + dstRowStride, + texImage->ImageOffsets, + width, 1, 1, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + +/** + * This is the software fallback for Driver.TexImage2D() + * and Driver.CopyTexImage2D(). + * + * This function is oriented toward storing images in main memory, rather + * than VRAM. Device driver's can easily plug in their own replacement. + */ +void +_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + GLuint sizeInBytes; + (void) border; + + /* allocate memory */ + sizeInBytes = texture_size(texImage); + texImage->Data = _mesa_alloc_texmemory(sizeInBytes); + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); + return; + } + + pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type, + pixels, packing, "glTexImage2D"); + if (!pixels) { + /* Note: we check for a NULL image pointer here, _after_ we allocated + * memory for the texture. That's what the GL spec calls for. + */ + return; + } + else { + GLint dstRowStride = texture_row_stride(texImage); + GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + 0, 0, 0, /* dstX/Y/Zoffset */ + dstRowStride, + texImage->ImageOffsets, + width, height, 1, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + + +/** + * This is the software fallback for Driver.TexImage3D() + * and Driver.CopyTexImage3D(). + * \sa _mesa_store_teximage2d() + */ +void +_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, GLint border, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + GLuint sizeInBytes; + (void) border; + + /* allocate memory */ + sizeInBytes = texture_size(texImage); + texImage->Data = _mesa_alloc_texmemory(sizeInBytes); + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D"); + return; + } + + pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format, + type, pixels, packing, "glTexImage3D"); + if (!pixels) { + /* Note: we check for a NULL image pointer here, _after_ we allocated + * memory for the texture. That's what the GL spec calls for. + */ + return; + } + else { + GLint dstRowStride = texture_row_stride(texImage); + GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + 0, 0, 0, /* dstX/Y/Zoffset */ + dstRowStride, + texImage->ImageOffsets, + width, height, depth, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + + + +/* + * This is the software fallback for Driver.TexSubImage1D() + * and Driver.CopyTexSubImage1D(). + */ +void +_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint width, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* get pointer to src pixels (may be in a pbo which we'll map here) */ + pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type, + pixels, packing, "glTexSubImage1D"); + if (!pixels) + return; + + { + const GLint dstRowStride = 0; + GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + xoffset, 0, 0, /* offsets */ + dstRowStride, + texImage->ImageOffsets, + width, 1, 1, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + + +/** + * This is the software fallback for Driver.TexSubImage2D() + * and Driver.CopyTexSubImage2D(). + */ +void +_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint width, GLint height, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* get pointer to src pixels (may be in a pbo which we'll map here) */ + pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type, + pixels, packing, "glTexSubImage2D"); + if (!pixels) + return; + + { + GLint dstRowStride = texture_row_stride(texImage); + GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + xoffset, yoffset, 0, + dstRowStride, + texImage->ImageOffsets, + width, height, 1, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + +/* + * This is the software fallback for Driver.TexSubImage3D(). + * and Driver.CopyTexSubImage3D(). + */ +void +_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type, const void *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* get pointer to src pixels (may be in a pbo which we'll map here) */ + pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format, + type, pixels, packing, + "glTexSubImage3D"); + if (!pixels) + return; + + { + GLint dstRowStride = texture_row_stride(texImage); + GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, + xoffset, yoffset, zoffset, + dstRowStride, + texImage->ImageOffsets, + width, height, depth, + format, type, pixels, packing); + if (!success) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D"); + } + } + + _mesa_unmap_teximage_pbo(ctx, packing); +} + + +/* + * Fallback for Driver.CompressedTexImage1D() + */ +void +_mesa_store_compressed_teximage1d(struct gl_context *ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* this space intentionally left blank */ + (void) ctx; + (void) target; (void) level; + (void) internalFormat; + (void) width; (void) border; + (void) imageSize; (void) data; + (void) texObj; + (void) texImage; +} + + + +/** + * Fallback for Driver.CompressedTexImage2D() + */ +void +_mesa_store_compressed_teximage2d(struct gl_context *ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + (void) width; (void) height; (void) border; + + /* This is pretty simple, basically just do a memcpy without worrying + * about the usual image unpacking or image transfer operations. + */ + ASSERT(texObj); + ASSERT(texImage); + ASSERT(texImage->Width > 0); + ASSERT(texImage->Height > 0); + ASSERT(texImage->Depth == 1); + ASSERT(texImage->Data == NULL); /* was freed in glCompressedTexImage2DARB */ + + /* allocate storage */ + texImage->Data = _mesa_alloc_texmemory(imageSize); + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); + return; + } + + data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data, + &ctx->Unpack, + "glCompressedTexImage2D"); + if (!data) + return; + + /* copy the data */ + memcpy(texImage->Data, data, imageSize); + + _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack); +} + + + +/* + * Fallback for Driver.CompressedTexImage3D() + */ +void +_mesa_store_compressed_teximage3d(struct gl_context *ctx, + GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, + GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* this space intentionally left blank */ + (void) ctx; + (void) target; (void) level; + (void) internalFormat; + (void) width; (void) height; (void) depth; + (void) border; + (void) imageSize; (void) data; + (void) texObj; + (void) texImage; +} + + + +/** + * Fallback for Driver.CompressedTexSubImage1D() + */ +void +_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLsizei width, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* there are no compressed 1D texture formats yet */ + (void) ctx; + (void) target; (void) level; + (void) xoffset; (void) width; + (void) format; + (void) imageSize; (void) data; + (void) texObj; + (void) texImage; +} + + +/** + * Fallback for Driver.CompressedTexSubImage2D() + */ +void +_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + GLint bytesPerRow, destRowStride, srcRowStride; + GLint i, rows; + GLubyte *dest; + const GLubyte *src; + const gl_format texFormat = texImage->TexFormat; + const GLint destWidth = texImage->Width; + GLuint bw, bh; + + _mesa_get_format_block_size(texFormat, &bw, &bh); + + (void) level; + (void) format; + + /* these should have been caught sooner */ + ASSERT((width % bw) == 0 || width == 2 || width == 1); + ASSERT((height % bh) == 0 || height == 2 || height == 1); + ASSERT((xoffset % bw) == 0); + ASSERT((yoffset % bh) == 0); + + /* get pointer to src pixels (may be in a pbo which we'll map here) */ + data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data, + &ctx->Unpack, + "glCompressedTexSubImage2D"); + if (!data) + return; + + srcRowStride = _mesa_format_row_stride(texFormat, width); + src = (const GLubyte *) data; + + destRowStride = _mesa_format_row_stride(texFormat, destWidth); + dest = _mesa_compressed_image_address(xoffset, yoffset, 0, + texFormat, destWidth, + (GLubyte *) texImage->Data); + + bytesPerRow = srcRowStride; /* bytes per row of blocks */ + rows = height / bh; /* rows in blocks */ + + /* copy rows of blocks */ + for (i = 0; i < rows; i++) { + memcpy(dest, src, bytesPerRow); + dest += destRowStride; + src += srcRowStride; + } + + _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack); +} + + +/** + * Fallback for Driver.CompressedTexSubImage3D() + */ +void +_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + /* there are no compressed 3D texture formats yet */ + (void) ctx; + (void) target; (void) level; + (void) xoffset; (void) yoffset; (void) zoffset; + (void) width; (void) height; (void) depth; + (void) format; + (void) imageSize; (void) data; + (void) texObj; + (void) texImage; +} diff --git a/mesalib/src/mesa/main/texstore.h b/mesalib/src/mesa/main/texstore.h index 8640a23a7..2f3c4e821 100644 --- a/mesalib/src/mesa/main/texstore.h +++ b/mesalib/src/mesa/main/texstore.h @@ -1,218 +1,227 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * Copyright (c) 2008 VMware, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file texstore.h - * Texture image storage routines. - * - * \author Brian Paul - */ - - -#ifndef TEXSTORE_H -#define TEXSTORE_H - - -#include "mtypes.h" -#include "formats.h" - - -/** - * This macro defines the (many) parameters to the texstore functions. - * \param dims either 1 or 2 or 3 - * \param baseInternalFormat user-specified base internal format - * \param dstFormat destination Mesa texture format - * \param dstAddr destination image address - * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels - * \param dstRowStride destination image row stride, in bytes - * \param dstImageOffsets offset of each 2D slice within 3D texture, in texels - * \param srcWidth/Height/Depth source image size, in pixels - * \param srcFormat incoming image format - * \param srcType incoming image data type - * \param srcAddr source image address - * \param srcPacking source image packing parameters - */ -#define TEXSTORE_PARAMS \ - struct gl_context *ctx, GLuint dims, \ - GLenum baseInternalFormat, \ - gl_format dstFormat, \ - GLvoid *dstAddr, \ - GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \ - GLint dstRowStride, const GLuint *dstImageOffsets, \ - GLint srcWidth, GLint srcHeight, GLint srcDepth, \ - GLenum srcFormat, GLenum srcType, \ - const GLvoid *srcAddr, \ - const struct gl_pixelstore_attrib *srcPacking - - -extern GLboolean -_mesa_texstore(TEXSTORE_PARAMS); - - -extern GLchan * -_mesa_make_temp_chan_image(struct gl_context *ctx, GLuint dims, - GLenum logicalBaseFormat, - GLenum textureBaseFormat, - GLint srcWidth, GLint srcHeight, GLint srcDepth, - GLenum srcFormat, GLenum srcType, - const GLvoid *srcAddr, - const struct gl_pixelstore_attrib *srcPacking); - - -extern void -_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint width, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint width, GLint height, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_compressed_teximage1d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - -extern void -_mesa_store_compressed_teximage2d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - -extern void -_mesa_store_compressed_teximage3d(struct gl_context *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint depth, - GLint border, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern void -_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target, - GLint level, - GLint xoffset, GLsizei width, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - -extern void -_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target, - GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - -extern void -_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target, - GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, - GLsizei imageSize, const GLvoid *data, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage); - - -extern const GLvoid * -_mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *unpack, - const char *funcName); - -extern const GLvoid * -_mesa_validate_pbo_compressed_teximage(struct gl_context *ctx, - GLsizei imageSize, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - const char *funcName); - -extern void -_mesa_unmap_teximage_pbo(struct gl_context *ctx, - const struct gl_pixelstore_attrib *unpack); - - -#endif +/* + * Mesa 3-D graphics library + * Version: 6.5.1 + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (c) 2008 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * \file texstore.h + * Texture image storage routines. + * + * \author Brian Paul + */ + + +#ifndef TEXSTORE_H +#define TEXSTORE_H + + +#include "mtypes.h" +#include "formats.h" + + +/** + * This macro defines the (many) parameters to the texstore functions. + * \param dims either 1 or 2 or 3 + * \param baseInternalFormat user-specified base internal format + * \param dstFormat destination Mesa texture format + * \param dstAddr destination image address + * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels + * \param dstRowStride destination image row stride, in bytes + * \param dstImageOffsets offset of each 2D slice within 3D texture, in texels + * \param srcWidth/Height/Depth source image size, in pixels + * \param srcFormat incoming image format + * \param srcType incoming image data type + * \param srcAddr source image address + * \param srcPacking source image packing parameters + */ +#define TEXSTORE_PARAMS \ + struct gl_context *ctx, GLuint dims, \ + GLenum baseInternalFormat, \ + gl_format dstFormat, \ + GLvoid *dstAddr, \ + GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \ + GLint dstRowStride, const GLuint *dstImageOffsets, \ + GLint srcWidth, GLint srcHeight, GLint srcDepth, \ + GLenum srcFormat, GLenum srcType, \ + const GLvoid *srcAddr, \ + const struct gl_pixelstore_attrib *srcPacking + + +extern GLboolean +_mesa_texstore(TEXSTORE_PARAMS); + + +extern GLchan * +_mesa_make_temp_chan_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking); + +GLfloat * +_mesa_make_temp_float_image(struct gl_context *ctx, GLuint dims, + GLenum logicalBaseFormat, + GLenum textureBaseFormat, + GLint srcWidth, GLint srcHeight, GLint srcDepth, + GLenum srcFormat, GLenum srcType, + const GLvoid *srcAddr, + const struct gl_pixelstore_attrib *srcPacking, + GLbitfield transferOps); + +extern void +_mesa_store_teximage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_teximage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_teximage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_texsubimage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint width, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_texsubimage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint width, GLint height, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_texsubimage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint width, GLint height, GLint depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_compressed_teximage1d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_teximage2d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_teximage3d(struct gl_context *ctx, GLenum target, GLint level, + GLint internalFormat, + GLint width, GLint height, GLint depth, + GLint border, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern void +_mesa_store_compressed_texsubimage1d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLsizei width, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_texsubimage2d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + +extern void +_mesa_store_compressed_texsubimage3d(struct gl_context *ctx, GLenum target, + GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); + + +extern const GLvoid * +_mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *unpack, + const char *funcName); + +extern const GLvoid * +_mesa_validate_pbo_compressed_teximage(struct gl_context *ctx, + GLsizei imageSize, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + const char *funcName); + +extern void +_mesa_unmap_teximage_pbo(struct gl_context *ctx, + const struct gl_pixelstore_attrib *unpack); + + +#endif diff --git a/mesalib/src/mesa/sources.mak b/mesalib/src/mesa/sources.mak index b10881c55..bdf4126cf 100644 --- a/mesalib/src/mesa/sources.mak +++ b/mesalib/src/mesa/sources.mak @@ -1,368 +1,369 @@ -### Lists of source files, included by Makefiles - -# this is part of MAIN_SOURCES -MAIN_ES_SOURCES = \ - main/api_exec_es1.c \ - main/api_exec_es2.c - -MAIN_SOURCES = \ - main/api_arrayelt.c \ - main/api_exec.c \ - main/api_loopback.c \ - main/api_noop.c \ - main/api_validate.c \ - main/accum.c \ - main/arbprogram.c \ - main/atifragshader.c \ - main/attrib.c \ - main/arrayobj.c \ - main/blend.c \ - main/bufferobj.c \ - main/buffers.c \ - main/clear.c \ - main/clip.c \ - main/colortab.c \ - main/condrender.c \ - main/context.c \ - main/convolve.c \ - main/cpuinfo.c \ - main/debug.c \ - main/depth.c \ - main/depthstencil.c \ - main/dlist.c \ - main/dlopen.c \ - main/drawpix.c \ - main/drawtex.c \ - main/enable.c \ - main/enums.c \ - main/eval.c \ - main/execmem.c \ - main/extensions.c \ - main/fbobject.c \ - main/feedback.c \ - main/ffvertex_prog.c \ - main/fog.c \ - main/formats.c \ - main/framebuffer.c \ - main/get.c \ - main/getstring.c \ - main/hash.c \ - main/hint.c \ - main/histogram.c \ - main/image.c \ - main/imports.c \ - main/light.c \ - main/lines.c \ - main/matrix.c \ - main/mipmap.c \ - main/mm.c \ - main/multisample.c \ - main/nvprogram.c \ - main/pack.c \ - main/pixel.c \ - main/pixelstore.c \ - main/pixeltransfer.c \ - main/points.c \ - main/polygon.c \ - main/queryobj.c \ - main/querymatrix.c \ - main/rastpos.c \ - main/readpix.c \ - main/remap.c \ - main/renderbuffer.c \ - main/scissor.c \ - main/shaderapi.c \ - main/shaderobj.c \ - main/shared.c \ - main/state.c \ - main/stencil.c \ - main/syncobj.c \ - main/texcompress.c \ - main/texcompress_s3tc.c \ - main/texcompress_fxt1.c \ - main/texenv.c \ - main/texenvprogram.c \ - main/texfetch.c \ - main/texformat.c \ - main/texgen.c \ - main/texgetimage.c \ - main/teximage.c \ - main/texobj.c \ - main/texpal.c \ - main/texparam.c \ - main/texrender.c \ - main/texstate.c \ - main/texstore.c \ - main/transformfeedback.c \ - main/uniforms.c \ - main/varray.c \ - main/version.c \ - main/viewport.c \ - main/vtxfmt.c \ - $(MAIN_ES_SOURCES) - -MATH_SOURCES = \ - math/m_debug_clip.c \ - math/m_debug_norm.c \ - math/m_debug_xform.c \ - math/m_eval.c \ - math/m_matrix.c \ - math/m_translate.c \ - math/m_vector.c - -MATH_XFORM_SOURCES = \ - math/m_xform.c - -SWRAST_SOURCES = \ - swrast/s_aaline.c \ - swrast/s_aatriangle.c \ - swrast/s_accum.c \ - swrast/s_alpha.c \ - swrast/s_atifragshader.c \ - swrast/s_bitmap.c \ - swrast/s_blend.c \ - swrast/s_blit.c \ - swrast/s_clear.c \ - swrast/s_copypix.c \ - swrast/s_context.c \ - swrast/s_depth.c \ - swrast/s_drawpix.c \ - swrast/s_feedback.c \ - swrast/s_fog.c \ - swrast/s_fragprog.c \ - swrast/s_lines.c \ - swrast/s_logic.c \ - swrast/s_masking.c \ - swrast/s_points.c \ - swrast/s_readpix.c \ - swrast/s_span.c \ - swrast/s_stencil.c \ - swrast/s_texcombine.c \ - swrast/s_texfilter.c \ - swrast/s_triangle.c \ - swrast/s_zoom.c - -SWRAST_SETUP_SOURCES = \ - swrast_setup/ss_context.c \ - swrast_setup/ss_triangle.c - -TNL_SOURCES = \ - tnl/t_context.c \ - tnl/t_pipeline.c \ - tnl/t_draw.c \ - tnl/t_rasterpos.c \ - tnl/t_vb_program.c \ - tnl/t_vb_render.c \ - tnl/t_vb_texgen.c \ - tnl/t_vb_texmat.c \ - tnl/t_vb_vertex.c \ - tnl/t_vb_fog.c \ - tnl/t_vb_light.c \ - tnl/t_vb_normals.c \ - tnl/t_vb_points.c \ - tnl/t_vp_build.c \ - tnl/t_vertex.c \ - tnl/t_vertex_sse.c \ - tnl/t_vertex_generic.c - -VBO_SOURCES = \ - vbo/vbo_context.c \ - vbo/vbo_exec.c \ - vbo/vbo_exec_api.c \ - vbo/vbo_exec_array.c \ - vbo/vbo_exec_draw.c \ - vbo/vbo_exec_eval.c \ - vbo/vbo_rebase.c \ - vbo/vbo_split.c \ - vbo/vbo_split_copy.c \ - vbo/vbo_split_inplace.c \ - vbo/vbo_save.c \ - vbo/vbo_save_api.c \ - vbo/vbo_save_draw.c \ - vbo/vbo_save_loopback.c - -STATETRACKER_SOURCES = \ - state_tracker/st_atom.c \ - state_tracker/st_atom_blend.c \ - state_tracker/st_atom_clip.c \ - state_tracker/st_atom_constbuf.c \ - state_tracker/st_atom_depth.c \ - state_tracker/st_atom_framebuffer.c \ - state_tracker/st_atom_msaa.c \ - state_tracker/st_atom_pixeltransfer.c \ - state_tracker/st_atom_sampler.c \ - state_tracker/st_atom_scissor.c \ - state_tracker/st_atom_shader.c \ - state_tracker/st_atom_rasterizer.c \ - state_tracker/st_atom_stipple.c \ - state_tracker/st_atom_texture.c \ - state_tracker/st_atom_viewport.c \ - state_tracker/st_cb_accum.c \ - state_tracker/st_cb_bitmap.c \ - state_tracker/st_cb_blit.c \ - state_tracker/st_cb_bufferobjects.c \ - state_tracker/st_cb_clear.c \ - state_tracker/st_cb_condrender.c \ - state_tracker/st_cb_flush.c \ - state_tracker/st_cb_drawpixels.c \ - state_tracker/st_cb_drawtex.c \ - state_tracker/st_cb_eglimage.c \ - state_tracker/st_cb_fbo.c \ - state_tracker/st_cb_feedback.c \ - state_tracker/st_cb_program.c \ - state_tracker/st_cb_queryobj.c \ - state_tracker/st_cb_rasterpos.c \ - state_tracker/st_cb_readpixels.c \ - state_tracker/st_cb_strings.c \ - state_tracker/st_cb_texture.c \ - state_tracker/st_cb_viewport.c \ - state_tracker/st_cb_xformfb.c \ - state_tracker/st_context.c \ - state_tracker/st_debug.c \ - state_tracker/st_draw.c \ - state_tracker/st_draw_feedback.c \ - state_tracker/st_extensions.c \ - state_tracker/st_format.c \ - state_tracker/st_gen_mipmap.c \ - state_tracker/st_manager.c \ - state_tracker/st_mesa_to_tgsi.c \ - state_tracker/st_program.c \ - state_tracker/st_texture.c - -PROGRAM_SOURCES = \ - program/arbprogparse.c \ - program/hash_table.c \ - program/lex.yy.c \ - program/nvfragparse.c \ - program/nvvertparse.c \ - program/program.c \ - program/program_parse.tab.c \ - program/program_parse_extra.c \ - program/prog_cache.c \ - program/prog_execute.c \ - program/prog_instruction.c \ - program/prog_noise.c \ - program/prog_optimize.c \ - program/prog_parameter.c \ - program/prog_parameter_layout.c \ - program/prog_print.c \ - program/prog_statevars.c \ - program/prog_uniform.c \ - program/programopt.c \ - program/register_allocate.c \ - program/symbol_table.c - -SHADER_CXX_SOURCES = \ - program/ir_to_mesa.cpp \ - program/sampler.cpp - -ASM_C_SOURCES = \ - x86/common_x86.c \ - x86/x86_xform.c \ - x86/3dnow.c \ - x86/sse.c \ - x86/rtasm/x86sse.c \ - sparc/sparc.c \ - ppc/common_ppc.c \ - x86-64/x86-64.c - -X86_SOURCES = \ - x86/common_x86_asm.S \ - x86/x86_xform2.S \ - x86/x86_xform3.S \ - x86/x86_xform4.S \ - x86/x86_cliptest.S \ - x86/mmx_blend.S \ - x86/3dnow_xform1.S \ - x86/3dnow_xform2.S \ - x86/3dnow_xform3.S \ - x86/3dnow_xform4.S \ - x86/3dnow_normal.S \ - x86/sse_xform1.S \ - x86/sse_xform2.S \ - x86/sse_xform3.S \ - x86/sse_xform4.S \ - x86/sse_normal.S \ - x86/read_rgba_span_x86.S - -X86-64_SOURCES = \ - x86-64/xform4.S - -SPARC_SOURCES = \ - sparc/clip.S \ - sparc/norm.S \ - sparc/xform.S - -COMMON_DRIVER_SOURCES = \ - drivers/common/driverfuncs.c \ - drivers/common/meta.c - - -# Sources for building non-Gallium drivers -MESA_SOURCES = \ - $(MAIN_SOURCES) \ - $(MATH_SOURCES) \ - $(MATH_XFORM_SOURCES) \ - $(VBO_SOURCES) \ - $(TNL_SOURCES) \ - $(PROGRAM_SOURCES) \ - $(SWRAST_SOURCES) \ - $(SWRAST_SETUP_SOURCES) \ - $(COMMON_DRIVER_SOURCES)\ - $(ASM_C_SOURCES) - -MESA_CXX_SOURCES = \ - $(SHADER_CXX_SOURCES) - -# Sources for building Gallium drivers -MESA_GALLIUM_SOURCES = \ - $(MAIN_SOURCES) \ - $(MATH_SOURCES) \ - $(VBO_SOURCES) \ - $(STATETRACKER_SOURCES) \ - $(PROGRAM_SOURCES) \ - ppc/common_ppc.c \ - x86/common_x86.c - -MESA_GALLIUM_CXX_SOURCES = \ - $(SHADER_CXX_SOURCES) - -# All the core C sources, for dependency checking -ALL_SOURCES = \ - $(MESA_SOURCES) \ - $(MESA_CXX_SOURCES) \ - $(MESA_ASM_SOURCES) \ - $(STATETRACKER_SOURCES) - - -### Object files - -MESA_OBJECTS = \ - $(MESA_SOURCES:.c=.o) \ - $(MESA_CXX_SOURCES:.cpp=.o) \ - $(MESA_ASM_SOURCES:.S=.o) - -MESA_GALLIUM_OBJECTS = \ - $(MESA_GALLIUM_SOURCES:.c=.o) \ - $(MESA_GALLIUM_CXX_SOURCES:.cpp=.o) \ - $(MESA_ASM_SOURCES:.S=.o) - - -COMMON_DRIVER_OBJECTS = $(COMMON_DRIVER_SOURCES:.c=.o) - - -### Other archives/libraries - -GLSL_LIBS = \ - $(TOP)/src/glsl/libglsl.a - - -### Include directories - -INCLUDE_DIRS = \ - -I$(TOP)/include \ - -I$(TOP)/src/glsl \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/mapi \ - -I$(TOP)/src/gallium/include \ - -I$(TOP)/src/gallium/auxiliary +### Lists of source files, included by Makefiles + +# this is part of MAIN_SOURCES +MAIN_ES_SOURCES = \ + main/api_exec_es1.c \ + main/api_exec_es2.c + +MAIN_SOURCES = \ + main/api_arrayelt.c \ + main/api_exec.c \ + main/api_loopback.c \ + main/api_noop.c \ + main/api_validate.c \ + main/accum.c \ + main/arbprogram.c \ + main/atifragshader.c \ + main/attrib.c \ + main/arrayobj.c \ + main/blend.c \ + main/bufferobj.c \ + main/buffers.c \ + main/clear.c \ + main/clip.c \ + main/colortab.c \ + main/condrender.c \ + main/context.c \ + main/convolve.c \ + main/cpuinfo.c \ + main/debug.c \ + main/depth.c \ + main/depthstencil.c \ + main/dlist.c \ + main/dlopen.c \ + main/drawpix.c \ + main/drawtex.c \ + main/enable.c \ + main/enums.c \ + main/eval.c \ + main/execmem.c \ + main/extensions.c \ + main/fbobject.c \ + main/feedback.c \ + main/ffvertex_prog.c \ + main/fog.c \ + main/formats.c \ + main/framebuffer.c \ + main/get.c \ + main/getstring.c \ + main/hash.c \ + main/hint.c \ + main/histogram.c \ + main/image.c \ + main/imports.c \ + main/light.c \ + main/lines.c \ + main/matrix.c \ + main/mipmap.c \ + main/mm.c \ + main/multisample.c \ + main/nvprogram.c \ + main/pack.c \ + main/pixel.c \ + main/pixelstore.c \ + main/pixeltransfer.c \ + main/points.c \ + main/polygon.c \ + main/queryobj.c \ + main/querymatrix.c \ + main/rastpos.c \ + main/readpix.c \ + main/remap.c \ + main/renderbuffer.c \ + main/scissor.c \ + main/shaderapi.c \ + main/shaderobj.c \ + main/shared.c \ + main/state.c \ + main/stencil.c \ + main/syncobj.c \ + main/texcompress.c \ + main/texcompress_rgtc.c \ + main/texcompress_s3tc.c \ + main/texcompress_fxt1.c \ + main/texenv.c \ + main/texenvprogram.c \ + main/texfetch.c \ + main/texformat.c \ + main/texgen.c \ + main/texgetimage.c \ + main/teximage.c \ + main/texobj.c \ + main/texpal.c \ + main/texparam.c \ + main/texrender.c \ + main/texstate.c \ + main/texstore.c \ + main/transformfeedback.c \ + main/uniforms.c \ + main/varray.c \ + main/version.c \ + main/viewport.c \ + main/vtxfmt.c \ + $(MAIN_ES_SOURCES) + +MATH_SOURCES = \ + math/m_debug_clip.c \ + math/m_debug_norm.c \ + math/m_debug_xform.c \ + math/m_eval.c \ + math/m_matrix.c \ + math/m_translate.c \ + math/m_vector.c + +MATH_XFORM_SOURCES = \ + math/m_xform.c + +SWRAST_SOURCES = \ + swrast/s_aaline.c \ + swrast/s_aatriangle.c \ + swrast/s_accum.c \ + swrast/s_alpha.c \ + swrast/s_atifragshader.c \ + swrast/s_bitmap.c \ + swrast/s_blend.c \ + swrast/s_blit.c \ + swrast/s_clear.c \ + swrast/s_copypix.c \ + swrast/s_context.c \ + swrast/s_depth.c \ + swrast/s_drawpix.c \ + swrast/s_feedback.c \ + swrast/s_fog.c \ + swrast/s_fragprog.c \ + swrast/s_lines.c \ + swrast/s_logic.c \ + swrast/s_masking.c \ + swrast/s_points.c \ + swrast/s_readpix.c \ + swrast/s_span.c \ + swrast/s_stencil.c \ + swrast/s_texcombine.c \ + swrast/s_texfilter.c \ + swrast/s_triangle.c \ + swrast/s_zoom.c + +SWRAST_SETUP_SOURCES = \ + swrast_setup/ss_context.c \ + swrast_setup/ss_triangle.c + +TNL_SOURCES = \ + tnl/t_context.c \ + tnl/t_pipeline.c \ + tnl/t_draw.c \ + tnl/t_rasterpos.c \ + tnl/t_vb_program.c \ + tnl/t_vb_render.c \ + tnl/t_vb_texgen.c \ + tnl/t_vb_texmat.c \ + tnl/t_vb_vertex.c \ + tnl/t_vb_fog.c \ + tnl/t_vb_light.c \ + tnl/t_vb_normals.c \ + tnl/t_vb_points.c \ + tnl/t_vp_build.c \ + tnl/t_vertex.c \ + tnl/t_vertex_sse.c \ + tnl/t_vertex_generic.c + +VBO_SOURCES = \ + vbo/vbo_context.c \ + vbo/vbo_exec.c \ + vbo/vbo_exec_api.c \ + vbo/vbo_exec_array.c \ + vbo/vbo_exec_draw.c \ + vbo/vbo_exec_eval.c \ + vbo/vbo_rebase.c \ + vbo/vbo_split.c \ + vbo/vbo_split_copy.c \ + vbo/vbo_split_inplace.c \ + vbo/vbo_save.c \ + vbo/vbo_save_api.c \ + vbo/vbo_save_draw.c \ + vbo/vbo_save_loopback.c + +STATETRACKER_SOURCES = \ + state_tracker/st_atom.c \ + state_tracker/st_atom_blend.c \ + state_tracker/st_atom_clip.c \ + state_tracker/st_atom_constbuf.c \ + state_tracker/st_atom_depth.c \ + state_tracker/st_atom_framebuffer.c \ + state_tracker/st_atom_msaa.c \ + state_tracker/st_atom_pixeltransfer.c \ + state_tracker/st_atom_sampler.c \ + state_tracker/st_atom_scissor.c \ + state_tracker/st_atom_shader.c \ + state_tracker/st_atom_rasterizer.c \ + state_tracker/st_atom_stipple.c \ + state_tracker/st_atom_texture.c \ + state_tracker/st_atom_viewport.c \ + state_tracker/st_cb_accum.c \ + state_tracker/st_cb_bitmap.c \ + state_tracker/st_cb_blit.c \ + state_tracker/st_cb_bufferobjects.c \ + state_tracker/st_cb_clear.c \ + state_tracker/st_cb_condrender.c \ + state_tracker/st_cb_flush.c \ + state_tracker/st_cb_drawpixels.c \ + state_tracker/st_cb_drawtex.c \ + state_tracker/st_cb_eglimage.c \ + state_tracker/st_cb_fbo.c \ + state_tracker/st_cb_feedback.c \ + state_tracker/st_cb_program.c \ + state_tracker/st_cb_queryobj.c \ + state_tracker/st_cb_rasterpos.c \ + state_tracker/st_cb_readpixels.c \ + state_tracker/st_cb_strings.c \ + state_tracker/st_cb_texture.c \ + state_tracker/st_cb_viewport.c \ + state_tracker/st_cb_xformfb.c \ + state_tracker/st_context.c \ + state_tracker/st_debug.c \ + state_tracker/st_draw.c \ + state_tracker/st_draw_feedback.c \ + state_tracker/st_extensions.c \ + state_tracker/st_format.c \ + state_tracker/st_gen_mipmap.c \ + state_tracker/st_manager.c \ + state_tracker/st_mesa_to_tgsi.c \ + state_tracker/st_program.c \ + state_tracker/st_texture.c + +PROGRAM_SOURCES = \ + program/arbprogparse.c \ + program/hash_table.c \ + program/lex.yy.c \ + program/nvfragparse.c \ + program/nvvertparse.c \ + program/program.c \ + program/program_parse.tab.c \ + program/program_parse_extra.c \ + program/prog_cache.c \ + program/prog_execute.c \ + program/prog_instruction.c \ + program/prog_noise.c \ + program/prog_optimize.c \ + program/prog_parameter.c \ + program/prog_parameter_layout.c \ + program/prog_print.c \ + program/prog_statevars.c \ + program/prog_uniform.c \ + program/programopt.c \ + program/register_allocate.c \ + program/symbol_table.c + +SHADER_CXX_SOURCES = \ + program/ir_to_mesa.cpp \ + program/sampler.cpp + +ASM_C_SOURCES = \ + x86/common_x86.c \ + x86/x86_xform.c \ + x86/3dnow.c \ + x86/sse.c \ + x86/rtasm/x86sse.c \ + sparc/sparc.c \ + ppc/common_ppc.c \ + x86-64/x86-64.c + +X86_SOURCES = \ + x86/common_x86_asm.S \ + x86/x86_xform2.S \ + x86/x86_xform3.S \ + x86/x86_xform4.S \ + x86/x86_cliptest.S \ + x86/mmx_blend.S \ + x86/3dnow_xform1.S \ + x86/3dnow_xform2.S \ + x86/3dnow_xform3.S \ + x86/3dnow_xform4.S \ + x86/3dnow_normal.S \ + x86/sse_xform1.S \ + x86/sse_xform2.S \ + x86/sse_xform3.S \ + x86/sse_xform4.S \ + x86/sse_normal.S \ + x86/read_rgba_span_x86.S + +X86-64_SOURCES = \ + x86-64/xform4.S + +SPARC_SOURCES = \ + sparc/clip.S \ + sparc/norm.S \ + sparc/xform.S + +COMMON_DRIVER_SOURCES = \ + drivers/common/driverfuncs.c \ + drivers/common/meta.c + + +# Sources for building non-Gallium drivers +MESA_SOURCES = \ + $(MAIN_SOURCES) \ + $(MATH_SOURCES) \ + $(MATH_XFORM_SOURCES) \ + $(VBO_SOURCES) \ + $(TNL_SOURCES) \ + $(PROGRAM_SOURCES) \ + $(SWRAST_SOURCES) \ + $(SWRAST_SETUP_SOURCES) \ + $(COMMON_DRIVER_SOURCES)\ + $(ASM_C_SOURCES) + +MESA_CXX_SOURCES = \ + $(SHADER_CXX_SOURCES) + +# Sources for building Gallium drivers +MESA_GALLIUM_SOURCES = \ + $(MAIN_SOURCES) \ + $(MATH_SOURCES) \ + $(VBO_SOURCES) \ + $(STATETRACKER_SOURCES) \ + $(PROGRAM_SOURCES) \ + ppc/common_ppc.c \ + x86/common_x86.c + +MESA_GALLIUM_CXX_SOURCES = \ + $(SHADER_CXX_SOURCES) + +# All the core C sources, for dependency checking +ALL_SOURCES = \ + $(MESA_SOURCES) \ + $(MESA_CXX_SOURCES) \ + $(MESA_ASM_SOURCES) \ + $(STATETRACKER_SOURCES) + + +### Object files + +MESA_OBJECTS = \ + $(MESA_SOURCES:.c=.o) \ + $(MESA_CXX_SOURCES:.cpp=.o) \ + $(MESA_ASM_SOURCES:.S=.o) + +MESA_GALLIUM_OBJECTS = \ + $(MESA_GALLIUM_SOURCES:.c=.o) \ + $(MESA_GALLIUM_CXX_SOURCES:.cpp=.o) \ + $(MESA_ASM_SOURCES:.S=.o) + + +COMMON_DRIVER_OBJECTS = $(COMMON_DRIVER_SOURCES:.c=.o) + + +### Other archives/libraries + +GLSL_LIBS = \ + $(TOP)/src/glsl/libglsl.a + + +### Include directories + +INCLUDE_DIRS = \ + -I$(TOP)/include \ + -I$(TOP)/src/glsl \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/mapi \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/auxiliary diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c index 6530a06ad..c99eafbad 100644 --- a/mesalib/src/mesa/state_tracker/st_draw.c +++ b/mesalib/src/mesa/state_tracker/st_draw.c @@ -579,6 +579,7 @@ st_validate_varrays(struct gl_context *ctx, if (is_interleaved_arrays(vp, vpv, arrays)) { setup_interleaved_attribs(ctx, vp, vpv, arrays, vbuffer, velements, max_index); + num_vbuffers = 1; num_velements = vpv->num_inputs; if (num_velements == 0) @@ -645,6 +646,7 @@ st_draw_vbo(struct gl_context *ctx, for (i = 0; i < nr_prims; i++) { min_index = MIN2(min_index, prims[i].start); max_index = MAX2(max_index, prims[i].start + prims[i].count - 1); + max_index = MAX2(max_index, prims[i].num_instances); } } diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index b1ede1c8b..d2098987d 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -1,482 +1,498 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * Copyright (c) 2008 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "main/imports.h" -#include "main/context.h" -#include "main/macros.h" -#include "main/mfeatures.h" - -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_screen.h" - -#include "st_context.h" -#include "st_extensions.h" - - -static int _min(int a, int b) -{ - return (a < b) ? a : b; -} - -static float _maxf(float a, float b) -{ - return (a > b) ? a : b; -} - -static int _clamp(int a, int min, int max) -{ - if (a < min) - return min; - else if (a > max) - return max; - else - return a; -} - - -/** - * Query driver to get implementation limits. - * Note that we have to limit/clamp against Mesa's internal limits too. - */ -void st_init_limits(struct st_context *st) -{ - struct pipe_screen *screen = st->pipe->screen; - struct gl_constants *c = &st->ctx->Const; - gl_shader_type sh; - - c->MaxTextureLevels - = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), - MAX_TEXTURE_LEVELS); - - c->Max3DTextureLevels - = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS), - MAX_3D_TEXTURE_LEVELS); - - c->MaxCubeTextureLevels - = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS), - MAX_CUBE_TEXTURE_LEVELS); - - c->MaxTextureRectSize - = _min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE); - - c->MaxTextureImageUnits - = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS), - MAX_TEXTURE_IMAGE_UNITS); - - c->MaxVertexTextureImageUnits - = _min(screen->get_param(screen, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS), - MAX_VERTEX_TEXTURE_IMAGE_UNITS); - - c->MaxCombinedTextureImageUnits - = _min(screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SAMPLERS), - MAX_COMBINED_TEXTURE_IMAGE_UNITS); - - c->MaxTextureCoordUnits - = _min(c->MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS); - - c->MaxTextureUnits = _min(c->MaxTextureImageUnits, c->MaxTextureCoordUnits); - - c->MaxDrawBuffers - = _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), - 1, MAX_DRAW_BUFFERS); - - c->MaxLineWidth - = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH)); - c->MaxLineWidthAA - = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH_AA)); - - c->MaxPointSize - = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH)); - c->MaxPointSizeAA - = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH_AA)); - /* called after _mesa_create_context/_mesa_init_point, fix default user - * settable max point size up - */ - st->ctx->Point.MaxSize = MAX2(c->MaxPointSize, c->MaxPointSizeAA); - /* these are not queryable. Note that GL basically mandates a 1.0 minimum - * for non-aa sizes, but we can go down to 0.0 for aa points. - */ - c->MinPointSize = 1.0f; - c->MinPointSizeAA = 0.0f; - - c->MaxTextureMaxAnisotropy - = _maxf(2.0f, screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_ANISOTROPY)); - - c->MaxTextureLodBias - = screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_LOD_BIAS); - - c->MaxDrawBuffers - = CLAMP(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), - 1, MAX_DRAW_BUFFERS); - - /* Quads always follow GL provoking rules. */ - c->QuadsFollowProvokingVertexConvention = GL_FALSE; - - for (sh = 0; sh < MESA_SHADER_TYPES; ++sh) { - struct gl_shader_compiler_options *options = - &st->ctx->ShaderCompilerOptions[sh]; - struct gl_program_constants *pc; - - switch (sh) { - case PIPE_SHADER_FRAGMENT: - pc = &c->FragmentProgram; - break; - case PIPE_SHADER_VERTEX: - pc = &c->VertexProgram; - break; - case PIPE_SHADER_GEOMETRY: - pc = &c->GeometryProgram; - break; - default: - assert(0); - continue; - } - - pc->MaxNativeInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS); - pc->MaxNativeAluInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS); - pc->MaxNativeTexInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS); - pc->MaxNativeTexIndirections = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS); - pc->MaxNativeAttribs = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INPUTS); - pc->MaxNativeTemps = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEMPS); - pc->MaxNativeAddressRegs = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ADDRS); - pc->MaxNativeParameters = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONSTS); - pc->MaxUniformComponents = 4 * MIN2(pc->MaxNativeParameters, MAX_UNIFORMS); - - options->EmitNoNoise = TRUE; - - /* TODO: make these more fine-grained if anyone needs it */ - options->EmitNoIfs = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH); - options->EmitNoLoops = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH); - options->EmitNoFunctions = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES); - options->EmitNoMainReturn = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES); - - options->EmitNoCont = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED); - - options->EmitNoIndirectInput = !screen->get_shader_param(screen, sh, - PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR); - options->EmitNoIndirectOutput = !screen->get_shader_param(screen, sh, - PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR); - options->EmitNoIndirectTemp = !screen->get_shader_param(screen, sh, - PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR); - options->EmitNoIndirectUniform = !screen->get_shader_param(screen, sh, - PIPE_SHADER_CAP_INDIRECT_CONST_ADDR); - - if(options->EmitNoLoops) - options->MaxUnrollIterations = MIN2(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS), 65536); - } - - /* PIPE_CAP_MAX_FS_INPUTS specifies the number of COLORn + GENERICn inputs - * and is set in MaxNativeAttribs. It's always 2 colors + N generic - * attributes. The GLSL compiler never uses COLORn for varyings, so we - * subtract the 2 colors to get the maximum number of varyings (generic - * attributes) supported by a driver. */ - c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_MAX_INPUTS) - 2; - c->MaxVarying = MIN2(c->MaxVarying, MAX_VARYING); - - /* XXX we'll need a better query here someday */ - if (screen->get_param(screen, PIPE_CAP_GLSL)) { - c->GLSLVersion = 120; - } -} - - -/** - * Use pipe_screen::get_param() to query PIPE_CAP_ values to determine - * which GL extensions are supported. - * Quite a few extensions are always supported because they are standard - * features or can be built on top of other gallium features. - * Some fine tuning may still be needed. - */ -void st_init_extensions(struct st_context *st) -{ - struct pipe_screen *screen = st->pipe->screen; - struct gl_context *ctx = st->ctx; - - /* - * Extensions that are supported by all Gallium drivers: - */ - ctx->Extensions.ARB_copy_buffer = GL_TRUE; - ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE; - ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; - ctx->Extensions.ARB_fragment_program = GL_TRUE; - ctx->Extensions.ARB_half_float_pixel = GL_TRUE; - ctx->Extensions.ARB_map_buffer_range = GL_TRUE; - ctx->Extensions.ARB_multisample = GL_TRUE; - ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; /* XXX temp */ - ctx->Extensions.ARB_texture_compression = GL_TRUE; - ctx->Extensions.ARB_texture_cube_map = GL_TRUE; - ctx->Extensions.ARB_texture_env_combine = GL_TRUE; - ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; - ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; - ctx->Extensions.ARB_vertex_array_object = GL_TRUE; - ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE; - ctx->Extensions.ARB_vertex_program = GL_TRUE; - ctx->Extensions.ARB_window_pos = GL_TRUE; - - ctx->Extensions.EXT_blend_color = GL_TRUE; - ctx->Extensions.EXT_blend_func_separate = GL_TRUE; - ctx->Extensions.EXT_blend_logic_op = GL_TRUE; - ctx->Extensions.EXT_blend_minmax = GL_TRUE; - ctx->Extensions.EXT_blend_subtract = GL_TRUE; - ctx->Extensions.EXT_framebuffer_blit = GL_TRUE; - ctx->Extensions.EXT_framebuffer_object = GL_TRUE; - ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE; - ctx->Extensions.EXT_fog_coord = GL_TRUE; - ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE; - ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE; - ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; - ctx->Extensions.EXT_point_parameters = GL_TRUE; - ctx->Extensions.EXT_provoking_vertex = GL_TRUE; - ctx->Extensions.EXT_secondary_color = GL_TRUE; - ctx->Extensions.EXT_stencil_wrap = GL_TRUE; - ctx->Extensions.EXT_texture_env_add = GL_TRUE; - ctx->Extensions.EXT_texture_env_combine = GL_TRUE; - ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE; - ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; - ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; - if (ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2) - ctx->Extensions.EXT_texture_format_BGRA8888 = GL_TRUE; - - ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; - - ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE; - - ctx->Extensions.MESA_pack_invert = GL_TRUE; - - ctx->Extensions.NV_blend_square = GL_TRUE; - ctx->Extensions.NV_texgen_reflection = GL_TRUE; - ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; - ctx->Extensions.NV_texture_rectangle = GL_TRUE; -#if 0 - /* possibly could support the following two */ - ctx->Extensions.NV_vertex_program = GL_TRUE; - ctx->Extensions.NV_vertex_program1_1 = GL_TRUE; -#endif - -#if FEATURE_OES_EGL_image - ctx->Extensions.OES_EGL_image = GL_TRUE; -#endif -#if FEATURE_OES_draw_texture - ctx->Extensions.OES_draw_texture = GL_TRUE; -#endif - - ctx->Extensions.SGIS_generate_mipmap = GL_TRUE; - - /* - * Extensions that depend on the driver/hardware: - */ - if (screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS) > 0) { - ctx->Extensions.ARB_draw_buffers = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_TEXTURE_SWIZZLE) > 0) { - ctx->Extensions.EXT_texture_swizzle = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_GLSL)) { - ctx->Extensions.ARB_fragment_shader = GL_TRUE; - ctx->Extensions.ARB_vertex_shader = GL_TRUE; - ctx->Extensions.ARB_shader_objects = GL_TRUE; - ctx->Extensions.ARB_shading_language_100 = GL_TRUE; - ctx->Extensions.ARB_explicit_attrib_location = GL_TRUE; - ctx->Extensions.EXT_separate_shader_objects = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_REPEAT) > 0) { - ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_BLEND_EQUATION_SEPARATE)) { - ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_CLAMP) > 0) { - ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE; - ctx->Extensions.ATI_texture_mirror_once = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_NPOT_TEXTURES)) { - ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS) > 1) { - ctx->Extensions.ARB_multitexture = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_TWO_SIDED_STENCIL)) { - ctx->Extensions.ATI_separate_stencil = GL_TRUE; - ctx->Extensions.EXT_stencil_two_side = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_ANISOTROPIC_FILTER)) { - ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_POINT_SPRITE)) { - ctx->Extensions.ARB_point_sprite = GL_TRUE; - /* GL_NV_point_sprite is not supported by gallium because we don't - * support the GL_POINT_SPRITE_R_MODE_NV option. - */ - } - - if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY)) { - ctx->Extensions.ARB_occlusion_query = GL_TRUE; - ctx->Extensions.ARB_occlusion_query2 = GL_TRUE; - } - if (screen->get_param(screen, PIPE_CAP_TIMER_QUERY)) { - ctx->Extensions.EXT_timer_query = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_TEXTURE_SHADOW_MAP)) { - ctx->Extensions.ARB_depth_texture = GL_TRUE; - ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE; - ctx->Extensions.ARB_shadow = GL_TRUE; - ctx->Extensions.EXT_shadow_funcs = GL_TRUE; - /*ctx->Extensions.ARB_shadow_ambient = GL_TRUE;*/ - } - - /* GL_EXT_packed_depth_stencil requires both the ability to render to - * a depth/stencil buffer and texture from depth/stencil source. - */ - if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, - PIPE_TEXTURE_2D, 0, - PIPE_BIND_DEPTH_STENCIL, 0) && - screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, - PIPE_TEXTURE_2D, 0, - PIPE_BIND_SAMPLER_VIEW, 0)) { - ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; - } - else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, - PIPE_TEXTURE_2D, 0, - PIPE_BIND_DEPTH_STENCIL, 0) && - screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, - PIPE_TEXTURE_2D, 0, - PIPE_BIND_SAMPLER_VIEW, 0)) { - ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; - } - - /* sRGB support */ - if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB, - PIPE_TEXTURE_2D, 0, - PIPE_BIND_SAMPLER_VIEW, 0) || - screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB, - PIPE_TEXTURE_2D, 0, - PIPE_BIND_SAMPLER_VIEW, 0)) { - ctx->Extensions.EXT_texture_sRGB = GL_TRUE; - ctx->Extensions.EXT_texture_sRGB_decode = GL_TRUE; - if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB, - PIPE_TEXTURE_2D, 0, - PIPE_BIND_RENDER_TARGET, 0) || - screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB, - PIPE_TEXTURE_2D, 0, - PIPE_BIND_RENDER_TARGET, 0)) { - ctx->Extensions.EXT_framebuffer_sRGB = GL_TRUE; - ctx->Const.sRGBCapable = GL_TRUE; - } - } - - if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8_UNORM, - PIPE_TEXTURE_2D, 0, - PIPE_BIND_SAMPLER_VIEW, 0)) { - ctx->Extensions.ARB_texture_rg = GL_TRUE; - } - - /* s3tc support */ - if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, - PIPE_TEXTURE_2D, 0, - PIPE_BIND_SAMPLER_VIEW, 0) && - ctx->Mesa_DXTn) { - ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE; - ctx->Extensions.S3_s3tc = GL_TRUE; - } - - /* ycbcr support */ - if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, - PIPE_TEXTURE_2D, 0, - PIPE_BIND_SAMPLER_VIEW, 0) || - screen->is_format_supported(screen, PIPE_FORMAT_YUYV, - PIPE_TEXTURE_2D, 0, - PIPE_BIND_SAMPLER_VIEW, 0)) { - ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; - } - - /* GL_EXT_texture_array */ - if (screen->get_param(screen, PIPE_CAP_ARRAY_TEXTURES)) { - ctx->Extensions.EXT_texture_array = GL_TRUE; - ctx->Extensions.MESA_texture_array = GL_TRUE; - } - - /* GL_ARB_framebuffer_object */ - if (ctx->Extensions.EXT_packed_depth_stencil) { - /* we support always support GL_EXT_framebuffer_blit */ - ctx->Extensions.ARB_framebuffer_object = GL_TRUE; - } - - if (st->pipe->render_condition) { - ctx->Extensions.NV_conditional_render = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_ENABLE)) { - ctx->Extensions.EXT_draw_buffers2 = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_FUNC)) { - ctx->Extensions.ARB_draw_buffers_blend = GL_TRUE; - } - - /* GL_ARB_half_float_vertex */ - if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_FLOAT, - PIPE_BUFFER, 0, - PIPE_BIND_VERTEX_BUFFER, 0)) { - ctx->Extensions.ARB_half_float_vertex = GL_TRUE; - } - - if (screen->get_shader_param(screen, PIPE_SHADER_GEOMETRY, PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) { -#if 0 /* XXX re-enable when GLSL compiler again supports geometry shaders */ - ctx->Extensions.ARB_geometry_shader4 = GL_TRUE; -#endif - } - - if (screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART)) { - ctx->Extensions.NV_primitive_restart = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_DEPTH_CLAMP)) { - ctx->Extensions.ARB_depth_clamp = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT)) { - ctx->Extensions.ARB_shader_stencil_export = GL_TRUE; - } - - if (screen->get_param(screen, PIPE_CAP_INSTANCED_DRAWING)) { - ctx->Extensions.ARB_draw_instanced = GL_TRUE; - ctx->Extensions.ARB_instanced_arrays = GL_TRUE; - } -} +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright (c) 2008 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "main/imports.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/mfeatures.h" + +#include "pipe/p_context.h" +#include "pipe/p_defines.h" +#include "pipe/p_screen.h" + +#include "st_context.h" +#include "st_extensions.h" + + +static int _min(int a, int b) +{ + return (a < b) ? a : b; +} + +static float _maxf(float a, float b) +{ + return (a > b) ? a : b; +} + +static int _clamp(int a, int min, int max) +{ + if (a < min) + return min; + else if (a > max) + return max; + else + return a; +} + + +/** + * Query driver to get implementation limits. + * Note that we have to limit/clamp against Mesa's internal limits too. + */ +void st_init_limits(struct st_context *st) +{ + struct pipe_screen *screen = st->pipe->screen; + struct gl_constants *c = &st->ctx->Const; + gl_shader_type sh; + + c->MaxTextureLevels + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), + MAX_TEXTURE_LEVELS); + + c->Max3DTextureLevels + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS), + MAX_3D_TEXTURE_LEVELS); + + c->MaxCubeTextureLevels + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS), + MAX_CUBE_TEXTURE_LEVELS); + + c->MaxTextureRectSize + = _min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE); + + c->MaxTextureImageUnits + = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS), + MAX_TEXTURE_IMAGE_UNITS); + + c->MaxVertexTextureImageUnits + = _min(screen->get_param(screen, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS), + MAX_VERTEX_TEXTURE_IMAGE_UNITS); + + c->MaxCombinedTextureImageUnits + = _min(screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SAMPLERS), + MAX_COMBINED_TEXTURE_IMAGE_UNITS); + + c->MaxTextureCoordUnits + = _min(c->MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS); + + c->MaxTextureUnits = _min(c->MaxTextureImageUnits, c->MaxTextureCoordUnits); + + c->MaxDrawBuffers + = _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), + 1, MAX_DRAW_BUFFERS); + + c->MaxLineWidth + = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH)); + c->MaxLineWidthAA + = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_LINE_WIDTH_AA)); + + c->MaxPointSize + = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH)); + c->MaxPointSizeAA + = _maxf(1.0f, screen->get_paramf(screen, PIPE_CAP_MAX_POINT_WIDTH_AA)); + /* called after _mesa_create_context/_mesa_init_point, fix default user + * settable max point size up + */ + st->ctx->Point.MaxSize = MAX2(c->MaxPointSize, c->MaxPointSizeAA); + /* these are not queryable. Note that GL basically mandates a 1.0 minimum + * for non-aa sizes, but we can go down to 0.0 for aa points. + */ + c->MinPointSize = 1.0f; + c->MinPointSizeAA = 0.0f; + + c->MaxTextureMaxAnisotropy + = _maxf(2.0f, screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_ANISOTROPY)); + + c->MaxTextureLodBias + = screen->get_paramf(screen, PIPE_CAP_MAX_TEXTURE_LOD_BIAS); + + c->MaxDrawBuffers + = CLAMP(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS), + 1, MAX_DRAW_BUFFERS); + + /* Quads always follow GL provoking rules. */ + c->QuadsFollowProvokingVertexConvention = GL_FALSE; + + for (sh = 0; sh < MESA_SHADER_TYPES; ++sh) { + struct gl_shader_compiler_options *options = + &st->ctx->ShaderCompilerOptions[sh]; + struct gl_program_constants *pc; + + switch (sh) { + case PIPE_SHADER_FRAGMENT: + pc = &c->FragmentProgram; + break; + case PIPE_SHADER_VERTEX: + pc = &c->VertexProgram; + break; + case PIPE_SHADER_GEOMETRY: + pc = &c->GeometryProgram; + break; + default: + assert(0); + continue; + } + + pc->MaxNativeInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS); + pc->MaxNativeAluInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS); + pc->MaxNativeTexInstructions = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS); + pc->MaxNativeTexIndirections = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS); + pc->MaxNativeAttribs = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INPUTS); + pc->MaxNativeTemps = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_TEMPS); + pc->MaxNativeAddressRegs = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ADDRS); + pc->MaxNativeParameters = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONSTS); + pc->MaxUniformComponents = 4 * MIN2(pc->MaxNativeParameters, MAX_UNIFORMS); + + options->EmitNoNoise = TRUE; + + /* TODO: make these more fine-grained if anyone needs it */ + options->EmitNoIfs = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH); + options->EmitNoLoops = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH); + options->EmitNoFunctions = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES); + options->EmitNoMainReturn = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES); + + options->EmitNoCont = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED); + + options->EmitNoIndirectInput = !screen->get_shader_param(screen, sh, + PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR); + options->EmitNoIndirectOutput = !screen->get_shader_param(screen, sh, + PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR); + options->EmitNoIndirectTemp = !screen->get_shader_param(screen, sh, + PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR); + options->EmitNoIndirectUniform = !screen->get_shader_param(screen, sh, + PIPE_SHADER_CAP_INDIRECT_CONST_ADDR); + + if(options->EmitNoLoops) + options->MaxUnrollIterations = MIN2(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS), 65536); + } + + /* PIPE_CAP_MAX_FS_INPUTS specifies the number of COLORn + GENERICn inputs + * and is set in MaxNativeAttribs. It's always 2 colors + N generic + * attributes. The GLSL compiler never uses COLORn for varyings, so we + * subtract the 2 colors to get the maximum number of varyings (generic + * attributes) supported by a driver. */ + c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_MAX_INPUTS) - 2; + c->MaxVarying = MIN2(c->MaxVarying, MAX_VARYING); + + /* XXX we'll need a better query here someday */ + if (screen->get_param(screen, PIPE_CAP_GLSL)) { + c->GLSLVersion = 120; + } +} + + +/** + * Use pipe_screen::get_param() to query PIPE_CAP_ values to determine + * which GL extensions are supported. + * Quite a few extensions are always supported because they are standard + * features or can be built on top of other gallium features. + * Some fine tuning may still be needed. + */ +void st_init_extensions(struct st_context *st) +{ + struct pipe_screen *screen = st->pipe->screen; + struct gl_context *ctx = st->ctx; + + /* + * Extensions that are supported by all Gallium drivers: + */ + ctx->Extensions.ARB_copy_buffer = GL_TRUE; + ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE; + ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; + ctx->Extensions.ARB_fragment_program = GL_TRUE; + ctx->Extensions.ARB_half_float_pixel = GL_TRUE; + ctx->Extensions.ARB_map_buffer_range = GL_TRUE; + ctx->Extensions.ARB_multisample = GL_TRUE; + ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; /* XXX temp */ + ctx->Extensions.ARB_texture_compression = GL_TRUE; + ctx->Extensions.ARB_texture_cube_map = GL_TRUE; + ctx->Extensions.ARB_texture_env_combine = GL_TRUE; + ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; + ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; + ctx->Extensions.ARB_vertex_array_object = GL_TRUE; + ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE; + ctx->Extensions.ARB_vertex_program = GL_TRUE; + ctx->Extensions.ARB_window_pos = GL_TRUE; + + ctx->Extensions.EXT_blend_color = GL_TRUE; + ctx->Extensions.EXT_blend_func_separate = GL_TRUE; + ctx->Extensions.EXT_blend_logic_op = GL_TRUE; + ctx->Extensions.EXT_blend_minmax = GL_TRUE; + ctx->Extensions.EXT_blend_subtract = GL_TRUE; + ctx->Extensions.EXT_framebuffer_blit = GL_TRUE; + ctx->Extensions.EXT_framebuffer_object = GL_TRUE; + ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE; + ctx->Extensions.EXT_fog_coord = GL_TRUE; + ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE; + ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE; + ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; + ctx->Extensions.EXT_point_parameters = GL_TRUE; + ctx->Extensions.EXT_provoking_vertex = GL_TRUE; + ctx->Extensions.EXT_secondary_color = GL_TRUE; + ctx->Extensions.EXT_stencil_wrap = GL_TRUE; + ctx->Extensions.EXT_texture_env_add = GL_TRUE; + ctx->Extensions.EXT_texture_env_combine = GL_TRUE; + ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE; + ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; + ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; + if (ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2) + ctx->Extensions.EXT_texture_format_BGRA8888 = GL_TRUE; + + ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; + + ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE; + + ctx->Extensions.MESA_pack_invert = GL_TRUE; + + ctx->Extensions.NV_blend_square = GL_TRUE; + ctx->Extensions.NV_texgen_reflection = GL_TRUE; + ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; + ctx->Extensions.NV_texture_rectangle = GL_TRUE; +#if 0 + /* possibly could support the following two */ + ctx->Extensions.NV_vertex_program = GL_TRUE; + ctx->Extensions.NV_vertex_program1_1 = GL_TRUE; +#endif + +#if FEATURE_OES_EGL_image + ctx->Extensions.OES_EGL_image = GL_TRUE; +#endif +#if FEATURE_OES_draw_texture + ctx->Extensions.OES_draw_texture = GL_TRUE; +#endif + + ctx->Extensions.SGIS_generate_mipmap = GL_TRUE; + + /* + * Extensions that depend on the driver/hardware: + */ + if (screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS) > 0) { + ctx->Extensions.ARB_draw_buffers = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_TEXTURE_SWIZZLE) > 0) { + ctx->Extensions.EXT_texture_swizzle = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_GLSL)) { + ctx->Extensions.ARB_fragment_shader = GL_TRUE; + ctx->Extensions.ARB_vertex_shader = GL_TRUE; + ctx->Extensions.ARB_shader_objects = GL_TRUE; + ctx->Extensions.ARB_shading_language_100 = GL_TRUE; + ctx->Extensions.ARB_explicit_attrib_location = GL_TRUE; + ctx->Extensions.EXT_separate_shader_objects = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_REPEAT) > 0) { + ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_BLEND_EQUATION_SEPARATE)) { + ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_CLAMP) > 0) { + ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE; + ctx->Extensions.ATI_texture_mirror_once = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_NPOT_TEXTURES)) { + ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS) > 1) { + ctx->Extensions.ARB_multitexture = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_TWO_SIDED_STENCIL)) { + ctx->Extensions.ATI_separate_stencil = GL_TRUE; + ctx->Extensions.EXT_stencil_two_side = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_ANISOTROPIC_FILTER)) { + ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_POINT_SPRITE)) { + ctx->Extensions.ARB_point_sprite = GL_TRUE; + /* GL_NV_point_sprite is not supported by gallium because we don't + * support the GL_POINT_SPRITE_R_MODE_NV option. + */ + } + + if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY)) { + ctx->Extensions.ARB_occlusion_query = GL_TRUE; + ctx->Extensions.ARB_occlusion_query2 = GL_TRUE; + } + if (screen->get_param(screen, PIPE_CAP_TIMER_QUERY)) { + ctx->Extensions.EXT_timer_query = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_TEXTURE_SHADOW_MAP)) { + ctx->Extensions.ARB_depth_texture = GL_TRUE; + ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE; + ctx->Extensions.ARB_shadow = GL_TRUE; + ctx->Extensions.EXT_shadow_funcs = GL_TRUE; + /*ctx->Extensions.ARB_shadow_ambient = GL_TRUE;*/ + } + + /* GL_EXT_packed_depth_stencil requires both the ability to render to + * a depth/stencil buffer and texture from depth/stencil source. + */ + if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_DEPTH_STENCIL, 0) && + screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0)) { + ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; + } + else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_DEPTH_STENCIL, 0) && + screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0)) { + ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; + } + + /* sRGB support */ + if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) || + screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0)) { + ctx->Extensions.EXT_texture_sRGB = GL_TRUE; + ctx->Extensions.EXT_texture_sRGB_decode = GL_TRUE; + if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_RENDER_TARGET, 0) || + screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_RENDER_TARGET, 0)) { + ctx->Extensions.EXT_framebuffer_sRGB = GL_TRUE; + ctx->Const.sRGBCapable = GL_TRUE; + } + } + + if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8_UNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0)) { + ctx->Extensions.ARB_texture_rg = GL_TRUE; + } + + /* s3tc support */ + if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) && + ctx->Mesa_DXTn) { + ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE; + ctx->Extensions.S3_s3tc = GL_TRUE; + } + + if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_UNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) && + screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_SNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) && + screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_UNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) && + screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_SNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) + ) { + ctx->Extensions.ARB_texture_compression_rgtc = GL_TRUE; + } + + /* ycbcr support */ + if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0) || + screen->is_format_supported(screen, PIPE_FORMAT_YUYV, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0)) { + ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; + } + + /* GL_EXT_texture_array */ + if (screen->get_param(screen, PIPE_CAP_ARRAY_TEXTURES)) { + ctx->Extensions.EXT_texture_array = GL_TRUE; + ctx->Extensions.MESA_texture_array = GL_TRUE; + } + + /* GL_ARB_framebuffer_object */ + if (ctx->Extensions.EXT_packed_depth_stencil) { + /* we support always support GL_EXT_framebuffer_blit */ + ctx->Extensions.ARB_framebuffer_object = GL_TRUE; + } + + if (st->pipe->render_condition) { + ctx->Extensions.NV_conditional_render = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_ENABLE)) { + ctx->Extensions.EXT_draw_buffers2 = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_FUNC)) { + ctx->Extensions.ARB_draw_buffers_blend = GL_TRUE; + } + + /* GL_ARB_half_float_vertex */ + if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_FLOAT, + PIPE_BUFFER, 0, + PIPE_BIND_VERTEX_BUFFER, 0)) { + ctx->Extensions.ARB_half_float_vertex = GL_TRUE; + } + + if (screen->get_shader_param(screen, PIPE_SHADER_GEOMETRY, PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) { +#if 0 /* XXX re-enable when GLSL compiler again supports geometry shaders */ + ctx->Extensions.ARB_geometry_shader4 = GL_TRUE; +#endif + } + + if (screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART)) { + ctx->Extensions.NV_primitive_restart = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_DEPTH_CLAMP)) { + ctx->Extensions.ARB_depth_clamp = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT)) { + ctx->Extensions.ARB_shader_stencil_export = GL_TRUE; + } + + if (screen->get_param(screen, PIPE_CAP_INSTANCED_DRAWING)) { + ctx->Extensions.ARB_draw_instanced = GL_TRUE; + ctx->Extensions.ARB_instanced_arrays = GL_TRUE; + } +} diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c index 577ee6189..c58ec9267 100644 --- a/mesalib/src/mesa/state_tracker/st_format.c +++ b/mesalib/src/mesa/state_tracker/st_format.c @@ -241,6 +241,14 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) case MESA_FORMAT_RGBA_UINT32: return PIPE_FORMAT_R32G32B32A32_USCALED; + case MESA_FORMAT_RED_RGTC1: + return PIPE_FORMAT_RGTC1_UNORM; + case MESA_FORMAT_SIGNED_RED_RGTC1: + return PIPE_FORMAT_RGTC1_SNORM; + case MESA_FORMAT_RG_RGTC2: + return PIPE_FORMAT_RGTC2_UNORM; + case MESA_FORMAT_SIGNED_RG_RGTC2: + return PIPE_FORMAT_RGTC2_SNORM; default: assert(0); return PIPE_FORMAT_NONE; @@ -380,6 +388,15 @@ st_pipe_format_to_mesa_format(enum pipe_format format) case PIPE_FORMAT_R32G32B32A32_USCALED: return MESA_FORMAT_RGBA_UINT32; + case PIPE_FORMAT_RGTC1_UNORM: + return MESA_FORMAT_RED_RGTC1; + case PIPE_FORMAT_RGTC1_SNORM: + return MESA_FORMAT_SIGNED_RED_RGTC1; + case PIPE_FORMAT_RGTC2_UNORM: + return MESA_FORMAT_RG_RGTC2; + case PIPE_FORMAT_RGTC2_SNORM: + return MESA_FORMAT_SIGNED_RG_RGTC2; + default: assert(0); return MESA_FORMAT_NONE; diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c index 5c68fd78c..c07739f9d 100644 --- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -224,9 +224,9 @@ src_register( struct st_translate *t, case PROGRAM_TEMPORARY: assert(index >= 0); + assert(index < Elements(t->temps)); if (ureg_dst_is_undef(t->temps[index])) t->temps[index] = ureg_DECL_temporary( t->ureg ); - assert(index < Elements(t->temps)); return ureg_src(t->temps[index]); case PROGRAM_NAMED_PARAM: diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac index f3b293940..85d5c980e 100644 --- a/xorg-server/configure.ac +++ b/xorg-server/configure.ac @@ -26,8 +26,8 @@ dnl dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) -AC_INIT([xorg-server], 1.9.99.903, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) -RELEASE_DATE="2011-2-24" +AC_INIT([xorg-server], 1.10.0, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) +RELEASE_DATE="2011-2-25" AC_CONFIG_SRCDIR([Makefile.am]) AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE @@ -2173,6 +2173,8 @@ AC_SUBST([libdir]) AC_SUBST([exec_prefix]) AC_SUBST([prefix]) +AC_CONFIG_COMMANDS([sdksyms], [touch hw/xfree86/loader/sdksyms.dep]) + AC_OUTPUT([ Makefile glx/Makefile @@ -2246,6 +2248,7 @@ hw/xfree86/utils/gtf/Makefile hw/dmx/config/Makefile hw/dmx/config/man/Makefile hw/dmx/doc/Makefile +hw/dmx/doc/doxygen.conf hw/dmx/examples/Makefile hw/dmx/input/Makefile hw/dmx/glxProxy/Makefile diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c index 08eb6c1cd..89294aacb 100644 --- a/xorg-server/dix/devices.c +++ b/xorg-server/dix/devices.c @@ -1,2602 +1,2604 @@ -/************************************************************ - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -********************************************************/ - - - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include -#include "misc.h" -#include "resource.h" -#include -#include -#include "windowstr.h" -#include "inputstr.h" -#include "scrnintstr.h" -#include "cursorstr.h" -#include "dixstruct.h" -#include "ptrveloc.h" -#include "site.h" -#include "xkbsrv.h" -#include "privates.h" -#include "xace.h" -#include "mi.h" - -#include "dispatch.h" -#include "swaprep.h" -#include "dixevents.h" -#include "mipointer.h" -#include "eventstr.h" - -#include -#include -#include -#include -#include -#include "exglobals.h" -#include "exevents.h" -#include "xiquerydevice.h" /* for SizeDeviceClasses */ -#include "xiproperty.h" -#include "enterleave.h" /* for EnterWindow() */ -#include "xserver-properties.h" -#include "xichangehierarchy.h" /* For XISendDeviceHierarchyEvent */ - -/** @file - * This file handles input device-related stuff. - */ - -static void RecalculateMasterButtons(DeviceIntPtr slave); - -static void -DeviceSetTransform(DeviceIntPtr dev, float *transform) -{ - struct pixman_f_transform scale; - double sx, sy; - int x, y; - - /** - * calculate combined transformation matrix: - * - * M = InvScale * Transform * Scale - * - * So we can later transform points using M * p - * - * Where: - * Scale scales coordinates into 0..1 range - * Transform is the user supplied (affine) transform - * InvScale scales coordinates back up into their native range - */ - sx = dev->valuator->axes[0].max_value - dev->valuator->axes[0].min_value; - sy = dev->valuator->axes[1].max_value - dev->valuator->axes[1].min_value; - - /* invscale */ - pixman_f_transform_init_scale(&scale, sx, sy); - scale.m[0][2] = dev->valuator->axes[0].min_value; - scale.m[1][2] = dev->valuator->axes[1].min_value; - - /* transform */ - for (y=0; y<3; y++) - for (x=0; x<3; x++) - dev->transform.m[y][x] = *transform++; - - pixman_f_transform_multiply(&dev->transform, &scale, &dev->transform); - - /* scale */ - pixman_f_transform_init_scale(&scale, 1.0 / sx, 1.0 / sy); - scale.m[0][2] = -dev->valuator->axes[0].min_value / sx; - scale.m[1][2] = -dev->valuator->axes[1].min_value / sy; - - pixman_f_transform_multiply(&dev->transform, &dev->transform, &scale); -} - -/** - * DIX property handler. - */ -static int -DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, - BOOL checkonly) -{ - if (property == XIGetKnownProperty(XI_PROP_ENABLED)) - { - if (prop->format != 8 || prop->type != XA_INTEGER || prop->size != 1) - return BadValue; - - /* Don't allow disabling of VCP/VCK */ - if ((dev == inputInfo.pointer || dev == inputInfo.keyboard) && - !(*(CARD8*)prop->data)) - return BadAccess; - - if (!checkonly) - { - if ((*((CARD8*)prop->data)) && !dev->enabled) - EnableDevice(dev, TRUE); - else if (!(*((CARD8*)prop->data)) && dev->enabled) - DisableDevice(dev, TRUE); - } - } else if (property == XIGetKnownProperty(XI_PROP_TRANSFORM)) - { - float *f = (float*)prop->data; - int i; - - if (prop->format != 32 || prop->size != 9 || - prop->type != XIGetKnownProperty(XATOM_FLOAT)) - return BadValue; - - for (i=0; i<9; i++) - if (!isfinite(f[i])) - return BadValue; - - if (!checkonly) - DeviceSetTransform(dev, f); - } - - return Success; -} - -/* Pair the keyboard to the pointer device. Keyboard events will follow the - * pointer sprite. Only applicable for master devices. - * If the client is set, the request to pair comes from some client. In this - * case, we need to check for access. If the client is NULL, it's from an - * internal automatic pairing, we must always permit this. - */ -static int -PairDevices(ClientPtr client, DeviceIntPtr ptr, DeviceIntPtr kbd) -{ - if (!ptr) - return BadDevice; - - /* Don't allow pairing for slave devices */ - if (!IsMaster(ptr) || !IsMaster(kbd)) - return BadDevice; - - if (ptr->spriteInfo->paired) - return BadDevice; - - if (kbd->spriteInfo->spriteOwner) - { - free(kbd->spriteInfo->sprite); - kbd->spriteInfo->sprite = NULL; - kbd->spriteInfo->spriteOwner = FALSE; - } - - kbd->spriteInfo->sprite = ptr->spriteInfo->sprite; - kbd->spriteInfo->paired = ptr; - ptr->spriteInfo->paired = kbd; - return Success; -} - - -/** - * Find and return the next unpaired MD pointer device. - */ -static DeviceIntPtr -NextFreePointerDevice(void) -{ - DeviceIntPtr dev; - for (dev = inputInfo.devices; dev; dev = dev->next) - if (IsMaster(dev) && - dev->spriteInfo->spriteOwner && - !dev->spriteInfo->paired) - return dev; - return NULL; -} - -/** - * Create a new input device and init it to sane values. The device is added - * to the server's off_devices list. - * - * @param deviceProc Callback for device control function (switch dev on/off). - * @return The newly created device. - */ -DeviceIntPtr -AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart) -{ - DeviceIntPtr dev, *prev; /* not a typo */ - DeviceIntPtr devtmp; - int devid; - char devind[MAXDEVICES]; - BOOL enabled; - float transform[9]; - - /* Find next available id, 0 and 1 are reserved */ - memset(devind, 0, sizeof(char)*MAXDEVICES); - for (devtmp = inputInfo.devices; devtmp; devtmp = devtmp->next) - devind[devtmp->id]++; - for (devtmp = inputInfo.off_devices; devtmp; devtmp = devtmp->next) - devind[devtmp->id]++; - for (devid = 2; devid < MAXDEVICES && devind[devid]; devid++) - ; - - if (devid >= MAXDEVICES) - return (DeviceIntPtr)NULL; - dev = _dixAllocateObjectWithPrivates(sizeof(DeviceIntRec) + sizeof(SpriteInfoRec), - sizeof(DeviceIntRec) + sizeof(SpriteInfoRec), - offsetof(DeviceIntRec, devPrivates), PRIVATE_DEVICE); - if (!dev) - return (DeviceIntPtr)NULL; - dev->id = devid; - dev->public.processInputProc = ProcessOtherEvent; - dev->public.realInputProc = ProcessOtherEvent; - dev->public.enqueueInputProc = EnqueueEvent; - dev->deviceProc = deviceProc; - dev->startup = autoStart; - - /* device grab defaults */ - dev->deviceGrab.grabTime = currentTime; - dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab; - dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab; - - XkbSetExtension(dev, ProcessKeyboardEvent); - - dev->coreEvents = TRUE; - - /* sprite defaults */ - dev->spriteInfo = (SpriteInfoPtr)&dev[1]; - - /* security creation/labeling check - */ - if (XaceHook(XACE_DEVICE_ACCESS, client, dev, DixCreateAccess)) { - free(dev); - return NULL; - } - - inputInfo.numDevices++; - - for (prev = &inputInfo.off_devices; *prev; prev = &(*prev)->next) - ; - *prev = dev; - dev->next = NULL; - - enabled = FALSE; - XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED), - XA_INTEGER, 8, PropModeReplace, 1, &enabled, - FALSE); - XISetDevicePropertyDeletable(dev, XIGetKnownProperty(XI_PROP_ENABLED), FALSE); - - /* unity matrix */ - memset(transform, 0, sizeof(transform)); - transform[0] = transform[4] = transform[8] = 1.0f; - - XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_TRANSFORM), - XIGetKnownProperty(XATOM_FLOAT), 32, - PropModeReplace, 9, transform, FALSE); - XISetDevicePropertyDeletable(dev, XIGetKnownProperty(XI_PROP_TRANSFORM), - FALSE); - - XIRegisterPropertyHandler(dev, DeviceSetProperty, NULL, NULL); - - return dev; -} - -void -SendDevicePresenceEvent(int deviceid, int type) -{ - DeviceIntRec dummyDev; - devicePresenceNotify ev; - - memset(&dummyDev, 0, sizeof(DeviceIntRec)); - ev.type = DevicePresenceNotify; - ev.time = currentTime.milliseconds; - ev.devchange = type; - ev.deviceid = deviceid; - dummyDev.id = XIAllDevices; - SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask, - (xEvent*)&ev, 1); -} - -/** - * Enable the device through the driver, add the device to the device list. - * Switch device ON through the driver and push it onto the global device - * list. Initialize the DIX sprite or pair the device. All clients are - * notified about the device being enabled. - * - * A master pointer device needs to be enabled before a master keyboard - * device. - * - * @param The device to be enabled. - * @param sendevent True if an XI2 event should be sent. - * @return TRUE on success or FALSE otherwise. - */ -Bool -EnableDevice(DeviceIntPtr dev, BOOL sendevent) -{ - DeviceIntPtr *prev; - int ret; - DeviceIntPtr other; - BOOL enabled; - int flags[MAXDEVICES] = {0}; - - for (prev = &inputInfo.off_devices; - *prev && (*prev != dev); - prev = &(*prev)->next) - ; - - if (!dev->spriteInfo->sprite) - { - if (IsMaster(dev)) - { - /* Sprites appear on first root window, so we can hardcode it */ - if (dev->spriteInfo->spriteOwner) - { - InitializeSprite(dev, screenInfo.screens[0]->root); - /* mode doesn't matter */ - EnterWindow(dev, screenInfo.screens[0]->root, NotifyAncestor); - } - else if ((other = NextFreePointerDevice()) == NULL) - { - ErrorF("[dix] cannot find pointer to pair with. " - "This is a bug.\n"); - return FALSE; - } else - PairDevices(NULL, other, dev); - } else - { - if (dev->coreEvents) - other = (IsPointerDevice(dev)) ? inputInfo.pointer : - inputInfo.keyboard; - else - other = NULL; /* auto-float non-core devices */ - AttachDevice(NULL, dev, other); - } - } - - if ((*prev != dev) || !dev->inited || - ((ret = (*dev->deviceProc)(dev, DEVICE_ON)) != Success)) { - ErrorF("[dix] couldn't enable device %d\n", dev->id); - return FALSE; - } - dev->enabled = TRUE; - *prev = dev->next; - - for (prev = &inputInfo.devices; *prev; prev = &(*prev)->next) - ; - *prev = dev; - dev->next = NULL; - - enabled = TRUE; - XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED), - XA_INTEGER, 8, PropModeReplace, 1, &enabled, - TRUE); - - SendDevicePresenceEvent(dev->id, DeviceEnabled); - if (sendevent) - { - flags[dev->id] |= XIDeviceEnabled; - XISendDeviceHierarchyEvent(flags); - } - - RecalculateMasterButtons(dev); - - return TRUE; -} - -/** - * Switch a device off through the driver and push it onto the off_devices - * list. A device will not send events while disabled. All clients are - * notified about the device being disabled. - * - * Master keyboard devices have to be disabled before master pointer devices - * otherwise things turn bad. - * - * @param sendevent True if an XI2 event should be sent. - * @return TRUE on success or FALSE otherwise. - */ -Bool -DisableDevice(DeviceIntPtr dev, BOOL sendevent) -{ - DeviceIntPtr *prev, other; - BOOL enabled; - int flags[MAXDEVICES] = {0}; - - for (prev = &inputInfo.devices; - *prev && (*prev != dev); - prev = &(*prev)->next) - ; - if (*prev != dev) - return FALSE; - - /* float attached devices */ - if (IsMaster(dev)) - { - for (other = inputInfo.devices; other; other = other->next) - { - if (other->u.master == dev) - { - AttachDevice(NULL, other, NULL); - flags[other->id] |= XISlaveDetached; - } - } - } - else - { - for (other = inputInfo.devices; other; other = other->next) - { - if (IsMaster(other) && other->u.lastSlave == dev) - other->u.lastSlave = NULL; - } - } - - if (IsMaster(dev) && dev->spriteInfo->sprite) - { - for (other = inputInfo.devices; other; other = other->next) - { - if (other->spriteInfo->paired == dev) - { - ErrorF("[dix] cannot disable device, still paired. " - "This is a bug. \n"); - return FALSE; - } - } - } - - (void)(*dev->deviceProc)(dev, DEVICE_OFF); - dev->enabled = FALSE; - - /* now that the device is disabled, we can reset the signal handler's - * last.slave */ - OsBlockSignals(); - for (other = inputInfo.devices; other; other = other->next) - { - if (other->last.slave == dev) - other->last.slave = NULL; - } - OsReleaseSignals(); - - LeaveWindow(dev); - SetFocusOut(dev); - - *prev = dev->next; - dev->next = inputInfo.off_devices; - inputInfo.off_devices = dev; - - enabled = FALSE; - XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED), - XA_INTEGER, 8, PropModeReplace, 1, &enabled, - TRUE); - - SendDevicePresenceEvent(dev->id, DeviceDisabled); - if (sendevent) - { - flags[dev->id] = XIDeviceDisabled; - XISendDeviceHierarchyEvent(flags); - } - - RecalculateMasterButtons(dev); - - return TRUE; -} - -/** - * Initialise a new device through the driver and tell all clients about the - * new device. - * - * Must be called before EnableDevice. - * The device will NOT send events until it is enabled! - * - * @param sendevent True if an XI2 event should be sent. - * @return Success or an error code on failure. - */ -int -ActivateDevice(DeviceIntPtr dev, BOOL sendevent) -{ - int ret = Success; - ScreenPtr pScreen = screenInfo.screens[0]; - - if (!dev || !dev->deviceProc) - return BadImplementation; - - ret = (*dev->deviceProc) (dev, DEVICE_INIT); - dev->inited = (ret == Success); - if (!dev->inited) - return ret; - - /* Initialize memory for sprites. */ - if (IsMaster(dev) && dev->spriteInfo->spriteOwner) - if (!pScreen->DeviceCursorInitialize(dev, pScreen)) - ret = BadAlloc; - - SendDevicePresenceEvent(dev->id, DeviceAdded); - if (sendevent) - { - int flags[MAXDEVICES] = {0}; - flags[dev->id] = XISlaveAdded; - XISendDeviceHierarchyEvent(flags); - } - return ret; -} - -/** - * Ring the bell. - * The actual task of ringing the bell is the job of the DDX. - */ -static void -CoreKeyboardBell(int volume, DeviceIntPtr pDev, pointer arg, int something) -{ - KeybdCtrl *ctrl = arg; - - DDXRingBell(volume, ctrl->bell_pitch, ctrl->bell_duration); -} - -static void -CoreKeyboardCtl(DeviceIntPtr pDev, KeybdCtrl *ctrl) -{ - return; -} - -/** - * Device control function for the Virtual Core Keyboard. - */ -int -CoreKeyboardProc(DeviceIntPtr pDev, int what) -{ - - switch (what) { - case DEVICE_INIT: - if (!InitKeyboardDeviceStruct(pDev, NULL, CoreKeyboardBell, - CoreKeyboardCtl)) - { - ErrorF("Keyboard initialization failed. This could be a missing " - "or incorrect setup of xkeyboard-config.\n"); - return BadValue; - } - return Success; - - case DEVICE_ON: - case DEVICE_OFF: - return Success; - - case DEVICE_CLOSE: - return Success; - } - - return BadMatch; -} - -/** - * Device control function for the Virtual Core Pointer. - */ -int -CorePointerProc(DeviceIntPtr pDev, int what) -{ -#define NBUTTONS 10 -#define NAXES 2 - BYTE map[NBUTTONS + 1]; - int i = 0; - Atom btn_labels[NBUTTONS] = {0}; - Atom axes_labels[NAXES] = {0}; - - switch (what) { - case DEVICE_INIT: - for (i = 1; i <= NBUTTONS; i++) - map[i] = i; - - btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); - btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); - btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); - btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); - btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); - btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT); - btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); - /* don't know about the rest */ - - axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); - axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); - - if (!InitPointerDeviceStruct((DevicePtr)pDev, map, NBUTTONS, btn_labels, - (PtrCtrlProcPtr)NoopDDA, - GetMotionHistorySize(), NAXES, axes_labels)) - { - ErrorF("Could not initialize device '%s'. Out of memory.\n", - pDev->name); - return BadAlloc; /* IPDS only fails on allocs */ - } - pDev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2; - pDev->last.valuators[0] = pDev->valuator->axisVal[0]; - pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2; - pDev->last.valuators[1] = pDev->valuator->axisVal[1]; - break; - - case DEVICE_CLOSE: - break; - - default: - break; - } - - return Success; - -#undef NBUTTONS -#undef NAXES -} - -/** - * Initialise the two core devices, VCP and VCK (see events.c). - * Both devices are not tied to physical devices, but guarantee that there is - * always a keyboard and a pointer present and keep the protocol semantics. - * - * Note that the server MUST have two core devices at all times, even if there - * is no physical device connected. - */ -void -InitCoreDevices(void) -{ - if (AllocDevicePair(serverClient, "Virtual core", - &inputInfo.pointer, &inputInfo.keyboard, - CorePointerProc, CoreKeyboardProc, - TRUE) != Success) - FatalError("Failed to allocate core devices"); - - if (ActivateDevice(inputInfo.pointer, TRUE) != Success || - ActivateDevice(inputInfo.keyboard, TRUE) != Success) - FatalError("Failed to activate core devices."); - if (!EnableDevice(inputInfo.pointer, TRUE) || - !EnableDevice(inputInfo.keyboard, TRUE)) - FatalError("Failed to enable core devices."); - - InitXTestDevices(); -} - -/** - * Activate all switched-off devices and then enable all those devices. - * - * Will return an error if no core keyboard or core pointer is present. - * In theory this should never happen if you call InitCoreDevices() first. - * - * InitAndStartDevices needs to be called AFTER the windows are initialized. - * Devices will start sending events after InitAndStartDevices() has - * completed. - * - * @return Success or error code on failure. - */ -int -InitAndStartDevices(void) -{ - DeviceIntPtr dev, next; - - for (dev = inputInfo.off_devices; dev; dev = dev->next) { - DebugF("(dix) initialising device %d\n", dev->id); - if (!dev->inited) - ActivateDevice(dev, TRUE); - } - - /* enable real devices */ - for (dev = inputInfo.off_devices; dev; dev = next) - { - DebugF("(dix) enabling device %d\n", dev->id); - next = dev->next; - if (dev->inited && dev->startup) - EnableDevice(dev, TRUE); - } - - return Success; -} - -/** - * Free the given device class and reset the pointer to NULL. - */ -static void -FreeDeviceClass(int type, pointer *class) -{ - if (!(*class)) - return; - - switch(type) - { - case KeyClass: - { - KeyClassPtr* k = (KeyClassPtr*)class; - if ((*k)->xkbInfo) - { - XkbFreeInfo((*k)->xkbInfo); - (*k)->xkbInfo = NULL; - } - free((*k)); - break; - } - case ButtonClass: - { - ButtonClassPtr *b = (ButtonClassPtr*)class; - free((*b)->xkb_acts); - free((*b)); - break; - } - case ValuatorClass: - { - ValuatorClassPtr *v = (ValuatorClassPtr*)class; - - free((*v)->motion); - free((*v)); - break; - } - case FocusClass: - { - FocusClassPtr *f = (FocusClassPtr*)class; - free((*f)->trace); - free((*f)); - break; - } - case ProximityClass: - { - ProximityClassPtr *p = (ProximityClassPtr*)class; - free((*p)); - break; - } - } - *class = NULL; -} - -static void -FreeFeedbackClass(int type, pointer *class) -{ - if (!(*class)) - return; - - switch(type) - { - case KbdFeedbackClass: - { - KbdFeedbackPtr *kbdfeed = (KbdFeedbackPtr*)class; - KbdFeedbackPtr k, knext; - for (k = (*kbdfeed); k; k = knext) { - knext = k->next; - if (k->xkb_sli) - XkbFreeSrvLedInfo(k->xkb_sli); - free(k); - } - break; - } - case PtrFeedbackClass: - { - PtrFeedbackPtr *ptrfeed = (PtrFeedbackPtr*)class; - PtrFeedbackPtr p, pnext; - - for (p = (*ptrfeed); p; p = pnext) { - pnext = p->next; - free(p); - } - break; - } - case IntegerFeedbackClass: - { - IntegerFeedbackPtr *intfeed = (IntegerFeedbackPtr*)class; - IntegerFeedbackPtr i, inext; - - for (i = (*intfeed); i; i = inext) { - inext = i->next; - free(i); - } - break; - } - case StringFeedbackClass: - { - StringFeedbackPtr *stringfeed = (StringFeedbackPtr*)class; - StringFeedbackPtr s, snext; - - for (s = (*stringfeed); s; s = snext) { - snext = s->next; - free(s->ctrl.symbols_supported); - free(s->ctrl.symbols_displayed); - free(s); - } - break; - } - case BellFeedbackClass: - { - BellFeedbackPtr *bell = (BellFeedbackPtr*)class; - BellFeedbackPtr b, bnext; - - for (b = (*bell); b; b = bnext) { - bnext = b->next; - free(b); - } - break; - } - case LedFeedbackClass: - { - LedFeedbackPtr *leds = (LedFeedbackPtr*)class; - LedFeedbackPtr l, lnext; - - for (l = (*leds); l; l = lnext) { - lnext = l->next; - if (l->xkb_sli) - XkbFreeSrvLedInfo(l->xkb_sli); - free(l); - } - break; - } - } - *class = NULL; -} - -static void -FreeAllDeviceClasses(ClassesPtr classes) -{ - if (!classes) - return; - - FreeDeviceClass(KeyClass, (pointer)&classes->key); - FreeDeviceClass(ValuatorClass, (pointer)&classes->valuator); - FreeDeviceClass(ButtonClass, (pointer)&classes->button); - FreeDeviceClass(FocusClass, (pointer)&classes->focus); - FreeDeviceClass(ProximityClass, (pointer)&classes->proximity); - - FreeFeedbackClass(KbdFeedbackClass, (pointer)&classes->kbdfeed); - FreeFeedbackClass(PtrFeedbackClass, (pointer)&classes->ptrfeed); - FreeFeedbackClass(IntegerFeedbackClass, (pointer)&classes->intfeed); - FreeFeedbackClass(StringFeedbackClass, (pointer)&classes->stringfeed); - FreeFeedbackClass(BellFeedbackClass, (pointer)&classes->bell); - FreeFeedbackClass(LedFeedbackClass, (pointer)&classes->leds); - -} - -/** - * Close down a device and free all resources. - * Once closed down, the driver will probably not expect you that you'll ever - * enable it again and free associated structs. If you want the device to just - * be disabled, DisableDevice(). - * Don't call this function directly, use RemoveDevice() instead. - */ -static void -CloseDevice(DeviceIntPtr dev) -{ - ScreenPtr screen = screenInfo.screens[0]; - ClassesPtr classes; - int j; - - if (!dev) - return; - - XIDeleteAllDeviceProperties(dev); - - if (dev->inited) - (void)(*dev->deviceProc)(dev, DEVICE_CLOSE); - - /* free sprite memory */ - if (IsMaster(dev) && dev->spriteInfo->sprite) - screen->DeviceCursorCleanup(dev, screen); - - /* free acceleration info */ - if(dev->valuator && dev->valuator->accelScheme.AccelCleanupProc) - dev->valuator->accelScheme.AccelCleanupProc(dev); - - while (dev->xkb_interest) - XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource); - - free(dev->name); - - classes = (ClassesPtr)&dev->key; - FreeAllDeviceClasses(classes); - - if (IsMaster(dev)) - { - classes = dev->unused_classes; - FreeAllDeviceClasses(classes); - free(classes); - } - - if (DevHasCursor(dev) && dev->spriteInfo->sprite) { - if (dev->spriteInfo->sprite->current) - FreeCursor(dev->spriteInfo->sprite->current, None); - free(dev->spriteInfo->sprite->spriteTrace); - free(dev->spriteInfo->sprite); - } - - /* a client may have the device set as client pointer */ - for (j = 0; j < currentMaxClients; j++) - { - if (clients[j] && clients[j]->clientPtr == dev) - { - clients[j]->clientPtr = NULL; - clients[j]->clientPtr = PickPointer(clients[j]); - } - } - - free(dev->deviceGrab.sync.event); - dixFreeObjectWithPrivates(dev, PRIVATE_DEVICE); -} - -/** - * Shut down all devices of one list and free all resources. - */ -static -void -CloseDeviceList(DeviceIntPtr *listHead) -{ - /* Used to mark devices that we tried to free */ - Bool freedIds[MAXDEVICES]; - DeviceIntPtr dev; - int i; - - if (listHead == NULL) - return; - - for (i = 0; i < MAXDEVICES; i++) - freedIds[i] = FALSE; - - dev = *listHead; - while (dev != NULL) - { - freedIds[dev->id] = TRUE; - DeleteInputDeviceRequest(dev); - - dev = *listHead; - while (dev != NULL && freedIds[dev->id]) - dev = dev->next; - } -} - -/** - * Shut down all devices, free all resources, etc. - * Only useful if you're shutting down the server! - */ -void -CloseDownDevices(void) -{ - DeviceIntPtr dev; - - /* Float all SDs before closing them. Note that at this point resources - * (e.g. cursors) have been freed already, so we can't just call - * AttachDevice(NULL, dev, NULL). Instead, we have to forcibly set master - * to NULL and pretend nothing happened. - */ - for (dev = inputInfo.devices; dev; dev = dev->next) - { - if (!IsMaster(dev) && dev->u.master) - dev->u.master = NULL; - } - - CloseDeviceList(&inputInfo.devices); - CloseDeviceList(&inputInfo.off_devices); - - CloseDevice(inputInfo.pointer); - CloseDevice(inputInfo.keyboard); - - inputInfo.devices = NULL; - inputInfo.off_devices = NULL; - inputInfo.keyboard = NULL; - inputInfo.pointer = NULL; - XkbDeleteRulesDflts(); -} - -/** - * Remove the cursor sprite for all devices. This needs to be done before any - * resources are freed or any device is deleted. - */ -void -UndisplayDevices(void) -{ - DeviceIntPtr dev; - ScreenPtr screen = screenInfo.screens[0]; - - for (dev = inputInfo.devices; dev; dev = dev->next) - screen->DisplayCursor(dev, screen, NullCursor); -} - -/** - * Remove a device from the device list, closes it and thus frees all - * resources. - * Removes both enabled and disabled devices and notifies all devices about - * the removal of the device. - * - * No PresenceNotify is sent for device that the client never saw. This can - * happen if a malloc fails during the addition of master devices. If - * dev->init is FALSE it means the client never received a DeviceAdded event, - * so let's not send a DeviceRemoved event either. - * - * @param sendevent True if an XI2 event should be sent. - */ -int -RemoveDevice(DeviceIntPtr dev, BOOL sendevent) -{ - DeviceIntPtr prev,tmp,next; - int ret = BadMatch; - ScreenPtr screen = screenInfo.screens[0]; - int deviceid; - int initialized; - int flags[MAXDEVICES] = {0}; - - DebugF("(dix) removing device %d\n", dev->id); - - if (!dev || dev == inputInfo.keyboard || dev == inputInfo.pointer) - return BadImplementation; - - initialized = dev->inited; - deviceid = dev->id; - - if (initialized) - { - if (DevHasCursor(dev)) - screen->DisplayCursor(dev, screen, NullCursor); - - DisableDevice(dev, sendevent); - flags[dev->id] = XIDeviceDisabled; - } - - prev = NULL; - for (tmp = inputInfo.devices; tmp; (prev = tmp), (tmp = next)) { - next = tmp->next; - if (tmp == dev) { - - if (prev==NULL) - inputInfo.devices = next; - else - prev->next = next; - - flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved; - CloseDevice(tmp); - ret = Success; - } - } - - prev = NULL; - for (tmp = inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) { - next = tmp->next; - if (tmp == dev) { - flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved; - CloseDevice(tmp); - - if (prev == NULL) - inputInfo.off_devices = next; - else - prev->next = next; - - ret = Success; - } - } - - if (ret == Success && initialized) { - inputInfo.numDevices--; - SendDevicePresenceEvent(deviceid, DeviceRemoved); - if (sendevent) - XISendDeviceHierarchyEvent(flags); - } - - return ret; -} - -int -NumMotionEvents(void) -{ - /* only called to fill data in initial connection reply. - * VCP is ok here, it is the only fixed device we have. */ - return inputInfo.pointer->valuator->numMotionEvents; -} - -int -dixLookupDevice(DeviceIntPtr *pDev, int id, ClientPtr client, Mask access_mode) -{ - DeviceIntPtr dev; - int rc; - *pDev = NULL; - - for (dev=inputInfo.devices; dev; dev=dev->next) { - if (dev->id == id) - goto found; - } - for (dev=inputInfo.off_devices; dev; dev=dev->next) { - if (dev->id == id) - goto found; - } - return BadDevice; - -found: - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode); - if (rc == Success) - *pDev = dev; - return rc; -} - -void -QueryMinMaxKeyCodes(KeyCode *minCode, KeyCode *maxCode) -{ - if (inputInfo.keyboard) { - *minCode = inputInfo.keyboard->key->xkbInfo->desc->min_key_code; - *maxCode = inputInfo.keyboard->key->xkbInfo->desc->max_key_code; - } -} - -/* Notably, this function does not expand the destination's keycode range, or - * notify clients. */ -Bool -SetKeySymsMap(KeySymsPtr dst, KeySymsPtr src) -{ - int i, j; - KeySym *tmp; - int rowDif = src->minKeyCode - dst->minKeyCode; - - /* if keysym map size changes, grow map first */ - if (src->mapWidth < dst->mapWidth) { - for (i = src->minKeyCode; i <= src->maxKeyCode; i++) { -#define SI(r, c) (((r - src->minKeyCode) * src->mapWidth) + (c)) -#define DI(r, c) (((r - dst->minKeyCode) * dst->mapWidth) + (c)) - for (j = 0; j < src->mapWidth; j++) - dst->map[DI(i, j)] = src->map[SI(i, j)]; - for (j = src->mapWidth; j < dst->mapWidth; j++) - dst->map[DI(i, j)] = NoSymbol; -#undef SI -#undef DI - } - return TRUE; - } - else if (src->mapWidth > dst->mapWidth) { - i = sizeof(KeySym) * src->mapWidth * - (dst->maxKeyCode - dst->minKeyCode + 1); - tmp = calloc(sizeof(KeySym), i); - if (!tmp) - return FALSE; - - if (dst->map) { - for (i = 0; i <= dst->maxKeyCode-dst->minKeyCode; i++) - memmove(&tmp[i * src->mapWidth], &dst->map[i * dst->mapWidth], - dst->mapWidth * sizeof(KeySym)); - free(dst->map); - } - dst->mapWidth = src->mapWidth; - dst->map = tmp; - } - else if (!dst->map) { - i = sizeof(KeySym) * src->mapWidth * - (dst->maxKeyCode - dst->minKeyCode + 1); - tmp = calloc(sizeof(KeySym), i); - if (!tmp) - return FALSE; - - dst->map = tmp; - dst->mapWidth = src->mapWidth; - } - - memmove(&dst->map[rowDif * dst->mapWidth], src->map, - (src->maxKeyCode - src->minKeyCode + 1) * - dst->mapWidth * sizeof(KeySym)); - - return TRUE; -} - -Bool -InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons, Atom* labels, - CARD8 *map) -{ - ButtonClassPtr butc; - int i; - - butc = calloc(1, sizeof(ButtonClassRec)); - if (!butc) - return FALSE; - butc->numButtons = numButtons; - butc->sourceid = dev->id; - for (i = 1; i <= numButtons; i++) - butc->map[i] = map[i]; - for (i = numButtons + 1; i < MAP_LENGTH; i++) - butc->map[i] = i; - memcpy(butc->labels, labels, numButtons * sizeof(Atom)); - dev->button = butc; - return TRUE; -} - -Bool -InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels, - int numMotionEvents, int mode) -{ - int i; - ValuatorClassPtr valc; - - if (!dev) - return FALSE; - - if (numAxes > MAX_VALUATORS) - { - LogMessage(X_WARNING, - "Device '%s' has %d axes, only using first %d.\n", - dev->name, numAxes, MAX_VALUATORS); - numAxes = MAX_VALUATORS; - } - - valc = (ValuatorClassPtr)calloc(1, sizeof(ValuatorClassRec) + - numAxes * sizeof(AxisInfo) + - numAxes * sizeof(double)); - if (!valc) - return FALSE; - - valc->sourceid = dev->id; - valc->motion = NULL; - valc->first_motion = 0; - valc->last_motion = 0; - - valc->numMotionEvents = numMotionEvents; - valc->motionHintWindow = NullWindow; - valc->numAxes = numAxes; - valc->axes = (AxisInfoPtr)(valc + 1); - valc->axisVal = (double *)(valc->axes + numAxes); - - if (mode & OutOfProximity) - InitProximityClassDeviceStruct(dev); - - dev->valuator = valc; - - AllocateMotionHistory(dev); - - for (i=0; iaxisVal[i]=0; - } - - dev->last.numValuators = numAxes; - - if (IsMaster(dev) || /* do not accelerate master or xtest devices */ - IsXTestDevice(dev, NULL)) - InitPointerAccelerationScheme(dev, PtrAccelNoOp); - else - InitPointerAccelerationScheme(dev, PtrAccelDefault); - return TRUE; -} - -/* global list of acceleration schemes */ -ValuatorAccelerationRec pointerAccelerationScheme[] = { - {PtrAccelNoOp, NULL, NULL, NULL}, - {PtrAccelPredictable, acceleratePointerPredictable, NULL, AccelerationDefaultCleanup}, - {PtrAccelLightweight, acceleratePointerLightweight, NULL, NULL}, - {-1, NULL, NULL, NULL} /* terminator */ -}; - -/** - * install an acceleration scheme. returns TRUE on success, and should not - * change anything if unsuccessful. - */ -Bool -InitPointerAccelerationScheme(DeviceIntPtr dev, - int scheme) -{ - int x, i = -1; - void* data = NULL; - ValuatorClassPtr val; - - val = dev->valuator; - - if(!val) - return FALSE; - - if(IsMaster(dev) && scheme != PtrAccelNoOp) - return FALSE; - - for(x = 0; pointerAccelerationScheme[x].number >= 0; x++) { - if(pointerAccelerationScheme[x].number == scheme){ - i = x; - break; - } - } - - if(-1 == i) - return FALSE; - - if (val->accelScheme.AccelCleanupProc) - val->accelScheme.AccelCleanupProc(dev); - - /* init scheme-specific data */ - switch(scheme){ - case PtrAccelPredictable: - { - DeviceVelocityPtr s; - s = malloc(sizeof(DeviceVelocityRec)); - if(!s) - return FALSE; - InitVelocityData(s); - data = s; - break; - } - default: - break; - } - - val->accelScheme = pointerAccelerationScheme[i]; - val->accelScheme.accelData = data; - - /* post-init scheme */ - switch(scheme){ - case PtrAccelPredictable: - InitializePredictableAccelerationProperties(dev); - break; - - default: - break; - } - - return TRUE; -} - -Bool -InitAbsoluteClassDeviceStruct(DeviceIntPtr dev) -{ - AbsoluteClassPtr abs; - - abs = malloc(sizeof(AbsoluteClassRec)); - if (!abs) - return FALSE; - - /* we don't do anything sensible with these, but should */ - abs->min_x = NO_AXIS_LIMITS; - abs->min_y = NO_AXIS_LIMITS; - abs->max_x = NO_AXIS_LIMITS; - abs->max_y = NO_AXIS_LIMITS; - abs->flip_x = 0; - abs->flip_y = 0; - abs->rotation = 0; - abs->button_threshold = 0; - - abs->offset_x = 0; - abs->offset_y = 0; - abs->width = NO_AXIS_LIMITS; - abs->height = NO_AXIS_LIMITS; - abs->following = 0; - abs->screen = 0; - - abs->sourceid = dev->id; - - dev->absolute = abs; - - return TRUE; -} - -Bool -InitFocusClassDeviceStruct(DeviceIntPtr dev) -{ - FocusClassPtr focc; - - focc = malloc(sizeof(FocusClassRec)); - if (!focc) - return FALSE; - focc->win = PointerRootWin; - focc->revert = None; - focc->time = currentTime; - focc->trace = (WindowPtr *)NULL; - focc->traceSize = 0; - focc->traceGood = 0; - focc->sourceid = dev->id; - dev->focus = focc; - return TRUE; -} - -Bool -InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc) -{ - PtrFeedbackPtr feedc; - - feedc = malloc(sizeof(PtrFeedbackClassRec)); - if (!feedc) - return FALSE; - feedc->CtrlProc = controlProc; - feedc->ctrl = defaultPointerControl; - feedc->ctrl.id = 0; - if ( (feedc->next = dev->ptrfeed) ) - feedc->ctrl.id = dev->ptrfeed->ctrl.id + 1; - dev->ptrfeed = feedc; - (*controlProc)(dev, &feedc->ctrl); - return TRUE; -} - - -static LedCtrl defaultLedControl = { - DEFAULT_LEDS, DEFAULT_LEDS_MASK, 0}; - -static BellCtrl defaultBellControl = { - DEFAULT_BELL, - DEFAULT_BELL_PITCH, - DEFAULT_BELL_DURATION, - 0}; - -static IntegerCtrl defaultIntegerControl = { - DEFAULT_INT_RESOLUTION, - DEFAULT_INT_MIN_VALUE, - DEFAULT_INT_MAX_VALUE, - DEFAULT_INT_DISPLAYED, - 0}; - -Bool -InitStringFeedbackClassDeviceStruct ( - DeviceIntPtr dev, StringCtrlProcPtr controlProc, - int max_symbols, int num_symbols_supported, KeySym *symbols) -{ - int i; - StringFeedbackPtr feedc; - - feedc = malloc(sizeof(StringFeedbackClassRec)); - if (!feedc) - return FALSE; - feedc->CtrlProc = controlProc; - feedc->ctrl.num_symbols_supported = num_symbols_supported; - feedc->ctrl.num_symbols_displayed = 0; - feedc->ctrl.max_symbols = max_symbols; - feedc->ctrl.symbols_supported = malloc(sizeof (KeySym) * num_symbols_supported); - feedc->ctrl.symbols_displayed = malloc(sizeof (KeySym) * max_symbols); - if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed) - { - free(feedc->ctrl.symbols_supported); - free(feedc->ctrl.symbols_displayed); - free(feedc); - return FALSE; - } - for (i=0; ictrl.symbols_supported+i) = *symbols++; - for (i=0; ictrl.symbols_displayed+i) = (KeySym) 0; - feedc->ctrl.id = 0; - if ( (feedc->next = dev->stringfeed) ) - feedc->ctrl.id = dev->stringfeed->ctrl.id + 1; - dev->stringfeed = feedc; - (*controlProc)(dev, &feedc->ctrl); - return TRUE; -} - -Bool -InitBellFeedbackClassDeviceStruct (DeviceIntPtr dev, BellProcPtr bellProc, - BellCtrlProcPtr controlProc) -{ - BellFeedbackPtr feedc; - - feedc = malloc(sizeof(BellFeedbackClassRec)); - if (!feedc) - return FALSE; - feedc->CtrlProc = controlProc; - feedc->BellProc = bellProc; - feedc->ctrl = defaultBellControl; - feedc->ctrl.id = 0; - if ( (feedc->next = dev->bell) ) - feedc->ctrl.id = dev->bell->ctrl.id + 1; - dev->bell = feedc; - (*controlProc)(dev, &feedc->ctrl); - return TRUE; -} - -Bool -InitLedFeedbackClassDeviceStruct (DeviceIntPtr dev, LedCtrlProcPtr controlProc) -{ - LedFeedbackPtr feedc; - - feedc = malloc(sizeof(LedFeedbackClassRec)); - if (!feedc) - return FALSE; - feedc->CtrlProc = controlProc; - feedc->ctrl = defaultLedControl; - feedc->ctrl.id = 0; - if ( (feedc->next = dev->leds) ) - feedc->ctrl.id = dev->leds->ctrl.id + 1; - feedc->xkb_sli= NULL; - dev->leds = feedc; - (*controlProc)(dev, &feedc->ctrl); - return TRUE; -} - -Bool -InitIntegerFeedbackClassDeviceStruct (DeviceIntPtr dev, IntegerCtrlProcPtr controlProc) -{ - IntegerFeedbackPtr feedc; - - feedc = malloc(sizeof(IntegerFeedbackClassRec)); - if (!feedc) - return FALSE; - feedc->CtrlProc = controlProc; - feedc->ctrl = defaultIntegerControl; - feedc->ctrl.id = 0; - if ( (feedc->next = dev->intfeed) ) - feedc->ctrl.id = dev->intfeed->ctrl.id + 1; - dev->intfeed = feedc; - (*controlProc)(dev, &feedc->ctrl); - return TRUE; -} - -Bool -InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons, Atom* btn_labels, - PtrCtrlProcPtr controlProc, int numMotionEvents, - int numAxes, Atom *axes_labels) -{ - DeviceIntPtr dev = (DeviceIntPtr)device; - - return(InitButtonClassDeviceStruct(dev, numButtons, btn_labels, map) && - InitValuatorClassDeviceStruct(dev, numAxes, axes_labels, - numMotionEvents, Relative) && - InitPtrFeedbackClassDeviceStruct(dev, controlProc)); -} - -/* - * Check if the given buffer contains elements between low (inclusive) and - * high (inclusive) only. - * - * @return TRUE if the device map is invalid, FALSE otherwise. - */ -Bool -BadDeviceMap(BYTE *buff, int length, unsigned low, unsigned high, XID *errval) -{ - int i; - - for (i = 0; i < length; i++) - if (buff[i]) /* only check non-zero elements */ - { - if ((low > buff[i]) || (high < buff[i])) - { - *errval = buff[i]; - return TRUE; - } - } - return FALSE; -} - -int -ProcSetModifierMapping(ClientPtr client) -{ - xSetModifierMappingReply rep; - int rc; - REQUEST(xSetModifierMappingReq); - REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq); - - if (client->req_len != ((stuff->numKeyPerModifier << 1) + - bytes_to_int32(sizeof(xSetModifierMappingReq)))) - return BadLength; - - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - - rc = change_modmap(client, PickKeyboard(client), (KeyCode *)&stuff[1], - stuff->numKeyPerModifier); - if (rc == MappingFailed || rc == -1) - return BadValue; - if (rc != Success && rc != MappingSuccess && rc != MappingFailed && - rc != MappingBusy) - return rc; - - rep.success = rc; - - WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep); - return Success; -} - -int -ProcGetModifierMapping(ClientPtr client) -{ - xGetModifierMappingReply rep; - int max_keys_per_mod = 0; - KeyCode *modkeymap = NULL; - REQUEST_SIZE_MATCH(xReq); - - generate_modkeymap(client, PickKeyboard(client), &modkeymap, - &max_keys_per_mod); - - memset(&rep, 0, sizeof(xGetModifierMappingReply)); - rep.type = X_Reply; - rep.numKeyPerModifier = max_keys_per_mod; - rep.sequenceNumber = client->sequence; - /* length counts 4 byte quantities - there are 8 modifiers 1 byte big */ - rep.length = max_keys_per_mod << 1; - - WriteReplyToClient(client, sizeof(xGetModifierMappingReply), &rep); - (void)WriteToClient(client, max_keys_per_mod * 8, (char *) modkeymap); - - free(modkeymap); - - return Success; -} - -int -ProcChangeKeyboardMapping(ClientPtr client) -{ - REQUEST(xChangeKeyboardMappingReq); - unsigned len; - KeySymsRec keysyms; - DeviceIntPtr pDev, tmp; - int rc; - REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq); - - len = client->req_len - bytes_to_int32(sizeof(xChangeKeyboardMappingReq)); - if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode)) - return BadLength; - - pDev = PickKeyboard(client); - - if ((stuff->firstKeyCode < pDev->key->xkbInfo->desc->min_key_code) || - (stuff->firstKeyCode > pDev->key->xkbInfo->desc->max_key_code)) { - client->errorValue = stuff->firstKeyCode; - return BadValue; - - } - if (((unsigned)(stuff->firstKeyCode + stuff->keyCodes - 1) > - pDev->key->xkbInfo->desc->max_key_code) || - (stuff->keySymsPerKeyCode == 0)) { - client->errorValue = stuff->keySymsPerKeyCode; - return BadValue; - } - - keysyms.minKeyCode = stuff->firstKeyCode; - keysyms.maxKeyCode = stuff->firstKeyCode + stuff->keyCodes - 1; - keysyms.mapWidth = stuff->keySymsPerKeyCode; - keysyms.map = (KeySym *) &stuff[1]; - - rc = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess); - if (rc != Success) - return rc; - - XkbApplyMappingChange(pDev, &keysyms, stuff->firstKeyCode, - stuff->keyCodes, NULL, client); - - for (tmp = inputInfo.devices; tmp; tmp = tmp->next) { - if (IsMaster(tmp) || tmp->u.master != pDev) - continue; - if (!tmp->key) - continue; - - rc = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess); - if (rc != Success) - continue; - - XkbApplyMappingChange(tmp, &keysyms, stuff->firstKeyCode, - stuff->keyCodes, NULL, client); - } - - return Success; -} - -int -ProcSetPointerMapping(ClientPtr client) -{ - BYTE *map; - int ret; - int i, j; - DeviceIntPtr ptr = PickPointer(client); - xSetPointerMappingReply rep; - REQUEST(xSetPointerMappingReq); - REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq); - - if (client->req_len != - bytes_to_int32(sizeof(xSetPointerMappingReq) + stuff->nElts)) - return BadLength; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.success = MappingSuccess; - map = (BYTE *)&stuff[1]; - - /* So we're bounded here by the number of core buttons. This check - * probably wants disabling through XFixes. */ - /* MPX: With ClientPointer, we can return the right number of buttons. - * Let's just hope nobody changed ClientPointer between GetPointerMapping - * and SetPointerMapping - */ - if (stuff->nElts != ptr->button->numButtons) { - client->errorValue = stuff->nElts; - return BadValue; - } - - /* Core protocol specs don't allow for duplicate mappings; this check - * almost certainly wants disabling through XFixes too. */ - for (i = 0; i < stuff->nElts; i++) { - for (j = i + 1; j < stuff->nElts; j++) { - if (map[i] && map[i] == map[j]) { - client->errorValue = map[i]; - return BadValue; - } - } - } - - ret = ApplyPointerMapping(ptr, map, stuff->nElts, client); - if (ret == MappingBusy) - rep.success = ret; - else if (ret == -1) - return BadValue; - else if (ret != Success) - return ret; - - WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep); - return Success; -} - -int -ProcGetKeyboardMapping(ClientPtr client) -{ - xGetKeyboardMappingReply rep; - DeviceIntPtr kbd = PickKeyboard(client); - XkbDescPtr xkb; - KeySymsPtr syms; - int rc; - REQUEST(xGetKeyboardMappingReq); - REQUEST_SIZE_MATCH(xGetKeyboardMappingReq); - - rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetAttrAccess); - if (rc != Success) - return rc; - - xkb = kbd->key->xkbInfo->desc; - - if ((stuff->firstKeyCode < xkb->min_key_code) || - (stuff->firstKeyCode > xkb->max_key_code)) { - client->errorValue = stuff->firstKeyCode; - return BadValue; - } - if (stuff->firstKeyCode + stuff->count > xkb->max_key_code + 1) { - client->errorValue = stuff->count; - return BadValue; - } - - syms = XkbGetCoreMap(kbd); - if (!syms) - return BadAlloc; - - memset(&rep, 0, sizeof(xGetKeyboardMappingReply)); - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.keySymsPerKeyCode = syms->mapWidth; - /* length is a count of 4 byte quantities and KeySyms are 4 bytes */ - rep.length = syms->mapWidth * stuff->count; - WriteReplyToClient(client, sizeof(xGetKeyboardMappingReply), &rep); - client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; - WriteSwappedDataToClient(client, - syms->mapWidth * stuff->count * sizeof(KeySym), - &syms->map[syms->mapWidth * (stuff->firstKeyCode - - syms->minKeyCode)]); - free(syms->map); - free(syms); - - return Success; -} - -int -ProcGetPointerMapping(ClientPtr client) -{ - xGetPointerMappingReply rep; - /* Apps may get different values each time they call GetPointerMapping as - * the ClientPointer could change. */ - DeviceIntPtr ptr = PickPointer(client); - ButtonClassPtr butc = ptr->button; - int rc; - REQUEST_SIZE_MATCH(xReq); - - rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, DixGetAttrAccess); - if (rc != Success) - return rc; - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.nElts = (butc) ? butc->numButtons : 0; - rep.length = ((unsigned)rep.nElts + (4-1))/4; - WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep); - if (butc) - WriteToClient(client, (int)rep.nElts, (char *)&butc->map[1]); - return Success; -} - -void -NoteLedState(DeviceIntPtr keybd, int led, Bool on) -{ - KeybdCtrl *ctrl = &keybd->kbdfeed->ctrl; - if (on) - ctrl->leds |= ((Leds)1 << (led - 1)); - else - ctrl->leds &= ~((Leds)1 << (led - 1)); -} - -int -Ones(unsigned long mask) /* HACKMEM 169 */ -{ - unsigned long y; - - y = (mask >> 1) &033333333333; - y = mask - y - ((y >>1) & 033333333333); - return (((y + (y >> 3)) & 030707070707) % 077); -} - -static int -DoChangeKeyboardControl (ClientPtr client, DeviceIntPtr keybd, XID *vlist, - BITS32 vmask) -{ -#define DO_ALL (-1) - KeybdCtrl ctrl; - int t; - int led = DO_ALL; - int key = DO_ALL; - BITS32 index2; - int mask = vmask, i; - XkbEventCauseRec cause; - - ctrl = keybd->kbdfeed->ctrl; - while (vmask) { - index2 = (BITS32) lowbit (vmask); - vmask &= ~index2; - switch (index2) { - case KBKeyClickPercent: - t = (INT8)*vlist; - vlist++; - if (t == -1) { - t = defaultKeyboardControl.click; - } - else if (t < 0 || t > 100) { - client->errorValue = t; - return BadValue; - } - ctrl.click = t; - break; - case KBBellPercent: - t = (INT8)*vlist; - vlist++; - if (t == -1) { - t = defaultKeyboardControl.bell; - } - else if (t < 0 || t > 100) { - client->errorValue = t; - return BadValue; - } - ctrl.bell = t; - break; - case KBBellPitch: - t = (INT16)*vlist; - vlist++; - if (t == -1) { - t = defaultKeyboardControl.bell_pitch; - } - else if (t < 0) { - client->errorValue = t; - return BadValue; - } - ctrl.bell_pitch = t; - break; - case KBBellDuration: - t = (INT16)*vlist; - vlist++; - if (t == -1) - t = defaultKeyboardControl.bell_duration; - else if (t < 0) { - client->errorValue = t; - return BadValue; - } - ctrl.bell_duration = t; - break; - case KBLed: - led = (CARD8)*vlist; - vlist++; - if (led < 1 || led > 32) { - client->errorValue = led; - return BadValue; - } - if (!(mask & KBLedMode)) - return BadMatch; - break; - case KBLedMode: - t = (CARD8)*vlist; - vlist++; - if (t == LedModeOff) { - if (led == DO_ALL) - ctrl.leds = 0x0; - else - ctrl.leds &= ~(((Leds)(1)) << (led - 1)); - } - else if (t == LedModeOn) { - if (led == DO_ALL) - ctrl.leds = ~0L; - else - ctrl.leds |= (((Leds)(1)) << (led - 1)); - } - else { - client->errorValue = t; - return BadValue; - } - - XkbSetCauseCoreReq(&cause,X_ChangeKeyboardControl,client); - XkbSetIndicators(keybd,((led == DO_ALL) ? ~0L : (1L<<(led-1))), - ctrl.leds, &cause); - ctrl.leds = keybd->kbdfeed->ctrl.leds; - - break; - case KBKey: - key = (KeyCode)*vlist; - vlist++; - if ((KeyCode)key < keybd->key->xkbInfo->desc->min_key_code || - (KeyCode)key > keybd->key->xkbInfo->desc->max_key_code) { - client->errorValue = key; - return BadValue; - } - if (!(mask & KBAutoRepeatMode)) - return BadMatch; - break; - case KBAutoRepeatMode: - i = (key >> 3); - mask = (1 << (key & 7)); - t = (CARD8)*vlist; - vlist++; - if (key != DO_ALL) - XkbDisableComputedAutoRepeats(keybd,key); - if (t == AutoRepeatModeOff) { - if (key == DO_ALL) - ctrl.autoRepeat = FALSE; - else - ctrl.autoRepeats[i] &= ~mask; - } - else if (t == AutoRepeatModeOn) { - if (key == DO_ALL) - ctrl.autoRepeat = TRUE; - else - ctrl.autoRepeats[i] |= mask; - } - else if (t == AutoRepeatModeDefault) { - if (key == DO_ALL) - ctrl.autoRepeat = defaultKeyboardControl.autoRepeat; - else - ctrl.autoRepeats[i] = - (ctrl.autoRepeats[i] & ~mask) | - (defaultKeyboardControl.autoRepeats[i] & mask); - } - else { - client->errorValue = t; - return BadValue; - } - break; - default: - client->errorValue = mask; - return BadValue; - } - } - keybd->kbdfeed->ctrl = ctrl; - - /* The XKB RepeatKeys control and core protocol global autorepeat */ - /* value are linked */ - XkbSetRepeatKeys(keybd, key, keybd->kbdfeed->ctrl.autoRepeat); - - return Success; - -#undef DO_ALL -} - -/** - * Changes kbd control on the ClientPointer and all attached SDs. - */ -int -ProcChangeKeyboardControl (ClientPtr client) -{ - XID *vlist; - BITS32 vmask; - int ret = Success, error = Success; - DeviceIntPtr pDev = NULL, keyboard; - REQUEST(xChangeKeyboardControlReq); - - REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq); - - vmask = stuff->mask; - vlist = (XID *)&stuff[1]; - - if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask)) - return BadLength; - - keyboard = PickKeyboard(client); - - for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { - if ((pDev == keyboard || - (!IsMaster(pDev) && GetMaster(pDev, MASTER_KEYBOARD) == keyboard)) - && pDev->kbdfeed && pDev->kbdfeed->CtrlProc) { - ret = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess); - if (ret != Success) - return ret; - } - } - - for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { - if ((pDev == keyboard || - (!IsMaster(pDev) && GetMaster(pDev, MASTER_KEYBOARD) == keyboard)) - && pDev->kbdfeed && pDev->kbdfeed->CtrlProc) { - ret = DoChangeKeyboardControl(client, pDev, vlist, vmask); - if (ret != Success) - error = ret; - } - } - - return error; -} - -int -ProcGetKeyboardControl (ClientPtr client) -{ - int rc, i; - DeviceIntPtr kbd = PickKeyboard(client); - KeybdCtrl *ctrl = &kbd->kbdfeed->ctrl; - xGetKeyboardControlReply rep; - REQUEST_SIZE_MATCH(xReq); - - rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetAttrAccess); - if (rc != Success) - return rc; - - rep.type = X_Reply; - rep.length = 5; - rep.sequenceNumber = client->sequence; - rep.globalAutoRepeat = ctrl->autoRepeat; - rep.keyClickPercent = ctrl->click; - rep.bellPercent = ctrl->bell; - rep.bellPitch = ctrl->bell_pitch; - rep.bellDuration = ctrl->bell_duration; - rep.ledMask = ctrl->leds; - for (i = 0; i < 32; i++) - rep.map[i] = ctrl->autoRepeats[i]; - WriteReplyToClient(client, sizeof(xGetKeyboardControlReply), &rep); - return Success; -} - -int -ProcBell(ClientPtr client) -{ - DeviceIntPtr dev, keybd = PickKeyboard(client); - int base = keybd->kbdfeed->ctrl.bell; - int newpercent; - int rc; - REQUEST(xBellReq); - REQUEST_SIZE_MATCH(xBellReq); - - if (stuff->percent < -100 || stuff->percent > 100) { - client->errorValue = stuff->percent; - return BadValue; - } - - newpercent = (base * stuff->percent) / 100; - if (stuff->percent < 0) - newpercent = base + newpercent; - else - newpercent = base - newpercent + stuff->percent; - - for (dev = inputInfo.devices; dev; dev = dev->next) { - if ((dev == keybd || - (!IsMaster(dev) && GetMaster(dev, MASTER_KEYBOARD) == keybd)) && - dev->kbdfeed && dev->kbdfeed->BellProc) { - - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixBellAccess); - if (rc != Success) - return rc; - XkbHandleBell(FALSE, FALSE, dev, newpercent, - &dev->kbdfeed->ctrl, 0, None, NULL, client); - } - } - - return Success; -} - -int -ProcChangePointerControl(ClientPtr client) -{ - DeviceIntPtr dev, mouse = PickPointer(client); - PtrCtrl ctrl; /* might get BadValue part way through */ - int rc; - REQUEST(xChangePointerControlReq); - REQUEST_SIZE_MATCH(xChangePointerControlReq); - - ctrl = mouse->ptrfeed->ctrl; - if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse)) { - client->errorValue = stuff->doAccel; - return BadValue; - } - if ((stuff->doThresh != xTrue) && (stuff->doThresh != xFalse)) { - client->errorValue = stuff->doThresh; - return BadValue; - } - if (stuff->doAccel) { - if (stuff->accelNum == -1) { - ctrl.num = defaultPointerControl.num; - } - else if (stuff->accelNum < 0) { - client->errorValue = stuff->accelNum; - return BadValue; - } - else { - ctrl.num = stuff->accelNum; - } - - if (stuff->accelDenum == -1) { - ctrl.den = defaultPointerControl.den; - } - else if (stuff->accelDenum <= 0) { - client->errorValue = stuff->accelDenum; - return BadValue; - } - else { - ctrl.den = stuff->accelDenum; - } - } - if (stuff->doThresh) { - if (stuff->threshold == -1) { - ctrl.threshold = defaultPointerControl.threshold; - } - else if (stuff->threshold < 0) { - client->errorValue = stuff->threshold; - return BadValue; - } - else { - ctrl.threshold = stuff->threshold; - } - } - - for (dev = inputInfo.devices; dev; dev = dev->next) { - if ((dev == mouse || - (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) == mouse)) && - dev->ptrfeed) { - rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixManageAccess); - if (rc != Success) - return rc; - } - } - - for (dev = inputInfo.devices; dev; dev = dev->next) { - if ((dev == mouse || - (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) == mouse)) && - dev->ptrfeed) { - dev->ptrfeed->ctrl = ctrl; - } - } - - return Success; -} - -int -ProcGetPointerControl(ClientPtr client) -{ - DeviceIntPtr ptr = PickPointer(client); - PtrCtrl *ctrl = &ptr->ptrfeed->ctrl; - xGetPointerControlReply rep; - int rc; - REQUEST_SIZE_MATCH(xReq); - - rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, DixGetAttrAccess); - if (rc != Success) - return rc; - - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.threshold = ctrl->threshold; - rep.accelNumerator = ctrl->num; - rep.accelDenominator = ctrl->den; - WriteReplyToClient(client, sizeof(xGenericReply), &rep); - return Success; -} - -void -MaybeStopHint(DeviceIntPtr dev, ClientPtr client) -{ - GrabPtr grab = dev->deviceGrab.grab; - - if ((grab && SameClient(grab, client) && - ((grab->eventMask & PointerMotionHintMask) || - (grab->ownerEvents && - (EventMaskForClient(dev->valuator->motionHintWindow, client) & - PointerMotionHintMask)))) || - (!grab && - (EventMaskForClient(dev->valuator->motionHintWindow, client) & - PointerMotionHintMask))) - dev->valuator->motionHintWindow = NullWindow; -} - -int -ProcGetMotionEvents(ClientPtr client) -{ - WindowPtr pWin; - xTimecoord * coords = (xTimecoord *) NULL; - xGetMotionEventsReply rep; - int i, count, xmin, xmax, ymin, ymax, rc; - unsigned long nEvents; - DeviceIntPtr mouse = PickPointer(client); - TimeStamp start, stop; - REQUEST(xGetMotionEventsReq); - REQUEST_SIZE_MATCH(xGetMotionEventsReq); - - rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); - if (rc != Success) - return rc; - rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixReadAccess); - if (rc != Success) - return rc; - - if (mouse->valuator->motionHintWindow) - MaybeStopHint(mouse, client); - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - nEvents = 0; - start = ClientTimeToServerTime(stuff->start); - stop = ClientTimeToServerTime(stuff->stop); - if ((CompareTimeStamps(start, stop) != LATER) && - (CompareTimeStamps(start, currentTime) != LATER) && - mouse->valuator->numMotionEvents) - { - if (CompareTimeStamps(stop, currentTime) == LATER) - stop = currentTime; - count = GetMotionHistory(mouse, &coords, start.milliseconds, - stop.milliseconds, pWin->drawable.pScreen, - TRUE); - xmin = pWin->drawable.x - wBorderWidth (pWin); - xmax = pWin->drawable.x + (int)pWin->drawable.width + - wBorderWidth (pWin); - ymin = pWin->drawable.y - wBorderWidth (pWin); - ymax = pWin->drawable.y + (int)pWin->drawable.height + - wBorderWidth (pWin); - for (i = 0; i < count; i++) - if ((xmin <= coords[i].x) && (coords[i].x < xmax) && - (ymin <= coords[i].y) && (coords[i].y < ymax)) - { - coords[nEvents].time = coords[i].time; - coords[nEvents].x = coords[i].x - pWin->drawable.x; - coords[nEvents].y = coords[i].y - pWin->drawable.y; - nEvents++; - } - } - rep.length = nEvents * bytes_to_int32(sizeof(xTimecoord)); - rep.nEvents = nEvents; - WriteReplyToClient(client, sizeof(xGetMotionEventsReply), &rep); - if (nEvents) - { - client->pSwapReplyFunc = (ReplySwapPtr) SwapTimeCoordWrite; - WriteSwappedDataToClient(client, nEvents * sizeof(xTimecoord), - (char *)coords); - } - free(coords); - return Success; -} - -int -ProcQueryKeymap(ClientPtr client) -{ - xQueryKeymapReply rep; - int rc, i; - DeviceIntPtr keybd = PickKeyboard(client); - CARD8 *down = keybd->key->down; - - REQUEST_SIZE_MATCH(xReq); - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 2; - - rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess); - if (rc != Success && rc != BadAccess) - return rc; - - for (i = 0; i<32; i++) - rep.map[i] = down[i]; - - if (rc == BadAccess) - memset(rep.map, 0, 32); - - WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep); - - return Success; -} - - -/** - * Recalculate the number of buttons for the master device. The number of - * buttons on the master device is equal to the number of buttons on the - * slave device with the highest number of buttons. - */ -static void -RecalculateMasterButtons(DeviceIntPtr slave) -{ - DeviceIntPtr dev, master; - int maxbuttons = 0; - - if (!slave->button || IsMaster(slave)) - return; - - master = GetMaster(slave, MASTER_POINTER); - if (!master) - return; - - for (dev = inputInfo.devices; dev; dev = dev->next) - { - if (IsMaster(dev) || - dev->u.master != master || - !dev->button) - continue; - - maxbuttons = max(maxbuttons, dev->button->numButtons); - } - - if (master->button && master->button->numButtons != maxbuttons) - { - int i; - DeviceChangedEvent event; - - memset(&event, 0, sizeof(event)); - - master->button->numButtons = maxbuttons; - - event.header = ET_Internal; - event.type = ET_DeviceChanged; - event.time = GetTimeInMillis(); - event.deviceid = master->id; - event.flags = DEVCHANGE_POINTER_EVENT | DEVCHANGE_DEVICE_CHANGE; - event.buttons.num_buttons = maxbuttons; - memcpy(&event.buttons.names, master->button->labels, maxbuttons * - sizeof(Atom)); - - if (master->valuator) - { - event.num_valuators = master->valuator->numAxes; - for (i = 0; i < event.num_valuators; i++) - { - event.valuators[i].min = master->valuator->axes[i].min_value; - event.valuators[i].max = master->valuator->axes[i].max_value; - event.valuators[i].resolution = master->valuator->axes[i].resolution; - event.valuators[i].mode = master->valuator->axes[i].mode; - event.valuators[i].name = master->valuator->axes[i].label; - } - } - - if (master->key) - { - event.keys.min_keycode = master->key->xkbInfo->desc->min_key_code; - event.keys.max_keycode = master->key->xkbInfo->desc->max_key_code; - } - - XISendDeviceChangedEvent(master, master, &event); - } -} - -/** - * Attach device 'dev' to device 'master'. - * Client is set to the client that issued the request, or NULL if it comes - * from some internal automatic pairing. - * - * Master may be NULL to set the device floating. - * - * We don't allow multi-layer hierarchies right now. You can't attach a slave - * to another slave. - */ -int -AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master) -{ - ScreenPtr screen; - DeviceIntPtr oldmaster; - if (!dev || IsMaster(dev)) - return BadDevice; - - if (master && !IsMaster(master)) /* can't attach to slaves */ - return BadDevice; - - /* set from floating to floating? */ - if (!dev->u.master && !master && dev->enabled) - return Success; - - /* free the existing sprite. */ - if (!dev->u.master && dev->spriteInfo->paired == dev) - { - screen = miPointerGetScreen(dev); - screen->DeviceCursorCleanup(dev, screen); - free(dev->spriteInfo->sprite); - } - - oldmaster = dev->u.master; - dev->u.master = master; - - /* If device is set to floating, we need to create a sprite for it, - * otherwise things go bad. However, we don't want to render the cursor, - * so we reset spriteOwner. - * Sprite has to be forced to NULL first, otherwise InitializeSprite won't - * alloc new memory but overwrite the previous one. - */ - if (!master) - { - WindowPtr currentRoot; - - if (dev->spriteInfo->sprite) - currentRoot = GetCurrentRootWindow(dev); - else /* new device auto-set to floating */ - currentRoot = screenInfo.screens[0]->root; - - /* we need to init a fake sprite */ - screen = currentRoot->drawable.pScreen; - screen->DeviceCursorInitialize(dev, screen); - dev->spriteInfo->sprite = NULL; - InitializeSprite(dev, currentRoot); - dev->spriteInfo->spriteOwner = FALSE; - dev->spriteInfo->paired = dev; - } else - { - dev->spriteInfo->sprite = master->spriteInfo->sprite; - dev->spriteInfo->paired = master; - dev->spriteInfo->spriteOwner = FALSE; - - RecalculateMasterButtons(master); - } - - /* XXX: in theory, the MD should change back to its old, original - * classes when the last SD is detached. Thanks to the XTEST devices, - * we'll always have an SD attached until the MD is removed. - * So let's not worry about that. - */ - - return Success; -} - -/** - * Return the device paired with the given device or NULL. - * Returns the device paired with the parent master if the given device is a - * slave device. - */ -DeviceIntPtr -GetPairedDevice(DeviceIntPtr dev) -{ - if (!IsMaster(dev) && dev->u.master) - dev = dev->u.master; - - return dev->spriteInfo->paired; -} - - -/** - * Returns the right master for the type of event needed. If the event is a - * keyboard event. - * This function may be called with a master device as argument. If so, the - * returned master is either the device itself or the paired master device. - * If dev is a floating slave device, NULL is returned. - * - * @type ::MASTER_KEYBOARD or ::MASTER_POINTER - */ -DeviceIntPtr -GetMaster(DeviceIntPtr dev, int which) -{ - DeviceIntPtr master; - - if (IsMaster(dev)) - master = dev; - else - master = dev->u.master; - - if (master) - { - if (which == MASTER_KEYBOARD) - { - if (master->type != MASTER_KEYBOARD) - master = GetPairedDevice(master); - } else - { - if (master->type != MASTER_POINTER) - master = GetPairedDevice(master); - } - } - - return master; -} - -/** - * Create a new device pair (== one pointer, one keyboard device). - * Only allocates the devices, you will need to call ActivateDevice() and - * EnableDevice() manually. - * Either a master or a slave device can be created depending on - * the value for master. - */ -int -AllocDevicePair (ClientPtr client, char* name, - DeviceIntPtr* ptr, - DeviceIntPtr* keybd, - DeviceProc ptr_proc, - DeviceProc keybd_proc, - Bool master) -{ - DeviceIntPtr pointer; - DeviceIntPtr keyboard; - *ptr = *keybd = NULL; - - pointer = AddInputDevice(client, ptr_proc, TRUE); - if (!pointer) - return BadAlloc; - - if (asprintf(&pointer->name, "%s pointer", name) == -1) { - pointer->name = NULL; - RemoveDevice(pointer, FALSE); - return BadAlloc; - } - - pointer->public.processInputProc = ProcessOtherEvent; - pointer->public.realInputProc = ProcessOtherEvent; - XkbSetExtension(pointer, ProcessPointerEvent); - pointer->deviceGrab.ActivateGrab = ActivatePointerGrab; - pointer->deviceGrab.DeactivateGrab = DeactivatePointerGrab; - pointer->coreEvents = TRUE; - pointer->spriteInfo->spriteOwner = TRUE; - - pointer->u.lastSlave = NULL; - pointer->last.slave = NULL; - pointer->type = (master) ? MASTER_POINTER : SLAVE; - - keyboard = AddInputDevice(client, keybd_proc, TRUE); - if (!keyboard) - { - RemoveDevice(pointer, FALSE); - return BadAlloc; - } - - if (asprintf(&keyboard->name, "%s keyboard", name) == -1) { - keyboard->name = NULL; - RemoveDevice(keyboard, FALSE); - RemoveDevice(pointer, FALSE); - return BadAlloc; - } - - keyboard->public.processInputProc = ProcessOtherEvent; - keyboard->public.realInputProc = ProcessOtherEvent; - XkbSetExtension(keyboard, ProcessKeyboardEvent); - keyboard->deviceGrab.ActivateGrab = ActivateKeyboardGrab; - keyboard->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab; - keyboard->coreEvents = TRUE; - keyboard->spriteInfo->spriteOwner = FALSE; - - keyboard->u.lastSlave = NULL; - keyboard->last.slave = NULL; - keyboard->type = (master) ? MASTER_KEYBOARD : SLAVE; - - /* The ClassesRec stores the device classes currently not used. */ - pointer->unused_classes = calloc(1, sizeof(ClassesRec)); - keyboard->unused_classes = calloc(1, sizeof(ClassesRec)); - - *ptr = pointer; - *keybd = keyboard; - - return Success; -} - -/** - * Return Relative or Absolute for the device. - */ -int valuator_get_mode(DeviceIntPtr dev, int axis) -{ - return (dev->valuator->axes[axis].mode & DeviceMode); -} - -/** - * Set the given mode for the axis. If axis is VALUATOR_MODE_ALL_AXES, then - * set the mode for all axes. - */ -void valuator_set_mode(DeviceIntPtr dev, int axis, int mode) -{ - if (axis != VALUATOR_MODE_ALL_AXES) - dev->valuator->axes[axis].mode = mode; - else { - int i; - for (i = 0; i < dev->valuator->numAxes; i++) - dev->valuator->axes[i].mode = mode; - } -} +/************************************************************ + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + + +Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +********************************************************/ + + + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include "misc.h" +#include "resource.h" +#include +#include +#include "windowstr.h" +#include "inputstr.h" +#include "scrnintstr.h" +#include "cursorstr.h" +#include "dixstruct.h" +#include "ptrveloc.h" +#include "site.h" +#include "xkbsrv.h" +#include "privates.h" +#include "xace.h" +#include "mi.h" + +#include "dispatch.h" +#include "swaprep.h" +#include "dixevents.h" +#include "mipointer.h" +#include "eventstr.h" + +#include +#include +#include +#include +#include +#include "exglobals.h" +#include "exevents.h" +#include "xiquerydevice.h" /* for SizeDeviceClasses */ +#include "xiproperty.h" +#include "enterleave.h" /* for EnterWindow() */ +#include "xserver-properties.h" +#include "xichangehierarchy.h" /* For XISendDeviceHierarchyEvent */ + +/** @file + * This file handles input device-related stuff. + */ + +static void RecalculateMasterButtons(DeviceIntPtr slave); + +static void +DeviceSetTransform(DeviceIntPtr dev, float *transform) +{ + struct pixman_f_transform scale; + double sx, sy; + int x, y; + + /** + * calculate combined transformation matrix: + * + * M = InvScale * Transform * Scale + * + * So we can later transform points using M * p + * + * Where: + * Scale scales coordinates into 0..1 range + * Transform is the user supplied (affine) transform + * InvScale scales coordinates back up into their native range + */ + sx = dev->valuator->axes[0].max_value - dev->valuator->axes[0].min_value; + sy = dev->valuator->axes[1].max_value - dev->valuator->axes[1].min_value; + + /* invscale */ + pixman_f_transform_init_scale(&scale, sx, sy); + scale.m[0][2] = dev->valuator->axes[0].min_value; + scale.m[1][2] = dev->valuator->axes[1].min_value; + + /* transform */ + for (y=0; y<3; y++) + for (x=0; x<3; x++) + dev->transform.m[y][x] = *transform++; + + pixman_f_transform_multiply(&dev->transform, &scale, &dev->transform); + + /* scale */ + pixman_f_transform_init_scale(&scale, 1.0 / sx, 1.0 / sy); + scale.m[0][2] = -dev->valuator->axes[0].min_value / sx; + scale.m[1][2] = -dev->valuator->axes[1].min_value / sy; + + pixman_f_transform_multiply(&dev->transform, &dev->transform, &scale); +} + +/** + * DIX property handler. + */ +static int +DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, + BOOL checkonly) +{ + if (property == XIGetKnownProperty(XI_PROP_ENABLED)) + { + if (prop->format != 8 || prop->type != XA_INTEGER || prop->size != 1) + return BadValue; + + /* Don't allow disabling of VCP/VCK */ + if ((dev == inputInfo.pointer || dev == inputInfo.keyboard) && + !(*(CARD8*)prop->data)) + return BadAccess; + + if (!checkonly) + { + if ((*((CARD8*)prop->data)) && !dev->enabled) + EnableDevice(dev, TRUE); + else if (!(*((CARD8*)prop->data)) && dev->enabled) + DisableDevice(dev, TRUE); + } + } else if (property == XIGetKnownProperty(XI_PROP_TRANSFORM)) + { + float *f = (float*)prop->data; + int i; + + if (prop->format != 32 || prop->size != 9 || + prop->type != XIGetKnownProperty(XATOM_FLOAT)) + return BadValue; + + for (i=0; i<9; i++) + if (!isfinite(f[i])) + return BadValue; + + if (!checkonly) + DeviceSetTransform(dev, f); + } + + return Success; +} + +/* Pair the keyboard to the pointer device. Keyboard events will follow the + * pointer sprite. Only applicable for master devices. + * If the client is set, the request to pair comes from some client. In this + * case, we need to check for access. If the client is NULL, it's from an + * internal automatic pairing, we must always permit this. + */ +static int +PairDevices(ClientPtr client, DeviceIntPtr ptr, DeviceIntPtr kbd) +{ + if (!ptr) + return BadDevice; + + /* Don't allow pairing for slave devices */ + if (!IsMaster(ptr) || !IsMaster(kbd)) + return BadDevice; + + if (ptr->spriteInfo->paired) + return BadDevice; + + if (kbd->spriteInfo->spriteOwner) + { + free(kbd->spriteInfo->sprite); + kbd->spriteInfo->sprite = NULL; + kbd->spriteInfo->spriteOwner = FALSE; + } + + kbd->spriteInfo->sprite = ptr->spriteInfo->sprite; + kbd->spriteInfo->paired = ptr; + ptr->spriteInfo->paired = kbd; + return Success; +} + + +/** + * Find and return the next unpaired MD pointer device. + */ +static DeviceIntPtr +NextFreePointerDevice(void) +{ + DeviceIntPtr dev; + for (dev = inputInfo.devices; dev; dev = dev->next) + if (IsMaster(dev) && + dev->spriteInfo->spriteOwner && + !dev->spriteInfo->paired) + return dev; + return NULL; +} + +/** + * Create a new input device and init it to sane values. The device is added + * to the server's off_devices list. + * + * @param deviceProc Callback for device control function (switch dev on/off). + * @return The newly created device. + */ +DeviceIntPtr +AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart) +{ + DeviceIntPtr dev, *prev; /* not a typo */ + DeviceIntPtr devtmp; + int devid; + char devind[MAXDEVICES]; + BOOL enabled; + float transform[9]; + + /* Find next available id, 0 and 1 are reserved */ + memset(devind, 0, sizeof(char)*MAXDEVICES); + for (devtmp = inputInfo.devices; devtmp; devtmp = devtmp->next) + devind[devtmp->id]++; + for (devtmp = inputInfo.off_devices; devtmp; devtmp = devtmp->next) + devind[devtmp->id]++; + for (devid = 2; devid < MAXDEVICES && devind[devid]; devid++) + ; + + if (devid >= MAXDEVICES) + return (DeviceIntPtr)NULL; + dev = _dixAllocateObjectWithPrivates(sizeof(DeviceIntRec) + sizeof(SpriteInfoRec), + sizeof(DeviceIntRec) + sizeof(SpriteInfoRec), + offsetof(DeviceIntRec, devPrivates), PRIVATE_DEVICE); + if (!dev) + return (DeviceIntPtr)NULL; + dev->id = devid; + dev->public.processInputProc = ProcessOtherEvent; + dev->public.realInputProc = ProcessOtherEvent; + dev->public.enqueueInputProc = EnqueueEvent; + dev->deviceProc = deviceProc; + dev->startup = autoStart; + + /* device grab defaults */ + dev->deviceGrab.grabTime = currentTime; + dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab; + dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab; + + XkbSetExtension(dev, ProcessKeyboardEvent); + + dev->coreEvents = TRUE; + + /* sprite defaults */ + dev->spriteInfo = (SpriteInfoPtr)&dev[1]; + + /* security creation/labeling check + */ + if (XaceHook(XACE_DEVICE_ACCESS, client, dev, DixCreateAccess)) { + free(dev); + return NULL; + } + + inputInfo.numDevices++; + + for (prev = &inputInfo.off_devices; *prev; prev = &(*prev)->next) + ; + *prev = dev; + dev->next = NULL; + + enabled = FALSE; + XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED), + XA_INTEGER, 8, PropModeReplace, 1, &enabled, + FALSE); + XISetDevicePropertyDeletable(dev, XIGetKnownProperty(XI_PROP_ENABLED), FALSE); + + /* unity matrix */ + memset(transform, 0, sizeof(transform)); + transform[0] = transform[4] = transform[8] = 1.0f; + + XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_TRANSFORM), + XIGetKnownProperty(XATOM_FLOAT), 32, + PropModeReplace, 9, transform, FALSE); + XISetDevicePropertyDeletable(dev, XIGetKnownProperty(XI_PROP_TRANSFORM), + FALSE); + + XIRegisterPropertyHandler(dev, DeviceSetProperty, NULL, NULL); + + return dev; +} + +void +SendDevicePresenceEvent(int deviceid, int type) +{ + DeviceIntRec dummyDev; + devicePresenceNotify ev; + + memset(&dummyDev, 0, sizeof(DeviceIntRec)); + ev.type = DevicePresenceNotify; + ev.time = currentTime.milliseconds; + ev.devchange = type; + ev.deviceid = deviceid; + dummyDev.id = XIAllDevices; + SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask, + (xEvent*)&ev, 1); +} + +/** + * Enable the device through the driver, add the device to the device list. + * Switch device ON through the driver and push it onto the global device + * list. Initialize the DIX sprite or pair the device. All clients are + * notified about the device being enabled. + * + * A master pointer device needs to be enabled before a master keyboard + * device. + * + * @param The device to be enabled. + * @param sendevent True if an XI2 event should be sent. + * @return TRUE on success or FALSE otherwise. + */ +Bool +EnableDevice(DeviceIntPtr dev, BOOL sendevent) +{ + DeviceIntPtr *prev; + int ret; + DeviceIntPtr other; + BOOL enabled; + int flags[MAXDEVICES] = {0}; + + for (prev = &inputInfo.off_devices; + *prev && (*prev != dev); + prev = &(*prev)->next) + ; + + if (!dev->spriteInfo->sprite) + { + if (IsMaster(dev)) + { + /* Sprites appear on first root window, so we can hardcode it */ + if (dev->spriteInfo->spriteOwner) + { + InitializeSprite(dev, screenInfo.screens[0]->root); + /* mode doesn't matter */ + EnterWindow(dev, screenInfo.screens[0]->root, NotifyAncestor); + } + else if ((other = NextFreePointerDevice()) == NULL) + { + ErrorF("[dix] cannot find pointer to pair with. " + "This is a bug.\n"); + return FALSE; + } else + PairDevices(NULL, other, dev); + } else + { + if (dev->coreEvents) + other = (IsPointerDevice(dev)) ? inputInfo.pointer : + inputInfo.keyboard; + else + other = NULL; /* auto-float non-core devices */ + AttachDevice(NULL, dev, other); + } + } + + if ((*prev != dev) || !dev->inited || + ((ret = (*dev->deviceProc)(dev, DEVICE_ON)) != Success)) { + ErrorF("[dix] couldn't enable device %d\n", dev->id); + return FALSE; + } + dev->enabled = TRUE; + *prev = dev->next; + + for (prev = &inputInfo.devices; *prev; prev = &(*prev)->next) + ; + *prev = dev; + dev->next = NULL; + + enabled = TRUE; + XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED), + XA_INTEGER, 8, PropModeReplace, 1, &enabled, + TRUE); + + SendDevicePresenceEvent(dev->id, DeviceEnabled); + if (sendevent) + { + flags[dev->id] |= XIDeviceEnabled; + XISendDeviceHierarchyEvent(flags); + } + + RecalculateMasterButtons(dev); + + return TRUE; +} + +/** + * Switch a device off through the driver and push it onto the off_devices + * list. A device will not send events while disabled. All clients are + * notified about the device being disabled. + * + * Master keyboard devices have to be disabled before master pointer devices + * otherwise things turn bad. + * + * @param sendevent True if an XI2 event should be sent. + * @return TRUE on success or FALSE otherwise. + */ +Bool +DisableDevice(DeviceIntPtr dev, BOOL sendevent) +{ + DeviceIntPtr *prev, other; + BOOL enabled; + int flags[MAXDEVICES] = {0}; + + for (prev = &inputInfo.devices; + *prev && (*prev != dev); + prev = &(*prev)->next) + ; + if (*prev != dev) + return FALSE; + + /* float attached devices */ + if (IsMaster(dev)) + { + for (other = inputInfo.devices; other; other = other->next) + { + if (other->u.master == dev) + { + AttachDevice(NULL, other, NULL); + flags[other->id] |= XISlaveDetached; + } + } + } + else + { + for (other = inputInfo.devices; other; other = other->next) + { + if (IsMaster(other) && other->u.lastSlave == dev) + other->u.lastSlave = NULL; + } + } + + if (IsMaster(dev) && dev->spriteInfo->sprite) + { + for (other = inputInfo.devices; other; other = other->next) + { + if (other->spriteInfo->paired == dev) + { + ErrorF("[dix] cannot disable device, still paired. " + "This is a bug. \n"); + return FALSE; + } + } + } + + (void)(*dev->deviceProc)(dev, DEVICE_OFF); + dev->enabled = FALSE; + + /* now that the device is disabled, we can reset the signal handler's + * last.slave */ + OsBlockSignals(); + for (other = inputInfo.devices; other; other = other->next) + { + if (other->last.slave == dev) + other->last.slave = NULL; + } + OsReleaseSignals(); + + LeaveWindow(dev); + SetFocusOut(dev); + + *prev = dev->next; + dev->next = inputInfo.off_devices; + inputInfo.off_devices = dev; + + enabled = FALSE; + XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED), + XA_INTEGER, 8, PropModeReplace, 1, &enabled, + TRUE); + + SendDevicePresenceEvent(dev->id, DeviceDisabled); + if (sendevent) + { + flags[dev->id] = XIDeviceDisabled; + XISendDeviceHierarchyEvent(flags); + } + + RecalculateMasterButtons(dev); + + return TRUE; +} + +/** + * Initialise a new device through the driver and tell all clients about the + * new device. + * + * Must be called before EnableDevice. + * The device will NOT send events until it is enabled! + * + * @param sendevent True if an XI2 event should be sent. + * @return Success or an error code on failure. + */ +int +ActivateDevice(DeviceIntPtr dev, BOOL sendevent) +{ + int ret = Success; + ScreenPtr pScreen = screenInfo.screens[0]; + + if (!dev || !dev->deviceProc) + return BadImplementation; + + ret = (*dev->deviceProc) (dev, DEVICE_INIT); + dev->inited = (ret == Success); + if (!dev->inited) + return ret; + + /* Initialize memory for sprites. */ + if (IsMaster(dev) && dev->spriteInfo->spriteOwner) + if (!pScreen->DeviceCursorInitialize(dev, pScreen)) + ret = BadAlloc; + + SendDevicePresenceEvent(dev->id, DeviceAdded); + if (sendevent) + { + int flags[MAXDEVICES] = {0}; + flags[dev->id] = XISlaveAdded; + XISendDeviceHierarchyEvent(flags); + } + return ret; +} + +/** + * Ring the bell. + * The actual task of ringing the bell is the job of the DDX. + */ +static void +CoreKeyboardBell(int volume, DeviceIntPtr pDev, pointer arg, int something) +{ + KeybdCtrl *ctrl = arg; + + DDXRingBell(volume, ctrl->bell_pitch, ctrl->bell_duration); +} + +static void +CoreKeyboardCtl(DeviceIntPtr pDev, KeybdCtrl *ctrl) +{ + return; +} + +/** + * Device control function for the Virtual Core Keyboard. + */ +int +CoreKeyboardProc(DeviceIntPtr pDev, int what) +{ + + switch (what) { + case DEVICE_INIT: + if (!InitKeyboardDeviceStruct(pDev, NULL, CoreKeyboardBell, + CoreKeyboardCtl)) + { + ErrorF("Keyboard initialization failed. This could be a missing " + "or incorrect setup of xkeyboard-config.\n"); + return BadValue; + } + return Success; + + case DEVICE_ON: + case DEVICE_OFF: + return Success; + + case DEVICE_CLOSE: + return Success; + } + + return BadMatch; +} + +/** + * Device control function for the Virtual Core Pointer. + */ +int +CorePointerProc(DeviceIntPtr pDev, int what) +{ +#define NBUTTONS 10 +#define NAXES 2 + BYTE map[NBUTTONS + 1]; + int i = 0; + Atom btn_labels[NBUTTONS] = {0}; + Atom axes_labels[NAXES] = {0}; + + switch (what) { + case DEVICE_INIT: + for (i = 1; i <= NBUTTONS; i++) + map[i] = i; + + btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); + btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); + btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); + btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); + btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); + btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT); + btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); + /* don't know about the rest */ + + axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); + axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); + + if (!InitPointerDeviceStruct((DevicePtr)pDev, map, NBUTTONS, btn_labels, + (PtrCtrlProcPtr)NoopDDA, + GetMotionHistorySize(), NAXES, axes_labels)) + { + ErrorF("Could not initialize device '%s'. Out of memory.\n", + pDev->name); + return BadAlloc; /* IPDS only fails on allocs */ + } + pDev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2; + pDev->last.valuators[0] = pDev->valuator->axisVal[0]; + pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2; + pDev->last.valuators[1] = pDev->valuator->axisVal[1]; + break; + + case DEVICE_CLOSE: + break; + + default: + break; + } + + return Success; + +#undef NBUTTONS +#undef NAXES +} + +/** + * Initialise the two core devices, VCP and VCK (see events.c). + * Both devices are not tied to physical devices, but guarantee that there is + * always a keyboard and a pointer present and keep the protocol semantics. + * + * Note that the server MUST have two core devices at all times, even if there + * is no physical device connected. + */ +void +InitCoreDevices(void) +{ + if (AllocDevicePair(serverClient, "Virtual core", + &inputInfo.pointer, &inputInfo.keyboard, + CorePointerProc, CoreKeyboardProc, + TRUE) != Success) + FatalError("Failed to allocate core devices"); + + if (ActivateDevice(inputInfo.pointer, TRUE) != Success || + ActivateDevice(inputInfo.keyboard, TRUE) != Success) + FatalError("Failed to activate core devices."); + if (!EnableDevice(inputInfo.pointer, TRUE) || + !EnableDevice(inputInfo.keyboard, TRUE)) + FatalError("Failed to enable core devices."); + + InitXTestDevices(); +} + +/** + * Activate all switched-off devices and then enable all those devices. + * + * Will return an error if no core keyboard or core pointer is present. + * In theory this should never happen if you call InitCoreDevices() first. + * + * InitAndStartDevices needs to be called AFTER the windows are initialized. + * Devices will start sending events after InitAndStartDevices() has + * completed. + * + * @return Success or error code on failure. + */ +int +InitAndStartDevices(void) +{ + DeviceIntPtr dev, next; + + for (dev = inputInfo.off_devices; dev; dev = dev->next) { + DebugF("(dix) initialising device %d\n", dev->id); + if (!dev->inited) + ActivateDevice(dev, TRUE); + } + + /* enable real devices */ + for (dev = inputInfo.off_devices; dev; dev = next) + { + DebugF("(dix) enabling device %d\n", dev->id); + next = dev->next; + if (dev->inited && dev->startup) + EnableDevice(dev, TRUE); + } + + return Success; +} + +/** + * Free the given device class and reset the pointer to NULL. + */ +static void +FreeDeviceClass(int type, pointer *class) +{ + if (!(*class)) + return; + + switch(type) + { + case KeyClass: + { + KeyClassPtr* k = (KeyClassPtr*)class; + if ((*k)->xkbInfo) + { + XkbFreeInfo((*k)->xkbInfo); + (*k)->xkbInfo = NULL; + } + free((*k)); + break; + } + case ButtonClass: + { + ButtonClassPtr *b = (ButtonClassPtr*)class; + free((*b)->xkb_acts); + free((*b)); + break; + } + case ValuatorClass: + { + ValuatorClassPtr *v = (ValuatorClassPtr*)class; + + free((*v)->motion); + free((*v)); + break; + } + case FocusClass: + { + FocusClassPtr *f = (FocusClassPtr*)class; + free((*f)->trace); + free((*f)); + break; + } + case ProximityClass: + { + ProximityClassPtr *p = (ProximityClassPtr*)class; + free((*p)); + break; + } + } + *class = NULL; +} + +static void +FreeFeedbackClass(int type, pointer *class) +{ + if (!(*class)) + return; + + switch(type) + { + case KbdFeedbackClass: + { + KbdFeedbackPtr *kbdfeed = (KbdFeedbackPtr*)class; + KbdFeedbackPtr k, knext; + for (k = (*kbdfeed); k; k = knext) { + knext = k->next; + if (k->xkb_sli) + XkbFreeSrvLedInfo(k->xkb_sli); + free(k); + } + break; + } + case PtrFeedbackClass: + { + PtrFeedbackPtr *ptrfeed = (PtrFeedbackPtr*)class; + PtrFeedbackPtr p, pnext; + + for (p = (*ptrfeed); p; p = pnext) { + pnext = p->next; + free(p); + } + break; + } + case IntegerFeedbackClass: + { + IntegerFeedbackPtr *intfeed = (IntegerFeedbackPtr*)class; + IntegerFeedbackPtr i, inext; + + for (i = (*intfeed); i; i = inext) { + inext = i->next; + free(i); + } + break; + } + case StringFeedbackClass: + { + StringFeedbackPtr *stringfeed = (StringFeedbackPtr*)class; + StringFeedbackPtr s, snext; + + for (s = (*stringfeed); s; s = snext) { + snext = s->next; + free(s->ctrl.symbols_supported); + free(s->ctrl.symbols_displayed); + free(s); + } + break; + } + case BellFeedbackClass: + { + BellFeedbackPtr *bell = (BellFeedbackPtr*)class; + BellFeedbackPtr b, bnext; + + for (b = (*bell); b; b = bnext) { + bnext = b->next; + free(b); + } + break; + } + case LedFeedbackClass: + { + LedFeedbackPtr *leds = (LedFeedbackPtr*)class; + LedFeedbackPtr l, lnext; + + for (l = (*leds); l; l = lnext) { + lnext = l->next; + if (l->xkb_sli) + XkbFreeSrvLedInfo(l->xkb_sli); + free(l); + } + break; + } + } + *class = NULL; +} + +static void +FreeAllDeviceClasses(ClassesPtr classes) +{ + if (!classes) + return; + + FreeDeviceClass(KeyClass, (pointer)&classes->key); + FreeDeviceClass(ValuatorClass, (pointer)&classes->valuator); + FreeDeviceClass(ButtonClass, (pointer)&classes->button); + FreeDeviceClass(FocusClass, (pointer)&classes->focus); + FreeDeviceClass(ProximityClass, (pointer)&classes->proximity); + + FreeFeedbackClass(KbdFeedbackClass, (pointer)&classes->kbdfeed); + FreeFeedbackClass(PtrFeedbackClass, (pointer)&classes->ptrfeed); + FreeFeedbackClass(IntegerFeedbackClass, (pointer)&classes->intfeed); + FreeFeedbackClass(StringFeedbackClass, (pointer)&classes->stringfeed); + FreeFeedbackClass(BellFeedbackClass, (pointer)&classes->bell); + FreeFeedbackClass(LedFeedbackClass, (pointer)&classes->leds); + +} + +/** + * Close down a device and free all resources. + * Once closed down, the driver will probably not expect you that you'll ever + * enable it again and free associated structs. If you want the device to just + * be disabled, DisableDevice(). + * Don't call this function directly, use RemoveDevice() instead. + */ +static void +CloseDevice(DeviceIntPtr dev) +{ + ScreenPtr screen = screenInfo.screens[0]; + ClassesPtr classes; + int j; + + if (!dev) + return; + + XIDeleteAllDeviceProperties(dev); + + if (dev->inited) + (void)(*dev->deviceProc)(dev, DEVICE_CLOSE); + + /* free sprite memory */ + if (IsMaster(dev) && dev->spriteInfo->sprite) + screen->DeviceCursorCleanup(dev, screen); + + /* free acceleration info */ + if(dev->valuator && dev->valuator->accelScheme.AccelCleanupProc) + dev->valuator->accelScheme.AccelCleanupProc(dev); + + while (dev->xkb_interest) + XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource); + + free(dev->name); + + classes = (ClassesPtr)&dev->key; + FreeAllDeviceClasses(classes); + + if (IsMaster(dev)) + { + classes = dev->unused_classes; + FreeAllDeviceClasses(classes); + free(classes); + } + + if (DevHasCursor(dev) && dev->spriteInfo->sprite) { + if (dev->spriteInfo->sprite->current) + FreeCursor(dev->spriteInfo->sprite->current, None); + free(dev->spriteInfo->sprite->spriteTrace); + free(dev->spriteInfo->sprite); + } + + /* a client may have the device set as client pointer */ + for (j = 0; j < currentMaxClients; j++) + { + if (clients[j] && clients[j]->clientPtr == dev) + { + clients[j]->clientPtr = NULL; + clients[j]->clientPtr = PickPointer(clients[j]); + } + } + + free(dev->deviceGrab.sync.event); + dixFreeObjectWithPrivates(dev, PRIVATE_DEVICE); +} + +/** + * Shut down all devices of one list and free all resources. + */ +static +void +CloseDeviceList(DeviceIntPtr *listHead) +{ + /* Used to mark devices that we tried to free */ + Bool freedIds[MAXDEVICES]; + DeviceIntPtr dev; + int i; + + if (listHead == NULL) + return; + + for (i = 0; i < MAXDEVICES; i++) + freedIds[i] = FALSE; + + dev = *listHead; + while (dev != NULL) + { + freedIds[dev->id] = TRUE; + DeleteInputDeviceRequest(dev); + + dev = *listHead; + while (dev != NULL && freedIds[dev->id]) + dev = dev->next; + } +} + +/** + * Shut down all devices, free all resources, etc. + * Only useful if you're shutting down the server! + */ +void +CloseDownDevices(void) +{ + DeviceIntPtr dev; + + /* Float all SDs before closing them. Note that at this point resources + * (e.g. cursors) have been freed already, so we can't just call + * AttachDevice(NULL, dev, NULL). Instead, we have to forcibly set master + * to NULL and pretend nothing happened. + */ + for (dev = inputInfo.devices; dev; dev = dev->next) + { + if (!IsMaster(dev) && dev->u.master) + dev->u.master = NULL; + } + + CloseDeviceList(&inputInfo.devices); + CloseDeviceList(&inputInfo.off_devices); + + CloseDevice(inputInfo.pointer); + CloseDevice(inputInfo.keyboard); + + inputInfo.devices = NULL; + inputInfo.off_devices = NULL; + inputInfo.keyboard = NULL; + inputInfo.pointer = NULL; + XkbDeleteRulesDflts(); +} + +/** + * Remove the cursor sprite for all devices. This needs to be done before any + * resources are freed or any device is deleted. + */ +void +UndisplayDevices(void) +{ + DeviceIntPtr dev; + ScreenPtr screen = screenInfo.screens[0]; + + for (dev = inputInfo.devices; dev; dev = dev->next) + screen->DisplayCursor(dev, screen, NullCursor); +} + +/** + * Remove a device from the device list, closes it and thus frees all + * resources. + * Removes both enabled and disabled devices and notifies all devices about + * the removal of the device. + * + * No PresenceNotify is sent for device that the client never saw. This can + * happen if a malloc fails during the addition of master devices. If + * dev->init is FALSE it means the client never received a DeviceAdded event, + * so let's not send a DeviceRemoved event either. + * + * @param sendevent True if an XI2 event should be sent. + */ +int +RemoveDevice(DeviceIntPtr dev, BOOL sendevent) +{ + DeviceIntPtr prev,tmp,next; + int ret = BadMatch; + ScreenPtr screen = screenInfo.screens[0]; + int deviceid; + int initialized; + int flags[MAXDEVICES] = {0}; + + DebugF("(dix) removing device %d\n", dev->id); + + if (!dev || dev == inputInfo.keyboard || dev == inputInfo.pointer) + return BadImplementation; + + initialized = dev->inited; + deviceid = dev->id; + + if (initialized) + { + if (DevHasCursor(dev)) + screen->DisplayCursor(dev, screen, NullCursor); + + DisableDevice(dev, sendevent); + flags[dev->id] = XIDeviceDisabled; + } + + prev = NULL; + for (tmp = inputInfo.devices; tmp; (prev = tmp), (tmp = next)) { + next = tmp->next; + if (tmp == dev) { + + if (prev==NULL) + inputInfo.devices = next; + else + prev->next = next; + + flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved; + CloseDevice(tmp); + ret = Success; + } + } + + prev = NULL; + for (tmp = inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) { + next = tmp->next; + if (tmp == dev) { + flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved; + CloseDevice(tmp); + + if (prev == NULL) + inputInfo.off_devices = next; + else + prev->next = next; + + ret = Success; + } + } + + if (ret == Success && initialized) { + inputInfo.numDevices--; + SendDevicePresenceEvent(deviceid, DeviceRemoved); + if (sendevent) + XISendDeviceHierarchyEvent(flags); + } + + return ret; +} + +int +NumMotionEvents(void) +{ + /* only called to fill data in initial connection reply. + * VCP is ok here, it is the only fixed device we have. */ + return inputInfo.pointer->valuator->numMotionEvents; +} + +int +dixLookupDevice(DeviceIntPtr *pDev, int id, ClientPtr client, Mask access_mode) +{ + DeviceIntPtr dev; + int rc; + *pDev = NULL; + + for (dev=inputInfo.devices; dev; dev=dev->next) { + if (dev->id == id) + goto found; + } + for (dev=inputInfo.off_devices; dev; dev=dev->next) { + if (dev->id == id) + goto found; + } + return BadDevice; + +found: + rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode); + if (rc == Success) + *pDev = dev; + return rc; +} + +void +QueryMinMaxKeyCodes(KeyCode *minCode, KeyCode *maxCode) +{ + if (inputInfo.keyboard) { + *minCode = inputInfo.keyboard->key->xkbInfo->desc->min_key_code; + *maxCode = inputInfo.keyboard->key->xkbInfo->desc->max_key_code; + } +} + +/* Notably, this function does not expand the destination's keycode range, or + * notify clients. */ +Bool +SetKeySymsMap(KeySymsPtr dst, KeySymsPtr src) +{ + int i, j; + KeySym *tmp; + int rowDif = src->minKeyCode - dst->minKeyCode; + + /* if keysym map size changes, grow map first */ + if (src->mapWidth < dst->mapWidth) { + for (i = src->minKeyCode; i <= src->maxKeyCode; i++) { +#define SI(r, c) (((r - src->minKeyCode) * src->mapWidth) + (c)) +#define DI(r, c) (((r - dst->minKeyCode) * dst->mapWidth) + (c)) + for (j = 0; j < src->mapWidth; j++) + dst->map[DI(i, j)] = src->map[SI(i, j)]; + for (j = src->mapWidth; j < dst->mapWidth; j++) + dst->map[DI(i, j)] = NoSymbol; +#undef SI +#undef DI + } + return TRUE; + } + else if (src->mapWidth > dst->mapWidth) { + i = sizeof(KeySym) * src->mapWidth * + (dst->maxKeyCode - dst->minKeyCode + 1); + tmp = calloc(sizeof(KeySym), i); + if (!tmp) + return FALSE; + + if (dst->map) { + for (i = 0; i <= dst->maxKeyCode-dst->minKeyCode; i++) + memmove(&tmp[i * src->mapWidth], &dst->map[i * dst->mapWidth], + dst->mapWidth * sizeof(KeySym)); + free(dst->map); + } + dst->mapWidth = src->mapWidth; + dst->map = tmp; + } + else if (!dst->map) { + i = sizeof(KeySym) * src->mapWidth * + (dst->maxKeyCode - dst->minKeyCode + 1); + tmp = calloc(sizeof(KeySym), i); + if (!tmp) + return FALSE; + + dst->map = tmp; + dst->mapWidth = src->mapWidth; + } + + memmove(&dst->map[rowDif * dst->mapWidth], src->map, + (src->maxKeyCode - src->minKeyCode + 1) * + dst->mapWidth * sizeof(KeySym)); + + return TRUE; +} + +Bool +InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons, Atom* labels, + CARD8 *map) +{ + ButtonClassPtr butc; + int i; + + butc = calloc(1, sizeof(ButtonClassRec)); + if (!butc) + return FALSE; + butc->numButtons = numButtons; + butc->sourceid = dev->id; + for (i = 1; i <= numButtons; i++) + butc->map[i] = map[i]; + for (i = numButtons + 1; i < MAP_LENGTH; i++) + butc->map[i] = i; + memcpy(butc->labels, labels, numButtons * sizeof(Atom)); + dev->button = butc; + return TRUE; +} + +Bool +InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels, + int numMotionEvents, int mode) +{ + int i; + ValuatorClassPtr valc; + union align_u { ValuatorClassRec valc; double d; } *align; + + if (!dev) + return FALSE; + + if (numAxes > MAX_VALUATORS) + { + LogMessage(X_WARNING, + "Device '%s' has %d axes, only using first %d.\n", + dev->name, numAxes, MAX_VALUATORS); + numAxes = MAX_VALUATORS; + } + + align = (union align_u *) calloc(1, sizeof(union align_u) + + numAxes * sizeof(double) + + numAxes * sizeof(AxisInfo)); + if (!align) + return FALSE; + + valc = &align->valc; + valc->sourceid = dev->id; + valc->motion = NULL; + valc->first_motion = 0; + valc->last_motion = 0; + + valc->numMotionEvents = numMotionEvents; + valc->motionHintWindow = NullWindow; + valc->numAxes = numAxes; + valc->axisVal = (double *)(align + 1); + valc->axes = (AxisInfoPtr)(valc->axisVal + numAxes); + + if (mode & OutOfProximity) + InitProximityClassDeviceStruct(dev); + + dev->valuator = valc; + + AllocateMotionHistory(dev); + + for (i=0; iaxisVal[i]=0; + } + + dev->last.numValuators = numAxes; + + if (IsMaster(dev) || /* do not accelerate master or xtest devices */ + IsXTestDevice(dev, NULL)) + InitPointerAccelerationScheme(dev, PtrAccelNoOp); + else + InitPointerAccelerationScheme(dev, PtrAccelDefault); + return TRUE; +} + +/* global list of acceleration schemes */ +ValuatorAccelerationRec pointerAccelerationScheme[] = { + {PtrAccelNoOp, NULL, NULL, NULL}, + {PtrAccelPredictable, acceleratePointerPredictable, NULL, AccelerationDefaultCleanup}, + {PtrAccelLightweight, acceleratePointerLightweight, NULL, NULL}, + {-1, NULL, NULL, NULL} /* terminator */ +}; + +/** + * install an acceleration scheme. returns TRUE on success, and should not + * change anything if unsuccessful. + */ +Bool +InitPointerAccelerationScheme(DeviceIntPtr dev, + int scheme) +{ + int x, i = -1; + void* data = NULL; + ValuatorClassPtr val; + + val = dev->valuator; + + if(!val) + return FALSE; + + if(IsMaster(dev) && scheme != PtrAccelNoOp) + return FALSE; + + for(x = 0; pointerAccelerationScheme[x].number >= 0; x++) { + if(pointerAccelerationScheme[x].number == scheme){ + i = x; + break; + } + } + + if(-1 == i) + return FALSE; + + if (val->accelScheme.AccelCleanupProc) + val->accelScheme.AccelCleanupProc(dev); + + /* init scheme-specific data */ + switch(scheme){ + case PtrAccelPredictable: + { + DeviceVelocityPtr s; + s = malloc(sizeof(DeviceVelocityRec)); + if(!s) + return FALSE; + InitVelocityData(s); + data = s; + break; + } + default: + break; + } + + val->accelScheme = pointerAccelerationScheme[i]; + val->accelScheme.accelData = data; + + /* post-init scheme */ + switch(scheme){ + case PtrAccelPredictable: + InitializePredictableAccelerationProperties(dev); + break; + + default: + break; + } + + return TRUE; +} + +Bool +InitAbsoluteClassDeviceStruct(DeviceIntPtr dev) +{ + AbsoluteClassPtr abs; + + abs = malloc(sizeof(AbsoluteClassRec)); + if (!abs) + return FALSE; + + /* we don't do anything sensible with these, but should */ + abs->min_x = NO_AXIS_LIMITS; + abs->min_y = NO_AXIS_LIMITS; + abs->max_x = NO_AXIS_LIMITS; + abs->max_y = NO_AXIS_LIMITS; + abs->flip_x = 0; + abs->flip_y = 0; + abs->rotation = 0; + abs->button_threshold = 0; + + abs->offset_x = 0; + abs->offset_y = 0; + abs->width = NO_AXIS_LIMITS; + abs->height = NO_AXIS_LIMITS; + abs->following = 0; + abs->screen = 0; + + abs->sourceid = dev->id; + + dev->absolute = abs; + + return TRUE; +} + +Bool +InitFocusClassDeviceStruct(DeviceIntPtr dev) +{ + FocusClassPtr focc; + + focc = malloc(sizeof(FocusClassRec)); + if (!focc) + return FALSE; + focc->win = PointerRootWin; + focc->revert = None; + focc->time = currentTime; + focc->trace = (WindowPtr *)NULL; + focc->traceSize = 0; + focc->traceGood = 0; + focc->sourceid = dev->id; + dev->focus = focc; + return TRUE; +} + +Bool +InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc) +{ + PtrFeedbackPtr feedc; + + feedc = malloc(sizeof(PtrFeedbackClassRec)); + if (!feedc) + return FALSE; + feedc->CtrlProc = controlProc; + feedc->ctrl = defaultPointerControl; + feedc->ctrl.id = 0; + if ( (feedc->next = dev->ptrfeed) ) + feedc->ctrl.id = dev->ptrfeed->ctrl.id + 1; + dev->ptrfeed = feedc; + (*controlProc)(dev, &feedc->ctrl); + return TRUE; +} + + +static LedCtrl defaultLedControl = { + DEFAULT_LEDS, DEFAULT_LEDS_MASK, 0}; + +static BellCtrl defaultBellControl = { + DEFAULT_BELL, + DEFAULT_BELL_PITCH, + DEFAULT_BELL_DURATION, + 0}; + +static IntegerCtrl defaultIntegerControl = { + DEFAULT_INT_RESOLUTION, + DEFAULT_INT_MIN_VALUE, + DEFAULT_INT_MAX_VALUE, + DEFAULT_INT_DISPLAYED, + 0}; + +Bool +InitStringFeedbackClassDeviceStruct ( + DeviceIntPtr dev, StringCtrlProcPtr controlProc, + int max_symbols, int num_symbols_supported, KeySym *symbols) +{ + int i; + StringFeedbackPtr feedc; + + feedc = malloc(sizeof(StringFeedbackClassRec)); + if (!feedc) + return FALSE; + feedc->CtrlProc = controlProc; + feedc->ctrl.num_symbols_supported = num_symbols_supported; + feedc->ctrl.num_symbols_displayed = 0; + feedc->ctrl.max_symbols = max_symbols; + feedc->ctrl.symbols_supported = malloc(sizeof (KeySym) * num_symbols_supported); + feedc->ctrl.symbols_displayed = malloc(sizeof (KeySym) * max_symbols); + if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed) + { + free(feedc->ctrl.symbols_supported); + free(feedc->ctrl.symbols_displayed); + free(feedc); + return FALSE; + } + for (i=0; ictrl.symbols_supported+i) = *symbols++; + for (i=0; ictrl.symbols_displayed+i) = (KeySym) 0; + feedc->ctrl.id = 0; + if ( (feedc->next = dev->stringfeed) ) + feedc->ctrl.id = dev->stringfeed->ctrl.id + 1; + dev->stringfeed = feedc; + (*controlProc)(dev, &feedc->ctrl); + return TRUE; +} + +Bool +InitBellFeedbackClassDeviceStruct (DeviceIntPtr dev, BellProcPtr bellProc, + BellCtrlProcPtr controlProc) +{ + BellFeedbackPtr feedc; + + feedc = malloc(sizeof(BellFeedbackClassRec)); + if (!feedc) + return FALSE; + feedc->CtrlProc = controlProc; + feedc->BellProc = bellProc; + feedc->ctrl = defaultBellControl; + feedc->ctrl.id = 0; + if ( (feedc->next = dev->bell) ) + feedc->ctrl.id = dev->bell->ctrl.id + 1; + dev->bell = feedc; + (*controlProc)(dev, &feedc->ctrl); + return TRUE; +} + +Bool +InitLedFeedbackClassDeviceStruct (DeviceIntPtr dev, LedCtrlProcPtr controlProc) +{ + LedFeedbackPtr feedc; + + feedc = malloc(sizeof(LedFeedbackClassRec)); + if (!feedc) + return FALSE; + feedc->CtrlProc = controlProc; + feedc->ctrl = defaultLedControl; + feedc->ctrl.id = 0; + if ( (feedc->next = dev->leds) ) + feedc->ctrl.id = dev->leds->ctrl.id + 1; + feedc->xkb_sli= NULL; + dev->leds = feedc; + (*controlProc)(dev, &feedc->ctrl); + return TRUE; +} + +Bool +InitIntegerFeedbackClassDeviceStruct (DeviceIntPtr dev, IntegerCtrlProcPtr controlProc) +{ + IntegerFeedbackPtr feedc; + + feedc = malloc(sizeof(IntegerFeedbackClassRec)); + if (!feedc) + return FALSE; + feedc->CtrlProc = controlProc; + feedc->ctrl = defaultIntegerControl; + feedc->ctrl.id = 0; + if ( (feedc->next = dev->intfeed) ) + feedc->ctrl.id = dev->intfeed->ctrl.id + 1; + dev->intfeed = feedc; + (*controlProc)(dev, &feedc->ctrl); + return TRUE; +} + +Bool +InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons, Atom* btn_labels, + PtrCtrlProcPtr controlProc, int numMotionEvents, + int numAxes, Atom *axes_labels) +{ + DeviceIntPtr dev = (DeviceIntPtr)device; + + return(InitButtonClassDeviceStruct(dev, numButtons, btn_labels, map) && + InitValuatorClassDeviceStruct(dev, numAxes, axes_labels, + numMotionEvents, Relative) && + InitPtrFeedbackClassDeviceStruct(dev, controlProc)); +} + +/* + * Check if the given buffer contains elements between low (inclusive) and + * high (inclusive) only. + * + * @return TRUE if the device map is invalid, FALSE otherwise. + */ +Bool +BadDeviceMap(BYTE *buff, int length, unsigned low, unsigned high, XID *errval) +{ + int i; + + for (i = 0; i < length; i++) + if (buff[i]) /* only check non-zero elements */ + { + if ((low > buff[i]) || (high < buff[i])) + { + *errval = buff[i]; + return TRUE; + } + } + return FALSE; +} + +int +ProcSetModifierMapping(ClientPtr client) +{ + xSetModifierMappingReply rep; + int rc; + REQUEST(xSetModifierMappingReq); + REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq); + + if (client->req_len != ((stuff->numKeyPerModifier << 1) + + bytes_to_int32(sizeof(xSetModifierMappingReq)))) + return BadLength; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + rc = change_modmap(client, PickKeyboard(client), (KeyCode *)&stuff[1], + stuff->numKeyPerModifier); + if (rc == MappingFailed || rc == -1) + return BadValue; + if (rc != Success && rc != MappingSuccess && rc != MappingFailed && + rc != MappingBusy) + return rc; + + rep.success = rc; + + WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep); + return Success; +} + +int +ProcGetModifierMapping(ClientPtr client) +{ + xGetModifierMappingReply rep; + int max_keys_per_mod = 0; + KeyCode *modkeymap = NULL; + REQUEST_SIZE_MATCH(xReq); + + generate_modkeymap(client, PickKeyboard(client), &modkeymap, + &max_keys_per_mod); + + memset(&rep, 0, sizeof(xGetModifierMappingReply)); + rep.type = X_Reply; + rep.numKeyPerModifier = max_keys_per_mod; + rep.sequenceNumber = client->sequence; + /* length counts 4 byte quantities - there are 8 modifiers 1 byte big */ + rep.length = max_keys_per_mod << 1; + + WriteReplyToClient(client, sizeof(xGetModifierMappingReply), &rep); + (void)WriteToClient(client, max_keys_per_mod * 8, (char *) modkeymap); + + free(modkeymap); + + return Success; +} + +int +ProcChangeKeyboardMapping(ClientPtr client) +{ + REQUEST(xChangeKeyboardMappingReq); + unsigned len; + KeySymsRec keysyms; + DeviceIntPtr pDev, tmp; + int rc; + REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq); + + len = client->req_len - bytes_to_int32(sizeof(xChangeKeyboardMappingReq)); + if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode)) + return BadLength; + + pDev = PickKeyboard(client); + + if ((stuff->firstKeyCode < pDev->key->xkbInfo->desc->min_key_code) || + (stuff->firstKeyCode > pDev->key->xkbInfo->desc->max_key_code)) { + client->errorValue = stuff->firstKeyCode; + return BadValue; + + } + if (((unsigned)(stuff->firstKeyCode + stuff->keyCodes - 1) > + pDev->key->xkbInfo->desc->max_key_code) || + (stuff->keySymsPerKeyCode == 0)) { + client->errorValue = stuff->keySymsPerKeyCode; + return BadValue; + } + + keysyms.minKeyCode = stuff->firstKeyCode; + keysyms.maxKeyCode = stuff->firstKeyCode + stuff->keyCodes - 1; + keysyms.mapWidth = stuff->keySymsPerKeyCode; + keysyms.map = (KeySym *) &stuff[1]; + + rc = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess); + if (rc != Success) + return rc; + + XkbApplyMappingChange(pDev, &keysyms, stuff->firstKeyCode, + stuff->keyCodes, NULL, client); + + for (tmp = inputInfo.devices; tmp; tmp = tmp->next) { + if (IsMaster(tmp) || tmp->u.master != pDev) + continue; + if (!tmp->key) + continue; + + rc = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess); + if (rc != Success) + continue; + + XkbApplyMappingChange(tmp, &keysyms, stuff->firstKeyCode, + stuff->keyCodes, NULL, client); + } + + return Success; +} + +int +ProcSetPointerMapping(ClientPtr client) +{ + BYTE *map; + int ret; + int i, j; + DeviceIntPtr ptr = PickPointer(client); + xSetPointerMappingReply rep; + REQUEST(xSetPointerMappingReq); + REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq); + + if (client->req_len != + bytes_to_int32(sizeof(xSetPointerMappingReq) + stuff->nElts)) + return BadLength; + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.success = MappingSuccess; + map = (BYTE *)&stuff[1]; + + /* So we're bounded here by the number of core buttons. This check + * probably wants disabling through XFixes. */ + /* MPX: With ClientPointer, we can return the right number of buttons. + * Let's just hope nobody changed ClientPointer between GetPointerMapping + * and SetPointerMapping + */ + if (stuff->nElts != ptr->button->numButtons) { + client->errorValue = stuff->nElts; + return BadValue; + } + + /* Core protocol specs don't allow for duplicate mappings; this check + * almost certainly wants disabling through XFixes too. */ + for (i = 0; i < stuff->nElts; i++) { + for (j = i + 1; j < stuff->nElts; j++) { + if (map[i] && map[i] == map[j]) { + client->errorValue = map[i]; + return BadValue; + } + } + } + + ret = ApplyPointerMapping(ptr, map, stuff->nElts, client); + if (ret == MappingBusy) + rep.success = ret; + else if (ret == -1) + return BadValue; + else if (ret != Success) + return ret; + + WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep); + return Success; +} + +int +ProcGetKeyboardMapping(ClientPtr client) +{ + xGetKeyboardMappingReply rep; + DeviceIntPtr kbd = PickKeyboard(client); + XkbDescPtr xkb; + KeySymsPtr syms; + int rc; + REQUEST(xGetKeyboardMappingReq); + REQUEST_SIZE_MATCH(xGetKeyboardMappingReq); + + rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetAttrAccess); + if (rc != Success) + return rc; + + xkb = kbd->key->xkbInfo->desc; + + if ((stuff->firstKeyCode < xkb->min_key_code) || + (stuff->firstKeyCode > xkb->max_key_code)) { + client->errorValue = stuff->firstKeyCode; + return BadValue; + } + if (stuff->firstKeyCode + stuff->count > xkb->max_key_code + 1) { + client->errorValue = stuff->count; + return BadValue; + } + + syms = XkbGetCoreMap(kbd); + if (!syms) + return BadAlloc; + + memset(&rep, 0, sizeof(xGetKeyboardMappingReply)); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.keySymsPerKeyCode = syms->mapWidth; + /* length is a count of 4 byte quantities and KeySyms are 4 bytes */ + rep.length = syms->mapWidth * stuff->count; + WriteReplyToClient(client, sizeof(xGetKeyboardMappingReply), &rep); + client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; + WriteSwappedDataToClient(client, + syms->mapWidth * stuff->count * sizeof(KeySym), + &syms->map[syms->mapWidth * (stuff->firstKeyCode - + syms->minKeyCode)]); + free(syms->map); + free(syms); + + return Success; +} + +int +ProcGetPointerMapping(ClientPtr client) +{ + xGetPointerMappingReply rep; + /* Apps may get different values each time they call GetPointerMapping as + * the ClientPointer could change. */ + DeviceIntPtr ptr = PickPointer(client); + ButtonClassPtr butc = ptr->button; + int rc; + REQUEST_SIZE_MATCH(xReq); + + rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, DixGetAttrAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.nElts = (butc) ? butc->numButtons : 0; + rep.length = ((unsigned)rep.nElts + (4-1))/4; + WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep); + if (butc) + WriteToClient(client, (int)rep.nElts, (char *)&butc->map[1]); + return Success; +} + +void +NoteLedState(DeviceIntPtr keybd, int led, Bool on) +{ + KeybdCtrl *ctrl = &keybd->kbdfeed->ctrl; + if (on) + ctrl->leds |= ((Leds)1 << (led - 1)); + else + ctrl->leds &= ~((Leds)1 << (led - 1)); +} + +int +Ones(unsigned long mask) /* HACKMEM 169 */ +{ + unsigned long y; + + y = (mask >> 1) &033333333333; + y = mask - y - ((y >>1) & 033333333333); + return (((y + (y >> 3)) & 030707070707) % 077); +} + +static int +DoChangeKeyboardControl (ClientPtr client, DeviceIntPtr keybd, XID *vlist, + BITS32 vmask) +{ +#define DO_ALL (-1) + KeybdCtrl ctrl; + int t; + int led = DO_ALL; + int key = DO_ALL; + BITS32 index2; + int mask = vmask, i; + XkbEventCauseRec cause; + + ctrl = keybd->kbdfeed->ctrl; + while (vmask) { + index2 = (BITS32) lowbit (vmask); + vmask &= ~index2; + switch (index2) { + case KBKeyClickPercent: + t = (INT8)*vlist; + vlist++; + if (t == -1) { + t = defaultKeyboardControl.click; + } + else if (t < 0 || t > 100) { + client->errorValue = t; + return BadValue; + } + ctrl.click = t; + break; + case KBBellPercent: + t = (INT8)*vlist; + vlist++; + if (t == -1) { + t = defaultKeyboardControl.bell; + } + else if (t < 0 || t > 100) { + client->errorValue = t; + return BadValue; + } + ctrl.bell = t; + break; + case KBBellPitch: + t = (INT16)*vlist; + vlist++; + if (t == -1) { + t = defaultKeyboardControl.bell_pitch; + } + else if (t < 0) { + client->errorValue = t; + return BadValue; + } + ctrl.bell_pitch = t; + break; + case KBBellDuration: + t = (INT16)*vlist; + vlist++; + if (t == -1) + t = defaultKeyboardControl.bell_duration; + else if (t < 0) { + client->errorValue = t; + return BadValue; + } + ctrl.bell_duration = t; + break; + case KBLed: + led = (CARD8)*vlist; + vlist++; + if (led < 1 || led > 32) { + client->errorValue = led; + return BadValue; + } + if (!(mask & KBLedMode)) + return BadMatch; + break; + case KBLedMode: + t = (CARD8)*vlist; + vlist++; + if (t == LedModeOff) { + if (led == DO_ALL) + ctrl.leds = 0x0; + else + ctrl.leds &= ~(((Leds)(1)) << (led - 1)); + } + else if (t == LedModeOn) { + if (led == DO_ALL) + ctrl.leds = ~0L; + else + ctrl.leds |= (((Leds)(1)) << (led - 1)); + } + else { + client->errorValue = t; + return BadValue; + } + + XkbSetCauseCoreReq(&cause,X_ChangeKeyboardControl,client); + XkbSetIndicators(keybd,((led == DO_ALL) ? ~0L : (1L<<(led-1))), + ctrl.leds, &cause); + ctrl.leds = keybd->kbdfeed->ctrl.leds; + + break; + case KBKey: + key = (KeyCode)*vlist; + vlist++; + if ((KeyCode)key < keybd->key->xkbInfo->desc->min_key_code || + (KeyCode)key > keybd->key->xkbInfo->desc->max_key_code) { + client->errorValue = key; + return BadValue; + } + if (!(mask & KBAutoRepeatMode)) + return BadMatch; + break; + case KBAutoRepeatMode: + i = (key >> 3); + mask = (1 << (key & 7)); + t = (CARD8)*vlist; + vlist++; + if (key != DO_ALL) + XkbDisableComputedAutoRepeats(keybd,key); + if (t == AutoRepeatModeOff) { + if (key == DO_ALL) + ctrl.autoRepeat = FALSE; + else + ctrl.autoRepeats[i] &= ~mask; + } + else if (t == AutoRepeatModeOn) { + if (key == DO_ALL) + ctrl.autoRepeat = TRUE; + else + ctrl.autoRepeats[i] |= mask; + } + else if (t == AutoRepeatModeDefault) { + if (key == DO_ALL) + ctrl.autoRepeat = defaultKeyboardControl.autoRepeat; + else + ctrl.autoRepeats[i] = + (ctrl.autoRepeats[i] & ~mask) | + (defaultKeyboardControl.autoRepeats[i] & mask); + } + else { + client->errorValue = t; + return BadValue; + } + break; + default: + client->errorValue = mask; + return BadValue; + } + } + keybd->kbdfeed->ctrl = ctrl; + + /* The XKB RepeatKeys control and core protocol global autorepeat */ + /* value are linked */ + XkbSetRepeatKeys(keybd, key, keybd->kbdfeed->ctrl.autoRepeat); + + return Success; + +#undef DO_ALL +} + +/** + * Changes kbd control on the ClientPointer and all attached SDs. + */ +int +ProcChangeKeyboardControl (ClientPtr client) +{ + XID *vlist; + BITS32 vmask; + int ret = Success, error = Success; + DeviceIntPtr pDev = NULL, keyboard; + REQUEST(xChangeKeyboardControlReq); + + REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq); + + vmask = stuff->mask; + vlist = (XID *)&stuff[1]; + + if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask)) + return BadLength; + + keyboard = PickKeyboard(client); + + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { + if ((pDev == keyboard || + (!IsMaster(pDev) && GetMaster(pDev, MASTER_KEYBOARD) == keyboard)) + && pDev->kbdfeed && pDev->kbdfeed->CtrlProc) { + ret = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess); + if (ret != Success) + return ret; + } + } + + for (pDev = inputInfo.devices; pDev; pDev = pDev->next) { + if ((pDev == keyboard || + (!IsMaster(pDev) && GetMaster(pDev, MASTER_KEYBOARD) == keyboard)) + && pDev->kbdfeed && pDev->kbdfeed->CtrlProc) { + ret = DoChangeKeyboardControl(client, pDev, vlist, vmask); + if (ret != Success) + error = ret; + } + } + + return error; +} + +int +ProcGetKeyboardControl (ClientPtr client) +{ + int rc, i; + DeviceIntPtr kbd = PickKeyboard(client); + KeybdCtrl *ctrl = &kbd->kbdfeed->ctrl; + xGetKeyboardControlReply rep; + REQUEST_SIZE_MATCH(xReq); + + rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetAttrAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.length = 5; + rep.sequenceNumber = client->sequence; + rep.globalAutoRepeat = ctrl->autoRepeat; + rep.keyClickPercent = ctrl->click; + rep.bellPercent = ctrl->bell; + rep.bellPitch = ctrl->bell_pitch; + rep.bellDuration = ctrl->bell_duration; + rep.ledMask = ctrl->leds; + for (i = 0; i < 32; i++) + rep.map[i] = ctrl->autoRepeats[i]; + WriteReplyToClient(client, sizeof(xGetKeyboardControlReply), &rep); + return Success; +} + +int +ProcBell(ClientPtr client) +{ + DeviceIntPtr dev, keybd = PickKeyboard(client); + int base = keybd->kbdfeed->ctrl.bell; + int newpercent; + int rc; + REQUEST(xBellReq); + REQUEST_SIZE_MATCH(xBellReq); + + if (stuff->percent < -100 || stuff->percent > 100) { + client->errorValue = stuff->percent; + return BadValue; + } + + newpercent = (base * stuff->percent) / 100; + if (stuff->percent < 0) + newpercent = base + newpercent; + else + newpercent = base - newpercent + stuff->percent; + + for (dev = inputInfo.devices; dev; dev = dev->next) { + if ((dev == keybd || + (!IsMaster(dev) && GetMaster(dev, MASTER_KEYBOARD) == keybd)) && + dev->kbdfeed && dev->kbdfeed->BellProc) { + + rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixBellAccess); + if (rc != Success) + return rc; + XkbHandleBell(FALSE, FALSE, dev, newpercent, + &dev->kbdfeed->ctrl, 0, None, NULL, client); + } + } + + return Success; +} + +int +ProcChangePointerControl(ClientPtr client) +{ + DeviceIntPtr dev, mouse = PickPointer(client); + PtrCtrl ctrl; /* might get BadValue part way through */ + int rc; + REQUEST(xChangePointerControlReq); + REQUEST_SIZE_MATCH(xChangePointerControlReq); + + ctrl = mouse->ptrfeed->ctrl; + if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse)) { + client->errorValue = stuff->doAccel; + return BadValue; + } + if ((stuff->doThresh != xTrue) && (stuff->doThresh != xFalse)) { + client->errorValue = stuff->doThresh; + return BadValue; + } + if (stuff->doAccel) { + if (stuff->accelNum == -1) { + ctrl.num = defaultPointerControl.num; + } + else if (stuff->accelNum < 0) { + client->errorValue = stuff->accelNum; + return BadValue; + } + else { + ctrl.num = stuff->accelNum; + } + + if (stuff->accelDenum == -1) { + ctrl.den = defaultPointerControl.den; + } + else if (stuff->accelDenum <= 0) { + client->errorValue = stuff->accelDenum; + return BadValue; + } + else { + ctrl.den = stuff->accelDenum; + } + } + if (stuff->doThresh) { + if (stuff->threshold == -1) { + ctrl.threshold = defaultPointerControl.threshold; + } + else if (stuff->threshold < 0) { + client->errorValue = stuff->threshold; + return BadValue; + } + else { + ctrl.threshold = stuff->threshold; + } + } + + for (dev = inputInfo.devices; dev; dev = dev->next) { + if ((dev == mouse || + (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) == mouse)) && + dev->ptrfeed) { + rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixManageAccess); + if (rc != Success) + return rc; + } + } + + for (dev = inputInfo.devices; dev; dev = dev->next) { + if ((dev == mouse || + (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) == mouse)) && + dev->ptrfeed) { + dev->ptrfeed->ctrl = ctrl; + } + } + + return Success; +} + +int +ProcGetPointerControl(ClientPtr client) +{ + DeviceIntPtr ptr = PickPointer(client); + PtrCtrl *ctrl = &ptr->ptrfeed->ctrl; + xGetPointerControlReply rep; + int rc; + REQUEST_SIZE_MATCH(xReq); + + rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, DixGetAttrAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.threshold = ctrl->threshold; + rep.accelNumerator = ctrl->num; + rep.accelDenominator = ctrl->den; + WriteReplyToClient(client, sizeof(xGenericReply), &rep); + return Success; +} + +void +MaybeStopHint(DeviceIntPtr dev, ClientPtr client) +{ + GrabPtr grab = dev->deviceGrab.grab; + + if ((grab && SameClient(grab, client) && + ((grab->eventMask & PointerMotionHintMask) || + (grab->ownerEvents && + (EventMaskForClient(dev->valuator->motionHintWindow, client) & + PointerMotionHintMask)))) || + (!grab && + (EventMaskForClient(dev->valuator->motionHintWindow, client) & + PointerMotionHintMask))) + dev->valuator->motionHintWindow = NullWindow; +} + +int +ProcGetMotionEvents(ClientPtr client) +{ + WindowPtr pWin; + xTimecoord * coords = (xTimecoord *) NULL; + xGetMotionEventsReply rep; + int i, count, xmin, xmax, ymin, ymax, rc; + unsigned long nEvents; + DeviceIntPtr mouse = PickPointer(client); + TimeStamp start, stop; + REQUEST(xGetMotionEventsReq); + REQUEST_SIZE_MATCH(xGetMotionEventsReq); + + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixReadAccess); + if (rc != Success) + return rc; + + if (mouse->valuator->motionHintWindow) + MaybeStopHint(mouse, client); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + nEvents = 0; + start = ClientTimeToServerTime(stuff->start); + stop = ClientTimeToServerTime(stuff->stop); + if ((CompareTimeStamps(start, stop) != LATER) && + (CompareTimeStamps(start, currentTime) != LATER) && + mouse->valuator->numMotionEvents) + { + if (CompareTimeStamps(stop, currentTime) == LATER) + stop = currentTime; + count = GetMotionHistory(mouse, &coords, start.milliseconds, + stop.milliseconds, pWin->drawable.pScreen, + TRUE); + xmin = pWin->drawable.x - wBorderWidth (pWin); + xmax = pWin->drawable.x + (int)pWin->drawable.width + + wBorderWidth (pWin); + ymin = pWin->drawable.y - wBorderWidth (pWin); + ymax = pWin->drawable.y + (int)pWin->drawable.height + + wBorderWidth (pWin); + for (i = 0; i < count; i++) + if ((xmin <= coords[i].x) && (coords[i].x < xmax) && + (ymin <= coords[i].y) && (coords[i].y < ymax)) + { + coords[nEvents].time = coords[i].time; + coords[nEvents].x = coords[i].x - pWin->drawable.x; + coords[nEvents].y = coords[i].y - pWin->drawable.y; + nEvents++; + } + } + rep.length = nEvents * bytes_to_int32(sizeof(xTimecoord)); + rep.nEvents = nEvents; + WriteReplyToClient(client, sizeof(xGetMotionEventsReply), &rep); + if (nEvents) + { + client->pSwapReplyFunc = (ReplySwapPtr) SwapTimeCoordWrite; + WriteSwappedDataToClient(client, nEvents * sizeof(xTimecoord), + (char *)coords); + } + free(coords); + return Success; +} + +int +ProcQueryKeymap(ClientPtr client) +{ + xQueryKeymapReply rep; + int rc, i; + DeviceIntPtr keybd = PickKeyboard(client); + CARD8 *down = keybd->key->down; + + REQUEST_SIZE_MATCH(xReq); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 2; + + rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess); + if (rc != Success && rc != BadAccess) + return rc; + + for (i = 0; i<32; i++) + rep.map[i] = down[i]; + + if (rc == BadAccess) + memset(rep.map, 0, 32); + + WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep); + + return Success; +} + + +/** + * Recalculate the number of buttons for the master device. The number of + * buttons on the master device is equal to the number of buttons on the + * slave device with the highest number of buttons. + */ +static void +RecalculateMasterButtons(DeviceIntPtr slave) +{ + DeviceIntPtr dev, master; + int maxbuttons = 0; + + if (!slave->button || IsMaster(slave)) + return; + + master = GetMaster(slave, MASTER_POINTER); + if (!master) + return; + + for (dev = inputInfo.devices; dev; dev = dev->next) + { + if (IsMaster(dev) || + dev->u.master != master || + !dev->button) + continue; + + maxbuttons = max(maxbuttons, dev->button->numButtons); + } + + if (master->button && master->button->numButtons != maxbuttons) + { + int i; + DeviceChangedEvent event; + + memset(&event, 0, sizeof(event)); + + master->button->numButtons = maxbuttons; + + event.header = ET_Internal; + event.type = ET_DeviceChanged; + event.time = GetTimeInMillis(); + event.deviceid = master->id; + event.flags = DEVCHANGE_POINTER_EVENT | DEVCHANGE_DEVICE_CHANGE; + event.buttons.num_buttons = maxbuttons; + memcpy(&event.buttons.names, master->button->labels, maxbuttons * + sizeof(Atom)); + + if (master->valuator) + { + event.num_valuators = master->valuator->numAxes; + for (i = 0; i < event.num_valuators; i++) + { + event.valuators[i].min = master->valuator->axes[i].min_value; + event.valuators[i].max = master->valuator->axes[i].max_value; + event.valuators[i].resolution = master->valuator->axes[i].resolution; + event.valuators[i].mode = master->valuator->axes[i].mode; + event.valuators[i].name = master->valuator->axes[i].label; + } + } + + if (master->key) + { + event.keys.min_keycode = master->key->xkbInfo->desc->min_key_code; + event.keys.max_keycode = master->key->xkbInfo->desc->max_key_code; + } + + XISendDeviceChangedEvent(master, master, &event); + } +} + +/** + * Attach device 'dev' to device 'master'. + * Client is set to the client that issued the request, or NULL if it comes + * from some internal automatic pairing. + * + * Master may be NULL to set the device floating. + * + * We don't allow multi-layer hierarchies right now. You can't attach a slave + * to another slave. + */ +int +AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master) +{ + ScreenPtr screen; + DeviceIntPtr oldmaster; + if (!dev || IsMaster(dev)) + return BadDevice; + + if (master && !IsMaster(master)) /* can't attach to slaves */ + return BadDevice; + + /* set from floating to floating? */ + if (!dev->u.master && !master && dev->enabled) + return Success; + + /* free the existing sprite. */ + if (!dev->u.master && dev->spriteInfo->paired == dev) + { + screen = miPointerGetScreen(dev); + screen->DeviceCursorCleanup(dev, screen); + free(dev->spriteInfo->sprite); + } + + oldmaster = dev->u.master; + dev->u.master = master; + + /* If device is set to floating, we need to create a sprite for it, + * otherwise things go bad. However, we don't want to render the cursor, + * so we reset spriteOwner. + * Sprite has to be forced to NULL first, otherwise InitializeSprite won't + * alloc new memory but overwrite the previous one. + */ + if (!master) + { + WindowPtr currentRoot; + + if (dev->spriteInfo->sprite) + currentRoot = GetCurrentRootWindow(dev); + else /* new device auto-set to floating */ + currentRoot = screenInfo.screens[0]->root; + + /* we need to init a fake sprite */ + screen = currentRoot->drawable.pScreen; + screen->DeviceCursorInitialize(dev, screen); + dev->spriteInfo->sprite = NULL; + InitializeSprite(dev, currentRoot); + dev->spriteInfo->spriteOwner = FALSE; + dev->spriteInfo->paired = dev; + } else + { + dev->spriteInfo->sprite = master->spriteInfo->sprite; + dev->spriteInfo->paired = master; + dev->spriteInfo->spriteOwner = FALSE; + + RecalculateMasterButtons(master); + } + + /* XXX: in theory, the MD should change back to its old, original + * classes when the last SD is detached. Thanks to the XTEST devices, + * we'll always have an SD attached until the MD is removed. + * So let's not worry about that. + */ + + return Success; +} + +/** + * Return the device paired with the given device or NULL. + * Returns the device paired with the parent master if the given device is a + * slave device. + */ +DeviceIntPtr +GetPairedDevice(DeviceIntPtr dev) +{ + if (!IsMaster(dev) && dev->u.master) + dev = dev->u.master; + + return dev->spriteInfo->paired; +} + + +/** + * Returns the right master for the type of event needed. If the event is a + * keyboard event. + * This function may be called with a master device as argument. If so, the + * returned master is either the device itself or the paired master device. + * If dev is a floating slave device, NULL is returned. + * + * @type ::MASTER_KEYBOARD or ::MASTER_POINTER + */ +DeviceIntPtr +GetMaster(DeviceIntPtr dev, int which) +{ + DeviceIntPtr master; + + if (IsMaster(dev)) + master = dev; + else + master = dev->u.master; + + if (master) + { + if (which == MASTER_KEYBOARD) + { + if (master->type != MASTER_KEYBOARD) + master = GetPairedDevice(master); + } else + { + if (master->type != MASTER_POINTER) + master = GetPairedDevice(master); + } + } + + return master; +} + +/** + * Create a new device pair (== one pointer, one keyboard device). + * Only allocates the devices, you will need to call ActivateDevice() and + * EnableDevice() manually. + * Either a master or a slave device can be created depending on + * the value for master. + */ +int +AllocDevicePair (ClientPtr client, char* name, + DeviceIntPtr* ptr, + DeviceIntPtr* keybd, + DeviceProc ptr_proc, + DeviceProc keybd_proc, + Bool master) +{ + DeviceIntPtr pointer; + DeviceIntPtr keyboard; + *ptr = *keybd = NULL; + + pointer = AddInputDevice(client, ptr_proc, TRUE); + if (!pointer) + return BadAlloc; + + if (asprintf(&pointer->name, "%s pointer", name) == -1) { + pointer->name = NULL; + RemoveDevice(pointer, FALSE); + return BadAlloc; + } + + pointer->public.processInputProc = ProcessOtherEvent; + pointer->public.realInputProc = ProcessOtherEvent; + XkbSetExtension(pointer, ProcessPointerEvent); + pointer->deviceGrab.ActivateGrab = ActivatePointerGrab; + pointer->deviceGrab.DeactivateGrab = DeactivatePointerGrab; + pointer->coreEvents = TRUE; + pointer->spriteInfo->spriteOwner = TRUE; + + pointer->u.lastSlave = NULL; + pointer->last.slave = NULL; + pointer->type = (master) ? MASTER_POINTER : SLAVE; + + keyboard = AddInputDevice(client, keybd_proc, TRUE); + if (!keyboard) + { + RemoveDevice(pointer, FALSE); + return BadAlloc; + } + + if (asprintf(&keyboard->name, "%s keyboard", name) == -1) { + keyboard->name = NULL; + RemoveDevice(keyboard, FALSE); + RemoveDevice(pointer, FALSE); + return BadAlloc; + } + + keyboard->public.processInputProc = ProcessOtherEvent; + keyboard->public.realInputProc = ProcessOtherEvent; + XkbSetExtension(keyboard, ProcessKeyboardEvent); + keyboard->deviceGrab.ActivateGrab = ActivateKeyboardGrab; + keyboard->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab; + keyboard->coreEvents = TRUE; + keyboard->spriteInfo->spriteOwner = FALSE; + + keyboard->u.lastSlave = NULL; + keyboard->last.slave = NULL; + keyboard->type = (master) ? MASTER_KEYBOARD : SLAVE; + + /* The ClassesRec stores the device classes currently not used. */ + pointer->unused_classes = calloc(1, sizeof(ClassesRec)); + keyboard->unused_classes = calloc(1, sizeof(ClassesRec)); + + *ptr = pointer; + *keybd = keyboard; + + return Success; +} + +/** + * Return Relative or Absolute for the device. + */ +int valuator_get_mode(DeviceIntPtr dev, int axis) +{ + return (dev->valuator->axes[axis].mode & DeviceMode); +} + +/** + * Set the given mode for the axis. If axis is VALUATOR_MODE_ALL_AXES, then + * set the mode for all axes. + */ +void valuator_set_mode(DeviceIntPtr dev, int axis, int mode) +{ + if (axis != VALUATOR_MODE_ALL_AXES) + dev->valuator->axes[axis].mode = mode; + else { + int i; + for (i = 0; i < dev->valuator->numAxes; i++) + dev->valuator->axes[i].mode = mode; + } +} diff --git a/xorg-server/hw/dmx/doc/Makefile.am b/xorg-server/hw/dmx/doc/Makefile.am index 4bbc8bf88..8e7360288 100644 --- a/xorg-server/hw/dmx/doc/Makefile.am +++ b/xorg-server/hw/dmx/doc/Makefile.am @@ -24,34 +24,14 @@ doc_sources = dmx.xml scaled.xml # Developer's documentation is not installed if ENABLE_DEVEL_DOCS include $(top_srcdir)/doc/xml/xmlrules-noinst.in - -if HAVE_DOXYGEN - -DOXYGEN_SRC=doxygen.head doxygen.foot doxygen.css doxygen.conf - -all-local: html/annotated.html - -dist-local: html/annotated.html - -html/annotated.html: $(DOXYGEN_SRC) - $(DOXYGEN) $(srcdir)/doxygen.conf - -maintainer-clean-local: - rm -rf html/ -endif endif ENABLE_DEVEL_DOCS -EXTRA_DIST = \ - $(XML_FILES) \ - DMXSpec.txt \ - DMXSpec-v1.txt \ +DOXYGEN_HEAD=\ + html/annotated.html + +DOXYGEN_REST= \ dmx.txt \ - doxygen.conf \ - doxygen.css \ - doxygen.foot \ - doxygen.head \ scaled.txt \ - html/annotated.html \ html/ChkNotMaskEv_8c.html \ html/ChkNotMaskEv_8h.html \ html/ChkNotMaskEv_8h_source.html \ @@ -254,6 +234,41 @@ EXTRA_DIST = \ html/usb-private_8h.html \ html/usb-private_8h_source.html +DOXYGEN_FILES=$(DOXYGEN_HEAD) $(DOXYGEN_REST) + +EXTRA_DIST = \ + $(XML_FILES) \ + DMXSpec.txt \ + DMXSpec-v1.txt \ + doxygen.conf \ + doxygen.css \ + doxygen.foot \ + doxygen.head \ + $(DOXYGEN_FILES) + +if ENABLE_DEVEL_DOCS +if HAVE_DOXYGEN + +DOXYGEN_SRC=doxygen.head doxygen.foot doxygen.css doxygen.conf + +all-local: $(DOXYGEN_FILES) + +dist-local: $(DOXYGEN_FILES) + +$(DOXYGEN_HEAD): $(DOXYGEN_SRC) + $(DOXYGEN) doxygen.conf + +$(DOXYGEN_REST): $(DOXYGEN_HEAD) + +maintainer-clean-local: + rm -rf html/ scaled.txt dmx.txt + +distclean-local: + rm -rf html/ scaled.txt dmx.txt + +endif HAVE_DOXYGEN +endif ENABLE_DEVEL_DOCS + $(builddir)/doxygen.head: $(LN_S) $(srcdir)/doxygen.head $@ diff --git a/xorg-server/hw/dmx/doc/doxygen.conf b/xorg-server/hw/dmx/doc/doxygen.conf deleted file mode 100644 index f7a541f90..000000000 --- a/xorg-server/hw/dmx/doc/doxygen.conf +++ /dev/null @@ -1,1053 +0,0 @@ -# Doxyfile 1.3.4 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = "Distributed Multihead X" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = "dmx-1-2-20040604 and later" - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, -# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en -# (Japanese with English messages), Korean, Norwegian, Polish, Portuguese, -# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = YES - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited -# members of a class in the documentation of that class as if those members were -# ordinary class members. Constructors, destructors and assignment operators of -# the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. It is allowed to use relative paths in the argument list. - -STRIP_FROM_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explict @brief command for a brief description. - -JAVADOC_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# reimplements. - -INHERIT_DOCS = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources -# only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = YES - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = YES - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = .. \ - ../input \ - ../config - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp -# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = ../config/parser.c \ - ../config/parser.h \ - ../config/scanner.c - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories -# that are symbolic links (a Unix filesystem feature) are excluded from the input. - -EXCLUDE_SYMLINKS = YES - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. - -EXCLUDE_PATTERNS = atKeynames.h \ - Canvas*.* - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. - -INPUT_FILTER = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = doxygen.head - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = doxygen.foot - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet - -HTML_STYLESHEET = doxygen.css - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output dir. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = YES - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimised for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assigments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_PREDEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. - -PREDEFINED = SHAPE \ - RENDER \ - XKB \ - XINPUT - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse the -# parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or -# super classes. Setting the tag to NO turns the diagrams off. Note that this -# option is superceded by the HAVE_DOT option below. This is only a fallback. It is -# recommended to install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similiar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = gif - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found on the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes that -# lay further from the root node will be omitted. Note that setting this option to -# 1 or 2 may greatly reduce the computation time needed for large code bases. Also -# note that a graph may be further truncated if the graph's image dimensions are -# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). -# If 0 is used for the depth value (the default), the graph is not depth-constrained. - -MAX_DOT_GRAPH_DEPTH = 0 - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff --git a/xorg-server/hw/dmx/doc/doxygen.conf.in b/xorg-server/hw/dmx/doc/doxygen.conf.in new file mode 100644 index 000000000..f886a436f --- /dev/null +++ b/xorg-server/hw/dmx/doc/doxygen.conf.in @@ -0,0 +1,1053 @@ +# Doxyfile 1.3.4 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "Distributed Multihead X" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = "dmx-1-2-20040604 and later" + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, +# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en +# (Japanese with English messages), Korean, Norwegian, Polish, Portuguese, +# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = YES + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited +# members of a class in the documentation of that class as if those members were +# ordinary class members. Constructors, destructors and assignment operators of +# the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. It is allowed to use relative paths in the argument list. + +STRIP_FROM_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like the Qt-style comments (thus requiring an +# explict @brief command for a brief description. + +JAVADOC_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# reimplements. + +INHERIT_DOCS = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources +# only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = YES + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = YES + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = @srcdir@/.. \ + @srcdir@/../input \ + @srcdir@/../config + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp +# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = @srcdir@/../config/parser.c \ + @srcdir@/../config/parser.h \ + @srcdir@/../config/scanner.c + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories +# that are symbolic links (a Unix filesystem feature) are excluded from the input. + +EXCLUDE_SYMLINKS = YES + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. + +EXCLUDE_PATTERNS = atKeynames.h \ + Canvas*.* + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. + +INPUT_FILTER = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = @srcdir@/doxygen.head + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = @srcdir@/doxygen.foot + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet + +HTML_STYLESHEET = @srcdir@/doxygen.css + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output dir. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = YES + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimised for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assigments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_PREDEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. + +PREDEFINED = SHAPE \ + RENDER \ + XKB \ + XINPUT + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse the +# parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::addtions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or +# super classes. Setting the tag to NO turns the diagrams off. Note that this +# option is superceded by the HAVE_DOT option below. This is only a fallback. It is +# recommended to install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = YES + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similiar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = gif + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found on the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes that +# lay further from the root node will be omitted. Note that setting this option to +# 1 or 2 may greatly reduce the computation time needed for large code bases. Also +# note that a graph may be further truncated if the graph's image dimensions are +# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). +# If 0 is used for the depth value (the default), the graph is not depth-constrained. + +MAX_DOT_GRAPH_DEPTH = 0 + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::addtions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/xorg-server/hw/xfree86/loader/Makefile.am b/xorg-server/hw/xfree86/loader/Makefile.am index acacda650..7f386ccc0 100644 --- a/xorg-server/hw/xfree86/loader/Makefile.am +++ b/xorg-server/hw/xfree86/loader/Makefile.am @@ -1,29 +1,30 @@ -noinst_LTLIBRARIES = libloader.la - -INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(top_srcdir)/miext/cw \ - -I$(srcdir)/../ddc -I$(srcdir)/../i2c -I$(srcdir)/../modes \ - -I$(srcdir)/../ramdac - -#AM_LDFLAGS = -r -AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) - -EXTRA_DIST = \ - loader.h \ - loaderProcs.h \ - sdksyms.sh - -libloader_la_SOURCES = \ - loader.c \ - loaderProcs.h \ - loadext.c \ - loadmod.c \ - os.c \ - sdksyms.c -libloader_la_LIBADD = $(DLOPEN_LIBS) - -CLEANFILES = sdksyms.c sdksyms.dep - -sdksyms.dep sdksyms.c: sdksyms.sh - CPP='$(CPP)' AWK='$(AWK)' $(srcdir)/sdksyms.sh $(top_srcdir) $(AM_CFLAGS) $(CFLAGS) $(INCLUDES) - -sinclude sdksyms.dep +noinst_LTLIBRARIES = libloader.la + +INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(top_srcdir)/miext/cw \ + -I$(srcdir)/../ddc -I$(srcdir)/../i2c -I$(srcdir)/../modes \ + -I$(srcdir)/../ramdac + +#AM_LDFLAGS = -r +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) + +EXTRA_DIST = \ + loader.h \ + loaderProcs.h \ + sdksyms.sh + +libloader_la_SOURCES = \ + loader.c \ + loaderProcs.h \ + loadext.c \ + loadmod.c \ + os.c \ + sdksyms.c +libloader_la_LIBADD = $(DLOPEN_LIBS) + +CLEANFILES = sdksyms.c sdksyms.dep + +sdksyms.dep sdksyms.c: sdksyms.sh + CPP='$(CPP)' AWK='$(AWK)' $(srcdir)/sdksyms.sh $(top_srcdir) $(AM_CFLAGS) $(CFLAGS) $(INCLUDES) + +SDKSYMS_DEP = sdksyms.dep +include $(SDKSYMS_DEP) diff --git a/xorg-server/hw/xwin/glx/Makefile.am b/xorg-server/hw/xwin/glx/Makefile.am index dae58bf89..303ff53f2 100644 --- a/xorg-server/hw/xwin/glx/Makefile.am +++ b/xorg-server/hw/xwin/glx/Makefile.am @@ -1,60 +1,60 @@ -noinst_LTLIBRARIES = libXwinGLX.la - -libXwinGLX_la_SOURCES = \ - winpriv.c \ - winpriv.h \ - glwindows.h \ - glwrap.c \ - indirect.c \ - wgl_ext_api.c - -if XWIN_MULTIWINDOW -DEFS_MULTIWINDOW = -DXWIN_MULTIWINDOW -endif - -if XWIN_MULTIWINDOWEXTWM -DEFS_MULTIWINDOWEXTWM = -DXWIN_MULTIWINDOWEXTWM -endif - -DEFS = $(DEFS_MULTIWINDOW) $(DEFS_MULTIWINDOWEXTWM) - -INCLUDES = -I$(top_srcdir)/miext/rootless - -AM_CFLAGS = -DHAVE_XWIN_CONFIG_H $(DIX_CFLAGS) \ - $(XWINMODULES_CFLAGS) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/hw/xwin/ - -glwrap.c: generated_gl_wrappers.c -wgl_ext_api.c: generated_wgl_wrappers.c wglext.h -wgl_ext_api.h: wglext.h -indirect.c: wgl_ext_api.h - -SPEC_FILES = gl.spec gl.tm wglext.spec wgl.tm - -gl.spec: - wget http://www.opengl.org/registry/api/gl.spec - -gl.tm: - wget http://www.opengl.org/registry/api/gl.tm - -wglext.spec: - wget http://www.opengl.org/registry/api/wglext.spec - -wgl.tm: - wget http://www.opengl.org/registry/api/wgl.tm - -generated_gl_wrappers.c: gen_gl_wrappers.py gl.spec gl.tm - $(srcdir)/gen_gl_wrappers.py --spec=$(srcdir)/gl.spec --typemap=$(srcdir)/gl.tm --dispatch-header=$(top_srcdir)/glx/dispatch.h --staticwrappers >generated_gl_wrappers.c - -generated_wgl_wrappers.c: gen_gl_wrappers.py wglext.spec wgl.tm - $(srcdir)/gen_gl_wrappers.py --spec=$(srcdir)/wglext.spec --typemap=$(srcdir)/wgl.tm --prefix=wgl --preresolve >generated_wgl_wrappers.c - -wglext.h: - wget http://www.opengl.org/registry/api/wglext.h - -BUILT_SOURCES = generated_gl_wrappers.c generated_wgl_wrappers.c -CLEANFILES = $(BUILT_SOURCES) -DISTCLEANFILES = $(SPEC_FILES) wglext.h - -EXTRA_DIST = gen_gl_wrappers.py $(SPEC_FILES) wglext.h +noinst_LTLIBRARIES = libXwinGLX.la + +libXwinGLX_la_SOURCES = \ + winpriv.c \ + winpriv.h \ + glwindows.h \ + glwrap.c \ + indirect.c \ + wgl_ext_api.c + +if XWIN_MULTIWINDOW +DEFS_MULTIWINDOW = -DXWIN_MULTIWINDOW +endif + +if XWIN_MULTIWINDOWEXTWM +DEFS_MULTIWINDOWEXTWM = -DXWIN_MULTIWINDOWEXTWM +endif + +DEFS = $(DEFS_MULTIWINDOW) $(DEFS_MULTIWINDOWEXTWM) + +INCLUDES = -I$(top_srcdir)/miext/rootless + +AM_CFLAGS = -DHAVE_XWIN_CONFIG_H $(DIX_CFLAGS) \ + $(XWINMODULES_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/hw/xwin/ + +glwrap.c: generated_gl_wrappers.c +wgl_ext_api.c: generated_wgl_wrappers.c wglext.h +wgl_ext_api.h: wglext.h +indirect.c: wgl_ext_api.h + +SPEC_FILES = gl.spec gl.tm wglext.spec wgl.tm + +gl.spec: + wget http://www.opengl.org/registry/api/gl.spec + +gl.tm: + wget http://www.opengl.org/registry/api/gl.tm + +wglext.spec: + wget http://www.opengl.org/registry/api/wglext.spec + +wgl.tm: + wget http://www.opengl.org/registry/api/wgl.tm + +generated_gl_wrappers.c: gen_gl_wrappers.py gl.spec gl.tm + $(srcdir)/gen_gl_wrappers.py --spec=`test -e gl.spec || echo $(srcdir)/`gl.spec --typemap=`test -e gl.tm || echo $(srcdir)/`gl.tm --dispatch-header=$(top_srcdir)/glx/dispatch.h --staticwrappers >generated_gl_wrappers.c + +generated_wgl_wrappers.c: gen_gl_wrappers.py wglext.spec wgl.tm + $(srcdir)/gen_gl_wrappers.py --spec=`test -e wglext.spec || echo $(srcdir)/`wglext.spec --typemap=`test -e wgl.tm || echo $(srcdir)/`wgl.tm --prefix=wgl --preresolve >generated_wgl_wrappers.c + +wglext.h: + wget http://www.opengl.org/registry/api/wglext.h + +BUILT_SOURCES = generated_gl_wrappers.c generated_wgl_wrappers.c +CLEANFILES = $(BUILT_SOURCES) +DISTCLEANFILES = $(SPEC_FILES) wglext.h + +EXTRA_DIST = gen_gl_wrappers.py $(SPEC_FILES) wglext.h diff --git a/xorg-server/xkeyboard-config/rules/base.o_s.part b/xorg-server/xkeyboard-config/rules/base.o_s.part index 00634858d..3e23396da 100644 --- a/xorg-server/xkeyboard-config/rules/base.o_s.part +++ b/xorg-server/xkeyboard-config/rules/base.o_s.part @@ -1,142 +1,143 @@ - altwin:menu = +altwin(menu) - altwin:meta_alt = +altwin(meta_alt) - altwin:ctrl_win = +altwin(ctrl_win) - altwin:ctrl_alt_win = +altwin(ctrl_alt_win) - altwin:meta_win = +altwin(meta_win) - altwin:left_meta_win = +altwin(left_meta_win) - altwin:hyper_win = +altwin(hyper_win) - altwin:alt_super_win = +altwin(alt_super_win) - altwin:swap_lalt_lwin = +altwin(swap_lalt_lwin) - grp:switch = +group(switch) - grp:lswitch = +group(lswitch) - grp:win_switch = +group(win_switch) - grp:lwin_switch = +group(lwin_switch) - grp:rwin_switch = +group(rwin_switch) - grp:toggle = +group(toggle) - grp:shifts_toggle = +group(shifts_toggle) - grp:ctrls_toggle = +group(ctrls_toggle) - grp:alts_toggle = +group(alts_toggle) - grp:ctrl_shift_toggle = +group(ctrl_shift_toggle) - grp:lctrl_lshift_toggle = +group(lctrl_lshift_toggle) - grp:rctrl_rshift_toggle = +group(rctrl_rshift_toggle) - grp:caps_toggle = +capslock(grouplock) - grp:caps_switch = +capslock(groupshift) - grp:shift_caps_toggle = +group(shift_caps_toggle) - grp:shift_caps_switch = +group(shift_caps_switch) - grp:win_menu_switch = +group(win_menu_switch) - grp:alt_caps_toggle = +group(alt_caps_toggle) - grp:ctrl_alt_toggle = +group(ctrl_alt_toggle) - grp:alt_shift_toggle = +group(alt_shift_toggle) - grp:alt_space_toggle = +group(alt_space_toggle) - grp:menu_toggle = +group(menu_toggle) - grp:lwin_toggle = +group(lwin_toggle) - grp:rwin_toggle = +group(rwin_toggle) - grp:lshift_toggle = +group(lshift_toggle) - grp:rshift_toggle = +group(rshift_toggle) - grp:rctrl_switch = +group(rctrl_switch) - grp:lctrl_toggle = +group(lctrl_toggle) - grp:rctrl_toggle = +group(rctrl_toggle) - grp:lalt_toggle = +group(lalt_toggle) - grp:sclk_toggle = +group(sclk_toggle) - grp:lctrl_rctrl_switch = +group(lctrl_rctrl_switch) - grp:lctrl_lwin_rctrl_menu = +group(lctrl_lwin_rctrl_menu) - lv3:switch = +level3(switch) - lv3:ralt_switch = +level3(ralt_switch) - lv3:ralt_switch_multikey = +level3(ralt_switch_multikey) - lv3:ralt_alt = +level3(ralt_alt) - lv3:lalt_switch = +level3(lalt_switch) - lv3:alt_switch = +level3(alt_switch) - lv3:menu_switch = +level3(menu_switch) - lv3:win_switch = +level3(win_switch) - lv3:lwin_switch = +level3(lwin_switch) - lv3:rwin_switch = +level3(rwin_switch) - lv3:enter_switch = +level3(enter_switch) - caps:capslock = +capslock(capslock) - caps:numlock = +capslock(numlock) - caps:shiftlock = +capslock(shiftlock) - caps:swapescape = +capslock(swapescape) - caps:escape = +capslock(escape) - caps:backspace = +capslock(backspace) - caps:super = +capslock(super) - caps:hyper = +capslock(hyper) - caps:none = +capslock(none) - ctrl:nocaps = +ctrl(nocaps) - ctrl:lctrl_meta = +ctrl(lctrl_meta) - ctrl:swapcaps = +ctrl(swapcaps) - ctrl:ctrl_ac = +ctrl(ctrl_ac) - ctrl:ctrl_aa = +ctrl(ctrl_aa) - ctrl:ctrl_ra = +ctrl(ctrl_ra) - ctrl:ctrl_menu = +ctrl(ctrl_menu) - compose:ralt = +compose(ralt) - compose:lwin = +compose(lwin) - compose:rwin = +compose(rwin) - compose:menu = +compose(menu) - compose:lctrl = +compose(lctrl) - compose:rctrl = +compose(rctrl) - compose:caps = +compose(caps) - compose:102 = +compose(102) - compose:paus = +compose(paus) - compose:prsc = +compose(prsc) - compose:sclk = +compose(sclk) - srvrkeys:none = +srvr_ctrl(no_srvr_keys) - eurosign:e = +eurosign(e) - eurosign:2 = +eurosign(2) - eurosign:4 = +eurosign(4) - eurosign:5 = +eurosign(5) - rupeesign:4 = +rupeesign(4) - keypad:oss = +keypad(oss) - keypad:legacy = +keypad(legacy) - keypad:legacy_wang = +keypad(legacy_wang) - keypad:oss_wang = +keypad(oss_wang) - keypad:future = +keypad(future) - keypad:future_wang = +keypad(future_wang) - keypad:hex = +keypad(ops)+keypad(hex) - keypad:atm = +keypad(ops)+keypad(hex)+keypad(atm) - nbsp:none = +nbsp(none) - nbsp:level2 = +nbsp(level2) - nbsp:level3 = +nbsp(level3) - nbsp:level3s = +nbsp(level3s) - nbsp:level3n = +nbsp(level3n) - nbsp:level4 = +nbsp(level4) - nbsp:level4n = +nbsp(level4n) - nbsp:level4nl = +nbsp(level4nl) - japan:nicola_f_bs = +jp(nicola_f_bs) - kpdl:dot = +kpdl(dot) - kpdl:comma = +kpdl(comma) - kpdl:dotoss = +kpdl(dotoss) - kpdl:dotoss_latin9 = +kpdl(dotoss_latin9) - kpdl:commaoss = +kpdl(commaoss) - kpdl:momayyezoss = +kpdl(momayyezoss) - kpdl:kposs = +kpdl(kposs) - kpdl:semi = +kpdl(semi) - shift:breaks_caps = +shift(breaks_caps) - esperanto:qwerty = +epo(qwerty) - esperanto:dvorak = +epo(dvorak) - terminate:ctrl_alt_bksp = +terminate(ctrl_alt_bksp) - keypad:pointerkeys = +keypad(pointerkeys) - apple:alupckeys = +macintosh_vndr/apple(alupckeys) - shift:both_capslock = +shift(both_capslock) - shift:lshift_both_capslock = +shift(lshift_both_capslock) - shift:rshift_both_capslock = +shift(rshift_both_capslock) - shift:both_capslock_cancel = +shift(both_capslock_cancel) - shift:lshift_both_capslock_cancel = +shift(lshift_both_capslock_cancel) - shift:rshift_both_capslock_cancel = +shift(rshift_both_capslock_cancel) - shift:both_shiftlock = +shift(both_shiftlock) - shift:lshift_both_shiftlock = +shift(lshift_both_shiftlock) - shift:rshift_both_shiftlock = +shift(rshift_both_shiftlock) - lv3:caps_switch = +level3(caps_switch) - lv3:bksl_switch = +level3(bksl_switch) - lv3:lsgt_switch = +level3(lsgt_switch) - lv3:caps_switch_latch = +level3(caps_switch_latch) - lv3:bksl_switch_latch = +level3(bksl_switch_latch) - lv3:lsgt_switch_latch = +level3(lsgt_switch_latch) - lv5:lsgt_switch_lock = +level5(lsgt_switch_lock) - lv5:ralt_switch_lock = +level5(ralt_switch_lock) - lv5:lwin_switch_lock = +level5(lwin_switch_lock) - lv5:rwin_switch_lock = +level5(rwin_switch_lock) - lv5:lsgt_switch_lock_cancel = +level5(lsgt_switch_lock_cancel) - lv5:ralt_switch_lock_cancel = +level5(ralt_switch_lock_cancel) - lv5:lwin_switch_lock_cancel = +level5(lwin_switch_lock_cancel) - lv5:rwin_switch_lock_cancel = +level5(rwin_switch_lock_cancel) - - + altwin:menu = +altwin(menu) + altwin:meta_alt = +altwin(meta_alt) + altwin:ctrl_win = +altwin(ctrl_win) + altwin:ctrl_alt_win = +altwin(ctrl_alt_win) + altwin:meta_win = +altwin(meta_win) + altwin:left_meta_win = +altwin(left_meta_win) + altwin:hyper_win = +altwin(hyper_win) + altwin:alt_super_win = +altwin(alt_super_win) + altwin:swap_lalt_lwin = +altwin(swap_lalt_lwin) + grp:switch = +group(switch) + grp:lswitch = +group(lswitch) + grp:win_switch = +group(win_switch) + grp:lwin_switch = +group(lwin_switch) + grp:rwin_switch = +group(rwin_switch) + grp:toggle = +group(toggle) + grp:shifts_toggle = +group(shifts_toggle) + grp:ctrls_toggle = +group(ctrls_toggle) + grp:alts_toggle = +group(alts_toggle) + grp:ctrl_shift_toggle = +group(ctrl_shift_toggle) + grp:lctrl_lshift_toggle = +group(lctrl_lshift_toggle) + grp:rctrl_rshift_toggle = +group(rctrl_rshift_toggle) + grp:caps_toggle = +capslock(grouplock) + grp:caps_switch = +capslock(groupshift) + grp:shift_caps_toggle = +group(shift_caps_toggle) + grp:shift_caps_switch = +group(shift_caps_switch) + grp:win_menu_switch = +group(win_menu_switch) + grp:alt_caps_toggle = +group(alt_caps_toggle) + grp:ctrl_alt_toggle = +group(ctrl_alt_toggle) + grp:alt_shift_toggle = +group(alt_shift_toggle) + grp:alt_space_toggle = +group(alt_space_toggle) + grp:menu_toggle = +group(menu_toggle) + grp:lwin_toggle = +group(lwin_toggle) + grp:rwin_toggle = +group(rwin_toggle) + grp:lshift_toggle = +group(lshift_toggle) + grp:rshift_toggle = +group(rshift_toggle) + grp:rctrl_switch = +group(rctrl_switch) + grp:lctrl_toggle = +group(lctrl_toggle) + grp:rctrl_toggle = +group(rctrl_toggle) + grp:lalt_toggle = +group(lalt_toggle) + grp:sclk_toggle = +group(sclk_toggle) + grp:lctrl_rctrl_switch = +group(lctrl_rctrl_switch) + grp:lctrl_lwin_rctrl_menu = +group(lctrl_lwin_rctrl_menu) + lv3:switch = +level3(switch) + lv3:ralt_switch = +level3(ralt_switch) + lv3:ralt_switch_multikey = +level3(ralt_switch_multikey) + lv3:ralt_alt = +level3(ralt_alt) + lv3:lalt_switch = +level3(lalt_switch) + lv3:alt_switch = +level3(alt_switch) + lv3:menu_switch = +level3(menu_switch) + lv3:win_switch = +level3(win_switch) + lv3:lwin_switch = +level3(lwin_switch) + lv3:rwin_switch = +level3(rwin_switch) + lv3:enter_switch = +level3(enter_switch) + caps:capslock = +capslock(capslock) + caps:numlock = +capslock(numlock) + caps:shiftlock = +capslock(shiftlock) + caps:swapescape = +capslock(swapescape) + caps:escape = +capslock(escape) + caps:backspace = +capslock(backspace) + caps:super = +capslock(super) + caps:hyper = +capslock(hyper) + caps:none = +capslock(none) + caps:ctrl_modifier = +capslock(ctrl_modifier) + ctrl:nocaps = +ctrl(nocaps) + ctrl:lctrl_meta = +ctrl(lctrl_meta) + ctrl:swapcaps = +ctrl(swapcaps) + ctrl:ctrl_ac = +ctrl(ctrl_ac) + ctrl:ctrl_aa = +ctrl(ctrl_aa) + ctrl:ctrl_ra = +ctrl(ctrl_ra) + ctrl:ctrl_menu = +ctrl(ctrl_menu) + compose:ralt = +compose(ralt) + compose:lwin = +compose(lwin) + compose:rwin = +compose(rwin) + compose:menu = +compose(menu) + compose:lctrl = +compose(lctrl) + compose:rctrl = +compose(rctrl) + compose:caps = +compose(caps) + compose:102 = +compose(102) + compose:paus = +compose(paus) + compose:prsc = +compose(prsc) + compose:sclk = +compose(sclk) + srvrkeys:none = +srvr_ctrl(no_srvr_keys) + eurosign:e = +eurosign(e) + eurosign:2 = +eurosign(2) + eurosign:4 = +eurosign(4) + eurosign:5 = +eurosign(5) + rupeesign:4 = +rupeesign(4) + keypad:oss = +keypad(oss) + keypad:legacy = +keypad(legacy) + keypad:legacy_wang = +keypad(legacy_wang) + keypad:oss_wang = +keypad(oss_wang) + keypad:future = +keypad(future) + keypad:future_wang = +keypad(future_wang) + keypad:hex = +keypad(ops)+keypad(hex) + keypad:atm = +keypad(ops)+keypad(hex)+keypad(atm) + nbsp:none = +nbsp(none) + nbsp:level2 = +nbsp(level2) + nbsp:level3 = +nbsp(level3) + nbsp:level3s = +nbsp(level3s) + nbsp:level3n = +nbsp(level3n) + nbsp:level4 = +nbsp(level4) + nbsp:level4n = +nbsp(level4n) + nbsp:level4nl = +nbsp(level4nl) + japan:nicola_f_bs = +jp(nicola_f_bs) + kpdl:dot = +kpdl(dot) + kpdl:comma = +kpdl(comma) + kpdl:dotoss = +kpdl(dotoss) + kpdl:dotoss_latin9 = +kpdl(dotoss_latin9) + kpdl:commaoss = +kpdl(commaoss) + kpdl:momayyezoss = +kpdl(momayyezoss) + kpdl:kposs = +kpdl(kposs) + kpdl:semi = +kpdl(semi) + shift:breaks_caps = +shift(breaks_caps) + esperanto:qwerty = +epo(qwerty) + esperanto:dvorak = +epo(dvorak) + terminate:ctrl_alt_bksp = +terminate(ctrl_alt_bksp) + keypad:pointerkeys = +keypad(pointerkeys) + apple:alupckeys = +macintosh_vndr/apple(alupckeys) + shift:both_capslock = +shift(both_capslock) + shift:lshift_both_capslock = +shift(lshift_both_capslock) + shift:rshift_both_capslock = +shift(rshift_both_capslock) + shift:both_capslock_cancel = +shift(both_capslock_cancel) + shift:lshift_both_capslock_cancel = +shift(lshift_both_capslock_cancel) + shift:rshift_both_capslock_cancel = +shift(rshift_both_capslock_cancel) + shift:both_shiftlock = +shift(both_shiftlock) + shift:lshift_both_shiftlock = +shift(lshift_both_shiftlock) + shift:rshift_both_shiftlock = +shift(rshift_both_shiftlock) + lv3:caps_switch = +level3(caps_switch) + lv3:bksl_switch = +level3(bksl_switch) + lv3:lsgt_switch = +level3(lsgt_switch) + lv3:caps_switch_latch = +level3(caps_switch_latch) + lv3:bksl_switch_latch = +level3(bksl_switch_latch) + lv3:lsgt_switch_latch = +level3(lsgt_switch_latch) + lv5:lsgt_switch_lock = +level5(lsgt_switch_lock) + lv5:ralt_switch_lock = +level5(ralt_switch_lock) + lv5:lwin_switch_lock = +level5(lwin_switch_lock) + lv5:rwin_switch_lock = +level5(rwin_switch_lock) + lv5:lsgt_switch_lock_cancel = +level5(lsgt_switch_lock_cancel) + lv5:ralt_switch_lock_cancel = +level5(ralt_switch_lock_cancel) + lv5:lwin_switch_lock_cancel = +level5(lwin_switch_lock_cancel) + lv5:rwin_switch_lock_cancel = +level5(rwin_switch_lock_cancel) + + diff --git a/xorg-server/xkeyboard-config/rules/base.xml.in b/xorg-server/xkeyboard-config/rules/base.xml.in index 3578100ee..ef97ab8d2 100644 --- a/xorg-server/xkeyboard-config/rules/base.xml.in +++ b/xorg-server/xkeyboard-config/rules/base.xml.in @@ -1394,14 +1394,14 @@ - olpc-fa + fa-olpc <_description>OLPC Dari - olpc-uz + uz-olpc <_description>OLPC Southern Uzbek uzb @@ -5295,6 +5295,12 @@ <_description>Caps Lock is disabled + diff --git a/xorg-server/xkeyboard-config/symbols/af b/xorg-server/xkeyboard-config/symbols/af index 90bfe127d..d7d866d34 100644 --- a/xorg-server/xkeyboard-config/symbols/af +++ b/xorg-server/xkeyboard-config/symbols/af @@ -1,397 +1,397 @@ -// -// Keymap for the Afghan dari keybord layout -// Based on the specification "Computer Locale Requirements for -// Afghanstan" [1] from the "United Nations Development Programme -// Afghanistan" and the "Afghan Transitional Islamic -// Administration Ministry of Communications". -// [1] http://www.evertype.com/standards/af/ -// For a MINI HOWTO see [2]. -// [2] http://www.afghanischerKulturverein.de/en/afghanComputer_en.php -// -// 2006-02-15 file created by M. Emal Alekozai - -partial default alphanumeric_keys -xkb_symbols "basic" { - //name[Group1]= "Afghanistan Dari"; - name[Group1]= "Afghanistan"; - - key { [ 0x100200d, 0x10000f7, dead_tilde ] }; - key { [ 0x10006f1, exclam, 0x1000060 ] }; - key { [ 0x10006f2, 0x100066c, 0x1000040 ] }; - key { [ 0x10006f3, 0x100066b, numbersign ] }; - key { [ 0x10006f4, 0x100e60b, 0x1000024] }; - key { [ 0x10006f5, 0x100066a, 0x1000025 ] }; - key { [ 0x10006f6, multiply, 0x100005e ] }; - key { [ 0x10006f7, Arabic_comma, 0x1000026 ] }; - key { [ 0x10006f8, asterisk, 0x1002022 ] }; - key { [ 0x10006f9, 0x1000029, 0x100200e ] }; - key { [ 0x10006f0, 0x1000028, 0x100200f ] }; - key { [ minus, Arabic_tatweel, 0x100005f ] }; - key { [ plus, equal ] }; - - key { [ Arabic_dad, Arabic_sukun, 0x10000b0 ] }; - key { [ Arabic_sad, Arabic_dammatan ] }; - key { [ Arabic_theh, Arabic_kasratan, 0x10020ac ] }; - key { [ Arabic_qaf, Arabic_fathatan, 0x100fd3e ] }; - key { [ Arabic_feh, Arabic_damma, 0x100fd3f ] }; - key { [ Arabic_ghain, Arabic_kasra, 0x100e656] }; - key { [ Arabic_ain, Arabic_fatha, 0x100e659] }; - key { [ Arabic_heh, Arabic_shadda, 0x1000655] }; - key { [ Arabic_khah, bracketright, 0x1000027] }; - key { [ Arabic_hah, bracketleft, 0x1000022] }; - key { [ Arabic_jeem, braceright, 0x1000681 ] }; - key { [ 0x1000686, braceleft, 0x1000685 ] }; - - key { [ Arabic_sheen, Arabic_hamzaonwaw, 0x100069a ] }; - key { [ Arabic_seen, Arabic_hamzaonyeh, 0x10006cd ] }; - key { [ 0x10006cc, Arabic_yeh, 0x1000649 ] }; - key { [ Arabic_beh, Arabic_hamzaunderalef, 0x10006d0 ] }; - key { [ Arabic_lam, Arabic_hamzaonalef, 0x10006b7 ] }; - key { [ Arabic_alef, Arabic_maddaonalef, 0x1000671 ] }; - key { [ Arabic_teh, Arabic_tehmarbuta, 0x100067c ] }; - key { [ Arabic_noon, 0x10000bb, 0x10006bc ] }; - key { [ Arabic_meem, 0x10000ab, 0x10006ba ] }; - key { [ 0x10006a9, colon, 0x100003b ] }; - key { [ 0x10006af, Arabic_semicolon, 0x10006ab ] }; - - key { [ backslash, bar, 0x100003f ] }; - - key { [ Arabic_zah, Arabic_kaf, 0x10006d2] }; - key { [ Arabic_tah, 0x1000653 , 0x1000691 ] }; - key { [ Arabic_zain, 0x1000698, 0x1000696 ] }; - key { [ Arabic_ra, 0x1000670 , 0x1000693 ] }; - key { [ Arabic_thal, 0x100200c, 0x1000688 ] }; - key { [ Arabic_dal, 0x1000654, 0x1000689 ] }; - key { [ 0x100067e, Arabic_hamza, 0x1000679 ] }; - key { [ Arabic_waw, greater, 0x100002c ] }; - key { [ period, less, 0x10006c7 ] }; - key { [ slash, Arabic_question_mark, 0x10006c9 ] }; - - include "nbsp(zwnj2nb3)" - include "level3(ralt_switch)" -}; - -// Keymap for the Afghan pashto keybord layout -// Based on the specification "Computer Locale Requirements for -// Afghanstan" [1] from the "United Nations Development Programme -// Afghanistan"" and the "Afghan Transitional Islamic -// Administration Ministry of Communications". -// [1] http://www.evertype.com/standards/af/ -// For a MINI HOWTO see [2]. -// [2] http://www.afghanischerKulturverein.de/en/afghanComputer_en.php -// -// 2006-02-15 file created by M. Emal Alekozai - -partial alphanumeric_keys -xkb_symbols "ps" { - name[Group1]= "Afghanistan - Pashto"; - - key { [ 0x100200d, 0x10000f7, dead_tilde ] }; - key { [ 0x10006f1, exclam, 0x1000060 ] }; - key { [ 0x10006f2, 0x100066c, 0x1000040 ] }; - key { [ 0x10006f3, 0x100066b, numbersign ] }; - key { [ 0x10006f4, 0x100e60b, 0x1000024] }; - key { [ 0x10006f5, 0x100066a, 0x1000025 ] }; - key { [ 0x10006f6, multiply, 0x100005e ] }; - key { [ 0x10006f7, 0x10000bb, 0x1000026 ] }; - key { [ 0x10006f8, 0x10000ab, 0x1002022 ] }; - key { [ 0x10006f9, 0x1000029, 0x100200e ] }; - key { [ 0x10006f0, 0x1000028, 0x100200f ] }; - key { [ minus, Arabic_tatweel, 0x100005f ] }; - key { [ plus, equal ] }; - - key { [ Arabic_dad, Arabic_sukun, 0x10000b0 ] }; - key { [ Arabic_sad, Arabic_dammatan, 0x1000653 ] }; - key { [ Arabic_theh, Arabic_kasratan, 0x10020ac ] }; - key { [ Arabic_qaf, Arabic_fathatan, 0x100fd3e ] }; - key { [ Arabic_feh, Arabic_damma, 0x100fd3f ] }; - key { [ Arabic_ghain, Arabic_kasra, 0x100e656] }; - key { [ Arabic_ain, Arabic_fatha, 0x100e659] }; - key { [ Arabic_heh, Arabic_shadda, 0x1000670] }; - key { [ Arabic_khah, 0x1000681, 0x1000027] }; - key { [ Arabic_hah, 0x1000685, 0x1000022] }; - key { [ Arabic_jeem, 0x100005d, 0x100007d ] }; - key { [ 0x1000686, 0x100005b, 0x100007b ] }; - - key { [ Arabic_sheen, 0x100069a ] }; - key { [ Arabic_seen, Arabic_hamzaonyeh, 0x10006d2 ] }; - key { [ 0x10006cc, Arabic_yeh, 0x1000649 ] }; - key { [ Arabic_beh, 0x100067e, 0x10006ba ] }; - key { [ Arabic_lam, Arabic_hamzaonalef, 0x10006b7 ] }; - key { [ Arabic_alef, Arabic_maddaonalef, 0x1000671 ] }; - key { [ Arabic_teh, 0x100067c, 0x1000679 ] }; - key { [ Arabic_noon, 0x10006bc, 0x100003e ] }; - key { [ Arabic_meem, 0x1000629, 0x100003c ] }; - key { [ 0x10006a9, colon, 0x1000643 ] }; - key { [ 0x10006ab, Arabic_semicolon, 0x10006af ] }; - - key { [ backslash, 0x100002a, 0x100007c ] }; - - key { [ 0x10006cd, 0x1000638, 0x100003f] }; - key { [ 0x10006d0, 0x1000637, 0x100003b ] }; - key { [ Arabic_zain, 0x1000698, 0x1000655 ] }; - key { [ Arabic_ra, 0x1000621, 0x1000654 ] }; - key { [ Arabic_thal, 0x100200c, 0x1000625 ] }; - key { [ Arabic_dal, 0x1000689, 0x1000688 ] }; - key { [ 0x1000693, 0x1000624, 0x1000691 ] }; - key { [ Arabic_waw, 0x100060c, 0x100002c ] }; - key { [ 0x1000696, 0x100002e, 0x10006c7 ] }; - key { [ slash, Arabic_question_mark, 0x10006c9 ] }; - - include "nbsp(zwnj2nb3)" - include "level3(ralt_switch)" -}; - -// Keymap for the Afghan southern uzbek keybord layout -// Based on the specification "Computer Locale Requirements for -// Afghanstan" [1] from the "United Nations Development Programme -// Afghanistan"" and the "Afghan Transitional Islamic -// Administration Ministry of Communications". -// [1] http://www.evertype.com/standards/af/ -// For a MINI HOWTO see [2]. -// [2] http://www.afghanischerKulturverein.de/en/afghanComputer_en.php -// -// 2006-02-15 file created by M. Emal Alekozai - -partial alphanumeric_keys -xkb_symbols "uz" { - name[Group1]= "Afghanistan - Southern Uzbek"; - - key { [ 0x100200d, 0x10000f7, dead_tilde ] }; - key { [ 0x10006f1, exclam, 0x1000060 ] }; - key { [ 0x10006f2, 0x100066c, 0x1000040 ] }; - key { [ 0x10006f3, 0x100066b, numbersign ] }; - key { [ 0x10006f4, 0x100e60b, 0x1000024] }; - key { [ 0x10006f5, 0x100066a, 0x1000025 ] }; - key { [ 0x10006f6, multiply, 0x100005e ] }; - key { [ 0x10006f7, Arabic_comma, 0x1000026 ] }; - key { [ 0x10006f8, asterisk, 0x1002022 ] }; - key { [ 0x10006f9, 0x1000029, 0x100200e ] }; - key { [ 0x10006f0, 0x1000028, 0x100200f ] }; - key { [ minus, Arabic_tatweel, 0x100005f ] }; - key { [ plus, equal ] }; - - key { [ Arabic_dad, Arabic_sukun, 0x10000b0 ] }; - key { [ Arabic_sad, Arabic_dammatan, 0x1000653 ] }; - key { [ Arabic_theh, Arabic_kasratan, 0x10020ac ] }; - key { [ Arabic_qaf, Arabic_fathatan, 0x100fd3e ] }; - key { [ Arabic_feh, Arabic_damma, 0x100fd3f ] }; - key { [ Arabic_ghain, Arabic_kasra, 0x100e656] }; - key { [ Arabic_ain, Arabic_fatha, 0x100e659] }; - key { [ Arabic_heh, Arabic_shadda, 0x1000670] }; - key { [ Arabic_khah, bracketright, 0x1000027] }; - key { [ Arabic_hah, bracketleft, 0x1000022] }; - key { [ Arabic_jeem, braceright, 0x1000681 ] }; - key { [ 0x1000686, braceleft, 0x1000685 ] }; - - key { [ Arabic_sheen, Arabic_hamzaonwaw, 0x100069a ] }; - key { [ Arabic_seen, Arabic_hamzaonyeh, 0x10006cd ] }; - key { [ 0x10006cc, Arabic_yeh, 0x1000649 ] }; - key { [ Arabic_beh, 0x10006d0, 0x1000643 ] }; - key { [ Arabic_lam, Arabic_hamzaonalef, 0x10006b7 ] }; - key { [ Arabic_alef, Arabic_maddaonalef, 0x1000671 ] }; - key { [ Arabic_teh, Arabic_tehmarbuta, 0x100067c ] }; - key { [ Arabic_noon, 0x10000bb, 0x10006bc ] }; - key { [ Arabic_meem, 0x10000ab, 0x10006ba ] }; - key { [ 0x10006a9, colon, 0x100003b ] }; - key { [ 0x10006af, Arabic_semicolon, 0x10006ab ] }; - - key { [ backslash, bar, 0x100003f ] }; - - key { [ Arabic_zah, 0x10006c9, 0x10006d2] }; - key { [ Arabic_tah, 0x10006c7, 0x1000691 ] }; - key { [ Arabic_zain, 0x1000698, 0x1000696 ] }; - key { [ Arabic_ra, 0x1000625, 0x1000693 ] }; - key { [ Arabic_thal, 0x100200c, 0x1000688 ] }; - key { [ Arabic_dal, 0x1000654, 0x1000689 ] }; - key { [ 0x100067e, Arabic_hamza, 0x1000679 ] }; - key { [ Arabic_waw, greater, 0x100002c ] }; - key { [ period, less ] }; - key { [ slash, Arabic_question_mark, 0x1000655 ] }; - - include "nbsp(zwnj2nb3)" - include "level3(ralt_switch)" -}; - -partial alphanumeric_keys -xkb_symbols "olpc-ps" { - - name[Group1]= "Afghanistan - OLPC Pashto"; - - key { [ 0x100200D, 0x1000654, grave ] }; // zero width joiner, Arabic hamza above - key { [ 0x10006F1, exclam, asciitilde ] }; // Arabic one - key { [ 0x10006F2, 0x100066C, at ] }; // Arabic two, Arabic thousands separator - key { [ 0x10006F3, 0x100066B, numbersign ] }; // Arabic three, Arabic decimal separator - key { [ 0x10006F4, 0x100060B, dollar ] }; // Arabic four, Afghani sign - key { [ 0x10006F5, 0x100066A, percent ] }; // Arabic five, Arabic percent sign - key { [ 0x10006F6, multiply, asciicircum ] }; // Arabic six - key { [ 0x10006F7, guillemotright, ampersand ] }; // Arabic seven - key { [ 0x10006F8, guillemotleft, 0x100066D ] }; // Arabic eight, Arabic five-pointed star - key { [ 0x10006F9, parenright, enfilledcircbullet ] }; // Arabic nine - key { [ 0x10006F0, parenleft, degree ] }; // Arabic zero - key { [ minus, 0x1000640, underscore ] }; // Arabic_tatweel - key { [ plus, equal, division ] }; - - key { [ 0x1000636, 0x1000652, EuroSign ] }; // Arabic dad, Arabic sukun - key { [ 0x1000635, 0x100064C, 0x1000671 ] }; // Arabic sad, Arabic dammatan, Arabic alef walsa - key { [ 0x100062B, 0x100064D, 0x1000649 ] }; // Arabic theh, Arabic kasratan, Arabic alef maksura initial form - key { [ 0x1000642, 0x100064B, 0x100200E ] }; // Arabic qaf, Arabic fathatan, left-to-right mark - key { [ 0x1000641, 0x100064F, 0x100200F ] }; // Arabic feh, Arabic damma, right-to-left mark - key { [ 0x100063A, 0x1000650, 0x100e653 ] }; // Arabic ghain, Arabic kasra, Arabic alef with madda above - key { [ 0x1000639, 0x100064E, 0x100e659 ] }; // Arabic ain, Arabic fatha, Arabic zwarakay - key { [ 0x1000647, 0x1000651, 0x1000670 ] }; // Arabic heh, Arabic shadda, Arabic superscript alef - key { [ 0x100062E, 0x1000681, apostrophe ] }; // Arabic khah, Arabic hah with hamza above, - key { [ 0x100062D, 0x1000685, quotedbl ] }; // Arabic hah, Arabic hah with three dots above - key { [ 0x100062C, bracketright, braceleft ] }; // Arabic jeem - key { [ 0x1000686, bracketleft, braceright ] }; // Arabic tcheh - - key { [ 0x1000634, 0x100069A ] }; // Arabic sheen, Arabic seen with dot below and dot above - key { [ 0x1000633, 0x10006CD ] }; // Arabic seen, Arabic yeh with tail - key { [ 0x10006CC, 0x100064A, 0x10006D2 ] }; // Farsi yeh, Arabic yeh, Arabic yeh barree - key { [ 0x1000628, 0x100067E, 0x10006BA ] }; // Arabic beh, Arabic peh, Arabic noon ghunna - key { [ 0x1000644, 0x1000623, 0x10006B7 ] }; // Arabic lam, Arabic hamza on alef, Arabic alef with hamza above - key { [ 0x1000627, 0x1000622, 0x1000625 ] }; // Arabic alef, Arabic madda on alef, Arabic alef with hamza below - key { [ 0x100062A, 0x100067C, 0x1000679 ] }; // Arabic teh, Arabic teh with ring, Arabic tteh - key { [ 0x1000646, 0x10006BC, greater ] }; // Arabic noon, Arabic noon with ring - key { [ 0x1000645, 0x1000629, less ] }; // Arabic meem, Arabic teh marbuta - key { [ 0x10006A9, colon, 0x1000643 ] }; // Arabic keheh, Arabic kaf - key { [ 0x10006AB, 0x100061B, 0x10006AF ] }; // Arabic kaf with ring, Arabic semicolon, Arabic gaf - - key { [ backslash, asterisk, bar ] }; - - key { [ 0x1000638, 0x1000626, question] }; // Arabic zah, Arabic yeh with hamza above - key { [ 0x10006D0, 0x1000637, semicolon ] }; // Arabic tah, Arabic E - key { [ 0x1000632, 0x1000698 ] }; // Arabic zain, Arabic jeh - key { [ 0x1000631, 0x1000621 ] }; // Arabic_ra (reh?), Arabic hamza - key { [ 0x1000630, 0x100200C ] }; // Arabic_thal, zero width non-joiner - key { [ 0x100062F, 0x1000689, 0x1000688 ] }; // Arabic_dal, Arabic dal with ring, Arabic ddal - key { [ 0x1000693, 0x1000624, 0x1000691 ] }; // Arabic reh with ring, Arabic waw with hamza above, Arabic rreh - key { [ 0x1000648, period, comma ] }; // Arabic_waw, Arabic comma - key { [ 0x1000696, 0x100002E, 0x10006C7 ] }; // Arabic reh with dot below and dot above, full stop, Arabic letter U - key { [ slash, 0x100061F, 0x10006C9 ] }; // Arabic question mark, Arabic kirghiz yu - - include "nbsp(zwnj2nb3)" - include "group(olpc)" -}; - -partial alphanumeric_keys -xkb_symbols "olpc-fa" { - - name[Group1]= "Afghanistan - OLPC Dari"; - - key { [ 0x100200D, division, asciitilde ] }; // zero width joiner - key { [ 0x10006F1, exclam, grave ] }; // Arabic one - key { [ 0x10006F2, 0x100066C, at ] }; // Arabic two, Arabic thousands separator - key { [ 0x10006F3, 0x100066B, numbersign ] }; // Arabic three, Arabic decimal separator - key { [ 0x10006F4, 0x100060B, dollar ] }; // Arabic four, Afghani sign - key { [ 0x10006F5, 0x100066A, percent ] }; // Arabic five, Arabic percent sign - key { [ 0x10006F6, multiply, asciicircum ] }; // Arabic six - key { [ 0x10006F7, 0x100060C, ampersand ] }; // Arabic seven, Arabic comma - key { [ 0x10006F8, asterisk, enfilledcircbullet ] }; // Arabic eight, - key { [ 0x10006F9, parenright, 0x100200E ] }; // Arabic nine, left-to-right mark - key { [ 0x10006F0, parenleft, 0x100200F ] }; // Arabic zero, right-to-left mark - key { [ minus, 0x1000640, underscore ] }; // Arabic_tatweel - key { [ plus, equal ] }; - - key { [ 0x1000636, 0x1000652, degree ] }; // Arabic dad, Arabic sukun - key { [ 0x1000635, 0x100064C ] }; // Arabic sad, Arabic dammatan - key { [ 0x100062B, 0x100064D, EuroSign ] }; // Arabic theh, Arabic kasratan - key { [ 0x1000642, 0x100064B, 0x100FD3E ] }; // Arabic qaf, Arabic fathatan, ornate left paren - key { [ 0x1000641, 0x100064F, 0x100FD3F ] }; // Arabic feh, Arabic damma, ornate right paren - key { [ 0x100063A, 0x1000650, 0x1000656 ] }; // Arabic ghain, Arabic kasra, Arabic subscript alef - key { [ 0x1000639, 0x100064E, 0x100e659 ] }; // Arabic ain, Arabic fatha, Arabic zwarakay - key { [ 0x1000647, 0x1000651, 0x1000655 ] }; // Arabic heh, Arabic shadda, Arabic hamza below - key { [ 0x100062E, bracketright, apostrophe ] }; // Arabic khah - key { [ 0x100062D, bracketleft, quotedbl ] }; // Arabic hah - key { [ 0x100062C, braceright, 0x1000681 ] }; // Arabic jeem, Arabic hah with hamza above - key { [ 0x1000686, braceleft, 0x1000685 ] }; // Arabic tcheh, Arabic hah with three dots above - - key { [ 0x1000634, 0x1000624, 0x100069A ] }; // Arabic sheen, Arabic waw with hamza above, Arabic seen with dot below and dot above - key { [ 0x1000633, 0x1000626, 0x10006CD ] }; // Arabic seen, Arabic yeh with hamza above, Arabic yeh with tail - key { [ 0x10006CC, 0x100064A, 0x1000649 ] }; // Farsi yeh, Arabic yeh, Arabic alef maksura - key { [ 0x1000628, 0x1000625, 0x10006D0 ] }; // Arabic beh, Arabic alef with hamza below, Arabic e - key { [ 0x1000644, 0x1000623, 0x10006B7 ] }; // Arabic lam, Arabic hamza on alef, Arabic alef with hamza above - key { [ 0x1000627, 0x1000622, 0x1000671 ] }; // Arabic alef, Arabic madda on alef, Arabic alef wasla - key { [ 0x100062A, 0x1000629, 0x100067C ] }; // Arabic teh, Arabic teh marbuta, Arabic tteh - key { [ 0x1000646, guillemotright, 0x10006BC ] }; // Arabic noon, Arabic noon with ring - key { [ 0x1000645, guillemotleft, 0x10006BA ] }; // Arabic meem, Arabic noon ghunna - key { [ 0x10006A9, colon, semicolon ] }; // Arabic keheh, - key { [ 0x10006AF, 0x100061B, 0x10006AB ] }; // Arabic gaf, Arabic semicolon, Arabic kaf with ring - - key { [ backslash, bar, question ] }; - - key { [ 0x1000638, 0x1000643, 0x10006D2 ] }; // Arabic zah, Arabic kaf, Arabic yeh barree - key { [ 0x1000637, 0x1000653, 0x1000691 ] }; // Arabic tah, Arabic maddah above, Arabic rreh - key { [ 0x1000632, 0x1000698, 0x1000696 ] }; // Arabic zain, Arabic jeh, Arabic reh with dot below and dot above - key { [ 0x1000631, 0x1000670, 0x1000693 ] }; // Arabic_ra (reh?), Arabic superscript alef, Arabic reh with ring - key { [ 0x1000630, 0x100200C, 0x1000688 ] }; // Arabic_thal, zero width non-joiner, Arabic ddal - key { [ 0x100062F, 0x1000654, 0x1000689 ] }; // Arabic dal, Arabic hamza above, Arabic dal with ring - key { [ 0x100067E, 0x1000621, 0x1000679 ] }; // Arabic peh, Arabic hamza, Arabic tteh - key { [ 0x1000648, greater, comma ] }; // Arabic_waw - key { [ period, less, 0x10006C7 ] }; // Arabic u - key { [ slash, 0x100061F, 0x10006C9 ] }; // Arabic question mark, Arabic kirghiz yu - - include "nbsp(zwnj2nb3)" - include "group(olpc)" -}; - -partial alphanumeric_keys -xkb_symbols "olpc-uz" { - - name[Group1]= "Afghanistan - OLPC Southern Uzbek"; - - key { [ 0x100200D, division, asciitilde ] }; // zero width joiner - key { [ 0x10006F1, exclam, grave ] }; // Arabic one - key { [ 0x10006F2, 0x100066C, at ] }; // Arabic two, Arabic thousands separator - key { [ 0x10006F3, 0x100066B, numbersign ] }; // Arabic three, Arabic decimal separator - key { [ 0x10006F4, 0x100060B, dollar ] }; // Arabic four, Afghani sign - key { [ 0x10006F5, 0x100066A, percent ] }; // Arabic five, Arabic percent sign - key { [ 0x10006F6, multiply, asciicircum ] }; // Arabic six - key { [ 0x10006F7, 0x100060C, ampersand ] }; // Arabic seven, Arabic comma - key { [ 0x10006F8, asterisk, enfilledcircbullet ] }; // Arabic eight, - key { [ 0x10006F9, parenright, 0x100200E ] }; // Arabic nine, left-to-right mark - key { [ 0x10006F0, parenleft, 0x100200F ] }; // Arabic zero, right-to-left mark - key { [ minus, 0x1000640, underscore ] }; // Arabic_tatweel - key { [ plus, equal ] }; - - key { [ 0x1000636, 0x1000652, degree ] }; // Arabic dad, Arabic sukun - key { [ 0x1000635, 0x100064C, 0x1000653 ] }; // Arabic sad, Arabic dammatan, Arabic maddah above - key { [ 0x100062B, 0x100064D, EuroSign ] }; // Arabic theh, Arabic kasratan - key { [ 0x1000642, 0x100064B, 0x100FD3E ] }; // Arabic qaf, Arabic fathatan, ornate left paren - key { [ 0x1000641, 0x100064F, 0x100FD3F ] }; // Arabic feh, Arabic damma, ornate right paren - key { [ 0x100063A, 0x1000650, 0x1000656 ] }; // Arabic ghain, Arabic kasra, Arabic subscript alef - key { [ 0x1000639, 0x100064E, 0x100e659 ] }; // Arabic ain, Arabic fatha, Arabic zwarakay - key { [ 0x1000647, 0x1000651, 0x1000670 ] }; // Arabic heh, Arabic shadda, Arabic superscript alef - key { [ 0x100062E, bracketright, apostrophe ] }; // Arabic khah - key { [ 0x100062D, bracketleft, quotedbl ] }; // Arabic hah - key { [ 0x100062C, braceright, 0x1000681 ] }; // Arabic jeem, Arabic hah with hamza above - key { [ 0x1000686, braceleft, 0x1000685 ] }; // Arabic tcheh, Arabic hah with three dots above - - key { [ 0x1000634, 0x1000624, 0x100069A ] }; // Arabic sheen, Arabic waw with hamza above, Arabic seen with dot below and dot above - key { [ 0x1000633, 0x1000626, 0x10006CD ] }; // Arabic seen, Arabic yeh with hamza above, Arabic yeh with tail - key { [ 0x10006CC, 0x100064A, 0x1000649 ] }; // Farsi yeh, Arabic yeh, Arabic alef maksura - key { [ 0x1000628, 0x10006D0, 0x1000643 ] }; // Arabic beh, Arabic e, Arabic kaf - key { [ 0x1000644, 0x1000623, 0x10006B7 ] }; // Arabic lam, Arabic hamza on alef, Arabic alef with hamza above - key { [ 0x1000627, 0x1000622, 0x1000671 ] }; // Arabic alef, Arabic madda on alef, Arabic alef wasla - key { [ 0x100062A, 0x1000629, 0x100067C ] }; // Arabic teh, Arabic teh marbuta, Arabic tteh - key { [ 0x1000646, guillemotright, 0x10006BC ] }; // Arabic noon, Arabic noon with ring - key { [ 0x1000645, guillemotleft, 0x10006BA ] }; // Arabic meem, Arabic noon ghunna - key { [ 0x10006A9, colon, semicolon ] }; // Arabic keheh, - key { [ 0x10006AF, 0x100061B, 0x10006AB ] }; // Arabic gaf, Arabic semicolon, Arabic kaf with ring - - key { [ backslash, bar, question ] }; - - key { [ 0x1000638, 0x10006C9, 0x10006D2 ] }; // Arabic zah, Arabic kirghiz yu, Arabic yeh barree - key { [ 0x1000637, 0x10006C7, 0x1000691 ] }; // Arabic tah, Arabic u, Arabic rreh - key { [ 0x1000632, 0x1000698, 0x1000696 ] }; // Arabic zain, Arabic jeh, Arabic reh with dot below and dot above - key { [ 0x1000631, 0x1000625, 0x1000693 ] }; // Arabic_ra (reh?), Arabic alef with hamza below, Arabic reh with ring - key { [ 0x1000630, 0x100200C, 0x1000688 ] }; // Arabic_thal, zero width non-joiner, Arabic ddal - key { [ 0x100062F, 0x1000654, 0x1000689 ] }; // Arabic dal, Arabic hamza above, Arabic dal with ring - key { [ 0x100067E, 0x1000621, 0x1000679 ] }; // Arabic peh, Arabic hamza, Arabic tteh - key { [ 0x1000648, greater, comma ] }; // Arabic_waw - key { [ period, less ] }; - key { [ slash, 0x100061F, 0x1000655 ] }; // Arabic question mark, Arabic hamza below - - include "nbsp(zwnj2nb3)" - include "group(olpc)" -}; +// +// Keymap for the Afghan dari keybord layout +// Based on the specification "Computer Locale Requirements for +// Afghanstan" [1] from the "United Nations Development Programme +// Afghanistan" and the "Afghan Transitional Islamic +// Administration Ministry of Communications". +// [1] http://www.evertype.com/standards/af/ +// For a MINI HOWTO see [2]. +// [2] http://www.afghanischerKulturverein.de/en/afghanComputer_en.php +// +// 2006-02-15 file created by M. Emal Alekozai + +partial default alphanumeric_keys +xkb_symbols "basic" { + //name[Group1]= "Afghanistan Dari"; + name[Group1]= "Afghanistan"; + + key { [ 0x100200d, 0x10000f7, dead_tilde ] }; + key { [ 0x10006f1, exclam, 0x1000060 ] }; + key { [ 0x10006f2, 0x100066c, 0x1000040 ] }; + key { [ 0x10006f3, 0x100066b, numbersign ] }; + key { [ 0x10006f4, 0x100e60b, 0x1000024] }; + key { [ 0x10006f5, 0x100066a, 0x1000025 ] }; + key { [ 0x10006f6, multiply, 0x100005e ] }; + key { [ 0x10006f7, Arabic_comma, 0x1000026 ] }; + key { [ 0x10006f8, asterisk, 0x1002022 ] }; + key { [ 0x10006f9, 0x1000029, 0x100200e ] }; + key { [ 0x10006f0, 0x1000028, 0x100200f ] }; + key { [ minus, Arabic_tatweel, 0x100005f ] }; + key { [ plus, equal ] }; + + key { [ Arabic_dad, Arabic_sukun, 0x10000b0 ] }; + key { [ Arabic_sad, Arabic_dammatan ] }; + key { [ Arabic_theh, Arabic_kasratan, 0x10020ac ] }; + key { [ Arabic_qaf, Arabic_fathatan, 0x100fd3e ] }; + key { [ Arabic_feh, Arabic_damma, 0x100fd3f ] }; + key { [ Arabic_ghain, Arabic_kasra, 0x100e656] }; + key { [ Arabic_ain, Arabic_fatha, 0x100e659] }; + key { [ Arabic_heh, Arabic_shadda, 0x1000655] }; + key { [ Arabic_khah, bracketright, 0x1000027] }; + key { [ Arabic_hah, bracketleft, 0x1000022] }; + key { [ Arabic_jeem, braceright, 0x1000681 ] }; + key { [ 0x1000686, braceleft, 0x1000685 ] }; + + key { [ Arabic_sheen, Arabic_hamzaonwaw, 0x100069a ] }; + key { [ Arabic_seen, Arabic_hamzaonyeh, 0x10006cd ] }; + key { [ 0x10006cc, Arabic_yeh, 0x1000649 ] }; + key { [ Arabic_beh, Arabic_hamzaunderalef, 0x10006d0 ] }; + key { [ Arabic_lam, Arabic_hamzaonalef, 0x10006b7 ] }; + key { [ Arabic_alef, Arabic_maddaonalef, 0x1000671 ] }; + key { [ Arabic_teh, Arabic_tehmarbuta, 0x100067c ] }; + key { [ Arabic_noon, 0x10000bb, 0x10006bc ] }; + key { [ Arabic_meem, 0x10000ab, 0x10006ba ] }; + key { [ 0x10006a9, colon, 0x100003b ] }; + key { [ 0x10006af, Arabic_semicolon, 0x10006ab ] }; + + key { [ backslash, bar, 0x100003f ] }; + + key { [ Arabic_zah, Arabic_kaf, 0x10006d2] }; + key { [ Arabic_tah, 0x1000653 , 0x1000691 ] }; + key { [ Arabic_zain, 0x1000698, 0x1000696 ] }; + key { [ Arabic_ra, 0x1000670 , 0x1000693 ] }; + key { [ Arabic_thal, 0x100200c, 0x1000688 ] }; + key { [ Arabic_dal, 0x1000654, 0x1000689 ] }; + key { [ 0x100067e, Arabic_hamza, 0x1000679 ] }; + key { [ Arabic_waw, greater, 0x100002c ] }; + key { [ period, less, 0x10006c7 ] }; + key { [ slash, Arabic_question_mark, 0x10006c9 ] }; + + include "nbsp(zwnj2nb3)" + include "level3(ralt_switch)" +}; + +// Keymap for the Afghan pashto keybord layout +// Based on the specification "Computer Locale Requirements for +// Afghanstan" [1] from the "United Nations Development Programme +// Afghanistan"" and the "Afghan Transitional Islamic +// Administration Ministry of Communications". +// [1] http://www.evertype.com/standards/af/ +// For a MINI HOWTO see [2]. +// [2] http://www.afghanischerKulturverein.de/en/afghanComputer_en.php +// +// 2006-02-15 file created by M. Emal Alekozai + +partial alphanumeric_keys +xkb_symbols "ps" { + name[Group1]= "Afghanistan - Pashto"; + + key { [ 0x100200d, 0x10000f7, dead_tilde ] }; + key { [ 0x10006f1, exclam, 0x1000060 ] }; + key { [ 0x10006f2, 0x100066c, 0x1000040 ] }; + key { [ 0x10006f3, 0x100066b, numbersign ] }; + key { [ 0x10006f4, 0x100e60b, 0x1000024] }; + key { [ 0x10006f5, 0x100066a, 0x1000025 ] }; + key { [ 0x10006f6, multiply, 0x100005e ] }; + key { [ 0x10006f7, 0x10000bb, 0x1000026 ] }; + key { [ 0x10006f8, 0x10000ab, 0x1002022 ] }; + key { [ 0x10006f9, 0x1000029, 0x100200e ] }; + key { [ 0x10006f0, 0x1000028, 0x100200f ] }; + key { [ minus, Arabic_tatweel, 0x100005f ] }; + key { [ plus, equal ] }; + + key { [ Arabic_dad, Arabic_sukun, 0x10000b0 ] }; + key { [ Arabic_sad, Arabic_dammatan, 0x1000653 ] }; + key { [ Arabic_theh, Arabic_kasratan, 0x10020ac ] }; + key { [ Arabic_qaf, Arabic_fathatan, 0x100fd3e ] }; + key { [ Arabic_feh, Arabic_damma, 0x100fd3f ] }; + key { [ Arabic_ghain, Arabic_kasra, 0x100e656] }; + key { [ Arabic_ain, Arabic_fatha, 0x100e659] }; + key { [ Arabic_heh, Arabic_shadda, 0x1000670] }; + key { [ Arabic_khah, 0x1000681, 0x1000027] }; + key { [ Arabic_hah, 0x1000685, 0x1000022] }; + key { [ Arabic_jeem, 0x100005d, 0x100007d ] }; + key { [ 0x1000686, 0x100005b, 0x100007b ] }; + + key { [ Arabic_sheen, 0x100069a ] }; + key { [ Arabic_seen, Arabic_hamzaonyeh, 0x10006d2 ] }; + key { [ 0x10006cc, Arabic_yeh, 0x1000649 ] }; + key { [ Arabic_beh, 0x100067e, 0x10006ba ] }; + key { [ Arabic_lam, Arabic_hamzaonalef, 0x10006b7 ] }; + key { [ Arabic_alef, Arabic_maddaonalef, 0x1000671 ] }; + key { [ Arabic_teh, 0x100067c, 0x1000679 ] }; + key { [ Arabic_noon, 0x10006bc, 0x100003e ] }; + key { [ Arabic_meem, 0x1000629, 0x100003c ] }; + key { [ 0x10006a9, colon, 0x1000643 ] }; + key { [ 0x10006ab, Arabic_semicolon, 0x10006af ] }; + + key { [ backslash, 0x100002a, 0x100007c ] }; + + key { [ 0x10006cd, 0x1000638, 0x100003f] }; + key { [ 0x10006d0, 0x1000637, 0x100003b ] }; + key { [ Arabic_zain, 0x1000698, 0x1000655 ] }; + key { [ Arabic_ra, 0x1000621, 0x1000654 ] }; + key { [ Arabic_thal, 0x100200c, 0x1000625 ] }; + key { [ Arabic_dal, 0x1000689, 0x1000688 ] }; + key { [ 0x1000693, 0x1000624, 0x1000691 ] }; + key { [ Arabic_waw, 0x100060c, 0x100002c ] }; + key { [ 0x1000696, 0x100002e, 0x10006c7 ] }; + key { [ slash, Arabic_question_mark, 0x10006c9 ] }; + + include "nbsp(zwnj2nb3)" + include "level3(ralt_switch)" +}; + +// Keymap for the Afghan southern uzbek keybord layout +// Based on the specification "Computer Locale Requirements for +// Afghanstan" [1] from the "United Nations Development Programme +// Afghanistan"" and the "Afghan Transitional Islamic +// Administration Ministry of Communications". +// [1] http://www.evertype.com/standards/af/ +// For a MINI HOWTO see [2]. +// [2] http://www.afghanischerKulturverein.de/en/afghanComputer_en.php +// +// 2006-02-15 file created by M. Emal Alekozai + +partial alphanumeric_keys +xkb_symbols "uz" { + name[Group1]= "Afghanistan - Southern Uzbek"; + + key { [ 0x100200d, 0x10000f7, dead_tilde ] }; + key { [ 0x10006f1, exclam, 0x1000060 ] }; + key { [ 0x10006f2, 0x100066c, 0x1000040 ] }; + key { [ 0x10006f3, 0x100066b, numbersign ] }; + key { [ 0x10006f4, 0x100e60b, 0x1000024] }; + key { [ 0x10006f5, 0x100066a, 0x1000025 ] }; + key { [ 0x10006f6, multiply, 0x100005e ] }; + key { [ 0x10006f7, Arabic_comma, 0x1000026 ] }; + key { [ 0x10006f8, asterisk, 0x1002022 ] }; + key { [ 0x10006f9, 0x1000029, 0x100200e ] }; + key { [ 0x10006f0, 0x1000028, 0x100200f ] }; + key { [ minus, Arabic_tatweel, 0x100005f ] }; + key { [ plus, equal ] }; + + key { [ Arabic_dad, Arabic_sukun, 0x10000b0 ] }; + key { [ Arabic_sad, Arabic_dammatan, 0x1000653 ] }; + key { [ Arabic_theh, Arabic_kasratan, 0x10020ac ] }; + key { [ Arabic_qaf, Arabic_fathatan, 0x100fd3e ] }; + key { [ Arabic_feh, Arabic_damma, 0x100fd3f ] }; + key { [ Arabic_ghain, Arabic_kasra, 0x100e656] }; + key { [ Arabic_ain, Arabic_fatha, 0x100e659] }; + key { [ Arabic_heh, Arabic_shadda, 0x1000670] }; + key { [ Arabic_khah, bracketright, 0x1000027] }; + key { [ Arabic_hah, bracketleft, 0x1000022] }; + key { [ Arabic_jeem, braceright, 0x1000681 ] }; + key { [ 0x1000686, braceleft, 0x1000685 ] }; + + key { [ Arabic_sheen, Arabic_hamzaonwaw, 0x100069a ] }; + key { [ Arabic_seen, Arabic_hamzaonyeh, 0x10006cd ] }; + key { [ 0x10006cc, Arabic_yeh, 0x1000649 ] }; + key { [ Arabic_beh, 0x10006d0, 0x1000643 ] }; + key { [ Arabic_lam, Arabic_hamzaonalef, 0x10006b7 ] }; + key { [ Arabic_alef, Arabic_maddaonalef, 0x1000671 ] }; + key { [ Arabic_teh, Arabic_tehmarbuta, 0x100067c ] }; + key { [ Arabic_noon, 0x10000bb, 0x10006bc ] }; + key { [ Arabic_meem, 0x10000ab, 0x10006ba ] }; + key { [ 0x10006a9, colon, 0x100003b ] }; + key { [ 0x10006af, Arabic_semicolon, 0x10006ab ] }; + + key { [ backslash, bar, 0x100003f ] }; + + key { [ Arabic_zah, 0x10006c9, 0x10006d2] }; + key { [ Arabic_tah, 0x10006c7, 0x1000691 ] }; + key { [ Arabic_zain, 0x1000698, 0x1000696 ] }; + key { [ Arabic_ra, 0x1000625, 0x1000693 ] }; + key { [ Arabic_thal, 0x100200c, 0x1000688 ] }; + key { [ Arabic_dal, 0x1000654, 0x1000689 ] }; + key { [ 0x100067e, Arabic_hamza, 0x1000679 ] }; + key { [ Arabic_waw, greater, 0x100002c ] }; + key { [ period, less ] }; + key { [ slash, Arabic_question_mark, 0x1000655 ] }; + + include "nbsp(zwnj2nb3)" + include "level3(ralt_switch)" +}; + +partial alphanumeric_keys +xkb_symbols "olpc-ps" { + + name[Group1]= "Afghanistan - OLPC Pashto"; + + key { [ 0x100200D, 0x1000654, grave ] }; // zero width joiner, Arabic hamza above + key { [ 0x10006F1, exclam, asciitilde ] }; // Arabic one + key { [ 0x10006F2, 0x100066C, at ] }; // Arabic two, Arabic thousands separator + key { [ 0x10006F3, 0x100066B, numbersign ] }; // Arabic three, Arabic decimal separator + key { [ 0x10006F4, 0x100060B, dollar ] }; // Arabic four, Afghani sign + key { [ 0x10006F5, 0x100066A, percent ] }; // Arabic five, Arabic percent sign + key { [ 0x10006F6, multiply, asciicircum ] }; // Arabic six + key { [ 0x10006F7, guillemotright, ampersand ] }; // Arabic seven + key { [ 0x10006F8, guillemotleft, 0x100066D ] }; // Arabic eight, Arabic five-pointed star + key { [ 0x10006F9, parenright, enfilledcircbullet ] }; // Arabic nine + key { [ 0x10006F0, parenleft, degree ] }; // Arabic zero + key { [ minus, 0x1000640, underscore ] }; // Arabic_tatweel + key { [ plus, equal, division ] }; + + key { [ 0x1000636, 0x1000652, EuroSign ] }; // Arabic dad, Arabic sukun + key { [ 0x1000635, 0x100064C, 0x1000671 ] }; // Arabic sad, Arabic dammatan, Arabic alef walsa + key { [ 0x100062B, 0x100064D, 0x1000649 ] }; // Arabic theh, Arabic kasratan, Arabic alef maksura initial form + key { [ 0x1000642, 0x100064B, 0x100200E ] }; // Arabic qaf, Arabic fathatan, left-to-right mark + key { [ 0x1000641, 0x100064F, 0x100200F ] }; // Arabic feh, Arabic damma, right-to-left mark + key { [ 0x100063A, 0x1000650, 0x100e653 ] }; // Arabic ghain, Arabic kasra, Arabic alef with madda above + key { [ 0x1000639, 0x100064E, 0x100e659 ] }; // Arabic ain, Arabic fatha, Arabic zwarakay + key { [ 0x1000647, 0x1000651, 0x1000670 ] }; // Arabic heh, Arabic shadda, Arabic superscript alef + key { [ 0x100062E, 0x1000681, apostrophe ] }; // Arabic khah, Arabic hah with hamza above, + key { [ 0x100062D, 0x1000685, quotedbl ] }; // Arabic hah, Arabic hah with three dots above + key { [ 0x100062C, bracketright, braceleft ] }; // Arabic jeem + key { [ 0x1000686, bracketleft, braceright ] }; // Arabic tcheh + + key { [ 0x1000634, 0x100069A ] }; // Arabic sheen, Arabic seen with dot below and dot above + key { [ 0x1000633, 0x10006CD ] }; // Arabic seen, Arabic yeh with tail + key { [ 0x10006CC, 0x100064A, 0x10006D2 ] }; // Farsi yeh, Arabic yeh, Arabic yeh barree + key { [ 0x1000628, 0x100067E, 0x10006BA ] }; // Arabic beh, Arabic peh, Arabic noon ghunna + key { [ 0x1000644, 0x1000623, 0x10006B7 ] }; // Arabic lam, Arabic hamza on alef, Arabic alef with hamza above + key { [ 0x1000627, 0x1000622, 0x1000625 ] }; // Arabic alef, Arabic madda on alef, Arabic alef with hamza below + key { [ 0x100062A, 0x100067C, 0x1000679 ] }; // Arabic teh, Arabic teh with ring, Arabic tteh + key { [ 0x1000646, 0x10006BC, greater ] }; // Arabic noon, Arabic noon with ring + key { [ 0x1000645, 0x1000629, less ] }; // Arabic meem, Arabic teh marbuta + key { [ 0x10006A9, colon, 0x1000643 ] }; // Arabic keheh, Arabic kaf + key { [ 0x10006AB, 0x100061B, 0x10006AF ] }; // Arabic kaf with ring, Arabic semicolon, Arabic gaf + + key { [ backslash, asterisk, bar ] }; + + key { [ 0x1000638, 0x1000626, question] }; // Arabic zah, Arabic yeh with hamza above + key { [ 0x10006D0, 0x1000637, semicolon ] }; // Arabic tah, Arabic E + key { [ 0x1000632, 0x1000698 ] }; // Arabic zain, Arabic jeh + key { [ 0x1000631, 0x1000621 ] }; // Arabic_ra (reh?), Arabic hamza + key { [ 0x1000630, 0x100200C ] }; // Arabic_thal, zero width non-joiner + key { [ 0x100062F, 0x1000689, 0x1000688 ] }; // Arabic_dal, Arabic dal with ring, Arabic ddal + key { [ 0x1000693, 0x1000624, 0x1000691 ] }; // Arabic reh with ring, Arabic waw with hamza above, Arabic rreh + key { [ 0x1000648, period, comma ] }; // Arabic_waw, Arabic comma + key { [ 0x1000696, 0x100002E, 0x10006C7 ] }; // Arabic reh with dot below and dot above, full stop, Arabic letter U + key { [ slash, 0x100061F, 0x10006C9 ] }; // Arabic question mark, Arabic kirghiz yu + + include "nbsp(zwnj2nb3)" + include "group(olpc)" +}; + +partial alphanumeric_keys +xkb_symbols "fa-olpc" { + + name[Group1]= "Afghanistan - OLPC Dari"; + + key { [ 0x100200D, division, asciitilde ] }; // zero width joiner + key { [ 0x10006F1, exclam, grave ] }; // Arabic one + key { [ 0x10006F2, 0x100066C, at ] }; // Arabic two, Arabic thousands separator + key { [ 0x10006F3, 0x100066B, numbersign ] }; // Arabic three, Arabic decimal separator + key { [ 0x10006F4, 0x100060B, dollar ] }; // Arabic four, Afghani sign + key { [ 0x10006F5, 0x100066A, percent ] }; // Arabic five, Arabic percent sign + key { [ 0x10006F6, multiply, asciicircum ] }; // Arabic six + key { [ 0x10006F7, 0x100060C, ampersand ] }; // Arabic seven, Arabic comma + key { [ 0x10006F8, asterisk, enfilledcircbullet ] }; // Arabic eight, + key { [ 0x10006F9, parenright, 0x100200E ] }; // Arabic nine, left-to-right mark + key { [ 0x10006F0, parenleft, 0x100200F ] }; // Arabic zero, right-to-left mark + key { [ minus, 0x1000640, underscore ] }; // Arabic_tatweel + key { [ plus, equal ] }; + + key { [ 0x1000636, 0x1000652, degree ] }; // Arabic dad, Arabic sukun + key { [ 0x1000635, 0x100064C ] }; // Arabic sad, Arabic dammatan + key { [ 0x100062B, 0x100064D, EuroSign ] }; // Arabic theh, Arabic kasratan + key { [ 0x1000642, 0x100064B, 0x100FD3E ] }; // Arabic qaf, Arabic fathatan, ornate left paren + key { [ 0x1000641, 0x100064F, 0x100FD3F ] }; // Arabic feh, Arabic damma, ornate right paren + key { [ 0x100063A, 0x1000650, 0x1000656 ] }; // Arabic ghain, Arabic kasra, Arabic subscript alef + key { [ 0x1000639, 0x100064E, 0x100e659 ] }; // Arabic ain, Arabic fatha, Arabic zwarakay + key { [ 0x1000647, 0x1000651, 0x1000655 ] }; // Arabic heh, Arabic shadda, Arabic hamza below + key { [ 0x100062E, bracketright, apostrophe ] }; // Arabic khah + key { [ 0x100062D, bracketleft, quotedbl ] }; // Arabic hah + key { [ 0x100062C, braceright, 0x1000681 ] }; // Arabic jeem, Arabic hah with hamza above + key { [ 0x1000686, braceleft, 0x1000685 ] }; // Arabic tcheh, Arabic hah with three dots above + + key { [ 0x1000634, 0x1000624, 0x100069A ] }; // Arabic sheen, Arabic waw with hamza above, Arabic seen with dot below and dot above + key { [ 0x1000633, 0x1000626, 0x10006CD ] }; // Arabic seen, Arabic yeh with hamza above, Arabic yeh with tail + key { [ 0x10006CC, 0x100064A, 0x1000649 ] }; // Farsi yeh, Arabic yeh, Arabic alef maksura + key { [ 0x1000628, 0x1000625, 0x10006D0 ] }; // Arabic beh, Arabic alef with hamza below, Arabic e + key { [ 0x1000644, 0x1000623, 0x10006B7 ] }; // Arabic lam, Arabic hamza on alef, Arabic alef with hamza above + key { [ 0x1000627, 0x1000622, 0x1000671 ] }; // Arabic alef, Arabic madda on alef, Arabic alef wasla + key { [ 0x100062A, 0x1000629, 0x100067C ] }; // Arabic teh, Arabic teh marbuta, Arabic tteh + key { [ 0x1000646, guillemotright, 0x10006BC ] }; // Arabic noon, Arabic noon with ring + key { [ 0x1000645, guillemotleft, 0x10006BA ] }; // Arabic meem, Arabic noon ghunna + key { [ 0x10006A9, colon, semicolon ] }; // Arabic keheh, + key { [ 0x10006AF, 0x100061B, 0x10006AB ] }; // Arabic gaf, Arabic semicolon, Arabic kaf with ring + + key { [ backslash, bar, question ] }; + + key { [ 0x1000638, 0x1000643, 0x10006D2 ] }; // Arabic zah, Arabic kaf, Arabic yeh barree + key { [ 0x1000637, 0x1000653, 0x1000691 ] }; // Arabic tah, Arabic maddah above, Arabic rreh + key { [ 0x1000632, 0x1000698, 0x1000696 ] }; // Arabic zain, Arabic jeh, Arabic reh with dot below and dot above + key { [ 0x1000631, 0x1000670, 0x1000693 ] }; // Arabic_ra (reh?), Arabic superscript alef, Arabic reh with ring + key { [ 0x1000630, 0x100200C, 0x1000688 ] }; // Arabic_thal, zero width non-joiner, Arabic ddal + key { [ 0x100062F, 0x1000654, 0x1000689 ] }; // Arabic dal, Arabic hamza above, Arabic dal with ring + key { [ 0x100067E, 0x1000621, 0x1000679 ] }; // Arabic peh, Arabic hamza, Arabic tteh + key { [ 0x1000648, greater, comma ] }; // Arabic_waw + key { [ period, less, 0x10006C7 ] }; // Arabic u + key { [ slash, 0x100061F, 0x10006C9 ] }; // Arabic question mark, Arabic kirghiz yu + + include "nbsp(zwnj2nb3)" + include "group(olpc)" +}; + +partial alphanumeric_keys +xkb_symbols "uz-olpc" { + + name[Group1]= "Afghanistan - OLPC Southern Uzbek"; + + key { [ 0x100200D, division, asciitilde ] }; // zero width joiner + key { [ 0x10006F1, exclam, grave ] }; // Arabic one + key { [ 0x10006F2, 0x100066C, at ] }; // Arabic two, Arabic thousands separator + key { [ 0x10006F3, 0x100066B, numbersign ] }; // Arabic three, Arabic decimal separator + key { [ 0x10006F4, 0x100060B, dollar ] }; // Arabic four, Afghani sign + key { [ 0x10006F5, 0x100066A, percent ] }; // Arabic five, Arabic percent sign + key { [ 0x10006F6, multiply, asciicircum ] }; // Arabic six + key { [ 0x10006F7, 0x100060C, ampersand ] }; // Arabic seven, Arabic comma + key { [ 0x10006F8, asterisk, enfilledcircbullet ] }; // Arabic eight, + key { [ 0x10006F9, parenright, 0x100200E ] }; // Arabic nine, left-to-right mark + key { [ 0x10006F0, parenleft, 0x100200F ] }; // Arabic zero, right-to-left mark + key { [ minus, 0x1000640, underscore ] }; // Arabic_tatweel + key { [ plus, equal ] }; + + key { [ 0x1000636, 0x1000652, degree ] }; // Arabic dad, Arabic sukun + key { [ 0x1000635, 0x100064C, 0x1000653 ] }; // Arabic sad, Arabic dammatan, Arabic maddah above + key { [ 0x100062B, 0x100064D, EuroSign ] }; // Arabic theh, Arabic kasratan + key { [ 0x1000642, 0x100064B, 0x100FD3E ] }; // Arabic qaf, Arabic fathatan, ornate left paren + key { [ 0x1000641, 0x100064F, 0x100FD3F ] }; // Arabic feh, Arabic damma, ornate right paren + key { [ 0x100063A, 0x1000650, 0x1000656 ] }; // Arabic ghain, Arabic kasra, Arabic subscript alef + key { [ 0x1000639, 0x100064E, 0x100e659 ] }; // Arabic ain, Arabic fatha, Arabic zwarakay + key { [ 0x1000647, 0x1000651, 0x1000670 ] }; // Arabic heh, Arabic shadda, Arabic superscript alef + key { [ 0x100062E, bracketright, apostrophe ] }; // Arabic khah + key { [ 0x100062D, bracketleft, quotedbl ] }; // Arabic hah + key { [ 0x100062C, braceright, 0x1000681 ] }; // Arabic jeem, Arabic hah with hamza above + key { [ 0x1000686, braceleft, 0x1000685 ] }; // Arabic tcheh, Arabic hah with three dots above + + key { [ 0x1000634, 0x1000624, 0x100069A ] }; // Arabic sheen, Arabic waw with hamza above, Arabic seen with dot below and dot above + key { [ 0x1000633, 0x1000626, 0x10006CD ] }; // Arabic seen, Arabic yeh with hamza above, Arabic yeh with tail + key { [ 0x10006CC, 0x100064A, 0x1000649 ] }; // Farsi yeh, Arabic yeh, Arabic alef maksura + key { [ 0x1000628, 0x10006D0, 0x1000643 ] }; // Arabic beh, Arabic e, Arabic kaf + key { [ 0x1000644, 0x1000623, 0x10006B7 ] }; // Arabic lam, Arabic hamza on alef, Arabic alef with hamza above + key { [ 0x1000627, 0x1000622, 0x1000671 ] }; // Arabic alef, Arabic madda on alef, Arabic alef wasla + key { [ 0x100062A, 0x1000629, 0x100067C ] }; // Arabic teh, Arabic teh marbuta, Arabic tteh + key { [ 0x1000646, guillemotright, 0x10006BC ] }; // Arabic noon, Arabic noon with ring + key { [ 0x1000645, guillemotleft, 0x10006BA ] }; // Arabic meem, Arabic noon ghunna + key { [ 0x10006A9, colon, semicolon ] }; // Arabic keheh, + key { [ 0x10006AF, 0x100061B, 0x10006AB ] }; // Arabic gaf, Arabic semicolon, Arabic kaf with ring + + key { [ backslash, bar, question ] }; + + key { [ 0x1000638, 0x10006C9, 0x10006D2 ] }; // Arabic zah, Arabic kirghiz yu, Arabic yeh barree + key { [ 0x1000637, 0x10006C7, 0x1000691 ] }; // Arabic tah, Arabic u, Arabic rreh + key { [ 0x1000632, 0x1000698, 0x1000696 ] }; // Arabic zain, Arabic jeh, Arabic reh with dot below and dot above + key { [ 0x1000631, 0x1000625, 0x1000693 ] }; // Arabic_ra (reh?), Arabic alef with hamza below, Arabic reh with ring + key { [ 0x1000630, 0x100200C, 0x1000688 ] }; // Arabic_thal, zero width non-joiner, Arabic ddal + key { [ 0x100062F, 0x1000654, 0x1000689 ] }; // Arabic dal, Arabic hamza above, Arabic dal with ring + key { [ 0x100067E, 0x1000621, 0x1000679 ] }; // Arabic peh, Arabic hamza, Arabic tteh + key { [ 0x1000648, greater, comma ] }; // Arabic_waw + key { [ period, less ] }; + key { [ slash, 0x100061F, 0x1000655 ] }; // Arabic question mark, Arabic hamza below + + include "nbsp(zwnj2nb3)" + include "group(olpc)" +}; diff --git a/xorg-server/xkeyboard-config/symbols/capslock b/xorg-server/xkeyboard-config/symbols/capslock index 288a1d293..3e0880573 100644 --- a/xorg-server/xkeyboard-config/symbols/capslock +++ b/xorg-server/xkeyboard-config/symbols/capslock @@ -1,62 +1,74 @@ -default partial hidden modifier_keys -xkb_symbols "capslock" { - replace key { [ Caps_Lock ] }; - modifier_map Lock { Caps_Lock }; -}; - -partial hidden modifier_keys -xkb_symbols "shiftlock" { - replace key { [ Shift_Lock ] }; - modifier_map Shift { Shift_Lock }; -}; - -partial hidden modifier_keys -xkb_symbols "grouplock" { - replace key { [ ISO_Next_Group, Caps_Lock ] }; -}; - -partial hidden modifier_keys -xkb_symbols "swapescape" { - key { [ Escape ] }; - key { [ Caps_Lock ] }; -}; - -partial hidden modifier_keys -xkb_symbols "groupshift" { - key { - type[Group1]="PC_ALT_LEVEL2", - [ Mode_switch, Caps_Lock ] - }; -}; - -partial hidden modifier_keys -xkb_symbols "escape" { - key { [ Escape ] }; -}; - -partial hidden modifier_keys -xkb_symbols "backspace" { - key { [ BackSpace ] }; -}; - -partial hidden modifier_keys -xkb_symbols "super" { - key { [ Super_L ] }; - modifier_map Mod4 { }; -}; - -partial hidden modifier_keys -xkb_symbols "hyper" { - key { [ Hyper_L ] }; - modifier_map Mod4 { }; -}; - -partial hidden modifier_keys -xkb_symbols "none" { - key { [ VoidSymbol ] }; -}; - -partial hidden modifier_keys -xkb_symbols "numlock" { - key { [ Num_Lock ] }; -}; +default partial hidden modifier_keys +xkb_symbols "capslock" { + replace key { [ Caps_Lock ] }; + modifier_map Lock { Caps_Lock }; +}; + +partial hidden modifier_keys +xkb_symbols "shiftlock" { + replace key { [ Shift_Lock ] }; + modifier_map Shift { Shift_Lock }; +}; + +partial hidden modifier_keys +xkb_symbols "grouplock" { + replace key { [ ISO_Next_Group, Caps_Lock ] }; +}; + +partial hidden modifier_keys +xkb_symbols "swapescape" { + key { [ Escape ] }; + key { [ Caps_Lock ] }; +}; + +partial hidden modifier_keys +xkb_symbols "groupshift" { + key { + type[Group1]="PC_ALT_LEVEL2", + [ Mode_switch, Caps_Lock ] + }; +}; + +partial hidden modifier_keys +xkb_symbols "escape" { + key { [ Escape ] }; +}; + +partial hidden modifier_keys +xkb_symbols "backspace" { + key { [ BackSpace ] }; +}; + +partial hidden modifier_keys +xkb_symbols "super" { + key { [ Super_L ] }; + modifier_map Mod4 { }; +}; + +partial hidden modifier_keys +xkb_symbols "hyper" { + key { [ Hyper_L ] }; + modifier_map Mod4 { }; +}; + +partial hidden modifier_keys +xkb_symbols "none" { + key { [ VoidSymbol ] }; +}; + +partial hidden modifier_keys +xkb_symbols "numlock" { + key { [ Num_Lock ] }; +}; + +// This changes the modifier behavior of the key. +// The keysym will be reset to Caps_Lock +partial hidden modifier_keys +xkb_symbols "ctrl_modifier" { + replace key { + type[Group1] = "ONE_LEVEL", + symbols[Group1] = [ Caps_Lock ], + actions[Group1] = [ SetMods(modifiers=Control) ] + }; + modifier_map Control { }; +}; diff --git a/xorg-server/xkeyboard-config/symbols/et b/xorg-server/xkeyboard-config/symbols/et index 6f71b2f97..7d15967e2 100644 --- a/xorg-server/xkeyboard-config/symbols/et +++ b/xorg-server/xkeyboard-config/symbols/et @@ -1,73 +1,73 @@ -// -// Ethiopia -// Designed as a part of OLPC project -// -// 2007 Sergey Udaltsov -// - -partial default alphanumeric_keys -xkb_symbols "basic" { - include "et(olpc)" - name[Group1]="Ethiopia"; -}; - -partial alphanumeric_keys -xkb_symbols "olpc" { - - name[Group1]="Ethiopia"; - - key { [ 0x01001369, 0x01001372 ] }; // 1 - key { [ 0x0100136a, 0x01001373 ] }; // 2 - key { [ 0x0100136b, 0x01001374 ] }; // 3 - key { [ 0x0100136c, 0x01001375 ] }; // 4 - key { [ 0x0100136d, 0x01001376 ] }; // 5 - key { [ 0x0100136e, 0x01001377 ] }; // 6 - key { [ 0x0100136f, 0x01001378 ] }; // 7 - key { [ 0x01001370, 0x01001379 ] }; // 8 - key { [ 0x01001371, 0x0100137a ] }; // 9 - key { [ 0x0100137b, 0x0100137c ] }; // 0 - key { [ minus, underscore ] }; // -_ - key { [ equal, plus ] }; // =+ - - key { [ 0x01001240, 0x01001250 ] }; // q - key { [ 0x010012C8, VoidSymbol ] }; // w - key { [ e, E ] }; // e - key { [ 0x01001228, VoidSymbol ] }; // r - key { [ 0x01001270, 0x01001320 ] }; // t - key { [ 0x010012E8, VoidSymbol ] }; // y - key { [ u, U ] }; // u - key { [ i, I ] }; // i - key { [ o, O ] }; // o - key { [ 0x01001350, 0x01001330 ] }; // p - key { [ 0x01001340, 0x01001338 ] }; // [ - key { [ 0x01001328, 0x01001280 ] }; // ] - - key { [ a, A ] }; // a - key { [ 0x01001230, 0x01001220 ] }; // s - key { [ 0x010012F0, 0x010012F8 ] }; // d - key { [ 0x01001348, VoidSymbol ] }; // f - key { [ 0x01001308, 0x01001318 ] }; // g - key { [ 0x01001200, 0x01001210 ] }; // h - key { [ 0x01001300, VoidSymbol ] }; // j - key { [ 0x010012A8, 0x010012B8 ] }; // k - key { [ 0x01001208, VoidSymbol ] }; // l - - key { [ 0x01001362, 0x01001361 ] }; // :; - key { [ 0x01001366, 0x01001365 ] }; // '" - - key { [ 0x010012D8, 0x010012E0 ] }; // z - key { [ 0x010012A0, 0x010012D0 ] }; // x - key { [ 0x01001278, VoidSymbol ] }; // c - key { [ 0x01001238, 0x01001268 ] }; // v - key { [ 0x01001260, VoidSymbol ] }; // b - key { [ 0x01001290, 0x01001298 ] }; // n - key { [ 0x01001218, VoidSymbol ] }; // m - - key { [ 0x01001363, VoidSymbol ] }; // < - key { [ 0x01001364, VoidSymbol ] }; // > - key { [ 0x01001367, VoidSymbol ] }; // ? - - key { [ VoidSymbol, 0x01002010 ] }; // bksl - - include "group(olpc)" -}; +// +// Ethiopia +// Designed as a part of OLPC project +// +// 2007 Sergey Udaltsov +// + +partial default alphanumeric_keys +xkb_symbols "basic" { + include "et(olpc)" + name[Group1]="Ethiopia"; +}; + +partial alphanumeric_keys +xkb_symbols "olpc" { + + name[Group1]="Ethiopia"; + + key { [ 0x01001369, 0x01001372 ] }; // 1 + key { [ 0x0100136a, 0x01001373 ] }; // 2 + key { [ 0x0100136b, 0x01001374 ] }; // 3 + key { [ 0x0100136c, 0x01001375 ] }; // 4 + key { [ 0x0100136d, 0x01001376 ] }; // 5 + key { [ 0x0100136e, 0x01001377 ] }; // 6 + key { [ 0x0100136f, 0x01001378 ] }; // 7 + key { [ 0x01001370, 0x01001379 ] }; // 8 + key { [ 0x01001371, 0x0100137a ] }; // 9 + key { [ 0x0100137b, 0x0100137c ] }; // 0 + key { [ minus, underscore ] }; // -_ + key { [ equal, plus ] }; // =+ + + key { [ 0x01001240, 0x01001250 ] }; // q + key { [ 0x010012C8, VoidSymbol ] }; // w + key { [ 0x0100FE69, 0x0100FE70 ] }; // dead e + key { [ 0x01001228, VoidSymbol ] }; // r + key { [ 0x01001270, 0x01001320 ] }; // t + key { [ 0x010012E8, VoidSymbol ] }; // y + key { [ 0x0100FE75, 0x0100FE76 ] }; // dead u + key { [ 0x0100FE71, 0x0100FE72 ] }; // dead i + key { [ 0x0100FE73, 0x0100FE74 ] }; // dead o + key { [ 0x01001350, 0x01001330 ] }; // p + key { [ 0x01001340, 0x01001338 ] }; // [ + key { [ 0x01001328, 0x01001280 ] }; // ] + + key { [ 0x0100FE67, 0x0100FE68 ] }; // dead a + key { [ 0x01001230, 0x01001220 ] }; // s + key { [ 0x010012F0, 0x010012F8 ] }; // d + key { [ 0x01001348, VoidSymbol ] }; // f + key { [ 0x01001308, 0x01001318 ] }; // g + key { [ 0x01001200, 0x01001210 ] }; // h + key { [ 0x01001300, VoidSymbol ] }; // j + key { [ 0x010012A8, 0x010012B8 ] }; // k + key { [ 0x01001208, VoidSymbol ] }; // l + + key { [ 0x01001362, 0x01001361 ] }; // :; + key { [ 0x01001366, 0x01001365 ] }; // '" + + key { [ 0x010012D8, 0x010012E0 ] }; // z + key { [ 0x010012A0, 0x010012D0 ] }; // x + key { [ 0x01001278, 0x0100FE78 ] }; // c + key { [ 0x01001238, 0x01001268 ] }; // v + key { [ 0x01001260, VoidSymbol ] }; // b + key { [ 0x01001290, 0x01001298 ] }; // n + key { [ 0x01001218, VoidSymbol ] }; // m + + key { [ 0x01001363, VoidSymbol ] }; // < + key { [ 0x01001364, VoidSymbol ] }; // > + key { [ 0x01001367, question ] }; // ? + + key { [ VoidSymbol, 0x01002010 ] }; // bksl + + include "group(olpc)" +}; diff --git a/xorg-server/xkeyboard-config/symbols/mn b/xorg-server/xkeyboard-config/symbols/mn index 44e5e4e67..a838bd5e0 100644 --- a/xorg-server/xkeyboard-config/symbols/mn +++ b/xorg-server/xkeyboard-config/symbols/mn @@ -1,80 +1,82 @@ -// based on: -// Mongolian standard keyboard -// Author Sanlig Badral -// 2002/12/7 Version 1.0 - -partial default alphanumeric_keys -xkb_symbols "basic" { - - name[Group1]= "Mongolia"; - - key { [ equal, plus, degree ] }; - key { [ 1, numerosign, multiply ] }; - key { [ 2, minus, division ] }; - key { [ 3, quotedbl, plusminus ] }; - key { [ 4, U20ae, notsign ] }; // Tugrik sign - key { [ 5, colon, NoSymbol ] }; - key { [ 6, period, notequal ] }; - key { [ 7, underscore, ampersand ] }; - key { [ 8, comma, asterisk ] }; - key { [ 9, percent, bracketleft ] }; - key { [ 0, question, bracketright ] }; - key { [ Cyrillic_ie, Cyrillic_IE, X ] }; - key { [ Cyrillic_shcha, Cyrillic_SHCHA, L ] }; - - key { [ Cyrillic_ef, Cyrillic_EF, apostrophe ] }; - key { [ Cyrillic_tse, Cyrillic_TSE, grave ] }; - key { [ Cyrillic_u, Cyrillic_U, EuroSign ] }; - key { [ Cyrillic_zhe, Cyrillic_ZHE, registered ] }; - key { [ Cyrillic_e, Cyrillic_E, trademark ] }; - key { [ Cyrillic_en, Cyrillic_EN, yen ] }; - key { [ Cyrillic_ghe, Cyrillic_GHE, doublelowquotemark ] }; - key { [ Cyrillic_sha, Cyrillic_SHA, leftdoublequotemark ] }; - key { [ Cyrillic_u_straight,Cyrillic_U_straight,rightdoublequotemark] }; - key { [ Cyrillic_ze, Cyrillic_ZE, NoSymbol ] }; - key { [ Cyrillic_ka, Cyrillic_KA, braceleft ] }; - key { [ Cyrillic_hardsign, Cyrillic_HARDSIGN, braceright ] }; - - key { [ Cyrillic_shorti, Cyrillic_SHORTI, mu ] }; - key { [ Cyrillic_yeru, Cyrillic_YERU, sterling ] }; - key { [ Cyrillic_be, Cyrillic_BE, dollar ] }; - key { [ Cyrillic_o_bar, Cyrillic_O_bar, rightdoublequotemark ] }; - key { [ Cyrillic_a, Cyrillic_A, Cyrillic_yeru ] }; - key { [ Cyrillic_ha, Cyrillic_HA, Cyrillic_YERU ] }; - key { [ Cyrillic_er, Cyrillic_ER, Cyrillic_e ] }; - key { [ Cyrillic_o, Cyrillic_O, Cyrillic_E ] }; - key { [ Cyrillic_el, Cyrillic_EL, numerosign ] }; - key { [ Cyrillic_de, Cyrillic_DE, section ] }; - key { [ Cyrillic_pe, Cyrillic_PE, ellipsis ] }; - key { [ exclam, bar, bar ] }; - - key { [ parenleft, parenright, NoSymbol ] }; - key { [ Cyrillic_ya, Cyrillic_YA, emdash ] }; - key { [ Cyrillic_che, Cyrillic_CHE, endash ] }; - key { [ Cyrillic_io, Cyrillic_IO, copyright ] }; - key { [ Cyrillic_es, Cyrillic_ES, NoSymbol ] }; - key { [ Cyrillic_em, Cyrillic_EM, NoSymbol ] }; - key { [ Cyrillic_i, Cyrillic_I, less ] }; - key { [ Cyrillic_te, Cyrillic_TE, greater ] }; - key { [ Cyrillic_softsign, Cyrillic_SOFTSIGN, guillemotleft ] }; - key { [ Cyrillic_ve, Cyrillic_VE, guillemotright ] }; - key { [ Cyrillic_yu, Cyrillic_YU, backslash ] }; - - // End alphanumeric section - - key { [ space, space, nobreakspace ] }; - - include "level3(ralt_switch)" -}; - -partial alphanumeric_keys -xkb_symbols "olpc" { - -// Contact: Walter Bender - - include "mn(basic)" - - key { [ backslash, bar, exclam ] }; - - include "group(olpc)" -}; +// based on: +// Mongolian standard keyboard +// Author Sanlig Badral +// 2002/12/7 Version 1.0 + +partial default alphanumeric_keys +xkb_symbols "basic" { + + name[Group1]= "Mongolia"; + + key { [ equal, plus, degree ] }; + key { [ 1, numerosign, multiply ] }; + key { [ 2, minus, division ] }; + key { [ 3, quotedbl, plusminus ] }; + key { [ 4, U20ae, notsign ] }; // Tugrik sign + key { [ 5, colon, NoSymbol ] }; + key { [ 6, period, notequal ] }; + key { [ 7, underscore, ampersand ] }; + key { [ 8, comma, asterisk ] }; + key { [ 9, percent, bracketleft ] }; + key { [ 0, question, bracketright ] }; + key { [ Cyrillic_ie, Cyrillic_IE, X ] }; + key { [ Cyrillic_shcha, Cyrillic_SHCHA, L ] }; + + key { [ Cyrillic_ef, Cyrillic_EF, apostrophe ] }; + key { [ Cyrillic_tse, Cyrillic_TSE, grave ] }; + key { [ Cyrillic_u, Cyrillic_U, EuroSign ] }; + key { [ Cyrillic_zhe, Cyrillic_ZHE, registered ] }; + key { [ Cyrillic_e, Cyrillic_E, trademark ] }; + key { [ Cyrillic_en, Cyrillic_EN, yen ] }; + key { [ Cyrillic_ghe, Cyrillic_GHE, doublelowquotemark ] }; + key { [ Cyrillic_sha, Cyrillic_SHA, leftdoublequotemark ] }; + key { [ Cyrillic_u_straight,Cyrillic_U_straight,rightdoublequotemark] }; + key { [ Cyrillic_ze, Cyrillic_ZE, NoSymbol ] }; + key { [ Cyrillic_ka, Cyrillic_KA, braceleft ] }; + key { [ Cyrillic_hardsign, Cyrillic_HARDSIGN, braceright ] }; + + key { [ Cyrillic_shorti, Cyrillic_SHORTI, mu ] }; + key { [ Cyrillic_yeru, Cyrillic_YERU, sterling ] }; + key { [ Cyrillic_be, Cyrillic_BE, dollar ] }; + key { [ Cyrillic_o_bar, Cyrillic_O_bar, rightdoublequotemark ] }; + key { [ Cyrillic_a, Cyrillic_A, Cyrillic_yeru ] }; + key { [ Cyrillic_ha, Cyrillic_HA, Cyrillic_YERU ] }; + key { [ Cyrillic_er, Cyrillic_ER, Cyrillic_e ] }; + key { [ Cyrillic_o, Cyrillic_O, Cyrillic_E ] }; + key { [ Cyrillic_el, Cyrillic_EL, numerosign ] }; + key { [ Cyrillic_de, Cyrillic_DE, section ] }; + key { [ Cyrillic_pe, Cyrillic_PE, ellipsis ] }; + key { [ exclam, bar, bar ] }; + + key { [ parenleft, parenright, NoSymbol ] }; + key { [ Cyrillic_ya, Cyrillic_YA, emdash ] }; + key { [ Cyrillic_che, Cyrillic_CHE, endash ] }; + key { [ Cyrillic_io, Cyrillic_IO, copyright ] }; + key { [ Cyrillic_es, Cyrillic_ES, NoSymbol ] }; + key { [ Cyrillic_em, Cyrillic_EM, NoSymbol ] }; + key { [ Cyrillic_i, Cyrillic_I, less ] }; + key { [ Cyrillic_te, Cyrillic_TE, greater ] }; + key { [ Cyrillic_softsign, Cyrillic_SOFTSIGN, guillemotleft ] }; + key { [ Cyrillic_ve, Cyrillic_VE, guillemotright ] }; + key { [ Cyrillic_yu, Cyrillic_YU, backslash ] }; + + // End alphanumeric section + + key { [ space, space, nobreakspace ] }; + + include "level3(ralt_switch)" +}; + +partial alphanumeric_keys +xkb_symbols "olpc" { + +// Contact: Walter Bender + + include "mn(basic)" + + key { [ 7, semicolon, ampersand ] }; + + key { [ backslash, bar, exclam ] }; + + include "group(olpc)" +}; diff --git a/xorg-server/xkeyboard-config/symbols/np b/xorg-server/xkeyboard-config/symbols/np index 635fa348a..e139b0ff7 100644 --- a/xorg-server/xkeyboard-config/symbols/np +++ b/xorg-server/xkeyboard-config/symbols/np @@ -1,120 +1,121 @@ -// based on a keyboard map from an 'xkb/symbols/dev' file - -partial default alphanumeric_keys -xkb_symbols "basic" { - - name[Group1]= "Nepal"; - -// `,1,2,3,4,5,6,7,8,9,0,-,= - - key { [ 0x100093D,0x100093C ] }; - key { [ 0x1000967 ] }; - key { [ 0x1000968 ] }; - key { [ 0x1000969 ] }; - key { [ 0x100096A ] }; - key { [ 0x100096B ] }; - key { [ 0x100096C ] }; - key { [ 0x100096D ] }; - key { [ 0x100096e ] }; - key { [ 0x100096F ] }; - key { [ 0x1000966,0x1000970 ] }; - key { [ minus, 0x1000952 ] }; - key { [ equal, 0x100200C ] }; - -// q,w,e,r,t,y,u,i,o,p,[,] - - key { [ 0x100091F, 0x1000920 ] }; - key { [ 0x100094C, 0x1000914 ] }; - key { [ 0x1000947, 0x1000948 ] }; - key { [ 0x1000930, 0x1000943 ] }; - key { [ 0x1000924, 0x1000925 ] }; - key { [ 0x100092F, 0x100091E ] }; - key { [ 0x1000941, 0x1000942 ] }; - key { [ 0x100093F, 0x1000940 ] }; - key { [ 0x100094B, 0x1000913 ] }; - key { [ 0x100092A, 0x100092B ] }; - key { [ 0x1000907, 0x1000908 ] }; - key { [ 0x100090F, 0x1000910 ] }; - -// a,s,d,f,g,h,j,k,l,;,',Backslash - key { [ 0x100093E, 0x1000906 ] }; - key { [ 0x1000938, 0x1000936 ] }; - key { [ 0x1000926, 0x1000927 ] }; - key { [ 0x1000909, 0x100090A ] }; - key { [ 0x1000917, 0x1000918 ] }; - key { [ 0x1000939, 0x1000905 ] }; - key { [ 0x100091C, 0x100091D ] }; - key { [ 0x1000915, 0x1000916 ] }; - key { [ 0x1000932, 0x1000933 ] }; - key { [ semicolon, colon ] }; - key { [ quoteright, quotedbl ] }; - key { [ 0x1000950, 0x1000903 ] }; - - -// z,x,c,v,b,n,m,,,.,/ - key { [ 0x1000937, 0x100090B ] }; - key { [ 0x1000921, 0x1000922 ] }; - key { [ 0x100091B, 0x100091A ] }; - key { [ 0x1000935, 0x1000901 ] }; - key { [ 0x100092C, 0x100092D ] }; - key { [ 0x1000928, 0x1000923 ] }; - key { [ 0x100092E, 0x1000902 ] }; - key { [ comma, 0x1000919 ] }; - key { [ 0x1000964, 0x1000965 ] }; - key { [ 0x100094D, question ] }; -}; - -partial alphanumeric_keys -xkb_symbols "olpc" { - -// Contact: Walter Bender - - include "np" - key { [ grave, asciitilde ] }; - key { [ 0x1000967 ] }; // Nepali digit one - key { [ 0x1000968 ] }; // Nepali digit two - key { [ 0x1000969 ] }; // Nepali digit three - key { [ 0x100096A ] }; // Nepali digit four - key { [ 0x100096B ] }; // Nepali digit five - key { [ 0x100096C, sterling ] }; // Nepali digit six - key { [ 0x100096D, eurosign ] }; // Nepali digit seven - key { [ 0x100096e ] }; // Nepali digit eight - key { [ 0x100096F ] }; // Nepali digit nine - key { [ 0x1000966 ] }; // Nepali digit zero - key { [ 0x1000950, 0x1000903 ] }; // OM, SIGN VISARGA - - key { [ 0x100091C, 0x100091D ] }; // JA, JHA - key { [ 0x1000917, 0x1000918 ] }; // GA, GHA - key { [ 0x100092F, 0x100091E ] }; // YA, YNA - key { [ 0x1000938, 0x1000936 ] }; // SA, SHA - key { [ 0x100090F, 0x1000910 ] }; // E, AI - key { [ 0x100091B, 0x100091A ] }; // CHHA, CHA - key { [ 0x100092A, 0x100092B ] }; // PA, PHA - key { [ 0x1000947, 0x1000948 ] }; // VOWEL SIGN E, VOWEL SIGN AI - key { [ 0x100094B, 0x100093E ] }; // VOWEL SIGN O, VOWEL SIGN AA - key { [ 0x1000924, 0x1000925 ] }; // TA, THA - key { [ 0x1000909, 0x100090A ] }; // HRSHWA U, DIRGHA UU - key { [ 0x100093F, 0x1000940 ] }; // VOWEL SIGN HRSHWA I, VOWEL SIGN DIRGHA II - - key { [ 0x100092E, 0x1000902 ] }; // MA, SIGN ANUSVARA - key { [ 0x1000907, 0x1000908 ] }; // HRSHWA I, DIRGHA II - key { [ 0x1000928, 0x1000923 ] }; // NA, NNA - key { [ 0x100094D, 0x1000921 ] }; // VIRAMA (HALANTA?), DDA - key { [ 0x100091F, 0x1000920 ] }; // TTA, TTHA - key { [ 0x1000926, 0x1000927 ] }; // DA, DHA - key { [ 0x100093E, 0x1000901 ] }; // SIGN AA, SIGN CANDRABINDU - key { [ 0x1000930, 0x1000943 ] }; // RA, VOWEL SIGN VOCALIC R - key { [ 0x1000915, 0x1000916 ] }; // KA, KHA - - key { [ 0x1000937, 0x100090B ] }; // SSA, VOCALIC R (RRI) - key { [ 0x100092C, 0x100092D ] }; // BA, BHA - key { [ 0x1000941, 0x1000942 ] }; // VOWEL SIGN HRSHWA U, VOWEL SIGN DIRGHA U (UU) - key { [ 0x1000939, 0x1000922 ] }; // HA, DDHA - key { [ 0x1000913, 0x1000914 ] }; // O, AU - key { [ 0x1000905, 0x1000906 ] }; // A, AA - key { [ 0x1000932, 0x1000919 ] }; // LA, NGA - key { [ comma, 0x1000935 ] }; // VA - key { [ 0x1000964, 0x1000965 ] }; // PURNA VIRAM, DIRGHA VIRAM - - include "group(olpc)" -}; +// based on a keyboard map from an 'xkb/symbols/dev' file + +partial default alphanumeric_keys +xkb_symbols "basic" { + + name[Group1]= "Nepal"; + +// `,1,2,3,4,5,6,7,8,9,0,-,= + + key { [ 0x100093D,0x100093C ] }; + key { [ 0x1000967 ] }; + key { [ 0x1000968 ] }; + key { [ 0x1000969 ] }; + key { [ 0x100096A ] }; + key { [ 0x100096B ] }; + key { [ 0x100096C ] }; + key { [ 0x100096D ] }; + key { [ 0x100096e ] }; + key { [ 0x100096F ] }; + key { [ 0x1000966,0x1000970 ] }; + key { [ minus, 0x1000952 ] }; + key { [ equal, 0x100200C ] }; + +// q,w,e,r,t,y,u,i,o,p,[,] + + key { [ 0x100091F, 0x1000920 ] }; + key { [ 0x100094C, 0x1000914 ] }; + key { [ 0x1000947, 0x1000948 ] }; + key { [ 0x1000930, 0x1000943 ] }; + key { [ 0x1000924, 0x1000925 ] }; + key { [ 0x100092F, 0x100091E ] }; + key { [ 0x1000941, 0x1000942 ] }; + key { [ 0x100093F, 0x1000940 ] }; + key { [ 0x100094B, 0x1000913 ] }; + key { [ 0x100092A, 0x100092B ] }; + key { [ 0x1000907, 0x1000908 ] }; + key { [ 0x100090F, 0x1000910 ] }; + +// a,s,d,f,g,h,j,k,l,;,',Backslash + key { [ 0x100093E, 0x1000906 ] }; + key { [ 0x1000938, 0x1000936 ] }; + key { [ 0x1000926, 0x1000927 ] }; + key { [ 0x1000909, 0x100090A ] }; + key { [ 0x1000917, 0x1000918 ] }; + key { [ 0x1000939, 0x1000905 ] }; + key { [ 0x100091C, 0x100091D ] }; + key { [ 0x1000915, 0x1000916 ] }; + key { [ 0x1000932, 0x1000933 ] }; + key { [ semicolon, colon ] }; + key { [ quoteright, quotedbl ] }; + key { [ 0x1000950, 0x1000903 ] }; + + +// z,x,c,v,b,n,m,,,.,/ + key { [ 0x1000937, 0x100090B ] }; + key { [ 0x1000921, 0x1000922 ] }; + key { [ 0x100091B, 0x100091A ] }; + key { [ 0x1000935, 0x1000901 ] }; + key { [ 0x100092C, 0x100092D ] }; + key { [ 0x1000928, 0x1000923 ] }; + key { [ 0x100092E, 0x1000902 ] }; + key { [ comma, 0x1000919 ] }; + key { [ 0x1000964, 0x1000965 ] }; + key { [ 0x100094D, question ] }; +}; + +partial alphanumeric_keys + +xkb_symbols "olpc" { +// Contact: Walter Bender + + include "np" + key { [ 0x100091E, 0x1000965 ] }; // NYA; double danda + key { [ 0x1000967, 0x10FFFFD ] }; // Nepali digit one; U091C+U094D+U091E + key { [ 0x1000968, 0x1000908 ] }; // Nepali digit two; key { [ 0x1000969, 0x1000918 ] }; // Nepali digit three; + key { [ 0x100096A, 0x10FFFFC ] }; // Nepali digit four; U0926+U094D+U0927 + key { [ 0x100096B, 0x100091B ] }; // Nepali digit five + key { [ 0x100096C, 0x100091F ] }; // Nepali digit six + key { [ 0x100096D, 0x1000920 ] }; // Nepali digit seven + key { [ 0x100096e, 0x1000921 ] }; // Nepali digit eight + key { [ 0x100096F, 0x1000922 ] }; // Nepali digit nine + key { [ 0x1000966, 0x1000923 ] }; // Nepali digit zero + key { [ 0x1000914, 0x1000913 ] }; // O, AU + key { [ 0x100200C, 0x1000902 ] }; // ZERO-WIDTH-NON-JOINER (ZWNJ); SIGN ANUSVARA + key { [ 0x100094D, 0x100200D ] }; // SIGN VIRAMA; ZERO-WIDTH-JOINER (ZWJ) + key { [ 0x10FFFFB, 0x10FFFFA ] }; // U0924+U094D+U0930; U0924+U094D+U0924 + key { [ 0x1000927, 0x10FFFF9 ] }; // DHA; U0921+U094D+U0922 + key { [ 0x100092D, 0x1000910 ] }; // BHA, AI + key { [ 0x100091A, 0x10FFFF8 ] }; // CA; U0926+U094D+U0935 + key { [ 0x1000924, 0x10FFFF7 ] }; // TA; U091F+U094D+U091F + key { [ 0x1000925, 0x10FFFF6 ] }; // THA; U0920+U094D+U0920 + key { [ 0x1000917, 0x100090A ] }; // GA, UU + key { [ 0x1000937, 0x10FFFF5 ] }; // SSA; U0915+U094D+U0937 + key { [ 0x100092F, 0x1000907 ] }; // YA, I + key { [ 0x1000909, 0x100090F ] }; // U, E + key { [ 0x10FFFF4, 0x1000943 ] }; // U0928+U094D+ZWJ; VOWEL SIGN VOCALIC R + key { [ 0x1000947, 0x1000948 ] }; // SIGN E; SIGN AI + key { [ 0x100092C, 0x1000906 ] }; // BA, AA + key { [ 0x1000915, 0x10FFFF3 ] }; // KA; U0919+U094D+U0915 + key { [ 0x100092E, 0x10FFFF2 ] }; // MA; U0919+U094D+U0917 + key { [ 0x100093E, 0x1000901 ] }; // CANDRABINDU, VOWEL SIGN AA + key { [ 0x1000928, 0x10FFFF1 ] }; // NA; U0926+U094D+U0926 + key { [ 0x100091C, 0x100091D ] }; // JA, JHA + key { [ 0x1000935, 0x100094B ] }; // VA, VOWEL SIGN O + key { [ 0x100092A, 0x100092B ] }; // PA, PHA + key { [ 0x100093F, 0x1000940 ] }; // VOWEL SIGN I, VOWEL SIGN II + key { [ 0x1000938, 0x10FFFF0 ] }; // SA; U091F+U094D+U0920 + key { [ 0x1000941, 0x1000942 ] }; // VOWEL SIGN U, VOWEL SIGN UU + key { [ 0x1000936, 0x10FFFEF ] }; // SHA; U0915+U094D+U0915 + key { [ 0x1000939, 0x10FFFEE ] }; // HA; U0939+U094D+U092F + key { [ 0x1000905, 0x100090B ] }; // A; U0909+U090B + key { [ 0x1000916, 0x1000950 ] }; // KHA, OM + key { [ 0x1000926, 0x100094C ] }; // DA, VOWEL SIGN AU + key { [ 0x1000932, 0x10FFFED ] }; // LA; U0926+U094D+U092F + key { [ 0x1000903, 0x10FFFEC ] }; // SIGN VISARGA; U0921+U094D+U0921 + key { [ 0x100093D, 0x1000919 ] }; // SIGN AVAGRHA; NGA + key { [ 0x1000964, 0x10FFFEB ] }; // DANDA; U0936+U094D+U0930 + key { [ 0x1000930, 0x10FFFEA ] }; // RA; U0930+U0941 + + include "group(olpc)" +}; -- cgit v1.2.3