Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 4357 → Rev 4358

/contrib/sdk/sources/Mesa/src/glx/Makefile.am
0,0 → 1,116
# Copyright © 2012 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
 
if HAVE_SHARED_GLAPI
SHARED_GLAPI_CFLAGS = -DGLX_SHARED_GLAPI
SHARED_GLAPI_LIBS = $(top_builddir)/src/mapi/shared-glapi/libglapi.la
endif
 
SUBDIRS=. tests
 
GLAPI_LIB = $(top_builddir)/src/mapi/glapi/libglapi.la
 
if HAVE_XF86VIDMODE
EXTRA_DEFINES_XF86VIDMODE = -DXF86VIDMODE
endif
 
AM_CFLAGS = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/include/GL/internal \
-I$(top_srcdir)/src/mapi \
-I$(top_srcdir)/src/mapi/glapi \
-I$(top_builddir)/src/mapi \
-I$(top_builddir)/src/mapi/glapi \
$(VISIBILITY_CFLAGS) \
$(SHARED_GLAPI_CFLAGS) \
$(EXTRA_DEFINES_XF86VIDMODE) \
-D_REENTRANT \
-DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" \
$(DEFINES) \
$(LIBDRM_CFLAGS) \
$(DRI2PROTO_CFLAGS) \
$(GLPROTO_CFLAGS) \
$(X11_INCLUDES)
 
lib_LTLIBRARIES = lib@GL_LIB@.la
 
noinst_LTLIBRARIES = libglx.la
 
libglx_la_SOURCES = \
clientattrib.c \
clientinfo.c \
compsize.c \
create_context.c \
eval.c \
glxconfig.c \
glxcmds.c \
glxcurrent.c \
glx_error.c \
glxext.c \
glxextensions.c \
indirect_glx.c \
indirect.c \
indirect_init.c \
indirect_size.c \
indirect_window_pos.c \
indirect_texture_compression.c \
indirect_transpose_matrix.c \
indirect_vertex_array.c \
indirect_vertex_program.c \
pixel.c \
pixelstore.c \
render2.c \
renderpix.c \
single2.c \
singlepix.c \
vertarr.c \
xfont.c \
glx_pbuffer.c \
glx_query.c \
drisw_glx.c \
dri_common.c \
dri_glx.c \
XF86dri.c \
glxhash.c \
dri2_glx.c \
dri2.c \
applegl_glx.c
 
GL_LIBS = \
libglx.la \
$(SHARED_GLAPI_LIBS) \
$(GLAPI_LIB) \
$(GL_LIB_DEPS)
 
GL_LDFLAGS = \
-Wl,-Bsymbolic \
-version-number 1:2 -no-undefined
 
lib@GL_LIB@_la_SOURCES =
lib@GL_LIB@_la_LIBADD = $(GL_LIBS)
lib@GL_LIB@_la_LDFLAGS = $(GL_LDFLAGS)
 
# Provide compatibility with scripts for the old Mesa build system for
# a while by putting a link to the driver into /lib of the build tree.
all-local: lib@GL_LIB@.la
$(MKDIR_P) $(top_builddir)/$(LIB_DIR);
ln -f .libs/lib@GL_LIB@.so.1.2.0 $(top_builddir)/$(LIB_DIR)/lib@GL_LIB@.so.1
ln -sf lib@GL_LIB@.so.1 $(top_builddir)/$(LIB_DIR)/lib@GL_LIB@.so
/contrib/sdk/sources/Mesa/src/glx/Makefile.in
0,0 → 1,1090
# Makefile.in generated by automake 1.14 from Makefile.am.
# @configure_input@
 
# Copyright (C) 1994-2013 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@
 
# Copyright © 2012 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
 
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
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@
target_triplet = @target@
subdir = src/glx
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/bin/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_bison.m4 \
$(top_srcdir)/m4/ax_prog_cc_for_build.m4 \
$(top_srcdir)/m4/ax_prog_cxx_for_build.m4 \
$(top_srcdir)/m4/ax_prog_flex.m4 \
$(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/ax_python_module.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
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__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(libdir)"
LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
am__DEPENDENCIES_1 =
am__DEPENDENCIES_2 = libglx.la $(SHARED_GLAPI_LIBS) $(GLAPI_LIB) \
$(am__DEPENDENCIES_1)
lib@GL_LIB@_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
am_lib@GL_LIB@_la_OBJECTS =
lib@GL_LIB@_la_OBJECTS = $(am_lib@GL_LIB@_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
lib@GL_LIB@_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
$(AM_CFLAGS) $(CFLAGS) $(lib@GL_LIB@_la_LDFLAGS) $(LDFLAGS) -o \
$@
libglx_la_LIBADD =
am_libglx_la_OBJECTS = clientattrib.lo clientinfo.lo compsize.lo \
create_context.lo eval.lo glxconfig.lo glxcmds.lo \
glxcurrent.lo glx_error.lo glxext.lo glxextensions.lo \
indirect_glx.lo indirect.lo indirect_init.lo indirect_size.lo \
indirect_window_pos.lo indirect_texture_compression.lo \
indirect_transpose_matrix.lo indirect_vertex_array.lo \
indirect_vertex_program.lo pixel.lo pixelstore.lo render2.lo \
renderpix.lo single2.lo singlepix.lo vertarr.lo xfont.lo \
glx_pbuffer.lo glx_query.lo drisw_glx.lo dri_common.lo \
dri_glx.lo XF86dri.lo glxhash.lo dri2_glx.lo dri2.lo \
applegl_glx.lo
libglx_la_OBJECTS = $(am_libglx_la_OBJECTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/bin/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(lib@GL_LIB@_la_SOURCES) $(libglx_la_SOURCES)
DIST_SOURCES = $(lib@GL_LIB@_la_SOURCES) $(libglx_la_SOURCES)
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-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 \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
distdir
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
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"
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_EXEEXT = @BUILD_EXEEXT@
BUILD_OBJEXT = @BUILD_OBJEXT@
CC = @CC@
CCAS = @CCAS@
CCASDEPMODE = @CCASDEPMODE@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CC_FOR_BUILD = @CC_FOR_BUILD@
CFLAGS = @CFLAGS@
CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
CLANG_RESOURCE_DIR = @CLANG_RESOURCE_DIR@
CLOCK_LIB = @CLOCK_LIB@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
CPP_FOR_BUILD = @CPP_FOR_BUILD@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXCPPFLAGS_FOR_BUILD = @CXXCPPFLAGS_FOR_BUILD@
CXXCPP_FOR_BUILD = @CXXCPP_FOR_BUILD@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CXXFLAGS_FOR_BUILD = @CXXFLAGS_FOR_BUILD@
CXX_FOR_BUILD = @CXX_FOR_BUILD@
CYGPATH_W = @CYGPATH_W@
DEFINES = @DEFINES@
DEFINES_FOR_BUILD = @DEFINES_FOR_BUILD@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DLOPEN_LIBS = @DLOPEN_LIBS@
DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
DRIGL_CFLAGS = @DRIGL_CFLAGS@
DRIGL_LIBS = @DRIGL_LIBS@
DRI_DRIVER_INSTALL_DIR = @DRI_DRIVER_INSTALL_DIR@
DRI_DRIVER_SEARCH_DIR = @DRI_DRIVER_SEARCH_DIR@
DRI_LIB_DEPS = @DRI_LIB_DEPS@
DRI_PC_REQ_PRIV = @DRI_PC_REQ_PRIV@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGL_CFLAGS = @EGL_CFLAGS@
EGL_CLIENT_APIS = @EGL_CLIENT_APIS@
EGL_DRIVER_INSTALL_DIR = @EGL_DRIVER_INSTALL_DIR@
EGL_LIB_DEPS = @EGL_LIB_DEPS@
EGL_LIB_GLOB = @EGL_LIB_GLOB@
EGL_LIB_NAME = @EGL_LIB_NAME@
EGL_NATIVE_PLATFORM = @EGL_NATIVE_PLATFORM@
EGL_PLATFORMS = @EGL_PLATFORMS@
EGREP = @EGREP@
ELF_LIB = @ELF_LIB@
EXEEXT = @EXEEXT@
EXPAT_INCLUDES = @EXPAT_INCLUDES@
FGREP = @FGREP@
FREEDRENO_CFLAGS = @FREEDRENO_CFLAGS@
FREEDRENO_LIBS = @FREEDRENO_LIBS@
GALLIUM_DRI_LIB_DEPS = @GALLIUM_DRI_LIB_DEPS@
GALLIUM_PIPE_LOADER_DEFINES = @GALLIUM_PIPE_LOADER_DEFINES@
GALLIUM_PIPE_LOADER_LIBS = @GALLIUM_PIPE_LOADER_LIBS@
GALLIUM_PIPE_LOADER_XCB_CFLAGS = @GALLIUM_PIPE_LOADER_XCB_CFLAGS@
GALLIUM_PIPE_LOADER_XCB_LIBS = @GALLIUM_PIPE_LOADER_XCB_LIBS@
GBM_PC_LIB_PRIV = @GBM_PC_LIB_PRIV@
GBM_PC_REQ_PRIV = @GBM_PC_REQ_PRIV@
GLAPI_LIB_GLOB = @GLAPI_LIB_GLOB@
GLAPI_LIB_NAME = @GLAPI_LIB_NAME@
GLESv1_CM_LIB_DEPS = @GLESv1_CM_LIB_DEPS@
GLESv1_CM_LIB_GLOB = @GLESv1_CM_LIB_GLOB@
GLESv1_CM_LIB_NAME = @GLESv1_CM_LIB_NAME@
GLESv1_CM_PC_LIB_PRIV = @GLESv1_CM_PC_LIB_PRIV@
GLESv2_LIB_DEPS = @GLESv2_LIB_DEPS@
GLESv2_LIB_GLOB = @GLESv2_LIB_GLOB@
GLESv2_LIB_NAME = @GLESv2_LIB_NAME@
GLESv2_PC_LIB_PRIV = @GLESv2_PC_LIB_PRIV@
GLPROTO_CFLAGS = @GLPROTO_CFLAGS@
GLPROTO_LIBS = @GLPROTO_LIBS@
GLX_TLS = @GLX_TLS@
GL_LIB = @GL_LIB@
GL_LIB_DEPS = @GL_LIB_DEPS@
GL_LIB_GLOB = @GL_LIB_GLOB@
GL_LIB_NAME = @GL_LIB_NAME@
GL_PC_CFLAGS = @GL_PC_CFLAGS@
GL_PC_LIB_PRIV = @GL_PC_LIB_PRIV@
GL_PC_REQ_PRIV = @GL_PC_REQ_PRIV@
GREP = @GREP@
HAVE_XF86VIDMODE = @HAVE_XF86VIDMODE@
INDENT = @INDENT@
INDENT_FLAGS = @INDENT_FLAGS@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTEL_CFLAGS = @INTEL_CFLAGS@
INTEL_LIBS = @INTEL_LIBS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBCLC_INCLUDEDIR = @LIBCLC_INCLUDEDIR@
LIBCLC_LIBEXECDIR = @LIBCLC_LIBEXECDIR@
LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
LIBDRM_LIBS = @LIBDRM_LIBS@
LIBDRM_XORG_CFLAGS = @LIBDRM_XORG_CFLAGS@
LIBDRM_XORG_LIBS = @LIBDRM_XORG_LIBS@
LIBKMS_XORG_CFLAGS = @LIBKMS_XORG_CFLAGS@
LIBKMS_XORG_LIBS = @LIBKMS_XORG_LIBS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@
LIBUDEV_LIBS = @LIBUDEV_LIBS@
LIB_DIR = @LIB_DIR@
LIPO = @LIPO@
LLVM_BINDIR = @LLVM_BINDIR@
LLVM_CFLAGS = @LLVM_CFLAGS@
LLVM_CONFIG = @LLVM_CONFIG@
LLVM_CPPFLAGS = @LLVM_CPPFLAGS@
LLVM_CXXFLAGS = @LLVM_CXXFLAGS@
LLVM_INCLUDEDIR = @LLVM_INCLUDEDIR@
LLVM_LDFLAGS = @LLVM_LDFLAGS@
LLVM_LIBDIR = @LLVM_LIBDIR@
LLVM_LIBS = @LLVM_LIBS@
LLVM_VERSION = @LLVM_VERSION@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKE = @MAKE@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MESA_LLVM = @MESA_LLVM@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
NOUVEAU_CFLAGS = @NOUVEAU_CFLAGS@
NOUVEAU_LIBS = @NOUVEAU_LIBS@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OPENCL_LIB_INSTALL_DIR = @OPENCL_LIB_INSTALL_DIR@
OSMESA_LIB = @OSMESA_LIB@
OSMESA_LIB_DEPS = @OSMESA_LIB_DEPS@
OSMESA_LIB_NAME = @OSMESA_LIB_NAME@
OSMESA_MESA_DEPS = @OSMESA_MESA_DEPS@
OSMESA_PC_LIB_PRIV = @OSMESA_PC_LIB_PRIV@
OSMESA_PC_REQ = @OSMESA_PC_REQ@
OSMESA_VERSION = @OSMESA_VERSION@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
POSIX_SHELL = @POSIX_SHELL@
PTHREAD_CC = @PTHREAD_CC@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
PYTHON2 = @PYTHON2@
RADEON_CFLAGS = @RADEON_CFLAGS@
RADEON_LIBS = @RADEON_LIBS@
RANLIB = @RANLIB@
SED = @SED@
SELINUX_LIBS = @SELINUX_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VDPAU_CFLAGS = @VDPAU_CFLAGS@
VDPAU_LIBS = @VDPAU_LIBS@
VDPAU_LIB_INSTALL_DIR = @VDPAU_LIB_INSTALL_DIR@
VDPAU_MAJOR = @VDPAU_MAJOR@
VDPAU_MINOR = @VDPAU_MINOR@
VERSION = @VERSION@
VG_LIB_DEPS = @VG_LIB_DEPS@
VG_LIB_GLOB = @VG_LIB_GLOB@
VG_LIB_NAME = @VG_LIB_NAME@
VG_PC_LIB_PRIV = @VG_PC_LIB_PRIV@
VISIBILITY_CFLAGS = @VISIBILITY_CFLAGS@
VISIBILITY_CXXFLAGS = @VISIBILITY_CXXFLAGS@
WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
WAYLAND_LIBS = @WAYLAND_LIBS@
WAYLAND_SCANNER = @WAYLAND_SCANNER@
X11_INCLUDES = @X11_INCLUDES@
XA_MAJOR = @XA_MAJOR@
XA_MINOR = @XA_MINOR@
XA_TINY = @XA_TINY@
XA_VERSION = @XA_VERSION@
XCB_DRI2_CFLAGS = @XCB_DRI2_CFLAGS@
XCB_DRI2_LIBS = @XCB_DRI2_LIBS@
XEXT_CFLAGS = @XEXT_CFLAGS@
XEXT_LIBS = @XEXT_LIBS@
XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
XLIBGL_CFLAGS = @XLIBGL_CFLAGS@
XLIBGL_LIBS = @XLIBGL_LIBS@
XORG_CFLAGS = @XORG_CFLAGS@
XORG_DRIVER_INSTALL_DIR = @XORG_DRIVER_INSTALL_DIR@
XORG_LIBS = @XORG_LIBS@
XVMC_CFLAGS = @XVMC_CFLAGS@
XVMC_LIBS = @XVMC_LIBS@
XVMC_LIB_INSTALL_DIR = @XVMC_LIB_INSTALL_DIR@
XVMC_MAJOR = @XVMC_MAJOR@
XVMC_MINOR = @XVMC_MINOR@
YACC = @YACC@
YFLAGS = @YFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_CXX_FOR_BUILD = @ac_ct_CXX_FOR_BUILD@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
ax_pthread_config = @ax_pthread_config@
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 = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
@HAVE_SHARED_GLAPI_TRUE@SHARED_GLAPI_CFLAGS = -DGLX_SHARED_GLAPI
@HAVE_SHARED_GLAPI_TRUE@SHARED_GLAPI_LIBS = $(top_builddir)/src/mapi/shared-glapi/libglapi.la
SUBDIRS = . tests
GLAPI_LIB = $(top_builddir)/src/mapi/glapi/libglapi.la
@HAVE_XF86VIDMODE_TRUE@EXTRA_DEFINES_XF86VIDMODE = -DXF86VIDMODE
AM_CFLAGS = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/include/GL/internal \
-I$(top_srcdir)/src/mapi \
-I$(top_srcdir)/src/mapi/glapi \
-I$(top_builddir)/src/mapi \
-I$(top_builddir)/src/mapi/glapi \
$(VISIBILITY_CFLAGS) \
$(SHARED_GLAPI_CFLAGS) \
$(EXTRA_DEFINES_XF86VIDMODE) \
-D_REENTRANT \
-DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" \
$(DEFINES) \
$(LIBDRM_CFLAGS) \
$(DRI2PROTO_CFLAGS) \
$(GLPROTO_CFLAGS) \
$(X11_INCLUDES)
 
lib_LTLIBRARIES = lib@GL_LIB@.la
noinst_LTLIBRARIES = libglx.la
libglx_la_SOURCES = \
clientattrib.c \
clientinfo.c \
compsize.c \
create_context.c \
eval.c \
glxconfig.c \
glxcmds.c \
glxcurrent.c \
glx_error.c \
glxext.c \
glxextensions.c \
indirect_glx.c \
indirect.c \
indirect_init.c \
indirect_size.c \
indirect_window_pos.c \
indirect_texture_compression.c \
indirect_transpose_matrix.c \
indirect_vertex_array.c \
indirect_vertex_program.c \
pixel.c \
pixelstore.c \
render2.c \
renderpix.c \
single2.c \
singlepix.c \
vertarr.c \
xfont.c \
glx_pbuffer.c \
glx_query.c \
drisw_glx.c \
dri_common.c \
dri_glx.c \
XF86dri.c \
glxhash.c \
dri2_glx.c \
dri2.c \
applegl_glx.c
 
GL_LIBS = \
libglx.la \
$(SHARED_GLAPI_LIBS) \
$(GLAPI_LIB) \
$(GL_LIB_DEPS)
 
GL_LDFLAGS = \
-Wl,-Bsymbolic \
-version-number 1:2 -no-undefined
 
lib@GL_LIB@_la_SOURCES =
lib@GL_LIB@_la_LIBADD = $(GL_LIBS)
lib@GL_LIB@_la_LDFLAGS = $(GL_LDFLAGS)
all: all-recursive
 
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/glx/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign src/glx/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
 
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
 
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
list2="$$list2 $$p"; \
else :; fi; \
done; \
test -z "$$list2" || { \
echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
}
 
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
for p in $$list; do \
$(am__strip_dir) \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
done
 
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; \
locs=`for p in $$list; do echo $$p; done | \
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
sort -u`; \
test -z "$$locs" || { \
echo rm -f $${locs}; \
rm -f $${locs}; \
}
 
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_LTLIBRARIES)'; \
locs=`for p in $$list; do echo $$p; done | \
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
sort -u`; \
test -z "$$locs" || { \
echo rm -f $${locs}; \
rm -f $${locs}; \
}
 
lib@GL_LIB@.la: $(lib@GL_LIB@_la_OBJECTS) $(lib@GL_LIB@_la_DEPENDENCIES) $(EXTRA_lib@GL_LIB@_la_DEPENDENCIES)
$(AM_V_CCLD)$(lib@GL_LIB@_la_LINK) -rpath $(libdir) $(lib@GL_LIB@_la_OBJECTS) $(lib@GL_LIB@_la_LIBADD) $(LIBS)
 
libglx.la: $(libglx_la_OBJECTS) $(libglx_la_DEPENDENCIES) $(EXTRA_libglx_la_DEPENDENCIES)
$(AM_V_CCLD)$(LINK) $(libglx_la_OBJECTS) $(libglx_la_LIBADD) $(LIBS)
 
mostlyclean-compile:
-rm -f *.$(OBJEXT)
 
distclean-compile:
-rm -f *.tab.c
 
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XF86dri.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/applegl_glx.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clientattrib.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clientinfo.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compsize.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/create_context.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dri2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dri2_glx.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dri_common.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dri_glx.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drisw_glx.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eval.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glx_error.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glx_pbuffer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glx_query.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glxcmds.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glxconfig.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glxcurrent.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glxext.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glxextensions.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glxhash.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indirect.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indirect_glx.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indirect_init.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indirect_size.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indirect_texture_compression.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indirect_transpose_matrix.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indirect_vertex_array.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indirect_vertex_program.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indirect_window_pos.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pixel.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pixelstore.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/render2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/renderpix.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/single2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/singlepix.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vertarr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfont.Plo@am__quote@
 
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
 
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
 
mostlyclean-libtool:
-rm -f *.lo
 
clean-libtool:
-rm -rf .libs _libs
 
# 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.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
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"
 
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
 
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
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; \
$(am__define_uniq_tagged_files); \
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-recursive
 
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
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"
cscopelist: cscopelist-recursive
 
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
 
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
distdir: $(DISTFILES)
@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 \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
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
check-am: all-am
check: check-recursive
all-am: Makefile $(LTLIBRARIES) all-local
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(libdir)"; 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:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
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."
clean: clean-recursive
 
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
clean-noinstLTLIBRARIES mostlyclean-am
 
distclean: distclean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
 
dvi: dvi-recursive
 
dvi-am:
 
html: html-recursive
 
html-am:
 
info: info-recursive
 
info-am:
 
install-data-am:
 
install-dvi: install-dvi-recursive
 
install-dvi-am:
 
install-exec-am: install-libLTLIBRARIES
 
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 -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
 
mostlyclean: mostlyclean-recursive
 
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
 
pdf: pdf-recursive
 
pdf-am:
 
ps: ps-recursive
 
ps-am:
 
uninstall-am: uninstall-libLTLIBRARIES
 
.MAKE: $(am__recursive_targets) install-am install-strip
 
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am all-local \
check check-am clean clean-generic clean-libLTLIBRARIES \
clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am 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-libLTLIBRARIES install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs installdirs-am \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
uninstall-libLTLIBRARIES
 
 
# Provide compatibility with scripts for the old Mesa build system for
# a while by putting a link to the driver into /lib of the build tree.
all-local: lib@GL_LIB@.la
$(MKDIR_P) $(top_builddir)/$(LIB_DIR);
ln -f .libs/lib@GL_LIB@.so.1.2.0 $(top_builddir)/$(LIB_DIR)/lib@GL_LIB@.so.1
ln -sf lib@GL_LIB@.so.1 $(top_builddir)/$(LIB_DIR)/lib@GL_LIB@.so
 
# 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:
/contrib/sdk/sources/Mesa/src/glx/SConscript
0,0 → 1,135
Import('*')
 
if not env['x11'] or not env['xcb'] or not env['drm']:
Return()
 
from sys import executable as python_cmd
 
env = env.Clone()
 
env.Prepend(CPPPATH = [
'.', # the build/<platform>/glx/ directory
'#include',
'#include/GL/internal',
'#src/mesa',
'#src/mapi',
'#src/mapi/glapi',
#$(LIBDRM_CFLAGS)
#$(DRI2PROTO_CFLAGS)
#$(GLPROTO_CFLAGS)
#$(X11_INCLUDES)
])
 
env.Append(CPPDEFINES = [
'_REENTRANT',
#('DEFAULT_DRIVER_DIR', 'DRI_DRIVER_SEARCH_DIR')
])
 
env.Prepend(LIBS = [
glapi
])
 
env.PkgUseModules('X11')
env.PkgUseModules('XCB')
env.PkgUseModules('DRM')
 
if env['HAVE_XF86VIDMODE']:
env.Append(CPPDEFINES = ['XF86VIDMODE'])
env.PkgUseModules('XF86VIDMODE')
 
if False: # XXX: SHARED_GLAPI
env.Append(CPPDEFINES = ['GLX_SHARED_GLAPI'])
 
sources = [
'clientattrib.c',
'clientinfo.c',
'create_context.c',
'compsize.c',
'eval.c',
'glx_error.c',
'glxconfig.c',
'glxcmds.c',
'glxcurrent.c',
'glxext.c',
'glxextensions.c',
'indirect_glx.c',
'indirect.c',
'indirect_init.c',
'indirect_size.c',
'indirect_window_pos.c',
'indirect_texture_compression.c',
'indirect_transpose_matrix.c',
'indirect_vertex_array.c',
'indirect_vertex_program.c',
'pixel.c',
'pixelstore.c',
'render2.c',
'renderpix.c',
'single2.c',
'singlepix.c',
'vertarr.c',
'xfont.c',
'glx_pbuffer.c',
'glx_query.c',
'drisw_glx.c',
'dri_common.c',
'dri_glx.c',
'XF86dri.c',
'glxhash.c',
'dri2_glx.c',
'dri2.c',
'applegl_glx.c',
]
 
libgl = env.SharedLibrary(
target ='GL',
source = sources,
)
 
 
# Generate GLX-specific .c and .h files here. Other GL API-related
# files are used, but they're generated in mapi/glapi/gen/ since they're
# used by other targets as well.
 
GLAPI = '#src/mapi/glapi/'
 
env.CodeGenerate(
target = 'indirect.c',
script = GLAPI + 'gen/glX_proto_send.py',
source = GLAPI + 'gen/gl_and_es_API.xml',
command = python_cmd + ' $SCRIPT -f $SOURCE -m proto > $TARGET'
)
 
env.CodeGenerate(
target = 'indirect_size.c',
script = GLAPI + 'gen/glX_proto_size.py',
source = GLAPI + 'gen/gl_API.xml',
command = python_cmd + ' $SCRIPT -f $SOURCE -m size_c --only-set > $TARGET'
)
 
env.CodeGenerate(
target = 'indirect_init.c',
script = GLAPI + 'gen/glX_proto_send.py',
source = GLAPI + 'gen/gl_API.xml',
command = python_cmd + ' $SCRIPT -f $SOURCE -m init_c > $TARGET'
)
 
env.CodeGenerate(
target = 'indirect_size.h',
script = GLAPI + 'gen/glX_proto_size.py',
source = GLAPI + 'gen/gl_API.xml',
command = python_cmd + ' $SCRIPT -f $SOURCE -m size_h --only-set -h _INDIRECT_SIZE_H > $TARGET'
)
 
env.CodeGenerate(
target = 'indirect.h',
script = GLAPI + 'gen/glX_proto_send.py',
source = GLAPI + 'gen/gl_API.xml',
command = python_cmd + ' $SCRIPT -m init_h -f $SOURCE > $TARGET',
)
 
 
libgl = env.InstallSharedLibrary(libgl, version=(1, 2))
 
env.Alias('glx', libgl)
env.Alias('libgl', libgl)
/contrib/sdk/sources/Mesa/src/glx/XF86dri.c
0,0 → 1,633
/**************************************************************************
 
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
**************************************************************************/
 
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Jens Owen <jens@tungstengraphics.com>
* Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
 
/* THIS IS NOT AN X CONSORTIUM STANDARD */
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
 
#include <X11/Xlibint.h>
#include <X11/Xfuncproto.h>
#include <X11/extensions/Xext.h>
#include <X11/extensions/extutil.h>
#include "xf86dristr.h"
#include <limits.h>
 
static XExtensionInfo _xf86dri_info_data;
static XExtensionInfo *xf86dri_info = &_xf86dri_info_data;
static char xf86dri_extension_name[] = XF86DRINAME;
 
#define XF86DRICheckExtension(dpy,i,val) \
XextCheckExtension (dpy, i, xf86dri_extension_name, val)
 
/*****************************************************************************
* *
* private utility routines *
* *
*****************************************************************************/
 
static int close_display(Display * dpy, XExtCodes * extCodes);
static /* const */ XExtensionHooks xf86dri_extension_hooks = {
NULL, /* create_gc */
NULL, /* copy_gc */
NULL, /* flush_gc */
NULL, /* free_gc */
NULL, /* create_font */
NULL, /* free_font */
close_display, /* close_display */
NULL, /* wire_to_event */
NULL, /* event_to_wire */
NULL, /* error */
NULL, /* error_string */
};
 
static
XEXT_GENERATE_FIND_DISPLAY(find_display, xf86dri_info,
xf86dri_extension_name,
&xf86dri_extension_hooks, 0, NULL)
 
static
XEXT_GENERATE_CLOSE_DISPLAY(close_display, xf86dri_info)
 
 
/*****************************************************************************
* *
* public XFree86-DRI Extension routines *
* *
*****************************************************************************/
#if 0
#include <stdio.h>
#define TRACE(msg) fprintf(stderr,"XF86DRI%s\n", msg);
#else
#define TRACE(msg)
#endif
 
Bool
XF86DRIQueryExtension(Display * dpy, int *event_basep,
int *error_basep)
{
XExtDisplayInfo *info = find_display(dpy);
 
TRACE("QueryExtension...");
if (XextHasExtension(info)) {
*event_basep = info->codes->first_event;
*error_basep = info->codes->first_error;
TRACE("QueryExtension... return True");
return True;
}
else {
TRACE("QueryExtension... return False");
return False;
}
}
 
Bool
XF86DRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion,
int *patchVersion)
{
XExtDisplayInfo *info = find_display(dpy);
xXF86DRIQueryVersionReply rep;
xXF86DRIQueryVersionReq *req;
 
TRACE("QueryVersion...");
XF86DRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(XF86DRIQueryVersion, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_XF86DRIQueryVersion;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("QueryVersion... return False");
return False;
}
*majorVersion = rep.majorVersion;
*minorVersion = rep.minorVersion;
*patchVersion = rep.patchVersion;
UnlockDisplay(dpy);
SyncHandle();
TRACE("QueryVersion... return True");
return True;
}
 
Bool
XF86DRIQueryDirectRenderingCapable(Display * dpy, int screen,
Bool * isCapable)
{
XExtDisplayInfo *info = find_display(dpy);
xXF86DRIQueryDirectRenderingCapableReply rep;
xXF86DRIQueryDirectRenderingCapableReq *req;
 
TRACE("QueryDirectRenderingCapable...");
XF86DRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(XF86DRIQueryDirectRenderingCapable, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_XF86DRIQueryDirectRenderingCapable;
req->screen = screen;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("QueryDirectRenderingCapable... return False");
return False;
}
*isCapable = rep.isCapable;
UnlockDisplay(dpy);
SyncHandle();
TRACE("QueryDirectRenderingCapable... return True");
return True;
}
 
Bool
XF86DRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA,
char **busIdString)
{
XExtDisplayInfo *info = find_display(dpy);
xXF86DRIOpenConnectionReply rep;
xXF86DRIOpenConnectionReq *req;
 
TRACE("OpenConnection...");
XF86DRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(XF86DRIOpenConnection, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_XF86DRIOpenConnection;
req->screen = screen;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("OpenConnection... return False");
return False;
}
 
*hSAREA = rep.hSAREALow;
if (sizeof(drm_handle_t) == 8) {
int shift = 32; /* var to prevent warning on next line */
*hSAREA |= ((drm_handle_t) rep.hSAREAHigh) << shift;
}
 
if (rep.length) {
if (rep.busIdStringLength < INT_MAX)
*busIdString = calloc(rep.busIdStringLength + 1, 1);
else
*busIdString = NULL;
if (*busIdString == NULL) {
_XEatData(dpy, ((rep.busIdStringLength + 3) & ~3));
UnlockDisplay(dpy);
SyncHandle();
TRACE("OpenConnection... return False");
return False;
}
_XReadPad(dpy, *busIdString, rep.busIdStringLength);
}
else {
*busIdString = NULL;
}
UnlockDisplay(dpy);
SyncHandle();
TRACE("OpenConnection... return True");
return True;
}
 
Bool
XF86DRIAuthConnection(Display * dpy, int screen, drm_magic_t magic)
{
XExtDisplayInfo *info = find_display(dpy);
xXF86DRIAuthConnectionReq *req;
xXF86DRIAuthConnectionReply rep;
 
TRACE("AuthConnection...");
XF86DRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(XF86DRIAuthConnection, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_XF86DRIAuthConnection;
req->screen = screen;
req->magic = magic;
rep.authenticated = 0;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.authenticated) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("AuthConnection... return False");
return False;
}
UnlockDisplay(dpy);
SyncHandle();
TRACE("AuthConnection... return True");
return True;
}
 
Bool
XF86DRICloseConnection(Display * dpy, int screen)
{
XExtDisplayInfo *info = find_display(dpy);
xXF86DRICloseConnectionReq *req;
 
TRACE("CloseConnection...");
 
XF86DRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(XF86DRICloseConnection, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_XF86DRICloseConnection;
req->screen = screen;
UnlockDisplay(dpy);
SyncHandle();
TRACE("CloseConnection... return True");
return True;
}
 
Bool
XF86DRIGetClientDriverName(Display * dpy, int screen,
int *ddxDriverMajorVersion,
int *ddxDriverMinorVersion,
int *ddxDriverPatchVersion,
char **clientDriverName)
{
XExtDisplayInfo *info = find_display(dpy);
xXF86DRIGetClientDriverNameReply rep;
xXF86DRIGetClientDriverNameReq *req;
 
TRACE("GetClientDriverName...");
XF86DRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(XF86DRIGetClientDriverName, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_XF86DRIGetClientDriverName;
req->screen = screen;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("GetClientDriverName... return False");
return False;
}
 
*ddxDriverMajorVersion = rep.ddxDriverMajorVersion;
*ddxDriverMinorVersion = rep.ddxDriverMinorVersion;
*ddxDriverPatchVersion = rep.ddxDriverPatchVersion;
 
if (rep.length) {
if (rep.clientDriverNameLength < INT_MAX)
*clientDriverName = calloc(rep.clientDriverNameLength + 1, 1);
else
*clientDriverName = NULL;
if (*clientDriverName == NULL) {
_XEatData(dpy, ((rep.clientDriverNameLength + 3) & ~3));
UnlockDisplay(dpy);
SyncHandle();
TRACE("GetClientDriverName... return False");
return False;
}
_XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength);
}
else {
*clientDriverName = NULL;
}
UnlockDisplay(dpy);
SyncHandle();
TRACE("GetClientDriverName... return True");
return True;
}
 
Bool
XF86DRICreateContextWithConfig(Display * dpy, int screen, int configID,
XID * context, drm_context_t * hHWContext)
{
XExtDisplayInfo *info = find_display(dpy);
xXF86DRICreateContextReply rep;
xXF86DRICreateContextReq *req;
 
TRACE("CreateContext...");
XF86DRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(XF86DRICreateContext, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_XF86DRICreateContext;
req->visual = configID;
req->screen = screen;
*context = XAllocID(dpy);
req->context = *context;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("CreateContext... return False");
return False;
}
*hHWContext = rep.hHWContext;
UnlockDisplay(dpy);
SyncHandle();
TRACE("CreateContext... return True");
return True;
}
 
Bool
XF86DRICreateContext(Display * dpy, int screen, Visual * visual,
XID * context, drm_context_t * hHWContext)
{
return XF86DRICreateContextWithConfig(dpy, screen, visual->visualid,
context, hHWContext);
}
 
Bool
XF86DRIDestroyContext(Display * dpy, int screen, XID context)
{
XExtDisplayInfo *info = find_display(dpy);
xXF86DRIDestroyContextReq *req;
 
TRACE("DestroyContext...");
XF86DRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(XF86DRIDestroyContext, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_XF86DRIDestroyContext;
req->screen = screen;
req->context = context;
UnlockDisplay(dpy);
SyncHandle();
TRACE("DestroyContext... return True");
return True;
}
 
Bool
XF86DRICreateDrawable(Display * dpy, int screen,
XID drawable, drm_drawable_t * hHWDrawable)
{
XExtDisplayInfo *info = find_display(dpy);
xXF86DRICreateDrawableReply rep;
xXF86DRICreateDrawableReq *req;
 
TRACE("CreateDrawable...");
XF86DRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(XF86DRICreateDrawable, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_XF86DRICreateDrawable;
req->screen = screen;
req->drawable = drawable;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("CreateDrawable... return False");
return False;
}
*hHWDrawable = rep.hHWDrawable;
UnlockDisplay(dpy);
SyncHandle();
TRACE("CreateDrawable... return True");
return True;
}
 
static int
noopErrorHandler(Display * dpy, XErrorEvent * xerr)
{
return 0;
}
 
Bool
XF86DRIDestroyDrawable(Display * dpy, int screen, XID drawable)
{
XExtDisplayInfo *info = find_display(dpy);
xXF86DRIDestroyDrawableReq *req;
int (*oldXErrorHandler) (Display *, XErrorEvent *);
 
TRACE("DestroyDrawable...");
XF86DRICheckExtension(dpy, info, False);
 
/* This is called from the DRI driver, which used call it like this
*
* if (windowExists(drawable))
* destroyDrawable(drawable);
*
* which is a textbook race condition - the window may disappear
* from the server between checking for its existance and
* destroying it. Instead we change the semantics of
* __DRIinterfaceMethodsRec::destroyDrawable() to succeed even if
* the windows is gone, by wrapping the destroy call in an error
* handler. */
 
XSync(dpy, False);
oldXErrorHandler = XSetErrorHandler(noopErrorHandler);
 
LockDisplay(dpy);
GetReq(XF86DRIDestroyDrawable, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_XF86DRIDestroyDrawable;
req->screen = screen;
req->drawable = drawable;
UnlockDisplay(dpy);
SyncHandle();
 
XSetErrorHandler(oldXErrorHandler);
 
TRACE("DestroyDrawable... return True");
return True;
}
 
Bool
XF86DRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable,
unsigned int *index, unsigned int *stamp,
int *X, int *Y, int *W, int *H,
int *numClipRects, drm_clip_rect_t ** pClipRects,
int *backX, int *backY,
int *numBackClipRects,
drm_clip_rect_t ** pBackClipRects)
{
XExtDisplayInfo *info = find_display(dpy);
xXF86DRIGetDrawableInfoReply rep;
xXF86DRIGetDrawableInfoReq *req;
int total_rects;
 
TRACE("GetDrawableInfo...");
XF86DRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(XF86DRIGetDrawableInfo, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_XF86DRIGetDrawableInfo;
req->screen = screen;
req->drawable = drawable;
 
if (!_XReply(dpy, (xReply *) & rep, 1, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("GetDrawableInfo... return False");
return False;
}
*index = rep.drawableTableIndex;
*stamp = rep.drawableTableStamp;
*X = (int) rep.drawableX;
*Y = (int) rep.drawableY;
*W = (int) rep.drawableWidth;
*H = (int) rep.drawableHeight;
*numClipRects = rep.numClipRects;
total_rects = *numClipRects;
 
*backX = rep.backX;
*backY = rep.backY;
*numBackClipRects = rep.numBackClipRects;
total_rects += *numBackClipRects;
 
#if 0
/* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks
* backwards compatibility (Because of the >> 2 shift) but the fix
* enables multi-threaded apps to work.
*/
if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) -
SIZEOF(xGenericReply) +
total_rects * sizeof(drm_clip_rect_t)) +
3) & ~3) >> 2)) {
_XEatData(dpy, rep.length);
UnlockDisplay(dpy);
SyncHandle();
TRACE("GetDrawableInfo... return False");
return False;
}
#endif
 
if (*numClipRects) {
int len = sizeof(drm_clip_rect_t) * (*numClipRects);
 
*pClipRects = calloc(len, 1);
if (*pClipRects)
_XRead(dpy, (char *) *pClipRects, len);
}
else {
*pClipRects = NULL;
}
 
if (*numBackClipRects) {
int len = sizeof(drm_clip_rect_t) * (*numBackClipRects);
 
*pBackClipRects = calloc(len, 1);
if (*pBackClipRects)
_XRead(dpy, (char *) *pBackClipRects, len);
}
else {
*pBackClipRects = NULL;
}
 
UnlockDisplay(dpy);
SyncHandle();
TRACE("GetDrawableInfo... return True");
return True;
}
 
Bool
XF86DRIGetDeviceInfo(Display * dpy, int screen, drm_handle_t * hFrameBuffer,
int *fbOrigin, int *fbSize, int *fbStride,
int *devPrivateSize, void **pDevPrivate)
{
XExtDisplayInfo *info = find_display(dpy);
xXF86DRIGetDeviceInfoReply rep;
xXF86DRIGetDeviceInfoReq *req;
 
TRACE("GetDeviceInfo...");
XF86DRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(XF86DRIGetDeviceInfo, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_XF86DRIGetDeviceInfo;
req->screen = screen;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("GetDeviceInfo... return False");
return False;
}
 
*hFrameBuffer = rep.hFrameBufferLow;
if (sizeof(drm_handle_t) == 8) {
int shift = 32; /* var to prevent warning on next line */
*hFrameBuffer |= ((drm_handle_t) rep.hFrameBufferHigh) << shift;
}
 
*fbOrigin = rep.framebufferOrigin;
*fbSize = rep.framebufferSize;
*fbStride = rep.framebufferStride;
*devPrivateSize = rep.devPrivateSize;
 
if (rep.length) {
if (!(*pDevPrivate = calloc(rep.devPrivateSize, 1))) {
_XEatData(dpy, ((rep.devPrivateSize + 3) & ~3));
UnlockDisplay(dpy);
SyncHandle();
TRACE("GetDeviceInfo... return False");
return False;
}
_XRead(dpy, (char *) *pDevPrivate, rep.devPrivateSize);
}
else {
*pDevPrivate = NULL;
}
 
UnlockDisplay(dpy);
SyncHandle();
TRACE("GetDeviceInfo... return True");
return True;
}
 
Bool
XF86DRIOpenFullScreen(Display * dpy, int screen, Drawable drawable)
{
/* This function and the underlying X protocol are deprecated.
*/
(void) dpy;
(void) screen;
(void) drawable;
return False;
}
 
Bool
XF86DRICloseFullScreen(Display * dpy, int screen, Drawable drawable)
{
/* This function and the underlying X protocol are deprecated.
*/
(void) dpy;
(void) screen;
(void) drawable;
return True;
}
 
#endif /* GLX_DIRECT_RENDERING */
/contrib/sdk/sources/Mesa/src/glx/apple/Makefile
0,0 → 1,132
TOP = ../../..
top_builddir = $(TOP)
# This can be a filthy lie. But it doesn't currently build out-of-tree
# anyway, so it's no worse than what we've got now.
top_srcdir = $(TOP)
 
include $(TOP)/configs/current
 
#CC=gcc
#GL_CFLAGS=-Wall -ggdb3 -Os -DHAVE_PTHREAD -D_REENTRANT $(RC_CFLAGS) $(CFLAGS)
#GL_LDFLAGS=-L$(INSTALL_DIR)/lib -L$(X11_DIR)/lib $(LDFLAGS) -Wl,-single_module
 
TCLSH=tclsh8.5
MKDIR=mkdir
INSTALL=install
LN=ln
RM=rm
 
#INCLUDE=-I. -Iinclude -I.. -DGLX_ALIAS_UNSUPPORTED -I$(INSTALL_DIR)/include -I$(X11_DIR)/include
 
#COMPILE=$(CC) $(INCLUDE) $(GL_CFLAGS) -c
 
#The directory with the final binaries.
BUILD_DIR=builds
 
default: $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
 
SOURCES = \
apple_cgl.c \
apple_glx.c \
apple_glx_context.c \
apple_glx_drawable.c \
apple_glx_log.c \
apple_glx_pbuffer.c \
apple_glx_pixmap.c \
apple_glx_surface.c \
apple_visual.c \
apple_glapi.c \
apple_xgl_api_read.c \
apple_xgl_api_stereo.c \
apple_xgl_api_viewport.c \
appledri.c \
../create_context.c \
../clientattrib.c \
../compsize.c \
../glxconfig.c \
glx_empty.c \
../glx_error.c \
../glx_pbuffer.c \
../glx_query.c \
../glxcmds.c \
../glxcurrent.c \
../glxext.c \
../glxextensions.c \
../glxhash.c \
glxreply.c \
../pixel.c \
../xfont.c \
../applegl_glx.c
 
include $(TOP)/src/mesa/Makefile.sources
 
# override GLAPI_LIB
GLAPI_LIB = $(TOP)/src/mapi/glapi/libglapi.a
 
LDFLAGS += -lXplugin -framework ApplicationServices -framework CoreFoundation
 
OBJECTS = $(SOURCES:.c=.o)
 
INCLUDES = -I. -Iinclude -I..\
-I$(TOP)/include \
-I$(TOP)/include/GL/internal \
-I$(TOP)/src/mesa \
-I$(TOP)/src/mesa/main \
-I$(TOP)/src/mapi \
-I$(TOP)/src/mapi/glapi \
$(LIBDRM_CFLAGS) \
$(DRI2PROTO_CFLAGS) \
$(X11_INCLUDES)
 
##### RULES #####
 
.c.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $(EXTRA_DEFINES) $< -o $@
 
.S.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $(EXTRA_DEFINES) $< -o $@
 
##### TARGETS #####
 
default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
 
# Make libGL
$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) $(GLAPI_LIB) Makefile
$(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
-major 1 -minor 2 $(MKLIB_OPTIONS) \
-install $(TOP)/$(LIB_DIR) -id $(INSTALL_LIB_DIR)/lib$(GL_LIB).1.dylib \
$(GL_LIB_DEPS) $(OBJECTS) $(GLAPI_LIB)
 
$(GLAPI_LIB):
@$(MAKE) -C $(TOP)/src/mapi/glapi
 
depend: $(SOURCES) $(MESA_GLAPI_SOURCES) $(MESA_GLAPI_ASM_SOURCES) Makefile
rm -f depend
touch depend
$(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(SOURCES) \
$(MESA_GLAPI_SOURCES) $(MESA_GLAPI_ASM_SOURCES)
 
# Emacs tags
tags:
etags `find . -name \*.[ch]` `find $(TOP)/include`
 
install_headers: include/GL/gl.h
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL
$(INSTALL) -m 644 include/GL/gl.h $(DESTDIR)$(INSTALL_DIR)/include/GL
 
install_libraries: $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
$(MAKE) -C $(TOP)/src/mesa install-libgl
 
install: install_libraries
 
# Remove .o and backup files
clean:
-rm -f *.o *.a *~
-rm -f *.c~ *.h~
-rm -f *.dylib
-rm -f include/GL/gl.h
-rm -f $(TOP)/$(LIB_DIR)/$(GL_LIB_GLOB)
-rm -f *.o *~
-rm -f depend depend.bak
 
-include depend
/contrib/sdk/sources/Mesa/src/glx/apple/RELEASE_NOTES
0,0 → 1,71
AppleSGLX Release Notes
 
o OpenGL Support
 
AppleSGLX supports the same version of OpenGL as Leopard (OpenGL 2.1).
Many extensions from the OpenGL framework are now builtin.
 
This adds support for GLSL, and a variety of other features.
 
o Thread Support
 
Thread support has been improved since the libGL in XQuartz 2.3.2.1.
 
o GLX 1.4 Support
 
The GLX 1.3 and 1.4 functions should all work with a few exceptions
as outlined in this document.
 
o glXMakeContextCurrent (a GLX 1.3 feature)
 
glXMakeContextCurrent should work with the readable drawable. The
OpenGL functions: glReadPixels, glCopyPixels, and glCopyColorTable,
should use the readable drawable if it's different than the rendering
drawable.
 
o glXGetProcAddress (a GLX 1.4 feature and ARB extension)
 
glXGetProcAddress should work and allow getting the address of any
extension functions you may need from the X11 libGL, or OpenGL framework
libGL. Previous versions of the X11 libGL didn't allow getting the newer
OpenGL framework addresses.
 
o GLXPixmaps
 
New support for GLXPixmaps works well with mixed X11 and OpenGL drawing
operations. You can create them using glXCreateGLXPixmap or
glXCreatePixmap.
 
o GLXPbuffers
 
Support for GLXPbuffers has been added. These are drawables that are
not possible to render to with X11, which is allowed by the spec.
A GLXPbuffer will never generate a clobber event, however
glXSelectEvent and glXGetSelectedEvent should operate normally.
 
Clobber events are not generated due to low-level architectural
differences. The contents of your pbuffers will not be clobbered.
 
o Shared Contexts
 
Due to basic low-level architectural differences the usage of shared
contexts requires a similar visual or GLXFBConfig be used in the
creation of a shared context. It's best if you specify the same
visual. This is due to a CGL design difference, and not something
that is easily worked around. UPDATE: some changes made seem to
help resolve this issue in many cases, so you may be able to use a
shared context without this restriction.
 
 
o Indirect
 
The X server supports indirect fairly well, so OpenGL applications
can be run remotely and displayed by XQuartz. This means you can run
applications from a remote host on an XQuartz X server.
 
AppleSGLX does not support indirect rendering. Any indirect context
created will appear to glXIsDirect as an indirect context, but it
does not actually support indirect rendering to a remote X server.
 
AppleSGLX supports GLXPixmaps and GLXPbuffers with direct and indirect
contexts, though they are all direct contexts by definition (see above).
/contrib/sdk/sources/Mesa/src/glx/apple/TODO
0,0 → 1,26
Test shared contexts!
 
Go over every glxcmd in glxcmds.c and make sure we have them working.
Verify the XError behavior of GLXPixmap support functions.
 
Test GLXPixmap support with various pixmap depths.
Test GLXPixmap support with invalid pixmaps (to stress the protocol code).
 
-- Feb 10, 2009
 
Test glXCopyContext.
 
-- Dec 12 2008
TEST glXCopyContext needs some work and additional code in apple_glx.c.
 
----
 
Make sure we report the proper list of GLX extensions available. Apple direct may not support some
that Mesa does, and vice-versa.
 
Modify create_destroy_context and create a new test called create_destroy_context_thread_race.
Where 2 threads are doing the same sort of path of create and destroy. The locking should protect
us there, but we need to verify nothing goes wrong.
 
/contrib/sdk/sources/Mesa/src/glx/apple/apple_cgl.c
0,0 → 1,127
/*
Copyright (c) 2008 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
 
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
 
#include "apple_cgl.h"
#include "apple_glx.h"
 
#ifndef OPENGL_FRAMEWORK_PATH
#define OPENGL_FRAMEWORK_PATH "/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL"
#endif
 
static void *dl_handle = NULL;
 
struct apple_cgl_api apple_cgl;
 
static bool initialized = false;
 
static void *
sym(void *h, const char *name)
{
void *s;
 
s = dlsym(h, name);
 
if (NULL == s) {
fprintf(stderr, "error: %s\n", dlerror());
abort();
}
 
return s;
}
 
void
apple_cgl_init(void)
{
void *h;
const char *opengl_framework_path;
 
if (initialized)
return;
 
opengl_framework_path = getenv("OPENGL_FRAMEWORK_PATH");
if (!opengl_framework_path) {
opengl_framework_path = OPENGL_FRAMEWORK_PATH;
}
 
(void) dlerror(); /*drain dlerror */
h = dlopen(opengl_framework_path, RTLD_NOW);
 
if (NULL == h) {
fprintf(stderr, "error: unable to dlopen %s : %s\n",
opengl_framework_path, dlerror());
abort();
}
 
dl_handle = h;
 
apple_cgl.get_version = sym(h, "CGLGetVersion");
 
apple_cgl.get_version(&apple_cgl.version_major, &apple_cgl.version_minor);
 
apple_glx_diagnostic("CGL major %d minor %d\n", apple_cgl.version_major, apple_cgl.version_minor);
 
if (1 != apple_cgl.version_major) {
fprintf(stderr, "WARNING: the CGL major version has changed!\n"
"libGL may be incompatible!\n");
}
 
apple_cgl.choose_pixel_format = sym(h, "CGLChoosePixelFormat");
apple_cgl.destroy_pixel_format = sym(h, "CGLDestroyPixelFormat");
 
apple_cgl.clear_drawable = sym(h, "CGLClearDrawable");
apple_cgl.flush_drawable = sym(h, "CGLFlushDrawable");
 
apple_cgl.create_context = sym(h, "CGLCreateContext");
apple_cgl.destroy_context = sym(h, "CGLDestroyContext");
 
apple_cgl.set_current_context = sym(h, "CGLSetCurrentContext");
apple_cgl.get_current_context = sym(h, "CGLGetCurrentContext");
apple_cgl.error_string = sym(h, "CGLErrorString");
 
apple_cgl.set_off_screen = sym(h, "CGLSetOffScreen");
 
apple_cgl.copy_context = sym(h, "CGLCopyContext");
 
apple_cgl.create_pbuffer = sym(h, "CGLCreatePBuffer");
apple_cgl.destroy_pbuffer = sym(h, "CGLDestroyPBuffer");
apple_cgl.set_pbuffer = sym(h, "CGLSetPBuffer");
 
initialized = true;
}
 
void *
apple_cgl_get_dl_handle(void)
{
return dl_handle;
}
/contrib/sdk/sources/Mesa/src/glx/apple/apple_cgl.h
0,0 → 1,87
/*
Copyright (c) 2008, 2009 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
 
#ifndef APPLE_CGL_H
#define APPLE_CGL_H
 
#include <stdio.h>
#include <OpenGL/CGLCurrent.h>
#include <OpenGL/CGLTypes.h>
#include <OpenGL/OpenGL.h>
 
/* For GLint and GLsizei on Tiger */
#include <OpenGL/gl.h>
 
struct apple_cgl_api
{
GLint version_major, version_minor;
void (*get_version) (GLint * version_major, GLint * version_minor);
 
CGLError(*choose_pixel_format) (const CGLPixelFormatAttribute * attribs,
CGLPixelFormatObj * pix, GLint * npix);
CGLError(*destroy_pixel_format) (CGLPixelFormatObj pix);
 
CGLError(*clear_drawable) (CGLContextObj ctx);
CGLError(*flush_drawable) (CGLContextObj ctx);
 
CGLError(*create_context) (CGLPixelFormatObj pix, CGLContextObj share,
CGLContextObj * ctx);
CGLError(*destroy_context) (CGLContextObj pix);
 
CGLError(*set_current_context) (CGLContextObj ctx);
CGLContextObj(*get_current_context) (void);
const char *(*error_string) (CGLError error);
 
CGLError(*set_off_screen) (CGLContextObj ctx,
GLsizei width, GLsizei height, GLint rowbytes,
void *baseaddr);
 
CGLError(*copy_context) (CGLContextObj src, CGLContextObj dst,
GLbitfield mask);
 
CGLError(*create_pbuffer) (GLsizei width,
GLsizei height,
GLenum target,
GLenum internalFormat,
GLint max_level, CGLPBufferObj * pbuffer);
 
CGLError(*destroy_pbuffer) (CGLPBufferObj pbuffer);
 
CGLError(*set_pbuffer) (CGLContextObj ctx,
CGLPBufferObj pbuffer,
GLenum face, GLint level, GLint screen);
};
 
extern struct apple_cgl_api apple_cgl;
 
extern void apple_cgl_init(void);
 
extern void *apple_cgl_get_dl_handle(void);
 
#endif
/contrib/sdk/sources/Mesa/src/glx/apple/apple_glapi.c
0,0 → 1,80
/*
* GLX implementation that uses Apple's OpenGL.framework
*
* Copyright (c) 2007-2011 Apple Inc.
* Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
* Copyright (c) 2002 Greg Parker. All Rights Reserved.
*
* Portions of this file are copied from Mesa's xf86glx.c,
* which contains the following copyright:
*
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE ABOVE LISTED COPYRIGHT HOLDER(S) 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 <assert.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
 
#include <GL/gl.h>
 
#include "glapi.h"
#include "glapitable.h"
#include "main/dispatch.h"
 
#include "apple_glx.h"
#include "apple_xgl_api.h"
#include "apple_cgl.h"
 
struct _glapi_table * __ogl_framework_api = NULL;
struct _glapi_table * __applegl_api = NULL;
 
static void _apple_glapi_create_table(void) {
if (__applegl_api)
return;
 
__ogl_framework_api = _glapi_create_table_from_handle(apple_cgl_get_dl_handle(), "gl");
assert(__ogl_framework_api);
 
__applegl_api = malloc(sizeof(struct _glapi_table));
assert(__applegl_api);
memcpy(__applegl_api, __ogl_framework_api, sizeof(struct _glapi_table));
 
SET_ReadPixels(__applegl_api, __applegl_glReadPixels);
SET_CopyPixels(__applegl_api, __applegl_glCopyPixels);
SET_CopyColorTable(__applegl_api, __applegl_glCopyColorTable);
SET_DrawBuffer(__applegl_api, __applegl_glDrawBuffer);
SET_DrawBuffers(__applegl_api, __applegl_glDrawBuffers);
SET_Viewport(__applegl_api, __applegl_glViewport);
}
 
void apple_glapi_set_dispatch(void) {
_apple_glapi_create_table();
_glapi_set_dispatch(__applegl_api);
}
 
void apple_glapi_oglfw_viewport_scissor(GLint x, GLint y, GLsizei width, GLsizei height) {
_apple_glapi_create_table();
__ogl_framework_api->Viewport(x, y, width, height);
__ogl_framework_api->Scissor(x, y, width, height);
}
/contrib/sdk/sources/Mesa/src/glx/apple/apple_glx.c
0,0 → 1,148
/*
Copyright (c) 2008, 2009 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdarg.h>
#include <dlfcn.h>
#include <pthread.h>
#include <inttypes.h>
#include "appledri.h"
#include "apple_glx.h"
#include "apple_glx_context.h"
#include "apple_cgl.h"
 
static bool initialized = false;
static int dri_event_base = 0;
 
const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 };
 
int
apple_get_dri_event_base(void)
{
if (!initialized) {
fprintf(stderr,
"error: dri_event_base called before apple_init_glx!\n");
abort();
}
return dri_event_base;
}
 
static void
surface_notify_handler(Display * dpy, unsigned int uid, int kind)
{
 
switch (kind) {
case AppleDRISurfaceNotifyDestroyed:
apple_glx_diagnostic("%s: surface destroyed %u\n", __func__, uid);
apple_glx_surface_destroy(uid);
break;
 
case AppleDRISurfaceNotifyChanged:{
int updated;
 
updated = apple_glx_context_surface_changed(uid, pthread_self());
 
apple_glx_diagnostic("surface notify updated %d\n", updated);
}
break;
 
default:
fprintf(stderr, "unhandled kind of event: %d in %s\n", kind, __func__);
}
}
 
xp_client_id
apple_glx_get_client_id(void)
{
static xp_client_id id;
 
if (0 == id) {
if ((XP_Success != xp_init(XP_IN_BACKGROUND)) ||
(Success != xp_get_client_id(&id))) {
return 0;
}
}
 
return id;
}
 
/* Return true if an error occured. */
bool
apple_init_glx(Display * dpy)
{
int eventBase, errorBase;
int major, minor, patch;
 
if (!XAppleDRIQueryExtension(dpy, &eventBase, &errorBase))
return true;
 
if (!XAppleDRIQueryVersion(dpy, &major, &minor, &patch))
return true;
 
if (initialized)
return false;
 
apple_glx_log_init();
 
apple_glx_log(ASL_LEVEL_INFO, "Initializing libGL.");
 
apple_cgl_init();
(void) apple_glx_get_client_id();
 
XAppleDRISetSurfaceNotifyHandler(surface_notify_handler);
 
/* This should really be per display. */
dri_event_base = eventBase;
initialized = true;
 
return false;
}
 
void
apple_glx_swap_buffers(void *ptr)
{
struct apple_glx_context *ac = ptr;
 
apple_cgl.flush_drawable(ac->context_obj);
}
 
void
apple_glx_waitx(Display * dpy, void *ptr)
{
struct apple_private_context *ac = ptr;
 
(void) ac;
 
glFlush();
glFinish();
XSync(dpy, False);
}
/contrib/sdk/sources/Mesa/src/glx/apple/apple_glx.h
0,0 → 1,52
/*
Copyright (c) 2008 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
 
#ifndef APPLE_GLX_H
#define APPLE_GLX_H
 
#include <stdbool.h>
#include <GL/gl.h>
#include <GL/glxint.h>
#include <X11/Xlib.h>
 
#define XP_NO_X_HEADERS
#include <Xplugin.h>
 
#include "apple_glx_log.h"
 
xp_client_id apple_glx_get_client_id(void);
bool apple_init_glx(Display * dpy);
void apple_glx_swap_buffers(void *ptr);
void apple_glx_waitx(Display * dpy, void *ptr);
int apple_get_dri_event_base(void);
 
void apple_glapi_set_dispatch(void);
void apple_glapi_oglfw_viewport_scissor(GLint x, GLint y, GLsizei width, GLsizei height);
 
#endif
/contrib/sdk/sources/Mesa/src/glx/apple/apple_glx_context.c
0,0 → 1,616
/*
Copyright (c) 2008, 2009 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
 
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <assert.h>
#include <pthread.h>
 
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
 
// Get the newer glext.h first
#include <GL/gl.h>
#include <GL/glext.h>
 
#include <OpenGL/CGLTypes.h>
#include <OpenGL/CGLCurrent.h>
#include <OpenGL/OpenGL.h>
 
#include "glxclient.h"
 
#include "apple_glx.h"
#include "apple_glx_context.h"
#include "appledri.h"
#include "apple_visual.h"
#include "apple_cgl.h"
#include "apple_glx_drawable.h"
 
static pthread_mutex_t context_lock = PTHREAD_MUTEX_INITIALIZER;
 
/*
* This should be locked on creation and destruction of the
* apple_glx_contexts.
*
* It's also locked when the surface_notify_handler is searching
* for a uid associated with a surface.
*/
static struct apple_glx_context *context_list = NULL;
 
/* This guards the context_list above. */
static void
lock_context_list(void)
{
int err;
 
err = pthread_mutex_lock(&context_lock);
 
if (err) {
fprintf(stderr, "pthread_mutex_lock failure in %s: %d\n",
__func__, err);
abort();
}
}
 
static void
unlock_context_list(void)
{
int err;
 
err = pthread_mutex_unlock(&context_lock);
 
if (err) {
fprintf(stderr, "pthread_mutex_unlock failure in %s: %d\n",
__func__, err);
abort();
}
}
 
static bool
is_context_valid(struct apple_glx_context *ac)
{
struct apple_glx_context *i;
 
lock_context_list();
 
for (i = context_list; i; i = i->next) {
if (ac == i) {
unlock_context_list();
return true;
}
}
 
unlock_context_list();
 
return false;
}
 
/* This creates an apple_private_context struct.
*
* It's typically called to save the struct in a GLXContext.
*
* This is also where the CGLContextObj is created, and the CGLPixelFormatObj.
*/
bool
apple_glx_create_context(void **ptr, Display * dpy, int screen,
const void *mode, void *sharedContext,
int *errorptr, bool * x11errorptr)
{
struct apple_glx_context *ac;
struct apple_glx_context *sharedac = sharedContext;
CGLError error;
 
*ptr = NULL;
 
ac = malloc(sizeof *ac);
 
if (NULL == ac) {
*errorptr = BadAlloc;
*x11errorptr = true;
return true;
}
 
if (sharedac && !is_context_valid(sharedac)) {
*errorptr = GLXBadContext;
*x11errorptr = false;
return true;
}
 
ac->context_obj = NULL;
ac->pixel_format_obj = NULL;
ac->drawable = NULL;
ac->thread_id = pthread_self();
ac->screen = screen;
ac->double_buffered = false;
ac->uses_stereo = false;
ac->need_update = false;
ac->is_current = false;
ac->made_current = false;
ac->last_surface_window = None;
 
apple_visual_create_pfobj(&ac->pixel_format_obj, mode,
&ac->double_buffered, &ac->uses_stereo,
/*offscreen */ false);
 
error = apple_cgl.create_context(ac->pixel_format_obj,
sharedac ? sharedac->context_obj : NULL,
&ac->context_obj);
 
 
if (error) {
(void) apple_cgl.destroy_pixel_format(ac->pixel_format_obj);
 
free(ac);
 
if (kCGLBadMatch == error) {
*errorptr = BadMatch;
*x11errorptr = true;
}
else {
*errorptr = GLXBadContext;
*x11errorptr = false;
}
 
if (getenv("LIBGL_DIAGNOSTIC"))
fprintf(stderr, "error: %s\n", apple_cgl.error_string(error));
 
return true;
}
 
/* The context creation succeeded, so we can link in the new context. */
lock_context_list();
 
if (context_list)
context_list->previous = ac;
 
ac->previous = NULL;
ac->next = context_list;
context_list = ac;
 
*ptr = ac;
 
apple_glx_diagnostic("%s: ac %p ac->context_obj %p\n",
__func__, (void *) ac, (void *) ac->context_obj);
 
unlock_context_list();
 
return false;
}
 
void
apple_glx_destroy_context(void **ptr, Display * dpy)
{
struct apple_glx_context *ac = *ptr;
 
if (NULL == ac)
return;
 
apple_glx_diagnostic("%s: ac %p ac->context_obj %p\n",
__func__, (void *) ac, (void *) ac->context_obj);
 
if (apple_cgl.get_current_context() == ac->context_obj) {
apple_glx_diagnostic("%s: context ac->context_obj %p "
"is still current!\n", __func__,
(void *) ac->context_obj);
if (apple_cgl.set_current_context(NULL)) {
abort();
}
}
 
/* Remove ac from the context_list as soon as possible. */
lock_context_list();
 
if (ac->previous) {
ac->previous->next = ac->next;
}
else {
context_list = ac->next;
}
 
if (ac->next) {
ac->next->previous = ac->previous;
}
 
unlock_context_list();
 
 
if (apple_cgl.clear_drawable(ac->context_obj)) {
fprintf(stderr, "error: while clearing drawable!\n");
abort();
}
 
/*
* This potentially causes surface_notify_handler to be called in
* apple_glx.c...
* We can NOT have a lock held at this point. It would result in
* an abort due to an attempted deadlock. This is why we earlier
* removed the ac pointer from the double-linked list.
*/
if (ac->drawable) {
ac->drawable->destroy(ac->drawable);
}
 
if (apple_cgl.destroy_pixel_format(ac->pixel_format_obj)) {
fprintf(stderr, "error: destroying pixel format in %s\n", __func__);
abort();
}
 
if (apple_cgl.destroy_context(ac->context_obj)) {
fprintf(stderr, "error: destroying context_obj in %s\n", __func__);
abort();
}
 
free(ac);
 
*ptr = NULL;
 
apple_glx_garbage_collect_drawables(dpy);
}
 
 
/* Return true if an error occured. */
bool
apple_glx_make_current_context(Display * dpy, void *oldptr, void *ptr,
GLXDrawable drawable)
{
struct apple_glx_context *oldac = oldptr;
struct apple_glx_context *ac = ptr;
struct apple_glx_drawable *newagd = NULL;
CGLError cglerr;
bool same_drawable = false;
 
#if 0
apple_glx_diagnostic("%s: oldac %p ac %p drawable 0x%lx\n",
__func__, (void *) oldac, (void *) ac, drawable);
 
apple_glx_diagnostic("%s: oldac->context_obj %p ac->context_obj %p\n",
__func__,
(void *) (oldac ? oldac->context_obj : NULL),
(void *) (ac ? ac->context_obj : NULL));
#endif
 
/* This a common path for GLUT and other apps, so special case it. */
if (ac && ac->drawable && ac->drawable->drawable == drawable) {
same_drawable = true;
 
if (ac->is_current)
return false;
}
 
/* Reset the is_current state of the old context, if non-NULL. */
if (oldac && (ac != oldac))
oldac->is_current = false;
 
if (NULL == ac) {
/*Clear the current context for this thread. */
apple_cgl.set_current_context(NULL);
 
if (oldac) {
oldac->is_current = false;
 
if (oldac->drawable) {
oldac->drawable->destroy(oldac->drawable);
oldac->drawable = NULL;
}
 
/* Invalidate this to prevent surface recreation. */
oldac->last_surface_window = None;
}
 
return false;
}
 
if (None == drawable) {
bool error = false;
 
/* Clear the current drawable for this context_obj. */
 
if (apple_cgl.set_current_context(ac->context_obj))
error = true;
 
if (apple_cgl.clear_drawable(ac->context_obj))
error = true;
 
if (ac->drawable) {
ac->drawable->destroy(ac->drawable);
ac->drawable = NULL;
}
 
/* Invalidate this to prevent surface recreation. */
ac->last_surface_window = None;
 
apple_glx_diagnostic("%s: drawable is None, error is: %d\n",
__func__, error);
 
return error;
}
 
/* This is an optimisation to avoid searching for the current drawable. */
if (ac->drawable && ac->drawable->drawable == drawable) {
newagd = ac->drawable;
}
else {
/* Find the drawable if possible, and retain a reference to it. */
newagd =
apple_glx_drawable_find(drawable, APPLE_GLX_DRAWABLE_REFERENCE);
}
 
/*
* Try to destroy the old drawable, so long as the new one
* isn't the old.
*/
if (ac->drawable && !same_drawable) {
ac->drawable->destroy(ac->drawable);
ac->drawable = NULL;
}
 
if (NULL == newagd) {
if (apple_glx_surface_create(dpy, ac->screen, drawable, &newagd))
return true;
 
/* The drawable is referenced once by apple_glx_surface_create. */
 
/*
* FIXME: We actually need 2 references to prevent premature surface
* destruction. The problem is that the surface gets destroyed in
* the case of the context being reused for another window, and
* we then lose the surface contents. Wait for destruction of a
* window to destroy a surface.
*
* Note: this may leave around surfaces we don't want around, if
* say we are using X for raster drawing after OpenGL rendering,
* but it will be compatible with the old libGL's behavior.
*
* Someday the X11 and OpenGL rendering must be unified at some
* layer. I suspect we can do that via shared memory and
* multiple threads in the X server (1 for each context created
* by a client). This would also allow users to render from
* multiple clients to the same OpenGL surface. In fact it could
* all be OpenGL.
*
*/
newagd->reference(newagd);
 
/* Save the new drawable with the context structure. */
ac->drawable = newagd;
}
else {
/* We are reusing an existing drawable structure. */
 
if (same_drawable) {
assert(ac->drawable == newagd);
/* The drawable_find above retained a reference for us. */
}
else {
ac->drawable = newagd;
}
}
 
/*
* Avoid this costly path if this is the same drawable and the
* context is already current.
*/
 
if (same_drawable && ac->is_current) {
apple_glx_diagnostic("same_drawable and ac->is_current\n");
return false;
}
 
cglerr = apple_cgl.set_current_context(ac->context_obj);
 
if (kCGLNoError != cglerr) {
fprintf(stderr, "set current error: %s\n",
apple_cgl.error_string(cglerr));
return true;
}
 
ac->is_current = true;
 
assert(NULL != ac->context_obj);
assert(NULL != ac->drawable);
 
ac->thread_id = pthread_self();
 
/* This will be set if the pending_destroy code indicates it should be: */
ac->last_surface_window = None;
 
switch (ac->drawable->type) {
case APPLE_GLX_DRAWABLE_PBUFFER:
case APPLE_GLX_DRAWABLE_SURFACE:
case APPLE_GLX_DRAWABLE_PIXMAP:
if (ac->drawable->callbacks.make_current) {
if (ac->drawable->callbacks.make_current(ac, ac->drawable))
return true;
}
break;
 
default:
fprintf(stderr, "internal error: invalid drawable type: %d\n",
ac->drawable->type);
abort();
}
 
return false;
}
 
bool
apple_glx_is_current_drawable(Display * dpy, void *ptr, GLXDrawable drawable)
{
struct apple_glx_context *ac = ptr;
 
if (ac->drawable && ac->drawable->drawable == drawable) {
return true;
}
else if (NULL == ac->drawable && None != ac->last_surface_window) {
apple_glx_context_update(dpy, ac);
 
return (ac->drawable && ac->drawable->drawable == drawable);
}
 
return false;
}
 
bool
apple_glx_copy_context(void *currentptr, void *srcptr, void *destptr,
unsigned long mask, int *errorptr, bool * x11errorptr)
{
struct apple_glx_context *src, *dest;
CGLError err;
 
src = srcptr;
dest = destptr;
 
if (src->screen != dest->screen) {
*errorptr = BadMatch;
*x11errorptr = true;
return true;
}
 
if (dest == currentptr || dest->is_current) {
*errorptr = BadAccess;
*x11errorptr = true;
return true;
}
 
/*
* If srcptr is the current context then we should do an implicit glFlush.
*/
if (currentptr == srcptr)
glFlush();
 
err = apple_cgl.copy_context(src->context_obj, dest->context_obj,
(GLbitfield) mask);
 
if (kCGLNoError != err) {
*errorptr = GLXBadContext;
*x11errorptr = false;
return true;
}
 
return false;
}
 
/*
* The value returned is the total number of contexts set to update.
* It's meant for debugging/introspection.
*/
int
apple_glx_context_surface_changed(unsigned int uid, pthread_t caller)
{
struct apple_glx_context *ac;
int updated = 0;
 
lock_context_list();
 
for (ac = context_list; ac; ac = ac->next) {
if (ac->drawable && APPLE_GLX_DRAWABLE_SURFACE == ac->drawable->type
&& ac->drawable->types.surface.uid == uid) {
 
if (caller == ac->thread_id) {
apple_glx_diagnostic("caller is the same thread for uid %u\n",
uid);
 
xp_update_gl_context(ac->context_obj);
}
else {
ac->need_update = true;
++updated;
}
}
}
 
unlock_context_list();
 
return updated;
}
 
void
apple_glx_context_update(Display * dpy, void *ptr)
{
struct apple_glx_context *ac = ptr;
 
if (NULL == ac->drawable && None != ac->last_surface_window) {
bool failed;
 
/* Attempt to recreate the surface for a destroyed drawable. */
failed =
apple_glx_make_current_context(dpy, ac, ac, ac->last_surface_window);
 
apple_glx_diagnostic("%s: surface recreation failed? %s\n", __func__,
failed ? "YES" : "NO");
}
 
if (ac->need_update) {
xp_update_gl_context(ac->context_obj);
ac->need_update = false;
 
apple_glx_diagnostic("%s: updating context %p\n", __func__, ptr);
}
 
if (ac->drawable && APPLE_GLX_DRAWABLE_SURFACE == ac->drawable->type
&& ac->drawable->types.surface.pending_destroy) {
apple_glx_diagnostic("%s: clearing drawable %p\n", __func__, ptr);
apple_cgl.clear_drawable(ac->context_obj);
 
if (ac->drawable) {
struct apple_glx_drawable *d;
 
apple_glx_diagnostic("%s: attempting to destroy drawable %p\n",
__func__, ptr);
apple_glx_diagnostic("%s: ac->drawable->drawable is 0x%lx\n",
__func__, ac->drawable->drawable);
 
d = ac->drawable;
 
ac->last_surface_window = d->drawable;
 
ac->drawable = NULL;
 
/*
* This will destroy the surface drawable if there are
* no references to it.
* It also subtracts 1 from the reference_count.
* If there are references to it, then it's probably made
* current in another context.
*/
d->destroy(d);
}
}
}
 
bool
apple_glx_context_uses_stereo(void *ptr)
{
struct apple_glx_context *ac = ptr;
 
return ac->uses_stereo;
}
/contrib/sdk/sources/Mesa/src/glx/apple/apple_glx_context.h
0,0 → 1,93
/*
Copyright (c) 2008, 2009 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#ifndef APPLE_GLX_CONTEXT_H
#define APPLE_GLX_CONTEXT_H
 
/* <rdar://problem/6953344> */
#define glTexImage1D glTexImage1D_OSX
#define glTexImage2D glTexImage2D_OSX
#define glTexImage3D glTexImage3D_OSX
#include <OpenGL/CGLTypes.h>
#include <OpenGL/CGLContext.h>
#undef glTexImage1D
#undef glTexImage2D
#undef glTexImage3D
 
#include <stdbool.h>
#include <X11/Xlib.h>
#include <GL/glx.h>
#define XP_NO_X_HEADERS
#include <Xplugin.h>
#undef XP_NO_X_HEADERS
 
#include "apple_glx_drawable.h"
 
struct apple_glx_context
{
CGLContextObj context_obj;
CGLPixelFormatObj pixel_format_obj;
struct apple_glx_drawable *drawable;
pthread_t thread_id;
int screen;
bool double_buffered;
bool uses_stereo;
bool need_update;
bool is_current; /* True if the context is current in some thread. */
bool made_current; /* True if the context has ever been made current. */
 
/*
* last_surface is set by the pending_destroy code handler for a drawable.
* Due to a CG difference, we have to recreate a surface if the window
* is unmapped and mapped again.
*/
Window last_surface_window;
struct apple_glx_context *previous, *next;
};
 
bool apple_glx_create_context(void **ptr, Display * dpy, int screen,
const void *mode, void *sharedContext,
int *errorptr, bool * x11errorptr);
void apple_glx_destroy_context(void **ptr, Display * dpy);
 
bool apple_glx_make_current_context(Display * dpy, void *oldptr, void *ptr,
GLXDrawable drawable);
bool apple_glx_is_current_drawable(Display * dpy, void *ptr,
GLXDrawable drawable);
 
bool apple_glx_copy_context(void *currentptr, void *srcptr, void *destptr,
unsigned long mask, int *errorptr,
bool * x11errorptr);
 
int apple_glx_context_surface_changed(unsigned int uid, pthread_t caller);
 
void apple_glx_context_update(Display * dpy, void *ptr);
 
bool apple_glx_context_uses_stereo(void *ptr);
 
#endif /*APPLE_GLX_CONTEXT_H */
/contrib/sdk/sources/Mesa/src/glx/apple/apple_glx_drawable.c
0,0 → 1,553
/*
Copyright (c) 2008, 2009 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
 
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <pthread.h>
#include <string.h>
#include "apple_glx.h"
#include "apple_glx_context.h"
#include "apple_glx_drawable.h"
#include "appledri.h"
 
static pthread_mutex_t drawables_lock = PTHREAD_MUTEX_INITIALIZER;
static struct apple_glx_drawable *drawables_list = NULL;
 
static void
lock_drawables_list(void)
{
int err;
 
err = pthread_mutex_lock(&drawables_lock);
 
if (err) {
fprintf(stderr, "pthread_mutex_lock failure in %s: %s\n",
__func__, strerror(err));
abort();
}
}
 
static void
unlock_drawables_list(void)
{
int err;
 
err = pthread_mutex_unlock(&drawables_lock);
 
if (err) {
fprintf(stderr, "pthread_mutex_unlock failure in %s: %s\n",
__func__, strerror(err));
abort();
}
}
 
struct apple_glx_drawable *
apple_glx_find_drawable(Display * dpy, GLXDrawable drawable)
{
struct apple_glx_drawable *i, *agd = NULL;
 
lock_drawables_list();
 
for (i = drawables_list; i; i = i->next) {
if (i->drawable == drawable) {
agd = i;
break;
}
}
 
unlock_drawables_list();
 
return agd;
}
 
static void
drawable_lock(struct apple_glx_drawable *agd)
{
int err;
 
err = pthread_mutex_lock(&agd->mutex);
 
if (err) {
fprintf(stderr, "pthread_mutex_lock error: %s\n", strerror(err));
abort();
}
}
 
static void
drawable_unlock(struct apple_glx_drawable *d)
{
int err;
 
err = pthread_mutex_unlock(&d->mutex);
 
if (err) {
fprintf(stderr, "pthread_mutex_unlock error: %s\n", strerror(err));
abort();
}
}
 
 
static void
reference_drawable(struct apple_glx_drawable *d)
{
d->lock(d);
d->reference_count++;
d->unlock(d);
}
 
static void
release_drawable(struct apple_glx_drawable *d)
{
d->lock(d);
d->reference_count--;
d->unlock(d);
}
 
/* The drawables list must be locked prior to calling this. */
/* Return true if the drawable was destroyed. */
static bool
destroy_drawable(struct apple_glx_drawable *d)
{
int err;
 
d->lock(d);
 
if (d->reference_count > 0) {
d->unlock(d);
return false;
}
 
d->unlock(d);
 
if (d->previous) {
d->previous->next = d->next;
}
else {
/*
* The item must be at the head of the list, if it
* has no previous pointer.
*/
drawables_list = d->next;
}
 
if (d->next)
d->next->previous = d->previous;
 
unlock_drawables_list();
 
if (d->callbacks.destroy) {
/*
* Warning: this causes other routines to be called (potentially)
* from surface_notify_handler. It's probably best to not have
* any locks at this point locked.
*/
d->callbacks.destroy(d->display, d);
}
 
apple_glx_diagnostic("%s: freeing %p\n", __func__, (void *) d);
 
/* Stupid recursive locks */
while (pthread_mutex_unlock(&d->mutex) == 0);
 
err = pthread_mutex_destroy(&d->mutex);
if (err) {
fprintf(stderr, "pthread_mutex_destroy error: %s\n", strerror(err));
abort();
}
free(d);
 
/* So that the locks are balanced and the caller correctly unlocks. */
lock_drawables_list();
 
return true;
}
 
/*
* This is typically called when a context is destroyed or the current
* drawable is made None.
*/
static bool
destroy_drawable_callback(struct apple_glx_drawable *d)
{
bool result;
 
d->lock(d);
 
apple_glx_diagnostic("%s: %p ->reference_count before -- %d\n", __func__,
(void *) d, d->reference_count);
 
d->reference_count--;
 
if (d->reference_count > 0) {
d->unlock(d);
return false;
}
 
d->unlock(d);
 
lock_drawables_list();
 
result = destroy_drawable(d);
 
unlock_drawables_list();
 
return result;
}
 
static bool
is_pbuffer(struct apple_glx_drawable *d)
{
return APPLE_GLX_DRAWABLE_PBUFFER == d->type;
}
 
static bool
is_pixmap(struct apple_glx_drawable *d)
{
return APPLE_GLX_DRAWABLE_PIXMAP == d->type;
}
 
static void
common_init(Display * dpy, GLXDrawable drawable, struct apple_glx_drawable *d)
{
int err;
pthread_mutexattr_t attr;
 
d->display = dpy;
d->reference_count = 0;
d->drawable = drawable;
d->type = -1;
 
err = pthread_mutexattr_init(&attr);
 
if (err) {
fprintf(stderr, "pthread_mutexattr_init error: %s\n", strerror(err));
abort();
}
 
/*
* There are some patterns that require a recursive mutex,
* when working with locks that protect the apple_glx_drawable,
* and reference functions like ->reference, and ->release.
*/
err = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
 
if (err) {
fprintf(stderr, "error: setting pthread mutex type: %s\n", strerror(err));
abort();
}
 
err = pthread_mutex_init(&d->mutex, &attr);
 
if (err) {
fprintf(stderr, "pthread_mutex_init error: %s\n", strerror(err));
abort();
}
 
(void) pthread_mutexattr_destroy(&attr);
 
d->lock = drawable_lock;
d->unlock = drawable_unlock;
 
d->reference = reference_drawable;
d->release = release_drawable;
 
d->destroy = destroy_drawable_callback;
 
d->is_pbuffer = is_pbuffer;
d->is_pixmap = is_pixmap;
 
d->width = -1;
d->height = -1;
d->row_bytes = 0;
d->path[0] = '\0';
d->fd = -1;
d->buffer = NULL;
d->buffer_length = 0;
 
d->previous = NULL;
d->next = NULL;
}
 
static void
link_tail(struct apple_glx_drawable *agd)
{
lock_drawables_list();
 
/* Link the new drawable into the global list. */
agd->next = drawables_list;
 
if (drawables_list)
drawables_list->previous = agd;
 
drawables_list = agd;
 
unlock_drawables_list();
}
 
/*WARNING: this returns a locked and referenced object. */
bool
apple_glx_drawable_create(Display * dpy,
int screen,
GLXDrawable drawable,
struct apple_glx_drawable **agdResult,
struct apple_glx_drawable_callbacks *callbacks)
{
struct apple_glx_drawable *d;
 
d = calloc(1, sizeof *d);
 
if (NULL == d) {
perror("malloc");
return true;
}
 
common_init(dpy, drawable, d);
d->type = callbacks->type;
d->callbacks = *callbacks;
 
d->reference(d);
d->lock(d);
 
link_tail(d);
 
apple_glx_diagnostic("%s: new drawable %p\n", __func__, (void *) d);
 
*agdResult = d;
 
return false;
}
 
static int error_count = 0;
 
static int
error_handler(Display * dpy, XErrorEvent * err)
{
if (err->error_code == BadWindow) {
++error_count;
}
 
return 0;
}
 
void
apple_glx_garbage_collect_drawables(Display * dpy)
{
struct apple_glx_drawable *d, *dnext;
Window root;
int x, y;
unsigned int width, height, bd, depth;
int (*old_handler) (Display *, XErrorEvent *);
 
 
if (NULL == drawables_list)
return;
 
old_handler = XSetErrorHandler(error_handler);
 
XSync(dpy, False);
 
lock_drawables_list();
 
for (d = drawables_list; d;) {
dnext = d->next;
 
d->lock(d);
 
if (d->reference_count > 0) {
/*
* Skip this, because some context still retains a reference
* to the drawable.
*/
d->unlock(d);
d = dnext;
continue;
}
 
d->unlock(d);
 
error_count = 0;
 
/*
* Mesa uses XGetWindowAttributes, but some of these things are
* most definitely not Windows, and that's against the rules.
* XGetGeometry on the other hand is legal with a Pixmap and Window.
*/
XGetGeometry(dpy, d->drawable, &root, &x, &y, &width, &height, &bd,
&depth);
 
if (error_count > 0) {
/*
* Note: this may not actually destroy the drawable.
* If another context retains a reference to the drawable
* after the reference count test above.
*/
(void) destroy_drawable(d);
error_count = 0;
}
 
d = dnext;
}
 
XSetErrorHandler(old_handler);
 
unlock_drawables_list();
}
 
unsigned int
apple_glx_get_drawable_count(void)
{
unsigned int result = 0;
struct apple_glx_drawable *d;
 
lock_drawables_list();
 
for (d = drawables_list; d; d = d->next)
++result;
 
unlock_drawables_list();
 
return result;
}
 
struct apple_glx_drawable *
apple_glx_drawable_find_by_type(GLXDrawable drawable, int type, int flags)
{
struct apple_glx_drawable *d;
 
lock_drawables_list();
 
for (d = drawables_list; d; d = d->next) {
if (d->type == type && d->drawable == drawable) {
if (flags & APPLE_GLX_DRAWABLE_REFERENCE)
d->reference(d);
 
if (flags & APPLE_GLX_DRAWABLE_LOCK)
d->lock(d);
 
unlock_drawables_list();
 
return d;
}
}
 
unlock_drawables_list();
 
return NULL;
}
 
struct apple_glx_drawable *
apple_glx_drawable_find(GLXDrawable drawable, int flags)
{
struct apple_glx_drawable *d;
 
lock_drawables_list();
 
for (d = drawables_list; d; d = d->next) {
if (d->drawable == drawable) {
if (flags & APPLE_GLX_DRAWABLE_REFERENCE)
d->reference(d);
 
if (flags & APPLE_GLX_DRAWABLE_LOCK)
d->lock(d);
 
unlock_drawables_list();
 
return d;
}
}
 
unlock_drawables_list();
 
return NULL;
}
 
/* Return true if the type is valid for the drawable. */
bool
apple_glx_drawable_destroy_by_type(Display * dpy,
GLXDrawable drawable, int type)
{
struct apple_glx_drawable *d;
 
lock_drawables_list();
 
for (d = drawables_list; d; d = d->next) {
if (drawable == d->drawable && type == d->type) {
/*
* The user has requested that we destroy this resource.
* However, there may be references in the contexts to it, so
* release it, and call destroy_drawable which doesn't destroy
* if the reference_count is > 0.
*/
d->release(d);
 
apple_glx_diagnostic("%s d->reference_count %d\n",
__func__, d->reference_count);
 
destroy_drawable(d);
unlock_drawables_list();
return true;
}
}
 
unlock_drawables_list();
 
return false;
}
 
struct apple_glx_drawable *
apple_glx_drawable_find_by_uid(unsigned int uid, int flags)
{
struct apple_glx_drawable *d;
 
lock_drawables_list();
 
for (d = drawables_list; d; d = d->next) {
/* Only surfaces have a uid. */
if (APPLE_GLX_DRAWABLE_SURFACE == d->type) {
if (d->types.surface.uid == uid) {
if (flags & APPLE_GLX_DRAWABLE_REFERENCE)
d->reference(d);
 
if (flags & APPLE_GLX_DRAWABLE_LOCK)
d->lock(d);
 
unlock_drawables_list();
 
return d;
}
}
}
 
unlock_drawables_list();
 
return NULL;
}
/contrib/sdk/sources/Mesa/src/glx/apple/apple_glx_drawable.h
0,0 → 1,227
/*
Copyright (c) 2008, 2009 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#ifndef APPLE_GLX_DRAWABLE_H
#define APPLE_GLX_DRAWABLE_H
 
/* Must be first for:
* <rdar://problem/6953344>
*/
#include "apple_glx_context.h"
 
#include <pthread.h>
#include <stdbool.h>
#include <limits.h>
#include <GL/glx.h>
#define XP_NO_X_HEADERS
#include <Xplugin.h>
#undef XP_NO_X_HEADERS
 
enum
{
APPLE_GLX_DRAWABLE_SURFACE = 1,
APPLE_GLX_DRAWABLE_PBUFFER,
APPLE_GLX_DRAWABLE_PIXMAP
};
 
/* The flag for the find routine. */
enum
{
APPLE_GLX_DRAWABLE_LOCK = 2,
APPLE_GLX_DRAWABLE_REFERENCE = 4
};
 
struct apple_glx_context;
struct apple_glx_drawable;
 
struct apple_glx_surface
{
xp_surface_id surface_id;
unsigned int uid;
bool pending_destroy;
};
 
struct apple_glx_pbuffer
{
GLXPbuffer xid; /* our pixmap */
int width, height;
GLint fbconfigID;
CGLPBufferObj buffer_obj;
unsigned long event_mask;
};
 
struct apple_glx_pixmap
{
GLXPixmap xpixmap;
void *buffer;
int width, height, pitch, /*bytes per pixel */ bpp;
size_t size;
char path[PATH_MAX];
int fd;
CGLPixelFormatObj pixel_format_obj;
CGLContextObj context_obj;
GLint fbconfigID;
};
 
struct apple_glx_drawable_callbacks
{
int type;
bool(*make_current) (struct apple_glx_context * ac,
struct apple_glx_drawable * d);
void (*destroy) (Display * dpy, struct apple_glx_drawable * d);
};
 
struct apple_glx_drawable
{
Display *display;
int reference_count;
GLXDrawable drawable;
int type; /* APPLE_GLX_DRAWABLE_* */
 
union
{
struct apple_glx_pixmap pixmap;
struct apple_glx_pbuffer pbuffer;
struct apple_glx_surface surface;
} types;
 
struct apple_glx_drawable_callbacks callbacks;
 
/*
* This mutex protects the reference count and any other drawable data.
* It's used to prevent an early release of a drawable.
*/
pthread_mutex_t mutex;
void (*lock) (struct apple_glx_drawable * agd);
void (*unlock) (struct apple_glx_drawable * agd);
 
void (*reference) (struct apple_glx_drawable * agd);
void (*release) (struct apple_glx_drawable * agd);
 
bool(*destroy) (struct apple_glx_drawable * agd);
 
bool(*is_pbuffer) (struct apple_glx_drawable * agd);
 
bool(*is_pixmap) (struct apple_glx_drawable * agd);
 
/*BEGIN These are used for the mixed mode drawing... */
int width, height;
int row_bytes;
char path[PATH_MAX];
int fd; /* The file descriptor for this drawable's shared memory. */
void *buffer; /* The memory for the drawable. Typically shared memory. */
size_t buffer_length;
/*END*/ struct apple_glx_drawable *previous, *next;
};
 
struct apple_glx_context;
 
/* May return NULL if not found */
struct apple_glx_drawable *apple_glx_find_drawable(Display * dpy,
GLXDrawable drawable);
 
/* Returns true on error and locks the agd result with a reference. */
bool apple_glx_drawable_create(Display * dpy,
int screen,
GLXDrawable drawable,
struct apple_glx_drawable **agd,
struct apple_glx_drawable_callbacks
*callbacks);
 
/* Returns true on error */
bool apple_glx_create_drawable(Display * dpy,
struct apple_glx_context *ac,
GLXDrawable drawable,
struct apple_glx_drawable **agd);
 
void apple_glx_garbage_collect_drawables(Display * dpy);
 
/*
* This returns the total number of drawables.
* It's mostly intended for debugging and introspection.
*/
unsigned int apple_glx_get_drawable_count(void);
 
struct apple_glx_drawable *apple_glx_drawable_find_by_type(GLXDrawable
drawable, int type,
int flags);
 
struct apple_glx_drawable *apple_glx_drawable_find(GLXDrawable drawable,
int flags);
 
 
bool apple_glx_drawable_destroy_by_type(Display * dpy, GLXDrawable drawable,
int type);
 
struct apple_glx_drawable *apple_glx_drawable_find_by_uid(unsigned int uid,
int flags);
 
/* Surfaces */
 
bool apple_glx_surface_create(Display * dpy, int screen, GLXDrawable drawable,
struct apple_glx_drawable **resultptr);
 
void apple_glx_surface_destroy(unsigned int uid);
 
/* Pbuffers */
 
/* Returns true if an error occurred. */
bool apple_glx_pbuffer_create(Display * dpy, GLXFBConfig config,
int width, int height, int *errorcode,
GLXPbuffer * pbuf);
 
/* Returns true if the pbuffer was invalid. */
bool apple_glx_pbuffer_destroy(Display * dpy, GLXPbuffer pbuf);
 
/* Returns true if the pbuffer was valid and the attribute. */
bool apple_glx_pbuffer_query(GLXDrawable d, int attribute,
unsigned int *value);
 
/* Returns true if the GLXDrawable is a valid GLXPbuffer, and the mask is set. */
bool apple_glx_pbuffer_set_event_mask(GLXDrawable d, unsigned long mask);
 
/* Returns true if the GLXDrawable is a valid GLXPbuffer, and the *mask is set. */
bool apple_glx_pbuffer_get_event_mask(GLXDrawable d, unsigned long *mask);
 
 
/* Pixmaps */
 
/* mode is a struct glx_config * */
/* Returns true if an error occurred. */
bool apple_glx_pixmap_create(Display * dpy, int screen, Pixmap pixmap,
const void *mode);
 
/* Returns true if an error occurred. */
bool apple_glx_pixmap_destroy(Display * dpy, Pixmap pixmap);
 
bool apple_glx_pixmap_query(GLXPixmap pixmap, int attribute,
unsigned int *value);
 
 
 
#endif
/contrib/sdk/sources/Mesa/src/glx/apple/apple_glx_log.c
0,0 → 1,128
/*
* Copyright (c) 2012 Apple 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 THE ABOVE LISTED COPYRIGHT
* HOLDER(S) 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(s) of the above
* copyright holders shall not be used in advertising or otherwise to
* promote the sale, use or other dealings in this Software without
* prior written authorization.
*/
 
#include <sys/cdefs.h>
#include <asl.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <inttypes.h>
#include <pthread.h>
#include "apple_glx_log.h"
 
static bool diagnostic = false;
static aslclient aslc;
 
void apple_glx_log_init(void) {
if (getenv("LIBGL_DIAGNOSTIC")) {
diagnostic = true;
}
 
aslc = asl_open(NULL, NULL, 0);
}
 
void _apple_glx_log(int level, const char *file, const char *function,
int line, const char *fmt, ...) {
va_list v;
va_start(v, fmt);
_apple_glx_vlog(level, file, function, line, fmt, v);
va_end(v);
}
 
static const char *
_asl_level_string(int level)
{
if (level == ASL_LEVEL_EMERG) return ASL_STRING_EMERG;
if (level == ASL_LEVEL_ALERT) return ASL_STRING_ALERT;
if (level == ASL_LEVEL_CRIT) return ASL_STRING_CRIT;
if (level == ASL_LEVEL_ERR) return ASL_STRING_ERR;
if (level == ASL_LEVEL_WARNING) return ASL_STRING_WARNING;
if (level == ASL_LEVEL_NOTICE) return ASL_STRING_NOTICE;
if (level == ASL_LEVEL_INFO) return ASL_STRING_INFO;
if (level == ASL_LEVEL_DEBUG) return ASL_STRING_DEBUG;
return "unknown";
}
 
void _apple_glx_vlog(int level, const char *file, const char *function,
int line, const char *fmt, va_list args) {
aslmsg msg;
uint64_t thread = 0;
 
if (pthread_is_threaded_np()) {
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
thread = (uint64_t)(uintptr_t)pthread_self();
#elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060
if (&pthread_threadid_np) {
pthread_threadid_np(NULL, &thread);
} else {
thread = (uint64_t)(uintptr_t)pthread_self();
}
#else
pthread_threadid_np(NULL, &thread);
#endif
}
 
if (diagnostic) {
va_list args2;
va_copy(args2, args);
 
fprintf(stderr, "%-9s %24s:%-4d %s(%"PRIu64"): ",
_asl_level_string(level), file, line, function, thread);
vfprintf(stderr, fmt, args2);
}
 
msg = asl_new(ASL_TYPE_MSG);
if (msg) {
if (file)
asl_set(msg, "File", file);
if (function)
asl_set(msg, "Function", function);
if (line) {
char *_line;
asprintf(&_line, "%d", line);
if (_line) {
asl_set(msg, "Line", _line);
free(_line);
}
}
if (pthread_is_threaded_np()) {
char *_thread;
asprintf(&_thread, "%"PRIu64, thread);
if (_thread) {
asl_set(msg, "Thread", _thread);
free(_thread);
}
}
}
 
asl_vlog(aslc, msg, level, fmt, args);
if (msg)
asl_free(msg);
}
/contrib/sdk/sources/Mesa/src/glx/apple/apple_glx_log.h
0,0 → 1,57
/*
* Copyright (c) 2012 Apple 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 THE ABOVE LISTED COPYRIGHT
* HOLDER(S) 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(s) of the above
* copyright holders shall not be used in advertising or otherwise to
* promote the sale, use or other dealings in this Software without
* prior written authorization.
*/
 
#ifndef APPLE_GLX_LOG_H
#define APPLE_GLX_LOG_H
 
#include <sys/cdefs.h>
#include <asl.h>
 
void apple_glx_log_init(void);
 
__printflike(5, 6)
void _apple_glx_log(int level, const char *file, const char *function,
int line, const char *fmt, ...);
#define apple_glx_log(l, f, args ...) \
_apple_glx_log(l, __FILE__, __FUNCTION__, __LINE__, f, ## args)
 
 
__printflike(5, 0)
void _apple_glx_vlog(int level, const char *file, const char *function,
int line, const char *fmt, va_list v);
#define apple_glx_vlog(l, f, v) \
_apple_glx_vlog(l, __FILE__, __FUNCTION__, __LINE__, f, v)
 
/* This is just here to help the transition.
* TODO: Replace calls to apple_glx_diagnostic
*/
#define apple_glx_diagnostic(f, args ...) \
apple_glx_log(ASL_LEVEL_DEBUG, f, ## args)
 
#endif
/contrib/sdk/sources/Mesa/src/glx/apple/apple_glx_pbuffer.c
0,0 → 1,347
/*
Copyright (c) 2009 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
 
/* Must be before OpenGL.framework is included. Remove once fixed:
* <rdar://problem/7872773>
*/
#include <GL/gl.h>
#include <GL/glext.h>
#define __gltypes_h_ 1
 
/* Must be first for:
* <rdar://problem/6953344>
*/
#include "apple_glx_context.h"
#include "apple_glx_drawable.h"
 
#include <stdlib.h>
#include <pthread.h>
#include <assert.h>
#include "apple_glx.h"
#include "glxconfig.h"
#include "apple_cgl.h"
 
/* mesa defines in glew.h, Apple in glext.h.
* Due to namespace nightmares, just do it here.
*/
#ifndef GL_TEXTURE_RECTANGLE_EXT
#define GL_TEXTURE_RECTANGLE_EXT 0x84F5
#endif
 
static bool pbuffer_make_current(struct apple_glx_context *ac,
struct apple_glx_drawable *d);
 
static void pbuffer_destroy(Display * dpy, struct apple_glx_drawable *d);
 
static struct apple_glx_drawable_callbacks callbacks = {
.type = APPLE_GLX_DRAWABLE_PBUFFER,
.make_current = pbuffer_make_current,
.destroy = pbuffer_destroy
};
 
 
/* Return true if an error occurred. */
bool
pbuffer_make_current(struct apple_glx_context *ac,
struct apple_glx_drawable *d)
{
struct apple_glx_pbuffer *pbuf = &d->types.pbuffer;
CGLError cglerr;
 
assert(APPLE_GLX_DRAWABLE_PBUFFER == d->type);
 
cglerr = apple_cgl.set_pbuffer(ac->context_obj, pbuf->buffer_obj, 0, 0, 0);
 
if (kCGLNoError != cglerr) {
fprintf(stderr, "set_pbuffer: %s\n", apple_cgl.error_string(cglerr));
return true;
}
 
if (!ac->made_current) {
apple_glapi_oglfw_viewport_scissor(0, 0, pbuf->width, pbuf->height);
ac->made_current = true;
}
 
apple_glx_diagnostic("made pbuffer drawable 0x%lx current\n", d->drawable);
 
return false;
}
 
void
pbuffer_destroy(Display * dpy, struct apple_glx_drawable *d)
{
struct apple_glx_pbuffer *pbuf = &d->types.pbuffer;
 
assert(APPLE_GLX_DRAWABLE_PBUFFER == d->type);
 
apple_glx_diagnostic("destroying pbuffer for drawable 0x%lx\n",
d->drawable);
 
apple_cgl.destroy_pbuffer(pbuf->buffer_obj);
XFreePixmap(dpy, pbuf->xid);
}
 
/* Return true if an error occurred. */
bool
apple_glx_pbuffer_destroy(Display * dpy, GLXPbuffer pbuf)
{
return !apple_glx_drawable_destroy_by_type(dpy, pbuf,
APPLE_GLX_DRAWABLE_PBUFFER);
}
 
/* Return true if an error occurred. */
bool
apple_glx_pbuffer_create(Display * dpy, GLXFBConfig config,
int width, int height, int *errorcode,
GLXPbuffer * result)
{
struct apple_glx_drawable *d;
struct apple_glx_pbuffer *pbuf = NULL;
CGLError err;
Window root;
int screen;
Pixmap xid;
struct glx_config *modes = (struct glx_config *) config;
 
root = DefaultRootWindow(dpy);
screen = DefaultScreen(dpy);
 
/*
* This pixmap is only used for a persistent XID.
* The XC-MISC extension cleans up XIDs and reuses them transparently,
* so we need to retain a server-side reference.
*/
xid = XCreatePixmap(dpy, root, (unsigned int) 1,
(unsigned int) 1, DefaultDepth(dpy, screen));
 
if (None == xid) {
*errorcode = BadAlloc;
return true;
}
 
if (apple_glx_drawable_create(dpy, screen, xid, &d, &callbacks)) {
*errorcode = BadAlloc;
return true;
}
 
/* The lock is held in d from create onward. */
pbuf = &d->types.pbuffer;
 
pbuf->xid = xid;
pbuf->width = width;
pbuf->height = height;
 
err = apple_cgl.create_pbuffer(width, height, GL_TEXTURE_RECTANGLE_EXT,
(modes->alphaBits > 0) ? GL_RGBA : GL_RGB,
0, &pbuf->buffer_obj);
 
if (kCGLNoError != err) {
d->unlock(d);
d->destroy(d);
*errorcode = BadMatch;
return true;
}
 
pbuf->fbconfigID = modes->fbconfigID;
 
pbuf->event_mask = 0;
 
*result = pbuf->xid;
 
d->unlock(d);
 
return false;
}
 
 
 
/* Return true if an error occurred. */
static bool
get_max_size(int *widthresult, int *heightresult)
{
CGLContextObj oldcontext;
GLint ar[2];
 
oldcontext = apple_cgl.get_current_context();
 
if (!oldcontext) {
/*
* There is no current context, so we need to make one in order
* to call glGetInteger.
*/
CGLPixelFormatObj pfobj;
CGLError err;
CGLPixelFormatAttribute attr[10];
int c = 0;
GLint vsref = 0;
CGLContextObj newcontext;
 
attr[c++] = kCGLPFAColorSize;
attr[c++] = 32;
attr[c++] = 0;
 
err = apple_cgl.choose_pixel_format(attr, &pfobj, &vsref);
if (kCGLNoError != err) {
if (getenv("LIBGL_DIAGNOSTIC")) {
printf("choose_pixel_format error in %s: %s\n", __func__,
apple_cgl.error_string(err));
}
 
return true;
}
 
 
err = apple_cgl.create_context(pfobj, NULL, &newcontext);
 
if (kCGLNoError != err) {
if (getenv("LIBGL_DIAGNOSTIC")) {
printf("create_context error in %s: %s\n", __func__,
apple_cgl.error_string(err));
}
 
apple_cgl.destroy_pixel_format(pfobj);
 
return true;
}
 
err = apple_cgl.set_current_context(newcontext);
 
if (kCGLNoError != err) {
printf("set_current_context error in %s: %s\n", __func__,
apple_cgl.error_string(err));
return true;
}
 
 
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, ar);
 
apple_cgl.set_current_context(oldcontext);
apple_cgl.destroy_context(newcontext);
apple_cgl.destroy_pixel_format(pfobj);
}
else {
/* We have a valid context. */
 
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, ar);
}
 
*widthresult = ar[0];
*heightresult = ar[1];
 
return false;
}
 
bool
apple_glx_pbuffer_query(GLXPbuffer p, int attr, unsigned int *value)
{
bool result = false;
struct apple_glx_drawable *d;
struct apple_glx_pbuffer *pbuf;
 
d = apple_glx_drawable_find_by_type(p, APPLE_GLX_DRAWABLE_PBUFFER,
APPLE_GLX_DRAWABLE_LOCK);
 
if (d) {
pbuf = &d->types.pbuffer;
 
switch (attr) {
case GLX_WIDTH:
*value = pbuf->width;
result = true;
break;
 
case GLX_HEIGHT:
*value = pbuf->height;
result = true;
break;
 
case GLX_PRESERVED_CONTENTS:
*value = true;
result = true;
break;
 
case GLX_LARGEST_PBUFFER:{
int width, height;
if (get_max_size(&width, &height)) {
fprintf(stderr, "internal error: "
"unable to find the largest pbuffer!\n");
}
else {
*value = width;
result = true;
}
}
break;
 
case GLX_FBCONFIG_ID:
*value = pbuf->fbconfigID;
result = true;
break;
}
 
d->unlock(d);
}
 
return result;
}
 
bool
apple_glx_pbuffer_set_event_mask(GLXDrawable drawable, unsigned long mask)
{
struct apple_glx_drawable *d;
bool result = false;
 
d = apple_glx_drawable_find_by_type(drawable, APPLE_GLX_DRAWABLE_PBUFFER,
APPLE_GLX_DRAWABLE_LOCK);
 
if (d) {
d->types.pbuffer.event_mask = mask;
result = true;
d->unlock(d);
}
 
return result;
}
 
bool
apple_glx_pbuffer_get_event_mask(GLXDrawable drawable, unsigned long *mask)
{
struct apple_glx_drawable *d;
bool result = false;
 
d = apple_glx_drawable_find_by_type(drawable, APPLE_GLX_DRAWABLE_PBUFFER,
APPLE_GLX_DRAWABLE_LOCK);
if (d) {
*mask = d->types.pbuffer.event_mask;
result = true;
d->unlock(d);
}
 
return result;
}
/contrib/sdk/sources/Mesa/src/glx/apple/apple_glx_pixmap.c
0,0 → 1,229
/*
Copyright (c) 2009 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
 
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
#include <assert.h>
#include "apple_glx.h"
#include "apple_cgl.h"
#include "apple_visual.h"
#include "apple_glx_drawable.h"
#include "appledri.h"
#include "glxconfig.h"
 
static bool pixmap_make_current(struct apple_glx_context *ac,
struct apple_glx_drawable *d);
 
static void pixmap_destroy(Display * dpy, struct apple_glx_drawable *d);
 
static struct apple_glx_drawable_callbacks callbacks = {
.type = APPLE_GLX_DRAWABLE_PIXMAP,
.make_current = pixmap_make_current,
.destroy = pixmap_destroy
};
 
static bool
pixmap_make_current(struct apple_glx_context *ac,
struct apple_glx_drawable *d)
{
CGLError cglerr;
struct apple_glx_pixmap *p = &d->types.pixmap;
 
assert(APPLE_GLX_DRAWABLE_PIXMAP == d->type);
 
cglerr = apple_cgl.set_current_context(p->context_obj);
 
if (kCGLNoError != cglerr) {
fprintf(stderr, "set current context: %s\n",
apple_cgl.error_string(cglerr));
return true;
}
 
cglerr = apple_cgl.set_off_screen(p->context_obj, p->width, p->height,
p->pitch, p->buffer);
 
if (kCGLNoError != cglerr) {
fprintf(stderr, "set off screen: %s\n", apple_cgl.error_string(cglerr));
 
return true;
}
 
if (!ac->made_current) {
apple_glapi_oglfw_viewport_scissor(0, 0, p->width, p->height);
ac->made_current = true;
}
 
return false;
}
 
static void
pixmap_destroy(Display * dpy, struct apple_glx_drawable *d)
{
struct apple_glx_pixmap *p = &d->types.pixmap;
 
if (p->pixel_format_obj)
(void) apple_cgl.destroy_pixel_format(p->pixel_format_obj);
 
if (p->context_obj)
(void) apple_cgl.destroy_context(p->context_obj);
 
XAppleDRIDestroyPixmap(dpy, p->xpixmap);
 
if (p->buffer) {
if (munmap(p->buffer, p->size))
perror("munmap");
 
if (-1 == close(p->fd))
perror("close");
 
if (shm_unlink(p->path))
perror("shm_unlink");
}
 
apple_glx_diagnostic("destroyed pixmap buffer for: 0x%lx\n", d->drawable);
}
 
/* Return true if an error occurred. */
bool
apple_glx_pixmap_create(Display * dpy, int screen, Pixmap pixmap,
const void *mode)
{
struct apple_glx_drawable *d;
struct apple_glx_pixmap *p;
bool double_buffered;
bool uses_stereo;
CGLError error;
const struct glx_config *cmodes = mode;
 
if (apple_glx_drawable_create(dpy, screen, pixmap, &d, &callbacks))
return true;
 
/* d is locked and referenced at this point. */
 
p = &d->types.pixmap;
 
p->xpixmap = pixmap;
p->buffer = NULL;
 
if (!XAppleDRICreatePixmap(dpy, screen, pixmap,
&p->width, &p->height, &p->pitch, &p->bpp,
&p->size, p->path, PATH_MAX)) {
d->unlock(d);
d->destroy(d);
return true;
}
 
p->fd = shm_open(p->path, O_RDWR, 0);
 
if (p->fd < 0) {
perror("shm_open");
d->unlock(d);
d->destroy(d);
return true;
}
 
p->buffer = mmap(NULL, p->size, PROT_READ | PROT_WRITE,
MAP_FILE | MAP_SHARED, p->fd, 0);
 
if (MAP_FAILED == p->buffer) {
perror("mmap");
d->unlock(d);
d->destroy(d);
return true;
}
 
apple_visual_create_pfobj(&p->pixel_format_obj, mode, &double_buffered,
&uses_stereo, /*offscreen */ true);
 
error = apple_cgl.create_context(p->pixel_format_obj, NULL,
&p->context_obj);
 
if (kCGLNoError != error) {
d->unlock(d);
d->destroy(d);
return true;
}
 
p->fbconfigID = cmodes->fbconfigID;
 
d->unlock(d);
 
apple_glx_diagnostic("created: pixmap buffer for 0x%lx\n", d->drawable);
 
return false;
}
 
bool
apple_glx_pixmap_query(GLXPixmap pixmap, int attr, unsigned int *value)
{
struct apple_glx_drawable *d;
struct apple_glx_pixmap *p;
bool result = false;
 
d = apple_glx_drawable_find_by_type(pixmap, APPLE_GLX_DRAWABLE_PIXMAP,
APPLE_GLX_DRAWABLE_LOCK);
 
if (d) {
p = &d->types.pixmap;
 
switch (attr) {
case GLX_WIDTH:
*value = p->width;
result = true;
break;
 
case GLX_HEIGHT:
*value = p->height;
result = true;
break;
 
case GLX_FBCONFIG_ID:
*value = p->fbconfigID;
result = true;
break;
}
 
d->unlock(d);
}
 
return result;
}
 
/* Return true if the type is valid for pixmap. */
bool
apple_glx_pixmap_destroy(Display * dpy, GLXPixmap pixmap)
{
return !apple_glx_drawable_destroy_by_type(dpy, pixmap,
APPLE_GLX_DRAWABLE_PIXMAP);
}
/contrib/sdk/sources/Mesa/src/glx/apple/apple_glx_surface.c
0,0 → 1,225
/*
Copyright (c) 2009 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#include <assert.h>
#include "glxclient.h"
#include "apple_glx.h"
#include "appledri.h"
#include "apple_glx_drawable.h"
 
static bool surface_make_current(struct apple_glx_context *ac,
struct apple_glx_drawable *d);
 
static void surface_destroy(Display * dpy, struct apple_glx_drawable *d);
 
 
static struct apple_glx_drawable_callbacks callbacks = {
.type = APPLE_GLX_DRAWABLE_SURFACE,
.make_current = surface_make_current,
.destroy = surface_destroy
};
 
static void
update_viewport_and_scissor(Display * dpy, GLXDrawable drawable)
{
Window root;
int x, y;
unsigned int width = 0, height = 0, bd, depth;
 
XGetGeometry(dpy, drawable, &root, &x, &y, &width, &height, &bd, &depth);
 
apple_glapi_oglfw_viewport_scissor(0, 0, width, height);
}
 
static bool
surface_make_current(struct apple_glx_context *ac,
struct apple_glx_drawable *d)
{
struct apple_glx_surface *s = &d->types.surface;
xp_error error;
 
assert(APPLE_GLX_DRAWABLE_SURFACE == d->type);
 
apple_glx_diagnostic("%s: ac->context_obj %p s->surface_id %u\n",
__func__, (void *) ac->context_obj, s->surface_id);
 
error = xp_attach_gl_context(ac->context_obj, s->surface_id);
 
if (error) {
fprintf(stderr, "error: xp_attach_gl_context returned: %d\n", error);
return true;
}
 
 
if (!ac->made_current) {
/*
* The first time a new context is made current the glViewport
* and glScissor should be updated.
*/
update_viewport_and_scissor(ac->drawable->display,
ac->drawable->drawable);
ac->made_current = true;
}
 
apple_glx_diagnostic("%s: drawable 0x%lx\n", __func__, d->drawable);
 
return false;
}
 
static void
surface_destroy(Display * dpy, struct apple_glx_drawable *d)
{
struct apple_glx_surface *s = &d->types.surface;
 
apple_glx_diagnostic("%s: s->surface_id %u\n", __func__, s->surface_id);
 
xp_error error = xp_destroy_surface(s->surface_id);
 
if (error) {
fprintf(stderr, "xp_destroy_surface error: %d\n", (int) error);
}
 
/*
* Check if this surface destroy came from the surface being destroyed
* on the server. If s->pending_destroy is true, then it did, and
* we don't want to try to destroy the surface on the server.
*/
if (!s->pending_destroy) {
/*
* Warning: this causes other routines to be called (potentially)
* from surface_notify_handler. It's probably best to not have
* any locks at this point locked.
*/
XAppleDRIDestroySurface(d->display, DefaultScreen(d->display),
d->drawable);
 
apple_glx_diagnostic
("%s: destroyed a surface for drawable 0x%lx uid %u\n", __func__,
d->drawable, s->uid);
}
}
 
/* Return true if an error occured. */
static bool
create_surface(Display * dpy, int screen, struct apple_glx_drawable *d)
{
struct apple_glx_surface *s = &d->types.surface;
unsigned int key[2];
xp_client_id id;
 
id = apple_glx_get_client_id();
if (0 == id)
return true;
 
assert(None != d->drawable);
 
s->pending_destroy = false;
 
if (XAppleDRICreateSurface(dpy, screen, d->drawable, id, key, &s->uid)) {
xp_error error;
 
error = xp_import_surface(key, &s->surface_id);
 
if (error) {
fprintf(stderr, "error: xp_import_surface returned: %d\n", error);
return true;
}
 
apple_glx_diagnostic("%s: created a surface for drawable 0x%lx"
" with uid %u\n", __func__, d->drawable, s->uid);
return false; /*success */
}
 
return true; /* unable to create a surface. */
}
 
/* Return true if an error occured. */
/* This returns a referenced object via resultptr. */
bool
apple_glx_surface_create(Display * dpy, int screen,
GLXDrawable drawable,
struct apple_glx_drawable ** resultptr)
{
struct apple_glx_drawable *d;
 
if (apple_glx_drawable_create(dpy, screen, drawable, &d, &callbacks))
return true;
 
/* apple_glx_drawable_create creates a locked and referenced object. */
 
if (create_surface(dpy, screen, d)) {
d->unlock(d);
d->destroy(d);
return true;
}
 
*resultptr = d;
 
d->unlock(d);
 
return false;
}
 
/*
* All surfaces are reference counted, and surfaces are only created
* when the window is made current. When all contexts no longer reference
* a surface drawable the apple_glx_drawable gets destroyed, and thus
* its surface is destroyed.
*
* However we can make the destruction occur a bit sooner by setting
* pending_destroy, which is then checked for in glViewport by
* apple_glx_context_update.
*/
void
apple_glx_surface_destroy(unsigned int uid)
{
struct apple_glx_drawable *d;
 
d = apple_glx_drawable_find_by_uid(uid, APPLE_GLX_DRAWABLE_REFERENCE
| APPLE_GLX_DRAWABLE_LOCK);
 
if (d) {
d->types.surface.pending_destroy = true;
d->release(d);
 
/*
* We release 2 references to the surface. One was acquired by
* the find, and the other was leftover from a context, or
* the surface being displayed, so the destroy() will decrease it
* once more.
*
* If the surface is in a context, it will take one d->destroy(d);
* to actually destroy it when the pending_destroy is processed
* by a glViewport callback (see apple_glx_context_update()).
*/
if (!d->destroy(d)) {
/* apple_glx_drawable_find_by_uid returns a locked drawable */
d->unlock(d);
}
}
}
/contrib/sdk/sources/Mesa/src/glx/apple/apple_visual.c
0,0 → 1,166
/*
Copyright (c) 2008, 2009 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
 
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <GL/gl.h>
 
/* <rdar://problem/6953344> */
#define glTexImage1D glTexImage1D_OSX
#define glTexImage2D glTexImage2D_OSX
#define glTexImage3D glTexImage3D_OSX
#include <OpenGL/OpenGL.h>
#include <OpenGL/CGLContext.h>
#include <OpenGL/CGLRenderers.h>
#include <OpenGL/CGLTypes.h>
#undef glTexImage1D
#undef glTexImage2D
#undef glTexImage3D
 
#ifndef kCGLPFAOpenGLProfile
#define kCGLPFAOpenGLProfile 99
#endif
 
#ifndef kCGLOGLPVersion_3_2_Core
#define kCGLOGLPVersion_3_2_Core 0x3200
#endif
 
#include "apple_cgl.h"
#include "apple_visual.h"
#include "apple_glx.h"
#include "glxconfig.h"
 
enum
{
MAX_ATTR = 60
};
 
void
apple_visual_create_pfobj(CGLPixelFormatObj * pfobj, const struct glx_config * mode,
bool * double_buffered, bool * uses_stereo,
bool offscreen)
{
CGLPixelFormatAttribute attr[MAX_ATTR];
int numattr = 0;
GLint vsref = 0;
CGLError error = 0;
 
/* Request an OpenGL 3.2 profile if one is available */
if(apple_cgl.version_major > 1 || (apple_cgl.version_major == 1 && apple_cgl.version_minor >= 3)) {
attr[numattr++] = kCGLPFAOpenGLProfile;
attr[numattr++] = kCGLOGLPVersion_3_2_Core;
}
 
if (offscreen) {
apple_glx_diagnostic
("offscreen rendering enabled. Using kCGLPFAOffScreen\n");
 
attr[numattr++] = kCGLPFAOffScreen;
attr[numattr++] = kCGLPFAColorSize;
attr[numattr++] = 32;
}
else if (getenv("LIBGL_ALWAYS_SOFTWARE") != NULL) {
apple_glx_diagnostic
("Software rendering requested. Using kCGLRendererGenericFloatID.\n");
attr[numattr++] = kCGLPFARendererID;
attr[numattr++] = kCGLRendererGenericFloatID;
}
else if (getenv("LIBGL_ALLOW_SOFTWARE") != NULL) {
apple_glx_diagnostic
("Software rendering is not being excluded. Not using kCGLPFAAccelerated.\n");
}
else {
attr[numattr++] = kCGLPFAAccelerated;
}
 
/*
* The program chose a config based on the fbconfigs or visuals.
* Those are based on the attributes from CGL, so we probably
* do want the closest match for the color, depth, and accum.
*/
attr[numattr++] = kCGLPFAClosestPolicy;
 
if (mode->stereoMode) {
attr[numattr++] = kCGLPFAStereo;
*uses_stereo = true;
}
else {
*uses_stereo = false;
}
 
if (!offscreen && mode->doubleBufferMode) {
attr[numattr++] = kCGLPFADoubleBuffer;
*double_buffered = true;
}
else {
*double_buffered = false;
}
 
attr[numattr++] = kCGLPFAColorSize;
attr[numattr++] = mode->redBits + mode->greenBits + mode->blueBits;
attr[numattr++] = kCGLPFAAlphaSize;
attr[numattr++] = mode->alphaBits;
 
if ((mode->accumRedBits + mode->accumGreenBits + mode->accumBlueBits) > 0) {
attr[numattr++] = kCGLPFAAccumSize;
attr[numattr++] = mode->accumRedBits + mode->accumGreenBits +
mode->accumBlueBits + mode->accumAlphaBits;
}
 
if (mode->depthBits > 0) {
attr[numattr++] = kCGLPFADepthSize;
attr[numattr++] = mode->depthBits;
}
 
if (mode->stencilBits > 0) {
attr[numattr++] = kCGLPFAStencilSize;
attr[numattr++] = mode->stencilBits;
}
 
if (mode->sampleBuffers > 0) {
attr[numattr++] = kCGLPFAMultisample;
attr[numattr++] = kCGLPFASampleBuffers;
attr[numattr++] = mode->sampleBuffers;
attr[numattr++] = kCGLPFASamples;
attr[numattr++] = mode->samples;
}
 
attr[numattr++] = 0;
 
assert(numattr < MAX_ATTR);
 
error = apple_cgl.choose_pixel_format(attr, pfobj, &vsref);
 
if (error) {
fprintf(stderr, "error: %s\n", apple_cgl.error_string(error));
abort();
}
}
/contrib/sdk/sources/Mesa/src/glx/apple/apple_visual.h
0,0 → 1,41
/*
Copyright (c) 2008 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
 
#ifndef APPLE_VISUAL_H
#define APPLE_VISUAL_H
 
#include <stdbool.h>
#include <OpenGL/CGLTypes.h>
#include "glxconfig.h"
 
void apple_visual_create_pfobj(CGLPixelFormatObj * pfobj, const struct glx_config * mode,
bool * double_buffered, bool * uses_stereo,
bool offscreen);
 
#endif
/contrib/sdk/sources/Mesa/src/glx/apple/apple_xgl_api.h
0,0 → 1,43
/*
Copyright (c) 2011 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
 
#ifndef APPLE_XGL_API_H
 
void __applegl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, void *pixels);
void __applegl_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
void __applegl_glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y,
GLsizei width);
 
void __applegl_glDrawBuffer(GLenum mode);
void __applegl_glDrawBuffers(GLsizei n, const GLenum * bufs);
 
void __applegl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
 
#endif
/contrib/sdk/sources/Mesa/src/glx/apple/apple_xgl_api_read.c
0,0 → 1,134
/*
Copyright (c) 2008-2011 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
 
/*
* This file works with the glXMakeContextCurrent readable drawable.
*
* The way it works is by swapping the currentDrawable for the currentReadable
* drawable if they are different.
*/
#include <stdbool.h>
#include "glxclient.h"
#include "apple_glx_context.h"
#include "apple_xgl_api.h"
#include "glapitable.h"
 
extern struct _glapi_table * __ogl_framework_api;
 
struct apple_xgl_saved_state
{
bool swapped;
};
 
static void
SetRead(struct apple_xgl_saved_state *saved)
{
struct glx_context *gc = __glXGetCurrentContext();
 
/*
* By default indicate that the state was not swapped, so that UnsetRead
* functions correctly.
*/
saved->swapped = false;
 
/*
* If the readable drawable isn't the same as the drawable then
* the user has requested a readable drawable with glXMakeContextCurrent().
* We emulate this behavior by switching the current drawable.
*/
if (None != gc->currentReadable
&& gc->currentReadable != gc->currentDrawable) {
Display *dpy = glXGetCurrentDisplay();
 
saved->swapped = true;
 
if (apple_glx_make_current_context(dpy, gc->driContext, gc->driContext,
gc->currentReadable)) {
/* An error occurred, so try to restore the old context state. */
(void) apple_glx_make_current_context(dpy, gc->driContext, gc->driContext,
gc->currentDrawable);
saved->swapped = false;
}
}
}
 
static void
UnsetRead(struct apple_xgl_saved_state *saved)
{
if (saved->swapped) {
struct glx_context *gc = __glXGetCurrentContext();
Display *dpy = glXGetCurrentDisplay();
 
if (apple_glx_make_current_context(dpy, gc->driContext, gc->driContext,
gc->currentDrawable)) {
/*
* An error occurred restoring the drawable.
* It's unclear what to do about that.
*/
}
}
}
 
void
__applegl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, void *pixels)
{
struct apple_xgl_saved_state saved;
 
SetRead(&saved);
 
__ogl_framework_api->ReadPixels(x, y, width, height, format, type, pixels);
 
UnsetRead(&saved);
}
 
void
__applegl_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
{
struct apple_xgl_saved_state saved;
 
SetRead(&saved);
 
__ogl_framework_api->CopyPixels(x, y, width, height, type);
 
UnsetRead(&saved);
}
 
void
__applegl_glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y,
GLsizei width)
{
struct apple_xgl_saved_state saved;
 
SetRead(&saved);
 
__ogl_framework_api->CopyColorTable(target, internalformat, x, y, width);
 
UnsetRead(&saved);
}
/contrib/sdk/sources/Mesa/src/glx/apple/apple_xgl_api_stereo.c
0,0 → 1,124
/*
Copyright (c) 2009-2011 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
 
/* This should be removed once stereo hardware bugs are fixed
* <rdar://problem/6729006>
*/
 
#include <stdbool.h>
 
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
 
#include "glxclient.h"
#include "apple_glx_context.h"
#include "apple_xgl_api.h"
#include "glapitable.h"
 
extern struct _glapi_table * __ogl_framework_api;
 
/*
* These are special functions for stereoscopic support
* differences in MacOS X.
*/
void
__applegl_glDrawBuffer(GLenum mode)
{
struct glx_context * gc = __glXGetCurrentContext();
 
if (gc && apple_glx_context_uses_stereo(gc->driContext)) {
GLenum buf[2];
GLsizei n = 0;
 
switch (mode) {
case GL_BACK:
buf[0] = GL_BACK_LEFT;
buf[1] = GL_BACK_RIGHT;
n = 2;
break;
case GL_FRONT:
buf[0] = GL_FRONT_LEFT;
buf[1] = GL_FRONT_RIGHT;
n = 2;
break;
 
default:
buf[0] = mode;
n = 1;
break;
}
 
__ogl_framework_api->DrawBuffersARB(n, buf);
}
else {
__ogl_framework_api->DrawBuffer(mode);
}
}
 
 
void
__applegl_glDrawBuffers(GLsizei n, const GLenum * bufs)
{
struct glx_context * gc = __glXGetCurrentContext();
 
if (gc && apple_glx_context_uses_stereo(gc->driContext)) {
GLenum newbuf[n + 2];
GLsizei i, outi = 0;
bool have_back = false;
bool have_front = false;
 
for (i = 0; i < n; ++i) {
if (GL_BACK == bufs[i]) {
have_back = true;
}
else if (GL_FRONT == bufs[i]) {
have_back = true;
}
else {
newbuf[outi++] = bufs[i];
}
}
 
if (have_back) {
newbuf[outi++] = GL_BACK_LEFT;
newbuf[outi++] = GL_BACK_RIGHT;
}
 
if (have_front) {
newbuf[outi++] = GL_FRONT_LEFT;
newbuf[outi++] = GL_FRONT_RIGHT;
}
 
__ogl_framework_api->DrawBuffersARB(outi, newbuf);
}
else {
__ogl_framework_api->DrawBuffersARB(n, bufs);
}
}
/contrib/sdk/sources/Mesa/src/glx/apple/apple_xgl_api_viewport.c
0,0 → 1,47
/*
Copyright (c) 2009-2011 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
 
#include "glxclient.h"
#include "apple_glx_context.h"
#include "apple_xgl_api.h"
#include "glapitable.h"
 
extern struct _glapi_table * __ogl_framework_api;
 
void
__applegl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
{
struct glx_context *gc = __glXGetCurrentContext();
Display *dpy = glXGetCurrentDisplay();
 
if (gc && gc->driContext)
apple_glx_context_update(dpy, gc->driContext);
 
__ogl_framework_api->Viewport(x, y, width, height);
}
/contrib/sdk/sources/Mesa/src/glx/apple/appledri.c
0,0 → 1,450
/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.12 2001/08/27 17:40:57 dawes Exp $ */
/**************************************************************************
 
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 2008 Apple Computer, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
**************************************************************************/
 
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Jens Owen <jens@valinux.com>
* Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
 
/* THIS IS NOT AN X CONSORTIUM STANDARD */
 
#include <X11/Xlibint.h>
#include "appledristr.h"
#include <X11/extensions/Xext.h>
#include <X11/extensions/extutil.h>
#include <stdio.h>
 
static XExtensionInfo _appledri_info_data;
static XExtensionInfo *appledri_info = &_appledri_info_data;
static char *appledri_extension_name = APPLEDRINAME;
 
#define AppleDRICheckExtension(dpy,i,val) \
XextCheckExtension (dpy, i, appledri_extension_name, val)
 
/*****************************************************************************
* *
* private utility routines *
* *
*****************************************************************************/
 
static int close_display(Display * dpy, XExtCodes * extCodes);
static Bool wire_to_event(Display * dpy, XEvent * re, xEvent * event);
 
static /* const */ XExtensionHooks appledri_extension_hooks = {
NULL, /* create_gc */
NULL, /* copy_gc */
NULL, /* flush_gc */
NULL, /* free_gc */
NULL, /* create_font */
NULL, /* free_font */
close_display, /* close_display */
wire_to_event, /* wire_to_event */
NULL, /* event_to_wire */
NULL, /* error */
NULL, /* error_string */
};
 
static
XEXT_GENERATE_FIND_DISPLAY(find_display, appledri_info,
appledri_extension_name,
&appledri_extension_hooks,
AppleDRINumberEvents, NULL)
 
static XEXT_GENERATE_CLOSE_DISPLAY(close_display, appledri_info)
 
static void (*surface_notify_handler) ();
 
void *XAppleDRISetSurfaceNotifyHandler(void (*fun) ())
{
void *old = surface_notify_handler;
surface_notify_handler = fun;
return old;
}
 
static Bool
wire_to_event(Display *dpy, XEvent *re, xEvent *event)
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRINotifyEvent *sevent;
 
AppleDRICheckExtension(dpy, info, False);
 
switch ((event->u.u.type & 0x7f) - info->codes->first_event) {
case AppleDRISurfaceNotify:
sevent = (xAppleDRINotifyEvent *) event;
if (surface_notify_handler != NULL) {
(*surface_notify_handler) (dpy, (unsigned int) sevent->arg,
(int) sevent->kind);
}
return False;
}
return False;
}
 
/*****************************************************************************
* *
* public Apple-DRI Extension routines *
* *
*****************************************************************************/
 
#if 0
#include <stdio.h>
#define TRACE(msg) fprintf(stderr, "AppleDRI%s\n", msg);
#else
#define TRACE(msg)
#endif
 
 
Bool
XAppleDRIQueryExtension(dpy, event_basep, error_basep)
Display *dpy;
int *event_basep, *error_basep;
{
XExtDisplayInfo *info = find_display(dpy);
 
TRACE("QueryExtension...");
if (XextHasExtension(info)) {
*event_basep = info->codes->first_event;
*error_basep = info->codes->first_error;
TRACE("QueryExtension... return True");
return True;
}
else {
TRACE("QueryExtension... return False");
return False;
}
}
 
Bool
XAppleDRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
Display *dpy;
int *majorVersion;
int *minorVersion;
int *patchVersion;
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRIQueryVersionReply rep;
xAppleDRIQueryVersionReq *req;
 
TRACE("QueryVersion...");
AppleDRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(AppleDRIQueryVersion, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRIQueryVersion;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("QueryVersion... return False");
return False;
}
*majorVersion = rep.majorVersion;
*minorVersion = rep.minorVersion;
*patchVersion = rep.patchVersion;
UnlockDisplay(dpy);
SyncHandle();
TRACE("QueryVersion... return True");
return True;
}
 
Bool
XAppleDRIQueryDirectRenderingCapable(dpy, screen, isCapable)
Display *dpy;
int screen;
Bool *isCapable;
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRIQueryDirectRenderingCapableReply rep;
xAppleDRIQueryDirectRenderingCapableReq *req;
 
TRACE("QueryDirectRenderingCapable...");
AppleDRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(AppleDRIQueryDirectRenderingCapable, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRIQueryDirectRenderingCapable;
req->screen = screen;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("QueryDirectRenderingCapable... return False");
return False;
}
*isCapable = rep.isCapable;
UnlockDisplay(dpy);
SyncHandle();
TRACE("QueryDirectRenderingCapable... return True");
return True;
}
 
Bool
XAppleDRIAuthConnection(dpy, screen, magic)
Display *dpy;
int screen;
unsigned int magic;
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRIAuthConnectionReq *req;
xAppleDRIAuthConnectionReply rep;
 
TRACE("AuthConnection...");
AppleDRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(AppleDRIAuthConnection, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRIAuthConnection;
req->screen = screen;
req->magic = magic;
rep.authenticated = 0;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.authenticated) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("AuthConnection... return False");
return False;
}
UnlockDisplay(dpy);
SyncHandle();
TRACE("AuthConnection... return True");
return True;
}
 
Bool
XAppleDRICreateSurface(dpy, screen, drawable, client_id, key, uid)
Display *dpy;
int screen;
Drawable drawable;
unsigned int client_id;
unsigned int *key;
unsigned int *uid;
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRICreateSurfaceReply rep;
xAppleDRICreateSurfaceReq *req;
 
TRACE("CreateSurface...");
AppleDRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(AppleDRICreateSurface, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRICreateSurface;
req->screen = screen;
req->drawable = drawable;
req->client_id = client_id;
rep.key_0 = rep.key_1 = rep.uid = 0;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.key_0) {
UnlockDisplay(dpy);
SyncHandle();
TRACE("CreateSurface... return False");
return False;
}
key[0] = rep.key_0;
key[1] = rep.key_1;
*uid = rep.uid;
UnlockDisplay(dpy);
SyncHandle();
TRACE("CreateSurface... return True");
return True;
}
 
Bool
XAppleDRIDestroySurface(dpy, screen, drawable)
Display *dpy;
int screen;
Drawable drawable;
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRIDestroySurfaceReq *req;
 
TRACE("DestroySurface...");
AppleDRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(AppleDRIDestroySurface, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRIDestroySurface;
req->screen = screen;
req->drawable = drawable;
UnlockDisplay(dpy);
SyncHandle();
TRACE("DestroySurface... return True");
return True;
}
 
Bool
XAppleDRICreateSharedBuffer(Display * dpy, int screen, Drawable drawable,
Bool doubleSwap, char *path, size_t pathlen,
int *width, int *height)
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRICreateSharedBufferReq *req;
xAppleDRICreateSharedBufferReply rep;
 
AppleDRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(AppleDRICreateSharedBuffer, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRICreateSharedBuffer;
req->screen = screen;
req->drawable = drawable;
req->doubleSwap = doubleSwap;
 
 
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
puts("REPLY ERROR");
 
UnlockDisplay(dpy);
SyncHandle();
return False;
}
 
/* printf("rep.stringLength %d\n", (int) rep.stringLength); */
 
if (rep.stringLength > 0 && rep.stringLength <= pathlen) {
_XReadPad(dpy, path, rep.stringLength);
 
/* printf("path: %s\n", path); */
 
*width = rep.width;
*height = rep.height;
 
UnlockDisplay(dpy);
SyncHandle();
return True;
}
 
UnlockDisplay(dpy);
SyncHandle();
 
return False;
}
 
Bool
XAppleDRISwapBuffers(Display * dpy, int screen, Drawable drawable)
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRISwapBuffersReq *req;
 
AppleDRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(AppleDRISwapBuffers, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRISwapBuffers;
req->screen = screen;
req->drawable = drawable;
UnlockDisplay(dpy);
SyncHandle();
 
return True;
}
 
Bool
XAppleDRICreatePixmap(Display * dpy, int screen, Drawable drawable,
int *width, int *height, int *pitch, int *bpp,
size_t * size, char *bufname, size_t bufnamesize)
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRICreatePixmapReq *req;
xAppleDRICreatePixmapReply rep;
 
AppleDRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(AppleDRICreatePixmap, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRICreatePixmap;
req->screen = screen;
req->drawable = drawable;
 
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
 
/*
printf("rep.stringLength %d\n", (int) rep.stringLength);
*/
 
if (rep.stringLength > 0 && rep.stringLength <= bufnamesize) {
_XReadPad(dpy, bufname, rep.stringLength);
 
/* printf("path: %s\n", bufname); */
 
*width = rep.width;
*height = rep.height;
*pitch = rep.pitch;
*bpp = rep.bpp;
*size = rep.size;
 
UnlockDisplay(dpy);
SyncHandle();
return True;
}
else if (rep.stringLength > 0) {
_XEatData(dpy, rep.stringLength);
}
 
UnlockDisplay(dpy);
SyncHandle();
 
return True;
}
 
/*
* Call it a drawable, because we really don't know what it is
* until it reaches the server, and we should keep that in mind.
*/
Bool
XAppleDRIDestroyPixmap(Display * dpy, Pixmap drawable)
{
XExtDisplayInfo *info = find_display(dpy);
xAppleDRIDestroyPixmapReq *req;
 
AppleDRICheckExtension(dpy, info, False);
 
LockDisplay(dpy);
GetReq(AppleDRIDestroyPixmap, req);
req->reqType = info->codes->major_opcode;
req->driReqType = X_AppleDRIDestroyPixmap;
req->drawable = drawable;
UnlockDisplay(dpy);
SyncHandle();
 
return True;
}
/contrib/sdk/sources/Mesa/src/glx/apple/appledri.h
0,0 → 1,124
/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.7 2000/12/07 20:26:02 dawes Exp $ */
/**************************************************************************
 
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 2008, 2009 Apple Computer, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
**************************************************************************/
 
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Jens Owen <jens@valinux.com>
* Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
 
#ifndef _APPLEDRI_H_
#define _APPLEDRI_H_
 
#include <X11/Xlib.h>
#include <X11/Xfuncproto.h>
 
#define X_AppleDRIQueryVersion 0
#define X_AppleDRIQueryDirectRenderingCapable 1
#define X_AppleDRICreateSurface 2
#define X_AppleDRIDestroySurface 3
#define X_AppleDRIAuthConnection 4
#define X_AppleDRICreateSharedBuffer 5
#define X_AppleDRISwapBuffers 6
#define X_AppleDRICreatePixmap 7
#define X_AppleDRIDestroyPixmap 8
 
/* Requests up to and including 18 were used in a previous version */
 
/* Events */
#define AppleDRIObsoleteEvent1 0
#define AppleDRIObsoleteEvent2 1
#define AppleDRIObsoleteEvent3 2
#define AppleDRISurfaceNotify 3
#define AppleDRINumberEvents 4
 
/* Errors */
#define AppleDRIClientNotLocal 0
#define AppleDRIOperationNotSupported 1
#define AppleDRINumberErrors (AppleDRIOperationNotSupported + 1)
 
/* Kinds of SurfaceNotify events: */
#define AppleDRISurfaceNotifyChanged 0
#define AppleDRISurfaceNotifyDestroyed 1
 
#ifndef _APPLEDRI_SERVER_
 
typedef struct
{
int type; /* of event */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came frome a SendEvent request */
Display *display; /* Display the event was read from */
Window window; /* window of event */
Time time; /* server timestamp when event happened */
int kind; /* subtype of event */
int arg;
} XAppleDRINotifyEvent;
 
_XFUNCPROTOBEGIN
Bool XAppleDRIQueryExtension(Display * dpy, int *event_base,
int *error_base);
 
Bool XAppleDRIQueryVersion(Display * dpy, int *majorVersion,
int *minorVersion, int *patchVersion);
 
Bool XAppleDRIQueryDirectRenderingCapable(Display * dpy, int screen,
Bool * isCapable);
 
void *XAppleDRISetSurfaceNotifyHandler(void (*fun) (Display * dpy,
unsigned uid, int kind));
 
Bool XAppleDRIAuthConnection(Display * dpy, int screen, unsigned int magic);
 
Bool XAppleDRICreateSurface(Display * dpy, int screen, Drawable drawable,
unsigned int client_id, unsigned int key[2],
unsigned int *uid);
 
Bool XAppleDRIDestroySurface(Display * dpy, int screen, Drawable drawable);
 
Bool XAppleDRISynchronizeSurfaces(Display * dpy);
 
Bool XAppleDRICreateSharedBuffer(Display * dpy, int screen, Drawable drawable,
Bool doubleSwap, char *path, size_t pathlen,
int *width, int *height);
 
Bool XAppleDRISwapBuffers(Display * dpy, int screen, Drawable drawable);
 
Bool XAppleDRICreatePixmap(Display * dpy, int screen, Drawable drawable,
int *width, int *height, int *pitch, int *bpp,
size_t * size, char *bufname, size_t bufnamesize);
 
Bool XAppleDRIDestroyPixmap(Display * dpy, Pixmap pixmap);
 
_XFUNCPROTOEND
#endif /* _APPLEDRI_SERVER_ */
#endif /* _APPLEDRI_H_ */
/contrib/sdk/sources/Mesa/src/glx/apple/appledristr.h
0,0 → 1,266
/**************************************************************************
 
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, Inc.
Copyright (c) 2002, 2008, 2009 Apple Computer, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
**************************************************************************/
 
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Jens Owen <jens@valinux.com>
* Rickard E. (Rik) Fiath <faith@valinux.com>
*
*/
 
#ifndef _APPLEDRISTR_H_
#define _APPLEDRISTR_H_
 
#include "appledri.h"
 
#define APPLEDRINAME "Apple-DRI"
 
#define APPLE_DRI_MAJOR_VERSION 1 /* current version numbers */
#define APPLE_DRI_MINOR_VERSION 0
#define APPLE_DRI_PATCH_VERSION 0
 
typedef struct _AppleDRIQueryVersion
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIQueryVersion */
CARD16 length B16;
} xAppleDRIQueryVersionReq;
#define sz_xAppleDRIQueryVersionReq 4
 
typedef struct
{
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD16 majorVersion B16; /* major version of DRI protocol */
CARD16 minorVersion B16; /* minor version of DRI protocol */
CARD32 patchVersion B32; /* patch version of DRI protocol */
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xAppleDRIQueryVersionReply;
#define sz_xAppleDRIQueryVersionReply 32
 
typedef struct _AppleDRIQueryDirectRenderingCapable
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
CARD16 length B16;
CARD32 screen B32;
} xAppleDRIQueryDirectRenderingCapableReq;
#define sz_xAppleDRIQueryDirectRenderingCapableReq 8
 
typedef struct
{
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
BOOL isCapable;
BOOL pad2;
BOOL pad3;
BOOL pad4;
CARD32 pad5 B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
CARD32 pad8 B32;
CARD32 pad9 B32;
} xAppleDRIQueryDirectRenderingCapableReply;
#define sz_xAppleDRIQueryDirectRenderingCapableReply 32
 
typedef struct _AppleDRIAuthConnection
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICloseConnection */
CARD16 length B16;
CARD32 screen B32;
CARD32 magic B32;
} xAppleDRIAuthConnectionReq;
#define sz_xAppleDRIAuthConnectionReq 12
 
typedef struct
{
BYTE type;
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 authenticated B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xAppleDRIAuthConnectionReply;
#define zx_xAppleDRIAuthConnectionReply 32
 
typedef struct _AppleDRICreateSurface
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICreateSurface */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
CARD32 client_id B32;
} xAppleDRICreateSurfaceReq;
#define sz_xAppleDRICreateSurfaceReq 16
 
typedef struct
{
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 key_0 B32;
CARD32 key_1 B32;
CARD32 uid B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xAppleDRICreateSurfaceReply;
#define sz_xAppleDRICreateSurfaceReply 32
 
typedef struct _AppleDRIDestroySurface
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIDestroySurface */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xAppleDRIDestroySurfaceReq;
#define sz_xAppleDRIDestroySurfaceReq 12
 
typedef struct _AppleDRINotify
{
BYTE type; /* always eventBase + event type */
BYTE kind;
CARD16 sequenceNumber B16;
CARD32 time B32; /* time of change */
CARD32 pad1 B32;
CARD32 arg B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xAppleDRINotifyEvent;
#define sz_xAppleDRINotifyEvent 32
 
 
typedef struct
{
CARD8 reqType;
CARD8 driReqType;
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
BOOL doubleSwap;
CARD8 pad1, pad2, pad3;
} xAppleDRICreateSharedBufferReq;
 
#define sz_xAppleDRICreateSharedBufferReq 16
 
typedef struct
{
BYTE type;
BYTE data1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 stringLength B32; /* 0 on error */
CARD32 width B32;
CARD32 height B32;
CARD32 pad1 B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
} xAppleDRICreateSharedBufferReply;
 
#define sz_xAppleDRICreateSharedBufferReply 32
 
typedef struct
{
CARD8 reqType;
CARD8 driReqType;
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xAppleDRISwapBuffersReq;
 
#define sz_xAppleDRISwapBuffersReq 12
 
typedef struct
{
CARD8 reqType; /*1 */
CARD8 driReqType; /*2 */
CARD16 length B16; /*4 */
CARD32 screen B32; /*8 */
CARD32 drawable B32; /*12 */
} xAppleDRICreatePixmapReq;
 
#define sz_xAppleDRICreatePixmapReq 12
 
typedef struct
{
BYTE type; /*1 */
BOOL pad1; /*2 */
CARD16 sequenceNumber B16; /*4 */
CARD32 length B32; /*8 */
CARD32 width B32; /*12 */
CARD32 height B32; /*16 */
CARD32 pitch B32; /*20 */
CARD32 bpp B32; /*24 */
CARD32 size B32; /*28 */
CARD32 stringLength B32; /*32 */
} xAppleDRICreatePixmapReply;
 
#define sz_xAppleDRICreatePixmapReply 32
 
typedef struct
{
CARD8 reqType; /*1 */
CARD8 driReqType; /*2 */
CARD16 length B16; /*4 */
CARD32 drawable B32; /*8 */
} xAppleDRIDestroyPixmapReq;
 
#define sz_xAppleDRIDestroyPixmapReq 8
 
#ifdef _APPLEDRI_SERVER_
 
void AppleDRISendEvent(
#if NeedFunctionPrototypes
int /* type */ ,
unsigned int /* mask */ ,
int /* which */ ,
int /* arg */
#endif
);
 
#endif /* _APPLEDRI_SERVER_ */
#endif /* _APPLEDRISTR_H_ */
/contrib/sdk/sources/Mesa/src/glx/apple/glx_empty.c
0,0 → 1,281
#include "glxclient.h"
#include "glxextensions.h"
#include "glxconfig.h"
 
/*
** GLX_SGI_swap_control
*/
int
glXSwapIntervalSGI(int interval)
{
(void) interval;
return 0;
}
 
 
/*
** GLX_MESA_swap_control
*/
int
glXSwapIntervalMESA(unsigned int interval)
{
(void) interval;
return GLX_BAD_CONTEXT;
}
 
 
int
glXGetSwapIntervalMESA(void)
{
return 0;
}
 
 
/*
** GLX_SGI_video_sync
*/
int
glXGetVideoSyncSGI(unsigned int *count)
{
(void) count;
return GLX_BAD_CONTEXT;
}
 
int
glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
{
(void) count;
return GLX_BAD_CONTEXT;
}
 
 
/*
** GLX_SGIX_swap_group
*/
void
glXJoinSwapGroupSGIX(Display * dpy, GLXDrawable drawable, GLXDrawable member)
{
(void) dpy;
(void) drawable;
(void) member;
}
 
 
/*
** GLX_SGIX_swap_barrier
*/
void
glXBindSwapBarrierSGIX(Display * dpy, GLXDrawable drawable, int barrier)
{
(void) dpy;
(void) drawable;
(void) barrier;
}
 
Bool
glXQueryMaxSwapBarriersSGIX(Display * dpy, int screen, int *max)
{
(void) dpy;
(void) screen;
(void) max;
return False;
}
 
 
/*
** GLX_OML_sync_control
*/
Bool
glXGetSyncValuesOML(Display * dpy, GLXDrawable drawable,
int64_t * ust, int64_t * msc, int64_t * sbc)
{
(void) dpy;
(void) drawable;
(void) ust;
(void) msc;
(void) sbc;
return False;
}
 
int64_t
glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable,
int64_t target_msc, int64_t divisor, int64_t remainder)
{
(void) dpy;
(void) drawable;
(void) target_msc;
(void) divisor;
(void) remainder;
return 0;
}
 
 
Bool
glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
int64_t target_msc, int64_t divisor,
int64_t remainder, int64_t * ust,
int64_t * msc, int64_t * sbc)
{
(void) dpy;
(void) drawable;
(void) target_msc;
(void) divisor;
(void) remainder;
(void) ust;
(void) msc;
(void) sbc;
return False;
}
 
 
Bool
glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
int64_t target_sbc, int64_t * ust,
int64_t * msc, int64_t * sbc)
{
(void) dpy;
(void) drawable;
(void) target_sbc;
(void) ust;
(void) msc;
(void) sbc;
return False;
}
 
 
Bool
glXReleaseBuffersMESA(Display * dpy, GLXDrawable d)
{
(void) dpy;
(void) d;
return False;
}
 
 
_X_EXPORT GLXPixmap
glXCreateGLXPixmapMESA(Display * dpy, XVisualInfo * visual,
Pixmap pixmap, Colormap cmap)
{
(void) dpy;
(void) visual;
(void) pixmap;
(void) cmap;
return 0;
}
 
 
/**
* GLX_MESA_copy_sub_buffer
*/
void
glXCopySubBufferMESA(Display * dpy, GLXDrawable drawable,
int x, int y, int width, int height)
{
(void) dpy;
(void) drawable;
(void) x;
(void) y;
(void) width;
(void) height;
}
 
 
_X_EXPORT int
glXQueryGLXPbufferSGIX(Display * dpy, GLXDrawable drawable,
int attribute, unsigned int *value)
{
(void) dpy;
(void) drawable;
(void) attribute;
(void) value;
return 0;
}
 
_X_EXPORT GLXDrawable
glXCreateGLXPbufferSGIX(Display * dpy, GLXFBConfig config,
unsigned int width, unsigned int height,
int *attrib_list)
{
(void) dpy;
(void) config;
(void) width;
(void) height;
(void) attrib_list;
return None;
}
 
#if 0
/* GLX_SGIX_fbconfig */
_X_EXPORT int
glXGetFBConfigAttribSGIX(Display * dpy, void *config, int a, int *b)
{
(void) dpy;
(void) config;
(void) a;
(void) b;
return 0;
}
 
_X_EXPORT void *
glXChooseFBConfigSGIX(Display * dpy, int a, int *b, int *c)
{
(void) dpy;
(void) a;
(void) b;
(void) c;
return NULL;
}
 
_X_EXPORT GLXPixmap
glXCreateGLXPixmapWithConfigSGIX(Display * dpy, void *config, Pixmap p)
{
(void) dpy;
(void) config;
(void) p;
return None;
}
 
_X_EXPORT GLXContext
glXCreateContextWithConfigSGIX(Display * dpy, void *config, int a,
GLXContext b, Bool c)
{
(void) dpy;
(void) config;
(void) a;
(void) b;
(void) c;
return NULL;
}
 
_X_EXPORT XVisualInfo *
glXGetVisualFromFBConfigSGIX(Display * dpy, void *config)
{
(void) dpy;
(void) config;
return NULL;
}
 
_X_EXPORT void *
glXGetFBConfigFromVisualSGIX(Display * dpy, XVisualInfo * visinfo)
{
(void) dpy;
(void) visinfo;
return NULL;
}
#endif
 
 
_X_EXPORT
GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX,
(Display * dpy, GLXDrawable pbuf),
(dpy, pbuf), glXDestroyPbuffer)
 
_X_EXPORT GLX_ALIAS_VOID(glXSelectEventSGIX,
(Display * dpy, GLXDrawable drawable,
unsigned long mask), (dpy, drawable, mask),
glXSelectEvent)
 
_X_EXPORT GLX_ALIAS_VOID(glXGetSelectedEventSGIX,
(Display * dpy, GLXDrawable drawable,
unsigned long *mask), (dpy, drawable, mask),
glXGetSelectedEvent)
/contrib/sdk/sources/Mesa/src/glx/apple/glxreply.c
0,0 → 1,134
/*
* (C) Copyright Apple Inc. 2008
* (C) Copyright IBM Corporation 2004, 2005
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* IBM,
* AND/OR THEIR 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 <GL/gl.h>
#include "glxclient.h"
#include <GL/glxproto.h>
 
CARD32
__glXReadReply(Display * dpy, size_t size, void *dest,
GLboolean reply_is_always_array)
{
xGLXSingleReply reply;
 
(void) _XReply(dpy, (xReply *) & reply, 0, False);
if (size != 0) {
if ((reply.length > 0) || reply_is_always_array) {
const GLint bytes = (reply_is_always_array)
? (4 * reply.length) : (reply.size * size);
const GLint extra = 4 - (bytes & 3);
 
_XRead(dpy, dest, bytes);
if (extra < 4) {
_XEatData(dpy, extra);
}
}
else {
(void) memcpy(dest, &(reply.pad3), size);
}
}
 
return reply.retval;
}
 
void
__glXReadPixelReply(Display * dpy, struct glx_context * gc, unsigned max_dim,
GLint width, GLint height, GLint depth, GLenum format,
GLenum type, void *dest, GLboolean dimensions_in_reply)
{
xGLXSingleReply reply;
GLint size;
 
(void) _XReply(dpy, (xReply *) & reply, 0, False);
 
if (dimensions_in_reply) {
width = reply.pad3;
height = reply.pad4;
depth = reply.pad5;
 
if ((height == 0) || (max_dim < 2)) {
height = 1;
}
if ((depth == 0) || (max_dim < 3)) {
depth = 1;
}
}
 
size = reply.length * 4;
if (size != 0) {
void *buf = malloc(size);
 
if (buf == NULL) {
_XEatData(dpy, size);
__glXSetError(gc, GL_OUT_OF_MEMORY);
}
else {
const GLint extra = 4 - (size & 3);
 
_XRead(dpy, buf, size);
if (extra < 4) {
_XEatData(dpy, extra);
}
 
__glEmptyImage(gc, 3, width, height, depth, format, type, buf, dest);
free(buf);
}
}
}
 
#if 0
GLubyte *
__glXSetupSingleRequest(struct glx_context * gc, GLint sop, GLint cmdlen)
{
xGLXSingleReq *req;
Display *const dpy = gc->currentDpy;
 
(void) __glXFlushRenderBuffer(gc, gc->pc);
LockDisplay(dpy);
GetReqExtra(GLXSingle, cmdlen, req);
req->reqType = gc->majorOpcode;
req->contextTag = gc->currentContextTag;
req->glxCode = sop;
return (GLubyte *) (req) + sz_xGLXSingleReq;
}
#endif
 
GLubyte *
__glXSetupVendorRequest(struct glx_context * gc, GLint code, GLint vop,
GLint cmdlen)
{
xGLXVendorPrivateReq *req;
Display *const dpy = gc->currentDpy;
 
(void) __glXFlushRenderBuffer(gc, gc->pc);
LockDisplay(dpy);
GetReqExtra(GLXVendorPrivate, cmdlen, req);
req->reqType = gc->majorOpcode;
req->glxCode = code;
req->vendorCode = vop;
req->contextTag = gc->currentContextTag;
return (GLubyte *) (req) + sz_xGLXVendorPrivateReq;
}
/contrib/sdk/sources/Mesa/src/glx/applegl_glx.c
0,0 → 1,195
/*
* Copyright © 2010 Intel Corporation
* Copyright © 2011 Apple Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Soft-
* ware"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, provided that the above copyright
* notice(s) and this permission notice appear in all copies of the Soft-
* ware and that both the above copyright notice(s) and this permission
* notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
* QUENTIAL 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 PERFOR-
* MANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder shall
* not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization of
* the copyright holder.
*
* Authors:
* Kristian Høgsberg (krh@bitplanet.net)
*/
 
#if defined(GLX_USE_APPLEGL)
 
#include <stdbool.h>
#include <dlfcn.h>
 
#include "glxclient.h"
#include "apple_glx_context.h"
#include "apple_glx.h"
#include "apple_cgl.h"
#include "glx_error.h"
 
static void
applegl_destroy_context(struct glx_context *gc)
{
apple_glx_destroy_context(&gc->driContext, gc->psc->dpy);
}
 
static int
applegl_bind_context(struct glx_context *gc, struct glx_context *old,
GLXDrawable draw, GLXDrawable read)
{
Display *dpy = gc->psc->dpy;
bool error = apple_glx_make_current_context(dpy,
(old && old != &dummyContext) ? old->driContext : NULL,
gc ? gc->driContext : NULL, draw);
 
apple_glx_diagnostic("%s: error %s\n", __func__, error ? "YES" : "NO");
if (error)
return 1; /* GLXBadContext is the same as Success (0) */
 
apple_glapi_set_dispatch();
 
return Success;
}
 
static void
applegl_unbind_context(struct glx_context *gc, struct glx_context *new)
{
Display *dpy;
bool error;
 
/* If we don't have a context, then we have nothing to unbind */
if (!gc)
return;
 
/* If we have a new context, keep this one around and remove it during bind. */
if (new)
return;
 
dpy = gc->psc->dpy;
 
error = apple_glx_make_current_context(dpy,
(gc != &dummyContext) ? gc->driContext : NULL,
NULL, None);
 
apple_glx_diagnostic("%s: error %s\n", __func__, error ? "YES" : "NO");
}
 
static void
applegl_wait_gl(struct glx_context *gc)
{
glFinish();
}
 
static void
applegl_wait_x(struct glx_context *gc)
{
Display *dpy = gc->psc->dpy;
apple_glx_waitx(dpy, gc->driContext);
}
 
static void *
applegl_get_proc_address(const char *symbol)
{
return dlsym(apple_cgl_get_dl_handle(), symbol);
}
 
static const struct glx_context_vtable applegl_context_vtable = {
applegl_destroy_context,
applegl_bind_context,
applegl_unbind_context,
applegl_wait_gl,
applegl_wait_x,
DRI_glXUseXFont,
NULL, /* bind_tex_image, */
NULL, /* release_tex_image, */
applegl_get_proc_address,
};
 
struct glx_context *
applegl_create_context(struct glx_screen *psc,
struct glx_config *config,
struct glx_context *shareList, int renderType)
{
struct glx_context *gc;
int errorcode;
bool x11error;
Display *dpy = psc->dpy;
int screen = psc->scr;
 
/* TODO: Integrate this with apple_glx_create_context and make
* struct apple_glx_context inherit from struct glx_context. */
 
gc = calloc(1, sizeof(*gc));
if (gc == NULL)
return NULL;
 
if (!glx_context_init(gc, psc, config)) {
free(gc);
return NULL;
}
 
gc->vtable = &applegl_context_vtable;
gc->driContext = NULL;
 
/* TODO: darwin: Integrate with above to do indirect */
if(apple_glx_create_context(&gc->driContext, dpy, screen, config,
shareList ? shareList->driContext : NULL,
&errorcode, &x11error)) {
__glXSendError(dpy, errorcode, 0, X_GLXCreateContext, x11error);
gc->vtable->destroy(gc);
return NULL;
}
 
gc->currentContextTag = -1;
gc->config = config;
gc->isDirect = GL_TRUE;
gc->xid = 1; /* Just something not None, so we know when to destroy
* it in MakeContextCurrent. */
 
return gc;
}
 
struct glx_screen_vtable applegl_screen_vtable = {
applegl_create_context
};
 
_X_HIDDEN struct glx_screen *
applegl_create_screen(int screen, struct glx_display * priv)
{
struct glx_screen *psc;
 
psc = calloc(1, sizeof *psc);
if (psc == NULL)
return NULL;
 
glx_screen_init(psc, screen, priv);
psc->vtable = &applegl_screen_vtable;
 
return psc;
}
 
_X_HIDDEN int
applegl_create_display(struct glx_display *glx_dpy)
{
if(!apple_init_glx(glx_dpy->dpy))
return 1;
 
return GLXBadContext;
}
 
#endif
/contrib/sdk/sources/Mesa/src/glx/clientattrib.c
0,0 → 1,144
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
#include <assert.h>
#include "glxclient.h"
#include "indirect.h"
#include "indirect_vertex_array.h"
 
/*****************************************************************************/
 
#ifndef GLX_USE_APPLEGL
static void
do_enable_disable(GLenum array, GLboolean val)
{
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
unsigned index = 0;
 
if (array == GL_TEXTURE_COORD_ARRAY) {
index = __glXGetActiveTextureUnit(state);
}
 
if (!__glXSetArrayEnable(state, array, index, val)) {
__glXSetError(gc, GL_INVALID_ENUM);
}
}
 
void
__indirect_glEnableClientState(GLenum array)
{
do_enable_disable(array, GL_TRUE);
}
 
void
__indirect_glDisableClientState(GLenum array)
{
do_enable_disable(array, GL_FALSE);
}
 
/************************************************************************/
 
void
__indirect_glPushClientAttrib(GLuint mask)
{
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
__GLXattribute **spp = gc->attributes.stackPointer, *sp;
 
if (spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]) {
if (!(sp = *spp)) {
sp = malloc(sizeof(__GLXattribute));
*spp = sp;
}
sp->mask = mask;
gc->attributes.stackPointer = spp + 1;
if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
sp->storePack = state->storePack;
sp->storeUnpack = state->storeUnpack;
}
if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
__glXPushArrayState(state);
}
}
else {
__glXSetError(gc, GL_STACK_OVERFLOW);
return;
}
}
 
void
__indirect_glPopClientAttrib(void)
{
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
__GLXattribute **spp = gc->attributes.stackPointer, *sp;
GLuint mask;
 
if (spp > &gc->attributes.stack[0]) {
--spp;
sp = *spp;
assert(sp != 0);
mask = sp->mask;
gc->attributes.stackPointer = spp;
 
if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
state->storePack = sp->storePack;
state->storeUnpack = sp->storeUnpack;
}
if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
__glXPopArrayState(state);
}
 
sp->mask = 0;
}
else {
__glXSetError(gc, GL_STACK_UNDERFLOW);
return;
}
}
#endif
 
void
__glFreeAttributeState(struct glx_context * gc)
{
__GLXattribute *sp, **spp;
 
for (spp = &gc->attributes.stack[0];
spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]; spp++) {
sp = *spp;
if (sp) {
free((char *) sp);
}
else {
break;
}
}
}
/contrib/sdk/sources/Mesa/src/glx/clientinfo.c
0,0 → 1,156
/*
* Copyright © 2011 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
 
#include <string.h>
#include <ctype.h>
 
#include "glxclient.h"
#include <xcb/glx.h>
#include <X11/Xlib-xcb.h>
 
_X_HIDDEN void
__glX_send_client_info(struct glx_display *glx_dpy)
{
const unsigned ext_length = strlen("GLX_ARB_create_context");
const unsigned prof_length = strlen("_profile");
char *gl_extension_string;
int gl_extension_length;
xcb_connection_t *c;
Bool any_screen_has_ARB_create_context = False;
Bool any_screen_has_ARB_create_context_profile = False;
unsigned i;
static const uint32_t gl_versions[] = {
1, 4,
};
static const uint32_t gl_versions_profiles[] = {
1, 4, 0x00000000,
};
static const char glx_extensions[] =
"GLX_ARB_create_context GLX_ARB_create_context_profile";
 
/* There are three possible flavors of the client info structure that the
* client could send to the server. The version sent depends on the
* combination of GLX versions and extensions supported by the client and
* the server.
*
* Server supports Client sends
* ----------------------------------------------------------------------
* GLX version = 1.0 Nothing.
*
* GLX version >= 1.1 struct GLXClientInfo
*
* GLX version >= 1.4 and
* GLX_ARB_create_context struct glXSetClientInfoARB
*
* GLX version >= 1.4 and
* GLX_ARB_create_context_profile struct glXSetClientInfo2ARB
*
* GLX_ARB_create_context and GLX_ARB_create_context_profile use FBConfigs,
* and these only exist in GLX 1.4 or with GLX_SGIX_fbconfig. I can't
* imagine an implementation that supports GLX_SGIX_fbconfig and
* GLX_ARB_create_context but not GLX 1.4. Making GLX 1.4 a hard
* requirement in this case does not seem like a limitation.
*
* This library currently only supports struct GLXClientInfo.
*/
 
if (glx_dpy->majorVersion == 1 && glx_dpy->minorVersion == 0)
return;
 
/* Determine whether any screen on the server supports either of the
* create-context extensions.
*/
for (i = 0; i < ScreenCount(glx_dpy->dpy); i++) {
struct glx_screen *src = glx_dpy->screens[i];
 
const char *haystack = src->serverGLXexts;
while (haystack != NULL) {
char *match = strstr(haystack, "GLX_ARB_create_context");
 
if (match == NULL)
break;
 
match += ext_length;
 
switch (match[0]) {
case '\0':
case ' ':
any_screen_has_ARB_create_context = True;
break;
 
case '_':
if (strncmp(match, "_profile", prof_length) == 0
&& (match[prof_length] == '\0'
|| match[prof_length] == ' ')) {
any_screen_has_ARB_create_context_profile = True;
match += prof_length;
}
break;
}
 
haystack = match;
}
}
 
gl_extension_string = __glXGetClientGLExtensionString();
gl_extension_length = strlen(gl_extension_string) + 1;
 
c = XGetXCBConnection(glx_dpy->dpy);
 
/* Depending on the GLX verion and the available extensions on the server,
* send the correct "flavor" of protocol to the server.
*
* THE ORDER IS IMPORTANT. We want to send the most recent version of the
* protocol that the server can support.
*/
if (glx_dpy->majorVersion == 1 && glx_dpy->minorVersion == 4
&& any_screen_has_ARB_create_context_profile) {
xcb_glx_set_client_info_2arb(c,
GLX_MAJOR_VERSION, GLX_MINOR_VERSION,
sizeof(gl_versions_profiles)
/ (3 * sizeof(gl_versions_profiles[0])),
gl_extension_length,
strlen(glx_extensions) + 1,
gl_versions_profiles,
gl_extension_string,
glx_extensions);
} else if (glx_dpy->majorVersion == 1 && glx_dpy->minorVersion == 4
&& any_screen_has_ARB_create_context) {
xcb_glx_set_client_info_arb(c,
GLX_MAJOR_VERSION, GLX_MINOR_VERSION,
sizeof(gl_versions)
/ (2 * sizeof(gl_versions[0])),
gl_extension_length,
strlen(glx_extensions) + 1,
gl_versions,
gl_extension_string,
glx_extensions);
} else {
xcb_glx_client_info(c,
GLX_MAJOR_VERSION, GLX_MINOR_VERSION,
gl_extension_length,
gl_extension_string);
}
 
free(gl_extension_string);
}
/contrib/sdk/sources/Mesa/src/glx/compsize.c
0,0 → 1,183
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
#include <GL/gl.h>
#include "glxclient.h"
 
/*
** Return the number of elements per group of a specified format
*/
GLint
__glElementsPerGroup(GLenum format, GLenum type)
{
/*
** To make row length computation valid for image extraction,
** packed pixel types assume elements per group equals one.
*/
switch (type) {
case GL_UNSIGNED_BYTE_3_3_2:
case GL_UNSIGNED_BYTE_2_3_3_REV:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_5_6_5_REV:
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
case GL_UNSIGNED_SHORT_5_5_5_1:
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
case GL_UNSIGNED_SHORT_8_8_APPLE:
case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
case GL_UNSIGNED_INT_8_8_8_8:
case GL_UNSIGNED_INT_8_8_8_8_REV:
case GL_UNSIGNED_INT_10_10_10_2:
case GL_UNSIGNED_INT_2_10_10_10_REV:
case GL_UNSIGNED_INT_24_8_NV:
return 1;
default:
break;
}
 
switch (format) {
case GL_RGB:
case GL_BGR:
return 3;
case GL_RG:
case GL_422_EXT:
case GL_422_REV_EXT:
case GL_422_AVERAGE_EXT:
case GL_422_REV_AVERAGE_EXT:
case GL_DEPTH_STENCIL_NV:
case GL_YCBCR_422_APPLE:
case GL_LUMINANCE_ALPHA:
return 2;
case GL_RGBA:
case GL_BGRA:
case GL_ABGR_EXT:
return 4;
case GL_COLOR_INDEX:
case GL_STENCIL_INDEX:
case GL_DEPTH_COMPONENT:
case GL_RED:
case GL_GREEN:
case GL_BLUE:
case GL_ALPHA:
case GL_LUMINANCE:
case GL_INTENSITY:
return 1;
default:
return 0;
}
}
 
/*
** Return the number of bytes per element, based on the element type (other
** than GL_BITMAP).
*/
GLint
__glBytesPerElement(GLenum type)
{
switch (type) {
case GL_UNSIGNED_SHORT:
case GL_SHORT:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_5_6_5_REV:
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
case GL_UNSIGNED_SHORT_5_5_5_1:
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
case GL_UNSIGNED_SHORT_8_8_APPLE:
case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
return 2;
case GL_UNSIGNED_BYTE:
case GL_BYTE:
case GL_UNSIGNED_BYTE_3_3_2:
case GL_UNSIGNED_BYTE_2_3_3_REV:
return 1;
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
case GL_UNSIGNED_INT_8_8_8_8:
case GL_UNSIGNED_INT_8_8_8_8_REV:
case GL_UNSIGNED_INT_10_10_10_2:
case GL_UNSIGNED_INT_2_10_10_10_REV:
case GL_UNSIGNED_INT_24_8_NV:
return 4;
default:
return 0;
}
}
 
/*
** Compute memory required for internal packed array of data of given type
** and format.
*/
GLint
__glImageSize(GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, GLenum target)
{
int bytes_per_row;
int components;
 
switch (target) {
case GL_PROXY_TEXTURE_1D:
case GL_PROXY_TEXTURE_2D:
case GL_PROXY_TEXTURE_3D:
case GL_PROXY_TEXTURE_4D_SGIS:
case GL_PROXY_TEXTURE_CUBE_MAP:
case GL_PROXY_TEXTURE_RECTANGLE_ARB:
case GL_PROXY_HISTOGRAM:
case GL_PROXY_COLOR_TABLE:
case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
case GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP:
return 0;
}
 
if (width < 0 || height < 0 || depth < 0) {
return 0;
}
 
/*
** Zero is returned if either format or type are invalid.
*/
components = __glElementsPerGroup(format, type);
if (type == GL_BITMAP) {
if (format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX) {
bytes_per_row = (width + 7) >> 3;
}
else {
return 0;
}
}
else {
bytes_per_row = __glBytesPerElement(type) * width;
}
 
return bytes_per_row * height * depth * components;
}
/contrib/sdk/sources/Mesa/src/glx/create_context.c
0,0 → 1,124
/*
* Copyright © 2011 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
 
#include <limits.h>
#include "glxclient.h"
#include "glx_error.h"
#include <xcb/glx.h>
#include <X11/Xlib-xcb.h>
 
#include <assert.h>
 
#if INT_MAX != 2147483647
#error This code requires sizeof(uint32_t) == sizeof(int).
#endif
 
_X_HIDDEN GLXContext
glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
GLXContext share_context, Bool direct,
const int *attrib_list)
{
xcb_connection_t *const c = XGetXCBConnection(dpy);
struct glx_config *const cfg = (struct glx_config *) config;
struct glx_context *const share = (struct glx_context *) share_context;
struct glx_context *gc = NULL;
unsigned num_attribs = 0;
struct glx_screen *psc;
xcb_generic_error_t *err;
xcb_void_cookie_t cookie;
unsigned dummy_err = 0;
 
 
if (dpy == NULL || cfg == NULL)
return NULL;
 
/* This means that either the caller passed the wrong display pointer or
* one of the internal GLX data structures (probably the fbconfig) has an
* error. There is nothing sensible to do, so return an error.
*/
psc = GetGLXScreenConfigs(dpy, cfg->screen);
if (psc == NULL)
return NULL;
 
assert(cfg->screen == psc->scr);
 
/* Count the number of attributes specified by the application. All
* attributes appear in pairs, except the terminating None.
*/
if (attrib_list != NULL) {
for (/* empty */; attrib_list[num_attribs * 2] != 0; num_attribs++)
/* empty */ ;
}
 
if (direct && psc->vtable->create_context_attribs) {
/* GLX drops the error returned by the driver. The expectation is that
* an error will also be returned by the server. The server's error
* will be delivered to the application.
*/
gc = psc->vtable->create_context_attribs(psc, cfg, share, num_attribs,
(const uint32_t *) attrib_list,
&dummy_err);
}
 
if (gc == NULL) {
#ifdef GLX_USE_APPLEGL
gc = applegl_create_context(psc, cfg, share, 0);
#else
gc = indirect_create_context_attribs(psc, cfg, share, num_attribs,
(const uint32_t *) attrib_list,
&dummy_err);
#endif
}
 
gc->xid = xcb_generate_id(c);
gc->share_xid = (share != NULL) ? share->xid : 0;
 
/* The manual pages for glXCreateContext and glXCreateNewContext say:
*
* "NULL is returned if execution fails on the client side."
*
* If the server generates an error, the application is supposed to catch
* the protocol error and handle it. Part of handling the error is freeing
* the possibly non-NULL value returned by this function.
*/
cookie =
xcb_glx_create_context_attribs_arb_checked(c,
gc->xid,
cfg->fbconfigID,
cfg->screen,
gc->share_xid,
gc->isDirect,
num_attribs,
(const uint32_t *)
attrib_list);
err = xcb_request_check(c, cookie);
if (err != NULL) {
gc->vtable->destroy(gc);
gc = NULL;
 
__glXSendErrorForXcb(dpy, err);
free(err);
}
 
return (GLXContext) gc;
}
/contrib/sdk/sources/Mesa/src/glx/dri2.c
0,0 → 1,544
/*
* Copyright © 2008 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Soft-
* ware"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, provided that the above copyright
* notice(s) and this permission notice appear in all copies of the Soft-
* ware and that both the above copyright notice(s) and this permission
* notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
* QUENTIAL 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 PERFOR-
* MANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder shall
* not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization of
* the copyright holder.
*
* Authors:
* Kristian Høgsberg (krh@redhat.com)
*/
 
 
#ifdef GLX_DIRECT_RENDERING
 
#include <stdio.h>
#include <X11/Xlibint.h>
#include <X11/extensions/Xext.h>
#include <X11/extensions/extutil.h>
#include <X11/extensions/dri2proto.h>
#include "xf86drm.h"
#include "dri2.h"
#include "glxclient.h"
#include "GL/glxext.h"
 
/* Allow the build to work with an older versions of dri2proto.h and
* dri2tokens.h.
*/
#if DRI2_MINOR < 1
#undef DRI2_MINOR
#define DRI2_MINOR 1
#define X_DRI2GetBuffersWithFormat 7
#endif
 
 
static char dri2ExtensionName[] = DRI2_NAME;
static XExtensionInfo *dri2Info;
static XEXT_GENERATE_CLOSE_DISPLAY (DRI2CloseDisplay, dri2Info)
 
static Bool
DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire);
static Status
DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire);
static int
DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code);
 
static /* const */ XExtensionHooks dri2ExtensionHooks = {
NULL, /* create_gc */
NULL, /* copy_gc */
NULL, /* flush_gc */
NULL, /* free_gc */
NULL, /* create_font */
NULL, /* free_font */
DRI2CloseDisplay, /* close_display */
DRI2WireToEvent, /* wire_to_event */
DRI2EventToWire, /* event_to_wire */
DRI2Error, /* error */
NULL, /* error_string */
};
 
static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay,
dri2Info,
dri2ExtensionName,
&dri2ExtensionHooks,
0, NULL)
 
static Bool
DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
struct glx_drawable *glxDraw;
 
XextCheckExtension(dpy, info, dri2ExtensionName, False);
 
switch ((wire->u.u.type & 0x7f) - info->codes->first_event) {
 
#ifdef X_DRI2SwapBuffers
case DRI2_BufferSwapComplete:
{
GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
xDRI2BufferSwapComplete2 *awire = (xDRI2BufferSwapComplete2 *)wire;
__GLXDRIdrawable *pdraw;
 
pdraw = dri2GetGlxDrawableFromXDrawableId(dpy, awire->drawable);
 
/* Ignore swap events if we're not looking for them */
aevent->type = dri2GetSwapEventType(dpy, awire->drawable);
if(!aevent->type)
return False;
 
aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire);
aevent->send_event = (awire->type & 0x80) != 0;
aevent->display = dpy;
aevent->drawable = awire->drawable;
switch (awire->event_type) {
case DRI2_EXCHANGE_COMPLETE:
aevent->event_type = GLX_EXCHANGE_COMPLETE_INTEL;
break;
case DRI2_BLIT_COMPLETE:
aevent->event_type = GLX_COPY_COMPLETE_INTEL;
break;
case DRI2_FLIP_COMPLETE:
aevent->event_type = GLX_FLIP_COMPLETE_INTEL;
break;
default:
/* unknown swap completion type */
return False;
}
aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
 
glxDraw = GetGLXDrawable(dpy, pdraw->drawable);
if (awire->sbc < glxDraw->lastEventSbc)
glxDraw->eventSbcWrap += 0x100000000;
glxDraw->lastEventSbc = awire->sbc;
aevent->sbc = awire->sbc + glxDraw->eventSbcWrap;
 
return True;
}
#endif
#ifdef DRI2_InvalidateBuffers
case DRI2_InvalidateBuffers:
{
xDRI2InvalidateBuffers *awire = (xDRI2InvalidateBuffers *)wire;
 
dri2InvalidateBuffers(dpy, awire->drawable);
return False;
}
#endif
default:
/* client doesn't support server event */
break;
}
 
return False;
}
 
/* We don't actually support this. It doesn't make sense for clients to
* send each other DRI2 events.
*/
static Status
DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
 
XextCheckExtension(dpy, info, dri2ExtensionName, False);
 
switch (event->type) {
default:
/* client doesn't support server event */
break;
}
 
return Success;
}
 
static int
DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code)
{
if (err->majorCode == codes->major_opcode &&
err->errorCode == BadDrawable &&
err->minorCode == X_DRI2CopyRegion)
return True;
 
/* If the X drawable was destroyed before the GLX drawable, the
* DRI2 drawble will be gone by the time we call
* DRI2DestroyDrawable. So just ignore BadDrawable here. */
if (err->majorCode == codes->major_opcode &&
err->errorCode == BadDrawable &&
err->minorCode == X_DRI2DestroyDrawable)
return True;
 
/* If the server is non-local DRI2Connect will raise BadRequest.
* Swallow this so that DRI2Connect can signal this in its return code */
if (err->majorCode == codes->major_opcode &&
err->minorCode == X_DRI2Connect &&
err->errorCode == BadRequest) {
*ret_code = False;
return True;
}
 
return False;
}
 
Bool
DRI2QueryExtension(Display * dpy, int *eventBase, int *errorBase)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
 
if (XextHasExtension(info)) {
*eventBase = info->codes->first_event;
*errorBase = info->codes->first_error;
return True;
}
 
return False;
}
 
Bool
DRI2QueryVersion(Display * dpy, int *major, int *minor)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2QueryVersionReply rep;
xDRI2QueryVersionReq *req;
int i, nevents;
 
XextCheckExtension(dpy, info, dri2ExtensionName, False);
 
LockDisplay(dpy);
GetReq(DRI2QueryVersion, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2QueryVersion;
req->majorVersion = DRI2_MAJOR;
req->minorVersion = DRI2_MINOR;
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
*major = rep.majorVersion;
*minor = rep.minorVersion;
UnlockDisplay(dpy);
SyncHandle();
 
switch (rep.minorVersion) {
case 1:
nevents = 0;
break;
case 2:
nevents = 1;
break;
case 3:
default:
nevents = 2;
break;
}
for (i = 0; i < nevents; i++) {
XESetWireToEvent (dpy, info->codes->first_event + i, DRI2WireToEvent);
XESetEventToWire (dpy, info->codes->first_event + i, DRI2EventToWire);
}
 
return True;
}
 
Bool
DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2ConnectReply rep;
xDRI2ConnectReq *req;
 
XextCheckExtension(dpy, info, dri2ExtensionName, False);
 
LockDisplay(dpy);
GetReq(DRI2Connect, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2Connect;
req->window = window;
 
req->driverType = DRI2DriverDRI;
#ifdef DRI2DriverPrimeShift
{
char *prime = getenv("DRI_PRIME");
if (prime) {
uint32_t primeid;
errno = 0;
primeid = strtoul(prime, NULL, 0);
if (errno == 0)
req->driverType |=
((primeid & DRI2DriverPrimeMask) << DRI2DriverPrimeShift);
}
}
#endif
 
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
 
if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
 
*driverName = malloc(rep.driverNameLength + 1);
if (*driverName == NULL) {
_XEatData(dpy,
((rep.driverNameLength + 3) & ~3) +
((rep.deviceNameLength + 3) & ~3));
UnlockDisplay(dpy);
SyncHandle();
return False;
}
_XReadPad(dpy, *driverName, rep.driverNameLength);
(*driverName)[rep.driverNameLength] = '\0';
 
*deviceName = malloc(rep.deviceNameLength + 1);
if (*deviceName == NULL) {
free(*driverName);
_XEatData(dpy, ((rep.deviceNameLength + 3) & ~3));
UnlockDisplay(dpy);
SyncHandle();
return False;
}
_XReadPad(dpy, *deviceName, rep.deviceNameLength);
(*deviceName)[rep.deviceNameLength] = '\0';
 
UnlockDisplay(dpy);
SyncHandle();
 
return True;
}
 
Bool
DRI2Authenticate(Display * dpy, XID window, drm_magic_t magic)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2AuthenticateReq *req;
xDRI2AuthenticateReply rep;
 
XextCheckExtension(dpy, info, dri2ExtensionName, False);
 
LockDisplay(dpy);
GetReq(DRI2Authenticate, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2Authenticate;
req->window = window;
req->magic = magic;
 
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
 
UnlockDisplay(dpy);
SyncHandle();
 
return rep.authenticated;
}
 
void
DRI2CreateDrawable(Display * dpy, XID drawable)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2CreateDrawableReq *req;
 
XextSimpleCheckExtension(dpy, info, dri2ExtensionName);
 
LockDisplay(dpy);
GetReq(DRI2CreateDrawable, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2CreateDrawable;
req->drawable = drawable;
UnlockDisplay(dpy);
SyncHandle();
}
 
void
DRI2DestroyDrawable(Display * dpy, XID drawable)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2DestroyDrawableReq *req;
 
XextSimpleCheckExtension(dpy, info, dri2ExtensionName);
 
XSync(dpy, False);
 
LockDisplay(dpy);
GetReq(DRI2DestroyDrawable, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2DestroyDrawable;
req->drawable = drawable;
UnlockDisplay(dpy);
SyncHandle();
}
 
DRI2Buffer *
DRI2GetBuffers(Display * dpy, XID drawable,
int *width, int *height,
unsigned int *attachments, int count, int *outCount)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2GetBuffersReply rep;
xDRI2GetBuffersReq *req;
DRI2Buffer *buffers;
xDRI2Buffer repBuffer;
CARD32 *p;
int i;
 
XextCheckExtension(dpy, info, dri2ExtensionName, False);
 
LockDisplay(dpy);
GetReqExtra(DRI2GetBuffers, count * 4, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2GetBuffers;
req->drawable = drawable;
req->count = count;
p = (CARD32 *) & req[1];
for (i = 0; i < count; i++)
p[i] = attachments[i];
 
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return NULL;
}
 
*width = rep.width;
*height = rep.height;
*outCount = rep.count;
 
buffers = malloc(rep.count * sizeof buffers[0]);
if (buffers == NULL) {
_XEatData(dpy, rep.count * sizeof repBuffer);
UnlockDisplay(dpy);
SyncHandle();
return NULL;
}
 
for (i = 0; i < rep.count; i++) {
_XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
buffers[i].attachment = repBuffer.attachment;
buffers[i].name = repBuffer.name;
buffers[i].pitch = repBuffer.pitch;
buffers[i].cpp = repBuffer.cpp;
buffers[i].flags = repBuffer.flags;
}
 
UnlockDisplay(dpy);
SyncHandle();
 
return buffers;
}
 
 
DRI2Buffer *
DRI2GetBuffersWithFormat(Display * dpy, XID drawable,
int *width, int *height,
unsigned int *attachments, int count, int *outCount)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2GetBuffersReply rep;
xDRI2GetBuffersReq *req;
DRI2Buffer *buffers;
xDRI2Buffer repBuffer;
CARD32 *p;
int i;
 
XextCheckExtension(dpy, info, dri2ExtensionName, False);
 
LockDisplay(dpy);
GetReqExtra(DRI2GetBuffers, count * (4 * 2), req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2GetBuffersWithFormat;
req->drawable = drawable;
req->count = count;
p = (CARD32 *) & req[1];
for (i = 0; i < (count * 2); i++)
p[i] = attachments[i];
 
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return NULL;
}
 
*width = rep.width;
*height = rep.height;
*outCount = rep.count;
 
buffers = malloc(rep.count * sizeof buffers[0]);
if (buffers == NULL) {
_XEatData(dpy, rep.count * sizeof repBuffer);
UnlockDisplay(dpy);
SyncHandle();
return NULL;
}
 
for (i = 0; i < rep.count; i++) {
_XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
buffers[i].attachment = repBuffer.attachment;
buffers[i].name = repBuffer.name;
buffers[i].pitch = repBuffer.pitch;
buffers[i].cpp = repBuffer.cpp;
buffers[i].flags = repBuffer.flags;
}
 
UnlockDisplay(dpy);
SyncHandle();
 
return buffers;
}
 
 
void
DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region,
CARD32 dest, CARD32 src)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2CopyRegionReq *req;
xDRI2CopyRegionReply rep;
 
XextSimpleCheckExtension(dpy, info, dri2ExtensionName);
 
LockDisplay(dpy);
GetReq(DRI2CopyRegion, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2CopyRegion;
req->drawable = drawable;
req->region = region;
req->dest = dest;
req->src = src;
 
_XReply(dpy, (xReply *) & rep, 0, xFalse);
 
UnlockDisplay(dpy);
SyncHandle();
}
 
#endif /* GLX_DIRECT_RENDERING */
/contrib/sdk/sources/Mesa/src/glx/dri2.h
0,0 → 1,88
/*
* Copyright © 2007,2008 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Soft-
* ware"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, provided that the above copyright
* notice(s) and this permission notice appear in all copies of the Soft-
* ware and that both the above copyright notice(s) and this permission
* notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
* QUENTIAL 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 PERFOR-
* MANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder shall
* not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization of
* the copyright holder.
*
* Authors:
* Kristian Høgsberg (krh@redhat.com)
*/
 
#ifndef _DRI2_H_
#define _DRI2_H_
 
#include <X11/extensions/Xfixes.h>
#include <X11/extensions/dri2tokens.h>
 
typedef struct
{
unsigned int attachment;
unsigned int name;
unsigned int pitch;
unsigned int cpp;
unsigned int flags;
} DRI2Buffer;
 
extern Bool
DRI2QueryExtension(Display * display, int *eventBase, int *errorBase);
 
extern Bool
DRI2QueryVersion(Display * display, int *major, int *minor);
 
extern Bool
DRI2Connect(Display * display, XID window,
char **driverName, char **deviceName);
 
extern Bool
DRI2Authenticate(Display * display, XID window, drm_magic_t magic);
 
extern void
DRI2CreateDrawable(Display * display, XID drawable);
 
extern void
DRI2DestroyDrawable(Display * display, XID handle);
 
extern DRI2Buffer*
DRI2GetBuffers(Display * dpy, XID drawable,
int *width, int *height,
unsigned int *attachments, int count,
int *outCount);
 
/**
* \note
* This function is only supported with DRI2 version 1.1 or later.
*/
extern DRI2Buffer*
DRI2GetBuffersWithFormat(Display * dpy, XID drawable,
int *width, int *height,
unsigned int *attachments,
int count, int *outCount);
 
extern void
DRI2CopyRegion(Display * dpy, XID drawable,
XserverRegion region,
CARD32 dest, CARD32 src);
 
#endif
/contrib/sdk/sources/Mesa/src/glx/dri2_glx.c
0,0 → 1,1388
/*
* Copyright © 2008 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Soft-
* ware"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, provided that the above copyright
* notice(s) and this permission notice appear in all copies of the Soft-
* ware and that both the above copyright notice(s) and this permission
* notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
* QUENTIAL 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 PERFOR-
* MANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder shall
* not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization of
* the copyright holder.
*
* Authors:
* Kristian Høgsberg (krh@redhat.com)
*/
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
 
#include <X11/Xlib.h>
#include <X11/extensions/Xfixes.h>
#include <X11/Xlib-xcb.h>
#include <xcb/xcb.h>
#include <xcb/dri2.h>
#include "glapi.h"
#include "glxclient.h"
#include <X11/extensions/dri2proto.h>
#include "xf86dri.h"
#include <dlfcn.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/time.h>
#include "xf86drm.h"
#include "dri2.h"
#include "dri_common.h"
 
/* From xmlpool/options.h, user exposed so should be stable */
#define DRI_CONF_VBLANK_NEVER 0
#define DRI_CONF_VBLANK_DEF_INTERVAL_0 1
#define DRI_CONF_VBLANK_DEF_INTERVAL_1 2
#define DRI_CONF_VBLANK_ALWAYS_SYNC 3
 
#undef DRI2_MINOR
#define DRI2_MINOR 1
 
struct dri2_display
{
__GLXDRIdisplay base;
 
/*
** XFree86-DRI version information
*/
int driMajor;
int driMinor;
int driPatch;
int swapAvailable;
int invalidateAvailable;
 
__glxHashTable *dri2Hash;
 
const __DRIextension *loader_extensions[4];
};
 
struct dri2_screen {
struct glx_screen base;
 
__DRIscreen *driScreen;
__GLXDRIscreen vtable;
const __DRIdri2Extension *dri2;
const __DRIcoreExtension *core;
 
const __DRI2flushExtension *f;
const __DRI2configQueryExtension *config;
const __DRItexBufferExtension *texBuffer;
const __DRI2throttleExtension *throttle;
const __DRIconfig **driver_configs;
 
void *driver;
int fd;
 
Bool show_fps;
};
 
struct dri2_context
{
struct glx_context base;
__DRIcontext *driContext;
};
 
struct dri2_drawable
{
__GLXDRIdrawable base;
__DRIdrawable *driDrawable;
__DRIbuffer buffers[5];
int bufferCount;
int width, height;
int have_back;
int have_fake_front;
int swap_interval;
 
uint64_t previous_time;
unsigned frames;
};
 
static const struct glx_context_vtable dri2_context_vtable;
 
/* For XCB's handling of ust/msc/sbc counters, we have to hand it the high and
* low halves separately. This helps you split them.
*/
static void
split_counter(uint64_t counter, uint32_t *hi, uint32_t *lo)
{
*hi = (counter >> 32);
*lo = counter & 0xffffffff;
}
 
static uint64_t
merge_counter(uint32_t hi, uint32_t lo)
{
return ((uint64_t)hi << 32) | lo;
}
 
static void
dri2_destroy_context(struct glx_context *context)
{
struct dri2_context *pcp = (struct dri2_context *) context;
struct dri2_screen *psc = (struct dri2_screen *) context->psc;
 
driReleaseDrawables(&pcp->base);
 
free((char *) context->extensions);
 
(*psc->core->destroyContext) (pcp->driContext);
 
free(pcp);
}
 
static Bool
dri2_bind_context(struct glx_context *context, struct glx_context *old,
GLXDrawable draw, GLXDrawable read)
{
struct dri2_context *pcp = (struct dri2_context *) context;
struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc;
struct dri2_drawable *pdraw, *pread;
struct dri2_display *pdp;
 
pdraw = (struct dri2_drawable *) driFetchDrawable(context, draw);
pread = (struct dri2_drawable *) driFetchDrawable(context, read);
 
driReleaseDrawables(&pcp->base);
 
if (pdraw == NULL || pread == NULL)
return GLXBadDrawable;
 
if (!(*psc->core->bindContext) (pcp->driContext,
pdraw->driDrawable, pread->driDrawable))
return GLXBadContext;
 
/* If the server doesn't send invalidate events, we may miss a
* resize before the rendering starts. Invalidate the buffers now
* so the driver will recheck before rendering starts. */
pdp = (struct dri2_display *) psc->base.display;
if (!pdp->invalidateAvailable) {
dri2InvalidateBuffers(psc->base.dpy, pdraw->base.xDrawable);
if (pread != pdraw)
dri2InvalidateBuffers(psc->base.dpy, pread->base.xDrawable);
}
 
return Success;
}
 
static void
dri2_unbind_context(struct glx_context *context, struct glx_context *new)
{
struct dri2_context *pcp = (struct dri2_context *) context;
struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc;
 
(*psc->core->unbindContext) (pcp->driContext);
}
 
static struct glx_context *
dri2_create_context(struct glx_screen *base,
struct glx_config *config_base,
struct glx_context *shareList, int renderType)
{
struct dri2_context *pcp, *pcp_shared;
struct dri2_screen *psc = (struct dri2_screen *) base;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
__DRIcontext *shared = NULL;
 
/* Check the renderType value */
if (!validate_renderType_against_config(config_base, renderType))
return NULL;
 
if (shareList) {
/* If the shareList context is not a DRI2 context, we cannot possibly
* create a DRI2 context that shares it.
*/
if (shareList->vtable->destroy != dri2_destroy_context) {
return NULL;
}
 
pcp_shared = (struct dri2_context *) shareList;
shared = pcp_shared->driContext;
}
 
pcp = calloc(1, sizeof *pcp);
if (pcp == NULL)
return NULL;
 
if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
free(pcp);
return NULL;
}
 
pcp->base.renderType = renderType;
 
pcp->driContext =
(*psc->dri2->createNewContext) (psc->driScreen,
config->driConfig, shared, pcp);
 
if (pcp->driContext == NULL) {
free(pcp);
return NULL;
}
 
pcp->base.vtable = &dri2_context_vtable;
 
return &pcp->base;
}
 
static struct glx_context *
dri2_create_context_attribs(struct glx_screen *base,
struct glx_config *config_base,
struct glx_context *shareList,
unsigned num_attribs,
const uint32_t *attribs,
unsigned *error)
{
struct dri2_context *pcp = NULL;
struct dri2_context *pcp_shared = NULL;
struct dri2_screen *psc = (struct dri2_screen *) base;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
__DRIcontext *shared = NULL;
 
uint32_t minor_ver;
uint32_t major_ver;
uint32_t renderType;
uint32_t flags;
unsigned api;
int reset;
uint32_t ctx_attribs[2 * 5];
unsigned num_ctx_attribs = 0;
 
if (psc->dri2->base.version < 3) {
*error = __DRI_CTX_ERROR_NO_MEMORY;
goto error_exit;
}
 
/* Remap the GLX tokens to DRI2 tokens.
*/
if (!dri2_convert_glx_attribs(num_attribs, attribs,
&major_ver, &minor_ver, &renderType, &flags,
&api, &reset, error))
goto error_exit;
 
/* Check the renderType value */
if (!validate_renderType_against_config(config_base, renderType))
goto error_exit;
 
if (shareList) {
pcp_shared = (struct dri2_context *) shareList;
shared = pcp_shared->driContext;
}
 
pcp = calloc(1, sizeof *pcp);
if (pcp == NULL) {
*error = __DRI_CTX_ERROR_NO_MEMORY;
goto error_exit;
}
 
if (!glx_context_init(&pcp->base, &psc->base, &config->base))
goto error_exit;
 
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MAJOR_VERSION;
ctx_attribs[num_ctx_attribs++] = major_ver;
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MINOR_VERSION;
ctx_attribs[num_ctx_attribs++] = minor_ver;
 
/* Only send a value when the non-default value is requested. By doing
* this we don't have to check the driver's DRI2 version before sending the
* default value.
*/
if (reset != __DRI_CTX_RESET_NO_NOTIFICATION) {
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_RESET_STRATEGY;
ctx_attribs[num_ctx_attribs++] = reset;
}
 
if (flags != 0) {
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_FLAGS;
 
/* The current __DRI_CTX_FLAG_* values are identical to the
* GLX_CONTEXT_*_BIT values.
*/
ctx_attribs[num_ctx_attribs++] = flags;
}
 
/* The renderType is retrieved from attribs, or set to default
* of GLX_RGBA_TYPE.
*/
pcp->base.renderType = renderType;
 
pcp->driContext =
(*psc->dri2->createContextAttribs) (psc->driScreen,
api,
config->driConfig,
shared,
num_ctx_attribs / 2,
ctx_attribs,
error,
pcp);
 
if (pcp->driContext == NULL)
goto error_exit;
 
pcp->base.vtable = &dri2_context_vtable;
 
return &pcp->base;
 
error_exit:
free(pcp);
 
return NULL;
}
 
static void
dri2DestroyDrawable(__GLXDRIdrawable *base)
{
struct dri2_screen *psc = (struct dri2_screen *) base->psc;
struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
struct glx_display *dpyPriv = psc->base.display;
struct dri2_display *pdp = (struct dri2_display *)dpyPriv->dri2Display;
 
__glxHashDelete(pdp->dri2Hash, pdraw->base.xDrawable);
(*psc->core->destroyDrawable) (pdraw->driDrawable);
 
/* If it's a GLX 1.3 drawables, we can destroy the DRI2 drawable
* now, as the application explicitly asked to destroy the GLX
* drawable. Otherwise, for legacy drawables, we let the DRI2
* drawable linger on the server, since there's no good way of
* knowing when the application is done with it. The server will
* destroy the DRI2 drawable when it destroys the X drawable or the
* client exits anyway. */
if (pdraw->base.xDrawable != pdraw->base.drawable)
DRI2DestroyDrawable(psc->base.dpy, pdraw->base.xDrawable);
 
free(pdraw);
}
 
static __GLXDRIdrawable *
dri2CreateDrawable(struct glx_screen *base, XID xDrawable,
GLXDrawable drawable, struct glx_config *config_base)
{
struct dri2_drawable *pdraw;
struct dri2_screen *psc = (struct dri2_screen *) base;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
struct glx_display *dpyPriv;
struct dri2_display *pdp;
GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
 
pdraw = calloc(1, sizeof(*pdraw));
if (!pdraw)
return NULL;
 
pdraw->base.destroyDrawable = dri2DestroyDrawable;
pdraw->base.xDrawable = xDrawable;
pdraw->base.drawable = drawable;
pdraw->base.psc = &psc->base;
pdraw->bufferCount = 0;
pdraw->swap_interval = 1; /* default may be overridden below */
pdraw->have_back = 0;
 
if (psc->config)
psc->config->configQueryi(psc->driScreen,
"vblank_mode", &vblank_mode);
 
switch (vblank_mode) {
case DRI_CONF_VBLANK_NEVER:
case DRI_CONF_VBLANK_DEF_INTERVAL_0:
pdraw->swap_interval = 0;
break;
case DRI_CONF_VBLANK_DEF_INTERVAL_1:
case DRI_CONF_VBLANK_ALWAYS_SYNC:
default:
pdraw->swap_interval = 1;
break;
}
 
DRI2CreateDrawable(psc->base.dpy, xDrawable);
 
dpyPriv = __glXInitialize(psc->base.dpy);
pdp = (struct dri2_display *)dpyPriv->dri2Display;;
/* Create a new drawable */
pdraw->driDrawable =
(*psc->dri2->createNewDrawable) (psc->driScreen,
config->driConfig, pdraw);
 
if (!pdraw->driDrawable) {
DRI2DestroyDrawable(psc->base.dpy, xDrawable);
free(pdraw);
return NULL;
}
 
if (__glxHashInsert(pdp->dri2Hash, xDrawable, pdraw)) {
(*psc->core->destroyDrawable) (pdraw->driDrawable);
DRI2DestroyDrawable(psc->base.dpy, xDrawable);
free(pdraw);
return None;
}
 
/*
* Make sure server has the same swap interval we do for the new
* drawable.
*/
if (psc->vtable.setSwapInterval)
psc->vtable.setSwapInterval(&pdraw->base, pdraw->swap_interval);
 
return &pdraw->base;
}
 
static int
dri2DrawableGetMSC(struct glx_screen *psc, __GLXDRIdrawable *pdraw,
int64_t *ust, int64_t *msc, int64_t *sbc)
{
xcb_connection_t *c = XGetXCBConnection(pdraw->psc->dpy);
xcb_dri2_get_msc_cookie_t get_msc_cookie;
xcb_dri2_get_msc_reply_t *get_msc_reply;
 
get_msc_cookie = xcb_dri2_get_msc_unchecked(c, pdraw->xDrawable);
get_msc_reply = xcb_dri2_get_msc_reply(c, get_msc_cookie, NULL);
 
if (!get_msc_reply)
return 0;
 
*ust = merge_counter(get_msc_reply->ust_hi, get_msc_reply->ust_lo);
*msc = merge_counter(get_msc_reply->msc_hi, get_msc_reply->msc_lo);
*sbc = merge_counter(get_msc_reply->sbc_hi, get_msc_reply->sbc_lo);
free(get_msc_reply);
 
return 1;
}
 
static int
dri2WaitForMSC(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc)
{
xcb_connection_t *c = XGetXCBConnection(pdraw->psc->dpy);
xcb_dri2_wait_msc_cookie_t wait_msc_cookie;
xcb_dri2_wait_msc_reply_t *wait_msc_reply;
uint32_t target_msc_hi, target_msc_lo;
uint32_t divisor_hi, divisor_lo;
uint32_t remainder_hi, remainder_lo;
 
split_counter(target_msc, &target_msc_hi, &target_msc_lo);
split_counter(divisor, &divisor_hi, &divisor_lo);
split_counter(remainder, &remainder_hi, &remainder_lo);
 
wait_msc_cookie = xcb_dri2_wait_msc_unchecked(c, pdraw->xDrawable,
target_msc_hi, target_msc_lo,
divisor_hi, divisor_lo,
remainder_hi, remainder_lo);
wait_msc_reply = xcb_dri2_wait_msc_reply(c, wait_msc_cookie, NULL);
 
if (!wait_msc_reply)
return 0;
 
*ust = merge_counter(wait_msc_reply->ust_hi, wait_msc_reply->ust_lo);
*msc = merge_counter(wait_msc_reply->msc_hi, wait_msc_reply->msc_lo);
*sbc = merge_counter(wait_msc_reply->sbc_hi, wait_msc_reply->sbc_lo);
free(wait_msc_reply);
 
return 1;
}
 
static int
dri2WaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
int64_t *msc, int64_t *sbc)
{
xcb_connection_t *c = XGetXCBConnection(pdraw->psc->dpy);
xcb_dri2_wait_sbc_cookie_t wait_sbc_cookie;
xcb_dri2_wait_sbc_reply_t *wait_sbc_reply;
uint32_t target_sbc_hi, target_sbc_lo;
 
split_counter(target_sbc, &target_sbc_hi, &target_sbc_lo);
 
wait_sbc_cookie = xcb_dri2_wait_sbc_unchecked(c, pdraw->xDrawable,
target_sbc_hi, target_sbc_lo);
wait_sbc_reply = xcb_dri2_wait_sbc_reply(c, wait_sbc_cookie, NULL);
 
if (!wait_sbc_reply)
return 0;
 
*ust = merge_counter(wait_sbc_reply->ust_hi, wait_sbc_reply->ust_lo);
*msc = merge_counter(wait_sbc_reply->msc_hi, wait_sbc_reply->msc_lo);
*sbc = merge_counter(wait_sbc_reply->sbc_hi, wait_sbc_reply->sbc_lo);
free(wait_sbc_reply);
 
return 1;
}
 
static __DRIcontext *
dri2GetCurrentContext()
{
struct glx_context *gc = __glXGetCurrentContext();
struct dri2_context *dri2Ctx = (struct dri2_context *)gc;
 
return dri2Ctx ? dri2Ctx->driContext : NULL;
}
 
/**
* dri2Throttle - Request driver throttling
*
* This function uses the DRI2 throttle extension to give the
* driver the opportunity to throttle on flush front, copysubbuffer
* and swapbuffers.
*/
static void
dri2Throttle(struct dri2_screen *psc,
struct dri2_drawable *draw,
enum __DRI2throttleReason reason)
{
if (psc->throttle) {
__DRIcontext *ctx = dri2GetCurrentContext();
 
psc->throttle->throttle(ctx, draw->driDrawable, reason);
}
}
 
/**
* Asks the driver to flush any queued work necessary for serializing with the
* X command stream, and optionally the slightly more strict requirement of
* glFlush() equivalence (which would require flushing even if nothing had
* been drawn to a window system framebuffer, for example).
*/
static void
dri2Flush(struct dri2_screen *psc,
__DRIcontext *ctx,
struct dri2_drawable *draw,
unsigned flags,
enum __DRI2throttleReason throttle_reason)
{
if (ctx && psc->f && psc->f->base.version >= 4) {
psc->f->flush_with_flags(ctx, draw->driDrawable, flags, throttle_reason);
} else {
if (flags & __DRI2_FLUSH_CONTEXT)
glFlush();
 
if (psc->f)
psc->f->flush(draw->driDrawable);
 
dri2Throttle(psc, draw, throttle_reason);
}
}
 
static void
__dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y,
int width, int height,
enum __DRI2throttleReason reason, Bool flush)
{
struct dri2_drawable *priv = (struct dri2_drawable *) pdraw;
struct dri2_screen *psc = (struct dri2_screen *) pdraw->psc;
XRectangle xrect;
XserverRegion region;
__DRIcontext *ctx = dri2GetCurrentContext();
unsigned flags;
 
/* Check we have the right attachments */
if (!priv->have_back)
return;
 
xrect.x = x;
xrect.y = priv->height - y - height;
xrect.width = width;
xrect.height = height;
 
flags = __DRI2_FLUSH_DRAWABLE;
if (flush)
flags |= __DRI2_FLUSH_CONTEXT;
dri2Flush(psc, ctx, priv, flags, __DRI2_THROTTLE_SWAPBUFFER);
 
region = XFixesCreateRegion(psc->base.dpy, &xrect, 1);
DRI2CopyRegion(psc->base.dpy, pdraw->xDrawable, region,
DRI2BufferFrontLeft, DRI2BufferBackLeft);
 
/* Refresh the fake front (if present) after we just damaged the real
* front.
*/
if (priv->have_fake_front)
DRI2CopyRegion(psc->base.dpy, pdraw->xDrawable, region,
DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);
 
XFixesDestroyRegion(psc->base.dpy, region);
}
 
static void
dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y,
int width, int height, Bool flush)
{
__dri2CopySubBuffer(pdraw, x, y, width, height,
__DRI2_THROTTLE_COPYSUBBUFFER, flush);
}
 
 
static void
dri2_copy_drawable(struct dri2_drawable *priv, int dest, int src)
{
XRectangle xrect;
XserverRegion region;
struct dri2_screen *psc = (struct dri2_screen *) priv->base.psc;
 
xrect.x = 0;
xrect.y = 0;
xrect.width = priv->width;
xrect.height = priv->height;
 
if (psc->f)
(*psc->f->flush) (priv->driDrawable);
 
region = XFixesCreateRegion(psc->base.dpy, &xrect, 1);
DRI2CopyRegion(psc->base.dpy, priv->base.xDrawable, region, dest, src);
XFixesDestroyRegion(psc->base.dpy, region);
 
}
 
static void
dri2_wait_x(struct glx_context *gc)
{
struct dri2_drawable *priv = (struct dri2_drawable *)
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
 
if (priv == NULL || !priv->have_fake_front)
return;
 
dri2_copy_drawable(priv, DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);
}
 
static void
dri2_wait_gl(struct glx_context *gc)
{
struct dri2_drawable *priv = (struct dri2_drawable *)
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
 
if (priv == NULL || !priv->have_fake_front)
return;
 
dri2_copy_drawable(priv, DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft);
}
 
/**
* Called by the driver when it needs to update the real front buffer with the
* contents of its fake front buffer.
*/
static void
dri2FlushFrontBuffer(__DRIdrawable *driDrawable, void *loaderPrivate)
{
struct glx_display *priv;
struct dri2_display *pdp;
struct glx_context *gc;
struct dri2_drawable *pdraw = loaderPrivate;
struct dri2_screen *psc;
 
if (!pdraw)
return;
 
if (!pdraw->base.psc)
return;
 
psc = (struct dri2_screen *) pdraw->base.psc;
 
priv = __glXInitialize(psc->base.dpy);
pdp = (struct dri2_display *) priv->dri2Display;
gc = __glXGetCurrentContext();
 
dri2Throttle(psc, pdraw, __DRI2_THROTTLE_FLUSHFRONT);
 
/* Old servers don't send invalidate events */
if (!pdp->invalidateAvailable)
dri2InvalidateBuffers(priv->dpy, pdraw->base.xDrawable);
 
dri2_wait_gl(gc);
}
 
 
static void
dri2DestroyScreen(struct glx_screen *base)
{
struct dri2_screen *psc = (struct dri2_screen *) base;
 
/* Free the direct rendering per screen data */
(*psc->core->destroyScreen) (psc->driScreen);
driDestroyConfigs(psc->driver_configs);
close(psc->fd);
free(psc);
}
 
/**
* Process list of buffer received from the server
*
* Processes the list of buffers received in a reply from the server to either
* \c DRI2GetBuffers or \c DRI2GetBuffersWithFormat.
*/
static void
process_buffers(struct dri2_drawable * pdraw, DRI2Buffer * buffers,
unsigned count)
{
int i;
 
pdraw->bufferCount = count;
pdraw->have_fake_front = 0;
pdraw->have_back = 0;
 
/* This assumes the DRI2 buffer attachment tokens matches the
* __DRIbuffer tokens. */
for (i = 0; i < count; i++) {
pdraw->buffers[i].attachment = buffers[i].attachment;
pdraw->buffers[i].name = buffers[i].name;
pdraw->buffers[i].pitch = buffers[i].pitch;
pdraw->buffers[i].cpp = buffers[i].cpp;
pdraw->buffers[i].flags = buffers[i].flags;
if (pdraw->buffers[i].attachment == __DRI_BUFFER_FAKE_FRONT_LEFT)
pdraw->have_fake_front = 1;
if (pdraw->buffers[i].attachment == __DRI_BUFFER_BACK_LEFT)
pdraw->have_back = 1;
}
 
}
 
unsigned dri2GetSwapEventType(Display* dpy, XID drawable)
{
struct glx_display *glx_dpy = __glXInitialize(dpy);
__GLXDRIdrawable *pdraw;
pdraw = dri2GetGlxDrawableFromXDrawableId(dpy, drawable);
if (!pdraw || !(pdraw->eventMask & GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK))
return 0;
return glx_dpy->codes->first_event + GLX_BufferSwapComplete;
}
 
static void show_fps(struct dri2_drawable *draw)
{
struct timeval tv;
uint64_t current_time;
 
gettimeofday(&tv, 0);
current_time = (uint64_t)tv.tv_sec*1000000 + (uint64_t)tv.tv_usec;
 
draw->frames++;
 
if (draw->previous_time + 1000000 <= current_time) {
if (draw->previous_time) {
fprintf(stderr, "libGL: FPS = %.1f\n",
((uint64_t)draw->frames * 1000000) /
(double)(current_time - draw->previous_time));
}
draw->frames = 0;
draw->previous_time = current_time;
}
}
 
static int64_t
dri2XcbSwapBuffers(Display *dpy,
__GLXDRIdrawable *pdraw,
int64_t target_msc,
int64_t divisor,
int64_t remainder)
{
xcb_dri2_swap_buffers_cookie_t swap_buffers_cookie;
xcb_dri2_swap_buffers_reply_t *swap_buffers_reply;
uint32_t target_msc_hi, target_msc_lo;
uint32_t divisor_hi, divisor_lo;
uint32_t remainder_hi, remainder_lo;
int64_t ret = 0;
xcb_connection_t *c = XGetXCBConnection(dpy);
 
split_counter(target_msc, &target_msc_hi, &target_msc_lo);
split_counter(divisor, &divisor_hi, &divisor_lo);
split_counter(remainder, &remainder_hi, &remainder_lo);
 
swap_buffers_cookie =
xcb_dri2_swap_buffers_unchecked(c, pdraw->xDrawable,
target_msc_hi, target_msc_lo,
divisor_hi, divisor_lo,
remainder_hi, remainder_lo);
 
/* Immediately wait on the swapbuffers reply. If we didn't, we'd have
* to do so some time before reusing a (non-pageflipped) backbuffer.
* Otherwise, the new rendering could get ahead of the X Server's
* dispatch of the swapbuffer and you'd display garbage.
*
* We use XSync() first to reap the invalidate events through the event
* filter, to ensure that the next drawing doesn't use an invalidated
* buffer.
*/
XSync(dpy, False);
 
swap_buffers_reply =
xcb_dri2_swap_buffers_reply(c, swap_buffers_cookie, NULL);
if (swap_buffers_reply) {
ret = merge_counter(swap_buffers_reply->swap_hi,
swap_buffers_reply->swap_lo);
free(swap_buffers_reply);
}
return ret;
}
 
static int64_t
dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
int64_t remainder, Bool flush)
{
struct dri2_drawable *priv = (struct dri2_drawable *) pdraw;
struct glx_display *dpyPriv = __glXInitialize(priv->base.psc->dpy);
struct dri2_screen *psc = (struct dri2_screen *) priv->base.psc;
struct dri2_display *pdp =
(struct dri2_display *)dpyPriv->dri2Display;
int64_t ret = 0;
 
/* Check we have the right attachments */
if (!priv->have_back)
return ret;
 
/* Old servers can't handle swapbuffers */
if (!pdp->swapAvailable) {
__dri2CopySubBuffer(pdraw, 0, 0, priv->width, priv->height,
__DRI2_THROTTLE_SWAPBUFFER, flush);
} else {
__DRIcontext *ctx = dri2GetCurrentContext();
unsigned flags = __DRI2_FLUSH_DRAWABLE;
if (flush)
flags |= __DRI2_FLUSH_CONTEXT;
dri2Flush(psc, ctx, priv, flags, __DRI2_THROTTLE_SWAPBUFFER);
 
ret = dri2XcbSwapBuffers(pdraw->psc->dpy, pdraw,
target_msc, divisor, remainder);
}
 
if (psc->show_fps) {
show_fps(priv);
}
 
/* Old servers don't send invalidate events */
if (!pdp->invalidateAvailable)
dri2InvalidateBuffers(dpyPriv->dpy, pdraw->xDrawable);
 
return ret;
}
 
static __DRIbuffer *
dri2GetBuffers(__DRIdrawable * driDrawable,
int *width, int *height,
unsigned int *attachments, int count,
int *out_count, void *loaderPrivate)
{
struct dri2_drawable *pdraw = loaderPrivate;
DRI2Buffer *buffers;
 
buffers = DRI2GetBuffers(pdraw->base.psc->dpy, pdraw->base.xDrawable,
width, height, attachments, count, out_count);
if (buffers == NULL)
return NULL;
 
pdraw->width = *width;
pdraw->height = *height;
process_buffers(pdraw, buffers, *out_count);
 
free(buffers);
 
return pdraw->buffers;
}
 
static __DRIbuffer *
dri2GetBuffersWithFormat(__DRIdrawable * driDrawable,
int *width, int *height,
unsigned int *attachments, int count,
int *out_count, void *loaderPrivate)
{
struct dri2_drawable *pdraw = loaderPrivate;
DRI2Buffer *buffers;
 
buffers = DRI2GetBuffersWithFormat(pdraw->base.psc->dpy,
pdraw->base.xDrawable,
width, height, attachments,
count, out_count);
if (buffers == NULL)
return NULL;
 
pdraw->width = *width;
pdraw->height = *height;
process_buffers(pdraw, buffers, *out_count);
 
free(buffers);
 
return pdraw->buffers;
}
 
static int
dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
{
xcb_connection_t *c = XGetXCBConnection(pdraw->psc->dpy);
struct dri2_drawable *priv = (struct dri2_drawable *) pdraw;
GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
struct dri2_screen *psc = (struct dri2_screen *) priv->base.psc;
 
if (psc->config)
psc->config->configQueryi(psc->driScreen,
"vblank_mode", &vblank_mode);
 
switch (vblank_mode) {
case DRI_CONF_VBLANK_NEVER:
if (interval != 0)
return GLX_BAD_VALUE;
break;
case DRI_CONF_VBLANK_ALWAYS_SYNC:
if (interval <= 0)
return GLX_BAD_VALUE;
break;
default:
break;
}
 
xcb_dri2_swap_interval(c, priv->base.xDrawable, interval);
priv->swap_interval = interval;
 
return 0;
}
 
static int
dri2GetSwapInterval(__GLXDRIdrawable *pdraw)
{
struct dri2_drawable *priv = (struct dri2_drawable *) pdraw;
 
return priv->swap_interval;
}
 
static const __DRIdri2LoaderExtension dri2LoaderExtension = {
{__DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION},
dri2GetBuffers,
dri2FlushFrontBuffer,
dri2GetBuffersWithFormat,
};
 
static const __DRIdri2LoaderExtension dri2LoaderExtension_old = {
{__DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION},
dri2GetBuffers,
dri2FlushFrontBuffer,
NULL,
};
 
static const __DRIuseInvalidateExtension dri2UseInvalidate = {
{ __DRI_USE_INVALIDATE, __DRI_USE_INVALIDATE_VERSION }
};
 
_X_HIDDEN void
dri2InvalidateBuffers(Display *dpy, XID drawable)
{
__GLXDRIdrawable *pdraw =
dri2GetGlxDrawableFromXDrawableId(dpy, drawable);
struct dri2_screen *psc;
struct dri2_drawable *pdp = (struct dri2_drawable *) pdraw;
 
if (!pdraw)
return;
 
psc = (struct dri2_screen *) pdraw->psc;
 
if (pdraw && psc->f && psc->f->base.version >= 3 && psc->f->invalidate)
psc->f->invalidate(pdp->driDrawable);
}
 
static void
dri2_bind_tex_image(Display * dpy,
GLXDrawable drawable,
int buffer, const int *attrib_list)
{
struct glx_context *gc = __glXGetCurrentContext();
struct dri2_context *pcp = (struct dri2_context *) gc;
__GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
struct glx_display *dpyPriv = __glXInitialize(dpy);
struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
struct dri2_display *pdp =
(struct dri2_display *) dpyPriv->dri2Display;
struct dri2_screen *psc;
 
if (pdraw != NULL) {
psc = (struct dri2_screen *) base->psc;
 
if (!pdp->invalidateAvailable && psc->f &&
psc->f->base.version >= 3 && psc->f->invalidate)
psc->f->invalidate(pdraw->driDrawable);
 
if (psc->texBuffer->base.version >= 2 &&
psc->texBuffer->setTexBuffer2 != NULL) {
(*psc->texBuffer->setTexBuffer2) (pcp->driContext,
pdraw->base.textureTarget,
pdraw->base.textureFormat,
pdraw->driDrawable);
}
else {
(*psc->texBuffer->setTexBuffer) (pcp->driContext,
pdraw->base.textureTarget,
pdraw->driDrawable);
}
}
}
 
static void
dri2_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
{
#if __DRI_TEX_BUFFER_VERSION >= 3
struct glx_context *gc = __glXGetCurrentContext();
struct dri2_context *pcp = (struct dri2_context *) gc;
__GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
struct glx_display *dpyPriv = __glXInitialize(dpy);
struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
struct dri2_display *pdp =
(struct dri2_display *) dpyPriv->dri2Display;
struct dri2_screen *psc;
 
if (pdraw != NULL) {
psc = (struct dri2_screen *) base->psc;
 
if (psc->texBuffer->base.version >= 3 &&
psc->texBuffer->releaseTexBuffer != NULL) {
(*psc->texBuffer->releaseTexBuffer) (pcp->driContext,
pdraw->base.textureTarget,
pdraw->driDrawable);
}
}
#endif
}
 
static const struct glx_context_vtable dri2_context_vtable = {
dri2_destroy_context,
dri2_bind_context,
dri2_unbind_context,
dri2_wait_gl,
dri2_wait_x,
DRI_glXUseXFont,
dri2_bind_tex_image,
dri2_release_tex_image,
NULL, /* get_proc_address */
};
 
static void
dri2BindExtensions(struct dri2_screen *psc, struct glx_display * priv,
const char *driverName)
{
const struct dri2_display *const pdp = (struct dri2_display *)
priv->dri2Display;
const __DRIextension **extensions;
int i;
 
extensions = psc->core->getExtensions(psc->driScreen);
 
__glXEnableDirectExtension(&psc->base, "GLX_SGI_video_sync");
__glXEnableDirectExtension(&psc->base, "GLX_SGI_swap_control");
__glXEnableDirectExtension(&psc->base, "GLX_MESA_swap_control");
__glXEnableDirectExtension(&psc->base, "GLX_SGI_make_current_read");
 
/*
* GLX_INTEL_swap_event is broken on the server side, where it's
* currently unconditionally enabled. This completely breaks
* systems running on drivers which don't support that extension.
* There's no way to test for its presence on this side, so instead
* of disabling it unconditionally, just disable it for drivers
* which are known to not support it, or for DDX drivers supporting
* only an older (pre-ScheduleSwap) version of DRI2.
*
* This is a hack which is required until:
* http://lists.x.org/archives/xorg-devel/2013-February/035449.html
* is merged and updated xserver makes it's way into distros:
*/
if (pdp->swapAvailable && strcmp(driverName, "vmwgfx") != 0) {
__glXEnableDirectExtension(&psc->base, "GLX_INTEL_swap_event");
}
 
if (psc->dri2->base.version >= 3) {
const unsigned mask = psc->dri2->getAPIMask(psc->driScreen);
 
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
 
if ((mask & (1 << __DRI_API_GLES2)) != 0)
__glXEnableDirectExtension(&psc->base,
"GLX_EXT_create_context_es2_profile");
}
 
for (i = 0; extensions[i]; i++) {
if ((strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) {
psc->texBuffer = (__DRItexBufferExtension *) extensions[i];
__glXEnableDirectExtension(&psc->base, "GLX_EXT_texture_from_pixmap");
}
 
if ((strcmp(extensions[i]->name, __DRI2_FLUSH) == 0)) {
psc->f = (__DRI2flushExtension *) extensions[i];
/* internal driver extension, no GL extension exposed */
}
 
if ((strcmp(extensions[i]->name, __DRI2_CONFIG_QUERY) == 0))
psc->config = (__DRI2configQueryExtension *) extensions[i];
 
if (((strcmp(extensions[i]->name, __DRI2_THROTTLE) == 0)))
psc->throttle = (__DRI2throttleExtension *) extensions[i];
 
/* DRI2 version 3 is also required because
* GLX_ARB_create_context_robustness requires GLX_ARB_create_context.
*/
if (psc->dri2->base.version >= 3
&& strcmp(extensions[i]->name, __DRI2_ROBUSTNESS) == 0)
__glXEnableDirectExtension(&psc->base,
"GLX_ARB_create_context_robustness");
}
}
 
static const struct glx_screen_vtable dri2_screen_vtable = {
dri2_create_context,
dri2_create_context_attribs
};
 
static struct glx_screen *
dri2CreateScreen(int screen, struct glx_display * priv)
{
const __DRIconfig **driver_configs;
const __DRIextension **extensions;
const struct dri2_display *const pdp = (struct dri2_display *)
priv->dri2Display;
struct dri2_screen *psc;
__GLXDRIscreen *psp;
struct glx_config *configs = NULL, *visuals = NULL;
char *driverName, *deviceName, *tmp;
drm_magic_t magic;
int i;
 
psc = calloc(1, sizeof *psc);
if (psc == NULL)
return NULL;
 
psc->fd = -1;
 
if (!glx_screen_init(&psc->base, screen, priv)) {
free(psc);
return NULL;
}
 
if (!DRI2Connect(priv->dpy, RootWindow(priv->dpy, screen),
&driverName, &deviceName)) {
glx_screen_cleanup(&psc->base);
free(psc);
InfoMessageF("screen %d does not appear to be DRI2 capable\n", screen);
return NULL;
}
 
psc->driver = driOpenDriver(driverName);
if (psc->driver == NULL) {
ErrorMessageF("driver pointer missing\n");
goto handle_error;
}
 
extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
if (extensions == NULL) {
ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
goto handle_error;
}
 
for (i = 0; extensions[i]; i++) {
if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
psc->core = (__DRIcoreExtension *) extensions[i];
if (strcmp(extensions[i]->name, __DRI_DRI2) == 0)
psc->dri2 = (__DRIdri2Extension *) extensions[i];
}
 
if (psc->core == NULL || psc->dri2 == NULL) {
ErrorMessageF("core dri or dri2 extension not found\n");
goto handle_error;
}
 
#ifdef O_CLOEXEC
psc->fd = open(deviceName, O_RDWR | O_CLOEXEC);
if (psc->fd == -1 && errno == EINVAL)
#endif
{
psc->fd = open(deviceName, O_RDWR);
if (psc->fd != -1)
fcntl(psc->fd, F_SETFD, fcntl(psc->fd, F_GETFD) | FD_CLOEXEC);
}
if (psc->fd < 0) {
ErrorMessageF("failed to open drm device: %s\n", strerror(errno));
goto handle_error;
}
 
if (drmGetMagic(psc->fd, &magic)) {
ErrorMessageF("failed to get magic\n");
goto handle_error;
}
 
if (!DRI2Authenticate(priv->dpy, RootWindow(priv->dpy, screen), magic)) {
ErrorMessageF("failed to authenticate magic %d\n", magic);
goto handle_error;
}
 
/* If the server does not support the protocol for
* DRI2GetBuffersWithFormat, don't supply that interface to the driver.
*/
psc->driScreen =
psc->dri2->createNewScreen(screen, psc->fd,
(const __DRIextension **)
&pdp->loader_extensions[0],
&driver_configs, psc);
 
if (psc->driScreen == NULL) {
ErrorMessageF("failed to create dri screen\n");
goto handle_error;
}
 
dri2BindExtensions(psc, priv, driverName);
 
configs = driConvertConfigs(psc->core, psc->base.configs, driver_configs);
visuals = driConvertConfigs(psc->core, psc->base.visuals, driver_configs);
 
if (!configs || !visuals)
goto handle_error;
 
glx_config_destroy_list(psc->base.configs);
psc->base.configs = configs;
glx_config_destroy_list(psc->base.visuals);
psc->base.visuals = visuals;
 
psc->driver_configs = driver_configs;
 
psc->base.vtable = &dri2_screen_vtable;
psp = &psc->vtable;
psc->base.driScreen = psp;
psp->destroyScreen = dri2DestroyScreen;
psp->createDrawable = dri2CreateDrawable;
psp->swapBuffers = dri2SwapBuffers;
psp->getDrawableMSC = NULL;
psp->waitForMSC = NULL;
psp->waitForSBC = NULL;
psp->setSwapInterval = NULL;
psp->getSwapInterval = NULL;
 
if (pdp->driMinor >= 2) {
psp->getDrawableMSC = dri2DrawableGetMSC;
psp->waitForMSC = dri2WaitForMSC;
psp->waitForSBC = dri2WaitForSBC;
psp->setSwapInterval = dri2SetSwapInterval;
psp->getSwapInterval = dri2GetSwapInterval;
__glXEnableDirectExtension(&psc->base, "GLX_OML_sync_control");
}
 
/* DRI2 suports SubBuffer through DRI2CopyRegion, so it's always
* available.*/
psp->copySubBuffer = dri2CopySubBuffer;
__glXEnableDirectExtension(&psc->base, "GLX_MESA_copy_sub_buffer");
 
free(driverName);
free(deviceName);
 
tmp = getenv("LIBGL_SHOW_FPS");
psc->show_fps = tmp && strcmp(tmp, "1") == 0;
 
return &psc->base;
 
handle_error:
CriticalErrorMessageF("failed to load driver: %s\n", driverName);
 
if (configs)
glx_config_destroy_list(configs);
if (visuals)
glx_config_destroy_list(visuals);
if (psc->driScreen)
psc->core->destroyScreen(psc->driScreen);
psc->driScreen = NULL;
if (psc->fd >= 0)
close(psc->fd);
if (psc->driver)
dlclose(psc->driver);
 
free(driverName);
free(deviceName);
glx_screen_cleanup(&psc->base);
free(psc);
 
return NULL;
}
 
/* Called from __glXFreeDisplayPrivate.
*/
static void
dri2DestroyDisplay(__GLXDRIdisplay * dpy)
{
struct dri2_display *pdp = (struct dri2_display *) dpy;
 
__glxHashDestroy(pdp->dri2Hash);
free(dpy);
}
 
_X_HIDDEN __GLXDRIdrawable *
dri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id)
{
struct glx_display *d = __glXInitialize(dpy);
struct dri2_display *pdp = (struct dri2_display *) d->dri2Display;
__GLXDRIdrawable *pdraw;
 
if (__glxHashLookup(pdp->dri2Hash, id, (void *) &pdraw) == 0)
return pdraw;
 
return NULL;
}
 
/*
* Allocate, initialize and return a __DRIdisplayPrivate object.
* This is called from __glXInitialize() when we are given a new
* display pointer.
*/
_X_HIDDEN __GLXDRIdisplay *
dri2CreateDisplay(Display * dpy)
{
struct dri2_display *pdp;
int eventBase, errorBase, i;
 
if (!DRI2QueryExtension(dpy, &eventBase, &errorBase))
return NULL;
 
pdp = malloc(sizeof *pdp);
if (pdp == NULL)
return NULL;
 
if (!DRI2QueryVersion(dpy, &pdp->driMajor, &pdp->driMinor)) {
free(pdp);
return NULL;
}
 
pdp->driPatch = 0;
pdp->swapAvailable = (pdp->driMinor >= 2);
pdp->invalidateAvailable = (pdp->driMinor >= 3);
 
pdp->base.destroyDisplay = dri2DestroyDisplay;
pdp->base.createScreen = dri2CreateScreen;
 
i = 0;
if (pdp->driMinor < 1)
pdp->loader_extensions[i++] = &dri2LoaderExtension_old.base;
else
pdp->loader_extensions[i++] = &dri2LoaderExtension.base;
pdp->loader_extensions[i++] = &systemTimeExtension.base;
 
pdp->loader_extensions[i++] = &dri2UseInvalidate.base;
 
pdp->loader_extensions[i++] = NULL;
 
pdp->dri2Hash = __glxHashCreate();
if (pdp->dri2Hash == NULL) {
free(pdp);
return NULL;
}
 
return &pdp->base;
}
 
#endif /* GLX_DIRECT_RENDERING */
/contrib/sdk/sources/Mesa/src/glx/dri_common.c
0,0 → 1,599
/*
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright © 2008 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Soft-
* ware"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, provided that the above copyright
* notice(s) and this permission notice appear in all copies of the Soft-
* ware and that both the above copyright notice(s) and this permission
* notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
* QUENTIAL 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 PERFOR-
* MANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder shall
* not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization of
* the copyright holder.
*
* Authors:
* Kevin E. Martin <kevin@precisioninsight.com>
* Brian Paul <brian@precisioninsight.com>
* Kristian Høgsberg (krh@redhat.com)
*/
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
 
#include <unistd.h>
#include <dlfcn.h>
#include <stdarg.h>
#include "glxclient.h"
#include "dri_common.h"
 
#ifndef RTLD_NOW
#define RTLD_NOW 0
#endif
#ifndef RTLD_GLOBAL
#define RTLD_GLOBAL 0
#endif
 
/**
* Print informational message to stderr if LIBGL_DEBUG is set to
* "verbose".
*/
_X_HIDDEN void
InfoMessageF(const char *f, ...)
{
va_list args;
const char *env;
 
if ((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose")) {
fprintf(stderr, "libGL: ");
va_start(args, f);
vfprintf(stderr, f, args);
va_end(args);
}
}
 
/**
* Print error message to stderr if LIBGL_DEBUG is set to anything but
* "quiet", (do nothing if LIBGL_DEBUG is unset).
*/
_X_HIDDEN void
ErrorMessageF(const char *f, ...)
{
va_list args;
const char *env;
 
if ((env = getenv("LIBGL_DEBUG")) && !strstr(env, "quiet")) {
fprintf(stderr, "libGL error: ");
va_start(args, f);
vfprintf(stderr, f, args);
va_end(args);
}
}
 
/**
* Print error message unless LIBGL_DEBUG is set to "quiet".
*
* The distinction between CriticalErrorMessageF and ErrorMessageF is
* that critcial errors will be printed by default, (even when
* LIBGL_DEBUG is unset).
*/
_X_HIDDEN void
CriticalErrorMessageF(const char *f, ...)
{
va_list args;
const char *env;
 
if (!(env = getenv("LIBGL_DEBUG")) || !strstr(env, "quiet")) {
fprintf(stderr, "libGL error: ");
va_start(args, f);
vfprintf(stderr, f, args);
va_end(args);
 
if (!env || !strstr(env, "verbose"))
fprintf(stderr, "libGL error: Try again with LIBGL_DEBUG=verbose for more details.\n");
}
}
 
#ifndef DEFAULT_DRIVER_DIR
/* this is normally defined in Mesa/configs/default with DRI_DRIVER_SEARCH_PATH */
#define DEFAULT_DRIVER_DIR "/usr/local/lib/dri"
#endif
 
/**
* Try to \c dlopen the named driver.
*
* This function adds the "_dri.so" suffix to the driver name and searches the
* directories specified by the \c LIBGL_DRIVERS_PATH environment variable in
* order to find the driver.
*
* \param driverName - a name like "i965", "radeon", "nouveau", etc.
*
* \returns
* A handle from \c dlopen, or \c NULL if driver file not found.
*/
_X_HIDDEN void *
driOpenDriver(const char *driverName)
{
void *glhandle, *handle;
const char *libPaths, *p, *next;
char realDriverName[200];
int len;
 
/* Attempt to make sure libGL symbols will be visible to the driver */
glhandle = dlopen("libGL.so.1", RTLD_NOW | RTLD_GLOBAL);
 
libPaths = NULL;
if (geteuid() == getuid()) {
/* don't allow setuid apps to use LIBGL_DRIVERS_PATH */
libPaths = getenv("LIBGL_DRIVERS_PATH");
if (!libPaths)
libPaths = getenv("LIBGL_DRIVERS_DIR"); /* deprecated */
}
if (libPaths == NULL)
libPaths = DEFAULT_DRIVER_DIR;
 
handle = NULL;
for (p = libPaths; *p; p = next) {
next = strchr(p, ':');
if (next == NULL) {
len = strlen(p);
next = p + len;
}
else {
len = next - p;
next++;
}
 
#ifdef GLX_USE_TLS
snprintf(realDriverName, sizeof realDriverName,
"%.*s/tls/%s_dri.so", len, p, driverName);
InfoMessageF("OpenDriver: trying %s\n", realDriverName);
handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL);
#endif
 
if (handle == NULL) {
snprintf(realDriverName, sizeof realDriverName,
"%.*s/%s_dri.so", len, p, driverName);
InfoMessageF("OpenDriver: trying %s\n", realDriverName);
handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL);
}
 
if (handle != NULL)
break;
else
ErrorMessageF("dlopen %s failed (%s)\n", realDriverName, dlerror());
}
 
if (!handle)
ErrorMessageF("unable to load driver: %s_dri.so\n", driverName);
 
if (glhandle)
dlclose(glhandle);
 
return handle;
}
 
static GLboolean
__driGetMSCRate(__DRIdrawable *draw,
int32_t * numerator, int32_t * denominator,
void *loaderPrivate)
{
__GLXDRIdrawable *glxDraw = loaderPrivate;
 
return __glxGetMscRate(glxDraw, numerator, denominator);
}
 
_X_HIDDEN const __DRIsystemTimeExtension systemTimeExtension = {
{__DRI_SYSTEM_TIME, __DRI_SYSTEM_TIME_VERSION},
__glXGetUST,
__driGetMSCRate
};
 
#define __ATTRIB(attrib, field) \
{ attrib, offsetof(struct glx_config, field) }
 
static const struct
{
unsigned int attrib, offset;
} attribMap[] = {
__ATTRIB(__DRI_ATTRIB_BUFFER_SIZE, rgbBits),
__ATTRIB(__DRI_ATTRIB_LEVEL, level),
__ATTRIB(__DRI_ATTRIB_RED_SIZE, redBits),
__ATTRIB(__DRI_ATTRIB_GREEN_SIZE, greenBits),
__ATTRIB(__DRI_ATTRIB_BLUE_SIZE, blueBits),
__ATTRIB(__DRI_ATTRIB_ALPHA_SIZE, alphaBits),
__ATTRIB(__DRI_ATTRIB_DEPTH_SIZE, depthBits),
__ATTRIB(__DRI_ATTRIB_STENCIL_SIZE, stencilBits),
__ATTRIB(__DRI_ATTRIB_ACCUM_RED_SIZE, accumRedBits),
__ATTRIB(__DRI_ATTRIB_ACCUM_GREEN_SIZE, accumGreenBits),
__ATTRIB(__DRI_ATTRIB_ACCUM_BLUE_SIZE, accumBlueBits),
__ATTRIB(__DRI_ATTRIB_ACCUM_ALPHA_SIZE, accumAlphaBits),
__ATTRIB(__DRI_ATTRIB_SAMPLE_BUFFERS, sampleBuffers),
__ATTRIB(__DRI_ATTRIB_SAMPLES, samples),
__ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER, doubleBufferMode),
__ATTRIB(__DRI_ATTRIB_STEREO, stereoMode),
__ATTRIB(__DRI_ATTRIB_AUX_BUFFERS, numAuxBuffers),
#if 0
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE, transparentPixel),
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE, transparentIndex),
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE, transparentRed),
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE, transparentGreen),
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE, transparentBlue),
__ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE, transparentAlpha),
__ATTRIB(__DRI_ATTRIB_RED_MASK, redMask),
__ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask),
__ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask),
__ATTRIB(__DRI_ATTRIB_ALPHA_MASK, alphaMask),
#endif
__ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH, maxPbufferWidth),
__ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT, maxPbufferHeight),
__ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels),
__ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH, optimalPbufferWidth),
__ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT, optimalPbufferHeight),
#if 0
__ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod),
#endif
__ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb),
__ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba),
__ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE,
bindToMipmapTexture),
__ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),
__ATTRIB(__DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE, sRGBCapable)
};
 
static int
scalarEqual(struct glx_config *mode, unsigned int attrib, unsigned int value)
{
unsigned int glxValue;
int i;
 
for (i = 0; i < ARRAY_SIZE(attribMap); i++)
if (attribMap[i].attrib == attrib) {
glxValue = *(unsigned int *) ((char *) mode + attribMap[i].offset);
return glxValue == GLX_DONT_CARE || glxValue == value;
}
 
return GL_TRUE; /* Is a non-existing attribute equal to value? */
}
 
static int
driConfigEqual(const __DRIcoreExtension *core,
struct glx_config *config, const __DRIconfig *driConfig)
{
unsigned int attrib, value, glxValue;
int i;
 
i = 0;
while (core->indexConfigAttrib(driConfig, i++, &attrib, &value)) {
switch (attrib) {
case __DRI_ATTRIB_RENDER_TYPE:
glxValue = 0;
if (value & __DRI_ATTRIB_RGBA_BIT) {
glxValue |= GLX_RGBA_BIT;
}
if (value & __DRI_ATTRIB_COLOR_INDEX_BIT) {
glxValue |= GLX_COLOR_INDEX_BIT;
}
if (value & __DRI_ATTRIB_FLOAT_BIT) {
glxValue |= GLX_RGBA_FLOAT_BIT_ARB;
}
if (value & __DRI_ATTRIB_UNSIGNED_FLOAT_BIT) {
glxValue |= GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT;
}
if (glxValue != config->renderType)
return GL_FALSE;
break;
 
case __DRI_ATTRIB_CONFIG_CAVEAT:
if (value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG)
glxValue = GLX_NON_CONFORMANT_CONFIG;
else if (value & __DRI_ATTRIB_SLOW_BIT)
glxValue = GLX_SLOW_CONFIG;
else
glxValue = GLX_NONE;
if (glxValue != config->visualRating)
return GL_FALSE;
break;
 
case __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS:
glxValue = 0;
if (value & __DRI_ATTRIB_TEXTURE_1D_BIT)
glxValue |= GLX_TEXTURE_1D_BIT_EXT;
if (value & __DRI_ATTRIB_TEXTURE_2D_BIT)
glxValue |= GLX_TEXTURE_2D_BIT_EXT;
if (value & __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT)
glxValue |= GLX_TEXTURE_RECTANGLE_BIT_EXT;
if (config->bindToTextureTargets != GLX_DONT_CARE &&
glxValue != config->bindToTextureTargets)
return GL_FALSE;
break;
 
default:
if (!scalarEqual(config, attrib, value))
return GL_FALSE;
}
}
 
return GL_TRUE;
}
 
static struct glx_config *
createDriMode(const __DRIcoreExtension * core,
struct glx_config *config, const __DRIconfig **driConfigs)
{
__GLXDRIconfigPrivate *driConfig;
int i;
 
for (i = 0; driConfigs[i]; i++) {
if (driConfigEqual(core, config, driConfigs[i]))
break;
}
 
if (driConfigs[i] == NULL)
return NULL;
 
driConfig = malloc(sizeof *driConfig);
if (driConfig == NULL)
return NULL;
 
driConfig->base = *config;
driConfig->driConfig = driConfigs[i];
 
return &driConfig->base;
}
 
_X_HIDDEN struct glx_config *
driConvertConfigs(const __DRIcoreExtension * core,
struct glx_config *configs, const __DRIconfig **driConfigs)
{
struct glx_config head, *tail, *m;
 
tail = &head;
head.next = NULL;
for (m = configs; m; m = m->next) {
tail->next = createDriMode(core, m, driConfigs);
if (tail->next == NULL) {
/* no matching dri config for m */
continue;
}
 
 
tail = tail->next;
}
 
return head.next;
}
 
_X_HIDDEN void
driDestroyConfigs(const __DRIconfig **configs)
{
int i;
 
for (i = 0; configs[i]; i++)
free((__DRIconfig *) configs[i]);
free(configs);
}
 
_X_HIDDEN __GLXDRIdrawable *
driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
{
struct glx_display *const priv = __glXInitialize(gc->psc->dpy);
__GLXDRIdrawable *pdraw;
struct glx_screen *psc;
 
if (priv == NULL)
return NULL;
 
psc = priv->screens[gc->screen];
if (priv->drawHash == NULL)
return NULL;
 
if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0) {
pdraw->refcount ++;
return pdraw;
}
 
pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
glxDrawable, gc->config);
 
if (pdraw == NULL) {
ErrorMessageF("failed to create drawable\n");
return NULL;
}
 
if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) {
(*pdraw->destroyDrawable) (pdraw);
return NULL;
}
pdraw->refcount = 1;
 
return pdraw;
}
 
_X_HIDDEN void
driReleaseDrawables(struct glx_context *gc)
{
const struct glx_display *priv = gc->psc->display;
__GLXDRIdrawable *pdraw;
 
if (priv == NULL)
return;
 
if (__glxHashLookup(priv->drawHash,
gc->currentDrawable, (void *) &pdraw) == 0) {
if (pdraw->drawable == pdraw->xDrawable) {
pdraw->refcount --;
if (pdraw->refcount == 0) {
(*pdraw->destroyDrawable)(pdraw);
__glxHashDelete(priv->drawHash, gc->currentDrawable);
}
}
}
 
if (__glxHashLookup(priv->drawHash,
gc->currentReadable, (void *) &pdraw) == 0) {
if (pdraw->drawable == pdraw->xDrawable) {
pdraw->refcount --;
if (pdraw->refcount == 0) {
(*pdraw->destroyDrawable)(pdraw);
__glxHashDelete(priv->drawHash, gc->currentReadable);
}
}
}
 
gc->currentDrawable = None;
gc->currentReadable = None;
 
}
 
_X_HIDDEN bool
dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
unsigned *major_ver, unsigned *minor_ver,
uint32_t *render_type, uint32_t *flags, unsigned *api,
int *reset, unsigned *error)
{
unsigned i;
bool got_profile = false;
uint32_t profile;
 
*major_ver = 1;
*minor_ver = 0;
*render_type = GLX_RGBA_TYPE;
*reset = __DRI_CTX_RESET_NO_NOTIFICATION;
*flags = 0;
*api = __DRI_API_OPENGL;
 
if (num_attribs == 0) {
return true;
}
 
/* This is actually an internal error, but what the heck.
*/
if (attribs == NULL) {
*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
return false;
}
 
for (i = 0; i < num_attribs; i++) {
switch (attribs[i * 2]) {
case GLX_CONTEXT_MAJOR_VERSION_ARB:
*major_ver = attribs[i * 2 + 1];
break;
case GLX_CONTEXT_MINOR_VERSION_ARB:
*minor_ver = attribs[i * 2 + 1];
break;
case GLX_CONTEXT_FLAGS_ARB:
*flags = attribs[i * 2 + 1];
break;
case GLX_CONTEXT_PROFILE_MASK_ARB:
profile = attribs[i * 2 + 1];
got_profile = true;
break;
case GLX_RENDER_TYPE:
*render_type = attribs[i * 2 + 1];
break;
case GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB:
switch (attribs[i * 2 + 1]) {
case GLX_NO_RESET_NOTIFICATION_ARB:
*reset = __DRI_CTX_RESET_NO_NOTIFICATION;
break;
case GLX_LOSE_CONTEXT_ON_RESET_ARB:
*reset = __DRI_CTX_RESET_LOSE_CONTEXT;
break;
default:
*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
return false;
}
break;
default:
/* If an unknown attribute is received, fail.
*/
*error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
return false;
}
}
 
if (!got_profile) {
if (*major_ver > 3 || (*major_ver == 3 && *minor_ver >= 2))
*api = __DRI_API_OPENGL_CORE;
} else {
switch (profile) {
case GLX_CONTEXT_CORE_PROFILE_BIT_ARB:
/* There are no profiles before OpenGL 3.2. The
* GLX_ARB_create_context_profile spec says:
*
* "If the requested OpenGL version is less than 3.2,
* GLX_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality
* of the context is determined solely by the requested version."
*/
*api = (*major_ver > 3 || (*major_ver == 3 && *minor_ver >= 2))
? __DRI_API_OPENGL_CORE : __DRI_API_OPENGL;
break;
case GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB:
*api = __DRI_API_OPENGL;
break;
case GLX_CONTEXT_ES2_PROFILE_BIT_EXT:
*api = __DRI_API_GLES2;
break;
default:
*error = __DRI_CTX_ERROR_BAD_API;
return false;
}
}
 
/* Unknown flag value.
*/
if (*flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_FORWARD_COMPATIBLE
| __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS)) {
*error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
return false;
}
 
/* There are no forward-compatible contexts before OpenGL 3.0. The
* GLX_ARB_create_context spec says:
*
* "Forward-compatible contexts are defined only for OpenGL versions
* 3.0 and later."
*/
if (*major_ver < 3 && (*flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) {
*error = __DRI_CTX_ERROR_BAD_FLAG;
return false;
}
 
if (*major_ver >= 3 && *render_type == GLX_COLOR_INDEX_TYPE) {
*error = __DRI_CTX_ERROR_BAD_FLAG;
return false;
}
 
/* The GLX_EXT_create_context_es2_profile spec says:
*
* "... If the version requested is 2.0, and the
* GLX_CONTEXT_ES2_PROFILE_BIT_EXT bit is set in the
* GLX_CONTEXT_PROFILE_MASK_ARB attribute (see below), then the context
* returned will implement OpenGL ES 2.0. This is the only way in which
* an implementation may request an OpenGL ES 2.0 context."
*/
if (*api == __DRI_API_GLES2 && (*major_ver != 2 || *minor_ver != 0)) {
*error = __DRI_CTX_ERROR_BAD_API;
return false;
}
 
*error = __DRI_CTX_ERROR_SUCCESS;
return true;
}
 
#endif /* GLX_DIRECT_RENDERING */
/contrib/sdk/sources/Mesa/src/glx/dri_common.h
0,0 → 1,78
/*
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright © 2008 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Soft-
* ware"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, provided that the above copyright
* notice(s) and this permission notice appear in all copies of the Soft-
* ware and that both the above copyright notice(s) and this permission
* notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
* QUENTIAL 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 PERFOR-
* MANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder shall
* not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization of
* the copyright holder.
*
* Authors:
* Kevin E. Martin <kevin@precisioninsight.com>
* Brian Paul <brian@precisioninsight.com>
* Kristian Høgsberg (krh@redhat.com)
*/
 
#ifndef _DRI_COMMON_H
#define _DRI_COMMON_H
 
#include <GL/internal/dri_interface.h>
#include <stdbool.h>
 
typedef struct __GLXDRIconfigPrivateRec __GLXDRIconfigPrivate;
 
struct __GLXDRIconfigPrivateRec
{
struct glx_config base;
const __DRIconfig *driConfig;
};
 
extern struct glx_config *driConvertConfigs(const __DRIcoreExtension * core,
struct glx_config * modes,
const __DRIconfig ** configs);
 
extern void driDestroyConfigs(const __DRIconfig **configs);
 
extern __GLXDRIdrawable *
driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable);
 
extern void
driReleaseDrawables(struct glx_context *gc);
 
extern const __DRIsystemTimeExtension systemTimeExtension;
 
extern void InfoMessageF(const char *f, ...);
 
extern void ErrorMessageF(const char *f, ...);
 
extern void CriticalErrorMessageF(const char *f, ...);
 
extern void *driOpenDriver(const char *driverName);
 
extern bool
dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
unsigned *major_ver, unsigned *minor_ver,
uint32_t *render_type, uint32_t *flags, unsigned *api,
int *reset, unsigned *error);
 
#endif /* _DRI_COMMON_H */
/contrib/sdk/sources/Mesa/src/glx/dri_glx.c
0,0 → 1,923
/**************************************************************************
 
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
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 PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
**************************************************************************/
 
/*
* Authors:
* Kevin E. Martin <kevin@precisioninsight.com>
* Brian Paul <brian@precisioninsight.com>
*
*/
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
 
#include <X11/Xlib.h>
#include <X11/extensions/Xfixes.h>
#include <X11/extensions/Xdamage.h>
#include "glxclient.h"
#include "xf86dri.h"
#include "dri2.h"
#include "sarea.h"
#include <dlfcn.h>
#include <sys/types.h>
#include <sys/mman.h>
#include "xf86drm.h"
#include "dri_common.h"
 
struct dri_display
{
__GLXDRIdisplay base;
 
/*
** XFree86-DRI version information
*/
int driMajor;
int driMinor;
int driPatch;
};
 
struct dri_screen
{
struct glx_screen base;
 
__DRIscreen *driScreen;
__GLXDRIscreen vtable;
const __DRIlegacyExtension *legacy;
const __DRIcoreExtension *core;
const __DRIswapControlExtension *swapControl;
const __DRImediaStreamCounterExtension *msc;
const __DRIconfig **driver_configs;
const __DRIcopySubBufferExtension *driCopySubBuffer;
 
void *driver;
int fd;
};
 
struct dri_context
{
struct glx_context base;
__DRIcontext *driContext;
XID hwContextID;
};
 
struct dri_drawable
{
__GLXDRIdrawable base;
 
__DRIdrawable *driDrawable;
};
 
static const struct glx_context_vtable dri_context_vtable;
 
/*
* Given a display pointer and screen number, determine the name of
* the DRI driver for the screen (i.e., "i965", "radeon", "nouveau", etc).
* Return True for success, False for failure.
*/
static Bool
driGetDriverName(Display * dpy, int scrNum, char **driverName)
{
int directCapable;
Bool b;
int event, error;
int driverMajor, driverMinor, driverPatch;
 
*driverName = NULL;
 
if (XF86DRIQueryExtension(dpy, &event, &error)) { /* DRI1 */
if (!XF86DRIQueryDirectRenderingCapable(dpy, scrNum, &directCapable)) {
ErrorMessageF("XF86DRIQueryDirectRenderingCapable failed\n");
return False;
}
if (!directCapable) {
ErrorMessageF("XF86DRIQueryDirectRenderingCapable returned false\n");
return False;
}
 
b = XF86DRIGetClientDriverName(dpy, scrNum, &driverMajor, &driverMinor,
&driverPatch, driverName);
if (!b) {
ErrorMessageF("Cannot determine driver name for screen %d\n",
scrNum);
return False;
}
 
InfoMessageF("XF86DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n",
driverMajor, driverMinor, driverPatch, *driverName,
scrNum);
 
return True;
}
else if (DRI2QueryExtension(dpy, &event, &error)) { /* DRI2 */
char *dev;
Bool ret = DRI2Connect(dpy, RootWindow(dpy, scrNum), driverName, &dev);
 
if (ret)
free(dev);
 
return ret;
}
 
return False;
}
 
/*
* Exported function for querying the DRI driver for a given screen.
*
* The returned char pointer points to a static array that will be
* overwritten by subsequent calls.
*/
_X_EXPORT const char *
glXGetScreenDriver(Display * dpy, int scrNum)
{
static char ret[32];
char *driverName;
if (driGetDriverName(dpy, scrNum, &driverName)) {
int len;
if (!driverName)
return NULL;
len = strlen(driverName);
if (len >= 31)
return NULL;
memcpy(ret, driverName, len + 1);
free(driverName);
return ret;
}
return NULL;
}
 
/*
* Exported function for obtaining a driver's option list (UTF-8 encoded XML).
*
* The returned char pointer points directly into the driver. Therefore
* it should be treated as a constant.
*
* If the driver was not found or does not support configuration NULL is
* returned.
*
* Note: The driver remains opened after this function returns.
*/
_X_EXPORT const char *
glXGetDriverConfig(const char *driverName)
{
void *handle = driOpenDriver(driverName);
if (handle)
return dlsym(handle, "__driConfigOptions");
else
return NULL;
}
 
#ifdef XDAMAGE_1_1_INTERFACE
 
static GLboolean
has_damage_post(Display * dpy)
{
static GLboolean inited = GL_FALSE;
static GLboolean has_damage;
 
if (!inited) {
int major, minor;
 
if (XDamageQueryVersion(dpy, &major, &minor) &&
major == 1 && minor >= 1) {
has_damage = GL_TRUE;
}
else {
has_damage = GL_FALSE;
}
inited = GL_TRUE;
}
 
return has_damage;
}
 
static void
__glXReportDamage(__DRIdrawable * driDraw,
int x, int y,
drm_clip_rect_t * rects, int num_rects,
GLboolean front_buffer, void *loaderPrivate)
{
XRectangle *xrects;
XserverRegion region;
int i;
int x_off, y_off;
__GLXDRIdrawable *glxDraw = loaderPrivate;
struct glx_screen *psc = glxDraw->psc;
Display *dpy = psc->dpy;
Drawable drawable;
 
if (!has_damage_post(dpy))
return;
 
if (front_buffer) {
x_off = x;
y_off = y;
drawable = RootWindow(dpy, psc->scr);
}
else {
x_off = 0;
y_off = 0;
drawable = glxDraw->xDrawable;
}
 
xrects = malloc(sizeof(XRectangle) * num_rects);
if (xrects == NULL)
return;
 
for (i = 0; i < num_rects; i++) {
xrects[i].x = rects[i].x1 + x_off;
xrects[i].y = rects[i].y1 + y_off;
xrects[i].width = rects[i].x2 - rects[i].x1;
xrects[i].height = rects[i].y2 - rects[i].y1;
}
region = XFixesCreateRegion(dpy, xrects, num_rects);
free(xrects);
XDamageAdd(dpy, drawable, region);
XFixesDestroyRegion(dpy, region);
}
 
static const __DRIdamageExtension damageExtension = {
{__DRI_DAMAGE, __DRI_DAMAGE_VERSION},
__glXReportDamage,
};
 
#endif
 
static GLboolean
__glXDRIGetDrawableInfo(__DRIdrawable * drawable,
unsigned int *index, unsigned int *stamp,
int *X, int *Y, int *W, int *H,
int *numClipRects, drm_clip_rect_t ** pClipRects,
int *backX, int *backY,
int *numBackClipRects,
drm_clip_rect_t ** pBackClipRects,
void *loaderPrivate)
{
__GLXDRIdrawable *glxDraw = loaderPrivate;
struct glx_screen *psc = glxDraw->psc;
Display *dpy = psc->dpy;
 
return XF86DRIGetDrawableInfo(dpy, psc->scr, glxDraw->drawable,
index, stamp, X, Y, W, H,
numClipRects, pClipRects,
backX, backY,
numBackClipRects, pBackClipRects);
}
 
static const __DRIgetDrawableInfoExtension getDrawableInfoExtension = {
{__DRI_GET_DRAWABLE_INFO, __DRI_GET_DRAWABLE_INFO_VERSION},
__glXDRIGetDrawableInfo
};
 
static const __DRIextension *loader_extensions[] = {
&systemTimeExtension.base,
&getDrawableInfoExtension.base,
#ifdef XDAMAGE_1_1_INTERFACE
&damageExtension.base,
#endif
NULL
};
 
/**
* Perform the required libGL-side initialization and call the client-side
* driver's \c __driCreateNewScreen function.
*
* \param dpy Display pointer.
* \param scrn Screen number on the display.
* \param psc DRI screen information.
* \param driDpy DRI display information.
* \param createNewScreen Pointer to the client-side driver's
* \c __driCreateNewScreen function.
* \returns A pointer to the \c __DRIscreen structure returned by
* the client-side driver on success, or \c NULL on failure.
*/
static void *
CallCreateNewScreen(Display *dpy, int scrn, struct dri_screen *psc,
struct dri_display * driDpy)
{
void *psp = NULL;
drm_handle_t hSAREA;
drmAddress pSAREA = MAP_FAILED;
char *BusID;
__DRIversion ddx_version;
__DRIversion dri_version;
__DRIversion drm_version;
__DRIframebuffer framebuffer;
int fd = -1;
int status;
 
drm_magic_t magic;
drmVersionPtr version;
int newlyopened;
char *driverName;
drm_handle_t hFB;
int junk;
const __DRIconfig **driver_configs;
struct glx_config *visual, *configs = NULL, *visuals = NULL;
 
/* DRI protocol version. */
dri_version.major = driDpy->driMajor;
dri_version.minor = driDpy->driMinor;
dri_version.patch = driDpy->driPatch;
 
framebuffer.base = MAP_FAILED;
framebuffer.dev_priv = NULL;
framebuffer.size = 0;
 
if (!XF86DRIOpenConnection(dpy, scrn, &hSAREA, &BusID)) {
ErrorMessageF("XF86DRIOpenConnection failed\n");
goto handle_error;
}
 
fd = drmOpenOnce(NULL, BusID, &newlyopened);
 
free(BusID); /* No longer needed */
 
if (fd < 0) {
ErrorMessageF("drmOpenOnce failed (%s)\n", strerror(-fd));
goto handle_error;
}
 
if (drmGetMagic(fd, &magic)) {
ErrorMessageF("drmGetMagic failed\n");
goto handle_error;
}
 
version = drmGetVersion(fd);
if (version) {
drm_version.major = version->version_major;
drm_version.minor = version->version_minor;
drm_version.patch = version->version_patchlevel;
drmFreeVersion(version);
}
else {
drm_version.major = -1;
drm_version.minor = -1;
drm_version.patch = -1;
}
 
if (newlyopened && !XF86DRIAuthConnection(dpy, scrn, magic)) {
ErrorMessageF("XF86DRIAuthConnection failed\n");
goto handle_error;
}
 
/* Get device name (like "radeon") and the ddx version numbers.
* We'll check the version in each DRI driver's "createNewScreen"
* function. */
if (!XF86DRIGetClientDriverName(dpy, scrn,
&ddx_version.major,
&ddx_version.minor,
&ddx_version.patch, &driverName)) {
ErrorMessageF("XF86DRIGetClientDriverName failed\n");
goto handle_error;
}
 
free(driverName); /* No longer needed. */
 
/*
* Get device-specific info. pDevPriv will point to a struct
* (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h) that
* has information about the screen size, depth, pitch, ancilliary
* buffers, DRM mmap handles, etc.
*/
if (!XF86DRIGetDeviceInfo(dpy, scrn, &hFB, &junk,
&framebuffer.size, &framebuffer.stride,
&framebuffer.dev_priv_size,
&framebuffer.dev_priv)) {
ErrorMessageF("XF86DRIGetDeviceInfo failed");
goto handle_error;
}
 
framebuffer.width = DisplayWidth(dpy, scrn);
framebuffer.height = DisplayHeight(dpy, scrn);
 
/* Map the framebuffer region. */
status = drmMap(fd, hFB, framebuffer.size,
(drmAddressPtr) & framebuffer.base);
if (status != 0) {
ErrorMessageF("drmMap of framebuffer failed (%s)", strerror(-status));
goto handle_error;
}
 
/* Map the SAREA region. Further mmap regions may be setup in
* each DRI driver's "createNewScreen" function.
*/
status = drmMap(fd, hSAREA, SAREA_MAX, &pSAREA);
if (status != 0) {
ErrorMessageF("drmMap of SAREA failed (%s)", strerror(-status));
goto handle_error;
}
 
psp = (*psc->legacy->createNewScreen) (scrn,
&ddx_version,
&dri_version,
&drm_version,
&framebuffer,
pSAREA,
fd,
loader_extensions,
&driver_configs, psc);
 
if (psp == NULL) {
ErrorMessageF("Calling driver entry point failed");
goto handle_error;
}
 
configs = driConvertConfigs(psc->core, psc->base.configs, driver_configs);
visuals = driConvertConfigs(psc->core, psc->base.visuals, driver_configs);
 
if (!configs || !visuals)
goto handle_error;
 
glx_config_destroy_list(psc->base.configs);
psc->base.configs = configs;
glx_config_destroy_list(psc->base.visuals);
psc->base.visuals = visuals;
 
psc->driver_configs = driver_configs;
 
/* Visuals with depth != screen depth are subject to automatic compositing
* in the X server, so DRI1 can't render to them properly. Mark them as
* non-conformant to prevent apps from picking them up accidentally.
*/
for (visual = psc->base.visuals; visual; visual = visual->next) {
XVisualInfo template;
XVisualInfo *visuals;
int num_visuals;
long mask;
 
template.visualid = visual->visualID;
mask = VisualIDMask;
visuals = XGetVisualInfo(dpy, mask, &template, &num_visuals);
 
if (visuals) {
if (num_visuals > 0 && visuals->depth != DefaultDepth(dpy, scrn))
visual->visualRating = GLX_NON_CONFORMANT_CONFIG;
 
free(visuals);
}
}
 
return psp;
 
handle_error:
if (configs)
glx_config_destroy_list(configs);
if (visuals)
glx_config_destroy_list(visuals);
 
if (pSAREA != MAP_FAILED)
drmUnmap(pSAREA, SAREA_MAX);
 
if (framebuffer.base != MAP_FAILED)
drmUnmap((drmAddress) framebuffer.base, framebuffer.size);
 
free(framebuffer.dev_priv);
 
if (fd >= 0)
drmCloseOnce(fd);
 
XF86DRICloseConnection(dpy, scrn);
 
ErrorMessageF("reverting to software direct rendering\n");
 
return NULL;
}
 
static void
dri_destroy_context(struct glx_context * context)
{
struct dri_context *pcp = (struct dri_context *) context;
struct dri_screen *psc = (struct dri_screen *) context->psc;
 
driReleaseDrawables(&pcp->base);
 
free((char *) context->extensions);
 
(*psc->core->destroyContext) (pcp->driContext);
 
XF86DRIDestroyContext(psc->base.dpy, psc->base.scr, pcp->hwContextID);
free(pcp);
}
 
static int
dri_bind_context(struct glx_context *context, struct glx_context *old,
GLXDrawable draw, GLXDrawable read)
{
struct dri_context *pcp = (struct dri_context *) context;
struct dri_screen *psc = (struct dri_screen *) pcp->base.psc;
struct dri_drawable *pdraw, *pread;
 
pdraw = (struct dri_drawable *) driFetchDrawable(context, draw);
pread = (struct dri_drawable *) driFetchDrawable(context, read);
 
driReleaseDrawables(&pcp->base);
 
if (pdraw == NULL || pread == NULL)
return GLXBadDrawable;
 
if ((*psc->core->bindContext) (pcp->driContext,
pdraw->driDrawable, pread->driDrawable))
return Success;
 
return GLXBadContext;
}
 
static void
dri_unbind_context(struct glx_context *context, struct glx_context *new)
{
struct dri_context *pcp = (struct dri_context *) context;
struct dri_screen *psc = (struct dri_screen *) pcp->base.psc;
 
(*psc->core->unbindContext) (pcp->driContext);
}
 
static const struct glx_context_vtable dri_context_vtable = {
dri_destroy_context,
dri_bind_context,
dri_unbind_context,
NULL,
NULL,
DRI_glXUseXFont,
NULL,
NULL,
NULL, /* get_proc_address */
};
 
static struct glx_context *
dri_create_context(struct glx_screen *base,
struct glx_config *config_base,
struct glx_context *shareList, int renderType)
{
struct dri_context *pcp, *pcp_shared;
struct dri_screen *psc = (struct dri_screen *) base;
drm_context_t hwContext;
__DRIcontext *shared = NULL;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
 
if (!psc->base.driScreen)
return NULL;
 
/* Check the renderType value */
if (!validate_renderType_against_config(config_base, renderType))
return NULL;
 
if (shareList) {
/* If the shareList context is not a DRI context, we cannot possibly
* create a DRI context that shares it.
*/
if (shareList->vtable->destroy != dri_destroy_context) {
return NULL;
}
 
pcp_shared = (struct dri_context *) shareList;
shared = pcp_shared->driContext;
}
 
pcp = calloc(1, sizeof *pcp);
if (pcp == NULL)
return NULL;
 
if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
free(pcp);
return NULL;
}
 
pcp->base.renderType = renderType;
 
if (!XF86DRICreateContextWithConfig(psc->base.dpy, psc->base.scr,
config->base.visualID,
&pcp->hwContextID, &hwContext)) {
free(pcp);
return NULL;
}
 
pcp->driContext =
(*psc->legacy->createNewContext) (psc->driScreen,
config->driConfig,
renderType, shared, hwContext, pcp);
if (pcp->driContext == NULL) {
XF86DRIDestroyContext(psc->base.dpy, psc->base.scr, pcp->hwContextID);
free(pcp);
return NULL;
}
 
pcp->base.vtable = &dri_context_vtable;
 
return &pcp->base;
}
 
static void
driDestroyDrawable(__GLXDRIdrawable * pdraw)
{
struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
 
(*psc->core->destroyDrawable) (pdp->driDrawable);
XF86DRIDestroyDrawable(psc->base.dpy, psc->base.scr, pdraw->drawable);
free(pdraw);
}
 
static __GLXDRIdrawable *
driCreateDrawable(struct glx_screen *base,
XID xDrawable,
GLXDrawable drawable, struct glx_config *config_base)
{
drm_drawable_t hwDrawable;
void *empty_attribute_list = NULL;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
struct dri_screen *psc = (struct dri_screen *) base;
struct dri_drawable *pdp;
 
/* Old dri can't handle GLX 1.3+ drawable constructors. */
if (xDrawable != drawable)
return NULL;
 
pdp = calloc(1, sizeof *pdp);
if (!pdp)
return NULL;
 
pdp->base.drawable = drawable;
pdp->base.psc = &psc->base;
 
if (!XF86DRICreateDrawable(psc->base.dpy, psc->base.scr,
drawable, &hwDrawable)) {
free(pdp);
return NULL;
}
 
/* Create a new drawable */
pdp->driDrawable =
(*psc->legacy->createNewDrawable) (psc->driScreen,
config->driConfig,
hwDrawable,
GLX_WINDOW_BIT,
empty_attribute_list, pdp);
 
if (!pdp->driDrawable) {
XF86DRIDestroyDrawable(psc->base.dpy, psc->base.scr, drawable);
free(pdp);
return NULL;
}
 
pdp->base.destroyDrawable = driDestroyDrawable;
 
return &pdp->base;
}
 
static int64_t
driSwapBuffers(__GLXDRIdrawable * pdraw, int64_t unused1, int64_t unused2,
int64_t unused3, Bool flush)
{
struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
 
if (flush) {
glFlush();
}
 
(*psc->core->swapBuffers) (pdp->driDrawable);
return 0;
}
 
static void
driCopySubBuffer(__GLXDRIdrawable * pdraw,
int x, int y, int width, int height, Bool flush)
{
struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
struct dri_screen *psc = (struct dri_screen *) pdp->base.psc;
 
if (flush) {
glFlush();
}
 
(*psc->driCopySubBuffer->copySubBuffer) (pdp->driDrawable,
x, y, width, height);
}
 
static void
driDestroyScreen(struct glx_screen *base)
{
struct dri_screen *psc = (struct dri_screen *) base;
 
/* Free the direct rendering per screen data */
if (psc->driScreen)
(*psc->core->destroyScreen) (psc->driScreen);
driDestroyConfigs(psc->driver_configs);
psc->driScreen = NULL;
if (psc->driver)
dlclose(psc->driver);
}
 
static int
driSetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
{
struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
 
if (psc->swapControl != NULL && pdraw != NULL) {
psc->swapControl->setSwapInterval(pdp->driDrawable, interval);
return 0;
}
 
return GLX_BAD_CONTEXT;
}
 
static int
driGetSwapInterval(__GLXDRIdrawable *pdraw)
{
struct dri_drawable *pdp = (struct dri_drawable *) pdraw;
struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
 
if (psc->swapControl != NULL && pdraw != NULL)
return psc->swapControl->getSwapInterval(pdp->driDrawable);
 
return 0;
}
 
/* Bind DRI1 specific extensions */
static void
driBindExtensions(struct dri_screen *psc, const __DRIextension **extensions)
{
int i;
 
for (i = 0; extensions[i]; i++) {
/* No DRI2 support for swap_control at the moment, since SwapBuffers
* is done by the X server */
if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) {
psc->swapControl = (__DRIswapControlExtension *) extensions[i];
__glXEnableDirectExtension(&psc->base, "GLX_SGI_swap_control");
__glXEnableDirectExtension(&psc->base, "GLX_MESA_swap_control");
}
 
if (strcmp(extensions[i]->name, __DRI_MEDIA_STREAM_COUNTER) == 0) {
psc->msc = (__DRImediaStreamCounterExtension *) extensions[i];
__glXEnableDirectExtension(&psc->base, "GLX_SGI_video_sync");
}
 
if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) {
psc->driCopySubBuffer = (__DRIcopySubBufferExtension *) extensions[i];
__glXEnableDirectExtension(&psc->base, "GLX_MESA_copy_sub_buffer");
}
 
if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) {
__glXEnableDirectExtension(&psc->base, "GLX_SGI_make_current_read");
}
/* Ignore unknown extensions */
}
}
 
static const struct glx_screen_vtable dri_screen_vtable = {
dri_create_context,
NULL
};
 
static struct glx_screen *
driCreateScreen(int screen, struct glx_display *priv)
{
struct dri_display *pdp;
__GLXDRIscreen *psp;
const __DRIextension **extensions;
struct dri_screen *psc;
char *driverName;
int i;
 
psc = calloc(1, sizeof *psc);
if (psc == NULL)
return NULL;
 
if (!glx_screen_init(&psc->base, screen, priv)) {
free(psc);
return NULL;
}
 
if (!driGetDriverName(priv->dpy, screen, &driverName)) {
goto cleanup;
}
 
psc->driver = driOpenDriver(driverName);
if (psc->driver == NULL)
goto cleanup;
 
extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
if (extensions == NULL) {
ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
goto cleanup;
}
 
for (i = 0; extensions[i]; i++) {
if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
psc->core = (__DRIcoreExtension *) extensions[i];
if (strcmp(extensions[i]->name, __DRI_LEGACY) == 0)
psc->legacy = (__DRIlegacyExtension *) extensions[i];
}
 
if (psc->core == NULL || psc->legacy == NULL)
goto cleanup;
 
pdp = (struct dri_display *) priv->driDisplay;
psc->driScreen =
CallCreateNewScreen(psc->base.dpy, screen, psc, pdp);
if (psc->driScreen == NULL)
goto cleanup;
 
extensions = psc->core->getExtensions(psc->driScreen);
driBindExtensions(psc, extensions);
 
psc->base.vtable = &dri_screen_vtable;
psp = &psc->vtable;
psc->base.driScreen = psp;
if (psc->driCopySubBuffer)
psp->copySubBuffer = driCopySubBuffer;
 
psp->destroyScreen = driDestroyScreen;
psp->createDrawable = driCreateDrawable;
psp->swapBuffers = driSwapBuffers;
 
psp->setSwapInterval = driSetSwapInterval;
psp->getSwapInterval = driGetSwapInterval;
 
free(driverName);
 
return &psc->base;
 
cleanup:
CriticalErrorMessageF("failed to load driver: %s\n", driverName);
 
free(driverName);
 
if (psc->driver)
dlclose(psc->driver);
glx_screen_cleanup(&psc->base);
free(psc);
 
return NULL;
}
 
/* Called from __glXFreeDisplayPrivate.
*/
static void
driDestroyDisplay(__GLXDRIdisplay * dpy)
{
free(dpy);
}
 
/*
* Allocate, initialize and return a __DRIdisplayPrivate object.
* This is called from __glXInitialize() when we are given a new
* display pointer.
*/
_X_HIDDEN __GLXDRIdisplay *
driCreateDisplay(Display * dpy)
{
struct dri_display *pdpyp;
int eventBase, errorBase;
int major, minor, patch;
 
if (!XF86DRIQueryExtension(dpy, &eventBase, &errorBase)) {
return NULL;
}
 
if (!XF86DRIQueryVersion(dpy, &major, &minor, &patch)) {
return NULL;
}
 
pdpyp = malloc(sizeof *pdpyp);
if (!pdpyp) {
return NULL;
}
 
pdpyp->driMajor = major;
pdpyp->driMinor = minor;
pdpyp->driPatch = patch;
 
pdpyp->base.destroyDisplay = driDestroyDisplay;
pdpyp->base.createScreen = driCreateScreen;
 
return &pdpyp->base;
}
 
#endif /* GLX_DIRECT_RENDERING */
/contrib/sdk/sources/Mesa/src/glx/drisw_glx.c
0,0 → 1,765
/*
* Copyright 2008 George Sapountzis
*
* 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.
*/
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
 
#include <X11/Xlib.h>
#include "glxclient.h"
#include <dlfcn.h>
#include "dri_common.h"
 
struct drisw_display
{
__GLXDRIdisplay base;
};
 
struct drisw_context
{
struct glx_context base;
__DRIcontext *driContext;
 
};
 
struct drisw_screen
{
struct glx_screen base;
 
__DRIscreen *driScreen;
__GLXDRIscreen vtable;
const __DRIcoreExtension *core;
const __DRIswrastExtension *swrast;
const __DRItexBufferExtension *texBuffer;
 
const __DRIconfig **driver_configs;
 
void *driver;
};
 
struct drisw_drawable
{
__GLXDRIdrawable base;
 
GC gc;
GC swapgc;
 
__DRIdrawable *driDrawable;
XVisualInfo *visinfo;
XImage *ximage;
};
 
static Bool
XCreateDrawable(struct drisw_drawable * pdp,
Display * dpy, XID drawable, int visualid)
{
XGCValues gcvalues;
long visMask;
XVisualInfo visTemp;
int num_visuals;
 
/* create GC's */
pdp->gc = XCreateGC(dpy, drawable, 0, NULL);
pdp->swapgc = XCreateGC(dpy, drawable, 0, NULL);
 
gcvalues.function = GXcopy;
gcvalues.graphics_exposures = False;
XChangeGC(dpy, pdp->gc, GCFunction, &gcvalues);
XChangeGC(dpy, pdp->swapgc, GCFunction, &gcvalues);
XChangeGC(dpy, pdp->swapgc, GCGraphicsExposures, &gcvalues);
 
/* visual */
visTemp.visualid = visualid;
visMask = VisualIDMask;
pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp, &num_visuals);
 
if (!pdp->visinfo || num_visuals == 0)
return False;
 
/* create XImage */
pdp->ximage = XCreateImage(dpy,
pdp->visinfo->visual,
pdp->visinfo->depth,
ZPixmap, 0, /* format, offset */
NULL, /* data */
0, 0, /* width, height */
32, /* bitmap_pad */
0); /* bytes_per_line */
 
/**
* swrast does not handle 24-bit depth with 24 bpp, so let X do the
* the conversion for us.
*/
if (pdp->ximage->bits_per_pixel == 24)
pdp->ximage->bits_per_pixel = 32;
 
return True;
}
 
static void
XDestroyDrawable(struct drisw_drawable * pdp, Display * dpy, XID drawable)
{
XDestroyImage(pdp->ximage);
free(pdp->visinfo);
 
XFreeGC(dpy, pdp->gc);
XFreeGC(dpy, pdp->swapgc);
}
 
/**
* swrast loader functions
*/
 
static void
swrastGetDrawableInfo(__DRIdrawable * draw,
int *x, int *y, int *w, int *h,
void *loaderPrivate)
{
struct drisw_drawable *pdp = loaderPrivate;
__GLXDRIdrawable *pdraw = &(pdp->base);
Display *dpy = pdraw->psc->dpy;
Drawable drawable;
 
Window root;
unsigned uw, uh, bw, depth;
 
drawable = pdraw->xDrawable;
 
XGetGeometry(dpy, drawable, &root, x, y, &uw, &uh, &bw, &depth);
*w = uw;
*h = uh;
}
 
/**
* Align renderbuffer pitch.
*
* This should be chosen by the driver and the loader (libGL, xserver/glx)
* should use the driver provided pitch.
*
* It seems that the xorg loader (that is the xserver loading swrast_dri for
* indirect rendering, not client-side libGL) requires that the pitch is
* exactly the image width padded to 32 bits. XXX
*
* The above restriction can probably be overcome by using ScratchPixmap and
* CopyArea in the xserver, similar to ShmPutImage, and setting the width of
* the scratch pixmap to 'pitch / cpp'.
*/
static inline int
bytes_per_line(unsigned pitch_bits, unsigned mul)
{
unsigned mask = mul - 1;
 
return ((pitch_bits + mask) & ~mask) / 8;
}
 
static void
swrastPutImage(__DRIdrawable * draw, int op,
int x, int y, int w, int h,
char *data, void *loaderPrivate)
{
struct drisw_drawable *pdp = loaderPrivate;
__GLXDRIdrawable *pdraw = &(pdp->base);
Display *dpy = pdraw->psc->dpy;
Drawable drawable;
XImage *ximage;
GC gc;
 
switch (op) {
case __DRI_SWRAST_IMAGE_OP_DRAW:
gc = pdp->gc;
break;
case __DRI_SWRAST_IMAGE_OP_SWAP:
gc = pdp->swapgc;
break;
default:
return;
}
 
drawable = pdraw->xDrawable;
 
ximage = pdp->ximage;
ximage->data = data;
ximage->width = w;
ximage->height = h;
ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32);
 
XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h);
 
ximage->data = NULL;
}
 
static void
swrastGetImage(__DRIdrawable * read,
int x, int y, int w, int h,
char *data, void *loaderPrivate)
{
struct drisw_drawable *prp = loaderPrivate;
__GLXDRIdrawable *pread = &(prp->base);
Display *dpy = pread->psc->dpy;
Drawable readable;
XImage *ximage;
 
readable = pread->xDrawable;
 
ximage = prp->ximage;
ximage->data = data;
ximage->width = w;
ximage->height = h;
ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32);
 
XGetSubImage(dpy, readable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0);
 
ximage->data = NULL;
}
 
static const __DRIswrastLoaderExtension swrastLoaderExtension = {
{__DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION},
swrastGetDrawableInfo,
swrastPutImage,
swrastGetImage
};
 
static const __DRIextension *loader_extensions[] = {
&systemTimeExtension.base,
&swrastLoaderExtension.base,
NULL
};
 
/**
* GLXDRI functions
*/
 
static void
drisw_destroy_context(struct glx_context *context)
{
struct drisw_context *pcp = (struct drisw_context *) context;
struct drisw_screen *psc = (struct drisw_screen *) context->psc;
 
driReleaseDrawables(&pcp->base);
 
free((char *) context->extensions);
 
(*psc->core->destroyContext) (pcp->driContext);
 
free(pcp);
}
 
static int
drisw_bind_context(struct glx_context *context, struct glx_context *old,
GLXDrawable draw, GLXDrawable read)
{
struct drisw_context *pcp = (struct drisw_context *) context;
struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc;
struct drisw_drawable *pdraw, *pread;
 
pdraw = (struct drisw_drawable *) driFetchDrawable(context, draw);
pread = (struct drisw_drawable *) driFetchDrawable(context, read);
 
driReleaseDrawables(&pcp->base);
 
if (pdraw == NULL || pread == NULL)
return GLXBadDrawable;
 
if ((*psc->core->bindContext) (pcp->driContext,
pdraw->driDrawable, pread->driDrawable))
return Success;
 
return GLXBadContext;
}
 
static void
drisw_unbind_context(struct glx_context *context, struct glx_context *new)
{
struct drisw_context *pcp = (struct drisw_context *) context;
struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc;
 
(*psc->core->unbindContext) (pcp->driContext);
}
 
static void
drisw_bind_tex_image(Display * dpy,
GLXDrawable drawable,
int buffer, const int *attrib_list)
{
struct glx_context *gc = __glXGetCurrentContext();
struct drisw_context *pcp = (struct drisw_context *) gc;
__GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
struct drisw_drawable *pdraw = (struct drisw_drawable *) base;
struct drisw_screen *psc;
 
__glXInitialize(dpy);
 
if (pdraw != NULL) {
psc = (struct drisw_screen *) base->psc;
 
if (!psc->texBuffer)
return;
 
if (psc->texBuffer->base.version >= 2 &&
psc->texBuffer->setTexBuffer2 != NULL) {
(*psc->texBuffer->setTexBuffer2) (pcp->driContext,
pdraw->base.textureTarget,
pdraw->base.textureFormat,
pdraw->driDrawable);
}
else {
(*psc->texBuffer->setTexBuffer) (pcp->driContext,
pdraw->base.textureTarget,
pdraw->driDrawable);
}
}
}
 
static void
drisw_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
{
#if __DRI_TEX_BUFFER_VERSION >= 3
struct glx_context *gc = __glXGetCurrentContext();
struct dri2_context *pcp = (struct dri2_context *) gc;
__GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
struct glx_display *dpyPriv = __glXInitialize(dpy);
struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
struct dri2_screen *psc;
 
if (pdraw != NULL) {
psc = (struct dri2_screen *) base->psc;
 
if (!psc->texBuffer)
return;
 
if (psc->texBuffer->base.version >= 3 &&
psc->texBuffer->releaseTexBuffer != NULL) {
(*psc->texBuffer->releaseTexBuffer) (pcp->driContext,
pdraw->base.textureTarget,
pdraw->driDrawable);
}
}
#endif
}
 
static const struct glx_context_vtable drisw_context_vtable = {
drisw_destroy_context,
drisw_bind_context,
drisw_unbind_context,
NULL,
NULL,
DRI_glXUseXFont,
drisw_bind_tex_image,
drisw_release_tex_image,
NULL, /* get_proc_address */
};
 
static struct glx_context *
drisw_create_context(struct glx_screen *base,
struct glx_config *config_base,
struct glx_context *shareList, int renderType)
{
struct drisw_context *pcp, *pcp_shared;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
struct drisw_screen *psc = (struct drisw_screen *) base;
__DRIcontext *shared = NULL;
 
if (!psc->base.driScreen)
return NULL;
 
/* Check the renderType value */
if (!validate_renderType_against_config(config_base, renderType))
return NULL;
 
if (shareList) {
/* If the shareList context is not a DRISW context, we cannot possibly
* create a DRISW context that shares it.
*/
if (shareList->vtable->destroy != drisw_destroy_context) {
return NULL;
}
 
pcp_shared = (struct drisw_context *) shareList;
shared = pcp_shared->driContext;
}
 
pcp = calloc(1, sizeof *pcp);
if (pcp == NULL)
return NULL;
 
if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
free(pcp);
return NULL;
}
 
pcp->base.renderType = renderType;
 
pcp->driContext =
(*psc->core->createNewContext) (psc->driScreen,
config->driConfig, shared, pcp);
if (pcp->driContext == NULL) {
free(pcp);
return NULL;
}
 
pcp->base.vtable = &drisw_context_vtable;
 
return &pcp->base;
}
 
static struct glx_context *
drisw_create_context_attribs(struct glx_screen *base,
struct glx_config *config_base,
struct glx_context *shareList,
unsigned num_attribs,
const uint32_t *attribs,
unsigned *error)
{
struct drisw_context *pcp, *pcp_shared;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
struct drisw_screen *psc = (struct drisw_screen *) base;
__DRIcontext *shared = NULL;
 
uint32_t minor_ver;
uint32_t major_ver;
uint32_t renderType;
uint32_t flags;
unsigned api;
int reset;
uint32_t ctx_attribs[2 * 4];
unsigned num_ctx_attribs = 0;
 
if (!psc->base.driScreen)
return NULL;
 
if (psc->swrast->base.version < 3)
return NULL;
 
/* Remap the GLX tokens to DRI2 tokens.
*/
if (!dri2_convert_glx_attribs(num_attribs, attribs,
&major_ver, &minor_ver, &renderType, &flags,
&api, &reset, error))
return NULL;
 
/* Check the renderType value */
if (!validate_renderType_against_config(config_base, renderType)) {
return NULL;
}
 
if (reset != __DRI_CTX_RESET_NO_NOTIFICATION)
return NULL;
 
if (shareList) {
pcp_shared = (struct drisw_context *) shareList;
shared = pcp_shared->driContext;
}
 
pcp = calloc(1, sizeof *pcp);
if (pcp == NULL)
return NULL;
 
if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
free(pcp);
return NULL;
}
 
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MAJOR_VERSION;
ctx_attribs[num_ctx_attribs++] = major_ver;
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_MINOR_VERSION;
ctx_attribs[num_ctx_attribs++] = minor_ver;
 
if (flags != 0) {
ctx_attribs[num_ctx_attribs++] = __DRI_CTX_ATTRIB_FLAGS;
 
/* The current __DRI_CTX_FLAG_* values are identical to the
* GLX_CONTEXT_*_BIT values.
*/
ctx_attribs[num_ctx_attribs++] = flags;
}
 
pcp->base.renderType = renderType;
 
pcp->driContext =
(*psc->swrast->createContextAttribs) (psc->driScreen,
api,
config->driConfig,
shared,
num_ctx_attribs / 2,
ctx_attribs,
error,
pcp);
if (pcp->driContext == NULL) {
free(pcp);
return NULL;
}
 
pcp->base.vtable = &drisw_context_vtable;
 
return &pcp->base;
}
 
static void
driswDestroyDrawable(__GLXDRIdrawable * pdraw)
{
struct drisw_drawable *pdp = (struct drisw_drawable *) pdraw;
struct drisw_screen *psc = (struct drisw_screen *) pdp->base.psc;
 
(*psc->core->destroyDrawable) (pdp->driDrawable);
 
XDestroyDrawable(pdp, pdraw->psc->dpy, pdraw->drawable);
free(pdp);
}
 
static __GLXDRIdrawable *
driswCreateDrawable(struct glx_screen *base, XID xDrawable,
GLXDrawable drawable, struct glx_config *modes)
{
struct drisw_drawable *pdp;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
struct drisw_screen *psc = (struct drisw_screen *) base;
Bool ret;
const __DRIswrastExtension *swrast = psc->swrast;
 
pdp = calloc(1, sizeof(*pdp));
if (!pdp)
return NULL;
 
pdp->base.xDrawable = xDrawable;
pdp->base.drawable = drawable;
pdp->base.psc = &psc->base;
 
ret = XCreateDrawable(pdp, psc->base.dpy, xDrawable, modes->visualID);
if (!ret) {
free(pdp);
return NULL;
}
 
/* Create a new drawable */
pdp->driDrawable =
(*swrast->createNewDrawable) (psc->driScreen, config->driConfig, pdp);
 
if (!pdp->driDrawable) {
XDestroyDrawable(pdp, psc->base.dpy, xDrawable);
free(pdp);
return NULL;
}
 
pdp->base.destroyDrawable = driswDestroyDrawable;
 
return &pdp->base;
}
 
static int64_t
driswSwapBuffers(__GLXDRIdrawable * pdraw,
int64_t target_msc, int64_t divisor, int64_t remainder,
Bool flush)
{
struct drisw_drawable *pdp = (struct drisw_drawable *) pdraw;
struct drisw_screen *psc = (struct drisw_screen *) pdp->base.psc;
 
(void) target_msc;
(void) divisor;
(void) remainder;
 
if (flush) {
glFlush();
}
 
(*psc->core->swapBuffers) (pdp->driDrawable);
 
return 0;
}
 
static void
driswDestroyScreen(struct glx_screen *base)
{
struct drisw_screen *psc = (struct drisw_screen *) base;
 
/* Free the direct rendering per screen data */
(*psc->core->destroyScreen) (psc->driScreen);
driDestroyConfigs(psc->driver_configs);
psc->driScreen = NULL;
if (psc->driver)
dlclose(psc->driver);
}
 
#define SWRAST_DRIVER_NAME "swrast"
 
static void *
driOpenSwrast(void)
{
void *driver = NULL;
 
if (driver == NULL)
driver = driOpenDriver(SWRAST_DRIVER_NAME);
 
return driver;
}
 
static const struct glx_screen_vtable drisw_screen_vtable = {
drisw_create_context,
drisw_create_context_attribs
};
 
static void
driswBindExtensions(struct drisw_screen *psc, const __DRIextension **extensions)
{
int i;
 
__glXEnableDirectExtension(&psc->base, "GLX_SGI_make_current_read");
 
if (psc->swrast->base.version >= 3) {
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
 
/* DRISW version >= 2 implies support for OpenGL ES 2.0.
*/
__glXEnableDirectExtension(&psc->base,
"GLX_EXT_create_context_es2_profile");
}
 
/* FIXME: Figure out what other extensions can be ported here from dri2. */
for (i = 0; extensions[i]; i++) {
if ((strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) {
psc->texBuffer = (__DRItexBufferExtension *) extensions[i];
__glXEnableDirectExtension(&psc->base, "GLX_EXT_texture_from_pixmap");
}
}
}
 
static struct glx_screen *
driswCreateScreen(int screen, struct glx_display *priv)
{
__GLXDRIscreen *psp;
const __DRIconfig **driver_configs;
const __DRIextension **extensions;
struct drisw_screen *psc;
struct glx_config *configs = NULL, *visuals = NULL;
int i;
 
psc = calloc(1, sizeof *psc);
if (psc == NULL)
return NULL;
 
if (!glx_screen_init(&psc->base, screen, priv)) {
free(psc);
return NULL;
}
 
psc->driver = driOpenSwrast();
if (psc->driver == NULL)
goto handle_error;
 
extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
if (extensions == NULL) {
ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
goto handle_error;
}
 
for (i = 0; extensions[i]; i++) {
if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
psc->core = (__DRIcoreExtension *) extensions[i];
if (strcmp(extensions[i]->name, __DRI_SWRAST) == 0)
psc->swrast = (__DRIswrastExtension *) extensions[i];
}
 
if (psc->core == NULL || psc->swrast == NULL) {
ErrorMessageF("core dri extension not found\n");
goto handle_error;
}
 
psc->driScreen =
psc->swrast->createNewScreen(screen, loader_extensions,
&driver_configs, psc);
if (psc->driScreen == NULL) {
ErrorMessageF("failed to create dri screen\n");
goto handle_error;
}
 
extensions = psc->core->getExtensions(psc->driScreen);
driswBindExtensions(psc, extensions);
 
configs = driConvertConfigs(psc->core, psc->base.configs, driver_configs);
visuals = driConvertConfigs(psc->core, psc->base.visuals, driver_configs);
 
if (!configs || !visuals)
goto handle_error;
 
glx_config_destroy_list(psc->base.configs);
psc->base.configs = configs;
glx_config_destroy_list(psc->base.visuals);
psc->base.visuals = visuals;
 
psc->driver_configs = driver_configs;
 
psc->base.vtable = &drisw_screen_vtable;
psp = &psc->vtable;
psc->base.driScreen = psp;
psp->destroyScreen = driswDestroyScreen;
psp->createDrawable = driswCreateDrawable;
psp->swapBuffers = driswSwapBuffers;
 
return &psc->base;
 
handle_error:
if (configs)
glx_config_destroy_list(configs);
if (visuals)
glx_config_destroy_list(visuals);
if (psc->driScreen)
psc->core->destroyScreen(psc->driScreen);
psc->driScreen = NULL;
 
if (psc->driver)
dlclose(psc->driver);
glx_screen_cleanup(&psc->base);
free(psc);
 
CriticalErrorMessageF("failed to load driver: %s\n", SWRAST_DRIVER_NAME);
 
return NULL;
}
 
/* Called from __glXFreeDisplayPrivate.
*/
static void
driswDestroyDisplay(__GLXDRIdisplay * dpy)
{
free(dpy);
}
 
/*
* Allocate, initialize and return a __DRIdisplayPrivate object.
* This is called from __glXInitialize() when we are given a new
* display pointer.
*/
_X_HIDDEN __GLXDRIdisplay *
driswCreateDisplay(Display * dpy)
{
struct drisw_display *pdpyp;
 
pdpyp = malloc(sizeof *pdpyp);
if (pdpyp == NULL)
return NULL;
 
pdpyp->base.destroyDisplay = driswDestroyDisplay;
pdpyp->base.createScreen = driswCreateScreen;
 
return &pdpyp->base;
}
 
#endif /* GLX_DIRECT_RENDERING */
/contrib/sdk/sources/Mesa/src/glx/eval.c
0,0 → 1,132
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
#include "packrender.h"
 
/*
** Routines to pack evaluator maps into the transport buffer. Maps are
** allowed to have extra arbitrary data, so these routines extract just
** the information that the GL needs.
*/
 
void
__glFillMap1f(GLint k, GLint order, GLint stride,
const GLfloat * points, GLubyte * pc)
{
if (stride == k) {
/* Just copy the data */
__GLX_PUT_FLOAT_ARRAY(0, points, order * k);
}
else {
GLint i;
 
for (i = 0; i < order; i++) {
__GLX_PUT_FLOAT_ARRAY(0, points, k);
points += stride;
pc += k * __GLX_SIZE_FLOAT32;
}
}
}
 
void
__glFillMap1d(GLint k, GLint order, GLint stride,
const GLdouble * points, GLubyte * pc)
{
if (stride == k) {
/* Just copy the data */
__GLX_PUT_DOUBLE_ARRAY(0, points, order * k);
}
else {
GLint i;
for (i = 0; i < order; i++) {
__GLX_PUT_DOUBLE_ARRAY(0, points, k);
points += stride;
pc += k * __GLX_SIZE_FLOAT64;
}
}
}
 
void
__glFillMap2f(GLint k, GLint majorOrder, GLint minorOrder,
GLint majorStride, GLint minorStride,
const GLfloat * points, GLfloat * data)
{
GLint i, j, x;
 
if ((minorStride == k) && (majorStride == minorOrder * k)) {
/* Just copy the data */
__GLX_MEM_COPY(data, points, majorOrder * majorStride *
__GLX_SIZE_FLOAT32);
return;
}
for (i = 0; i < majorOrder; i++) {
for (j = 0; j < minorOrder; j++) {
for (x = 0; x < k; x++) {
data[x] = points[x];
}
points += minorStride;
data += k;
}
points += majorStride - minorStride * minorOrder;
}
}
 
void
__glFillMap2d(GLint k, GLint majorOrder, GLint minorOrder,
GLint majorStride, GLint minorStride,
const GLdouble * points, GLdouble * data)
{
int i, j, x;
 
if ((minorStride == k) && (majorStride == minorOrder * k)) {
/* Just copy the data */
__GLX_MEM_COPY(data, points, majorOrder * majorStride *
__GLX_SIZE_FLOAT64);
return;
}
 
#ifdef __GLX_ALIGN64
x = k * __GLX_SIZE_FLOAT64;
#endif
for (i = 0; i < majorOrder; i++) {
for (j = 0; j < minorOrder; j++) {
#ifdef __GLX_ALIGN64
__GLX_MEM_COPY(data, points, x);
#else
for (x = 0; x < k; x++) {
data[x] = points[x];
}
#endif
points += minorStride;
data += k;
}
points += majorStride - minorStride * minorOrder;
}
}
/contrib/sdk/sources/Mesa/src/glx/glx_error.c
0,0 → 1,86
/*
Copyright (c) 2009 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#include <stdbool.h>
#include <assert.h>
#include <X11/Xlibint.h>
#include <X11/extensions/extutil.h>
#include <X11/extensions/Xext.h>
#include "glxclient.h"
#include "glx_error.h"
 
void
__glXSendError(Display * dpy, int_fast8_t errorCode, uint_fast32_t resourceID,
uint_fast16_t minorCode, bool coreX11error)
{
struct glx_display *glx_dpy = __glXInitialize(dpy);
struct glx_context *gc = __glXGetCurrentContext();
xError error;
 
assert(glx_dpy);
assert(gc);
 
LockDisplay(dpy);
 
error.type = X_Error;
 
if (coreX11error) {
error.errorCode = errorCode;
}
else {
error.errorCode = glx_dpy->codes->first_error + errorCode;
}
 
error.sequenceNumber = dpy->request;
error.resourceID = resourceID;
error.minorCode = minorCode;
error.majorCode = gc ? gc->majorOpcode : 0;
 
_XError(dpy, &error);
 
UnlockDisplay(dpy);
}
 
void
__glXSendErrorForXcb(Display * dpy, const xcb_generic_error_t *err)
{
xError error;
 
LockDisplay(dpy);
 
error.type = X_Error;
error.errorCode = err->error_code;
error.sequenceNumber = err->sequence;
error.resourceID = err->resource_id;
error.minorCode = err->minor_code;
error.majorCode = err->major_code;
 
_XError(dpy, &error);
 
UnlockDisplay(dpy);
}
/contrib/sdk/sources/Mesa/src/glx/glx_error.h
0,0 → 1,39
/*
Copyright (c) 2009 Apple 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 THE ABOVE LISTED COPYRIGHT
HOLDER(S) 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(s) of the above
copyright holders shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software without
prior written authorization.
*/
#include <stdbool.h>
#include <stdint.h>
#include <X11/Xlib.h>
#include <xcb/xcb.h>
 
void __glXSendError(Display * dpy, int_fast8_t errorCode,
uint_fast32_t resourceID, uint_fast16_t minorCode,
bool coreX11error);
 
_X_HIDDEN void __glXSendErrorForXcb(Display * dpy,
const xcb_generic_error_t *err);
/contrib/sdk/sources/Mesa/src/glx/glx_pbuffer.c
0,0 → 1,968
/*
* (C) Copyright IBM Corporation 2004
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* IBM AND/OR THEIR 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.
*/
 
/**
* \file glx_pbuffer.c
* Implementation of pbuffer related functions.
*
* \author Ian Romanick <idr@us.ibm.com>
*/
 
#include <inttypes.h>
#include "glxclient.h"
#include <X11/extensions/extutil.h>
#include <X11/extensions/Xext.h>
#include <assert.h>
#include <string.h>
#include "glxextensions.h"
 
#ifdef GLX_USE_APPLEGL
#include <pthread.h>
#include "apple_glx_drawable.h"
#endif
 
#include "glx_error.h"
 
#define WARN_ONCE_GLX_1_3(a, b) { \
static int warned=1; \
if(warned) { \
warn_GLX_1_3((a), b ); \
warned=0; \
} \
}
 
/**
* Emit a warning when clients use GLX 1.3 functions on pre-1.3 systems.
*/
static void
warn_GLX_1_3(Display * dpy, const char *function_name)
{
struct glx_display *priv = __glXInitialize(dpy);
 
if (priv->minorVersion < 3) {
fprintf(stderr,
"WARNING: Application calling GLX 1.3 function \"%s\" "
"when GLX 1.3 is not supported! This is an application bug!\n",
function_name);
}
}
 
#ifndef GLX_USE_APPLEGL
/**
* Change a drawable's attribute.
*
* This function is used to implement \c glXSelectEvent and
* \c glXSelectEventSGIX.
*
* \note
* This function dynamically determines whether to use the SGIX_pbuffer
* version of the protocol or the GLX 1.3 version of the protocol.
*/
static void
ChangeDrawableAttribute(Display * dpy, GLXDrawable drawable,
const CARD32 * attribs, size_t num_attribs)
{
struct glx_display *priv = __glXInitialize(dpy);
#ifdef GLX_DIRECT_RENDERING
__GLXDRIdrawable *pdraw;
#endif
CARD32 *output;
CARD8 opcode;
int i;
 
if ((dpy == NULL) || (drawable == 0)) {
return;
}
 
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return;
 
LockDisplay(dpy);
 
if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
xGLXChangeDrawableAttributesReq *req;
 
GetReqExtra(GLXChangeDrawableAttributes, 8 * num_attribs, req);
output = (CARD32 *) (req + 1);
 
req->reqType = opcode;
req->glxCode = X_GLXChangeDrawableAttributes;
req->drawable = drawable;
req->numAttribs = (CARD32) num_attribs;
}
else {
xGLXVendorPrivateWithReplyReq *vpreq;
 
GetReqExtra(GLXVendorPrivateWithReply, 8 + (8 * num_attribs), vpreq);
output = (CARD32 *) (vpreq + 1);
 
vpreq->reqType = opcode;
vpreq->glxCode = X_GLXVendorPrivateWithReply;
vpreq->vendorCode = X_GLXvop_ChangeDrawableAttributesSGIX;
 
output[0] = (CARD32) drawable;
output[1] = num_attribs;
output += 2;
}
 
(void) memcpy(output, attribs, sizeof(CARD32) * 2 * num_attribs);
 
UnlockDisplay(dpy);
SyncHandle();
 
#ifdef GLX_DIRECT_RENDERING
pdraw = GetGLXDRIDrawable(dpy, drawable);
 
if (!pdraw)
return;
 
for (i = 0; i < num_attribs; i++) {
switch(attribs[i * 2]) {
case GLX_EVENT_MASK:
/* Keep a local copy for masking out DRI2 proto events as needed */
pdraw->eventMask = attribs[i * 2 + 1];
break;
}
}
#endif
 
return;
}
 
 
#ifdef GLX_DIRECT_RENDERING
static GLenum
determineTextureTarget(const int *attribs, int numAttribs)
{
GLenum target = 0;
int i;
 
for (i = 0; i < numAttribs; i++) {
if (attribs[2 * i] == GLX_TEXTURE_TARGET_EXT) {
switch (attribs[2 * i + 1]) {
case GLX_TEXTURE_2D_EXT:
target = GL_TEXTURE_2D;
break;
case GLX_TEXTURE_RECTANGLE_EXT:
target = GL_TEXTURE_RECTANGLE_ARB;
break;
}
}
}
 
return target;
}
 
static GLenum
determineTextureFormat(const int *attribs, int numAttribs)
{
int i;
 
for (i = 0; i < numAttribs; i++) {
if (attribs[2 * i] == GLX_TEXTURE_FORMAT_EXT)
return attribs[2 * i + 1];
}
 
return 0;
}
 
static GLboolean
CreateDRIDrawable(Display *dpy, struct glx_config *config,
XID drawable, XID glxdrawable,
const int *attrib_list, size_t num_attribs)
{
struct glx_display *const priv = __glXInitialize(dpy);
__GLXDRIdrawable *pdraw;
struct glx_screen *psc;
 
psc = priv->screens[config->screen];
if (psc->driScreen == NULL)
return GL_TRUE;
 
pdraw = psc->driScreen->createDrawable(psc, drawable,
glxdrawable, config);
if (pdraw == NULL) {
fprintf(stderr, "failed to create drawable\n");
return GL_FALSE;
}
 
if (__glxHashInsert(priv->drawHash, glxdrawable, pdraw)) {
(*pdraw->destroyDrawable) (pdraw);
return GL_FALSE;
}
 
pdraw->textureTarget = determineTextureTarget(attrib_list, num_attribs);
pdraw->textureFormat = determineTextureFormat(attrib_list, num_attribs);
 
return GL_TRUE;
}
 
static void
DestroyDRIDrawable(Display *dpy, GLXDrawable drawable, int destroy_xdrawable)
{
struct glx_display *const priv = __glXInitialize(dpy);
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
XID xid;
 
if (pdraw != NULL) {
xid = pdraw->xDrawable;
(*pdraw->destroyDrawable) (pdraw);
__glxHashDelete(priv->drawHash, drawable);
if (destroy_xdrawable)
XFreePixmap(priv->dpy, xid);
}
}
 
#else
 
static GLboolean
CreateDRIDrawable(Display *dpy, const struct glx_config * fbconfig,
XID drawable, XID glxdrawable,
const int *attrib_list, size_t num_attribs)
{
return GL_TRUE;
}
 
static void
DestroyDRIDrawable(Display *dpy, GLXDrawable drawable, int destroy_xdrawable)
{
}
 
#endif
 
/**
* Get a drawable's attribute.
*
* This function is used to implement \c glXGetSelectedEvent and
* \c glXGetSelectedEventSGIX.
*
* \note
* This function dynamically determines whether to use the SGIX_pbuffer
* version of the protocol or the GLX 1.3 version of the protocol.
*
* \todo
* The number of attributes returned is likely to be small, probably less than
* 10. Given that, this routine should try to use an array on the stack to
* capture the reply rather than always calling Xmalloc.
*/
static int
GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
int attribute, unsigned int *value)
{
struct glx_display *priv;
xGLXGetDrawableAttributesReply reply;
CARD32 *data;
CARD8 opcode;
unsigned int length;
unsigned int i;
unsigned int num_attributes;
GLboolean use_glx_1_3;
 
if (dpy == NULL)
return 0;
 
/* Page 38 (page 52 of the PDF) of glxencode1.3.pdf says:
*
* "If drawable is not a valid GLX drawable, a GLXBadDrawable error is
* generated."
*/
if (drawable == 0) {
__glXSendError(dpy, GLXBadDrawable, 0, X_GLXGetDrawableAttributes, false);
return 0;
}
 
priv = __glXInitialize(dpy);
use_glx_1_3 = ((priv->majorVersion > 1) || (priv->minorVersion >= 3));
 
*value = 0;
 
 
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return 0;
 
LockDisplay(dpy);
 
if (use_glx_1_3) {
xGLXGetDrawableAttributesReq *req;
 
GetReq(GLXGetDrawableAttributes, req);
req->reqType = opcode;
req->glxCode = X_GLXGetDrawableAttributes;
req->drawable = drawable;
}
else {
xGLXVendorPrivateWithReplyReq *vpreq;
 
GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq);
data = (CARD32 *) (vpreq + 1);
data[0] = (CARD32) drawable;
 
vpreq->reqType = opcode;
vpreq->glxCode = X_GLXVendorPrivateWithReply;
vpreq->vendorCode = X_GLXvop_GetDrawableAttributesSGIX;
}
 
_XReply(dpy, (xReply *) & reply, 0, False);
 
if (reply.type == X_Error) {
UnlockDisplay(dpy);
SyncHandle();
return 0;
}
 
length = reply.length;
if (length) {
num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2;
data = malloc(length * sizeof(CARD32));
if (data == NULL) {
/* Throw data on the floor */
_XEatData(dpy, length);
}
else {
_XRead(dpy, (char *) data, length * sizeof(CARD32));
 
/* Search the set of returned attributes for the attribute requested by
* the caller.
*/
for (i = 0; i < num_attributes; i++) {
if (data[i * 2] == attribute) {
*value = data[(i * 2) + 1];
break;
}
}
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
{
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
 
if (pdraw != NULL && !pdraw->textureTarget)
pdraw->textureTarget =
determineTextureTarget((const int *) data, num_attributes);
if (pdraw != NULL && !pdraw->textureFormat)
pdraw->textureFormat =
determineTextureFormat((const int *) data, num_attributes);
}
#endif
 
free(data);
}
}
 
UnlockDisplay(dpy);
SyncHandle();
 
return 0;
}
 
static void
protocolDestroyDrawable(Display *dpy, GLXDrawable drawable, CARD32 glxCode)
{
xGLXDestroyPbufferReq *req;
CARD8 opcode;
 
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return;
 
LockDisplay(dpy);
 
GetReq(GLXDestroyPbuffer, req);
req->reqType = opcode;
req->glxCode = glxCode;
req->pbuffer = (GLXPbuffer) drawable;
 
UnlockDisplay(dpy);
SyncHandle();
}
 
/**
* Create a non-pbuffer GLX drawable.
*/
static GLXDrawable
CreateDrawable(Display *dpy, struct glx_config *config,
Drawable drawable, const int *attrib_list, CARD8 glxCode)
{
xGLXCreateWindowReq *req;
struct glx_drawable *glxDraw;
CARD32 *data;
unsigned int i;
CARD8 opcode;
GLXDrawable xid;
 
i = 0;
if (attrib_list) {
while (attrib_list[i * 2] != None)
i++;
}
 
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return None;
 
glxDraw = malloc(sizeof(*glxDraw));
if (!glxDraw)
return None;
 
LockDisplay(dpy);
GetReqExtra(GLXCreateWindow, 8 * i, req);
data = (CARD32 *) (req + 1);
 
req->reqType = opcode;
req->glxCode = glxCode;
req->screen = config->screen;
req->fbconfig = config->fbconfigID;
req->window = drawable;
req->glxwindow = xid = XAllocID(dpy);
req->numAttribs = i;
 
if (attrib_list)
memcpy(data, attrib_list, 8 * i);
 
UnlockDisplay(dpy);
SyncHandle();
 
if (InitGLXDrawable(dpy, glxDraw, drawable, xid)) {
free(glxDraw);
return None;
}
 
if (!CreateDRIDrawable(dpy, config, drawable, xid, attrib_list, i)) {
if (glxCode == X_GLXCreatePixmap)
glxCode = X_GLXDestroyPixmap;
else
glxCode = X_GLXDestroyWindow;
protocolDestroyDrawable(dpy, xid, glxCode);
xid = None;
}
 
return xid;
}
 
 
/**
* Destroy a non-pbuffer GLX drawable.
*/
static void
DestroyDrawable(Display * dpy, GLXDrawable drawable, CARD32 glxCode)
{
if ((dpy == NULL) || (drawable == 0)) {
return;
}
 
protocolDestroyDrawable(dpy, drawable, glxCode);
 
DestroyGLXDrawable(dpy, drawable);
DestroyDRIDrawable(dpy, drawable, GL_FALSE);
 
return;
}
 
 
/**
* Create a pbuffer.
*
* This function is used to implement \c glXCreatePbuffer and
* \c glXCreateGLXPbufferSGIX.
*
* \note
* This function dynamically determines whether to use the SGIX_pbuffer
* version of the protocol or the GLX 1.3 version of the protocol.
*/
static GLXDrawable
CreatePbuffer(Display * dpy, struct glx_config *config,
unsigned int width, unsigned int height,
const int *attrib_list, GLboolean size_in_attribs)
{
struct glx_display *priv = __glXInitialize(dpy);
GLXDrawable id = 0;
CARD32 *data;
CARD8 opcode;
unsigned int i;
Pixmap pixmap;
GLboolean glx_1_3 = GL_FALSE;
 
i = 0;
if (attrib_list) {
while (attrib_list[i * 2])
i++;
}
 
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return None;
 
LockDisplay(dpy);
id = XAllocID(dpy);
 
if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
xGLXCreatePbufferReq *req;
unsigned int extra = (size_in_attribs) ? 0 : 2;
 
glx_1_3 = GL_TRUE;
 
GetReqExtra(GLXCreatePbuffer, (8 * (i + extra)), req);
data = (CARD32 *) (req + 1);
 
req->reqType = opcode;
req->glxCode = X_GLXCreatePbuffer;
req->screen = config->screen;
req->fbconfig = config->fbconfigID;
req->pbuffer = id;
req->numAttribs = i + extra;
 
if (!size_in_attribs) {
data[(2 * i) + 0] = GLX_PBUFFER_WIDTH;
data[(2 * i) + 1] = width;
data[(2 * i) + 2] = GLX_PBUFFER_HEIGHT;
data[(2 * i) + 3] = height;
data += 4;
}
}
else {
xGLXVendorPrivateReq *vpreq;
 
GetReqExtra(GLXVendorPrivate, 20 + (8 * i), vpreq);
data = (CARD32 *) (vpreq + 1);
 
vpreq->reqType = opcode;
vpreq->glxCode = X_GLXVendorPrivate;
vpreq->vendorCode = X_GLXvop_CreateGLXPbufferSGIX;
 
data[0] = config->screen;
data[1] = config->fbconfigID;
data[2] = id;
data[3] = width;
data[4] = height;
data += 5;
}
 
(void) memcpy(data, attrib_list, sizeof(CARD32) * 2 * i);
 
UnlockDisplay(dpy);
SyncHandle();
 
pixmap = XCreatePixmap(dpy, RootWindow(dpy, config->screen),
width, height, config->rgbBits);
 
if (!CreateDRIDrawable(dpy, config, pixmap, id, attrib_list, i)) {
CARD32 o = glx_1_3 ? X_GLXDestroyPbuffer : X_GLXvop_DestroyGLXPbufferSGIX;
XFreePixmap(dpy, pixmap);
protocolDestroyDrawable(dpy, id, o);
id = None;
}
 
return id;
}
 
/**
* Destroy a pbuffer.
*
* This function is used to implement \c glXDestroyPbuffer and
* \c glXDestroyGLXPbufferSGIX.
*
* \note
* This function dynamically determines whether to use the SGIX_pbuffer
* version of the protocol or the GLX 1.3 version of the protocol.
*/
static void
DestroyPbuffer(Display * dpy, GLXDrawable drawable)
{
struct glx_display *priv = __glXInitialize(dpy);
CARD8 opcode;
 
if ((dpy == NULL) || (drawable == 0)) {
return;
}
 
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return;
 
LockDisplay(dpy);
 
if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
xGLXDestroyPbufferReq *req;
 
GetReq(GLXDestroyPbuffer, req);
req->reqType = opcode;
req->glxCode = X_GLXDestroyPbuffer;
req->pbuffer = (GLXPbuffer) drawable;
}
else {
xGLXVendorPrivateWithReplyReq *vpreq;
CARD32 *data;
 
GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq);
data = (CARD32 *) (vpreq + 1);
 
data[0] = (CARD32) drawable;
 
vpreq->reqType = opcode;
vpreq->glxCode = X_GLXVendorPrivateWithReply;
vpreq->vendorCode = X_GLXvop_DestroyGLXPbufferSGIX;
}
 
UnlockDisplay(dpy);
SyncHandle();
 
DestroyDRIDrawable(dpy, drawable, GL_TRUE);
 
return;
}
 
/**
* Create a new pbuffer.
*/
_X_EXPORT GLXPbufferSGIX
glXCreateGLXPbufferSGIX(Display * dpy, GLXFBConfigSGIX config,
unsigned int width, unsigned int height,
int *attrib_list)
{
return (GLXPbufferSGIX) CreatePbuffer(dpy, (struct glx_config *) config,
width, height,
attrib_list, GL_FALSE);
}
 
#endif /* GLX_USE_APPLEGL */
 
/**
* Create a new pbuffer.
*/
_X_EXPORT GLXPbuffer
glXCreatePbuffer(Display * dpy, GLXFBConfig config, const int *attrib_list)
{
int i, width, height;
#ifdef GLX_USE_APPLEGL
GLXPbuffer result;
int errorcode;
#endif
 
width = 0;
height = 0;
 
WARN_ONCE_GLX_1_3(dpy, __func__);
 
#ifdef GLX_USE_APPLEGL
for (i = 0; attrib_list[i]; ++i) {
switch (attrib_list[i]) {
case GLX_PBUFFER_WIDTH:
width = attrib_list[i + 1];
++i;
break;
 
case GLX_PBUFFER_HEIGHT:
height = attrib_list[i + 1];
++i;
break;
 
case GLX_LARGEST_PBUFFER:
/* This is a hint we should probably handle, but how? */
++i;
break;
 
case GLX_PRESERVED_CONTENTS:
/* The contents are always preserved with AppleSGLX with CGL. */
++i;
break;
 
default:
return None;
}
}
 
if (apple_glx_pbuffer_create(dpy, config, width, height, &errorcode,
&result)) {
/*
* apple_glx_pbuffer_create only sets the errorcode to core X11
* errors.
*/
__glXSendError(dpy, errorcode, 0, X_GLXCreatePbuffer, true);
 
return None;
}
 
return result;
#else
for (i = 0; attrib_list[i * 2]; i++) {
switch (attrib_list[i * 2]) {
case GLX_PBUFFER_WIDTH:
width = attrib_list[i * 2 + 1];
break;
case GLX_PBUFFER_HEIGHT:
height = attrib_list[i * 2 + 1];
break;
}
}
 
return (GLXPbuffer) CreatePbuffer(dpy, (struct glx_config *) config,
width, height, attrib_list, GL_TRUE);
#endif
}
 
 
/**
* Destroy an existing pbuffer.
*/
_X_EXPORT void
glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf)
{
#ifdef GLX_USE_APPLEGL
if (apple_glx_pbuffer_destroy(dpy, pbuf)) {
__glXSendError(dpy, GLXBadPbuffer, pbuf, X_GLXDestroyPbuffer, false);
}
#else
DestroyPbuffer(dpy, pbuf);
#endif
}
 
 
/**
* Query an attribute of a drawable.
*/
_X_EXPORT void
glXQueryDrawable(Display * dpy, GLXDrawable drawable,
int attribute, unsigned int *value)
{
WARN_ONCE_GLX_1_3(dpy, __func__);
#ifdef GLX_USE_APPLEGL
Window root;
int x, y;
unsigned int width, height, bd, depth;
 
if (apple_glx_pixmap_query(drawable, attribute, value))
return; /*done */
 
if (apple_glx_pbuffer_query(drawable, attribute, value))
return; /*done */
 
/*
* The OpenGL spec states that we should report GLXBadDrawable if
* the drawable is invalid, however doing so would require that we
* use XSetErrorHandler(), which is known to not be thread safe.
* If we use a round-trip call to validate the drawable, there could
* be a race, so instead we just opt in favor of letting the
* XGetGeometry request fail with a GetGeometry request X error
* rather than GLXBadDrawable, in what is hoped to be a rare
* case of an invalid drawable. In practice most and possibly all
* X11 apps using GLX shouldn't notice a difference.
*/
if (XGetGeometry
(dpy, drawable, &root, &x, &y, &width, &height, &bd, &depth)) {
switch (attribute) {
case GLX_WIDTH:
*value = width;
break;
 
case GLX_HEIGHT:
*value = height;
break;
}
}
#else
GetDrawableAttribute(dpy, drawable, attribute, value);
#endif
}
 
 
#ifndef GLX_USE_APPLEGL
/**
* Query an attribute of a pbuffer.
*/
_X_EXPORT int
glXQueryGLXPbufferSGIX(Display * dpy, GLXPbufferSGIX drawable,
int attribute, unsigned int *value)
{
return GetDrawableAttribute(dpy, drawable, attribute, value);
}
#endif
 
/**
* Select the event mask for a drawable.
*/
_X_EXPORT void
glXSelectEvent(Display * dpy, GLXDrawable drawable, unsigned long mask)
{
#ifdef GLX_USE_APPLEGL
XWindowAttributes xwattr;
 
if (apple_glx_pbuffer_set_event_mask(drawable, mask))
return; /*done */
 
/*
* The spec allows a window, but currently there are no valid
* events for a window, so do nothing.
*/
if (XGetWindowAttributes(dpy, drawable, &xwattr))
return; /*done */
/* The drawable seems to be invalid. Report an error. */
 
__glXSendError(dpy, GLXBadDrawable, drawable,
X_GLXChangeDrawableAttributes, false);
#else
CARD32 attribs[2];
 
attribs[0] = (CARD32) GLX_EVENT_MASK;
attribs[1] = (CARD32) mask;
 
ChangeDrawableAttribute(dpy, drawable, attribs, 1);
#endif
}
 
 
/**
* Get the selected event mask for a drawable.
*/
_X_EXPORT void
glXGetSelectedEvent(Display * dpy, GLXDrawable drawable, unsigned long *mask)
{
#ifdef GLX_USE_APPLEGL
XWindowAttributes xwattr;
 
if (apple_glx_pbuffer_get_event_mask(drawable, mask))
return; /*done */
 
/*
* The spec allows a window, but currently there are no valid
* events for a window, so do nothing, but set the mask to 0.
*/
if (XGetWindowAttributes(dpy, drawable, &xwattr)) {
/* The window is valid, so set the mask to 0. */
*mask = 0;
return; /*done */
}
/* The drawable seems to be invalid. Report an error. */
 
__glXSendError(dpy, GLXBadDrawable, drawable, X_GLXGetDrawableAttributes,
true);
#else
unsigned int value;
 
 
/* The non-sense with value is required because on LP64 platforms
* sizeof(unsigned int) != sizeof(unsigned long). On little-endian
* we could just type-cast the pointer, but why?
*/
 
GetDrawableAttribute(dpy, drawable, GLX_EVENT_MASK_SGIX, &value);
*mask = value;
#endif
}
 
 
_X_EXPORT GLXPixmap
glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap,
const int *attrib_list)
{
WARN_ONCE_GLX_1_3(dpy, __func__);
 
#ifdef GLX_USE_APPLEGL
const struct glx_config *modes = (const struct glx_config *) config;
 
if (apple_glx_pixmap_create(dpy, modes->screen, pixmap, modes))
return None;
 
return pixmap;
#else
return CreateDrawable(dpy, (struct glx_config *) config,
(Drawable) pixmap, attrib_list, X_GLXCreatePixmap);
#endif
}
 
 
_X_EXPORT GLXWindow
glXCreateWindow(Display * dpy, GLXFBConfig config, Window win,
const int *attrib_list)
{
WARN_ONCE_GLX_1_3(dpy, __func__);
#ifdef GLX_USE_APPLEGL
XWindowAttributes xwattr;
XVisualInfo *visinfo;
 
(void) attrib_list; /*unused according to GLX 1.4 */
 
XGetWindowAttributes(dpy, win, &xwattr);
 
visinfo = glXGetVisualFromFBConfig(dpy, config);
 
if (NULL == visinfo) {
__glXSendError(dpy, GLXBadFBConfig, 0, X_GLXCreateWindow, false);
return None;
}
 
if (visinfo->visualid != XVisualIDFromVisual(xwattr.visual)) {
__glXSendError(dpy, BadMatch, 0, X_GLXCreateWindow, true);
return None;
}
 
free(visinfo);
 
return win;
#else
return CreateDrawable(dpy, (struct glx_config *) config,
(Drawable) win, attrib_list, X_GLXCreateWindow);
#endif
}
 
 
_X_EXPORT void
glXDestroyPixmap(Display * dpy, GLXPixmap pixmap)
{
WARN_ONCE_GLX_1_3(dpy, __func__);
#ifdef GLX_USE_APPLEGL
if (apple_glx_pixmap_destroy(dpy, pixmap))
__glXSendError(dpy, GLXBadPixmap, pixmap, X_GLXDestroyPixmap, false);
#else
DestroyDrawable(dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap);
#endif
}
 
 
_X_EXPORT void
glXDestroyWindow(Display * dpy, GLXWindow win)
{
WARN_ONCE_GLX_1_3(dpy, __func__);
#ifndef GLX_USE_APPLEGL
DestroyDrawable(dpy, (GLXDrawable) win, X_GLXDestroyWindow);
#endif
}
 
#ifndef GLX_USE_APPLEGL
_X_EXPORT
GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX,
(Display * dpy, GLXPbufferSGIX pbuf),
(dpy, pbuf), glXDestroyPbuffer)
 
_X_EXPORT
GLX_ALIAS_VOID(glXSelectEventSGIX,
(Display * dpy, GLXDrawable drawable,
unsigned long mask), (dpy, drawable, mask), glXSelectEvent)
 
_X_EXPORT
GLX_ALIAS_VOID(glXGetSelectedEventSGIX,
(Display * dpy, GLXDrawable drawable,
unsigned long *mask), (dpy, drawable, mask),
glXGetSelectedEvent)
#endif
/contrib/sdk/sources/Mesa/src/glx/glx_query.c
0,0 → 1,86
/*
* (C) Copyright IBM Corporation 2004
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* IBM AND/OR THEIR 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.
*/
 
/**
* \file glx_query.c
* Generic utility functions to query internal data from the server.
*
* \author Ian Romanick <idr@us.ibm.com>
*/
 
#include "glxclient.h"
 
# include <X11/Xlib-xcb.h>
# include <xcb/xcb.h>
# include <xcb/glx.h>
 
 
/**
* Exchange a protocol request for glXQueryServerString.
*/
char *
__glXQueryServerString(Display * dpy, int opcode, CARD32 screen, CARD32 name)
{
xcb_connection_t *c = XGetXCBConnection(dpy);
xcb_glx_query_server_string_reply_t *reply =
xcb_glx_query_server_string_reply(c,
xcb_glx_query_server_string(c,
screen,
name),
NULL);
 
/* The spec doesn't mention this, but the Xorg server replies with
* a string already terminated with '\0'. */
uint32_t len = xcb_glx_query_server_string_string_length(reply);
char *buf = malloc(len);
memcpy(buf, xcb_glx_query_server_string_string(reply), len);
free(reply);
 
return buf;
}
 
/**
* Exchange a protocol request for glGetString.
*/
char *
__glXGetString(Display * dpy, int opcode, CARD32 contextTag, CARD32 name)
{
xcb_connection_t *c = XGetXCBConnection(dpy);
xcb_glx_get_string_reply_t *reply = xcb_glx_get_string_reply(c,
xcb_glx_get_string
(c,
contextTag,
name),
NULL);
 
/* The spec doesn't mention this, but the Xorg server replies with
* a string already terminated with '\0'. */
uint32_t len = xcb_glx_get_string_string_length(reply);
char *buf = malloc(len);
memcpy(buf, xcb_glx_get_string_string(reply), len);
free(reply);
 
return buf;
}
 
/contrib/sdk/sources/Mesa/src/glx/glxclient.h
0,0 → 1,831
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
/**
* \file glxclient.h
* Direct rendering support added by Precision Insight, Inc.
*
* \author Kevin E. Martin <kevin@precisioninsight.com>
*/
 
#ifndef _GLX_client_h_
#define _GLX_client_h_
#include <X11/Xproto.h>
#include <X11/Xlibint.h>
#include <X11/Xfuncproto.h>
#include <X11/extensions/extutil.h>
#define GLX_GLXEXT_PROTOTYPES
#include <GL/glx.h>
#include <GL/glxext.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef _WIN32
#include <stdint.h>
#endif
#include "GL/glxproto.h"
#include "glxconfig.h"
#include "glxhash.h"
#if defined( HAVE_PTHREAD )
# include <pthread.h>
#endif
 
#include "glxextensions.h"
 
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
 
#define GLX_MAJOR_VERSION 1 /* current version numbers */
#define GLX_MINOR_VERSION 4
 
#define __GLX_MAX_TEXTURE_UNITS 32
 
struct glx_display;
struct glx_context;
 
/************************************************************************/
 
#ifdef GLX_DIRECT_RENDERING
 
extern void DRI_glXUseXFont(struct glx_context *ctx,
Font font, int first, int count, int listbase);
 
#endif
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
 
/**
* Display dependent methods. This structure is initialized during the
* \c driCreateDisplay call.
*/
typedef struct __GLXDRIdisplayRec __GLXDRIdisplay;
typedef struct __GLXDRIscreenRec __GLXDRIscreen;
typedef struct __GLXDRIdrawableRec __GLXDRIdrawable;
 
struct __GLXDRIdisplayRec
{
/**
* Method to destroy the private DRI display data.
*/
void (*destroyDisplay) (__GLXDRIdisplay * display);
 
struct glx_screen *(*createScreen)(int screen, struct glx_display * priv);
};
 
struct __GLXDRIscreenRec {
 
void (*destroyScreen)(struct glx_screen *psc);
 
struct glx_context *(*createContext)(struct glx_screen *psc,
struct glx_config *config,
struct glx_context *shareList,
int renderType);
 
__GLXDRIdrawable *(*createDrawable)(struct glx_screen *psc,
XID drawable,
GLXDrawable glxDrawable,
struct glx_config *config);
 
int64_t (*swapBuffers)(__GLXDRIdrawable *pdraw, int64_t target_msc,
int64_t divisor, int64_t remainder, Bool flush);
void (*copySubBuffer)(__GLXDRIdrawable *pdraw,
int x, int y, int width, int height, Bool flush);
int (*getDrawableMSC)(struct glx_screen *psc, __GLXDRIdrawable *pdraw,
int64_t *ust, int64_t *msc, int64_t *sbc);
int (*waitForMSC)(__GLXDRIdrawable *pdraw, int64_t target_msc,
int64_t divisor, int64_t remainder, int64_t *ust,
int64_t *msc, int64_t *sbc);
int (*waitForSBC)(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
int64_t *msc, int64_t *sbc);
int (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval);
int (*getSwapInterval)(__GLXDRIdrawable *pdraw);
};
 
struct __GLXDRIdrawableRec
{
void (*destroyDrawable) (__GLXDRIdrawable * drawable);
 
XID xDrawable;
XID drawable;
struct glx_screen *psc;
GLenum textureTarget;
GLenum textureFormat; /* EXT_texture_from_pixmap support */
unsigned long eventMask;
int refcount;
};
 
/*
** Function to create and DRI display data and initialize the display
** dependent methods.
*/
extern __GLXDRIdisplay *driswCreateDisplay(Display * dpy);
extern __GLXDRIdisplay *driCreateDisplay(Display * dpy);
extern __GLXDRIdisplay *dri2CreateDisplay(Display * dpy);
extern void dri2InvalidateBuffers(Display *dpy, XID drawable);
extern unsigned dri2GetSwapEventType(Display *dpy, XID drawable);
 
 
/*
** Functions to obtain driver configuration information from a direct
** rendering client application
*/
extern const char *glXGetScreenDriver(Display * dpy, int scrNum);
 
extern const char *glXGetDriverConfig(const char *driverName);
 
#endif
 
/************************************************************************/
 
#define __GL_CLIENT_ATTRIB_STACK_DEPTH 16
 
typedef struct __GLXpixelStoreModeRec
{
GLboolean swapEndian;
GLboolean lsbFirst;
GLuint rowLength;
GLuint imageHeight;
GLuint imageDepth;
GLuint skipRows;
GLuint skipPixels;
GLuint skipImages;
GLuint alignment;
} __GLXpixelStoreMode;
 
 
typedef struct __GLXattributeRec
{
GLuint mask;
 
/**
* Pixel storage state. Most of the pixel store mode state is kept
* here and used by the client code to manage the packing and
* unpacking of data sent to/received from the server.
*/
__GLXpixelStoreMode storePack, storeUnpack;
 
/**
* Is EXT_vertex_array / GL 1.1 DrawArrays protocol specifically
* disabled?
*/
GLboolean NoDrawArraysProtocol;
 
/**
* Vertex Array storage state. The vertex array component
* state is stored here and is used to manage the packing of
* DrawArrays data sent to the server.
*/
struct array_state_vector *array_state;
} __GLXattribute;
 
typedef struct __GLXattributeMachineRec
{
__GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
__GLXattribute **stackPointer;
} __GLXattributeMachine;
 
struct glx_context_vtable {
void (*destroy)(struct glx_context *ctx);
int (*bind)(struct glx_context *context, struct glx_context *old,
GLXDrawable draw, GLXDrawable read);
void (*unbind)(struct glx_context *context, struct glx_context *new_ctx);
void (*wait_gl)(struct glx_context *ctx);
void (*wait_x)(struct glx_context *ctx);
void (*use_x_font)(struct glx_context *ctx,
Font font, int first, int count, int listBase);
void (*bind_tex_image)(Display * dpy,
GLXDrawable drawable,
int buffer, const int *attrib_list);
void (*release_tex_image)(Display * dpy, GLXDrawable drawable, int buffer);
void * (*get_proc_address)(const char *symbol);
};
 
/**
* GLX state that needs to be kept on the client. One of these records
* exist for each context that has been made current by this client.
*/
struct glx_context
{
/**
* \name Drawing command buffer.
*
* Drawing commands are packed into this buffer before being sent as a
* single GLX protocol request. The buffer is sent when it overflows or
* is flushed by \c __glXFlushRenderBuffer. \c pc is the next location
* in the buffer to be filled. \c limit is described above in the buffer
* slop discussion.
*
* Commands that require large amounts of data to be transfered will
* also use this buffer to hold a header that describes the large
* command.
*
* These must be the first 6 fields since they are static initialized
* in the dummy context in glxext.c
*/
/*@{ */
GLubyte *buf;
GLubyte *pc;
GLubyte *limit;
GLubyte *bufEnd;
GLint bufSize;
/*@} */
 
const struct glx_context_vtable *vtable;
 
/**
* The XID of this rendering context. When the context is created a
* new XID is allocated. This is set to None when the context is
* destroyed but is still current to some thread. In this case the
* context will be freed on next MakeCurrent.
*/
XID xid;
 
/**
* The XID of the \c shareList context.
*/
XID share_xid;
 
/**
* Screen number.
*/
GLint screen;
struct glx_screen *psc;
 
/**
* \c GL_TRUE if the context was created with ImportContext, which
* means the server-side context was created by another X client.
*/
GLboolean imported;
 
/**
* The context tag returned by MakeCurrent when this context is made
* current. This tag is used to identify the context that a thread has
* current so that proper server context management can be done. It is
* used for all context specific commands (i.e., \c Render, \c RenderLarge,
* \c WaitX, \c WaitGL, \c UseXFont, and \c MakeCurrent (for the old
* context)).
*/
GLXContextTag currentContextTag;
 
/**
* \name Rendering mode
*
* The rendering mode is kept on the client as well as the server.
* When \c glRenderMode is called, the buffer associated with the
* previous rendering mode (feedback or select) is filled.
*/
/*@{ */
GLenum renderMode;
GLfloat *feedbackBuf;
GLuint *selectBuf;
/*@} */
 
/**
* Fill newImage with the unpacked form of \c oldImage getting it
* ready for transport to the server.
*/
void (*fillImage) (struct glx_context *, GLint, GLint, GLint, GLint, GLenum,
GLenum, const GLvoid *, GLubyte *, GLubyte *);
 
/**
* Client side attribs.
*/
__GLXattributeMachine attributes;
 
/**
* Client side error code. This is set when client side gl API
* routines need to set an error because of a bad enumerant or
* running out of memory, etc.
*/
GLenum error;
 
/**
* Whether this context does direct rendering.
*/
Bool isDirect;
 
#if defined(GLX_DIRECT_RENDERING) && defined(GLX_USE_APPLEGL)
void *driContext;
#endif
 
/**
* \c dpy of current display for this context. Will be \c NULL if not
* current to any display, or if this is the "dummy context".
*/
Display *currentDpy;
 
/**
* The current drawable for this context. Will be None if this
* context is not current to any drawable. currentReadable is below.
*/
GLXDrawable currentDrawable;
 
/**
* \name GL Constant Strings
*
* Constant strings that describe the server implementation
* These pertain to GL attributes, not to be confused with
* GLX versioning attributes.
*/
/*@{ */
GLubyte *vendor;
GLubyte *renderer;
GLubyte *version;
GLubyte *extensions;
/*@} */
 
/**
* Maximum small render command size. This is the smaller of 64k and
* the size of the above buffer.
*/
GLint maxSmallRenderCommandSize;
 
/**
* Major opcode for the extension. Copied here so a lookup isn't
* needed.
*/
GLint majorOpcode;
 
/**
* Pointer to the config used to create this context.
*/
struct glx_config *config;
 
/**
* The current read-drawable for this context. Will be None if this
* context is not current to any drawable.
*
* \since Internal API version 20030606.
*/
GLXDrawable currentReadable;
 
/**
* Pointer to client-state data that is private to libGL. This is only
* used for indirect rendering contexts.
*
* No internal API version change was made for this change. Client-side
* drivers should NEVER use this data or even care that it exists.
*/
void *client_state_private;
 
/**
* Stored value for \c glXQueryContext attribute \c GLX_RENDER_TYPE.
*/
int renderType;
 
/**
* \name Raw server GL version
*
* True core GL version supported by the server. This is the raw value
* returned by the server, and it may not reflect what is actually
* supported (or reported) by the client-side library.
*/
/*@{ */
int server_major; /**< Major version number. */
int server_minor; /**< Minor version number. */
/*@} */
 
/**
* Number of threads we're currently current in.
*/
unsigned long thread_refcount;
 
char gl_extension_bits[__GL_EXT_BYTES];
};
 
extern Bool
glx_context_init(struct glx_context *gc,
struct glx_screen *psc, struct glx_config *fbconfig);
 
#define __glXSetError(gc,code) \
if (!(gc)->error) { \
(gc)->error = code; \
}
 
extern void __glFreeAttributeState(struct glx_context *);
 
/************************************************************************/
 
/**
* The size of the largest drawing command known to the implementation
* that will use the GLXRender GLX command. In this case it is
* \c glPolygonStipple.
*/
#define __GLX_MAX_SMALL_RENDER_CMD_SIZE 156
 
/**
* To keep the implementation fast, the code uses a "limit" pointer
* to determine when the drawing command buffer is too full to hold
* another fixed size command. This constant defines the amount of
* space that must always be available in the drawing command buffer
* at all times for the implementation to work. It is important that
* the number be just large enough, but not so large as to reduce the
* efficacy of the buffer. The "+32" is just to keep the code working
* in case somebody counts wrong.
*/
#define __GLX_BUFFER_LIMIT_SIZE (__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32)
 
/**
* This implementation uses a smaller threshold for switching
* to the RenderLarge protocol than the protcol requires so that
* large copies don't occur.
*/
#define __GLX_RENDER_CMD_SIZE_LIMIT 4096
 
/**
* One of these records exists per screen of the display. It contains
* a pointer to the config data for that screen (if the screen supports GL).
*/
struct glx_screen_vtable {
struct glx_context *(*create_context)(struct glx_screen *psc,
struct glx_config *config,
struct glx_context *shareList,
int renderType);
 
struct glx_context *(*create_context_attribs)(struct glx_screen *psc,
struct glx_config *config,
struct glx_context *shareList,
unsigned num_attrib,
const uint32_t *attribs,
unsigned *error);
 
};
 
struct glx_screen
{
const struct glx_screen_vtable *vtable;
 
/**
* GLX extension string reported by the X-server.
*/
const char *serverGLXexts;
 
/**
* GLX extension string to be reported to applications. This is the
* set of extensions that the application can actually use.
*/
char *effectiveGLXexts;
 
struct glx_display *display;
 
Display *dpy;
int scr;
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
/**
* Per screen direct rendering interface functions and data.
*/
__GLXDRIscreen *driScreen;
#endif
 
/**
* Linked list of glx visuals and fbconfigs for this screen.
*/
struct glx_config *visuals, *configs;
 
/**
* Per-screen dynamic GLX extension tracking. The \c direct_support
* field only contains enough bits for 64 extensions. Should libGL
* ever need to track more than 64 GLX extensions, we can safely grow
* this field. The \c struct glx_screen structure is not used outside
* libGL.
*/
/*@{ */
unsigned char direct_support[8];
GLboolean ext_list_first_time;
/*@} */
 
};
 
/**
* Per display private data. One of these records exists for each display
* that is using the OpenGL (GLX) extension.
*/
struct glx_display
{
/* The extension protocol codes */
XExtCodes *codes;
struct glx_display *next;
 
/**
* Back pointer to the display
*/
Display *dpy;
 
/**
* The \c majorOpcode is common to all connections to the same server.
* It is also copied into the context structure.
*/
int majorOpcode;
 
/**
* \name Server Version
*
* Major and minor version returned by the server during initialization.
*/
/*@{ */
int majorVersion, minorVersion;
/*@} */
 
/**
* \name Storage for the servers GLX vendor and versions strings.
*
* These are the same for all screens on this display. These fields will
* be filled in on demand.
*/
/*@{ */
const char *serverGLXvendor;
const char *serverGLXversion;
/*@} */
 
/**
* Configurations of visuals for all screens on this display.
* Also, per screen data which now includes the server \c GLX_EXTENSION
* string.
*/
struct glx_screen **screens;
 
__glxHashTable *glXDrawHash;
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
__glxHashTable *drawHash;
 
/**
* Per display direct rendering interface functions and data.
*/
__GLXDRIdisplay *driswDisplay;
__GLXDRIdisplay *driDisplay;
__GLXDRIdisplay *dri2Display;
#endif
};
 
struct glx_drawable {
XID xDrawable;
XID drawable;
 
uint32_t lastEventSbc;
int64_t eventSbcWrap;
};
 
extern int
glx_screen_init(struct glx_screen *psc,
int screen, struct glx_display * priv);
extern void
glx_screen_cleanup(struct glx_screen *psc);
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
extern __GLXDRIdrawable *
dri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id);
#endif
 
extern GLubyte *__glXFlushRenderBuffer(struct glx_context *, GLubyte *);
 
extern void __glXSendLargeChunk(struct glx_context * gc, GLint requestNumber,
GLint totalRequests,
const GLvoid * data, GLint dataLen);
 
extern void __glXSendLargeCommand(struct glx_context *, const GLvoid *, GLint,
const GLvoid *, GLint);
 
/* Initialize the GLX extension for dpy */
extern struct glx_display *__glXInitialize(Display *);
 
extern void __glXPreferEGL(int state);
 
/************************************************************************/
 
extern int __glXDebug;
 
/* This is per-thread storage in an MT environment */
#if defined( HAVE_PTHREAD )
 
extern void __glXSetCurrentContext(struct glx_context * c);
 
# if defined( GLX_USE_TLS )
 
extern __thread void *__glX_tls_Context
__attribute__ ((tls_model("initial-exec")));
 
# define __glXGetCurrentContext() __glX_tls_Context
 
# else
 
extern struct glx_context *__glXGetCurrentContext(void);
 
# endif /* defined( GLX_USE_TLS ) */
 
#else
 
extern struct glx_context *__glXcurrentContext;
#define __glXGetCurrentContext() __glXcurrentContext
#define __glXSetCurrentContext(gc) __glXcurrentContext = gc
 
#endif /* defined( HAVE_PTHREAD ) */
 
extern void __glXSetCurrentContextNull(void);
 
 
/*
** Global lock for all threads in this address space using the GLX
** extension
*/
#if defined( HAVE_PTHREAD )
extern pthread_mutex_t __glXmutex;
#define __glXLock() pthread_mutex_lock(&__glXmutex)
#define __glXUnlock() pthread_mutex_unlock(&__glXmutex)
#else
#define __glXLock()
#define __glXUnlock()
#endif
 
/*
** Setup for a command. Initialize the extension for dpy if necessary.
*/
extern CARD8 __glXSetupForCommand(Display * dpy);
 
/************************************************************************/
 
/*
** Data conversion and packing support.
*/
 
extern const GLuint __glXDefaultPixelStore[9];
 
/* Send an image to the server using RenderLarge. */
extern void __glXSendLargeImage(struct glx_context * gc, GLint compsize, GLint dim,
GLint width, GLint height, GLint depth,
GLenum format, GLenum type,
const GLvoid * src, GLubyte * pc,
GLubyte * modes);
 
/* Return the size, in bytes, of some pixel data */
extern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum, GLenum);
 
/* Return the number of elements per group of a specified format*/
extern GLint __glElementsPerGroup(GLenum format, GLenum type);
 
/* Return the number of bytes per element, based on the element type (other
** than GL_BITMAP).
*/
extern GLint __glBytesPerElement(GLenum type);
 
/*
** Fill the transport buffer with the data from the users buffer,
** applying some of the pixel store modes (unpack modes) to the data
** first. As a side effect of this call, the "modes" field is
** updated to contain the modes needed by the server to decode the
** sent data.
*/
extern void __glFillImage(struct glx_context *, GLint, GLint, GLint, GLint, GLenum,
GLenum, const GLvoid *, GLubyte *, GLubyte *);
 
/* Copy map data with a stride into a packed buffer */
extern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *);
extern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *);
extern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint,
const GLfloat *, GLfloat *);
extern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint,
const GLdouble *, GLdouble *);
 
/*
** Empty an image out of the reply buffer into the clients memory applying
** the pack modes to pack back into the clients requested format.
*/
extern void __glEmptyImage(struct glx_context *, GLint, GLint, GLint, GLint, GLenum,
GLenum, const GLubyte *, GLvoid *);
 
 
/*
** Allocate and Initialize Vertex Array client state, and free.
*/
extern void __glXInitVertexArrayState(struct glx_context *);
extern void __glXFreeVertexArrayState(struct glx_context *);
 
/*
** Inform the Server of the major and minor numbers and of the client
** libraries extension string.
*/
extern void __glXClientInfo(Display * dpy, int opcode);
 
_X_HIDDEN void
__glX_send_client_info(struct glx_display *glx_dpy);
 
/************************************************************************/
 
/*
** Declarations that should be in Xlib
*/
#ifdef __GL_USE_OUR_PROTOTYPES
extern void _XFlush(Display *);
extern Status _XReply(Display *, xReply *, int, Bool);
extern void _XRead(Display *, void *, long);
extern void _XSend(Display *, const void *, long);
#endif
 
 
extern void __glXInitializeVisualConfigFromTags(struct glx_config * config,
int count, const INT32 * bp,
Bool tagged_only,
Bool fbconfig_style_tags);
 
extern char *__glXQueryServerString(Display * dpy, int opcode,
CARD32 screen, CARD32 name);
extern char *__glXGetString(Display * dpy, int opcode,
CARD32 screen, CARD32 name);
 
extern char *__glXstrdup(const char *str);
 
 
extern const char __glXGLClientVersion[];
extern const char __glXGLClientExtensions[];
 
/* Get the unadjusted system time */
extern int __glXGetUST(int64_t * ust);
 
extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
int32_t * numerator,
int32_t * denominator);
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
extern GLboolean
__glxGetMscRate(__GLXDRIdrawable *glxDraw,
int32_t * numerator, int32_t * denominator);
 
/* So that dri2.c:DRI2WireToEvent() can access
* glx_info->codes->first_event */
XExtDisplayInfo *__glXFindDisplay (Display *dpy);
 
extern void
GarbageCollectDRIDrawables(struct glx_screen *psc);
 
extern __GLXDRIdrawable *
GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable);
#endif
 
extern struct glx_screen *GetGLXScreenConfigs(Display * dpy, int scrn);
 
#ifdef GLX_USE_APPLEGL
extern struct glx_screen *
applegl_create_screen(int screen, struct glx_display * priv);
 
extern struct glx_context *
applegl_create_context(struct glx_screen *psc,
struct glx_config *mode,
struct glx_context *shareList, int renderType);
 
extern int
applegl_create_display(struct glx_display *display);
#endif
 
extern Bool validate_renderType_against_config(const struct glx_config *config,
int renderType);
 
 
extern struct glx_drawable *GetGLXDrawable(Display *dpy, GLXDrawable drawable);
extern int InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw,
XID xDrawable, GLXDrawable drawable);
extern void DestroyGLXDrawable(Display *dpy, GLXDrawable drawable);
 
extern struct glx_context dummyContext;
 
extern struct glx_screen *
indirect_create_screen(int screen, struct glx_display * priv);
extern struct glx_context *
indirect_create_context(struct glx_screen *psc,
struct glx_config *mode,
struct glx_context *shareList, int renderType);
extern struct glx_context *
indirect_create_context_attribs(struct glx_screen *base,
struct glx_config *config_base,
struct glx_context *shareList,
unsigned num_attribs,
const uint32_t *attribs,
unsigned *error);
 
#endif /* !__GLX_client_h__ */
/contrib/sdk/sources/Mesa/src/glx/glxcmds.c
0,0 → 1,2713
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
/**
* \file glxcmds.c
* Client-side GLX interface.
*/
 
#include "glxclient.h"
#include "glapi.h"
#include "glxextensions.h"
#include "indirect.h"
#include "glx_error.h"
 
#ifdef GLX_DIRECT_RENDERING
#ifdef GLX_USE_APPLEGL
#include "apple_glx_context.h"
#include "apple_glx.h"
#else
#include <sys/time.h>
#ifdef XF86VIDMODE
#include <X11/extensions/xf86vmode.h>
#endif
#include "xf86dri.h"
#endif
#else
#endif
 
#include <X11/Xlib-xcb.h>
#include <xcb/xcb.h>
#include <xcb/glx.h>
 
static const char __glXGLXClientVendorName[] = "Mesa Project and SGI";
static const char __glXGLXClientVersion[] = "1.4";
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
 
/**
* Get the __DRIdrawable for the drawable associated with a GLXContext
*
* \param dpy The display associated with \c drawable.
* \param drawable GLXDrawable whose __DRIdrawable part is to be retrieved.
* \param scrn_num If non-NULL, the drawables screen is stored there
* \returns A pointer to the context's __DRIdrawable on success, or NULL if
* the drawable is not associated with a direct-rendering context.
*/
_X_HIDDEN __GLXDRIdrawable *
GetGLXDRIDrawable(Display * dpy, GLXDrawable drawable)
{
struct glx_display *priv = __glXInitialize(dpy);
__GLXDRIdrawable *pdraw;
 
if (priv == NULL)
return NULL;
 
if (__glxHashLookup(priv->drawHash, drawable, (void *) &pdraw) == 0)
return pdraw;
 
return NULL;
}
 
#endif
 
_X_HIDDEN struct glx_drawable *
GetGLXDrawable(Display *dpy, GLXDrawable drawable)
{
struct glx_display *priv = __glXInitialize(dpy);
struct glx_drawable *glxDraw;
 
if (priv == NULL)
return NULL;
 
if (__glxHashLookup(priv->glXDrawHash, drawable, (void *) &glxDraw) == 0)
return glxDraw;
 
return NULL;
}
 
_X_HIDDEN int
InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw, XID xDrawable,
GLXDrawable drawable)
{
struct glx_display *priv = __glXInitialize(dpy);
 
if (!priv)
return -1;
 
glxDraw->xDrawable = xDrawable;
glxDraw->drawable = drawable;
glxDraw->lastEventSbc = 0;
glxDraw->eventSbcWrap = 0;
 
return __glxHashInsert(priv->glXDrawHash, drawable, glxDraw);
}
 
_X_HIDDEN void
DestroyGLXDrawable(Display *dpy, GLXDrawable drawable)
{
struct glx_display *priv = __glXInitialize(dpy);
struct glx_drawable *glxDraw;
 
if (!priv)
return;
 
glxDraw = GetGLXDrawable(dpy, drawable);
__glxHashDelete(priv->glXDrawHash, drawable);
free(glxDraw);
}
 
/**
* Get the GLX per-screen data structure associated with a GLX context.
*
* \param dpy Display for which the GLX per-screen information is to be
* retrieved.
* \param scrn Screen on \c dpy for which the GLX per-screen information is
* to be retrieved.
* \returns A pointer to the GLX per-screen data if \c dpy and \c scrn
* specify a valid GLX screen, or NULL otherwise.
*
* \todo Should this function validate that \c scrn is within the screen
* number range for \c dpy?
*/
 
_X_HIDDEN struct glx_screen *
GetGLXScreenConfigs(Display * dpy, int scrn)
{
struct glx_display *const priv = __glXInitialize(dpy);
 
return (priv
&& priv->screens !=
NULL) ? priv->screens[scrn] : NULL;
}
 
 
static int
GetGLXPrivScreenConfig(Display * dpy, int scrn, struct glx_display ** ppriv,
struct glx_screen ** ppsc)
{
/* Initialize the extension, if needed . This has the added value
* of initializing/allocating the display private
*/
 
if (dpy == NULL) {
return GLX_NO_EXTENSION;
}
 
*ppriv = __glXInitialize(dpy);
if (*ppriv == NULL) {
return GLX_NO_EXTENSION;
}
 
/* Check screen number to see if its valid */
if ((scrn < 0) || (scrn >= ScreenCount(dpy))) {
return GLX_BAD_SCREEN;
}
 
/* Check to see if the GL is supported on this screen */
*ppsc = (*ppriv)->screens[scrn];
if ((*ppsc)->configs == NULL) {
/* No support for GL on this screen regardless of visual */
return GLX_BAD_VISUAL;
}
 
return Success;
}
 
 
/**
* Determine if a \c GLXFBConfig supplied by the application is valid.
*
* \param dpy Application supplied \c Display pointer.
* \param config Application supplied \c GLXFBConfig.
*
* \returns If the \c GLXFBConfig is valid, the a pointer to the matching
* \c struct glx_config structure is returned. Otherwise, \c NULL
* is returned.
*/
static struct glx_config *
ValidateGLXFBConfig(Display * dpy, GLXFBConfig fbconfig)
{
struct glx_display *const priv = __glXInitialize(dpy);
int num_screens = ScreenCount(dpy);
unsigned i;
struct glx_config *config;
 
if (priv != NULL) {
for (i = 0; i < num_screens; i++) {
for (config = priv->screens[i]->configs; config != NULL;
config = config->next) {
if (config == (struct glx_config *) fbconfig) {
return config;
}
}
}
}
 
return NULL;
}
 
/**
* Verifies context's GLX_RENDER_TYPE value with config.
*
* \param config GLX FBConfig which will support the returned renderType.
* \param renderType The context render type to be verified.
* \return True if the value of context renderType was approved, or 0 if no
* valid value was found.
*/
Bool
validate_renderType_against_config(const struct glx_config *config,
int renderType)
{
switch (renderType) {
case GLX_RGBA_TYPE:
return (config->renderType & GLX_RGBA_BIT) != 0;
case GLX_COLOR_INDEX_TYPE:
return (config->renderType & GLX_COLOR_INDEX_BIT) != 0;
case GLX_RGBA_FLOAT_TYPE_ARB:
return (config->renderType & GLX_RGBA_FLOAT_BIT_ARB) != 0;
case GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT:
return (config->renderType & GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT) != 0;
default:
break;
}
return 0;
}
 
_X_HIDDEN Bool
glx_context_init(struct glx_context *gc,
struct glx_screen *psc, struct glx_config *config)
{
gc->majorOpcode = __glXSetupForCommand(psc->display->dpy);
if (!gc->majorOpcode)
return False;
 
gc->screen = psc->scr;
gc->psc = psc;
gc->config = config;
gc->isDirect = GL_TRUE;
gc->currentContextTag = -1;
 
return True;
}
 
 
/**
* Create a new context.
*
* \param renderType For FBConfigs, what is the rendering type?
*/
 
static GLXContext
CreateContext(Display *dpy, int generic_id, struct glx_config *config,
GLXContext shareList_user, Bool allowDirect,
unsigned code, int renderType, int screen)
{
struct glx_context *gc;
struct glx_screen *psc;
struct glx_context *shareList = (struct glx_context *) shareList_user;
if (dpy == NULL)
return NULL;
 
psc = GetGLXScreenConfigs(dpy, screen);
if (psc == NULL)
return NULL;
 
if (generic_id == None)
return NULL;
 
gc = NULL;
#ifdef GLX_USE_APPLEGL
gc = applegl_create_context(psc, config, shareList, renderType);
#else
if (allowDirect && psc->vtable->create_context)
gc = psc->vtable->create_context(psc, config, shareList, renderType);
if (!gc)
gc = indirect_create_context(psc, config, shareList, renderType);
#endif
if (!gc)
return NULL;
 
LockDisplay(dpy);
switch (code) {
case X_GLXCreateContext: {
xGLXCreateContextReq *req;
 
/* Send the glXCreateContext request */
GetReq(GLXCreateContext, req);
req->reqType = gc->majorOpcode;
req->glxCode = X_GLXCreateContext;
req->context = gc->xid = XAllocID(dpy);
req->visual = generic_id;
req->screen = screen;
req->shareList = shareList ? shareList->xid : None;
req->isDirect = gc->isDirect;
break;
}
 
case X_GLXCreateNewContext: {
xGLXCreateNewContextReq *req;
 
/* Send the glXCreateNewContext request */
GetReq(GLXCreateNewContext, req);
req->reqType = gc->majorOpcode;
req->glxCode = X_GLXCreateNewContext;
req->context = gc->xid = XAllocID(dpy);
req->fbconfig = generic_id;
req->screen = screen;
req->renderType = renderType;
req->shareList = shareList ? shareList->xid : None;
req->isDirect = gc->isDirect;
break;
}
 
case X_GLXvop_CreateContextWithConfigSGIX: {
xGLXVendorPrivateWithReplyReq *vpreq;
xGLXCreateContextWithConfigSGIXReq *req;
 
/* Send the glXCreateNewContext request */
GetReqExtra(GLXVendorPrivateWithReply,
sz_xGLXCreateContextWithConfigSGIXReq -
sz_xGLXVendorPrivateWithReplyReq, vpreq);
req = (xGLXCreateContextWithConfigSGIXReq *) vpreq;
req->reqType = gc->majorOpcode;
req->glxCode = X_GLXVendorPrivateWithReply;
req->vendorCode = X_GLXvop_CreateContextWithConfigSGIX;
req->context = gc->xid = XAllocID(dpy);
req->fbconfig = generic_id;
req->screen = screen;
req->renderType = renderType;
req->shareList = shareList ? shareList->xid : None;
req->isDirect = gc->isDirect;
break;
}
 
default:
/* What to do here? This case is the sign of an internal error. It
* should never be reachable.
*/
break;
}
 
UnlockDisplay(dpy);
SyncHandle();
 
gc->share_xid = shareList ? shareList->xid : None;
gc->imported = GL_FALSE;
 
return (GLXContext) gc;
}
 
_X_EXPORT GLXContext
glXCreateContext(Display * dpy, XVisualInfo * vis,
GLXContext shareList, Bool allowDirect)
{
struct glx_config *config = NULL;
int renderType = GLX_RGBA_TYPE;
 
#if defined(GLX_DIRECT_RENDERING) || defined(GLX_USE_APPLEGL)
struct glx_screen *const psc = GetGLXScreenConfigs(dpy, vis->screen);
 
config = glx_config_find_visual(psc->visuals, vis->visualid);
if (config == NULL) {
xError error;
 
error.errorCode = BadValue;
error.resourceID = vis->visualid;
error.sequenceNumber = dpy->request;
error.type = X_Error;
error.majorCode = __glXSetupForCommand(dpy);
error.minorCode = X_GLXCreateContext;
_XError(dpy, &error);
return None;
}
 
/* Choose the context render type based on DRI config values. It is
* unusual to set this type from config, but we have no other choice, as
* this old API does not provide renderType parameter.
*/
if (config->renderType & GLX_RGBA_FLOAT_BIT_ARB) {
renderType = GLX_RGBA_FLOAT_TYPE_ARB;
} else if (config->renderType & GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT) {
renderType = GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT;
} else if (config->renderType & GLX_RGBA_BIT) {
renderType = GLX_RGBA_TYPE;
} else if (config->renderType & GLX_COLOR_INDEX_BIT) {
renderType = GLX_COLOR_INDEX_TYPE;
} else if (config->rgbMode) {
/* If we're here, then renderType is not set correctly. Let's use a
* safeguard - any TrueColor or DirectColor mode is RGB mode. Such
* default value is needed by old DRI drivers, which didn't set
* renderType correctly as the value was just ignored.
*/
renderType = GLX_RGBA_TYPE;
} else {
/* Safeguard - only one option left, all non-RGB modes are indexed
* modes. Again, this allows drivers with invalid renderType to work
* properly.
*/
renderType = GLX_COLOR_INDEX_TYPE;
}
#endif
 
return CreateContext(dpy, vis->visualid, config, shareList, allowDirect,
X_GLXCreateContext, renderType, vis->screen);
}
 
static void
glx_send_destroy_context(Display *dpy, XID xid)
{
CARD8 opcode = __glXSetupForCommand(dpy);
xGLXDestroyContextReq *req;
 
LockDisplay(dpy);
GetReq(GLXDestroyContext, req);
req->reqType = opcode;
req->glxCode = X_GLXDestroyContext;
req->context = xid;
UnlockDisplay(dpy);
SyncHandle();
}
 
/*
** Destroy the named context
*/
 
_X_EXPORT void
glXDestroyContext(Display * dpy, GLXContext ctx)
{
struct glx_context *gc = (struct glx_context *) ctx;
 
if (gc == NULL || gc->xid == None)
return;
 
__glXLock();
if (!gc->imported)
glx_send_destroy_context(dpy, gc->xid);
 
if (gc->currentDpy) {
/* This context is bound to some thread. According to the man page,
* we should not actually delete the context until it's unbound.
* Note that we set gc->xid = None above. In MakeContextCurrent()
* we check for that and delete the context there.
*/
gc->xid = None;
} else {
gc->vtable->destroy(gc);
}
__glXUnlock();
}
 
/*
** Return the major and minor version #s for the GLX extension
*/
_X_EXPORT Bool
glXQueryVersion(Display * dpy, int *major, int *minor)
{
struct glx_display *priv;
 
/* Init the extension. This fetches the major and minor version. */
priv = __glXInitialize(dpy);
if (!priv)
return False;
 
if (major)
*major = priv->majorVersion;
if (minor)
*minor = priv->minorVersion;
return True;
}
 
/*
** Query the existance of the GLX extension
*/
_X_EXPORT Bool
glXQueryExtension(Display * dpy, int *errorBase, int *eventBase)
{
int major_op, erb, evb;
Bool rv;
 
rv = XQueryExtension(dpy, GLX_EXTENSION_NAME, &major_op, &evb, &erb);
if (rv) {
if (errorBase)
*errorBase = erb;
if (eventBase)
*eventBase = evb;
}
return rv;
}
 
/*
** Put a barrier in the token stream that forces the GL to finish its
** work before X can proceed.
*/
_X_EXPORT void
glXWaitGL(void)
{
struct glx_context *gc = __glXGetCurrentContext();
 
if (gc && gc->vtable->wait_gl)
gc->vtable->wait_gl(gc);
}
 
/*
** Put a barrier in the token stream that forces X to finish its
** work before GL can proceed.
*/
_X_EXPORT void
glXWaitX(void)
{
struct glx_context *gc = __glXGetCurrentContext();
 
if (gc && gc->vtable->wait_x)
gc->vtable->wait_x(gc);
}
 
_X_EXPORT void
glXUseXFont(Font font, int first, int count, int listBase)
{
struct glx_context *gc = __glXGetCurrentContext();
 
if (gc && gc->vtable->use_x_font)
gc->vtable->use_x_font(gc, font, first, count, listBase);
}
 
/************************************************************************/
 
/*
** Copy the source context to the destination context using the
** attribute "mask".
*/
_X_EXPORT void
glXCopyContext(Display * dpy, GLXContext source_user,
GLXContext dest_user, unsigned long mask)
{
struct glx_context *source = (struct glx_context *) source_user;
struct glx_context *dest = (struct glx_context *) dest_user;
#ifdef GLX_USE_APPLEGL
struct glx_context *gc = __glXGetCurrentContext();
int errorcode;
bool x11error;
 
if(apple_glx_copy_context(gc->driContext, source->driContext, dest->driContext,
mask, &errorcode, &x11error)) {
__glXSendError(dpy, errorcode, 0, X_GLXCopyContext, x11error);
}
#else
xGLXCopyContextReq *req;
struct glx_context *gc = __glXGetCurrentContext();
GLXContextTag tag;
CARD8 opcode;
 
opcode = __glXSetupForCommand(dpy);
if (!opcode) {
return;
}
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->isDirect) {
/* NOT_DONE: This does not work yet */
}
#endif
 
/*
** If the source is the current context, send its tag so that the context
** can be flushed before the copy.
*/
if (source == gc && dpy == gc->currentDpy) {
tag = gc->currentContextTag;
}
else {
tag = 0;
}
 
/* Send the glXCopyContext request */
LockDisplay(dpy);
GetReq(GLXCopyContext, req);
req->reqType = opcode;
req->glxCode = X_GLXCopyContext;
req->source = source ? source->xid : None;
req->dest = dest ? dest->xid : None;
req->mask = mask;
req->contextTag = tag;
UnlockDisplay(dpy);
SyncHandle();
#endif /* GLX_USE_APPLEGL */
}
 
 
/**
* Determine if a context uses direct rendering.
*
* \param dpy Display where the context was created.
* \param contextID ID of the context to be tested.
*
* \returns \c True if the context is direct rendering or not.
*/
static Bool
__glXIsDirect(Display * dpy, GLXContextID contextID)
{
CARD8 opcode;
xcb_connection_t *c;
xcb_generic_error_t *err;
xcb_glx_is_direct_reply_t *reply;
Bool is_direct;
 
opcode = __glXSetupForCommand(dpy);
if (!opcode) {
return False;
}
 
c = XGetXCBConnection(dpy);
reply = xcb_glx_is_direct_reply(c, xcb_glx_is_direct(c, contextID), &err);
is_direct = (reply != NULL && reply->is_direct) ? True : False;
 
if (err != NULL) {
__glXSendErrorForXcb(dpy, err);
free(err);
}
 
free(reply);
 
return is_direct;
}
 
/**
* \todo
* Shouldn't this function \b always return \c False when
* \c GLX_DIRECT_RENDERING is not defined? Do we really need to bother with
* the GLX protocol here at all?
*/
_X_EXPORT Bool
glXIsDirect(Display * dpy, GLXContext gc_user)
{
struct glx_context *gc = (struct glx_context *) gc_user;
 
if (!gc) {
return False;
}
else if (gc->isDirect) {
return True;
}
#ifdef GLX_USE_APPLEGL /* TODO: indirect on darwin */
return False;
#else
return __glXIsDirect(dpy, gc->xid);
#endif
}
 
_X_EXPORT GLXPixmap
glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
{
#ifdef GLX_USE_APPLEGL
int screen = vis->screen;
struct glx_screen *const psc = GetGLXScreenConfigs(dpy, screen);
const struct glx_config *config;
 
config = glx_config_find_visual(psc->visuals, vis->visualid);
if(apple_glx_pixmap_create(dpy, vis->screen, pixmap, config))
return None;
return pixmap;
#else
xGLXCreateGLXPixmapReq *req;
struct glx_drawable *glxDraw;
GLXPixmap xid;
CARD8 opcode;
 
opcode = __glXSetupForCommand(dpy);
if (!opcode) {
return None;
}
 
glxDraw = malloc(sizeof(*glxDraw));
if (!glxDraw)
return None;
 
/* Send the glXCreateGLXPixmap request */
LockDisplay(dpy);
GetReq(GLXCreateGLXPixmap, req);
req->reqType = opcode;
req->glxCode = X_GLXCreateGLXPixmap;
req->screen = vis->screen;
req->visual = vis->visualid;
req->pixmap = pixmap;
req->glxpixmap = xid = XAllocID(dpy);
UnlockDisplay(dpy);
SyncHandle();
 
if (InitGLXDrawable(dpy, glxDraw, pixmap, req->glxpixmap)) {
free(glxDraw);
return None;
}
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
do {
/* FIXME: Maybe delay __DRIdrawable creation until the drawable
* is actually bound to a context... */
 
struct glx_display *const priv = __glXInitialize(dpy);
__GLXDRIdrawable *pdraw;
struct glx_screen *psc;
struct glx_config *config;
 
psc = priv->screens[vis->screen];
if (psc->driScreen == NULL)
return xid;
 
config = glx_config_find_visual(psc->visuals, vis->visualid);
pdraw = psc->driScreen->createDrawable(psc, pixmap, xid, config);
if (pdraw == NULL) {
fprintf(stderr, "failed to create pixmap\n");
xid = None;
break;
}
 
if (__glxHashInsert(priv->drawHash, xid, pdraw)) {
(*pdraw->destroyDrawable) (pdraw);
xid = None;
break;
}
} while (0);
 
if (xid == None) {
xGLXDestroyGLXPixmapReq *dreq;
LockDisplay(dpy);
GetReq(GLXDestroyGLXPixmap, dreq);
dreq->reqType = opcode;
dreq->glxCode = X_GLXDestroyGLXPixmap;
dreq->glxpixmap = xid;
UnlockDisplay(dpy);
SyncHandle();
}
#endif
 
return xid;
#endif
}
 
/*
** Destroy the named pixmap
*/
_X_EXPORT void
glXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap)
{
#ifdef GLX_USE_APPLEGL
if(apple_glx_pixmap_destroy(dpy, glxpixmap))
__glXSendError(dpy, GLXBadPixmap, glxpixmap, X_GLXDestroyPixmap, false);
#else
xGLXDestroyGLXPixmapReq *req;
CARD8 opcode;
 
opcode = __glXSetupForCommand(dpy);
if (!opcode) {
return;
}
 
/* Send the glXDestroyGLXPixmap request */
LockDisplay(dpy);
GetReq(GLXDestroyGLXPixmap, req);
req->reqType = opcode;
req->glxCode = X_GLXDestroyGLXPixmap;
req->glxpixmap = glxpixmap;
UnlockDisplay(dpy);
SyncHandle();
 
DestroyGLXDrawable(dpy, glxpixmap);
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
{
struct glx_display *const priv = __glXInitialize(dpy);
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, glxpixmap);
 
if (pdraw != NULL) {
(*pdraw->destroyDrawable) (pdraw);
__glxHashDelete(priv->drawHash, glxpixmap);
}
}
#endif
#endif /* GLX_USE_APPLEGL */
}
 
_X_EXPORT void
glXSwapBuffers(Display * dpy, GLXDrawable drawable)
{
#ifdef GLX_USE_APPLEGL
struct glx_context * gc = __glXGetCurrentContext();
if(gc && apple_glx_is_current_drawable(dpy, gc->driContext, drawable)) {
apple_glx_swap_buffers(gc->driContext);
} else {
__glXSendError(dpy, GLXBadCurrentWindow, 0, X_GLXSwapBuffers, false);
}
#else
struct glx_context *gc;
GLXContextTag tag;
CARD8 opcode;
xcb_connection_t *c;
 
gc = __glXGetCurrentContext();
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
{
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
 
if (pdraw != NULL) {
Bool flush = gc && drawable == gc->currentDrawable;
 
(*pdraw->psc->driScreen->swapBuffers)(pdraw, 0, 0, 0, flush);
return;
}
}
#endif
 
opcode = __glXSetupForCommand(dpy);
if (!opcode) {
return;
}
 
/*
** The calling thread may or may not have a current context. If it
** does, send the context tag so the server can do a flush.
*/
if ((gc != NULL) && (dpy == gc->currentDpy) &&
((drawable == gc->currentDrawable)
|| (drawable == gc->currentReadable))) {
tag = gc->currentContextTag;
}
else {
tag = 0;
}
 
c = XGetXCBConnection(dpy);
xcb_glx_swap_buffers(c, tag, drawable);
xcb_flush(c);
#endif /* GLX_USE_APPLEGL */
}
 
 
/*
** Return configuration information for the given display, screen and
** visual combination.
*/
_X_EXPORT int
glXGetConfig(Display * dpy, XVisualInfo * vis, int attribute,
int *value_return)
{
struct glx_display *priv;
struct glx_screen *psc;
struct glx_config *config;
int status;
 
status = GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc);
if (status == Success) {
config = glx_config_find_visual(psc->visuals, vis->visualid);
 
/* Lookup attribute after first finding a match on the visual */
if (config != NULL) {
return glx_config_get(config, attribute, value_return);
}
 
status = GLX_BAD_VISUAL;
}
 
/*
** If we can't find the config for this visual, this visual is not
** supported by the OpenGL implementation on the server.
*/
if ((status == GLX_BAD_VISUAL) && (attribute == GLX_USE_GL)) {
*value_return = False;
status = Success;
}
 
return status;
}
 
/************************************************************************/
 
static void
init_fbconfig_for_chooser(struct glx_config * config,
GLboolean fbconfig_style_tags)
{
memset(config, 0, sizeof(struct glx_config));
config->visualID = (XID) GLX_DONT_CARE;
config->visualType = GLX_DONT_CARE;
 
/* glXChooseFBConfig specifies different defaults for these properties than
* glXChooseVisual.
*/
if (fbconfig_style_tags) {
config->rgbMode = GL_TRUE;
config->doubleBufferMode = GLX_DONT_CARE;
/* allow any kind of drawable, including those for off-screen buffers */
config->drawableType = 0;
} else {
/* allow configs which support on-screen drawing */
config->drawableType = GLX_WINDOW_BIT;
}
 
config->visualRating = GLX_DONT_CARE;
config->transparentPixel = GLX_NONE;
config->transparentRed = GLX_DONT_CARE;
config->transparentGreen = GLX_DONT_CARE;
config->transparentBlue = GLX_DONT_CARE;
config->transparentAlpha = GLX_DONT_CARE;
config->transparentIndex = GLX_DONT_CARE;
 
/* Set GLX_RENDER_TYPE property to not expect any flags by default. */
config->renderType = 0;
config->xRenderable = GLX_DONT_CARE;
config->fbconfigID = (GLXFBConfigID) (GLX_DONT_CARE);
 
config->swapMethod = GLX_DONT_CARE;
}
 
#define MATCH_DONT_CARE( param ) \
do { \
if ( ((int) a-> param != (int) GLX_DONT_CARE) \
&& (a-> param != b-> param) ) { \
return False; \
} \
} while ( 0 )
 
#define MATCH_MINIMUM( param ) \
do { \
if ( ((int) a-> param != (int) GLX_DONT_CARE) \
&& (a-> param > b-> param) ) { \
return False; \
} \
} while ( 0 )
 
#define MATCH_EXACT( param ) \
do { \
if ( a-> param != b-> param) { \
return False; \
} \
} while ( 0 )
 
/* Test that all bits from a are contained in b */
#define MATCH_MASK(param) \
do { \
if ( ((int) a-> param != (int) GLX_DONT_CARE) \
&& ((a->param & ~b->param) != 0) ) { \
return False; \
} \
} while (0);
 
/**
* Determine if two GLXFBConfigs are compatible.
*
* \param a Application specified config to test.
* \param b Server specified config to test against \c a.
*/
static Bool
fbconfigs_compatible(const struct glx_config * const a,
const struct glx_config * const b)
{
MATCH_DONT_CARE(doubleBufferMode);
MATCH_DONT_CARE(visualType);
MATCH_DONT_CARE(visualRating);
MATCH_DONT_CARE(xRenderable);
MATCH_DONT_CARE(fbconfigID);
MATCH_DONT_CARE(swapMethod);
 
MATCH_MINIMUM(rgbBits);
MATCH_MINIMUM(numAuxBuffers);
MATCH_MINIMUM(redBits);
MATCH_MINIMUM(greenBits);
MATCH_MINIMUM(blueBits);
MATCH_MINIMUM(alphaBits);
MATCH_MINIMUM(depthBits);
MATCH_MINIMUM(stencilBits);
MATCH_MINIMUM(accumRedBits);
MATCH_MINIMUM(accumGreenBits);
MATCH_MINIMUM(accumBlueBits);
MATCH_MINIMUM(accumAlphaBits);
MATCH_MINIMUM(sampleBuffers);
MATCH_MINIMUM(maxPbufferWidth);
MATCH_MINIMUM(maxPbufferHeight);
MATCH_MINIMUM(maxPbufferPixels);
MATCH_MINIMUM(samples);
 
MATCH_DONT_CARE(stereoMode);
MATCH_EXACT(level);
 
MATCH_MASK(drawableType);
MATCH_MASK(renderType);
 
/* There is a bug in a few of the XFree86 DDX drivers. They contain
* visuals with a "transparent type" of 0 when they really mean GLX_NONE.
* Technically speaking, it is a bug in the DDX driver, but there is
* enough of an installed base to work around the problem here. In any
* case, 0 is not a valid value of the transparent type, so we'll treat 0
* from the app as GLX_DONT_CARE. We'll consider GLX_NONE from the app and
* 0 from the server to be a match to maintain backward compatibility with
* the (broken) drivers.
*/
 
if (a->transparentPixel != (int) GLX_DONT_CARE && a->transparentPixel != 0) {
if (a->transparentPixel == GLX_NONE) {
if (b->transparentPixel != GLX_NONE && b->transparentPixel != 0)
return False;
}
else {
MATCH_EXACT(transparentPixel);
}
 
switch (a->transparentPixel) {
case GLX_TRANSPARENT_RGB:
MATCH_DONT_CARE(transparentRed);
MATCH_DONT_CARE(transparentGreen);
MATCH_DONT_CARE(transparentBlue);
MATCH_DONT_CARE(transparentAlpha);
break;
 
case GLX_TRANSPARENT_INDEX:
MATCH_DONT_CARE(transparentIndex);
break;
 
default:
break;
}
}
 
return True;
}
 
 
/* There's some trickly language in the GLX spec about how this is supposed
* to work. Basically, if a given component size is either not specified
* or the requested size is zero, it is supposed to act like PERFER_SMALLER.
* Well, that's really hard to do with the code as-is. This behavior is
* closer to correct, but still not technically right.
*/
#define PREFER_LARGER_OR_ZERO(comp) \
do { \
if ( ((*a)-> comp) != ((*b)-> comp) ) { \
if ( ((*a)-> comp) == 0 ) { \
return -1; \
} \
else if ( ((*b)-> comp) == 0 ) { \
return 1; \
} \
else { \
return ((*b)-> comp) - ((*a)-> comp) ; \
} \
} \
} while( 0 )
 
#define PREFER_LARGER(comp) \
do { \
if ( ((*a)-> comp) != ((*b)-> comp) ) { \
return ((*b)-> comp) - ((*a)-> comp) ; \
} \
} while( 0 )
 
#define PREFER_SMALLER(comp) \
do { \
if ( ((*a)-> comp) != ((*b)-> comp) ) { \
return ((*a)-> comp) - ((*b)-> comp) ; \
} \
} while( 0 )
 
/**
* Compare two GLXFBConfigs. This function is intended to be used as the
* compare function passed in to qsort.
*
* \returns If \c a is a "better" config, according to the specification of
* SGIX_fbconfig, a number less than zero is returned. If \c b is
* better, then a number greater than zero is return. If both are
* equal, zero is returned.
* \sa qsort, glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX
*/
static int
fbconfig_compare(struct glx_config **a, struct glx_config **b)
{
/* The order of these comparisons must NOT change. It is defined by
* the GLX 1.3 spec and ARB_multisample.
*/
 
PREFER_SMALLER(visualSelectGroup);
 
/* The sort order for the visualRating is GLX_NONE, GLX_SLOW, and
* GLX_NON_CONFORMANT_CONFIG. It just so happens that this is the
* numerical sort order of the enums (0x8000, 0x8001, and 0x800D).
*/
PREFER_SMALLER(visualRating);
 
/* This isn't quite right. It is supposed to compare the sum of the
* components the user specifically set minimums for.
*/
PREFER_LARGER_OR_ZERO(redBits);
PREFER_LARGER_OR_ZERO(greenBits);
PREFER_LARGER_OR_ZERO(blueBits);
PREFER_LARGER_OR_ZERO(alphaBits);
 
PREFER_SMALLER(rgbBits);
 
if (((*a)->doubleBufferMode != (*b)->doubleBufferMode)) {
/* Prefer single-buffer.
*/
return (!(*a)->doubleBufferMode) ? -1 : 1;
}
 
PREFER_SMALLER(numAuxBuffers);
 
PREFER_LARGER_OR_ZERO(depthBits);
PREFER_SMALLER(stencilBits);
 
/* This isn't quite right. It is supposed to compare the sum of the
* components the user specifically set minimums for.
*/
PREFER_LARGER_OR_ZERO(accumRedBits);
PREFER_LARGER_OR_ZERO(accumGreenBits);
PREFER_LARGER_OR_ZERO(accumBlueBits);
PREFER_LARGER_OR_ZERO(accumAlphaBits);
 
PREFER_SMALLER(visualType);
 
/* None of the multisample specs say where this comparison should happen,
* so I put it near the end.
*/
PREFER_SMALLER(sampleBuffers);
PREFER_SMALLER(samples);
 
/* None of the pbuffer or fbconfig specs say that this comparison needs
* to happen at all, but it seems like it should.
*/
PREFER_LARGER(maxPbufferWidth);
PREFER_LARGER(maxPbufferHeight);
PREFER_LARGER(maxPbufferPixels);
 
return 0;
}
 
 
/**
* Selects and sorts a subset of the supplied configs based on the attributes.
* This function forms to basis of \c glXChooseVisual, \c glXChooseFBConfig,
* and \c glXChooseFBConfigSGIX.
*
* \param configs Array of pointers to possible configs. The elements of
* this array that do not meet the criteria will be set to
* NULL. The remaining elements will be sorted according to
* the various visual / FBConfig selection rules.
* \param num_configs Number of elements in the \c configs array.
* \param attribList Attributes used select from \c configs. This array is
* terminated by a \c None tag. The array can either take
* the form expected by \c glXChooseVisual (where boolean
* tags do not have a value) or by \c glXChooseFBConfig
* (where every tag has a value).
* \param fbconfig_style_tags Selects whether \c attribList is in
* \c glXChooseVisual style or
* \c glXChooseFBConfig style.
* \returns The number of valid elements left in \c configs.
*
* \sa glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX
*/
static int
choose_visual(struct glx_config ** configs, int num_configs,
const int *attribList, GLboolean fbconfig_style_tags)
{
struct glx_config test_config;
int base;
int i;
 
/* This is a fairly direct implementation of the selection method
* described by GLX_SGIX_fbconfig. Start by culling out all the
* configs that are not compatible with the selected parameter
* list.
*/
 
init_fbconfig_for_chooser(&test_config, fbconfig_style_tags);
__glXInitializeVisualConfigFromTags(&test_config, 512,
(const INT32 *) attribList,
GL_TRUE, fbconfig_style_tags);
 
base = 0;
for (i = 0; i < num_configs; i++) {
if (fbconfigs_compatible(&test_config, configs[i])) {
configs[base] = configs[i];
base++;
}
}
 
if (base == 0) {
return 0;
}
 
if (base < num_configs) {
(void) memset(&configs[base], 0, sizeof(void *) * (num_configs - base));
}
 
/* After the incompatible configs are removed, the resulting
* list is sorted according to the rules set out in the various
* specifications.
*/
 
qsort(configs, base, sizeof(struct glx_config *),
(int (*)(const void *, const void *)) fbconfig_compare);
return base;
}
 
 
 
 
/*
** Return the visual that best matches the template. Return None if no
** visual matches the template.
*/
_X_EXPORT XVisualInfo *
glXChooseVisual(Display * dpy, int screen, int *attribList)
{
XVisualInfo *visualList = NULL;
struct glx_display *priv;
struct glx_screen *psc;
struct glx_config test_config;
struct glx_config *config;
struct glx_config *best_config = NULL;
 
/*
** Get a list of all visuals, return if list is empty
*/
if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) {
return None;
}
 
 
/*
** Build a template from the defaults and the attribute list
** Free visual list and return if an unexpected token is encountered
*/
init_fbconfig_for_chooser(&test_config, GL_FALSE);
__glXInitializeVisualConfigFromTags(&test_config, 512,
(const INT32 *) attribList,
GL_TRUE, GL_FALSE);
 
/*
** Eliminate visuals that don't meet minimum requirements
** Compute a score for those that do
** Remember which visual, if any, got the highest score
** If no visual is acceptable, return None
** Otherwise, create an XVisualInfo list with just the selected X visual
** and return this.
*/
for (config = psc->visuals; config != NULL; config = config->next) {
if (fbconfigs_compatible(&test_config, config)
&& ((best_config == NULL) ||
(fbconfig_compare (&config, &best_config) < 0))) {
XVisualInfo visualTemplate;
XVisualInfo *newList;
int i;
 
visualTemplate.screen = screen;
visualTemplate.visualid = config->visualID;
newList = XGetVisualInfo(dpy, VisualScreenMask | VisualIDMask,
&visualTemplate, &i);
 
if (newList) {
free(visualList);
visualList = newList;
best_config = config;
}
}
}
 
#ifdef GLX_USE_APPLEGL
if(visualList && getenv("LIBGL_DUMP_VISUALID")) {
printf("visualid 0x%lx\n", visualList[0].visualid);
}
#endif
 
return visualList;
}
 
 
_X_EXPORT const char *
glXQueryExtensionsString(Display * dpy, int screen)
{
struct glx_screen *psc;
struct glx_display *priv;
 
if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) {
return NULL;
}
 
if (!psc->effectiveGLXexts) {
if (!psc->serverGLXexts) {
psc->serverGLXexts =
__glXQueryServerString(dpy, priv->majorOpcode, screen,
GLX_EXTENSIONS);
}
 
__glXCalculateUsableExtensions(psc,
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
(psc->driScreen != NULL),
#else
GL_FALSE,
#endif
priv->minorVersion);
}
 
return psc->effectiveGLXexts;
}
 
_X_EXPORT const char *
glXGetClientString(Display * dpy, int name)
{
(void) dpy;
 
switch (name) {
case GLX_VENDOR:
return (__glXGLXClientVendorName);
case GLX_VERSION:
return (__glXGLXClientVersion);
case GLX_EXTENSIONS:
return (__glXGetClientExtensions());
default:
return NULL;
}
}
 
_X_EXPORT const char *
glXQueryServerString(Display * dpy, int screen, int name)
{
struct glx_screen *psc;
struct glx_display *priv;
const char **str;
 
 
if (GetGLXPrivScreenConfig(dpy, screen, &priv, &psc) != Success) {
return NULL;
}
 
switch (name) {
case GLX_VENDOR:
str = &priv->serverGLXvendor;
break;
case GLX_VERSION:
str = &priv->serverGLXversion;
break;
case GLX_EXTENSIONS:
str = &psc->serverGLXexts;
break;
default:
return NULL;
}
 
if (*str == NULL) {
*str = __glXQueryServerString(dpy, priv->majorOpcode, screen, name);
}
 
return *str;
}
 
void
__glXClientInfo(Display * dpy, int opcode)
{
char *ext_str = __glXGetClientGLExtensionString();
int size = strlen(ext_str) + 1;
 
xcb_connection_t *c = XGetXCBConnection(dpy);
xcb_glx_client_info(c,
GLX_MAJOR_VERSION, GLX_MINOR_VERSION, size, ext_str);
 
free(ext_str);
}
 
 
/*
** EXT_import_context
*/
 
_X_EXPORT Display *
glXGetCurrentDisplay(void)
{
struct glx_context *gc = __glXGetCurrentContext();
if (NULL == gc)
return NULL;
return gc->currentDpy;
}
 
_X_EXPORT
GLX_ALIAS(Display *, glXGetCurrentDisplayEXT, (void), (),
glXGetCurrentDisplay)
 
#ifndef GLX_USE_APPLEGL
_X_EXPORT GLXContext
glXImportContextEXT(Display *dpy, GLXContextID contextID)
{
struct glx_display *priv = __glXInitialize(dpy);
struct glx_screen *psc = NULL;
xGLXQueryContextReply reply;
CARD8 opcode;
struct glx_context *ctx;
 
/* This GLX implementation knows about 5 different properties, so
* allow the server to send us one of each.
*/
int propList[5 * 2], *pProp, nPropListBytes;
int numProps;
int i, renderType;
XID share;
struct glx_config *mode;
uint32_t fbconfigID = 0;
uint32_t visualID = 0;
uint32_t screen = 0;
Bool got_screen = False;
 
/* The GLX_EXT_import_context spec says:
*
* "If <contextID> does not refer to a valid context, then a BadContext
* error is generated; if <contextID> refers to direct rendering
* context then no error is generated but glXImportContextEXT returns
* NULL."
*
* If contextID is None, generate BadContext on the client-side. Other
* sorts of invalid contexts will be detected by the server in the
* __glXIsDirect call.
*/
if (contextID == None) {
__glXSendError(dpy, GLXBadContext, contextID, X_GLXIsDirect, false);
return NULL;
}
 
if (__glXIsDirect(dpy, contextID))
return NULL;
 
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return 0;
 
/* Send the glXQueryContextInfoEXT request */
LockDisplay(dpy);
 
if (priv->majorVersion > 1 || priv->minorVersion >= 3) {
xGLXQueryContextReq *req;
 
GetReq(GLXQueryContext, req);
 
req->reqType = opcode;
req->glxCode = X_GLXQueryContext;
req->context = contextID;
}
else {
xGLXVendorPrivateReq *vpreq;
xGLXQueryContextInfoEXTReq *req;
 
GetReqExtra(GLXVendorPrivate,
sz_xGLXQueryContextInfoEXTReq - sz_xGLXVendorPrivateReq,
vpreq);
req = (xGLXQueryContextInfoEXTReq *) vpreq;
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivateWithReply;
req->vendorCode = X_GLXvop_QueryContextInfoEXT;
req->context = contextID;
}
 
_XReply(dpy, (xReply *) & reply, 0, False);
 
if (reply.n <= __GLX_MAX_CONTEXT_PROPS)
nPropListBytes = reply.n * 2 * sizeof propList[0];
else
nPropListBytes = 0;
_XRead(dpy, (char *) propList, nPropListBytes);
UnlockDisplay(dpy);
SyncHandle();
 
numProps = nPropListBytes / (2 * sizeof(propList[0]));
share = None;
mode = NULL;
renderType = GLX_RGBA_TYPE; /* By default, assume RGBA context */
pProp = propList;
 
for (i = 0, pProp = propList; i < numProps; i++, pProp += 2)
switch (pProp[0]) {
case GLX_SCREEN:
screen = pProp[1];
got_screen = True;
break;
case GLX_SHARE_CONTEXT_EXT:
share = pProp[1];
break;
case GLX_VISUAL_ID_EXT:
visualID = pProp[1];
break;
case GLX_FBCONFIG_ID:
fbconfigID = pProp[1];
break;
case GLX_RENDER_TYPE:
renderType = pProp[1];
break;
}
 
if (!got_screen)
return NULL;
 
psc = GetGLXScreenConfigs(dpy, screen);
if (psc == NULL)
return NULL;
 
if (fbconfigID != 0) {
mode = glx_config_find_fbconfig(psc->configs, fbconfigID);
} else if (visualID != 0) {
mode = glx_config_find_visual(psc->visuals, visualID);
}
 
if (mode == NULL)
return NULL;
 
ctx = indirect_create_context(psc, mode, NULL, renderType);
if (ctx == NULL)
return NULL;
 
ctx->xid = contextID;
ctx->imported = GL_TRUE;
ctx->share_xid = share;
 
return (GLXContext) ctx;
}
 
#endif
 
_X_EXPORT int
glXQueryContext(Display * dpy, GLXContext ctx_user, int attribute, int *value)
{
struct glx_context *ctx = (struct glx_context *) ctx_user;
 
switch (attribute) {
case GLX_SHARE_CONTEXT_EXT:
*value = ctx->share_xid;
break;
case GLX_VISUAL_ID_EXT:
*value = ctx->config ? ctx->config->visualID : None;
break;
case GLX_SCREEN:
*value = ctx->screen;
break;
case GLX_FBCONFIG_ID:
*value = ctx->config ? ctx->config->fbconfigID : None;
break;
case GLX_RENDER_TYPE:
*value = ctx->renderType;
break;
default:
return GLX_BAD_ATTRIBUTE;
}
return Success;
}
 
_X_EXPORT
GLX_ALIAS(int, glXQueryContextInfoEXT,
(Display * dpy, GLXContext ctx, int attribute, int *value),
(dpy, ctx, attribute, value), glXQueryContext)
 
_X_EXPORT GLXContextID glXGetContextIDEXT(const GLXContext ctx_user)
{
struct glx_context *ctx = (struct glx_context *) ctx_user;
 
return (ctx == NULL) ? None : ctx->xid;
}
 
_X_EXPORT void
glXFreeContextEXT(Display *dpy, GLXContext ctx)
{
struct glx_context *gc = (struct glx_context *) ctx;
 
if (gc == NULL || gc->xid == None)
return;
 
/* The GLX_EXT_import_context spec says:
*
* "glXFreeContext does not free the server-side context information or
* the XID associated with the server-side context."
*
* Don't send any protocol. Just destroy the client-side tracking of the
* context. Also, only release the context structure if it's not current.
*/
__glXLock();
if (gc->currentDpy) {
gc->xid = None;
} else {
gc->vtable->destroy(gc);
}
__glXUnlock();
}
 
_X_EXPORT GLXFBConfig *
glXChooseFBConfig(Display * dpy, int screen,
const int *attribList, int *nitems)
{
struct glx_config **config_list;
int list_size;
 
 
config_list = (struct glx_config **)
glXGetFBConfigs(dpy, screen, &list_size);
 
if ((config_list != NULL) && (list_size > 0) && (attribList != NULL)) {
list_size = choose_visual(config_list, list_size, attribList, GL_TRUE);
if (list_size == 0) {
free(config_list);
config_list = NULL;
}
}
 
*nitems = list_size;
return (GLXFBConfig *) config_list;
}
 
 
_X_EXPORT GLXContext
glXCreateNewContext(Display * dpy, GLXFBConfig fbconfig,
int renderType, GLXContext shareList, Bool allowDirect)
{
struct glx_config *config = (struct glx_config *) fbconfig;
 
return CreateContext(dpy, config->fbconfigID, config, shareList,
allowDirect, X_GLXCreateNewContext, renderType,
config->screen);
}
 
 
_X_EXPORT GLXDrawable
glXGetCurrentReadDrawable(void)
{
struct glx_context *gc = __glXGetCurrentContext();
 
return gc->currentReadable;
}
 
 
_X_EXPORT GLXFBConfig *
glXGetFBConfigs(Display * dpy, int screen, int *nelements)
{
struct glx_display *priv = __glXInitialize(dpy);
struct glx_config **config_list = NULL;
struct glx_config *config;
unsigned num_configs = 0;
int i;
 
*nelements = 0;
if (priv && (priv->screens != NULL)
&& (screen >= 0) && (screen <= ScreenCount(dpy))
&& (priv->screens[screen]->configs != NULL)
&& (priv->screens[screen]->configs->fbconfigID
!= (int) GLX_DONT_CARE)) {
 
for (config = priv->screens[screen]->configs; config != NULL;
config = config->next) {
if (config->fbconfigID != (int) GLX_DONT_CARE) {
num_configs++;
}
}
 
config_list = malloc(num_configs * sizeof *config_list);
if (config_list != NULL) {
*nelements = num_configs;
i = 0;
for (config = priv->screens[screen]->configs; config != NULL;
config = config->next) {
if (config->fbconfigID != (int) GLX_DONT_CARE) {
config_list[i] = config;
i++;
}
}
}
}
 
return (GLXFBConfig *) config_list;
}
 
 
_X_EXPORT int
glXGetFBConfigAttrib(Display * dpy, GLXFBConfig fbconfig,
int attribute, int *value)
{
struct glx_config *config = ValidateGLXFBConfig(dpy, fbconfig);
 
if (config == NULL)
return GLXBadFBConfig;
 
return glx_config_get(config, attribute, value);
}
 
 
_X_EXPORT XVisualInfo *
glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig fbconfig)
{
XVisualInfo visualTemplate;
struct glx_config *config = (struct glx_config *) fbconfig;
int count;
 
/*
** Get a list of all visuals, return if list is empty
*/
visualTemplate.visualid = config->visualID;
return XGetVisualInfo(dpy, VisualIDMask, &visualTemplate, &count);
}
 
#ifndef GLX_USE_APPLEGL
/*
** GLX_SGI_swap_control
*/
static int
__glXSwapIntervalSGI(int interval)
{
xGLXVendorPrivateReq *req;
struct glx_context *gc = __glXGetCurrentContext();
struct glx_screen *psc;
Display *dpy;
CARD32 *interval_ptr;
CARD8 opcode;
 
if (gc == NULL) {
return GLX_BAD_CONTEXT;
}
 
if (interval <= 0) {
return GLX_BAD_VALUE;
}
 
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
 
#ifdef GLX_DIRECT_RENDERING
if (gc->isDirect && psc->driScreen && psc->driScreen->setSwapInterval) {
__GLXDRIdrawable *pdraw =
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
psc->driScreen->setSwapInterval(pdraw, interval);
return 0;
}
#endif
 
dpy = gc->currentDpy;
opcode = __glXSetupForCommand(dpy);
if (!opcode) {
return 0;
}
 
/* Send the glXSwapIntervalSGI request */
LockDisplay(dpy);
GetReqExtra(GLXVendorPrivate, sizeof(CARD32), req);
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivate;
req->vendorCode = X_GLXvop_SwapIntervalSGI;
req->contextTag = gc->currentContextTag;
 
interval_ptr = (CARD32 *) (req + 1);
*interval_ptr = interval;
 
UnlockDisplay(dpy);
SyncHandle();
XFlush(dpy);
 
return 0;
}
 
 
/*
** GLX_MESA_swap_control
*/
static int
__glXSwapIntervalMESA(unsigned int interval)
{
#ifdef GLX_DIRECT_RENDERING
struct glx_context *gc = __glXGetCurrentContext();
 
if (gc != NULL && gc->isDirect) {
struct glx_screen *psc;
 
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
if (psc->driScreen && psc->driScreen->setSwapInterval) {
__GLXDRIdrawable *pdraw =
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
return psc->driScreen->setSwapInterval(pdraw, interval);
}
}
#endif
 
return GLX_BAD_CONTEXT;
}
 
 
static int
__glXGetSwapIntervalMESA(void)
{
#ifdef GLX_DIRECT_RENDERING
struct glx_context *gc = __glXGetCurrentContext();
 
if (gc != NULL && gc->isDirect) {
struct glx_screen *psc;
 
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
if (psc->driScreen && psc->driScreen->getSwapInterval) {
__GLXDRIdrawable *pdraw =
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
return psc->driScreen->getSwapInterval(pdraw);
}
}
#endif
 
return 0;
}
 
 
/*
** GLX_SGI_video_sync
*/
static int
__glXGetVideoSyncSGI(unsigned int *count)
{
int64_t ust, msc, sbc;
int ret;
struct glx_context *gc = __glXGetCurrentContext();
struct glx_screen *psc;
#ifdef GLX_DIRECT_RENDERING
__GLXDRIdrawable *pdraw;
#endif
 
if (!gc)
return GLX_BAD_CONTEXT;
 
#ifdef GLX_DIRECT_RENDERING
if (!gc->isDirect)
return GLX_BAD_CONTEXT;
#endif
 
psc = GetGLXScreenConfigs(gc->currentDpy, gc->screen);
#ifdef GLX_DIRECT_RENDERING
pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
#endif
 
/* FIXME: Looking at the GLX_SGI_video_sync spec in the extension registry,
* FIXME: there should be a GLX encoding for this call. I can find no
* FIXME: documentation for the GLX encoding.
*/
#ifdef GLX_DIRECT_RENDERING
if (psc->driScreen && psc->driScreen->getDrawableMSC) {
ret = psc->driScreen->getDrawableMSC(psc, pdraw, &ust, &msc, &sbc);
*count = (unsigned) msc;
return (ret == True) ? 0 : GLX_BAD_CONTEXT;
}
#endif
 
return GLX_BAD_CONTEXT;
}
 
static int
__glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
{
struct glx_context *gc = __glXGetCurrentContext();
struct glx_screen *psc;
#ifdef GLX_DIRECT_RENDERING
__GLXDRIdrawable *pdraw;
#endif
int64_t ust, msc, sbc;
int ret;
 
if (divisor <= 0 || remainder < 0)
return GLX_BAD_VALUE;
 
if (!gc)
return GLX_BAD_CONTEXT;
 
#ifdef GLX_DIRECT_RENDERING
if (!gc->isDirect)
return GLX_BAD_CONTEXT;
#endif
 
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
#ifdef GLX_DIRECT_RENDERING
pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
#endif
 
#ifdef GLX_DIRECT_RENDERING
if (psc->driScreen && psc->driScreen->waitForMSC) {
ret = psc->driScreen->waitForMSC(pdraw, 0, divisor, remainder, &ust, &msc,
&sbc);
*count = (unsigned) msc;
return (ret == True) ? 0 : GLX_BAD_CONTEXT;
}
#endif
 
return GLX_BAD_CONTEXT;
}
 
#endif /* GLX_USE_APPLEGL */
 
/*
** GLX_SGIX_fbconfig
** Many of these functions are aliased to GLX 1.3 entry points in the
** GLX_functions table.
*/
 
_X_EXPORT
GLX_ALIAS(int, glXGetFBConfigAttribSGIX,
(Display * dpy, GLXFBConfigSGIX config, int attribute, int *value),
(dpy, config, attribute, value), glXGetFBConfigAttrib)
 
_X_EXPORT GLX_ALIAS(GLXFBConfigSGIX *, glXChooseFBConfigSGIX,
(Display * dpy, int screen, int *attrib_list,
int *nelements), (dpy, screen, attrib_list, nelements),
glXChooseFBConfig)
 
_X_EXPORT GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX,
(Display * dpy, GLXFBConfigSGIX config),
(dpy, config), glXGetVisualFromFBConfig)
 
_X_EXPORT GLXPixmap
glXCreateGLXPixmapWithConfigSGIX(Display * dpy,
GLXFBConfigSGIX fbconfig,
Pixmap pixmap)
{
#ifndef GLX_USE_APPLEGL
xGLXVendorPrivateWithReplyReq *vpreq;
xGLXCreateGLXPixmapWithConfigSGIXReq *req;
GLXPixmap xid = None;
CARD8 opcode;
struct glx_screen *psc;
#endif
struct glx_config *config = (struct glx_config *) fbconfig;
 
 
if ((dpy == NULL) || (config == NULL)) {
return None;
}
#ifdef GLX_USE_APPLEGL
if(apple_glx_pixmap_create(dpy, config->screen, pixmap, config))
return None;
return pixmap;
#else
 
psc = GetGLXScreenConfigs(dpy, config->screen);
if ((psc != NULL)
&& __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) {
opcode = __glXSetupForCommand(dpy);
if (!opcode) {
return None;
}
 
/* Send the glXCreateGLXPixmapWithConfigSGIX request */
LockDisplay(dpy);
GetReqExtra(GLXVendorPrivateWithReply,
sz_xGLXCreateGLXPixmapWithConfigSGIXReq -
sz_xGLXVendorPrivateWithReplyReq, vpreq);
req = (xGLXCreateGLXPixmapWithConfigSGIXReq *) vpreq;
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivateWithReply;
req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX;
req->screen = config->screen;
req->fbconfig = config->fbconfigID;
req->pixmap = pixmap;
req->glxpixmap = xid = XAllocID(dpy);
UnlockDisplay(dpy);
SyncHandle();
}
 
return xid;
#endif
}
 
_X_EXPORT GLXContext
glXCreateContextWithConfigSGIX(Display * dpy,
GLXFBConfigSGIX fbconfig, int renderType,
GLXContext shareList, Bool allowDirect)
{
GLXContext gc = NULL;
struct glx_config *config = (struct glx_config *) fbconfig;
struct glx_screen *psc;
 
 
if ((dpy == NULL) || (config == NULL)) {
return None;
}
 
psc = GetGLXScreenConfigs(dpy, config->screen);
if ((psc != NULL)
&& __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) {
gc = CreateContext(dpy, config->fbconfigID, config, shareList,
allowDirect,
X_GLXvop_CreateContextWithConfigSGIX, renderType,
config->screen);
}
 
return gc;
}
 
 
_X_EXPORT GLXFBConfigSGIX
glXGetFBConfigFromVisualSGIX(Display * dpy, XVisualInfo * vis)
{
struct glx_display *priv;
struct glx_screen *psc = NULL;
 
if ((GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc) == Success)
&& __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)
&& (psc->configs->fbconfigID != (int) GLX_DONT_CARE)) {
return (GLXFBConfigSGIX) glx_config_find_visual(psc->configs,
vis->visualid);
}
 
return NULL;
}
 
#ifndef GLX_USE_APPLEGL
/*
** GLX_SGIX_swap_group
*/
static void
__glXJoinSwapGroupSGIX(Display * dpy, GLXDrawable drawable,
GLXDrawable member)
{
(void) dpy;
(void) drawable;
(void) member;
}
 
 
/*
** GLX_SGIX_swap_barrier
*/
static void
__glXBindSwapBarrierSGIX(Display * dpy, GLXDrawable drawable, int barrier)
{
(void) dpy;
(void) drawable;
(void) barrier;
}
 
static Bool
__glXQueryMaxSwapBarriersSGIX(Display * dpy, int screen, int *max)
{
(void) dpy;
(void) screen;
(void) max;
return False;
}
 
 
/*
** GLX_OML_sync_control
*/
static Bool
__glXGetSyncValuesOML(Display * dpy, GLXDrawable drawable,
int64_t * ust, int64_t * msc, int64_t * sbc)
{
struct glx_display * const priv = __glXInitialize(dpy);
int ret;
#ifdef GLX_DIRECT_RENDERING
__GLXDRIdrawable *pdraw;
#endif
struct glx_screen *psc;
 
if (!priv)
return False;
 
#ifdef GLX_DIRECT_RENDERING
pdraw = GetGLXDRIDrawable(dpy, drawable);
psc = pdraw ? pdraw->psc : NULL;
if (pdraw && psc->driScreen->getDrawableMSC) {
ret = psc->driScreen->getDrawableMSC(psc, pdraw, ust, msc, sbc);
return ret;
}
#endif
 
return False;
}
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
_X_HIDDEN GLboolean
__glxGetMscRate(__GLXDRIdrawable *glxDraw,
int32_t * numerator, int32_t * denominator)
{
#ifdef XF86VIDMODE
struct glx_screen *psc;
XF86VidModeModeLine mode_line;
int dot_clock;
int i;
 
psc = glxDraw->psc;
if (XF86VidModeQueryVersion(psc->dpy, &i, &i) &&
XF86VidModeGetModeLine(psc->dpy, psc->scr, &dot_clock, &mode_line)) {
unsigned n = dot_clock * 1000;
unsigned d = mode_line.vtotal * mode_line.htotal;
 
# define V_INTERLACE 0x010
# define V_DBLSCAN 0x020
 
if (mode_line.flags & V_INTERLACE)
n *= 2;
else if (mode_line.flags & V_DBLSCAN)
d *= 2;
 
/* The OML_sync_control spec requires that if the refresh rate is a
* whole number, that the returned numerator be equal to the refresh
* rate and the denominator be 1.
*/
 
if (n % d == 0) {
n /= d;
d = 1;
}
else {
static const unsigned f[] = { 13, 11, 7, 5, 3, 2, 0 };
 
/* This is a poor man's way to reduce a fraction. It's far from
* perfect, but it will work well enough for this situation.
*/
 
for (i = 0; f[i] != 0; i++) {
while (n % f[i] == 0 && d % f[i] == 0) {
d /= f[i];
n /= f[i];
}
}
}
 
*numerator = n;
*denominator = d;
 
return True;
}
else
#endif
 
return False;
}
#endif
 
/**
* Determine the refresh rate of the specified drawable and display.
*
* \param dpy Display whose refresh rate is to be determined.
* \param drawable Drawable whose refresh rate is to be determined.
* \param numerator Numerator of the refresh rate.
* \param demoninator Denominator of the refresh rate.
* \return If the refresh rate for the specified display and drawable could
* be calculated, True is returned. Otherwise False is returned.
*
* \note This function is implemented entirely client-side. A lot of other
* functionality is required to export GLX_OML_sync_control, so on
* XFree86 this function can be called for direct-rendering contexts
* when GLX_OML_sync_control appears in the client extension string.
*/
 
_X_HIDDEN GLboolean
__glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
int32_t * numerator, int32_t * denominator)
{
#if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE )
__GLXDRIdrawable *draw = GetGLXDRIDrawable(dpy, drawable);
 
if (draw == NULL)
return False;
 
return __glxGetMscRate(draw, numerator, denominator);
#else
(void) dpy;
(void) drawable;
(void) numerator;
(void) denominator;
#endif
return False;
}
 
 
static int64_t
__glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable,
int64_t target_msc, int64_t divisor, int64_t remainder)
{
struct glx_context *gc = __glXGetCurrentContext();
#ifdef GLX_DIRECT_RENDERING
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
struct glx_screen *psc = pdraw ? pdraw->psc : NULL;
#endif
 
if (!gc) /* no GLX for this */
return -1;
 
#ifdef GLX_DIRECT_RENDERING
if (!pdraw || !gc->isDirect)
return -1;
#endif
 
/* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE
* error", but it also says "It [glXSwapBuffersMscOML] will return a value
* of -1 if the function failed because of errors detected in the input
* parameters"
*/
if (divisor < 0 || remainder < 0 || target_msc < 0)
return -1;
if (divisor > 0 && remainder >= divisor)
return -1;
 
if (target_msc == 0 && divisor == 0 && remainder == 0)
remainder = 1;
 
#ifdef GLX_DIRECT_RENDERING
if (psc->driScreen && psc->driScreen->swapBuffers)
return (*psc->driScreen->swapBuffers)(pdraw, target_msc, divisor,
remainder, False);
#endif
 
return -1;
}
 
 
static Bool
__glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
int64_t target_msc, int64_t divisor,
int64_t remainder, int64_t * ust,
int64_t * msc, int64_t * sbc)
{
#ifdef GLX_DIRECT_RENDERING
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
struct glx_screen *psc = pdraw ? pdraw->psc : NULL;
int ret;
#endif
 
 
/* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE
* error", but the return type in the spec is Bool.
*/
if (divisor < 0 || remainder < 0 || target_msc < 0)
return False;
if (divisor > 0 && remainder >= divisor)
return False;
 
#ifdef GLX_DIRECT_RENDERING
if (pdraw && psc->driScreen && psc->driScreen->waitForMSC) {
ret = psc->driScreen->waitForMSC(pdraw, target_msc, divisor, remainder,
ust, msc, sbc);
return ret;
}
#endif
 
return False;
}
 
 
static Bool
__glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
int64_t target_sbc, int64_t * ust,
int64_t * msc, int64_t * sbc)
{
#ifdef GLX_DIRECT_RENDERING
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
struct glx_screen *psc = pdraw ? pdraw->psc : NULL;
int ret;
#endif
 
/* The OML_sync_control spec says this should "generate a GLX_BAD_VALUE
* error", but the return type in the spec is Bool.
*/
if (target_sbc < 0)
return False;
 
#ifdef GLX_DIRECT_RENDERING
if (pdraw && psc->driScreen && psc->driScreen->waitForSBC) {
ret = psc->driScreen->waitForSBC(pdraw, target_sbc, ust, msc, sbc);
return ret;
}
#endif
 
return False;
}
 
/*@}*/
 
 
/**
* Mesa extension stubs. These will help reduce portability problems.
*/
/*@{*/
 
/**
* Release all buffers associated with the specified GLX drawable.
*
* \todo
* This function was intended for stand-alone Mesa. The issue there is that
* the library doesn't get any notification when a window is closed. In
* DRI there is a similar but slightly different issue. When GLX 1.3 is
* supported, there are 3 different functions to destroy a drawable. It
* should be possible to create GLX protocol (or have it determine which
* protocol to use based on the type of the drawable) to have one function
* do the work of 3. For the direct-rendering case, this function could
* just call the driver's \c __DRIdrawableRec::destroyDrawable function.
* This would reduce the frequency with which \c __driGarbageCollectDrawables
* would need to be used. This really should be done as part of the new DRI
* interface work.
*
* \sa http://oss.sgi.com/projects/ogl-sample/registry/MESA/release_buffers.txt
* __driGarbageCollectDrawables
* glXDestroyGLXPixmap
* glXDestroyPbuffer glXDestroyPixmap glXDestroyWindow
* glXDestroyGLXPbufferSGIX glXDestroyGLXVideoSourceSGIX
*/
static Bool
__glXReleaseBuffersMESA(Display * dpy, GLXDrawable d)
{
(void) dpy;
(void) d;
return False;
}
 
 
_X_EXPORT GLXPixmap
glXCreateGLXPixmapMESA(Display * dpy, XVisualInfo * visual,
Pixmap pixmap, Colormap cmap)
{
(void) dpy;
(void) visual;
(void) pixmap;
(void) cmap;
return 0;
}
 
/*@}*/
 
 
/**
* GLX_MESA_copy_sub_buffer
*/
#define X_GLXvop_CopySubBufferMESA 5154 /* temporary */
static void
__glXCopySubBufferMESA(Display * dpy, GLXDrawable drawable,
int x, int y, int width, int height)
{
xGLXVendorPrivateReq *req;
struct glx_context *gc;
GLXContextTag tag;
CARD32 *drawable_ptr;
INT32 *x_ptr, *y_ptr, *w_ptr, *h_ptr;
CARD8 opcode;
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
if (pdraw != NULL) {
struct glx_screen *psc = pdraw->psc;
if (psc->driScreen->copySubBuffer != NULL) {
(*psc->driScreen->copySubBuffer) (pdraw, x, y, width, height, True);
}
 
return;
}
#endif
 
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return;
 
/*
** The calling thread may or may not have a current context. If it
** does, send the context tag so the server can do a flush.
*/
gc = __glXGetCurrentContext();
if ((gc != NULL) && (dpy == gc->currentDpy) &&
((drawable == gc->currentDrawable) ||
(drawable == gc->currentReadable))) {
tag = gc->currentContextTag;
}
else {
tag = 0;
}
 
LockDisplay(dpy);
GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32) * 4, req);
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivate;
req->vendorCode = X_GLXvop_CopySubBufferMESA;
req->contextTag = tag;
 
drawable_ptr = (CARD32 *) (req + 1);
x_ptr = (INT32 *) (drawable_ptr + 1);
y_ptr = (INT32 *) (drawable_ptr + 2);
w_ptr = (INT32 *) (drawable_ptr + 3);
h_ptr = (INT32 *) (drawable_ptr + 4);
 
*drawable_ptr = drawable;
*x_ptr = x;
*y_ptr = y;
*w_ptr = width;
*h_ptr = height;
 
UnlockDisplay(dpy);
SyncHandle();
}
 
/*@{*/
static void
__glXBindTexImageEXT(Display * dpy,
GLXDrawable drawable, int buffer, const int *attrib_list)
{
struct glx_context *gc = __glXGetCurrentContext();
 
if (gc == NULL || gc->vtable->bind_tex_image == NULL)
return;
 
gc->vtable->bind_tex_image(dpy, drawable, buffer, attrib_list);
}
 
static void
__glXReleaseTexImageEXT(Display * dpy, GLXDrawable drawable, int buffer)
{
struct glx_context *gc = __glXGetCurrentContext();
 
if (gc == NULL || gc->vtable->release_tex_image == NULL)
return;
 
gc->vtable->release_tex_image(dpy, drawable, buffer);
}
 
/*@}*/
 
#endif /* GLX_USE_APPLEGL */
 
/**
* \c strdup is actually not a standard ANSI C or POSIX routine.
* Irix will not define it if ANSI mode is in effect.
*
* \sa strdup
*/
_X_HIDDEN char *
__glXstrdup(const char *str)
{
char *copy;
copy = malloc(strlen(str) + 1);
if (!copy)
return NULL;
strcpy(copy, str);
return copy;
}
 
/*
** glXGetProcAddress support
*/
 
struct name_address_pair
{
const char *Name;
GLvoid *Address;
};
 
#define GLX_FUNCTION(f) { # f, (GLvoid *) f }
#define GLX_FUNCTION2(n,f) { # n, (GLvoid *) f }
 
static const struct name_address_pair GLX_functions[] = {
/*** GLX_VERSION_1_0 ***/
GLX_FUNCTION(glXChooseVisual),
GLX_FUNCTION(glXCopyContext),
GLX_FUNCTION(glXCreateContext),
GLX_FUNCTION(glXCreateGLXPixmap),
GLX_FUNCTION(glXDestroyContext),
GLX_FUNCTION(glXDestroyGLXPixmap),
GLX_FUNCTION(glXGetConfig),
GLX_FUNCTION(glXGetCurrentContext),
GLX_FUNCTION(glXGetCurrentDrawable),
GLX_FUNCTION(glXIsDirect),
GLX_FUNCTION(glXMakeCurrent),
GLX_FUNCTION(glXQueryExtension),
GLX_FUNCTION(glXQueryVersion),
GLX_FUNCTION(glXSwapBuffers),
GLX_FUNCTION(glXUseXFont),
GLX_FUNCTION(glXWaitGL),
GLX_FUNCTION(glXWaitX),
 
/*** GLX_VERSION_1_1 ***/
GLX_FUNCTION(glXGetClientString),
GLX_FUNCTION(glXQueryExtensionsString),
GLX_FUNCTION(glXQueryServerString),
 
/*** GLX_VERSION_1_2 ***/
GLX_FUNCTION(glXGetCurrentDisplay),
 
/*** GLX_VERSION_1_3 ***/
GLX_FUNCTION(glXChooseFBConfig),
GLX_FUNCTION(glXCreateNewContext),
GLX_FUNCTION(glXCreatePbuffer),
GLX_FUNCTION(glXCreatePixmap),
GLX_FUNCTION(glXCreateWindow),
GLX_FUNCTION(glXDestroyPbuffer),
GLX_FUNCTION(glXDestroyPixmap),
GLX_FUNCTION(glXDestroyWindow),
GLX_FUNCTION(glXGetCurrentReadDrawable),
GLX_FUNCTION(glXGetFBConfigAttrib),
GLX_FUNCTION(glXGetFBConfigs),
GLX_FUNCTION(glXGetSelectedEvent),
GLX_FUNCTION(glXGetVisualFromFBConfig),
GLX_FUNCTION(glXMakeContextCurrent),
GLX_FUNCTION(glXQueryContext),
GLX_FUNCTION(glXQueryDrawable),
GLX_FUNCTION(glXSelectEvent),
 
#ifndef GLX_USE_APPLEGL
/*** GLX_SGI_swap_control ***/
GLX_FUNCTION2(glXSwapIntervalSGI, __glXSwapIntervalSGI),
 
/*** GLX_SGI_video_sync ***/
GLX_FUNCTION2(glXGetVideoSyncSGI, __glXGetVideoSyncSGI),
GLX_FUNCTION2(glXWaitVideoSyncSGI, __glXWaitVideoSyncSGI),
 
/*** GLX_SGI_make_current_read ***/
GLX_FUNCTION2(glXMakeCurrentReadSGI, glXMakeContextCurrent),
GLX_FUNCTION2(glXGetCurrentReadDrawableSGI, glXGetCurrentReadDrawable),
 
/*** GLX_EXT_import_context ***/
GLX_FUNCTION(glXFreeContextEXT),
GLX_FUNCTION(glXGetContextIDEXT),
GLX_FUNCTION2(glXGetCurrentDisplayEXT, glXGetCurrentDisplay),
GLX_FUNCTION(glXImportContextEXT),
GLX_FUNCTION2(glXQueryContextInfoEXT, glXQueryContext),
#endif
 
/*** GLX_SGIX_fbconfig ***/
GLX_FUNCTION2(glXGetFBConfigAttribSGIX, glXGetFBConfigAttrib),
GLX_FUNCTION2(glXChooseFBConfigSGIX, glXChooseFBConfig),
GLX_FUNCTION(glXCreateGLXPixmapWithConfigSGIX),
GLX_FUNCTION(glXCreateContextWithConfigSGIX),
GLX_FUNCTION2(glXGetVisualFromFBConfigSGIX, glXGetVisualFromFBConfig),
GLX_FUNCTION(glXGetFBConfigFromVisualSGIX),
 
#ifndef GLX_USE_APPLEGL
/*** GLX_SGIX_pbuffer ***/
GLX_FUNCTION(glXCreateGLXPbufferSGIX),
GLX_FUNCTION(glXDestroyGLXPbufferSGIX),
GLX_FUNCTION(glXQueryGLXPbufferSGIX),
GLX_FUNCTION(glXSelectEventSGIX),
GLX_FUNCTION(glXGetSelectedEventSGIX),
 
/*** GLX_SGIX_swap_group ***/
GLX_FUNCTION2(glXJoinSwapGroupSGIX, __glXJoinSwapGroupSGIX),
 
/*** GLX_SGIX_swap_barrier ***/
GLX_FUNCTION2(glXBindSwapBarrierSGIX, __glXBindSwapBarrierSGIX),
GLX_FUNCTION2(glXQueryMaxSwapBarriersSGIX, __glXQueryMaxSwapBarriersSGIX),
 
/*** GLX_MESA_copy_sub_buffer ***/
GLX_FUNCTION2(glXCopySubBufferMESA, __glXCopySubBufferMESA),
 
/*** GLX_MESA_pixmap_colormap ***/
GLX_FUNCTION(glXCreateGLXPixmapMESA),
 
/*** GLX_MESA_release_buffers ***/
GLX_FUNCTION2(glXReleaseBuffersMESA, __glXReleaseBuffersMESA),
 
/*** GLX_MESA_swap_control ***/
GLX_FUNCTION2(glXSwapIntervalMESA, __glXSwapIntervalMESA),
GLX_FUNCTION2(glXGetSwapIntervalMESA, __glXGetSwapIntervalMESA),
#endif
 
/*** GLX_ARB_get_proc_address ***/
GLX_FUNCTION(glXGetProcAddressARB),
 
/*** GLX 1.4 ***/
GLX_FUNCTION2(glXGetProcAddress, glXGetProcAddressARB),
 
#ifndef GLX_USE_APPLEGL
/*** GLX_OML_sync_control ***/
GLX_FUNCTION2(glXWaitForSbcOML, __glXWaitForSbcOML),
GLX_FUNCTION2(glXWaitForMscOML, __glXWaitForMscOML),
GLX_FUNCTION2(glXSwapBuffersMscOML, __glXSwapBuffersMscOML),
GLX_FUNCTION2(glXGetMscRateOML, __glXGetMscRateOML),
GLX_FUNCTION2(glXGetSyncValuesOML, __glXGetSyncValuesOML),
 
/*** GLX_EXT_texture_from_pixmap ***/
GLX_FUNCTION2(glXBindTexImageEXT, __glXBindTexImageEXT),
GLX_FUNCTION2(glXReleaseTexImageEXT, __glXReleaseTexImageEXT),
#endif
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
/*** DRI configuration ***/
GLX_FUNCTION(glXGetScreenDriver),
GLX_FUNCTION(glXGetDriverConfig),
#endif
 
/*** GLX_ARB_create_context and GLX_ARB_create_context_profile ***/
GLX_FUNCTION(glXCreateContextAttribsARB),
 
{NULL, NULL} /* end of list */
};
 
static const GLvoid *
get_glx_proc_address(const char *funcName)
{
GLuint i;
 
/* try static functions */
for (i = 0; GLX_functions[i].Name; i++) {
if (strcmp(GLX_functions[i].Name, funcName) == 0)
return GLX_functions[i].Address;
}
 
return NULL;
}
 
/**
* Get the address of a named GL function. This is the pre-GLX 1.4 name for
* \c glXGetProcAddress.
*
* \param procName Name of a GL or GLX function.
* \returns A pointer to the named function
*
* \sa glXGetProcAddress
*/
_X_EXPORT void (*glXGetProcAddressARB(const GLubyte * procName)) (void)
{
typedef void (*gl_function) (void);
gl_function f;
 
 
/* Search the table of GLX and internal functions first. If that
* fails and the supplied name could be a valid core GL name, try
* searching the core GL function table. This check is done to prevent
* DRI based drivers from searching the core GL function table for
* internal API functions.
*/
f = (gl_function) get_glx_proc_address((const char *) procName);
if ((f == NULL) && (procName[0] == 'g') && (procName[1] == 'l')
&& (procName[2] != 'X')) {
#ifdef GLX_SHARED_GLAPI
f = (gl_function) __indirect_get_proc_address((const char *) procName);
#endif
if (!f)
f = (gl_function) _glapi_get_proc_address((const char *) procName);
if (!f) {
struct glx_context *gc = __glXGetCurrentContext();
if (gc != NULL && gc->vtable->get_proc_address != NULL)
f = gc->vtable->get_proc_address((const char *) procName);
}
}
return f;
}
 
/**
* Get the address of a named GL function. This is the GLX 1.4 name for
* \c glXGetProcAddressARB.
*
* \param procName Name of a GL or GLX function.
* \returns A pointer to the named function
*
* \sa glXGetProcAddressARB
*/
_X_EXPORT void (*glXGetProcAddress(const GLubyte * procName)) (void)
#if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED)
__attribute__ ((alias("glXGetProcAddressARB")));
#else
{
return glXGetProcAddressARB(procName);
}
#endif /* __GNUC__ */
 
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
/**
* Get the unadjusted system time (UST). Currently, the UST is measured in
* microseconds since Epoc. The actual resolution of the UST may vary from
* system to system, and the units may vary from release to release.
* Drivers should not call this function directly. They should instead use
* \c glXGetProcAddress to obtain a pointer to the function.
*
* \param ust Location to store the 64-bit UST
* \returns Zero on success or a negative errno value on failure.
*
* \sa glXGetProcAddress, PFNGLXGETUSTPROC
*
* \since Internal API version 20030317.
*/
_X_HIDDEN int
__glXGetUST(int64_t * ust)
{
struct timeval tv;
 
if (ust == NULL) {
return -EFAULT;
}
 
if (gettimeofday(&tv, NULL) == 0) {
ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
return 0;
}
else {
return -errno;
}
}
#endif /* GLX_DIRECT_RENDERING */
/contrib/sdk/sources/Mesa/src/glx/glxconfig.c
0,0 → 1,309
/*
* (C) Copyright IBM Corporation 2003
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* VA LINUX SYSTEM, IBM AND/OR THEIR 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.
*/
 
/**
* \file glxconfig.c
* Utility routines for working with \c struct glx_config structures. At
* some point most or all of these functions will be moved to the Mesa
* code base.
*
* \author Ian Romanick <idr@us.ibm.com>
*/
 
#include <GL/glx.h>
#include "GL/glxint.h"
#include <stdlib.h>
#include <string.h>
 
#include "glxconfig.h"
 
#define NUM_VISUAL_TYPES 6
 
/**
* Get data from a GLX config
*
* \param mode GL context mode whose data is to be returned.
* \param attribute Attribute of \c mode that is to be returned.
* \param value_return Location to store the data member of \c mode.
* \return If \c attribute is a valid attribute of \c mode, zero is
* returned. Otherwise \c GLX_BAD_ATTRIBUTE is returned.
*/
_X_HIDDEN int
glx_config_get(struct glx_config * mode, int attribute, int *value_return)
{
switch (attribute) {
case GLX_USE_GL:
*value_return = GL_TRUE;
return 0;
case GLX_BUFFER_SIZE:
*value_return = mode->rgbBits;
return 0;
case GLX_RGBA:
*value_return = mode->rgbMode;
return 0;
case GLX_RED_SIZE:
*value_return = mode->redBits;
return 0;
case GLX_GREEN_SIZE:
*value_return = mode->greenBits;
return 0;
case GLX_BLUE_SIZE:
*value_return = mode->blueBits;
return 0;
case GLX_ALPHA_SIZE:
*value_return = mode->alphaBits;
return 0;
case GLX_DOUBLEBUFFER:
*value_return = mode->doubleBufferMode;
return 0;
case GLX_STEREO:
*value_return = mode->stereoMode;
return 0;
case GLX_AUX_BUFFERS:
*value_return = mode->numAuxBuffers;
return 0;
case GLX_DEPTH_SIZE:
*value_return = mode->depthBits;
return 0;
case GLX_STENCIL_SIZE:
*value_return = mode->stencilBits;
return 0;
case GLX_ACCUM_RED_SIZE:
*value_return = mode->accumRedBits;
return 0;
case GLX_ACCUM_GREEN_SIZE:
*value_return = mode->accumGreenBits;
return 0;
case GLX_ACCUM_BLUE_SIZE:
*value_return = mode->accumBlueBits;
return 0;
case GLX_ACCUM_ALPHA_SIZE:
*value_return = mode->accumAlphaBits;
return 0;
case GLX_LEVEL:
*value_return = mode->level;
return 0;
#ifndef GLX_USE_APPLEGL /* This isn't supported by CGL. */
case GLX_TRANSPARENT_TYPE_EXT:
*value_return = mode->transparentPixel;
return 0;
#endif
case GLX_TRANSPARENT_RED_VALUE:
*value_return = mode->transparentRed;
return 0;
case GLX_TRANSPARENT_GREEN_VALUE:
*value_return = mode->transparentGreen;
return 0;
case GLX_TRANSPARENT_BLUE_VALUE:
*value_return = mode->transparentBlue;
return 0;
case GLX_TRANSPARENT_ALPHA_VALUE:
*value_return = mode->transparentAlpha;
return 0;
case GLX_TRANSPARENT_INDEX_VALUE:
*value_return = mode->transparentIndex;
return 0;
case GLX_X_VISUAL_TYPE:
*value_return = mode->visualType;
return 0;
case GLX_CONFIG_CAVEAT:
*value_return = mode->visualRating;
return 0;
case GLX_VISUAL_ID:
*value_return = mode->visualID;
return 0;
case GLX_DRAWABLE_TYPE:
*value_return = mode->drawableType;
return 0;
case GLX_RENDER_TYPE:
*value_return = mode->renderType;
return 0;
case GLX_X_RENDERABLE:
*value_return = mode->xRenderable;
return 0;
case GLX_FBCONFIG_ID:
*value_return = mode->fbconfigID;
return 0;
case GLX_MAX_PBUFFER_WIDTH:
*value_return = mode->maxPbufferWidth;
return 0;
case GLX_MAX_PBUFFER_HEIGHT:
*value_return = mode->maxPbufferHeight;
return 0;
case GLX_MAX_PBUFFER_PIXELS:
*value_return = mode->maxPbufferPixels;
return 0;
#ifndef GLX_USE_APPLEGL /* These aren't supported by CGL. */
case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
*value_return = mode->optimalPbufferWidth;
return 0;
case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
*value_return = mode->optimalPbufferHeight;
return 0;
case GLX_SWAP_METHOD_OML:
*value_return = mode->swapMethod;
return 0;
#endif
case GLX_SAMPLE_BUFFERS_SGIS:
*value_return = mode->sampleBuffers;
return 0;
case GLX_SAMPLES_SGIS:
*value_return = mode->samples;
return 0;
case GLX_BIND_TO_TEXTURE_RGB_EXT:
*value_return = mode->bindToTextureRgb;
return 0;
case GLX_BIND_TO_TEXTURE_RGBA_EXT:
*value_return = mode->bindToTextureRgba;
return 0;
case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
*value_return = mode->bindToMipmapTexture == GL_TRUE ? GL_TRUE :
GL_FALSE;
return 0;
case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
*value_return = mode->bindToTextureTargets;
return 0;
case GLX_Y_INVERTED_EXT:
*value_return = mode->yInverted;
return 0;
 
case GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT:
*value_return = mode->sRGBCapable;
return 0;
 
/* Applications are NOT allowed to query GLX_VISUAL_SELECT_GROUP_SGIX.
* It is ONLY for communication between the GLX client and the GLX
* server.
*/
case GLX_VISUAL_SELECT_GROUP_SGIX:
default:
return GLX_BAD_ATTRIBUTE;
}
}
 
 
/**
* Allocate a linked list of \c struct glx_config structures. The fields of
* each structure will be initialized to "reasonable" default values. In
* most cases this is the default value defined by table 3.4 of the GLX
* 1.3 specification. This means that most values are either initialized to
* zero or \c GLX_DONT_CARE (which is -1). As support for additional
* extensions is added, the new values will be initialized to appropriate
* values from the extension specification.
*
* \param count Number of structures to allocate.
* \param minimum_size Minimum size of a structure to allocate. This allows
* for differences in the version of the
* \c struct glx_config stucture used in libGL and in a
* DRI-based driver.
* \returns A pointer to the first element in a linked list of \c count
* stuctures on success, or \c NULL on failure.
*/
_X_HIDDEN struct glx_config *
glx_config_create_list(unsigned count)
{
const size_t size = sizeof(struct glx_config);
struct glx_config *base = NULL;
struct glx_config **next;
unsigned i;
 
next = &base;
for (i = 0; i < count; i++) {
*next = malloc(size);
if (*next == NULL) {
glx_config_destroy_list(base);
base = NULL;
break;
}
 
(void) memset(*next, 0, size);
(*next)->visualID = GLX_DONT_CARE;
(*next)->visualType = GLX_DONT_CARE;
(*next)->visualRating = GLX_NONE;
(*next)->transparentPixel = GLX_NONE;
(*next)->transparentRed = GLX_DONT_CARE;
(*next)->transparentGreen = GLX_DONT_CARE;
(*next)->transparentBlue = GLX_DONT_CARE;
(*next)->transparentAlpha = GLX_DONT_CARE;
(*next)->transparentIndex = GLX_DONT_CARE;
(*next)->xRenderable = GLX_DONT_CARE;
(*next)->fbconfigID = GLX_DONT_CARE;
(*next)->swapMethod = GLX_SWAP_UNDEFINED_OML;
(*next)->bindToTextureRgb = GLX_DONT_CARE;
(*next)->bindToTextureRgba = GLX_DONT_CARE;
(*next)->bindToMipmapTexture = GLX_DONT_CARE;
(*next)->bindToTextureTargets = GLX_DONT_CARE;
(*next)->yInverted = GLX_DONT_CARE;
(*next)->sRGBCapable = GLX_DONT_CARE;
 
next = &((*next)->next);
}
 
return base;
}
 
_X_HIDDEN void
glx_config_destroy_list(struct glx_config *configs)
{
while (configs != NULL) {
struct glx_config *const next = configs->next;
 
free(configs);
configs = next;
}
}
 
 
/**
* Find a context mode matching a Visual ID.
*
* \param modes List list of context-mode structures to be searched.
* \param vid Visual ID to be found.
* \returns A pointer to a context-mode in \c modes if \c vid was found in
* the list, or \c NULL if it was not.
*/
 
_X_HIDDEN struct glx_config *
glx_config_find_visual(struct glx_config *configs, int vid)
{
struct glx_config *c;
 
for (c = configs; c != NULL; c = c->next)
if (c->visualID == vid)
return c;
 
return NULL;
}
 
_X_HIDDEN struct glx_config *
glx_config_find_fbconfig(struct glx_config *configs, int fbid)
{
struct glx_config *c;
 
for (c = configs; c != NULL; c = c->next)
if (c->fbconfigID == fbid)
return c;
 
return NULL;
}
/contrib/sdk/sources/Mesa/src/glx/glxconfig.h
0,0 → 1,136
/*
* (C) Copyright IBM Corporation 2003
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* VA LINUX SYSTEM, IBM AND/OR THEIR 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.
*/
 
/**
* \file glcontextmodes.h
* \author Ian Romanick <idr@us.ibm.com>
*/
 
#ifndef GLCONTEXTMODES_H
#define GLCONTEXTMODES_H
 
struct glx_config {
struct glx_config * next;
 
GLboolean rgbMode;
GLboolean floatMode;
GLboolean colorIndexMode;
GLuint doubleBufferMode;
GLuint stereoMode;
 
GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */
GLuint redMask, greenMask, blueMask, alphaMask;
GLint rgbBits; /* total bits for rgb */
GLint indexBits; /* total bits for colorindex */
 
GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
GLint depthBits;
GLint stencilBits;
 
GLint numAuxBuffers;
 
GLint level;
 
GLint pixmapMode;
 
/* GLX */
GLint visualID;
GLint visualType; /**< One of the GLX X visual types. (i.e.,
* \c GLX_TRUE_COLOR, etc.)
*/
 
/* EXT_visual_rating / GLX 1.2 */
GLint visualRating;
 
/* EXT_visual_info / GLX 1.2 */
GLint transparentPixel;
/* colors are floats scaled to ints */
GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha;
GLint transparentIndex;
 
/* ARB_multisample / SGIS_multisample */
GLint sampleBuffers;
GLint samples;
 
/* SGIX_fbconfig / GLX 1.3 */
GLint drawableType;
GLint renderType;
GLint xRenderable;
GLint fbconfigID;
 
/* SGIX_pbuffer / GLX 1.3 */
GLint maxPbufferWidth;
GLint maxPbufferHeight;
GLint maxPbufferPixels;
GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */
GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */
 
/* SGIX_visual_select_group */
GLint visualSelectGroup;
 
/* OML_swap_method */
GLint swapMethod;
 
GLint screen;
 
/* EXT_texture_from_pixmap */
GLint bindToTextureRgb;
GLint bindToTextureRgba;
GLint bindToMipmapTexture;
GLint bindToTextureTargets;
GLint yInverted;
 
/* EXT_framebuffer_sRGB */
GLint sRGBCapable;
};
 
#define __GLX_MIN_CONFIG_PROPS 18
#define __GLX_MAX_CONFIG_PROPS 500
#define __GLX_EXT_CONFIG_PROPS 10
 
/*
** Since we send all non-core visual properties as token, value pairs,
** we require 2 words across the wire. In order to maintain backwards
** compatibility, we need to send the total number of words that the
** VisualConfigs are sent back in so old libraries can simply "ignore"
** the new properties.
*/
#define __GLX_TOTAL_CONFIG \
(__GLX_MIN_CONFIG_PROPS + 2 * __GLX_EXT_CONFIG_PROPS)
 
extern GLint _gl_convert_from_x_visual_type(int visualType);
 
extern int
glx_config_get(struct glx_config * mode, int attribute, int *value_return);
extern struct glx_config *
glx_config_create_list(unsigned count);
extern void
glx_config_destroy_list(struct glx_config *configs);
extern struct glx_config *
glx_config_find_visual(struct glx_config *configs, int vid);
extern struct glx_config *
glx_config_find_fbconfig(struct glx_config *configs, int fbid);
 
#endif /* GLCONTEXTMODES_H */
 
/contrib/sdk/sources/Mesa/src/glx/glxcurrent.c
0,0 → 1,314
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
/**
* \file glxcurrent.c
* Client-side GLX interface for current context management.
*/
 
#ifdef HAVE_PTHREAD
#include <pthread.h>
#endif
 
#include "glxclient.h"
#ifdef GLX_USE_APPLEGL
#include <stdlib.h>
 
#include "apple_glx.h"
#include "apple_glx_context.h"
#endif
 
#include "glapi.h"
 
/*
** We setup some dummy structures here so that the API can be used
** even if no context is current.
*/
 
static GLubyte dummyBuffer[__GLX_BUFFER_LIMIT_SIZE];
static struct glx_context_vtable dummyVtable;
/*
** Dummy context used by small commands when there is no current context.
** All the
** gl and glx entry points are designed to operate as nop's when using
** the dummy context structure.
*/
struct glx_context dummyContext = {
&dummyBuffer[0],
&dummyBuffer[0],
&dummyBuffer[0],
&dummyBuffer[__GLX_BUFFER_LIMIT_SIZE],
sizeof(dummyBuffer),
&dummyVtable
};
 
/*
* Current context management and locking
*/
 
#if defined( HAVE_PTHREAD )
 
_X_HIDDEN pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER;
 
# if defined( GLX_USE_TLS )
 
/**
* Per-thread GLX context pointer.
*
* \c __glXSetCurrentContext is written is such a way that this pointer can
* \b never be \c NULL. This is important! Because of this
* \c __glXGetCurrentContext can be implemented as trivial macro.
*/
__thread void *__glX_tls_Context __attribute__ ((tls_model("initial-exec")))
= &dummyContext;
 
_X_HIDDEN void
__glXSetCurrentContext(struct glx_context * c)
{
__glX_tls_Context = (c != NULL) ? c : &dummyContext;
}
 
# else
 
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
 
/**
* Per-thread data key.
*
* Once \c init_thread_data has been called, the per-thread data key will
* take a value of \c NULL. As each new thread is created the default
* value, in that thread, will be \c NULL.
*/
static pthread_key_t ContextTSD;
 
/**
* Initialize the per-thread data key.
*
* This function is called \b exactly once per-process (not per-thread!) to
* initialize the per-thread data key. This is ideally done using the
* \c pthread_once mechanism.
*/
static void
init_thread_data(void)
{
if (pthread_key_create(&ContextTSD, NULL) != 0) {
perror("pthread_key_create");
exit(-1);
}
}
 
_X_HIDDEN void
__glXSetCurrentContext(struct glx_context * c)
{
pthread_once(&once_control, init_thread_data);
pthread_setspecific(ContextTSD, c);
}
 
_X_HIDDEN struct glx_context *
__glXGetCurrentContext(void)
{
void *v;
 
pthread_once(&once_control, init_thread_data);
 
v = pthread_getspecific(ContextTSD);
return (v == NULL) ? &dummyContext : (struct glx_context *) v;
}
 
# endif /* defined( GLX_USE_TLS ) */
 
#elif defined( THREADS )
 
#error Unknown threading method specified.
 
#else
 
/* not thread safe */
_X_HIDDEN struct glx_context *__glXcurrentContext = &dummyContext;
 
#endif
 
 
_X_HIDDEN void
__glXSetCurrentContextNull(void)
{
__glXSetCurrentContext(&dummyContext);
#if defined(GLX_DIRECT_RENDERING)
_glapi_set_dispatch(NULL); /* no-op functions */
_glapi_set_context(NULL);
#endif
}
 
_X_EXPORT GLXContext
glXGetCurrentContext(void)
{
struct glx_context *cx = __glXGetCurrentContext();
 
if (cx == &dummyContext) {
return NULL;
}
else {
return (GLXContext) cx;
}
}
 
_X_EXPORT GLXDrawable
glXGetCurrentDrawable(void)
{
struct glx_context *gc = __glXGetCurrentContext();
return gc->currentDrawable;
}
 
static void
__glXGenerateError(Display * dpy, XID resource,
BYTE errorCode, CARD16 minorCode)
{
xError error;
 
error.errorCode = errorCode;
error.resourceID = resource;
error.sequenceNumber = dpy->request;
error.type = X_Error;
error.majorCode = __glXSetupForCommand(dpy);
error.minorCode = minorCode;
_XError(dpy, &error);
}
 
/**
* Make a particular context current.
*
* \note This is in this file so that it can access dummyContext.
*/
static Bool
MakeContextCurrent(Display * dpy, GLXDrawable draw,
GLXDrawable read, GLXContext gc_user)
{
struct glx_context *gc = (struct glx_context *) gc_user;
struct glx_context *oldGC = __glXGetCurrentContext();
 
/* XXX: If this is left out, then libGL ends up not having this
* symbol, and drivers using it fail to load. Compare the
* implementation of this symbol to _glapi_noop_enable_warnings(),
* though, which gets into the library despite no callers, the same
* prototypes, and the same compile flags to the files containing
* them. Moving the definition to glapi_nop.c gets it into the
* library, though.
*/
(void)_glthread_GetID();
 
/* Make sure that the new context has a nonzero ID. In the request,
* a zero context ID is used only to mean that we bind to no current
* context.
*/
if ((gc != NULL) && (gc->xid == None)) {
return GL_FALSE;
}
 
if (gc == NULL && (draw != None || read != None)) {
__glXGenerateError(dpy, (draw != None) ? draw : read,
BadMatch, X_GLXMakeContextCurrent);
return False;
}
if (gc != NULL && (draw == None || read == None)) {
__glXGenerateError(dpy, None, BadMatch, X_GLXMakeContextCurrent);
return False;
}
 
_glapi_check_multithread();
 
__glXLock();
if (oldGC == gc &&
gc->currentDrawable == draw && gc->currentReadable == read) {
__glXUnlock();
return True;
}
 
if (oldGC != &dummyContext) {
if (--oldGC->thread_refcount == 0) {
oldGC->vtable->unbind(oldGC, gc);
oldGC->currentDpy = 0;
}
}
 
if (gc) {
/* Attempt to bind the context. We do this before mucking with
* gc and __glXSetCurrentContext to properly handle our state in
* case of an error.
*
* If an error occurs, set the Null context since we've already
* blown away our old context. The caller is responsible for
* figuring out how to handle setting a valid context.
*/
if (gc->vtable->bind(gc, oldGC, draw, read) != Success) {
__glXSetCurrentContextNull();
__glXUnlock();
__glXGenerateError(dpy, None, GLXBadContext, X_GLXMakeContextCurrent);
return GL_FALSE;
}
 
if (gc->thread_refcount == 0) {
gc->currentDpy = dpy;
gc->currentDrawable = draw;
gc->currentReadable = read;
}
gc->thread_refcount++;
__glXSetCurrentContext(gc);
} else {
__glXSetCurrentContextNull();
}
 
if (oldGC->thread_refcount == 0 && oldGC != &dummyContext && oldGC->xid == None) {
/* We are switching away from a context that was
* previously destroyed, so we need to free the memory
* for the old handle. */
oldGC->vtable->destroy(oldGC);
}
 
__glXUnlock();
 
return GL_TRUE;
}
 
 
_X_EXPORT Bool
glXMakeCurrent(Display * dpy, GLXDrawable draw, GLXContext gc)
{
return MakeContextCurrent(dpy, draw, draw, gc);
}
 
_X_EXPORT
GLX_ALIAS(Bool, glXMakeCurrentReadSGI,
(Display * dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
(dpy, d, r, ctx), MakeContextCurrent)
 
_X_EXPORT
GLX_ALIAS(Bool, glXMakeContextCurrent,
(Display * dpy, GLXDrawable d, GLXDrawable r,
GLXContext ctx), (dpy, d, r, ctx), MakeContextCurrent)
/contrib/sdk/sources/Mesa/src/glx/glxext.c
0,0 → 1,1076
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
/**
* \file glxext.c
* GLX protocol interface boot-strap code.
*
* Direct rendering support added by Precision Insight, Inc.
*
* \author Kevin E. Martin <kevin@precisioninsight.com>
*/
 
#include <assert.h>
#include "glxclient.h"
#include <X11/extensions/Xext.h>
#include <X11/extensions/extutil.h>
#ifdef GLX_USE_APPLEGL
#include "apple_glx.h"
#include "apple_visual.h"
#endif
#include "glxextensions.h"
 
#include <X11/Xlib-xcb.h>
#include <xcb/xcb.h>
#include <xcb/glx.h>
 
 
#ifdef DEBUG
void __glXDumpDrawBuffer(struct glx_context * ctx);
#endif
 
/*
** You can set this cell to 1 to force the gl drawing stuff to be
** one command per packet
*/
_X_HIDDEN int __glXDebug = 0;
 
/* Extension required boiler plate */
 
static const char __glXExtensionName[] = GLX_EXTENSION_NAME;
static struct glx_display *glx_displays;
 
static /* const */ char *error_list[] = {
"GLXBadContext",
"GLXBadContextState",
"GLXBadDrawable",
"GLXBadPixmap",
"GLXBadContextTag",
"GLXBadCurrentWindow",
"GLXBadRenderRequest",
"GLXBadLargeRequest",
"GLXUnsupportedPrivateRequest",
"GLXBadFBConfig",
"GLXBadPbuffer",
"GLXBadCurrentDrawable",
"GLXBadWindow",
"GLXBadProfileARB",
};
 
#ifdef GLX_USE_APPLEGL
static char *__glXErrorString(Display *dpy, int code, XExtCodes *codes,
char *buf, int n);
#endif
 
static
XEXT_GENERATE_ERROR_STRING(__glXErrorString, __glXExtensionName,
__GLX_NUMBER_ERRORS, error_list)
 
/*
* GLX events are a bit funky. We don't stuff the X event code into
* our user exposed (via XNextEvent) structure. Instead we use the GLX
* private event code namespace (and hope it doesn't conflict). Clients
* have to know that bit 15 in the event type field means they're getting
* a GLX event, and then handle the various sub-event types there, rather
* than simply checking the event code and handling it directly.
*/
 
static Bool
__glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire)
{
struct glx_display *glx_dpy = __glXInitialize(dpy);
 
if (glx_dpy == NULL)
return False;
 
switch ((wire->u.u.type & 0x7f) - glx_dpy->codes->first_event) {
case GLX_PbufferClobber:
{
GLXPbufferClobberEvent *aevent = (GLXPbufferClobberEvent *)event;
xGLXPbufferClobberEvent *awire = (xGLXPbufferClobberEvent *)wire;
aevent->event_type = awire->type;
aevent->serial = awire->sequenceNumber;
aevent->event_type = awire->event_type;
aevent->draw_type = awire->draw_type;
aevent->drawable = awire->drawable;
aevent->buffer_mask = awire->buffer_mask;
aevent->aux_buffer = awire->aux_buffer;
aevent->x = awire->x;
aevent->y = awire->y;
aevent->width = awire->width;
aevent->height = awire->height;
aevent->count = awire->count;
return True;
}
case GLX_BufferSwapComplete:
{
GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
xGLXBufferSwapComplete2 *awire = (xGLXBufferSwapComplete2 *)wire;
struct glx_drawable *glxDraw = GetGLXDrawable(dpy, awire->drawable);
aevent->event_type = awire->event_type;
aevent->drawable = awire->drawable;
aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
 
if (!glxDraw)
return False;
 
if (awire->sbc < glxDraw->lastEventSbc)
glxDraw->eventSbcWrap += 0x100000000;
glxDraw->lastEventSbc = awire->sbc;
aevent->sbc = awire->sbc + glxDraw->eventSbcWrap;
return True;
}
default:
/* client doesn't support server event */
break;
}
 
return False;
}
 
/* We don't actually support this. It doesn't make sense for clients to
* send each other GLX events.
*/
static Status
__glXEventToWire(Display *dpy, XEvent *event, xEvent *wire)
{
struct glx_display *glx_dpy = __glXInitialize(dpy);
 
if (glx_dpy == NULL)
return False;
 
switch (event->type) {
case GLX_DAMAGED:
break;
case GLX_SAVED:
break;
case GLX_EXCHANGE_COMPLETE_INTEL:
break;
case GLX_COPY_COMPLETE_INTEL:
break;
case GLX_FLIP_COMPLETE_INTEL:
break;
default:
/* client doesn't support server event */
break;
}
 
return Success;
}
 
/************************************************************************/
/*
** Free the per screen configs data as well as the array of
** __glXScreenConfigs.
*/
static void
FreeScreenConfigs(struct glx_display * priv)
{
struct glx_screen *psc;
GLint i, screens;
 
/* Free screen configuration information */
screens = ScreenCount(priv->dpy);
for (i = 0; i < screens; i++) {
psc = priv->screens[i];
glx_screen_cleanup(psc);
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (psc->driScreen) {
psc->driScreen->destroyScreen(psc);
} else {
free(psc);
}
#else
free(psc);
#endif
}
free((char *) priv->screens);
priv->screens = NULL;
}
 
static void
glx_display_free(struct glx_display *priv)
{
struct glx_context *gc;
 
gc = __glXGetCurrentContext();
if (priv->dpy == gc->currentDpy) {
gc->vtable->destroy(gc);
__glXSetCurrentContextNull();
}
 
FreeScreenConfigs(priv);
free((char *) priv->serverGLXvendor);
free((char *) priv->serverGLXversion);
 
__glxHashDestroy(priv->glXDrawHash);
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
__glxHashDestroy(priv->drawHash);
 
/* Free the direct rendering per display data */
if (priv->driswDisplay)
(*priv->driswDisplay->destroyDisplay) (priv->driswDisplay);
priv->driswDisplay = NULL;
 
if (priv->driDisplay)
(*priv->driDisplay->destroyDisplay) (priv->driDisplay);
priv->driDisplay = NULL;
 
if (priv->dri2Display)
(*priv->dri2Display->destroyDisplay) (priv->dri2Display);
priv->dri2Display = NULL;
#endif
 
free((char *) priv);
}
 
static int
__glXCloseDisplay(Display * dpy, XExtCodes * codes)
{
struct glx_display *priv, **prev;
 
_XLockMutex(_Xglobal_lock);
prev = &glx_displays;
for (priv = glx_displays; priv; prev = &priv->next, priv = priv->next) {
if (priv->dpy == dpy) {
*prev = priv->next;
break;
}
}
_XUnlockMutex(_Xglobal_lock);
 
glx_display_free(priv);
 
return 1;
}
 
/*
** Query the version of the GLX extension. This procedure works even if
** the client extension is not completely set up.
*/
static Bool
QueryVersion(Display * dpy, int opcode, int *major, int *minor)
{
xcb_connection_t *c = XGetXCBConnection(dpy);
xcb_glx_query_version_reply_t *reply = xcb_glx_query_version_reply(c,
xcb_glx_query_version
(c,
GLX_MAJOR_VERSION,
GLX_MINOR_VERSION),
NULL);
 
if (!reply)
return GL_FALSE;
 
if (reply->major_version != GLX_MAJOR_VERSION) {
free(reply);
return GL_FALSE;
}
*major = reply->major_version;
*minor = min(reply->minor_version, GLX_MINOR_VERSION);
free(reply);
return GL_TRUE;
}
 
/*
* We don't want to enable this GLX_OML_swap_method in glxext.h,
* because we can't support it. The X server writes it out though,
* so we should handle it somehow, to avoid false warnings.
*/
enum {
IGNORE_GLX_SWAP_METHOD_OML = 0x8060
};
 
 
static GLint
convert_from_x_visual_type(int visualType)
{
static const int glx_visual_types[] = {
GLX_STATIC_GRAY, GLX_GRAY_SCALE,
GLX_STATIC_COLOR, GLX_PSEUDO_COLOR,
GLX_TRUE_COLOR, GLX_DIRECT_COLOR
};
 
if (visualType < ARRAY_SIZE(glx_visual_types))
return glx_visual_types[visualType];
 
return GLX_NONE;
}
 
/*
* getVisualConfigs uses the !tagged_only path.
* getFBConfigs uses the tagged_only path.
*/
_X_HIDDEN void
__glXInitializeVisualConfigFromTags(struct glx_config * config, int count,
const INT32 * bp, Bool tagged_only,
Bool fbconfig_style_tags)
{
int i;
GLint renderType = 0;
 
if (!tagged_only) {
/* Copy in the first set of properties */
config->visualID = *bp++;
 
config->visualType = convert_from_x_visual_type(*bp++);
 
config->rgbMode = *bp++;
 
config->redBits = *bp++;
config->greenBits = *bp++;
config->blueBits = *bp++;
config->alphaBits = *bp++;
config->accumRedBits = *bp++;
config->accumGreenBits = *bp++;
config->accumBlueBits = *bp++;
config->accumAlphaBits = *bp++;
 
config->doubleBufferMode = *bp++;
config->stereoMode = *bp++;
 
config->rgbBits = *bp++;
config->depthBits = *bp++;
config->stencilBits = *bp++;
config->numAuxBuffers = *bp++;
config->level = *bp++;
 
#ifdef GLX_USE_APPLEGL
/* AppleSGLX supports pixmap and pbuffers with all config. */
config->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
/* Unfortunately this can create an ABI compatibility problem. */
count -= 18;
#else
count -= __GLX_MIN_CONFIG_PROPS;
#endif
}
 
config->sRGBCapable = GL_FALSE;
 
/*
** Additional properties may be in a list at the end
** of the reply. They are in pairs of property type
** and property value.
*/
 
#define FETCH_OR_SET(tag) \
config-> tag = ( fbconfig_style_tags ) ? *bp++ : 1
 
for (i = 0; i < count; i += 2) {
long int tag = *bp++;
switch (tag) {
case GLX_RGBA:
FETCH_OR_SET(rgbMode);
break;
case GLX_BUFFER_SIZE:
config->rgbBits = *bp++;
break;
case GLX_LEVEL:
config->level = *bp++;
break;
case GLX_DOUBLEBUFFER:
FETCH_OR_SET(doubleBufferMode);
break;
case GLX_STEREO:
FETCH_OR_SET(stereoMode);
break;
case GLX_AUX_BUFFERS:
config->numAuxBuffers = *bp++;
break;
case GLX_RED_SIZE:
config->redBits = *bp++;
break;
case GLX_GREEN_SIZE:
config->greenBits = *bp++;
break;
case GLX_BLUE_SIZE:
config->blueBits = *bp++;
break;
case GLX_ALPHA_SIZE:
config->alphaBits = *bp++;
break;
case GLX_DEPTH_SIZE:
config->depthBits = *bp++;
break;
case GLX_STENCIL_SIZE:
config->stencilBits = *bp++;
break;
case GLX_ACCUM_RED_SIZE:
config->accumRedBits = *bp++;
break;
case GLX_ACCUM_GREEN_SIZE:
config->accumGreenBits = *bp++;
break;
case GLX_ACCUM_BLUE_SIZE:
config->accumBlueBits = *bp++;
break;
case GLX_ACCUM_ALPHA_SIZE:
config->accumAlphaBits = *bp++;
break;
case GLX_VISUAL_CAVEAT_EXT:
config->visualRating = *bp++;
break;
case GLX_X_VISUAL_TYPE:
config->visualType = *bp++;
break;
case GLX_TRANSPARENT_TYPE:
config->transparentPixel = *bp++;
break;
case GLX_TRANSPARENT_INDEX_VALUE:
config->transparentIndex = *bp++;
break;
case GLX_TRANSPARENT_RED_VALUE:
config->transparentRed = *bp++;
break;
case GLX_TRANSPARENT_GREEN_VALUE:
config->transparentGreen = *bp++;
break;
case GLX_TRANSPARENT_BLUE_VALUE:
config->transparentBlue = *bp++;
break;
case GLX_TRANSPARENT_ALPHA_VALUE:
config->transparentAlpha = *bp++;
break;
case GLX_VISUAL_ID:
config->visualID = *bp++;
break;
case GLX_DRAWABLE_TYPE:
config->drawableType = *bp++;
#ifdef GLX_USE_APPLEGL
/* AppleSGLX supports pixmap and pbuffers with all config. */
config->drawableType |= GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
#endif
break;
case GLX_RENDER_TYPE: /* fbconfig render type bits */
renderType = *bp++;
break;
case GLX_X_RENDERABLE:
config->xRenderable = *bp++;
break;
case GLX_FBCONFIG_ID:
config->fbconfigID = *bp++;
break;
case GLX_MAX_PBUFFER_WIDTH:
config->maxPbufferWidth = *bp++;
break;
case GLX_MAX_PBUFFER_HEIGHT:
config->maxPbufferHeight = *bp++;
break;
case GLX_MAX_PBUFFER_PIXELS:
config->maxPbufferPixels = *bp++;
break;
#ifndef GLX_USE_APPLEGL
case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
config->optimalPbufferWidth = *bp++;
break;
case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
config->optimalPbufferHeight = *bp++;
break;
case GLX_VISUAL_SELECT_GROUP_SGIX:
config->visualSelectGroup = *bp++;
break;
case GLX_SWAP_METHOD_OML:
config->swapMethod = *bp++;
break;
#endif
case GLX_SAMPLE_BUFFERS_SGIS:
config->sampleBuffers = *bp++;
break;
case GLX_SAMPLES_SGIS:
config->samples = *bp++;
break;
#ifdef GLX_USE_APPLEGL
case IGNORE_GLX_SWAP_METHOD_OML:
/* We ignore this tag. See the comment above this function. */
++bp;
break;
#else
case GLX_BIND_TO_TEXTURE_RGB_EXT:
config->bindToTextureRgb = *bp++;
break;
case GLX_BIND_TO_TEXTURE_RGBA_EXT:
config->bindToTextureRgba = *bp++;
break;
case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
config->bindToMipmapTexture = *bp++;
break;
case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
config->bindToTextureTargets = *bp++;
break;
case GLX_Y_INVERTED_EXT:
config->yInverted = *bp++;
break;
#endif
case GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT:
config->sRGBCapable = *bp++;
break;
 
case GLX_USE_GL:
if (fbconfig_style_tags)
bp++;
break;
case None:
i = count;
break;
default:
if(getenv("LIBGL_DIAGNOSTIC")) {
long int tagvalue = *bp++;
fprintf(stderr, "WARNING: unknown GLX tag from server: "
"tag 0x%lx value 0x%lx\n", tag, tagvalue);
} else {
/* Ignore the unrecognized tag's value */
bp++;
}
break;
}
}
 
if (renderType != 0 && renderType != GLX_DONT_CARE) {
config->renderType = renderType;
config->floatMode = (renderType &
(GLX_RGBA_FLOAT_BIT_ARB|GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT)) != 0;
} else {
/* If there wasn't GLX_RENDER_TYPE property, set it based on
* config->rgbMode. The only way to communicate that the config is
* floating-point is via GLX_RENDER_TYPE, so this cannot be a float
* config.
*/
config->renderType =
(config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
}
 
/* The GLX_ARB_fbconfig_float spec says:
*
* "Note that floating point rendering is only supported for
* GLXPbuffer drawables."
*/
if (config->floatMode)
config->drawableType &= ~(GLX_WINDOW_BIT|GLX_PIXMAP_BIT);
}
 
static struct glx_config *
createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
int screen, GLboolean tagged_only)
{
INT32 buf[__GLX_TOTAL_CONFIG], *props;
unsigned prop_size;
struct glx_config *modes, *m;
int i;
 
if (nprops == 0)
return NULL;
 
/* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */
 
/* Check number of properties */
if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS)
return NULL;
 
/* Allocate memory for our config structure */
modes = glx_config_create_list(nvisuals);
if (!modes)
return NULL;
 
prop_size = nprops * __GLX_SIZE_INT32;
if (prop_size <= sizeof(buf))
props = buf;
else
props = malloc(prop_size);
 
/* Read each config structure and convert it into our format */
m = modes;
for (i = 0; i < nvisuals; i++) {
_XRead(dpy, (char *) props, prop_size);
#ifdef GLX_USE_APPLEGL
/* Older X servers don't send this so we default it here. */
m->drawableType = GLX_WINDOW_BIT;
#else
/*
* The XQuartz 2.3.2.1 X server doesn't set this properly, so
* set the proper bits here.
* AppleSGLX supports windows, pixmaps, and pbuffers with all config.
*/
m->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
#endif
__glXInitializeVisualConfigFromTags(m, nprops, props,
tagged_only, GL_TRUE);
m->screen = screen;
m = m->next;
}
 
if (props != buf)
free(props);
 
return modes;
}
 
static GLboolean
getVisualConfigs(struct glx_screen *psc,
struct glx_display *priv, int screen)
{
xGLXGetVisualConfigsReq *req;
xGLXGetVisualConfigsReply reply;
Display *dpy = priv->dpy;
 
LockDisplay(dpy);
 
psc->visuals = NULL;
GetReq(GLXGetVisualConfigs, req);
req->reqType = priv->majorOpcode;
req->glxCode = X_GLXGetVisualConfigs;
req->screen = screen;
 
if (!_XReply(dpy, (xReply *) & reply, 0, False))
goto out;
 
psc->visuals = createConfigsFromProperties(dpy,
reply.numVisuals,
reply.numProps,
screen, GL_FALSE);
 
out:
UnlockDisplay(dpy);
return psc->visuals != NULL;
}
 
static GLboolean
getFBConfigs(struct glx_screen *psc, struct glx_display *priv, int screen)
{
xGLXGetFBConfigsReq *fb_req;
xGLXGetFBConfigsSGIXReq *sgi_req;
xGLXVendorPrivateWithReplyReq *vpreq;
xGLXGetFBConfigsReply reply;
Display *dpy = priv->dpy;
 
psc->serverGLXexts =
__glXQueryServerString(dpy, priv->majorOpcode, screen, GLX_EXTENSIONS);
 
LockDisplay(dpy);
 
psc->configs = NULL;
if (atof(priv->serverGLXversion) >= 1.3) {
GetReq(GLXGetFBConfigs, fb_req);
fb_req->reqType = priv->majorOpcode;
fb_req->glxCode = X_GLXGetFBConfigs;
fb_req->screen = screen;
}
else if (strstr(psc->serverGLXexts, "GLX_SGIX_fbconfig") != NULL) {
GetReqExtra(GLXVendorPrivateWithReply,
sz_xGLXGetFBConfigsSGIXReq -
sz_xGLXVendorPrivateWithReplyReq, vpreq);
sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
sgi_req->reqType = priv->majorOpcode;
sgi_req->glxCode = X_GLXVendorPrivateWithReply;
sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX;
sgi_req->screen = screen;
}
else
goto out;
 
if (!_XReply(dpy, (xReply *) & reply, 0, False))
goto out;
 
psc->configs = createConfigsFromProperties(dpy,
reply.numFBConfigs,
reply.numAttribs * 2,
screen, GL_TRUE);
 
out:
UnlockDisplay(dpy);
return psc->configs != NULL;
}
 
_X_HIDDEN Bool
glx_screen_init(struct glx_screen *psc,
int screen, struct glx_display * priv)
{
/* Initialize per screen dynamic client GLX extensions */
psc->ext_list_first_time = GL_TRUE;
psc->scr = screen;
psc->dpy = priv->dpy;
psc->display = priv;
 
getVisualConfigs(psc, priv, screen);
getFBConfigs(psc, priv, screen);
 
return GL_TRUE;
}
 
_X_HIDDEN void
glx_screen_cleanup(struct glx_screen *psc)
{
if (psc->configs) {
glx_config_destroy_list(psc->configs);
free(psc->effectiveGLXexts);
psc->configs = NULL; /* NOTE: just for paranoia */
}
if (psc->visuals) {
glx_config_destroy_list(psc->visuals);
psc->visuals = NULL; /* NOTE: just for paranoia */
}
free((char *) psc->serverGLXexts);
}
 
/*
** Allocate the memory for the per screen configs for each screen.
** If that works then fetch the per screen configs data.
*/
static Bool
AllocAndFetchScreenConfigs(Display * dpy, struct glx_display * priv)
{
struct glx_screen *psc;
GLint i, screens;
 
/*
** First allocate memory for the array of per screen configs.
*/
screens = ScreenCount(dpy);
priv->screens = malloc(screens * sizeof *priv->screens);
if (!priv->screens)
return GL_FALSE;
 
priv->serverGLXversion =
__glXQueryServerString(dpy, priv->majorOpcode, 0, GLX_VERSION);
if (priv->serverGLXversion == NULL) {
FreeScreenConfigs(priv);
return GL_FALSE;
}
 
for (i = 0; i < screens; i++, psc++) {
psc = NULL;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (priv->dri2Display)
psc = (*priv->dri2Display->createScreen) (i, priv);
if (psc == NULL && priv->driDisplay)
psc = (*priv->driDisplay->createScreen) (i, priv);
if (psc == NULL && priv->driswDisplay)
psc = (*priv->driswDisplay->createScreen) (i, priv);
#endif
#if defined(GLX_USE_APPLEGL)
if (psc == NULL)
psc = applegl_create_screen(i, priv);
#else
if (psc == NULL)
psc = indirect_create_screen(i, priv);
#endif
priv->screens[i] = psc;
}
SyncHandle();
return GL_TRUE;
}
 
/*
** Initialize the client side extension code.
*/
_X_HIDDEN struct glx_display *
__glXInitialize(Display * dpy)
{
struct glx_display *dpyPriv, *d;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
Bool glx_direct, glx_accel;
#endif
int i;
 
_XLockMutex(_Xglobal_lock);
 
for (dpyPriv = glx_displays; dpyPriv; dpyPriv = dpyPriv->next) {
if (dpyPriv->dpy == dpy) {
_XUnlockMutex(_Xglobal_lock);
return dpyPriv;
}
}
 
/* Drop the lock while we create the display private. */
_XUnlockMutex(_Xglobal_lock);
 
dpyPriv = calloc(1, sizeof *dpyPriv);
if (!dpyPriv)
return NULL;
 
dpyPriv->codes = XInitExtension(dpy, __glXExtensionName);
if (!dpyPriv->codes) {
free(dpyPriv);
_XUnlockMutex(_Xglobal_lock);
return NULL;
}
 
dpyPriv->dpy = dpy;
dpyPriv->majorOpcode = dpyPriv->codes->major_opcode;
dpyPriv->serverGLXvendor = 0x0;
dpyPriv->serverGLXversion = 0x0;
 
/* See if the versions are compatible. This GLX implementation does not
* work with servers that only support GLX 1.0.
*/
if (!QueryVersion(dpy, dpyPriv->majorOpcode,
&dpyPriv->majorVersion, &dpyPriv->minorVersion)
|| (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion < 1)) {
free(dpyPriv);
_XUnlockMutex(_Xglobal_lock);
return NULL;
}
 
for (i = 0; i < __GLX_NUMBER_EVENTS; i++) {
XESetWireToEvent(dpy, dpyPriv->codes->first_event + i, __glXWireToEvent);
XESetEventToWire(dpy, dpyPriv->codes->first_event + i, __glXEventToWire);
}
 
XESetCloseDisplay(dpy, dpyPriv->codes->extension, __glXCloseDisplay);
XESetErrorString (dpy, dpyPriv->codes->extension,__glXErrorString);
 
dpyPriv->glXDrawHash = __glxHashCreate();
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
glx_direct = (getenv("LIBGL_ALWAYS_INDIRECT") == NULL);
glx_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);
 
dpyPriv->drawHash = __glxHashCreate();
 
/*
** Initialize the direct rendering per display data and functions.
** Note: This _must_ be done before calling any other DRI routines
** (e.g., those called in AllocAndFetchScreenConfigs).
*/
if (glx_direct && glx_accel) {
dpyPriv->dri2Display = dri2CreateDisplay(dpy);
dpyPriv->driDisplay = driCreateDisplay(dpy);
}
if (glx_direct)
dpyPriv->driswDisplay = driswCreateDisplay(dpy);
#endif
 
#ifdef GLX_USE_APPLEGL
if (!applegl_create_display(dpyPriv)) {
free(dpyPriv);
return NULL;
}
#endif
if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
free(dpyPriv);
return NULL;
}
 
__glX_send_client_info(dpyPriv);
 
/* Grab the lock again and add the dispay private, unless somebody
* beat us to initializing on this display in the meantime. */
_XLockMutex(_Xglobal_lock);
 
for (d = glx_displays; d; d = d->next) {
if (d->dpy == dpy) {
_XUnlockMutex(_Xglobal_lock);
glx_display_free(dpyPriv);
return d;
}
}
 
dpyPriv->next = glx_displays;
glx_displays = dpyPriv;
 
_XUnlockMutex(_Xglobal_lock);
 
return dpyPriv;
}
 
/*
** Setup for sending a GLX command on dpy. Make sure the extension is
** initialized. Try to avoid calling __glXInitialize as its kinda slow.
*/
_X_HIDDEN CARD8
__glXSetupForCommand(Display * dpy)
{
struct glx_context *gc;
struct glx_display *priv;
 
/* If this thread has a current context, flush its rendering commands */
gc = __glXGetCurrentContext();
if (gc->currentDpy) {
/* Flush rendering buffer of the current context, if any */
(void) __glXFlushRenderBuffer(gc, gc->pc);
 
if (gc->currentDpy == dpy) {
/* Use opcode from gc because its right */
return gc->majorOpcode;
}
else {
/*
** Have to get info about argument dpy because it might be to
** a different server
*/
}
}
 
/* Forced to lookup extension via the slow initialize route */
priv = __glXInitialize(dpy);
if (!priv) {
return 0;
}
return priv->majorOpcode;
}
 
/**
* Flush the drawing command transport buffer.
*
* \param ctx Context whose transport buffer is to be flushed.
* \param pc Pointer to first unused buffer location.
*
* \todo
* Modify this function to use \c ctx->pc instead of the explicit
* \c pc parameter.
*/
_X_HIDDEN GLubyte *
__glXFlushRenderBuffer(struct glx_context * ctx, GLubyte * pc)
{
Display *const dpy = ctx->currentDpy;
xcb_connection_t *c = XGetXCBConnection(dpy);
const GLint size = pc - ctx->buf;
 
if ((dpy != NULL) && (size > 0)) {
xcb_glx_render(c, ctx->currentContextTag, size,
(const uint8_t *) ctx->buf);
}
 
/* Reset pointer and return it */
ctx->pc = ctx->buf;
return ctx->pc;
}
 
 
/**
* Send a portion of a GLXRenderLarge command to the server. The advantage of
* this function over \c __glXSendLargeCommand is that callers can use the
* data buffer in the GLX context and may be able to avoid allocating an
* extra buffer. The disadvantage is the clients will have to do more
* GLX protocol work (i.e., calculating \c totalRequests, etc.).
*
* \sa __glXSendLargeCommand
*
* \param gc GLX context
* \param requestNumber Which part of the whole command is this? The first
* request is 1.
* \param totalRequests How many requests will there be?
* \param data Command data.
* \param dataLen Size, in bytes, of the command data.
*/
_X_HIDDEN void
__glXSendLargeChunk(struct glx_context * gc, GLint requestNumber,
GLint totalRequests, const GLvoid * data, GLint dataLen)
{
Display *dpy = gc->currentDpy;
xcb_connection_t *c = XGetXCBConnection(dpy);
xcb_glx_render_large(c, gc->currentContextTag, requestNumber,
totalRequests, dataLen, data);
}
 
 
/**
* Send a command that is too large for the GLXRender protocol request.
*
* Send a large command, one that is too large for some reason to
* send using the GLXRender protocol request. One reason to send
* a large command is to avoid copying the data.
*
* \param ctx GLX context
* \param header Header data.
* \param headerLen Size, in bytes, of the header data. It is assumed that
* the header data will always be small enough to fit in
* a single X protocol packet.
* \param data Command data.
* \param dataLen Size, in bytes, of the command data.
*/
_X_HIDDEN void
__glXSendLargeCommand(struct glx_context * ctx,
const GLvoid * header, GLint headerLen,
const GLvoid * data, GLint dataLen)
{
GLint maxSize;
GLint totalRequests, requestNumber;
 
/*
** Calculate the maximum amount of data can be stuffed into a single
** packet. sz_xGLXRenderReq is added because bufSize is the maximum
** packet size minus sz_xGLXRenderReq.
*/
maxSize = (ctx->bufSize + sz_xGLXRenderReq) - sz_xGLXRenderLargeReq;
totalRequests = 1 + (dataLen / maxSize);
if (dataLen % maxSize)
totalRequests++;
 
/*
** Send all of the command, except the large array, as one request.
*/
assert(headerLen <= maxSize);
__glXSendLargeChunk(ctx, 1, totalRequests, header, headerLen);
 
/*
** Send enough requests until the whole array is sent.
*/
for (requestNumber = 2; requestNumber <= (totalRequests - 1);
requestNumber++) {
__glXSendLargeChunk(ctx, requestNumber, totalRequests, data, maxSize);
data = (const GLvoid *) (((const GLubyte *) data) + maxSize);
dataLen -= maxSize;
assert(dataLen > 0);
}
 
assert(dataLen <= maxSize);
__glXSendLargeChunk(ctx, requestNumber, totalRequests, data, dataLen);
}
 
/************************************************************************/
 
#ifdef DEBUG
_X_HIDDEN void
__glXDumpDrawBuffer(struct glx_context * ctx)
{
GLubyte *p = ctx->buf;
GLubyte *end = ctx->pc;
GLushort opcode, length;
 
while (p < end) {
/* Fetch opcode */
opcode = *((GLushort *) p);
length = *((GLushort *) (p + 2));
printf("%2x: %5d: ", opcode, length);
length -= 4;
p += 4;
while (length > 0) {
printf("%08x ", *((unsigned *) p));
p += 4;
length -= 4;
}
printf("\n");
}
}
#endif
/contrib/sdk/sources/Mesa/src/glx/glxextensions.c
0,0 → 1,724
/*
* (C) Copyright IBM Corporation 2002, 2004
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS AND/OR THEIR 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.
*/
 
/**
* \file glxextensions.c
*
* \author Ian Romanick <idr@us.ibm.com>
*/
 
#include "glxclient.h"
#include <X11/extensions/extutil.h>
#include <X11/extensions/Xext.h>
#include <string.h>
#include "glxextensions.h"
 
 
#define SET_BIT(m,b) (m[ (b) / 8 ] |= (1U << ((b) % 8)))
#define CLR_BIT(m,b) (m[ (b) / 8 ] &= ~(1U << ((b) % 8)))
#define IS_SET(m,b) ((m[ (b) / 8 ] & (1U << ((b) % 8))) != 0)
#define CONCAT(a,b) a ## b
#define GLX(n) "GLX_" # n, 4 + sizeof( # n ) - 1, CONCAT(n,_bit)
#define GL(n) "GL_" # n, 3 + sizeof( # n ) - 1, GL_ ## n ## _bit
#define VER(a,b) a, b
#define Y 1
#define N 0
#define EXT_ENABLED(bit,supported) (IS_SET( supported, bit ))
 
 
struct extension_info
{
const char *const name;
unsigned name_len;
 
unsigned char bit;
 
/* This is the lowest version of GLX that "requires" this extension.
* For example, GLX 1.3 requires SGIX_fbconfig, SGIX_pbuffer, and
* SGI_make_current_read. If the extension is not required by any known
* version of GLX, use 0, 0.
*/
unsigned char version_major;
unsigned char version_minor;
unsigned char client_support;
unsigned char direct_support;
unsigned char client_only; /** Is the extension client-side only? */
unsigned char direct_only; /** Is the extension for direct
* contexts only?
*/
};
 
/* *INDENT-OFF* */
static const struct extension_info known_glx_extensions[] = {
{ GLX(ARB_create_context), VER(0,0), Y, N, N, N },
{ GLX(ARB_create_context_profile), VER(0,0), Y, N, N, N },
{ GLX(ARB_create_context_robustness), VER(0,0), Y, N, N, N },
{ GLX(ARB_fbconfig_float), VER(0,0), Y, Y, N, N },
{ GLX(ARB_framebuffer_sRGB), VER(0,0), Y, Y, N, N },
{ GLX(ARB_get_proc_address), VER(1,4), Y, N, Y, N },
{ GLX(ARB_multisample), VER(1,4), Y, Y, N, N },
{ GLX(ATI_pixel_format_float), VER(0,0), N, N, N, N },
{ GLX(EXT_import_context), VER(0,0), Y, Y, N, N },
{ GLX(EXT_visual_info), VER(0,0), Y, Y, N, N },
{ GLX(EXT_visual_rating), VER(0,0), Y, Y, N, N },
{ GLX(EXT_fbconfig_packed_float), VER(0,0), Y, Y, N, N },
{ GLX(EXT_framebuffer_sRGB), VER(0,0), Y, Y, N, N },
{ GLX(EXT_create_context_es2_profile), VER(0,0), Y, N, N, Y },
{ GLX(MESA_copy_sub_buffer), VER(0,0), Y, N, N, N },
{ GLX(MESA_multithread_makecurrent),VER(0,0), Y, N, Y, N },
{ GLX(MESA_swap_control), VER(0,0), Y, N, N, Y },
{ GLX(NV_float_buffer), VER(0,0), N, N, N, N },
{ GLX(OML_swap_method), VER(0,0), Y, Y, N, N },
{ GLX(OML_sync_control), VER(0,0), Y, N, N, Y },
{ GLX(SGI_make_current_read), VER(1,3), Y, N, N, N },
{ GLX(SGI_swap_control), VER(0,0), Y, N, N, N },
{ GLX(SGI_video_sync), VER(0,0), Y, N, N, Y },
{ GLX(SGIS_multisample), VER(0,0), Y, Y, N, N },
{ GLX(SGIX_fbconfig), VER(1,3), Y, Y, N, N },
{ GLX(SGIX_pbuffer), VER(1,3), Y, Y, N, N },
{ GLX(SGIX_swap_barrier), VER(0,0), N, N, N, N },
{ GLX(SGIX_swap_group), VER(0,0), N, N, N, N },
{ GLX(SGIX_visual_select_group), VER(0,0), Y, Y, N, N },
{ GLX(EXT_texture_from_pixmap), VER(0,0), Y, N, N, N },
{ GLX(INTEL_swap_event), VER(0,0), Y, N, N, N },
{ NULL }
};
 
static const struct extension_info known_gl_extensions[] = {
{ GL(ARB_depth_texture), VER(1,4), Y, N, N, N },
{ GL(ARB_draw_buffers), VER(0,0), Y, N, N, N },
{ GL(ARB_fragment_program), VER(0,0), Y, N, N, N },
{ GL(ARB_fragment_program_shadow), VER(0,0), Y, N, N, N },
{ GL(ARB_framebuffer_object), VER(0,0), Y, N, N, N },
{ GL(ARB_imaging), VER(0,0), Y, N, N, N },
{ GL(ARB_multisample), VER(1,3), Y, N, N, N },
{ GL(ARB_multitexture), VER(1,3), Y, N, N, N },
{ GL(ARB_occlusion_query), VER(1,5), Y, N, N, N },
{ GL(ARB_point_parameters), VER(1,4), Y, N, N, N },
{ GL(ARB_point_sprite), VER(0,0), Y, N, N, N },
{ GL(ARB_shadow), VER(1,4), Y, N, N, N },
{ GL(ARB_shadow_ambient), VER(0,0), Y, N, N, N },
{ GL(ARB_texture_border_clamp), VER(1,3), Y, N, N, N },
{ GL(ARB_texture_compression), VER(1,3), Y, N, N, N },
{ GL(ARB_texture_cube_map), VER(1,3), Y, N, N, N },
{ GL(ARB_texture_env_add), VER(1,3), Y, N, N, N },
{ GL(ARB_texture_env_combine), VER(1,3), Y, N, N, N },
{ GL(ARB_texture_env_crossbar), VER(1,4), Y, N, N, N },
{ GL(ARB_texture_env_dot3), VER(1,3), Y, N, N, N },
{ GL(ARB_texture_mirrored_repeat), VER(1,4), Y, N, N, N },
{ GL(ARB_texture_non_power_of_two), VER(1,5), Y, N, N, N },
{ GL(ARB_texture_rectangle), VER(0,0), Y, N, N, N },
{ GL(ARB_texture_rg), VER(0,0), Y, N, N, N },
{ GL(ARB_transpose_matrix), VER(1,3), Y, N, Y, N },
{ GL(ARB_vertex_buffer_object), VER(1,5), N, N, N, N },
{ GL(ARB_vertex_program), VER(0,0), Y, N, N, N },
{ GL(ARB_window_pos), VER(1,4), Y, N, N, N },
{ GL(EXT_abgr), VER(0,0), Y, N, N, N },
{ GL(EXT_bgra), VER(1,2), Y, N, N, N },
{ GL(EXT_blend_color), VER(1,4), Y, N, N, N },
{ GL(EXT_blend_equation_separate), VER(0,0), Y, N, N, N },
{ GL(EXT_blend_func_separate), VER(1,4), Y, N, N, N },
{ GL(EXT_blend_logic_op), VER(1,4), Y, N, N, N },
{ GL(EXT_blend_minmax), VER(1,4), Y, N, N, N },
{ GL(EXT_blend_subtract), VER(1,4), Y, N, N, N },
{ GL(EXT_clip_volume_hint), VER(0,0), Y, N, N, N },
{ GL(EXT_compiled_vertex_array), VER(0,0), N, N, N, N },
{ GL(EXT_convolution), VER(0,0), N, N, N, N },
{ GL(EXT_copy_texture), VER(1,1), Y, N, N, N },
{ GL(EXT_cull_vertex), VER(0,0), N, N, N, N },
{ GL(EXT_depth_bounds_test), VER(0,0), N, N, N, N },
{ GL(EXT_draw_range_elements), VER(1,2), Y, N, Y, N },
{ GL(EXT_fog_coord), VER(1,4), Y, N, N, N },
{ GL(EXT_framebuffer_blit), VER(0,0), Y, N, N, N },
{ GL(EXT_framebuffer_multisample), VER(0,0), Y, N, N, N },
{ GL(EXT_framebuffer_object), VER(0,0), Y, N, N, N },
{ GL(EXT_framebuffer_sRGB), VER(0,0), Y, N, N, N },
{ GL(EXT_multi_draw_arrays), VER(1,4), Y, N, Y, N },
{ GL(EXT_packed_depth_stencil), VER(0,0), Y, N, N, N },
{ GL(EXT_packed_pixels), VER(1,2), Y, N, N, N },
{ GL(EXT_paletted_texture), VER(0,0), Y, N, N, N },
{ GL(EXT_pixel_buffer_object), VER(0,0), N, N, N, N },
{ GL(EXT_point_parameters), VER(1,4), Y, N, N, N },
{ GL(EXT_polygon_offset), VER(1,1), Y, N, N, N },
{ GL(EXT_rescale_normal), VER(1,2), Y, N, N, N },
{ GL(EXT_secondary_color), VER(1,4), Y, N, N, N },
{ GL(EXT_separate_specular_color), VER(1,2), Y, N, N, N },
{ GL(EXT_shadow_funcs), VER(1,5), Y, N, N, N },
{ GL(EXT_shared_texture_palette), VER(0,0), Y, N, N, N },
{ GL(EXT_stencil_two_side), VER(0,0), Y, N, N, N },
{ GL(EXT_stencil_wrap), VER(1,4), Y, N, N, N },
{ GL(EXT_subtexture), VER(1,1), Y, N, N, N },
{ GL(EXT_texture), VER(1,1), Y, N, N, N },
{ GL(EXT_texture3D), VER(1,2), Y, N, N, N },
{ GL(EXT_texture_compression_dxt1), VER(0,0), Y, N, N, N },
{ GL(EXT_texture_compression_s3tc), VER(0,0), Y, N, N, N },
{ GL(EXT_texture_edge_clamp), VER(1,2), Y, N, N, N },
{ GL(EXT_texture_env_add), VER(1,3), Y, N, N, N },
{ GL(EXT_texture_env_combine), VER(1,3), Y, N, N, N },
{ GL(EXT_texture_env_dot3), VER(0,0), Y, N, N, N },
{ GL(EXT_texture_filter_anisotropic), VER(0,0), Y, N, N, N },
{ GL(EXT_texture_lod), VER(1,2), Y, N, N, N },
{ GL(EXT_texture_lod_bias), VER(1,4), Y, N, N, N },
{ GL(EXT_texture_mirror_clamp), VER(0,0), Y, N, N, N },
{ GL(EXT_texture_object), VER(1,1), Y, N, N, N },
{ GL(EXT_texture_rectangle), VER(0,0), Y, N, N, N },
{ GL(EXT_vertex_array), VER(0,0), Y, N, N, N },
{ GL(3DFX_texture_compression_FXT1), VER(0,0), Y, N, N, N },
{ GL(APPLE_packed_pixels), VER(1,2), Y, N, N, N },
{ GL(APPLE_ycbcr_422), VER(0,0), Y, N, N, N },
{ GL(ATI_draw_buffers), VER(0,0), Y, N, N, N },
{ GL(ATI_text_fragment_shader), VER(0,0), Y, N, N, N },
{ GL(ATI_texture_env_combine3), VER(0,0), Y, N, N, N },
{ GL(ATI_texture_float), VER(0,0), Y, N, N, N },
{ GL(ATI_texture_mirror_once), VER(0,0), Y, N, N, N },
{ GL(ATIX_texture_env_combine3), VER(0,0), Y, N, N, N },
{ GL(HP_convolution_border_modes), VER(0,0), Y, N, N, N },
{ GL(HP_occlusion_test), VER(0,0), Y, N, N, N },
{ GL(IBM_cull_vertex), VER(0,0), Y, N, N, N },
{ GL(IBM_pixel_filter_hint), VER(0,0), Y, N, N, N },
{ GL(IBM_rasterpos_clip), VER(0,0), Y, N, N, N },
{ GL(IBM_texture_clamp_nodraw), VER(0,0), Y, N, N, N },
{ GL(IBM_texture_mirrored_repeat), VER(0,0), Y, N, N, N },
{ GL(INGR_blend_func_separate), VER(0,0), Y, N, N, N },
{ GL(INGR_interlace_read), VER(0,0), Y, N, N, N },
{ GL(MESA_pack_invert), VER(0,0), Y, N, N, N },
{ GL(MESA_ycbcr_texture), VER(0,0), Y, N, N, N },
{ GL(NV_blend_square), VER(1,4), Y, N, N, N },
{ GL(NV_copy_depth_to_color), VER(0,0), Y, N, N, N },
{ GL(NV_depth_clamp), VER(0,0), Y, N, N, N },
{ GL(NV_fog_distance), VER(0,0), Y, N, N, N },
{ GL(NV_fragment_program), VER(0,0), Y, N, N, N },
{ GL(NV_fragment_program_option), VER(0,0), Y, N, N, N },
{ GL(NV_fragment_program2), VER(0,0), Y, N, N, N },
{ GL(NV_light_max_exponent), VER(0,0), Y, N, N, N },
{ GL(NV_multisample_filter_hint), VER(0,0), Y, N, N, N },
{ GL(NV_packed_depth_stencil), VER(0,0), Y, N, N, N },
{ GL(NV_point_sprite), VER(0,0), Y, N, N, N },
{ GL(NV_texgen_reflection), VER(0,0), Y, N, N, N },
{ GL(NV_texture_compression_vtc), VER(0,0), Y, N, N, N },
{ GL(NV_texture_env_combine4), VER(0,0), Y, N, N, N },
{ GL(NV_texture_rectangle), VER(0,0), Y, N, N, N },
{ GL(NV_vertex_program), VER(0,0), Y, N, N, N },
{ GL(NV_vertex_program1_1), VER(0,0), Y, N, N, N },
{ GL(NV_vertex_program2), VER(0,0), Y, N, N, N },
{ GL(NV_vertex_program2_option), VER(0,0), Y, N, N, N },
{ GL(NV_vertex_program3), VER(0,0), Y, N, N, N },
{ GL(OES_read_format), VER(0,0), Y, N, N, N },
{ GL(OES_compressed_paletted_texture),VER(0,0), Y, N, N, N },
{ GL(SGI_color_matrix), VER(0,0), Y, N, N, N },
{ GL(SGI_color_table), VER(0,0), Y, N, N, N },
{ GL(SGI_texture_color_table), VER(0,0), Y, N, N, N },
{ GL(SGIS_generate_mipmap), VER(1,4), Y, N, N, N },
{ GL(SGIS_multisample), VER(0,0), Y, N, N, N },
{ GL(SGIS_texture_border_clamp), VER(1,3), Y, N, N, N },
{ GL(SGIS_texture_edge_clamp), VER(1,2), Y, N, N, N },
{ GL(SGIS_texture_lod), VER(1,2), Y, N, N, N },
{ GL(SGIX_blend_alpha_minmax), VER(0,0), Y, N, N, N },
{ GL(SGIX_clipmap), VER(0,0), Y, N, N, N },
{ GL(SGIX_depth_texture), VER(0,0), Y, N, N, N },
{ GL(SGIX_fog_offset), VER(0,0), Y, N, N, N },
{ GL(SGIX_shadow), VER(0,0), Y, N, N, N },
{ GL(SGIX_shadow_ambient), VER(0,0), Y, N, N, N },
{ GL(SGIX_texture_coordinate_clamp), VER(0,0), Y, N, N, N },
{ GL(SGIX_texture_lod_bias), VER(0,0), Y, N, N, N },
{ GL(SGIX_texture_range), VER(0,0), Y, N, N, N },
{ GL(SGIX_texture_scale_bias), VER(0,0), Y, N, N, N },
{ GL(SGIX_vertex_preclip), VER(0,0), Y, N, N, N },
{ GL(SGIX_vertex_preclip_hint), VER(0,0), Y, N, N, N },
{ GL(SGIX_ycrcb), VER(0,0), Y, N, N, N },
{ GL(SUN_convolution_border_modes), VER(0,0), Y, N, N, N },
{ GL(SUN_multi_draw_arrays), VER(0,0), Y, N, Y, N },
{ GL(SUN_slice_accum), VER(0,0), Y, N, N, N },
{ NULL }
};
/* *INDENT-ON* */
 
 
/* global bit-fields of available extensions and their characteristics */
static unsigned char client_glx_support[8];
static unsigned char client_glx_only[8];
static unsigned char direct_glx_only[8];
static unsigned char client_gl_support[__GL_EXT_BYTES];
static unsigned char client_gl_only[__GL_EXT_BYTES];
 
/**
* Bits representing the set of extensions that are enabled by default in all
* direct rendering drivers.
*/
static unsigned char direct_glx_support[8];
 
/**
* Highest core GL version that can be supported for indirect rendering.
*/
static const unsigned gl_major = 1;
static const unsigned gl_minor = 4;
 
/* client extensions string */
static const char *__glXGLXClientExtensions = NULL;
 
static void __glXExtensionsCtr(void);
static void __glXExtensionsCtrScreen(struct glx_screen * psc);
static void __glXProcessServerString(const struct extension_info *ext,
const char *server_string,
unsigned char *server_support);
 
/**
* Set the state of a GLX extension.
*
* \param name Name of the extension.
* \param name_len Length, in characters, of the extension name.
* \param state New state (either enabled or disabled) of the extension.
* \param supported Table in which the state of the extension is to be set.
*/
static void
set_glx_extension(const struct extension_info *ext,
const char *name, unsigned name_len, GLboolean state,
unsigned char *supported)
{
unsigned i;
 
 
for (i = 0; ext[i].name != NULL; i++) {
if ((name_len == ext[i].name_len)
&& (strncmp(ext[i].name, name, name_len) == 0)) {
if (state) {
SET_BIT(supported, ext[i].bit);
}
else {
CLR_BIT(supported, ext[i].bit);
}
 
return;
}
}
}
 
 
#define NUL '\0'
#define SEPARATOR ' '
 
/**
* Convert the server's extension string to a bit-field.
*
* \param server_string GLX extension string from the server.
* \param server_support Bit-field of supported extensions.
*
* \note
* This function is used to process both GLX and GL extension strings. The
* bit-fields used to track each of these have different sizes. Therefore,
* the data pointed by \c server_support must be preinitialized to zero.
*/
static void
__glXProcessServerString(const struct extension_info *ext,
const char *server_string,
unsigned char *server_support)
{
unsigned base;
unsigned len;
 
for (base = 0; server_string[base] != NUL; /* empty */ ) {
/* Determine the length of the next extension name.
*/
for (len = 0; (server_string[base + len] != SEPARATOR)
&& (server_string[base + len] != NUL); len++) {
/* empty */
}
 
/* Set the bit for the extension in the server_support table.
*/
set_glx_extension(ext, &server_string[base], len, GL_TRUE,
server_support);
 
 
/* Advance to the next extension string. This means that we skip
* over the previous string and any trialing white-space.
*/
for (base += len; (server_string[base] == SEPARATOR)
&& (server_string[base] != NUL); base++) {
/* empty */
}
}
}
 
void
__glXEnableDirectExtension(struct glx_screen * psc, const char *name)
{
__glXExtensionsCtr();
__glXExtensionsCtrScreen(psc);
 
set_glx_extension(known_glx_extensions,
name, strlen(name), GL_TRUE, psc->direct_support);
}
 
/**
* Initialize global extension support tables.
*/
 
static void
__glXExtensionsCtr(void)
{
unsigned i;
static GLboolean ext_list_first_time = GL_TRUE;
 
 
if (ext_list_first_time) {
ext_list_first_time = GL_FALSE;
 
(void) memset(client_glx_support, 0, sizeof(client_glx_support));
(void) memset(direct_glx_support, 0, sizeof(direct_glx_support));
(void) memset(client_glx_only, 0, sizeof(client_glx_only));
(void) memset(direct_glx_only, 0, sizeof(direct_glx_only));
 
(void) memset(client_gl_support, 0, sizeof(client_gl_support));
(void) memset(client_gl_only, 0, sizeof(client_gl_only));
 
for (i = 0; known_glx_extensions[i].name != NULL; i++) {
const unsigned bit = known_glx_extensions[i].bit;
 
if (known_glx_extensions[i].client_support) {
SET_BIT(client_glx_support, bit);
}
 
if (known_glx_extensions[i].direct_support) {
SET_BIT(direct_glx_support, bit);
}
 
if (known_glx_extensions[i].client_only) {
SET_BIT(client_glx_only, bit);
}
 
if (known_glx_extensions[i].direct_only) {
SET_BIT(direct_glx_only, bit);
}
}
 
for (i = 0; known_gl_extensions[i].name != NULL; i++) {
const unsigned bit = known_gl_extensions[i].bit;
 
if (known_gl_extensions[i].client_support) {
SET_BIT(client_gl_support, bit);
}
 
if (known_gl_extensions[i].client_only) {
SET_BIT(client_gl_only, bit);
}
}
 
#if 0
fprintf(stderr, "[%s:%u] Maximum client library version: %u.%u\n",
__func__, __LINE__, gl_major, gl_minor);
#endif
}
}
 
 
/**
* Make sure that per-screen direct-support table is initialized.
*
* \param psc Pointer to GLX per-screen record.
*/
 
static void
__glXExtensionsCtrScreen(struct glx_screen * psc)
{
if (psc->ext_list_first_time) {
psc->ext_list_first_time = GL_FALSE;
(void) memcpy(psc->direct_support, direct_glx_support,
sizeof(direct_glx_support));
}
}
 
 
/**
* Check if a certain extension is enabled on a given screen.
*
* \param psc Pointer to GLX per-screen record.
* \param bit Bit index in the direct-support table.
* \returns If the extension bit is enabled for the screen, \c GL_TRUE is
* returned. If the extension bit is not enabled or if \c psc is
* \c NULL, then \c GL_FALSE is returned.
*/
GLboolean
__glXExtensionBitIsEnabled(struct glx_screen * psc, unsigned bit)
{
GLboolean enabled = GL_FALSE;
 
if (psc != NULL) {
__glXExtensionsCtr();
__glXExtensionsCtrScreen(psc);
enabled = EXT_ENABLED(bit, psc->direct_support);
}
 
return enabled;
}
 
 
/**
* Check if a certain extension is enabled in a given context.
*
*/
GLboolean
__glExtensionBitIsEnabled(struct glx_context *gc, unsigned bit)
{
GLboolean enabled = GL_FALSE;
 
if (gc != NULL) {
enabled = EXT_ENABLED(bit, gc->gl_extension_bits);
}
 
return enabled;
}
 
 
 
/**
* Convert a bit-field to a string of supported extensions.
*/
static char *
__glXGetStringFromTable(const struct extension_info *ext,
const unsigned char *supported)
{
unsigned i;
unsigned ext_str_len;
char *ext_str;
char *point;
 
 
ext_str_len = 0;
for (i = 0; ext[i].name != NULL; i++) {
if (EXT_ENABLED(ext[i].bit, supported)) {
ext_str_len += ext[i].name_len + 1;
}
}
 
ext_str = malloc(ext_str_len + 1);
if (ext_str != NULL) {
point = ext_str;
 
for (i = 0; ext[i].name != NULL; i++) {
if (EXT_ENABLED(ext[i].bit, supported)) {
(void) memcpy(point, ext[i].name, ext[i].name_len);
point += ext[i].name_len;
 
*point = ' ';
point++;
}
}
 
*point = '\0';
}
 
return ext_str;
}
 
 
/**
* Get the string of client library supported extensions.
*/
const char *
__glXGetClientExtensions(void)
{
if (__glXGLXClientExtensions == NULL) {
__glXExtensionsCtr();
__glXGLXClientExtensions = __glXGetStringFromTable(known_glx_extensions,
client_glx_support);
}
 
return __glXGLXClientExtensions;
}
 
 
/**
* Calculate the list of application usable extensions. The resulting
* string is stored in \c psc->effectiveGLXexts.
*
* \param psc Pointer to GLX per-screen record.
* \param display_is_direct_capable True if the display is capable of
* direct rendering.
* \param minor_version GLX minor version from the server.
*/
 
void
__glXCalculateUsableExtensions(struct glx_screen * psc,
GLboolean display_is_direct_capable,
int minor_version)
{
unsigned char server_support[8];
unsigned char usable[8];
unsigned i;
 
__glXExtensionsCtr();
__glXExtensionsCtrScreen(psc);
 
(void) memset(server_support, 0, sizeof(server_support));
__glXProcessServerString(known_glx_extensions,
psc->serverGLXexts, server_support);
 
 
/* This is a hack. Some servers support GLX 1.3 but don't export
* all of the extensions implied by GLX 1.3. If the server claims
* support for GLX 1.3, enable support for the extensions that can be
* "emulated" as well.
*/
#ifndef GLX_USE_APPLEGL
if (minor_version >= 3) {
SET_BIT(server_support, EXT_visual_info_bit);
SET_BIT(server_support, EXT_visual_rating_bit);
SET_BIT(server_support, SGI_make_current_read_bit);
SET_BIT(server_support, SGIX_fbconfig_bit);
SET_BIT(server_support, SGIX_pbuffer_bit);
 
/* This one is a little iffy. GLX 1.3 doesn't incorporate all of this
* extension. However, the only part that is not strictly client-side
* is shared. That's the glXQueryContext / glXQueryContextInfoEXT
* function.
*/
 
SET_BIT(server_support, EXT_import_context_bit);
}
#endif
 
/* An extension is supported if the client-side (i.e., libGL) supports
* it and the "server" supports it. In this case that means that either
* the true server supports it or it is only for direct-rendering and
* the direct rendering driver supports it.
*
* If the display is not capable of direct rendering, then the extension
* is enabled if and only if the client-side library and the server
* support it.
*/
 
if (display_is_direct_capable) {
for (i = 0; i < 8; i++) {
usable[i] = (client_glx_support[i] & client_glx_only[i])
| (client_glx_support[i] & psc->direct_support[i] &
server_support[i])
| (client_glx_support[i] & psc->direct_support[i] &
direct_glx_only[i]);
}
}
else {
for (i = 0; i < 8; i++) {
usable[i] = (client_glx_support[i] & client_glx_only[i])
| (client_glx_support[i] & server_support[i]);
}
}
 
/* This hack is necessary because GLX_ARB_create_context_profile depends on
* server support, but GLX_EXT_create_context_es2_profile is direct-only.
* Without this hack, it would be possible to advertise
* GLX_EXT_create_context_es2_profile without
* GLX_ARB_create_context_profile. That would be a problem.
*/
if (!IS_SET(server_support, ARB_create_context_profile_bit)) {
CLR_BIT(usable, EXT_create_context_es2_profile_bit);
}
 
psc->effectiveGLXexts = __glXGetStringFromTable(known_glx_extensions,
usable);
}
 
 
/**
* Calculate the list of application usable extensions. The resulting
* string is stored in \c gc->extensions.
*
* \param gc Pointer to GLX context.
* \param server_string Extension string from the server.
* \param major_version GL major version from the server.
* \param minor_version GL minor version from the server.
*/
 
void
__glXCalculateUsableGLExtensions(struct glx_context * gc,
const char *server_string,
int major_version, int minor_version)
{
unsigned char server_support[__GL_EXT_BYTES];
unsigned char usable[__GL_EXT_BYTES];
unsigned i;
 
 
__glXExtensionsCtr();
 
(void) memset(server_support, 0, sizeof(server_support));
__glXProcessServerString(known_gl_extensions, server_string,
server_support);
 
 
/* Handle lazy servers that don't export all the extensions strings that
* are part of the GL core version that they support.
*/
 
for (i = 0; i < __GL_EXT_BYTES; i++) {
if ((known_gl_extensions[i].version_major != 0)
&& ((major_version > known_gl_extensions[i].version_major)
|| ((major_version == known_gl_extensions[i].version_major)
&& (minor_version >=
known_gl_extensions[i].version_minor)))) {
SET_BIT(server_support, known_gl_extensions[i].bit);
}
}
 
 
/* An extension is supported if the client-side (i.e., libGL) supports
* it and the server supports it or the client-side library supports it
* and it only needs client-side support.
*/
 
for (i = 0; i < __GL_EXT_BYTES; i++) {
usable[i] = (client_gl_support[i] & client_gl_only[i])
| (client_gl_support[i] & server_support[i]);
}
 
gc->extensions = (unsigned char *)
__glXGetStringFromTable(known_gl_extensions, usable);
(void) memcpy(gc->gl_extension_bits, usable, sizeof(usable));
}
 
 
/**
* Calculates the maximum core GL version that can be supported for indirect
* rendering.
*/
void
__glXGetGLVersion(int *major_version, int *minor_version)
{
__glXExtensionsCtr();
*major_version = gl_major;
*minor_version = gl_minor;
}
 
 
/**
* Get a string representing the set of extensions supported by the client
* library. This is currently only used to send the list of extensions
* supported by the client to the server.
*/
char *
__glXGetClientGLExtensionString(void)
{
__glXExtensionsCtr();
return __glXGetStringFromTable(known_gl_extensions, client_gl_support);
}
/contrib/sdk/sources/Mesa/src/glx/glxextensions.h
0,0 → 1,296
/*
* (C) Copyright IBM Corporation 2002, 2004
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS AND/OR THEIR 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.
*/
 
/**
* \file glxextensions.h
*
* \author Ian Romanick <idr@us.ibm.com>
*/
 
#ifndef GLX_GLXEXTENSIONS_H
#define GLX_GLXEXTENSIONS_H
 
enum
{
ARB_create_context_bit = 0,
ARB_create_context_profile_bit,
ARB_create_context_robustness_bit,
ARB_fbconfig_float_bit,
ARB_get_proc_address_bit,
ARB_multisample_bit,
ATI_pixel_format_float_bit,
EXT_visual_info_bit,
EXT_visual_rating_bit,
EXT_import_context_bit,
EXT_framebuffer_sRGB_bit,
EXT_fbconfig_packed_float_bit,
EXT_create_context_es2_profile_bit,
MESA_copy_sub_buffer_bit,
MESA_depth_float_bit,
MESA_multithread_makecurrent_bit,
MESA_swap_control_bit,
MESA_swap_frame_usage_bit,
NV_float_buffer_bit,
OML_swap_method_bit,
OML_sync_control_bit,
SGI_make_current_read_bit,
SGI_swap_control_bit,
SGI_video_sync_bit,
SGIS_multisample_bit,
SGIX_fbconfig_bit,
SGIX_pbuffer_bit,
SGIX_swap_barrier_bit,
SGIX_swap_group_bit,
SGIX_visual_select_group_bit,
EXT_texture_from_pixmap_bit,
INTEL_swap_event_bit,
};
 
/* From the GLX perspective, the ARB and EXT extensions are identical. Use a
* single bit for both.
*/
#define ARB_framebuffer_sRGB_bit EXT_framebuffer_sRGB_bit
 
enum
{
GL_ARB_depth_texture_bit = 0,
GL_ARB_draw_buffers_bit,
GL_ARB_fragment_program_bit,
GL_ARB_fragment_program_shadow_bit,
GL_ARB_framebuffer_object_bit,
GL_ARB_imaging_bit,
GL_ARB_multisample_bit,
GL_ARB_multitexture_bit,
GL_ARB_occlusion_query_bit,
GL_ARB_point_parameters_bit,
GL_ARB_point_sprite_bit,
GL_ARB_shadow_bit,
GL_ARB_shadow_ambient_bit,
GL_ARB_texture_border_clamp_bit,
GL_ARB_texture_cube_map_bit,
GL_ARB_texture_compression_bit,
GL_ARB_texture_env_add_bit,
GL_ARB_texture_env_combine_bit,
GL_ARB_texture_env_crossbar_bit,
GL_ARB_texture_env_dot3_bit,
GL_ARB_texture_mirrored_repeat_bit,
GL_ARB_texture_non_power_of_two_bit,
GL_ARB_texture_rectangle_bit,
GL_ARB_texture_rg_bit,
GL_ARB_transpose_matrix_bit,
GL_ARB_vertex_buffer_object_bit,
GL_ARB_vertex_program_bit,
GL_ARB_window_pos_bit,
GL_EXT_abgr_bit,
GL_EXT_bgra_bit,
GL_EXT_blend_color_bit,
GL_EXT_blend_equation_separate_bit,
GL_EXT_blend_func_separate_bit,
GL_EXT_blend_logic_op_bit,
GL_EXT_blend_minmax_bit,
GL_EXT_blend_subtract_bit,
GL_EXT_clip_volume_hint_bit,
GL_EXT_compiled_vertex_array_bit,
GL_EXT_convolution_bit,
GL_EXT_copy_texture_bit,
GL_EXT_cull_vertex_bit,
GL_EXT_depth_bounds_test_bit,
GL_EXT_draw_range_elements_bit,
GL_EXT_fog_coord_bit,
GL_EXT_framebuffer_blit_bit,
GL_EXT_framebuffer_multisample_bit,
GL_EXT_framebuffer_object_bit,
GL_EXT_framebuffer_sRGB_bit,
GL_EXT_multi_draw_arrays_bit,
GL_EXT_packed_depth_stencil_bit,
GL_EXT_packed_pixels_bit,
GL_EXT_paletted_texture_bit,
GL_EXT_pixel_buffer_object_bit,
GL_EXT_polygon_offset_bit,
GL_EXT_rescale_normal_bit,
GL_EXT_secondary_color_bit,
GL_EXT_separate_specular_color_bit,
GL_EXT_shadow_funcs_bit,
GL_EXT_shared_texture_palette_bit,
GL_EXT_stencil_two_side_bit,
GL_EXT_stencil_wrap_bit,
GL_EXT_subtexture_bit,
GL_EXT_texture_bit,
GL_EXT_texture3D_bit,
GL_EXT_texture_compression_dxt1_bit,
GL_EXT_texture_compression_s3tc_bit,
GL_EXT_texture_edge_clamp_bit,
GL_EXT_texture_env_combine_bit,
GL_EXT_texture_env_dot3_bit,
GL_EXT_texture_filter_anisotropic_bit,
GL_EXT_texture_lod_bit,
GL_EXT_texture_lod_bias_bit,
GL_EXT_texture_mirror_clamp_bit,
GL_EXT_texture_object_bit,
GL_EXT_vertex_array_bit,
GL_3DFX_texture_compression_FXT1_bit,
GL_APPLE_packed_pixels_bit,
GL_APPLE_ycbcr_422_bit,
GL_ATI_text_fragment_shader_bit,
GL_ATI_texture_env_combine3_bit,
GL_ATI_texture_float_bit,
GL_ATI_texture_mirror_once_bit,
GL_HP_convolution_border_modes_bit,
GL_HP_occlusion_test_bit,
GL_IBM_cull_vertex_bit,
GL_IBM_pixel_filter_hint_bit,
GL_IBM_rasterpos_clip_bit,
GL_IBM_texture_clamp_nodraw_bit,
GL_INGR_interlace_read_bit,
GL_MESA_pack_invert_bit,
GL_MESA_ycbcr_texture_bit,
GL_NV_blend_square_bit,
GL_NV_copy_depth_to_color_bit,
GL_NV_depth_clamp_bit,
GL_NV_fog_distance_bit,
GL_NV_fragment_program_bit,
GL_NV_fragment_program_option_bit,
GL_NV_fragment_program2_bit,
GL_NV_light_max_exponent_bit,
GL_NV_multisample_filter_hint_bit,
GL_NV_packed_depth_stencil_bit,
GL_NV_point_sprite_bit,
GL_NV_texgen_reflection_bit,
GL_NV_texture_compression_vtc_bit,
GL_NV_texture_env_combine4_bit,
GL_NV_vertex_program_bit,
GL_NV_vertex_program1_1_bit,
GL_NV_vertex_program2_bit,
GL_NV_vertex_program2_option_bit,
GL_NV_vertex_program3_bit,
GL_OES_compressed_paletted_texture_bit,
GL_OES_read_format_bit,
GL_SGI_color_matrix_bit,
GL_SGI_color_table_bit,
GL_SGI_texture_color_table_bit,
GL_SGIS_generate_mipmap_bit,
GL_SGIS_multisample_bit,
GL_SGIS_texture_lod_bit,
GL_SGIX_blend_alpha_minmax_bit,
GL_SGIX_clipmap_bit,
GL_SGIX_depth_texture_bit,
GL_SGIX_fog_offset_bit,
GL_SGIX_shadow_bit,
GL_SGIX_texture_coordinate_clamp_bit,
GL_SGIX_texture_lod_bias_bit,
GL_SGIX_texture_range_bit,
GL_SGIX_texture_scale_bias_bit,
GL_SGIX_vertex_preclip_bit,
GL_SGIX_vertex_preclip_hint_bit,
GL_SGIX_ycrcb_bit,
GL_SUN_convolution_border_modes_bit,
GL_SUN_slice_accum_bit,
 
/* This *MUST* go here. If it gets put after the duplicate values it will
* get the value after the last duplicate.
*/
__NUM_GL_EXTS,
 
 
/* Alias extension bits. These extensions exist in either vendor-specific
* or EXT form and were later promoted to either EXT or ARB form. In all
* cases, the meaning is *exactly* the same. That's why
* EXT_texture_env_combine is *NOT* an alias of ARB_texture_env_combine and
* EXT_texture_env_dot3 is *NOT* an alias of ARB_texture_env_dot3. Be
* careful! When in doubt, src/mesa/main/extensions.c in the Mesa tree
* is a great reference.
*/
 
GL_ATI_blend_equation_separate_bit = GL_EXT_blend_equation_separate_bit,
GL_ATI_draw_buffers_bit = GL_ARB_draw_buffers_bit,
GL_ATIX_texture_env_combine3_bit = GL_ATI_texture_env_combine3_bit,
GL_EXT_point_parameters_bit = GL_ARB_point_parameters_bit,
GL_EXT_texture_env_add_bit = GL_ARB_texture_env_add_bit,
GL_EXT_texture_rectangle_bit = GL_ARB_texture_rectangle_bit,
GL_IBM_texture_mirrored_repeat_bit = GL_ARB_texture_mirrored_repeat_bit,
GL_INGR_blend_func_separate_bit = GL_EXT_blend_func_separate_bit,
GL_MESA_window_pos_bit = GL_ARB_window_pos_bit,
GL_NV_texture_rectangle_bit = GL_ARB_texture_rectangle_bit,
GL_SGIS_texture_border_clamp_bit = GL_ARB_texture_border_clamp_bit,
GL_SGIS_texture_edge_clamp_bit = GL_EXT_texture_edge_clamp_bit,
GL_SGIX_shadow_ambient_bit = GL_ARB_shadow_ambient_bit,
GL_SUN_multi_draw_arrays_bit = GL_EXT_multi_draw_arrays_bit
};
 
#define __GL_EXT_BYTES ((__NUM_GL_EXTS + 7) / 8)
 
struct glx_screen;
struct glx_context;
 
extern GLboolean __glXExtensionBitIsEnabled(struct glx_screen *psc,
unsigned bit);
extern const char *__glXGetClientExtensions(void);
extern void __glXCalculateUsableExtensions(struct glx_screen *psc,
GLboolean
display_is_direct_capable,
int server_minor_version);
 
extern void __glXCalculateUsableGLExtensions(struct glx_context *gc,
const char *server_string,
int major_version,
int minor_version);
extern void __glXGetGLVersion(int *major_version, int *minor_version);
extern char *__glXGetClientGLExtensionString(void);
 
extern GLboolean __glExtensionBitIsEnabled(struct glx_context *gc,
unsigned bit);
 
extern void
__glXEnableDirectExtension(struct glx_screen *psc, const char *name);
 
/* Source-level backwards compatibility with old drivers. They won't
* find the respective functions, though.
*/
typedef void (*PFNGLXENABLEEXTENSIONPROC) (const char *name,
GLboolean force_client);
typedef void (*PFNGLXDISABLEEXTENSIONPROC) (const char *name);
 
/* GLX_ALIAS should be used for functions with a non-void return type.
GLX_ALIAS_VOID is for functions with a void return type. */
#ifdef GLX_NO_STATIC_EXTENSION_FUNCTIONS
# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func)
# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func)
#else
# if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED)
# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \
return_type real_func proto_args \
__attribute__ ((alias( # aliased_func ) ));
# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \
GLX_ALIAS(void, real_func, proto_args, args, aliased_func)
# else
# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \
return_type real_func proto_args \
{ return aliased_func args ; }
# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \
void real_func proto_args \
{ aliased_func args ; }
# endif /* __GNUC__ */
#endif /* GLX_NO_STATIC_EXTENSION_FUNCTIONS */
 
#endif /* GLX_GLXEXTENSIONS_H */
/contrib/sdk/sources/Mesa/src/glx/glxhash.c
0,0 → 1,473
/* glxhash.c -- Small hash table support for integer -> integer mapping
* Taken from libdrm.
*
* Created: Sun Apr 18 09:35:45 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* 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
* PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors: Rickard E. (Rik) Faith <faith@valinux.com>
*
* DESCRIPTION
*
* This file contains a straightforward implementation of a fixed-sized
* hash table using self-organizing linked lists [Knuth73, pp. 398-399] for
* collision resolution. There are two potentially interesting things
* about this implementation:
*
* 1) The table is power-of-two sized. Prime sized tables are more
* traditional, but do not have a significant advantage over power-of-two
* sized table, especially when double hashing is not used for collision
* resolution.
*
* 2) The hash computation uses a table of random integers [Hanson97,
* pp. 39-41].
*
* FUTURE ENHANCEMENTS
*
* With a table size of 512, the current implementation is sufficient for a
* few hundred keys. Since this is well above the expected size of the
* tables for which this implementation was designed, the implementation of
* dynamic hash tables was postponed until the need arises. A common (and
* naive) approach to dynamic hash table implementation simply creates a
* new hash table when necessary, rehashes all the data into the new table,
* and destroys the old table. The approach in [Larson88] is superior in
* two ways: 1) only a portion of the table is expanded when needed,
* distributing the expansion cost over several insertions, and 2) portions
* of the table can be locked, enabling a scalable thread-safe
* implementation.
*
* REFERENCES
*
* [Hanson97] David R. Hanson. C Interfaces and Implementations:
* Techniques for Creating Reusable Software. Reading, Massachusetts:
* Addison-Wesley, 1997.
*
* [Knuth73] Donald E. Knuth. The Art of Computer Programming. Volume 3:
* Sorting and Searching. Reading, Massachusetts: Addison-Wesley, 1973.
*
* [Larson88] Per-Ake Larson. "Dynamic Hash Tables". CACM 31(4), April
* 1988, pp. 446-457.
*
*/
 
#include "glxhash.h"
#include <X11/Xfuncproto.h>
 
#define HASH_MAIN 0
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define HASH_MAGIC 0xdeadbeef
#define HASH_DEBUG 0
#define HASH_SIZE 512 /* Good for about 100 entries */
/* If you change this value, you probably
have to change the HashHash hashing
function! */
 
#define HASH_ALLOC malloc
#define HASH_FREE free
#ifndef __GLIBC__
#define HASH_RANDOM_DECL char *ps, rs[256]
#define HASH_RANDOM_INIT(seed) ps = initstate(seed, rs, sizeof(rs))
#define HASH_RANDOM random()
#define HASH_RANDOM_DESTROY setstate(ps)
#else
#define HASH_RANDOM_DECL struct random_data rd; int32_t rv; char rs[256]
#define HASH_RANDOM_INIT(seed) \
do { \
(void) memset(&rd, 0, sizeof(rd)); \
(void) initstate_r(seed, rs, sizeof(rs), &rd); \
} while(0)
#define HASH_RANDOM ((void) random_r(&rd, &rv), rv)
#define HASH_RANDOM_DESTROY
#endif
 
typedef struct __glxHashBucket
{
unsigned long key;
void *value;
struct __glxHashBucket *next;
} __glxHashBucket, *__glxHashBucketPtr;
 
typedef struct __glxHashTable *__glxHashTablePtr;
struct __glxHashTable
{
unsigned long magic;
unsigned long hits; /* At top of linked list */
unsigned long partials; /* Not at top of linked list */
unsigned long misses; /* Not in table */
__glxHashBucketPtr buckets[HASH_SIZE];
int p0;
__glxHashBucketPtr p1;
};
 
static unsigned long
HashHash(unsigned long key)
{
unsigned long hash = 0;
unsigned long tmp = key;
static int init = 0;
static unsigned long scatter[256];
int i;
 
if (!init) {
HASH_RANDOM_DECL;
HASH_RANDOM_INIT(37);
for (i = 0; i < 256; i++)
scatter[i] = HASH_RANDOM;
HASH_RANDOM_DESTROY;
++init;
}
 
while (tmp) {
hash = (hash << 1) + scatter[tmp & 0xff];
tmp >>= 8;
}
 
hash %= HASH_SIZE;
#if HASH_DEBUG
printf("Hash(%d) = %d\n", key, hash);
#endif
return hash;
}
 
_X_HIDDEN __glxHashTable *
__glxHashCreate(void)
{
__glxHashTablePtr table;
int i;
 
table = HASH_ALLOC(sizeof(*table));
if (!table)
return NULL;
table->magic = HASH_MAGIC;
table->hits = 0;
table->partials = 0;
table->misses = 0;
 
for (i = 0; i < HASH_SIZE; i++)
table->buckets[i] = NULL;
return table;
}
 
_X_HIDDEN int
__glxHashDestroy(__glxHashTable * t)
{
__glxHashTablePtr table = (__glxHashTablePtr) t;
__glxHashBucketPtr bucket;
__glxHashBucketPtr next;
int i;
 
if (table->magic != HASH_MAGIC)
return -1; /* Bad magic */
 
for (i = 0; i < HASH_SIZE; i++) {
for (bucket = table->buckets[i]; bucket;) {
next = bucket->next;
HASH_FREE(bucket);
bucket = next;
}
}
HASH_FREE(table);
return 0;
}
 
/* Find the bucket and organize the list so that this bucket is at the
top. */
 
static __glxHashBucketPtr
HashFind(__glxHashTablePtr table, unsigned long key, unsigned long *h)
{
unsigned long hash = HashHash(key);
__glxHashBucketPtr prev = NULL;
__glxHashBucketPtr bucket;
 
if (h)
*h = hash;
 
for (bucket = table->buckets[hash]; bucket; bucket = bucket->next) {
if (bucket->key == key) {
if (prev) {
/* Organize */
prev->next = bucket->next;
bucket->next = table->buckets[hash];
table->buckets[hash] = bucket;
++table->partials;
}
else {
++table->hits;
}
return bucket;
}
prev = bucket;
}
++table->misses;
return NULL;
}
 
_X_HIDDEN int
__glxHashLookup(__glxHashTable * t, unsigned long key, void **value)
{
__glxHashTablePtr table = (__glxHashTablePtr) t;
__glxHashBucketPtr bucket;
 
if (!table || table->magic != HASH_MAGIC)
return -1; /* Bad magic */
 
bucket = HashFind(table, key, NULL);
if (!bucket)
return 1; /* Not found */
*value = bucket->value;
return 0; /* Found */
}
 
_X_HIDDEN int
__glxHashInsert(__glxHashTable * t, unsigned long key, void *value)
{
__glxHashTablePtr table = (__glxHashTablePtr) t;
__glxHashBucketPtr bucket;
unsigned long hash;
 
if (table->magic != HASH_MAGIC)
return -1; /* Bad magic */
 
if (HashFind(table, key, &hash))
return 1; /* Already in table */
 
bucket = HASH_ALLOC(sizeof(*bucket));
if (!bucket)
return -1; /* Error */
bucket->key = key;
bucket->value = value;
bucket->next = table->buckets[hash];
table->buckets[hash] = bucket;
#if HASH_DEBUG
printf("Inserted %d at %d/%p\n", key, hash, bucket);
#endif
return 0; /* Added to table */
}
 
_X_HIDDEN int
__glxHashDelete(__glxHashTable * t, unsigned long key)
{
__glxHashTablePtr table = (__glxHashTablePtr) t;
unsigned long hash;
__glxHashBucketPtr bucket;
 
if (table->magic != HASH_MAGIC)
return -1; /* Bad magic */
 
bucket = HashFind(table, key, &hash);
 
if (!bucket)
return 1; /* Not found */
 
table->buckets[hash] = bucket->next;
HASH_FREE(bucket);
return 0;
}
 
_X_HIDDEN int
__glxHashNext(__glxHashTable * t, unsigned long *key, void **value)
{
__glxHashTablePtr table = (__glxHashTablePtr) t;
 
while (table->p0 < HASH_SIZE) {
if (table->p1) {
*key = table->p1->key;
*value = table->p1->value;
table->p1 = table->p1->next;
return 1;
}
table->p1 = table->buckets[table->p0];
++table->p0;
}
return 0;
}
 
_X_HIDDEN int
__glxHashFirst(__glxHashTable * t, unsigned long *key, void **value)
{
__glxHashTablePtr table = (__glxHashTablePtr) t;
 
if (table->magic != HASH_MAGIC)
return -1; /* Bad magic */
 
table->p0 = 0;
table->p1 = table->buckets[0];
return __glxHashNext(table, key, value);
}
 
#if HASH_MAIN
#define DIST_LIMIT 10
static int dist[DIST_LIMIT];
 
static void
clear_dist(void)
{
int i;
 
for (i = 0; i < DIST_LIMIT; i++)
dist[i] = 0;
}
 
static int
count_entries(__glxHashBucketPtr bucket)
{
int count = 0;
 
for (; bucket; bucket = bucket->next)
++count;
return count;
}
 
static void
update_dist(int count)
{
if (count >= DIST_LIMIT)
++dist[DIST_LIMIT - 1];
else
++dist[count];
}
 
static void
compute_dist(__glxHashTablePtr table)
{
int i;
__glxHashBucketPtr bucket;
 
printf("Hits = %ld, partials = %ld, misses = %ld\n",
table->hits, table->partials, table->misses);
clear_dist();
for (i = 0; i < HASH_SIZE; i++) {
bucket = table->buckets[i];
update_dist(count_entries(bucket));
}
for (i = 0; i < DIST_LIMIT; i++) {
if (i != DIST_LIMIT - 1)
printf("%5d %10d\n", i, dist[i]);
else
printf("other %10d\n", dist[i]);
}
}
 
static void
check_table(__glxHashTablePtr table, unsigned long key, unsigned long value)
{
unsigned long retval = 0;
int retcode = __glxHashLookup(table, key, &retval);
 
switch (retcode) {
case -1:
printf("Bad magic = 0x%08lx:"
" key = %lu, expected = %lu, returned = %lu\n",
table->magic, key, value, retval);
break;
case 1:
printf("Not found: key = %lu, expected = %lu returned = %lu\n",
key, value, retval);
break;
case 0:
if (value != retval)
printf("Bad value: key = %lu, expected = %lu, returned = %lu\n",
key, value, retval);
break;
default:
printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n",
retcode, key, value, retval);
break;
}
}
 
int
main(void)
{
__glxHashTablePtr table;
int i;
 
printf("\n***** 256 consecutive integers ****\n");
table = __glxHashCreate();
for (i = 0; i < 256; i++)
__glxHashInsert(table, i, i);
for (i = 0; i < 256; i++)
check_table(table, i, i);
for (i = 256; i >= 0; i--)
check_table(table, i, i);
compute_dist(table);
__glxHashDestroy(table);
 
printf("\n***** 1024 consecutive integers ****\n");
table = __glxHashCreate();
for (i = 0; i < 1024; i++)
__glxHashInsert(table, i, i);
for (i = 0; i < 1024; i++)
check_table(table, i, i);
for (i = 1024; i >= 0; i--)
check_table(table, i, i);
compute_dist(table);
__glxHashDestroy(table);
 
printf("\n***** 1024 consecutive page addresses (4k pages) ****\n");
table = __glxHashCreate();
for (i = 0; i < 1024; i++)
__glxHashInsert(table, i * 4096, i);
for (i = 0; i < 1024; i++)
check_table(table, i * 4096, i);
for (i = 1024; i >= 0; i--)
check_table(table, i * 4096, i);
compute_dist(table);
__glxHashDestroy(table);
 
printf("\n***** 1024 random integers ****\n");
table = __glxHashCreate();
srandom(0xbeefbeef);
for (i = 0; i < 1024; i++)
__glxHashInsert(table, random(), i);
srandom(0xbeefbeef);
for (i = 0; i < 1024; i++)
check_table(table, random(), i);
srandom(0xbeefbeef);
for (i = 0; i < 1024; i++)
check_table(table, random(), i);
compute_dist(table);
__glxHashDestroy(table);
 
printf("\n***** 5000 random integers ****\n");
table = __glxHashCreate();
srandom(0xbeefbeef);
for (i = 0; i < 5000; i++)
__glxHashInsert(table, random(), i);
srandom(0xbeefbeef);
for (i = 0; i < 5000; i++)
check_table(table, random(), i);
srandom(0xbeefbeef);
for (i = 0; i < 5000; i++)
check_table(table, random(), i);
compute_dist(table);
__glxHashDestroy(table);
 
return 0;
}
#endif
/contrib/sdk/sources/Mesa/src/glx/glxhash.h
0,0 → 1,20
#ifndef _GLX_HASH_H_
#define _GLX_HASH_H_
 
 
typedef struct __glxHashTable __glxHashTable;
 
/* Hash table routines */
extern __glxHashTable *__glxHashCreate(void);
extern int __glxHashDestroy(__glxHashTable * t);
extern int __glxHashLookup(__glxHashTable * t, unsigned long key,
void **value);
extern int __glxHashInsert(__glxHashTable * t, unsigned long key,
void *value);
extern int __glxHashDelete(__glxHashTable * t, unsigned long key);
extern int __glxHashFirst(__glxHashTable * t, unsigned long *key,
void **value);
extern int __glxHashNext(__glxHashTable * t, unsigned long *key,
void **value);
 
#endif /* _GLX_HASH_H_ */
/contrib/sdk/sources/Mesa/src/glx/indirect_glx.c
0,0 → 1,485
/*
* Copyright © 2010 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Soft-
* ware"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, provided that the above copyright
* notice(s) and this permission notice appear in all copies of the Soft-
* ware and that both the above copyright notice(s) and this permission
* notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
* QUENTIAL 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 PERFOR-
* MANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder shall
* not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization of
* the copyright holder.
*
* Authors:
* Kristian Høgsberg (krh@bitplanet.net)
*/
 
#include "glapi.h"
#include "glxclient.h"
 
extern struct _glapi_table *__glXNewIndirectAPI(void);
 
/*
** All indirect rendering contexts will share the same indirect dispatch table.
*/
static struct _glapi_table *IndirectAPI = NULL;
 
static void
indirect_destroy_context(struct glx_context *gc)
{
__glXFreeVertexArrayState(gc);
 
free((char *) gc->vendor);
free((char *) gc->renderer);
free((char *) gc->version);
free((char *) gc->extensions);
__glFreeAttributeState(gc);
free((char *) gc->buf);
free((char *) gc->client_state_private);
free((char *) gc);
}
 
static Bool
SendMakeCurrentRequest(Display * dpy, CARD8 opcode,
GLXContextID gc_id, GLXContextTag gc_tag,
GLXDrawable draw, GLXDrawable read,
xGLXMakeCurrentReply * reply)
{
Bool ret;
 
LockDisplay(dpy);
 
if (draw == read) {
xGLXMakeCurrentReq *req;
 
GetReq(GLXMakeCurrent, req);
req->reqType = opcode;
req->glxCode = X_GLXMakeCurrent;
req->drawable = draw;
req->context = gc_id;
req->oldContextTag = gc_tag;
}
else {
struct glx_display *priv = __glXInitialize(dpy);
 
/* If the server can support the GLX 1.3 version, we should
* perfer that. Not only that, some servers support GLX 1.3 but
* not the SGI extension.
*/
 
if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
xGLXMakeContextCurrentReq *req;
 
GetReq(GLXMakeContextCurrent, req);
req->reqType = opcode;
req->glxCode = X_GLXMakeContextCurrent;
req->drawable = draw;
req->readdrawable = read;
req->context = gc_id;
req->oldContextTag = gc_tag;
}
else {
xGLXVendorPrivateWithReplyReq *vpreq;
xGLXMakeCurrentReadSGIReq *req;
 
GetReqExtra(GLXVendorPrivateWithReply,
sz_xGLXMakeCurrentReadSGIReq -
sz_xGLXVendorPrivateWithReplyReq, vpreq);
req = (xGLXMakeCurrentReadSGIReq *) vpreq;
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivateWithReply;
req->vendorCode = X_GLXvop_MakeCurrentReadSGI;
req->drawable = draw;
req->readable = read;
req->context = gc_id;
req->oldContextTag = gc_tag;
}
}
 
ret = _XReply(dpy, (xReply *) reply, 0, False);
 
UnlockDisplay(dpy);
SyncHandle();
 
return ret;
}
 
static int
indirect_bind_context(struct glx_context *gc, struct glx_context *old,
GLXDrawable draw, GLXDrawable read)
{
xGLXMakeCurrentReply reply;
GLXContextTag tag;
__GLXattribute *state;
Display *dpy = gc->psc->dpy;
int opcode = __glXSetupForCommand(dpy);
 
if (old != &dummyContext && !old->isDirect && old->psc->dpy == dpy) {
tag = old->currentContextTag;
old->currentContextTag = 0;
} else {
tag = 0;
}
 
SendMakeCurrentRequest(dpy, opcode, gc->xid, tag, draw, read, &reply);
 
if (!IndirectAPI)
IndirectAPI = __glXNewIndirectAPI();
_glapi_set_dispatch(IndirectAPI);
 
gc->currentContextTag = reply.contextTag;
state = gc->client_state_private;
if (state->array_state == NULL) {
glGetString(GL_EXTENSIONS);
glGetString(GL_VERSION);
__glXInitVertexArrayState(gc);
}
 
return Success;
}
 
static void
indirect_unbind_context(struct glx_context *gc, struct glx_context *new)
{
Display *dpy = gc->psc->dpy;
int opcode = __glXSetupForCommand(dpy);
xGLXMakeCurrentReply reply;
 
if (gc == new)
return;
/* We are either switching to no context, away from a indirect
* context to a direct context or from one dpy to another and have
* to send a request to the dpy to unbind the previous context.
*/
if (!new || new->isDirect || new->psc->dpy != dpy) {
SendMakeCurrentRequest(dpy, opcode, None,
gc->currentContextTag, None, None, &reply);
gc->currentContextTag = 0;
}
}
 
static void
indirect_wait_gl(struct glx_context *gc)
{
xGLXWaitGLReq *req;
Display *dpy = gc->currentDpy;
 
/* Flush any pending commands out */
__glXFlushRenderBuffer(gc, gc->pc);
 
/* Send the glXWaitGL request */
LockDisplay(dpy);
GetReq(GLXWaitGL, req);
req->reqType = gc->majorOpcode;
req->glxCode = X_GLXWaitGL;
req->contextTag = gc->currentContextTag;
UnlockDisplay(dpy);
SyncHandle();
}
 
static void
indirect_wait_x(struct glx_context *gc)
{
xGLXWaitXReq *req;
Display *dpy = gc->currentDpy;
 
/* Flush any pending commands out */
__glXFlushRenderBuffer(gc, gc->pc);
 
LockDisplay(dpy);
GetReq(GLXWaitX, req);
req->reqType = gc->majorOpcode;
req->glxCode = X_GLXWaitX;
req->contextTag = gc->currentContextTag;
UnlockDisplay(dpy);
SyncHandle();
}
 
static void
indirect_use_x_font(struct glx_context *gc,
Font font, int first, int count, int listBase)
{
xGLXUseXFontReq *req;
Display *dpy = gc->currentDpy;
 
/* Flush any pending commands out */
__glXFlushRenderBuffer(gc, gc->pc);
 
/* Send the glXUseFont request */
LockDisplay(dpy);
GetReq(GLXUseXFont, req);
req->reqType = gc->majorOpcode;
req->glxCode = X_GLXUseXFont;
req->contextTag = gc->currentContextTag;
req->font = font;
req->first = first;
req->count = count;
req->listBase = listBase;
UnlockDisplay(dpy);
SyncHandle();
}
 
static void
indirect_bind_tex_image(Display * dpy,
GLXDrawable drawable,
int buffer, const int *attrib_list)
{
xGLXVendorPrivateReq *req;
struct glx_context *gc = __glXGetCurrentContext();
CARD32 *drawable_ptr;
INT32 *buffer_ptr;
CARD32 *num_attrib_ptr;
CARD32 *attrib_ptr;
CARD8 opcode;
unsigned int i;
 
i = 0;
if (attrib_list) {
while (attrib_list[i * 2] != None)
i++;
}
 
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return;
 
LockDisplay(dpy);
GetReqExtra(GLXVendorPrivate, 12 + 8 * i, req);
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivate;
req->vendorCode = X_GLXvop_BindTexImageEXT;
req->contextTag = gc->currentContextTag;
 
drawable_ptr = (CARD32 *) (req + 1);
buffer_ptr = (INT32 *) (drawable_ptr + 1);
num_attrib_ptr = (CARD32 *) (buffer_ptr + 1);
attrib_ptr = (CARD32 *) (num_attrib_ptr + 1);
 
*drawable_ptr = drawable;
*buffer_ptr = buffer;
*num_attrib_ptr = (CARD32) i;
 
i = 0;
if (attrib_list) {
while (attrib_list[i * 2] != None) {
*attrib_ptr++ = (CARD32) attrib_list[i * 2 + 0];
*attrib_ptr++ = (CARD32) attrib_list[i * 2 + 1];
i++;
}
}
 
UnlockDisplay(dpy);
SyncHandle();
}
 
static void
indirect_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
{
xGLXVendorPrivateReq *req;
struct glx_context *gc = __glXGetCurrentContext();
CARD32 *drawable_ptr;
INT32 *buffer_ptr;
CARD8 opcode;
 
opcode = __glXSetupForCommand(dpy);
if (!opcode)
return;
 
LockDisplay(dpy);
GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32), req);
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivate;
req->vendorCode = X_GLXvop_ReleaseTexImageEXT;
req->contextTag = gc->currentContextTag;
 
drawable_ptr = (CARD32 *) (req + 1);
buffer_ptr = (INT32 *) (drawable_ptr + 1);
 
*drawable_ptr = drawable;
*buffer_ptr = buffer;
 
UnlockDisplay(dpy);
SyncHandle();
}
 
static const struct glx_context_vtable indirect_context_vtable = {
indirect_destroy_context,
indirect_bind_context,
indirect_unbind_context,
indirect_wait_gl,
indirect_wait_x,
indirect_use_x_font,
indirect_bind_tex_image,
indirect_release_tex_image,
NULL, /* get_proc_address */
};
 
/**
* \todo Eliminate \c __glXInitVertexArrayState. Replace it with a new
* function called \c __glXAllocateClientState that allocates the memory and
* does all the initialization (including the pixel pack / unpack).
*
* \note
* This function is \b not the place to validate the context creation
* parameters. It is just the allocator for the \c glx_context.
*/
_X_HIDDEN struct glx_context *
indirect_create_context(struct glx_screen *psc,
struct glx_config *mode,
struct glx_context *shareList, int renderType)
{
struct glx_context *gc;
int bufSize;
CARD8 opcode;
__GLXattribute *state;
 
opcode = __glXSetupForCommand(psc->dpy);
if (!opcode) {
return NULL;
}
 
/* Allocate our context record */
gc = calloc(1, sizeof *gc);
if (!gc) {
/* Out of memory */
return NULL;
}
 
glx_context_init(gc, psc, mode);
gc->isDirect = GL_FALSE;
gc->vtable = &indirect_context_vtable;
state = calloc(1, sizeof(struct __GLXattributeRec));
gc->renderType = renderType;
 
if (state == NULL) {
/* Out of memory */
free(gc);
return NULL;
}
gc->client_state_private = state;
state->NoDrawArraysProtocol = (getenv("LIBGL_NO_DRAWARRAYS") != NULL);
 
/*
** Create a temporary buffer to hold GLX rendering commands. The size
** of the buffer is selected so that the maximum number of GLX rendering
** commands can fit in a single X packet and still have room in the X
** packet for the GLXRenderReq header.
*/
 
bufSize = (XMaxRequestSize(psc->dpy) * 4) - sz_xGLXRenderReq;
gc->buf = malloc(bufSize);
if (!gc->buf) {
free(gc->client_state_private);
free(gc);
return NULL;
}
gc->bufSize = bufSize;
 
/* Fill in the new context */
gc->renderMode = GL_RENDER;
 
state->storePack.alignment = 4;
state->storeUnpack.alignment = 4;
 
gc->attributes.stackPointer = &gc->attributes.stack[0];
 
/*
** PERFORMANCE NOTE: A mode dependent fill image can speed things up.
*/
gc->fillImage = __glFillImage;
gc->pc = gc->buf;
gc->bufEnd = gc->buf + bufSize;
gc->isDirect = GL_FALSE;
if (__glXDebug) {
/*
** Set limit register so that there will be one command per packet
*/
gc->limit = gc->buf;
}
else {
gc->limit = gc->buf + bufSize - __GLX_BUFFER_LIMIT_SIZE;
}
gc->majorOpcode = opcode;
 
/*
** Constrain the maximum drawing command size allowed to be
** transfered using the X_GLXRender protocol request. First
** constrain by a software limit, then constrain by the protocl
** limit.
*/
if (bufSize > __GLX_RENDER_CMD_SIZE_LIMIT) {
bufSize = __GLX_RENDER_CMD_SIZE_LIMIT;
}
if (bufSize > __GLX_MAX_RENDER_CMD_SIZE) {
bufSize = __GLX_MAX_RENDER_CMD_SIZE;
}
gc->maxSmallRenderCommandSize = bufSize;
 
return gc;
}
 
_X_HIDDEN struct glx_context *
indirect_create_context_attribs(struct glx_screen *base,
struct glx_config *config_base,
struct glx_context *shareList,
unsigned num_attribs,
const uint32_t *attribs,
unsigned *error)
{
int renderType = GLX_RGBA_TYPE;
unsigned i;
 
/* The error parameter is only used on the server so that correct GLX
* protocol errors can be generated. On the client, it can be ignored.
*/
(void) error;
 
/* All of the attribute validation for indirect contexts is handled on the
* server, so there's not much to do here. Still, we need to parse the
* attributes to correctly set renderType.
*/
for (i = 0; i < num_attribs; i++) {
if (attribs[i * 2] == GLX_RENDER_TYPE)
renderType = attribs[i * 2 + 1];
}
 
return indirect_create_context(base, config_base, shareList, renderType);
}
 
struct glx_screen_vtable indirect_screen_vtable = {
indirect_create_context,
indirect_create_context_attribs
};
 
_X_HIDDEN struct glx_screen *
indirect_create_screen(int screen, struct glx_display * priv)
{
struct glx_screen *psc;
 
psc = calloc(1, sizeof *psc);
if (psc == NULL)
return NULL;
 
glx_screen_init(psc, screen, priv);
psc->vtable = &indirect_screen_vtable;
 
return psc;
}
/contrib/sdk/sources/Mesa/src/glx/indirect_init.h
0,0 → 1,41
/**************************************************************************
 
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
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 PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
**************************************************************************/
 
/*
* Authors:
* Kevin E. Martin <kevin@precisioninsight.com>
*
*/
 
#ifndef _INDIRECT_INIT_H_
#define _INDIRECT_INIT_H_
 
#include "glxclient.h"
 
extern struct _glapi_table *__glXNewIndirectAPI(void);
 
#endif /* _INDIRECT_INIT_H_ */
/contrib/sdk/sources/Mesa/src/glx/indirect_texture_compression.c
0,0 → 1,343
/*
* (C) Copyright IBM Corporation 2004
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS AND/OR THEIR 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.
*/
 
/**
* \file glx_texture_compression.c
* Contains the routines required to implement GLX protocol for
* ARB_texture_compression and related extensions.
*
* \sa http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_compression.txt
*
* \author Ian Romanick <idr@us.ibm.com>
*/
 
#include "packrender.h"
#include "packsingle.h"
#include "indirect.h"
 
#include <assert.h>
 
 
void
__indirect_glGetCompressedTexImage(GLenum target, GLint level,
GLvoid * img)
{
__GLX_SINGLE_DECLARE_VARIABLES();
xGLXGetTexImageReply reply;
size_t image_bytes;
 
__GLX_SINGLE_LOAD_VARIABLES();
__GLX_SINGLE_BEGIN(X_GLsop_GetCompressedTexImage, 8);
__GLX_SINGLE_PUT_LONG(0, target);
__GLX_SINGLE_PUT_LONG(4, level);
__GLX_SINGLE_READ_XREPLY();
 
image_bytes = reply.width;
assert(image_bytes <= ((4 * reply.length) - 0));
assert(image_bytes >= ((4 * reply.length) - 3));
 
if (image_bytes != 0) {
_XRead(dpy, (char *) img, image_bytes);
if (image_bytes < (4 * reply.length)) {
_XEatData(dpy, (4 * reply.length) - image_bytes);
}
}
 
__GLX_SINGLE_END();
}
 
 
/**
* Internal function used for \c glCompressedTexImage1D and
* \c glCompressedTexImage2D.
*/
static void
CompressedTexImage1D2D(GLenum target, GLint level,
GLenum internal_format,
GLsizei width, GLsizei height,
GLint border, GLsizei image_size,
const GLvoid * data, CARD32 rop)
{
__GLX_DECLARE_VARIABLES();
 
__GLX_LOAD_VARIABLES();
if (gc->currentDpy == NULL) {
return;
}
 
if ((target == GL_PROXY_TEXTURE_1D)
|| (target == GL_PROXY_TEXTURE_2D)
|| (target == GL_PROXY_TEXTURE_CUBE_MAP)) {
compsize = 0;
}
else {
compsize = image_size;
}
 
cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE + compsize);
if (cmdlen <= gc->maxSmallRenderCommandSize) {
__GLX_BEGIN_VARIABLE(rop, cmdlen);
__GLX_PUT_LONG(4, target);
__GLX_PUT_LONG(8, level);
__GLX_PUT_LONG(12, internal_format);
__GLX_PUT_LONG(16, width);
__GLX_PUT_LONG(20, height);
__GLX_PUT_LONG(24, border);
__GLX_PUT_LONG(28, image_size);
if (compsize != 0) {
__GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE,
data, image_size);
}
__GLX_END(cmdlen);
}
else {
assert(compsize != 0);
 
__GLX_BEGIN_VARIABLE_LARGE(rop, cmdlen + 4);
__GLX_PUT_LONG(8, target);
__GLX_PUT_LONG(12, level);
__GLX_PUT_LONG(16, internal_format);
__GLX_PUT_LONG(20, width);
__GLX_PUT_LONG(24, height);
__GLX_PUT_LONG(28, border);
__GLX_PUT_LONG(32, image_size);
__glXSendLargeCommand(gc, gc->pc,
__GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE + 4,
data, image_size);
}
}
 
 
/**
* Internal function used for \c glCompressedTexSubImage1D and
* \c glCompressedTexSubImage2D.
*/
static void
CompressedTexSubImage1D2D(GLenum target, GLint level,
GLsizei xoffset, GLsizei yoffset,
GLsizei width, GLsizei height,
GLenum format, GLsizei image_size,
const GLvoid * data, CARD32 rop)
{
__GLX_DECLARE_VARIABLES();
 
__GLX_LOAD_VARIABLES();
if (gc->currentDpy == NULL) {
return;
}
 
if (target == GL_PROXY_TEXTURE_3D) {
compsize = 0;
}
else {
compsize = image_size;
}
 
cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE + compsize);
if (cmdlen <= gc->maxSmallRenderCommandSize) {
__GLX_BEGIN_VARIABLE(rop, cmdlen);
__GLX_PUT_LONG(4, target);
__GLX_PUT_LONG(8, level);
__GLX_PUT_LONG(12, xoffset);
__GLX_PUT_LONG(16, yoffset);
__GLX_PUT_LONG(20, width);
__GLX_PUT_LONG(24, height);
__GLX_PUT_LONG(28, format);
__GLX_PUT_LONG(32, image_size);
if (compsize != 0) {
__GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE,
data, image_size);
}
__GLX_END(cmdlen);
}
else {
assert(compsize != 0);
 
__GLX_BEGIN_VARIABLE_LARGE(rop, cmdlen + 4);
__GLX_PUT_LONG(8, target);
__GLX_PUT_LONG(12, level);
__GLX_PUT_LONG(16, xoffset);
__GLX_PUT_LONG(20, yoffset);
__GLX_PUT_LONG(24, width);
__GLX_PUT_LONG(28, height);
__GLX_PUT_LONG(32, format);
__GLX_PUT_LONG(36, image_size);
__glXSendLargeCommand(gc, gc->pc,
__GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE + 4,
data, image_size);
}
}
 
 
void
__indirect_glCompressedTexImage1D(GLenum target, GLint level,
GLenum internal_format, GLsizei width,
GLint border, GLsizei image_size,
const GLvoid * data)
{
CompressedTexImage1D2D(target, level, internal_format, width, 0,
border, image_size, data,
X_GLrop_CompressedTexImage1D);
}
 
 
void
__indirect_glCompressedTexImage2D(GLenum target, GLint level,
GLenum internal_format,
GLsizei width, GLsizei height,
GLint border, GLsizei image_size,
const GLvoid * data)
{
CompressedTexImage1D2D(target, level, internal_format, width, height,
border, image_size, data,
X_GLrop_CompressedTexImage2D);
}
 
 
void
__indirect_glCompressedTexImage3D(GLenum target, GLint level,
GLenum internal_format,
GLsizei width, GLsizei height,
GLsizei depth, GLint border,
GLsizei image_size, const GLvoid * data)
{
__GLX_DECLARE_VARIABLES();
 
__GLX_LOAD_VARIABLES();
if (gc->currentDpy == NULL) {
return;
}
 
cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE + image_size);
if (cmdlen <= gc->maxSmallRenderCommandSize) {
__GLX_BEGIN_VARIABLE(X_GLrop_CompressedTexImage3D, cmdlen);
__GLX_PUT_LONG(4, target);
__GLX_PUT_LONG(8, level);
__GLX_PUT_LONG(12, internal_format);
__GLX_PUT_LONG(16, width);
__GLX_PUT_LONG(20, height);
__GLX_PUT_LONG(24, depth);
__GLX_PUT_LONG(28, border);
__GLX_PUT_LONG(32, image_size);
if (image_size != 0) {
__GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE,
data, image_size);
}
__GLX_END(cmdlen);
}
else {
__GLX_BEGIN_VARIABLE_LARGE(X_GLrop_CompressedTexImage3D, cmdlen + 4);
__GLX_PUT_LONG(8, target);
__GLX_PUT_LONG(12, level);
__GLX_PUT_LONG(16, internal_format);
__GLX_PUT_LONG(20, width);
__GLX_PUT_LONG(24, height);
__GLX_PUT_LONG(28, depth);
__GLX_PUT_LONG(32, border);
__GLX_PUT_LONG(36, image_size);
__glXSendLargeCommand(gc, gc->pc,
__GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE + 4,
data, image_size);
}
}
 
 
void
__indirect_glCompressedTexSubImage1D(GLenum target, GLint level,
GLint xoffset,
GLsizei width,
GLenum format, GLsizei image_size,
const GLvoid * data)
{
CompressedTexSubImage1D2D(target, level, xoffset, 0, width, 0,
format, image_size, data,
X_GLrop_CompressedTexSubImage1D);
}
 
 
void
__indirect_glCompressedTexSubImage2D(GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height,
GLenum format, GLsizei image_size,
const GLvoid * data)
{
CompressedTexSubImage1D2D(target, level, xoffset, yoffset, width, height,
format, image_size, data,
X_GLrop_CompressedTexSubImage2D);
}
 
 
void
__indirect_glCompressedTexSubImage3D(GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLint zoffset, GLsizei width,
GLsizei height, GLsizei depth,
GLenum format, GLsizei image_size,
const GLvoid * data)
{
__GLX_DECLARE_VARIABLES();
 
__GLX_LOAD_VARIABLES();
if (gc->currentDpy == NULL) {
return;
}
 
cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE
+ image_size);
if (cmdlen <= gc->maxSmallRenderCommandSize) {
__GLX_BEGIN_VARIABLE(X_GLrop_CompressedTexSubImage3D, cmdlen);
__GLX_PUT_LONG(4, target);
__GLX_PUT_LONG(8, level);
__GLX_PUT_LONG(12, xoffset);
__GLX_PUT_LONG(16, yoffset);
__GLX_PUT_LONG(20, zoffset);
__GLX_PUT_LONG(24, width);
__GLX_PUT_LONG(28, height);
__GLX_PUT_LONG(32, depth);
__GLX_PUT_LONG(36, format);
__GLX_PUT_LONG(40, image_size);
if (image_size != 0) {
__GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE,
data, image_size);
}
__GLX_END(cmdlen);
}
else {
__GLX_BEGIN_VARIABLE_LARGE(X_GLrop_CompressedTexSubImage3D, cmdlen + 4);
__GLX_PUT_LONG(8, target);
__GLX_PUT_LONG(12, level);
__GLX_PUT_LONG(16, xoffset);
__GLX_PUT_LONG(20, yoffset);
__GLX_PUT_LONG(24, zoffset);
__GLX_PUT_LONG(28, width);
__GLX_PUT_LONG(32, height);
__GLX_PUT_LONG(36, depth);
__GLX_PUT_LONG(40, format);
__GLX_PUT_LONG(44, image_size);
__glXSendLargeCommand(gc, gc->pc,
__GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE + 4,
data, image_size);
}
}
/contrib/sdk/sources/Mesa/src/glx/indirect_transpose_matrix.c
0,0 → 1,85
/*
* (C) Copyright IBM Corporation 2004
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS AND/OR THEIR 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 <GL/gl.h>
#include "indirect.h"
 
static void
TransposeMatrixf(const GLfloat s[16], GLfloat d[16])
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
d[i * 4 + j] = s[j * 4 + i];
}
}
}
 
static void
TransposeMatrixd(const GLdouble s[16], GLdouble d[16])
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
d[i * 4 + j] = s[j * 4 + i];
}
}
}
 
 
void
__indirect_glLoadTransposeMatrixd(const GLdouble * m)
{
GLdouble mt[16];
 
TransposeMatrixd(m, mt);
__indirect_glLoadMatrixd(mt);
}
 
void
__indirect_glLoadTransposeMatrixf(const GLfloat * m)
{
GLfloat mt[16];
 
TransposeMatrixf(m, mt);
__indirect_glLoadMatrixf(mt);
}
 
void
__indirect_glMultTransposeMatrixd(const GLdouble * m)
{
GLdouble mt[16];
 
TransposeMatrixd(m, mt);
__indirect_glMultMatrixd(mt);
}
 
void
__indirect_glMultTransposeMatrixf(const GLfloat * m)
{
GLfloat mt[16];
 
TransposeMatrixf(m, mt);
__indirect_glMultMatrixf(mt);
}
/contrib/sdk/sources/Mesa/src/glx/indirect_vertex_array.c
0,0 → 1,1982
/*
* (C) Copyright IBM Corporation 2004, 2005
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* IBM,
* AND/OR THEIR 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 <inttypes.h>
#include <assert.h>
#include <string.h>
 
#include "glxclient.h"
#include "indirect.h"
#include <GL/glxproto.h>
#include "glxextensions.h"
#include "indirect_vertex_array.h"
#include "indirect_vertex_array_priv.h"
 
#define __GLX_PAD(n) (((n)+3) & ~3)
 
/**
* \file indirect_vertex_array.c
* Implement GLX protocol for vertex arrays and vertex buffer objects.
*
* The most important function in this fill is \c fill_array_info_cache.
* The \c array_state_vector contains a cache of the ARRAY_INFO data sent
* in the DrawArrays protocol. Certain operations, such as enabling or
* disabling an array, can invalidate this cache. \c fill_array_info_cache
* fills-in this data. Additionally, it examines the enabled state and
* other factors to determine what "version" of DrawArrays protocoal can be
* used.
*
* Current, only two versions of DrawArrays protocol are implemented. The
* first version is the "none" protocol. This is the fallback when the
* server does not support GL 1.1 / EXT_vertex_arrays. It is implemented
* by sending batches of immediate mode commands that are equivalent to the
* DrawArrays protocol.
*
* The other protocol that is currently implemented is the "old" protocol.
* This is the GL 1.1 DrawArrays protocol. The only difference between GL
* 1.1 and EXT_vertex_arrays is the opcode used for the DrawArrays command.
* This protocol is called "old" because the ARB is in the process of
* defining a new protocol, which will probably be called wither "new" or
* "vbo", to support multiple texture coordinate arrays, generic attributes,
* and vertex buffer objects.
*
* \author Ian Romanick <ian.d.romanick@intel.com>
*/
 
static void emit_DrawArrays_none(GLenum mode, GLint first, GLsizei count);
static void emit_DrawArrays_old(GLenum mode, GLint first, GLsizei count);
 
static void emit_DrawElements_none(GLenum mode, GLsizei count, GLenum type,
const GLvoid * indices);
static void emit_DrawElements_old(GLenum mode, GLsizei count, GLenum type,
const GLvoid * indices);
 
 
static GLubyte *emit_element_none(GLubyte * dst,
const struct array_state_vector *arrays,
unsigned index);
static GLubyte *emit_element_old(GLubyte * dst,
const struct array_state_vector *arrays,
unsigned index);
static struct array_state *get_array_entry(const struct array_state_vector
*arrays, GLenum key,
unsigned index);
static void fill_array_info_cache(struct array_state_vector *arrays);
static GLboolean validate_mode(struct glx_context * gc, GLenum mode);
static GLboolean validate_count(struct glx_context * gc, GLsizei count);
static GLboolean validate_type(struct glx_context * gc, GLenum type);
 
 
/**
* Table of sizes, in bytes, of a GL types. All of the type enums are be in
* the range 0x1400 - 0x140F. That includes types added by extensions (i.e.,
* \c GL_HALF_FLOAT_NV). This elements of this table correspond to the
* type enums masked with 0x0f.
*
* \notes
* \c GL_HALF_FLOAT_NV is not included. Neither are \c GL_2_BYTES,
* \c GL_3_BYTES, or \c GL_4_BYTES.
*/
const GLuint __glXTypeSize_table[16] = {
1, 1, 2, 2, 4, 4, 4, 0, 0, 0, 8, 0, 0, 0, 0, 0
};
 
 
/**
* Free the per-context array state that was allocated with
* __glXInitVertexArrayState().
*/
void
__glXFreeVertexArrayState(struct glx_context * gc)
{
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
 
if (arrays) {
free(arrays->stack);
arrays->stack = NULL;
free(arrays->arrays);
arrays->arrays = NULL;
free(arrays);
state->array_state = NULL;
}
}
 
 
/**
* Initialize vertex array state of a GLX context.
*
* \param gc GLX context whose vertex array state is to be initialized.
*
* \warning
* This function may only be called after struct glx_context::gl_extension_bits,
* struct glx_context::server_minor, and __GLXcontext::server_major have been
* initialized. These values are used to determine what vertex arrays are
* supported.
*
* \bug
* Return values from malloc are not properly tested.
*/
void
__glXInitVertexArrayState(struct glx_context * gc)
{
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays;
 
unsigned array_count;
int texture_units = 1, vertex_program_attribs = 0;
unsigned i, j;
 
GLboolean got_fog = GL_FALSE;
GLboolean got_secondary_color = GL_FALSE;
 
 
arrays = calloc(1, sizeof(struct array_state_vector));
state->array_state = arrays;
 
arrays->old_DrawArrays_possible = !state->NoDrawArraysProtocol;
arrays->new_DrawArrays_possible = GL_FALSE;
arrays->DrawArrays = NULL;
 
arrays->active_texture_unit = 0;
 
 
/* Determine how many arrays are actually needed. Only arrays that
* are supported by the server are create. For example, if the server
* supports only 2 texture units, then only 2 texture coordinate arrays
* are created.
*
* At the very least, GL_VERTEX_ARRAY, GL_NORMAL_ARRAY,
* GL_COLOR_ARRAY, GL_INDEX_ARRAY, GL_TEXTURE_COORD_ARRAY, and
* GL_EDGE_FLAG_ARRAY are supported.
*/
 
array_count = 5;
 
if (__glExtensionBitIsEnabled(gc, GL_EXT_fog_coord_bit)
|| (gc->server_major > 1) || (gc->server_minor >= 4)) {
got_fog = GL_TRUE;
array_count++;
}
 
if (__glExtensionBitIsEnabled(gc, GL_EXT_secondary_color_bit)
|| (gc->server_major > 1) || (gc->server_minor >= 4)) {
got_secondary_color = GL_TRUE;
array_count++;
}
 
if (__glExtensionBitIsEnabled(gc, GL_ARB_multitexture_bit)
|| (gc->server_major > 1) || (gc->server_minor >= 3)) {
__indirect_glGetIntegerv(GL_MAX_TEXTURE_UNITS, &texture_units);
}
 
if (__glExtensionBitIsEnabled(gc, GL_ARB_vertex_program_bit)) {
__indirect_glGetProgramivARB(GL_VERTEX_PROGRAM_ARB,
GL_MAX_PROGRAM_ATTRIBS_ARB,
&vertex_program_attribs);
}
 
arrays->num_texture_units = texture_units;
arrays->num_vertex_program_attribs = vertex_program_attribs;
array_count += texture_units + vertex_program_attribs;
arrays->num_arrays = array_count;
arrays->arrays = calloc(array_count, sizeof(struct array_state));
 
arrays->arrays[0].data_type = GL_FLOAT;
arrays->arrays[0].count = 3;
arrays->arrays[0].key = GL_NORMAL_ARRAY;
arrays->arrays[0].normalized = GL_TRUE;
arrays->arrays[0].old_DrawArrays_possible = GL_TRUE;
 
arrays->arrays[1].data_type = GL_FLOAT;
arrays->arrays[1].count = 4;
arrays->arrays[1].key = GL_COLOR_ARRAY;
arrays->arrays[1].normalized = GL_TRUE;
arrays->arrays[1].old_DrawArrays_possible = GL_TRUE;
 
arrays->arrays[2].data_type = GL_FLOAT;
arrays->arrays[2].count = 1;
arrays->arrays[2].key = GL_INDEX_ARRAY;
arrays->arrays[2].old_DrawArrays_possible = GL_TRUE;
 
arrays->arrays[3].data_type = GL_UNSIGNED_BYTE;
arrays->arrays[3].count = 1;
arrays->arrays[3].key = GL_EDGE_FLAG_ARRAY;
arrays->arrays[3].old_DrawArrays_possible = GL_TRUE;
 
for (i = 0; i < texture_units; i++) {
arrays->arrays[4 + i].data_type = GL_FLOAT;
arrays->arrays[4 + i].count = 4;
arrays->arrays[4 + i].key = GL_TEXTURE_COORD_ARRAY;
 
arrays->arrays[4 + i].old_DrawArrays_possible = (i == 0);
arrays->arrays[4 + i].index = i;
 
arrays->arrays[4 + i].header[1] = i + GL_TEXTURE0;
}
 
i = 4 + texture_units;
 
if (got_fog) {
arrays->arrays[i].data_type = GL_FLOAT;
arrays->arrays[i].count = 1;
arrays->arrays[i].key = GL_FOG_COORDINATE_ARRAY;
arrays->arrays[i].old_DrawArrays_possible = GL_TRUE;
i++;
}
 
if (got_secondary_color) {
arrays->arrays[i].data_type = GL_FLOAT;
arrays->arrays[i].count = 3;
arrays->arrays[i].key = GL_SECONDARY_COLOR_ARRAY;
arrays->arrays[i].old_DrawArrays_possible = GL_TRUE;
arrays->arrays[i].normalized = GL_TRUE;
i++;
}
 
 
for (j = 0; j < vertex_program_attribs; j++) {
const unsigned idx = (vertex_program_attribs - (j + 1));
 
 
arrays->arrays[idx + i].data_type = GL_FLOAT;
arrays->arrays[idx + i].count = 4;
arrays->arrays[idx + i].key = GL_VERTEX_ATTRIB_ARRAY_POINTER;
 
arrays->arrays[idx + i].old_DrawArrays_possible = 0;
arrays->arrays[idx + i].index = idx;
 
arrays->arrays[idx + i].header[1] = idx;
}
 
i += vertex_program_attribs;
 
 
/* Vertex array *must* be last becuase of the way that
* emit_DrawArrays_none works.
*/
 
arrays->arrays[i].data_type = GL_FLOAT;
arrays->arrays[i].count = 4;
arrays->arrays[i].key = GL_VERTEX_ARRAY;
arrays->arrays[i].old_DrawArrays_possible = GL_TRUE;
 
assert((i + 1) == arrays->num_arrays);
 
arrays->stack_index = 0;
arrays->stack = malloc(sizeof(struct array_stack_state)
* arrays->num_arrays
* __GL_CLIENT_ATTRIB_STACK_DEPTH);
}
 
 
/**
* Calculate the size of a single vertex for the "none" protocol. This is
* essentially the size of all the immediate-mode commands required to
* implement the enabled vertex arrays.
*/
static size_t
calculate_single_vertex_size_none(const struct array_state_vector *arrays)
{
size_t single_vertex_size = 0;
unsigned i;
 
 
for (i = 0; i < arrays->num_arrays; i++) {
if (arrays->arrays[i].enabled) {
single_vertex_size += ((uint16_t *) arrays->arrays[i].header)[0];
}
}
 
return single_vertex_size;
}
 
 
/**
* Emit a single element using non-DrawArrays protocol.
*/
GLubyte *
emit_element_none(GLubyte * dst,
const struct array_state_vector * arrays, unsigned index)
{
unsigned i;
 
 
for (i = 0; i < arrays->num_arrays; i++) {
if (arrays->arrays[i].enabled) {
const size_t offset = index * arrays->arrays[i].true_stride;
 
/* The generic attributes can have more data than is in the
* elements. This is because a vertex array can be a 2 element,
* normalized, unsigned short, but the "closest" immediate mode
* protocol is for a 4Nus. Since the sizes are small, the
* performance impact on modern processors should be negligible.
*/
(void) memset(dst, 0, ((uint16_t *) arrays->arrays[i].header)[0]);
 
(void) memcpy(dst, arrays->arrays[i].header,
arrays->arrays[i].header_size);
 
dst += arrays->arrays[i].header_size;
 
(void) memcpy(dst, ((GLubyte *) arrays->arrays[i].data) + offset,
arrays->arrays[i].element_size);
 
dst += __GLX_PAD(arrays->arrays[i].element_size);
}
}
 
return dst;
}
 
 
/**
* Emit a single element using "old" DrawArrays protocol from
* EXT_vertex_arrays / OpenGL 1.1.
*/
GLubyte *
emit_element_old(GLubyte * dst,
const struct array_state_vector * arrays, unsigned index)
{
unsigned i;
 
 
for (i = 0; i < arrays->num_arrays; i++) {
if (arrays->arrays[i].enabled) {
const size_t offset = index * arrays->arrays[i].true_stride;
 
(void) memcpy(dst, ((GLubyte *) arrays->arrays[i].data) + offset,
arrays->arrays[i].element_size);
 
dst += __GLX_PAD(arrays->arrays[i].element_size);
}
}
 
return dst;
}
 
 
struct array_state *
get_array_entry(const struct array_state_vector *arrays,
GLenum key, unsigned index)
{
unsigned i;
 
for (i = 0; i < arrays->num_arrays; i++) {
if ((arrays->arrays[i].key == key)
&& (arrays->arrays[i].index == index)) {
return &arrays->arrays[i];
}
}
 
return NULL;
}
 
 
static GLboolean
allocate_array_info_cache(struct array_state_vector *arrays,
size_t required_size)
{
#define MAX_HEADER_SIZE 20
if (arrays->array_info_cache_buffer_size < required_size) {
GLubyte *temp = realloc(arrays->array_info_cache_base,
required_size + MAX_HEADER_SIZE);
 
if (temp == NULL) {
return GL_FALSE;
}
 
arrays->array_info_cache_base = temp;
arrays->array_info_cache = temp + MAX_HEADER_SIZE;
arrays->array_info_cache_buffer_size = required_size;
}
 
arrays->array_info_cache_size = required_size;
return GL_TRUE;
}
 
 
/**
*/
void
fill_array_info_cache(struct array_state_vector *arrays)
{
GLboolean old_DrawArrays_possible;
unsigned i;
 
 
/* Determine how many arrays are enabled.
*/
 
arrays->enabled_client_array_count = 0;
old_DrawArrays_possible = arrays->old_DrawArrays_possible;
for (i = 0; i < arrays->num_arrays; i++) {
if (arrays->arrays[i].enabled) {
arrays->enabled_client_array_count++;
old_DrawArrays_possible &= arrays->arrays[i].old_DrawArrays_possible;
}
}
 
if (arrays->new_DrawArrays_possible) {
assert(!arrays->new_DrawArrays_possible);
}
else if (old_DrawArrays_possible) {
const size_t required_size = arrays->enabled_client_array_count * 12;
uint32_t *info;
 
 
if (!allocate_array_info_cache(arrays, required_size)) {
return;
}
 
 
info = (uint32_t *) arrays->array_info_cache;
for (i = 0; i < arrays->num_arrays; i++) {
if (arrays->arrays[i].enabled) {
*(info++) = arrays->arrays[i].data_type;
*(info++) = arrays->arrays[i].count;
*(info++) = arrays->arrays[i].key;
}
}
 
arrays->DrawArrays = emit_DrawArrays_old;
arrays->DrawElements = emit_DrawElements_old;
}
else {
arrays->DrawArrays = emit_DrawArrays_none;
arrays->DrawElements = emit_DrawElements_none;
}
 
arrays->array_info_cache_valid = GL_TRUE;
}
 
 
/**
* Emit a \c glDrawArrays command using the "none" protocol. That is,
* emit immediate-mode commands that are equivalent to the requiested
* \c glDrawArrays command. This is used with servers that don't support
* the OpenGL 1.1 / EXT_vertex_arrays DrawArrays protocol or in cases where
* vertex state is enabled that is not compatible with that protocol.
*/
void
emit_DrawArrays_none(GLenum mode, GLint first, GLsizei count)
{
struct glx_context *gc = __glXGetCurrentContext();
const __GLXattribute *state =
(const __GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
 
size_t single_vertex_size;
GLubyte *pc;
unsigned i;
static const uint16_t begin_cmd[2] = { 8, X_GLrop_Begin };
static const uint16_t end_cmd[2] = { 4, X_GLrop_End };
 
 
single_vertex_size = calculate_single_vertex_size_none(arrays);
 
pc = gc->pc;
 
(void) memcpy(pc, begin_cmd, 4);
*(int *) (pc + 4) = mode;
 
pc += 8;
 
for (i = 0; i < count; i++) {
if ((pc + single_vertex_size) >= gc->bufEnd) {
pc = __glXFlushRenderBuffer(gc, pc);
}
 
pc = emit_element_none(pc, arrays, first + i);
}
 
if ((pc + 4) >= gc->bufEnd) {
pc = __glXFlushRenderBuffer(gc, pc);
}
 
(void) memcpy(pc, end_cmd, 4);
pc += 4;
 
gc->pc = pc;
if (gc->pc > gc->limit) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
}
}
 
 
/**
* Emit the header data for the GL 1.1 / EXT_vertex_arrays DrawArrays
* protocol.
*
* \param gc GLX context.
* \param arrays Array state.
* \param elements_per_request Location to store the number of elements that
* can fit in a single Render / RenderLarge
* command.
* \param total_request Total number of requests for a RenderLarge
* command. If a Render command is used, this
* will be zero.
* \param mode Drawing mode.
* \param count Number of vertices.
*
* \returns
* A pointer to the buffer for array data.
*/
static GLubyte *
emit_DrawArrays_header_old(struct glx_context * gc,
struct array_state_vector *arrays,
size_t * elements_per_request,
unsigned int *total_requests,
GLenum mode, GLsizei count)
{
size_t command_size;
size_t single_vertex_size;
const unsigned header_size = 16;
unsigned i;
GLubyte *pc;
 
 
/* Determine the size of the whole command. This includes the header,
* the ARRAY_INFO data and the array data. Once this size is calculated,
* it will be known whether a Render or RenderLarge command is needed.
*/
 
single_vertex_size = 0;
for (i = 0; i < arrays->num_arrays; i++) {
if (arrays->arrays[i].enabled) {
single_vertex_size += __GLX_PAD(arrays->arrays[i].element_size);
}
}
 
command_size = arrays->array_info_cache_size + header_size
+ (single_vertex_size * count);
 
 
/* Write the header for either a Render command or a RenderLarge
* command. After the header is written, write the ARRAY_INFO data.
*/
 
if (command_size > gc->maxSmallRenderCommandSize) {
/* maxSize is the maximum amount of data can be stuffed into a single
* packet. sz_xGLXRenderReq is added because bufSize is the maximum
* packet size minus sz_xGLXRenderReq.
*/
const size_t maxSize = (gc->bufSize + sz_xGLXRenderReq)
- sz_xGLXRenderLargeReq;
unsigned vertex_requests;
 
 
/* Calculate the number of data packets that will be required to send
* the whole command. To do this, the number of verticies that
* will fit in a single buffer must be calculated.
*
* The important value here is elements_per_request. This is the
* number of complete array elements that will fit in a single
* buffer. There may be some wasted space at the end of the buffer,
* but splitting elements across buffer boundries would be painful.
*/
 
elements_per_request[0] = maxSize / single_vertex_size;
 
vertex_requests = (count + elements_per_request[0] - 1)
/ elements_per_request[0];
 
*total_requests = vertex_requests + 1;
 
 
__glXFlushRenderBuffer(gc, gc->pc);
 
command_size += 4;
 
pc = ((GLubyte *) arrays->array_info_cache) - (header_size + 4);
*(uint32_t *) (pc + 0) = command_size;
*(uint32_t *) (pc + 4) = X_GLrop_DrawArrays;
*(uint32_t *) (pc + 8) = count;
*(uint32_t *) (pc + 12) = arrays->enabled_client_array_count;
*(uint32_t *) (pc + 16) = mode;
 
__glXSendLargeChunk(gc, 1, *total_requests, pc,
header_size + 4 + arrays->array_info_cache_size);
 
pc = gc->pc;
}
else {
if ((gc->pc + command_size) >= gc->bufEnd) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
}
 
pc = gc->pc;
*(uint16_t *) (pc + 0) = command_size;
*(uint16_t *) (pc + 2) = X_GLrop_DrawArrays;
*(uint32_t *) (pc + 4) = count;
*(uint32_t *) (pc + 8) = arrays->enabled_client_array_count;
*(uint32_t *) (pc + 12) = mode;
 
pc += header_size;
 
(void) memcpy(pc, arrays->array_info_cache,
arrays->array_info_cache_size);
pc += arrays->array_info_cache_size;
 
*elements_per_request = count;
*total_requests = 0;
}
 
 
return pc;
}
 
 
/**
*/
void
emit_DrawArrays_old(GLenum mode, GLint first, GLsizei count)
{
struct glx_context *gc = __glXGetCurrentContext();
const __GLXattribute *state =
(const __GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
 
GLubyte *pc;
size_t elements_per_request;
unsigned total_requests = 0;
unsigned i;
size_t total_sent = 0;
 
 
pc = emit_DrawArrays_header_old(gc, arrays, &elements_per_request,
&total_requests, mode, count);
 
 
/* Write the arrays.
*/
 
if (total_requests == 0) {
assert(elements_per_request >= count);
 
for (i = 0; i < count; i++) {
pc = emit_element_old(pc, arrays, i + first);
}
 
assert(pc <= gc->bufEnd);
 
gc->pc = pc;
if (gc->pc > gc->limit) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
}
}
else {
unsigned req;
 
 
for (req = 2; req <= total_requests; req++) {
if (count < elements_per_request) {
elements_per_request = count;
}
 
pc = gc->pc;
for (i = 0; i < elements_per_request; i++) {
pc = emit_element_old(pc, arrays, i + first);
}
 
first += elements_per_request;
 
total_sent += (size_t) (pc - gc->pc);
__glXSendLargeChunk(gc, req, total_requests, gc->pc, pc - gc->pc);
 
count -= elements_per_request;
}
}
}
 
 
void
emit_DrawElements_none(GLenum mode, GLsizei count, GLenum type,
const GLvoid * indices)
{
struct glx_context *gc = __glXGetCurrentContext();
const __GLXattribute *state =
(const __GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
static const uint16_t begin_cmd[2] = { 8, X_GLrop_Begin };
static const uint16_t end_cmd[2] = { 4, X_GLrop_End };
 
GLubyte *pc;
size_t single_vertex_size;
unsigned i;
 
 
single_vertex_size = calculate_single_vertex_size_none(arrays);
 
 
if ((gc->pc + single_vertex_size) >= gc->bufEnd) {
gc->pc = __glXFlushRenderBuffer(gc, gc->pc);
}
 
pc = gc->pc;
 
(void) memcpy(pc, begin_cmd, 4);
*(int *) (pc + 4) = mode;
 
pc += 8;
 
for (i = 0; i < count; i++) {
unsigned index = 0;
 
if ((pc + single_vertex_size) >= gc->bufEnd) {
pc = __glXFlushRenderBuffer(gc, pc);
}
 
switch (type) {
case GL_UNSIGNED_INT:
index = (unsigned) (((GLuint *) indices)[i]);
break;
case GL_UNSIGNED_SHORT:
index = (unsigned) (((GLushort *) indices)[i]);
break;
case GL_UNSIGNED_BYTE:
index = (unsigned) (((GLubyte *) indices)[i]);
break;
}
pc = emit_element_none(pc, arrays, index);
}
 
if ((pc + 4) >= gc->bufEnd) {
pc = __glXFlushRenderBuffer(gc, pc);
}
 
(void) memcpy(pc, end_cmd, 4);
pc += 4;
 
gc->pc = pc;
if (gc->pc > gc->limit) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
}
}
 
 
/**
*/
void
emit_DrawElements_old(GLenum mode, GLsizei count, GLenum type,
const GLvoid * indices)
{
struct glx_context *gc = __glXGetCurrentContext();
const __GLXattribute *state =
(const __GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
 
GLubyte *pc;
size_t elements_per_request;
unsigned total_requests = 0;
unsigned i;
unsigned req;
unsigned req_element = 0;
 
 
pc = emit_DrawArrays_header_old(gc, arrays, &elements_per_request,
&total_requests, mode, count);
 
 
/* Write the arrays.
*/
 
req = 2;
while (count > 0) {
if (count < elements_per_request) {
elements_per_request = count;
}
 
switch (type) {
case GL_UNSIGNED_INT:{
const GLuint *ui_ptr = (const GLuint *) indices + req_element;
 
for (i = 0; i < elements_per_request; i++) {
const GLint index = (GLint) * (ui_ptr++);
pc = emit_element_old(pc, arrays, index);
}
break;
}
case GL_UNSIGNED_SHORT:{
const GLushort *us_ptr = (const GLushort *) indices + req_element;
 
for (i = 0; i < elements_per_request; i++) {
const GLint index = (GLint) * (us_ptr++);
pc = emit_element_old(pc, arrays, index);
}
break;
}
case GL_UNSIGNED_BYTE:{
const GLubyte *ub_ptr = (const GLubyte *) indices + req_element;
 
for (i = 0; i < elements_per_request; i++) {
const GLint index = (GLint) * (ub_ptr++);
pc = emit_element_old(pc, arrays, index);
}
break;
}
}
 
if (total_requests != 0) {
__glXSendLargeChunk(gc, req, total_requests, gc->pc, pc - gc->pc);
pc = gc->pc;
req++;
}
 
count -= elements_per_request;
req_element += elements_per_request;
}
 
 
assert((total_requests == 0) || ((req - 1) == total_requests));
 
if (total_requests == 0) {
assert(pc <= gc->bufEnd);
 
gc->pc = pc;
if (gc->pc > gc->limit) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
}
}
}
 
 
/**
* Validate that the \c mode parameter to \c glDrawArrays, et. al. is valid.
* If it is not valid, then an error code is set in the GLX context.
*
* \returns
* \c GL_TRUE if the argument is valid, \c GL_FALSE if is not.
*/
static GLboolean
validate_mode(struct glx_context * gc, GLenum mode)
{
switch (mode) {
case GL_POINTS:
case GL_LINE_STRIP:
case GL_LINE_LOOP:
case GL_LINES:
case GL_TRIANGLE_STRIP:
case GL_TRIANGLE_FAN:
case GL_TRIANGLES:
case GL_QUAD_STRIP:
case GL_QUADS:
case GL_POLYGON:
break;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return GL_FALSE;
}
 
return GL_TRUE;
}
 
 
/**
* Validate that the \c count parameter to \c glDrawArrays, et. al. is valid.
* A value less than zero is invalid and will result in \c GL_INVALID_VALUE
* being set. A value of zero will not result in an error being set, but
* will result in \c GL_FALSE being returned.
*
* \returns
* \c GL_TRUE if the argument is valid, \c GL_FALSE if it is not.
*/
static GLboolean
validate_count(struct glx_context * gc, GLsizei count)
{
if (count < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
}
 
return (count > 0);
}
 
 
/**
* Validate that the \c type parameter to \c glDrawElements, et. al. is
* valid. Only \c GL_UNSIGNED_BYTE, \c GL_UNSIGNED_SHORT, and
* \c GL_UNSIGNED_INT are valid.
*
* \returns
* \c GL_TRUE if the argument is valid, \c GL_FALSE if it is not.
*/
static GLboolean
validate_type(struct glx_context * gc, GLenum type)
{
switch (type) {
case GL_UNSIGNED_INT:
case GL_UNSIGNED_SHORT:
case GL_UNSIGNED_BYTE:
return GL_TRUE;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return GL_FALSE;
}
}
 
 
void
__indirect_glDrawArrays(GLenum mode, GLint first, GLsizei count)
{
struct glx_context *gc = __glXGetCurrentContext();
const __GLXattribute *state =
(const __GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
 
 
if (validate_mode(gc, mode) && validate_count(gc, count)) {
if (!arrays->array_info_cache_valid) {
fill_array_info_cache(arrays);
}
 
arrays->DrawArrays(mode, first, count);
}
}
 
 
void
__indirect_glArrayElement(GLint index)
{
struct glx_context *gc = __glXGetCurrentContext();
const __GLXattribute *state =
(const __GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
 
size_t single_vertex_size;
 
 
single_vertex_size = calculate_single_vertex_size_none(arrays);
 
if ((gc->pc + single_vertex_size) >= gc->bufEnd) {
gc->pc = __glXFlushRenderBuffer(gc, gc->pc);
}
 
gc->pc = emit_element_none(gc->pc, arrays, index);
 
if (gc->pc > gc->limit) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
}
}
 
 
void
__indirect_glDrawElements(GLenum mode, GLsizei count, GLenum type,
const GLvoid * indices)
{
struct glx_context *gc = __glXGetCurrentContext();
const __GLXattribute *state =
(const __GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
 
 
if (validate_mode(gc, mode) && validate_count(gc, count)
&& validate_type(gc, type)) {
if (!arrays->array_info_cache_valid) {
fill_array_info_cache(arrays);
}
 
arrays->DrawElements(mode, count, type, indices);
}
}
 
 
void
__indirect_glDrawRangeElements(GLenum mode, GLuint start, GLuint end,
GLsizei count, GLenum type,
const GLvoid * indices)
{
struct glx_context *gc = __glXGetCurrentContext();
const __GLXattribute *state =
(const __GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
 
 
if (validate_mode(gc, mode) && validate_count(gc, count)
&& validate_type(gc, type)) {
if (end < start) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
 
if (!arrays->array_info_cache_valid) {
fill_array_info_cache(arrays);
}
 
arrays->DrawElements(mode, count, type, indices);
}
}
 
 
void
__indirect_glMultiDrawArrays(GLenum mode, const GLint *first,
const GLsizei *count, GLsizei primcount)
{
struct glx_context *gc = __glXGetCurrentContext();
const __GLXattribute *state =
(const __GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
GLsizei i;
 
 
if (validate_mode(gc, mode)) {
if (!arrays->array_info_cache_valid) {
fill_array_info_cache(arrays);
}
 
for (i = 0; i < primcount; i++) {
if (validate_count(gc, count[i])) {
arrays->DrawArrays(mode, first[i], count[i]);
}
}
}
}
 
 
void
__indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei * count,
GLenum type, const GLvoid * const * indices,
GLsizei primcount)
{
struct glx_context *gc = __glXGetCurrentContext();
const __GLXattribute *state =
(const __GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
GLsizei i;
 
 
if (validate_mode(gc, mode) && validate_type(gc, type)) {
if (!arrays->array_info_cache_valid) {
fill_array_info_cache(arrays);
}
 
for (i = 0; i < primcount; i++) {
if (validate_count(gc, count[i])) {
arrays->DrawElements(mode, count[i], type, indices[i]);
}
}
}
}
 
 
#define COMMON_ARRAY_DATA_INIT(a, PTR, TYPE, STRIDE, COUNT, NORMALIZED, HDR_SIZE, OPCODE) \
do { \
(a)->data = PTR; \
(a)->data_type = TYPE; \
(a)->user_stride = STRIDE; \
(a)->count = COUNT; \
(a)->normalized = NORMALIZED; \
\
(a)->element_size = __glXTypeSize( TYPE ) * COUNT; \
(a)->true_stride = (STRIDE == 0) \
? (a)->element_size : STRIDE; \
\
(a)->header_size = HDR_SIZE; \
((uint16_t *) (a)->header)[0] = __GLX_PAD((a)->header_size + (a)->element_size); \
((uint16_t *) (a)->header)[1] = OPCODE; \
} while(0)
 
 
void
__indirect_glVertexPointer(GLint size, GLenum type, GLsizei stride,
const GLvoid * pointer)
{
static const uint16_t short_ops[5] = {
0, 0, X_GLrop_Vertex2sv, X_GLrop_Vertex3sv, X_GLrop_Vertex4sv
};
static const uint16_t int_ops[5] = {
0, 0, X_GLrop_Vertex2iv, X_GLrop_Vertex3iv, X_GLrop_Vertex4iv
};
static const uint16_t float_ops[5] = {
0, 0, X_GLrop_Vertex2fv, X_GLrop_Vertex3fv, X_GLrop_Vertex4fv
};
static const uint16_t double_ops[5] = {
0, 0, X_GLrop_Vertex2dv, X_GLrop_Vertex3dv, X_GLrop_Vertex4dv
};
uint16_t opcode;
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
struct array_state *a;
 
 
if (size < 2 || size > 4 || stride < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
 
switch (type) {
case GL_SHORT:
opcode = short_ops[size];
break;
case GL_INT:
opcode = int_ops[size];
break;
case GL_FLOAT:
opcode = float_ops[size];
break;
case GL_DOUBLE:
opcode = double_ops[size];
break;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
 
a = get_array_entry(arrays, GL_VERTEX_ARRAY, 0);
assert(a != NULL);
COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_FALSE, 4,
opcode);
 
if (a->enabled) {
arrays->array_info_cache_valid = GL_FALSE;
}
}
 
 
void
__indirect_glNormalPointer(GLenum type, GLsizei stride,
const GLvoid * pointer)
{
uint16_t opcode;
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
struct array_state *a;
 
 
if (stride < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
 
switch (type) {
case GL_BYTE:
opcode = X_GLrop_Normal3bv;
break;
case GL_SHORT:
opcode = X_GLrop_Normal3sv;
break;
case GL_INT:
opcode = X_GLrop_Normal3iv;
break;
case GL_FLOAT:
opcode = X_GLrop_Normal3fv;
break;
case GL_DOUBLE:
opcode = X_GLrop_Normal3dv;
break;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
 
a = get_array_entry(arrays, GL_NORMAL_ARRAY, 0);
assert(a != NULL);
COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, 3, GL_TRUE, 4, opcode);
 
if (a->enabled) {
arrays->array_info_cache_valid = GL_FALSE;
}
}
 
 
void
__indirect_glColorPointer(GLint size, GLenum type, GLsizei stride,
const GLvoid * pointer)
{
static const uint16_t byte_ops[5] = {
0, 0, 0, X_GLrop_Color3bv, X_GLrop_Color4bv
};
static const uint16_t ubyte_ops[5] = {
0, 0, 0, X_GLrop_Color3ubv, X_GLrop_Color4ubv
};
static const uint16_t short_ops[5] = {
0, 0, 0, X_GLrop_Color3sv, X_GLrop_Color4sv
};
static const uint16_t ushort_ops[5] = {
0, 0, 0, X_GLrop_Color3usv, X_GLrop_Color4usv
};
static const uint16_t int_ops[5] = {
0, 0, 0, X_GLrop_Color3iv, X_GLrop_Color4iv
};
static const uint16_t uint_ops[5] = {
0, 0, 0, X_GLrop_Color3uiv, X_GLrop_Color4uiv
};
static const uint16_t float_ops[5] = {
0, 0, 0, X_GLrop_Color3fv, X_GLrop_Color4fv
};
static const uint16_t double_ops[5] = {
0, 0, 0, X_GLrop_Color3dv, X_GLrop_Color4dv
};
uint16_t opcode;
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
struct array_state *a;
 
 
if (size < 3 || size > 4 || stride < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
 
switch (type) {
case GL_BYTE:
opcode = byte_ops[size];
break;
case GL_UNSIGNED_BYTE:
opcode = ubyte_ops[size];
break;
case GL_SHORT:
opcode = short_ops[size];
break;
case GL_UNSIGNED_SHORT:
opcode = ushort_ops[size];
break;
case GL_INT:
opcode = int_ops[size];
break;
case GL_UNSIGNED_INT:
opcode = uint_ops[size];
break;
case GL_FLOAT:
opcode = float_ops[size];
break;
case GL_DOUBLE:
opcode = double_ops[size];
break;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
 
a = get_array_entry(arrays, GL_COLOR_ARRAY, 0);
assert(a != NULL);
COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_TRUE, 4, opcode);
 
if (a->enabled) {
arrays->array_info_cache_valid = GL_FALSE;
}
}
 
 
void
__indirect_glIndexPointer(GLenum type, GLsizei stride, const GLvoid * pointer)
{
uint16_t opcode;
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
struct array_state *a;
 
 
if (stride < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
 
switch (type) {
case GL_UNSIGNED_BYTE:
opcode = X_GLrop_Indexubv;
break;
case GL_SHORT:
opcode = X_GLrop_Indexsv;
break;
case GL_INT:
opcode = X_GLrop_Indexiv;
break;
case GL_FLOAT:
opcode = X_GLrop_Indexfv;
break;
case GL_DOUBLE:
opcode = X_GLrop_Indexdv;
break;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
 
a = get_array_entry(arrays, GL_INDEX_ARRAY, 0);
assert(a != NULL);
COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, 1, GL_FALSE, 4, opcode);
 
if (a->enabled) {
arrays->array_info_cache_valid = GL_FALSE;
}
}
 
 
void
__indirect_glEdgeFlagPointer(GLsizei stride, const GLvoid * pointer)
{
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
struct array_state *a;
 
 
if (stride < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
 
 
a = get_array_entry(arrays, GL_EDGE_FLAG_ARRAY, 0);
assert(a != NULL);
COMMON_ARRAY_DATA_INIT(a, pointer, GL_UNSIGNED_BYTE, stride, 1, GL_FALSE,
4, X_GLrop_EdgeFlagv);
 
if (a->enabled) {
arrays->array_info_cache_valid = GL_FALSE;
}
}
 
 
void
__indirect_glTexCoordPointer(GLint size, GLenum type, GLsizei stride,
const GLvoid * pointer)
{
static const uint16_t short_ops[5] = {
0, X_GLrop_TexCoord1sv, X_GLrop_TexCoord2sv, X_GLrop_TexCoord3sv,
X_GLrop_TexCoord4sv
};
static const uint16_t int_ops[5] = {
0, X_GLrop_TexCoord1iv, X_GLrop_TexCoord2iv, X_GLrop_TexCoord3iv,
X_GLrop_TexCoord4iv
};
static const uint16_t float_ops[5] = {
0, X_GLrop_TexCoord1dv, X_GLrop_TexCoord2fv, X_GLrop_TexCoord3fv,
X_GLrop_TexCoord4fv
};
static const uint16_t double_ops[5] = {
0, X_GLrop_TexCoord1dv, X_GLrop_TexCoord2dv, X_GLrop_TexCoord3dv,
X_GLrop_TexCoord4dv
};
 
static const uint16_t mshort_ops[5] = {
0, X_GLrop_MultiTexCoord1svARB, X_GLrop_MultiTexCoord2svARB,
X_GLrop_MultiTexCoord3svARB, X_GLrop_MultiTexCoord4svARB
};
static const uint16_t mint_ops[5] = {
0, X_GLrop_MultiTexCoord1ivARB, X_GLrop_MultiTexCoord2ivARB,
X_GLrop_MultiTexCoord3ivARB, X_GLrop_MultiTexCoord4ivARB
};
static const uint16_t mfloat_ops[5] = {
0, X_GLrop_MultiTexCoord1dvARB, X_GLrop_MultiTexCoord2fvARB,
X_GLrop_MultiTexCoord3fvARB, X_GLrop_MultiTexCoord4fvARB
};
static const uint16_t mdouble_ops[5] = {
0, X_GLrop_MultiTexCoord1dvARB, X_GLrop_MultiTexCoord2dvARB,
X_GLrop_MultiTexCoord3dvARB, X_GLrop_MultiTexCoord4dvARB
};
 
uint16_t opcode;
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
struct array_state *a;
unsigned header_size;
unsigned index;
 
 
if (size < 1 || size > 4 || stride < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
 
index = arrays->active_texture_unit;
if (index == 0) {
switch (type) {
case GL_SHORT:
opcode = short_ops[size];
break;
case GL_INT:
opcode = int_ops[size];
break;
case GL_FLOAT:
opcode = float_ops[size];
break;
case GL_DOUBLE:
opcode = double_ops[size];
break;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
 
header_size = 4;
}
else {
switch (type) {
case GL_SHORT:
opcode = mshort_ops[size];
break;
case GL_INT:
opcode = mint_ops[size];
break;
case GL_FLOAT:
opcode = mfloat_ops[size];
break;
case GL_DOUBLE:
opcode = mdouble_ops[size];
break;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
 
header_size = 8;
}
 
a = get_array_entry(arrays, GL_TEXTURE_COORD_ARRAY, index);
assert(a != NULL);
COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_FALSE,
header_size, opcode);
 
if (a->enabled) {
arrays->array_info_cache_valid = GL_FALSE;
}
}
 
 
void
__indirect_glSecondaryColorPointer(GLint size, GLenum type, GLsizei stride,
const GLvoid * pointer)
{
uint16_t opcode;
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
struct array_state *a;
 
 
if (size != 3 || stride < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
 
switch (type) {
case GL_BYTE:
opcode = 4126;
break;
case GL_UNSIGNED_BYTE:
opcode = 4131;
break;
case GL_SHORT:
opcode = 4127;
break;
case GL_UNSIGNED_SHORT:
opcode = 4132;
break;
case GL_INT:
opcode = 4128;
break;
case GL_UNSIGNED_INT:
opcode = 4133;
break;
case GL_FLOAT:
opcode = 4129;
break;
case GL_DOUBLE:
opcode = 4130;
break;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
 
a = get_array_entry(arrays, GL_SECONDARY_COLOR_ARRAY, 0);
if (a == NULL) {
__glXSetError(gc, GL_INVALID_OPERATION);
return;
}
 
COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_TRUE, 4, opcode);
 
if (a->enabled) {
arrays->array_info_cache_valid = GL_FALSE;
}
}
 
 
void
__indirect_glFogCoordPointer(GLenum type, GLsizei stride,
const GLvoid * pointer)
{
uint16_t opcode;
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
struct array_state *a;
 
 
if (stride < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
 
switch (type) {
case GL_FLOAT:
opcode = 4124;
break;
case GL_DOUBLE:
opcode = 4125;
break;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
 
a = get_array_entry(arrays, GL_FOG_COORD_ARRAY, 0);
if (a == NULL) {
__glXSetError(gc, GL_INVALID_OPERATION);
return;
}
 
COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, 1, GL_FALSE, 4, opcode);
 
if (a->enabled) {
arrays->array_info_cache_valid = GL_FALSE;
}
}
 
 
void
__indirect_glVertexAttribPointer(GLuint index, GLint size,
GLenum type, GLboolean normalized,
GLsizei stride, const GLvoid * pointer)
{
static const uint16_t short_ops[5] = { 0, 4189, 4190, 4191, 4192 };
static const uint16_t float_ops[5] = { 0, 4193, 4194, 4195, 4196 };
static const uint16_t double_ops[5] = { 0, 4197, 4198, 4199, 4200 };
 
uint16_t opcode;
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
struct array_state_vector *arrays = state->array_state;
struct array_state *a;
unsigned true_immediate_count;
unsigned true_immediate_size;
 
 
if ((size < 1) || (size > 4) || (stride < 0)
|| (index > arrays->num_vertex_program_attribs)) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
 
if (normalized && (type != GL_FLOAT) && (type != GL_DOUBLE)) {
switch (type) {
case GL_BYTE:
opcode = X_GLrop_VertexAttrib4NbvARB;
break;
case GL_UNSIGNED_BYTE:
opcode = X_GLrop_VertexAttrib4NubvARB;
break;
case GL_SHORT:
opcode = X_GLrop_VertexAttrib4NsvARB;
break;
case GL_UNSIGNED_SHORT:
opcode = X_GLrop_VertexAttrib4NusvARB;
break;
case GL_INT:
opcode = X_GLrop_VertexAttrib4NivARB;
break;
case GL_UNSIGNED_INT:
opcode = X_GLrop_VertexAttrib4NuivARB;
break;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
 
true_immediate_count = 4;
}
else {
true_immediate_count = size;
 
switch (type) {
case GL_BYTE:
opcode = X_GLrop_VertexAttrib4bvARB;
true_immediate_count = 4;
break;
case GL_UNSIGNED_BYTE:
opcode = X_GLrop_VertexAttrib4ubvARB;
true_immediate_count = 4;
break;
case GL_SHORT:
opcode = short_ops[size];
break;
case GL_UNSIGNED_SHORT:
opcode = X_GLrop_VertexAttrib4usvARB;
true_immediate_count = 4;
break;
case GL_INT:
opcode = X_GLrop_VertexAttrib4ivARB;
true_immediate_count = 4;
break;
case GL_UNSIGNED_INT:
opcode = X_GLrop_VertexAttrib4uivARB;
true_immediate_count = 4;
break;
case GL_FLOAT:
opcode = float_ops[size];
break;
case GL_DOUBLE:
opcode = double_ops[size];
break;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
}
 
a = get_array_entry(arrays, GL_VERTEX_ATTRIB_ARRAY_POINTER, index);
if (a == NULL) {
__glXSetError(gc, GL_INVALID_OPERATION);
return;
}
 
COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, normalized, 8,
opcode);
 
true_immediate_size = __glXTypeSize(type) * true_immediate_count;
((uint16_t *) (a)->header)[0] = __GLX_PAD(a->header_size
+ true_immediate_size);
 
if (a->enabled) {
arrays->array_info_cache_valid = GL_FALSE;
}
}
 
 
/**
* I don't have 100% confidence that this is correct. The different rules
* about whether or not generic vertex attributes alias "classic" vertex
* attributes (i.e., attrib1 ?= primary color) between ARB_vertex_program,
* ARB_vertex_shader, and NV_vertex_program are a bit confusing. My
* feeling is that the client-side doesn't have to worry about it. The
* client just sends all the data to the server and lets the server deal
* with it.
*/
void
__indirect_glVertexAttribPointerNV(GLuint index, GLint size,
GLenum type, GLsizei stride,
const GLvoid * pointer)
{
struct glx_context *gc = __glXGetCurrentContext();
GLboolean normalized = GL_FALSE;
 
 
switch (type) {
case GL_UNSIGNED_BYTE:
if (size != 4) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
normalized = GL_TRUE;
 
case GL_SHORT:
case GL_FLOAT:
case GL_DOUBLE:
__indirect_glVertexAttribPointer(index, size, type,
normalized, stride, pointer);
return;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
}
 
 
void
__indirect_glClientActiveTexture(GLenum texture)
{
struct glx_context *const gc = __glXGetCurrentContext();
__GLXattribute *const state =
(__GLXattribute *) (gc->client_state_private);
struct array_state_vector *const arrays = state->array_state;
const GLint unit = (GLint) texture - GL_TEXTURE0;
 
 
if ((unit < 0) || (unit >= arrays->num_texture_units)) {
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
 
arrays->active_texture_unit = unit;
}
 
 
/**
* Modify the enable state for the selected array
*/
GLboolean
__glXSetArrayEnable(__GLXattribute * state, GLenum key, unsigned index,
GLboolean enable)
{
struct array_state_vector *arrays = state->array_state;
struct array_state *a;
 
 
/* Texture coordinate arrays have an implict index set when the
* application calls glClientActiveTexture.
*/
if (key == GL_TEXTURE_COORD_ARRAY) {
index = arrays->active_texture_unit;
}
 
a = get_array_entry(arrays, key, index);
 
if ((a != NULL) && (a->enabled != enable)) {
a->enabled = enable;
arrays->array_info_cache_valid = GL_FALSE;
}
 
return (a != NULL);
}
 
 
void
__glXArrayDisableAll(__GLXattribute * state)
{
struct array_state_vector *arrays = state->array_state;
unsigned i;
 
 
for (i = 0; i < arrays->num_arrays; i++) {
arrays->arrays[i].enabled = GL_FALSE;
}
 
arrays->array_info_cache_valid = GL_FALSE;
}
 
 
/**
*/
GLboolean
__glXGetArrayEnable(const __GLXattribute * const state,
GLenum key, unsigned index, GLintptr * dest)
{
const struct array_state_vector *arrays = state->array_state;
const struct array_state *a =
get_array_entry((struct array_state_vector *) arrays,
key, index);
 
if (a != NULL) {
*dest = (GLintptr) a->enabled;
}
 
return (a != NULL);
}
 
 
/**
*/
GLboolean
__glXGetArrayType(const __GLXattribute * const state,
GLenum key, unsigned index, GLintptr * dest)
{
const struct array_state_vector *arrays = state->array_state;
const struct array_state *a =
get_array_entry((struct array_state_vector *) arrays,
key, index);
 
if (a != NULL) {
*dest = (GLintptr) a->data_type;
}
 
return (a != NULL);
}
 
 
/**
*/
GLboolean
__glXGetArraySize(const __GLXattribute * const state,
GLenum key, unsigned index, GLintptr * dest)
{
const struct array_state_vector *arrays = state->array_state;
const struct array_state *a =
get_array_entry((struct array_state_vector *) arrays,
key, index);
 
if (a != NULL) {
*dest = (GLintptr) a->count;
}
 
return (a != NULL);
}
 
 
/**
*/
GLboolean
__glXGetArrayStride(const __GLXattribute * const state,
GLenum key, unsigned index, GLintptr * dest)
{
const struct array_state_vector *arrays = state->array_state;
const struct array_state *a =
get_array_entry((struct array_state_vector *) arrays,
key, index);
 
if (a != NULL) {
*dest = (GLintptr) a->user_stride;
}
 
return (a != NULL);
}
 
 
/**
*/
GLboolean
__glXGetArrayPointer(const __GLXattribute * const state,
GLenum key, unsigned index, void **dest)
{
const struct array_state_vector *arrays = state->array_state;
const struct array_state *a =
get_array_entry((struct array_state_vector *) arrays,
key, index);
 
 
if (a != NULL) {
*dest = (void *) (a->data);
}
 
return (a != NULL);
}
 
 
/**
*/
GLboolean
__glXGetArrayNormalized(const __GLXattribute * const state,
GLenum key, unsigned index, GLintptr * dest)
{
const struct array_state_vector *arrays = state->array_state;
const struct array_state *a =
get_array_entry((struct array_state_vector *) arrays,
key, index);
 
 
if (a != NULL) {
*dest = (GLintptr) a->normalized;
}
 
return (a != NULL);
}
 
 
/**
*/
GLuint
__glXGetActiveTextureUnit(const __GLXattribute * const state)
{
return state->array_state->active_texture_unit;
}
 
 
void
__glXPushArrayState(__GLXattribute * state)
{
struct array_state_vector *arrays = state->array_state;
struct array_stack_state *stack =
&arrays->stack[(arrays->stack_index * arrays->num_arrays)];
unsigned i;
 
/* XXX are we pushing _all_ the necessary fields? */
for (i = 0; i < arrays->num_arrays; i++) {
stack[i].data = arrays->arrays[i].data;
stack[i].data_type = arrays->arrays[i].data_type;
stack[i].user_stride = arrays->arrays[i].user_stride;
stack[i].count = arrays->arrays[i].count;
stack[i].key = arrays->arrays[i].key;
stack[i].index = arrays->arrays[i].index;
stack[i].enabled = arrays->arrays[i].enabled;
}
 
arrays->active_texture_unit_stack[arrays->stack_index] =
arrays->active_texture_unit;
 
arrays->stack_index++;
}
 
 
void
__glXPopArrayState(__GLXattribute * state)
{
struct array_state_vector *arrays = state->array_state;
struct array_stack_state *stack;
unsigned i;
 
 
arrays->stack_index--;
stack = &arrays->stack[(arrays->stack_index * arrays->num_arrays)];
 
for (i = 0; i < arrays->num_arrays; i++) {
switch (stack[i].key) {
case GL_NORMAL_ARRAY:
__indirect_glNormalPointer(stack[i].data_type,
stack[i].user_stride, stack[i].data);
break;
case GL_COLOR_ARRAY:
__indirect_glColorPointer(stack[i].count,
stack[i].data_type,
stack[i].user_stride, stack[i].data);
break;
case GL_INDEX_ARRAY:
__indirect_glIndexPointer(stack[i].data_type,
stack[i].user_stride, stack[i].data);
break;
case GL_EDGE_FLAG_ARRAY:
__indirect_glEdgeFlagPointer(stack[i].user_stride, stack[i].data);
break;
case GL_TEXTURE_COORD_ARRAY:
arrays->active_texture_unit = stack[i].index;
__indirect_glTexCoordPointer(stack[i].count,
stack[i].data_type,
stack[i].user_stride, stack[i].data);
break;
case GL_SECONDARY_COLOR_ARRAY:
__indirect_glSecondaryColorPointer(stack[i].count,
stack[i].data_type,
stack[i].user_stride,
stack[i].data);
break;
case GL_FOG_COORDINATE_ARRAY:
__indirect_glFogCoordPointer(stack[i].data_type,
stack[i].user_stride, stack[i].data);
break;
 
}
 
__glXSetArrayEnable(state, stack[i].key, stack[i].index,
stack[i].enabled);
}
 
arrays->active_texture_unit =
arrays->active_texture_unit_stack[arrays->stack_index];
}
/contrib/sdk/sources/Mesa/src/glx/indirect_vertex_array.h
0,0 → 1,64
/*
* (C) Copyright IBM Corporation 2004, 2005
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* IBM,
* AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
 
#ifndef INDIRECT_VERTEX_ARRAY_H
#define INDIRECT_VERTEX_ARRAY_H
 
extern const GLuint __glXTypeSize_table[16];
 
#define __glXTypeSize(e) ((((e) & ~0x0f) != 0x1400) \
? 0 : __glXTypeSize_table[ (e) & 0x0f ])
 
extern void __glXArrayDisableAll(__GLXattribute * state);
 
extern GLboolean __glXSetArrayEnable(__GLXattribute * state,
GLenum key, unsigned index,
GLboolean enable);
 
extern GLboolean __glXGetArrayEnable(const __GLXattribute * const state,
GLenum key, unsigned index,
GLintptr * dest);
extern GLboolean __glXGetArraySize(const __GLXattribute * const state,
GLenum key, unsigned index,
GLintptr * dest);
extern GLboolean __glXGetArrayType(const __GLXattribute * const state,
GLenum key, unsigned index,
GLintptr * dest);
extern GLboolean __glXGetArrayStride(const __GLXattribute * const state,
GLenum key, unsigned index,
GLintptr * dest);
extern GLboolean __glXGetArrayPointer(const __GLXattribute * const state,
GLenum key, unsigned index,
void **dest);
extern GLboolean __glXGetArrayNormalized(const __GLXattribute * const state,
GLenum key, unsigned index,
GLintptr * dest);
 
extern void __glXPushArrayState(__GLXattribute * state);
extern void __glXPopArrayState(__GLXattribute * state);
 
extern GLuint __glXGetActiveTextureUnit(const __GLXattribute * const state);
 
#endif /* INDIRECT_VERTEX_ARRAY_H */
/contrib/sdk/sources/Mesa/src/glx/indirect_vertex_array_priv.h
0,0 → 1,311
/*
* (C) Copyright IBM Corporation 2004, 2005
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* IBM,
* AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
 
#ifndef _INDIRECT_VA_PRIVATE_
#define _INDIRECT_VA_PRIVATE_
 
/**
* \file indirect_va_private.h
*
* \author Ian Romanick <idr@us.ibm.com>
*/
 
#include <inttypes.h>
 
#include "glxclient.h"
#include "indirect.h"
#include <GL/glxproto.h>
 
 
/**
* State descriptor for a single array of vertex data.
*/
struct array_state
{
/**
* Pointer to the application supplied data.
*/
const void *data;
 
/**
* Enum representing the type of the application supplied data.
*/
GLenum data_type;
 
/**
* Stride value supplied by the application. This value is not used
* internally. It is only kept so that it can be queried by the
* application using glGet*v.
*/
GLsizei user_stride;
 
/**
* Calculated size, in bytes, of a single element in the array. This
* is calculated based on \c count and the size of the data type
* represented by \c data_type.
*/
GLsizei element_size;
 
/**
* Actual byte-stride from one element to the next. This value will
* be equal to either \c user_stride or \c element_stride.
*/
GLsizei true_stride;
 
/**
* Number of data values in each element.
*/
GLint count;
 
/**
* "Normalized" data is on the range [0,1] (unsigned) or [-1,1] (signed).
* This is used for mapping integral types to floating point types.
*/
GLboolean normalized;
 
/**
* Pre-calculated GLX protocol command header.
*/
uint32_t header[2];
 
/**
* Size of the header data. For simple data, like glColorPointerfv,
* this is 4. For complex data that requires either a count (e.g.,
* glWeightfvARB), an index (e.g., glVertexAttrib1fvARB), or a
* selector enum (e.g., glMultiTexCoord2fv) this is 8.
*/
unsigned header_size;
 
/**
* Set to \c GL_TRUE if this array is enabled. Otherwise, it is set
* to \c GL_FALSE.
*/
GLboolean enabled;
 
/**
* For multi-arrayed data (e.g., texture coordinates, generic vertex
* program attributes, etc.), this specifies which array this is.
*/
unsigned index;
 
/**
* Per-array-type key. For most arrays, this will be the GL enum for
* that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY
* for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data,
* etc.).
*/
GLenum key;
 
/**
* If this array can be used with the "classic" \c glDrawArrays protocol,
* this is set to \c GL_TRUE. Otherwise, it is set to \c GL_FALSE.
*/
GLboolean old_DrawArrays_possible;
};
 
 
/**
* Array state that is pushed / poped by \c glPushClientAttrib and
* \c glPopClientAttrib.
*/
struct array_stack_state
{
/**
* Pointer to the application supplied data.
*/
const void *data;
 
/**
* Enum representing the type of the application supplied data.
*/
GLenum data_type;
 
/**
* Stride value supplied by the application. This value is not used
* internally. It is only kept so that it can be queried by the
* application using glGet*v.
*/
GLsizei user_stride;
 
/**
* Number of data values in each element.
*/
GLint count;
 
/**
* Per-array-type key. For most arrays, this will be the GL enum for
* that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY
* for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data,
* etc.).
*/
GLenum key;
 
/**
* For multi-arrayed data (e.g., texture coordinates, generic vertex
* program attributes, etc.), this specifies which array this is.
*/
unsigned index;
 
/**
* Set to \c GL_TRUE if this array is enabled. Otherwise, it is set
* to \c GL_FALSE.
*/
GLboolean enabled;
};
 
 
/**
* Collection of all the vertex array state.
*/
struct array_state_vector
{
/**
* Number of arrays tracked by \c ::arrays.
*/
size_t num_arrays;
 
/**
* Array of vertex array state. This array contains all of the valid
* vertex arrays. If a vertex array isn't in this array, then it isn't
* valid. For example, if an implementation does not support
* EXT_fog_coord, there won't be a GL_FOG_COORD_ARRAY entry in this
* array.
*/
struct array_state *arrays;
 
/**
* Number of currently enabled client-side arrays. The value of this
* field is only valid if \c array_info_cache_valid is true.
*/
size_t enabled_client_array_count;
 
/**
* \name ARRAY_INFO cache.
*
* These fields track the state of the ARRAY_INFO cache. The
* \c array_info_cache_size is the size of the actual data stored in
* \c array_info_cache. \c array_info_cache_buffer_size is the size of
* the buffer. This will always be greater than or equal to
* \c array_info_cache_size.
*
* \note
* There are some bytes of extra data before \c array_info_cache that is
* used to hold the header for RenderLarge commands. This is
* \b not included in \c array_info_cache_size or
* \c array_info_cache_buffer_size. \c array_info_cache_base stores a
* pointer to the true start of the buffer (i.e., what malloc returned).
*/
/*@{ */
size_t array_info_cache_size;
size_t array_info_cache_buffer_size;
void *array_info_cache;
void *array_info_cache_base;
/*@} */
 
 
/**
* Is the cache of ARRAY_INFO data valid? The cache can become invalid
* when one of several state changes occur. Among these chages are
* modifying the array settings for an enabled array and enabling /
* disabling an array.
*/
GLboolean array_info_cache_valid;
 
/**
* Is it possible to use the GL 1.1 / EXT_vertex_arrays protocol? Use
* of this protocol is disabled with really old servers (i.e., servers
* that don't support GL 1.1 or EXT_vertex_arrays) or when an environment
* variable is set.
*
* \todo
* GL 1.1 and EXT_vertex_arrays use identical protocol, but have different
* opcodes for \c glDrawArrays. For servers that advertise one or the
* other, there should be a way to select which opcode to use.
*/
GLboolean old_DrawArrays_possible;
 
/**
* Is it possible to use the new GL X.X / ARB_vertex_buffer_object
* protocol?
*
* \todo
* This protocol has not yet been defined by the ARB, but is currently a
* work in progress. This field is a place-holder.
*/
GLboolean new_DrawArrays_possible;
 
/**
* Active texture unit set by \c glClientActiveTexture.
*
* \sa __glXGetActiveTextureUnit
*/
unsigned active_texture_unit;
 
/**
* Number of supported texture units. Even if ARB_multitexture /
* GL 1.3 are not supported, this will be at least 1. When multitexture
* is supported, this will be the value queried by calling
* \c glGetIntegerv with \c GL_MAX_TEXTURE_UNITS.
*
* \todo
* Investigate if this should be the value of \c GL_MAX_TEXTURE_COORDS
* instead (if GL 2.0 / ARB_fragment_shader / ARB_fragment_program /
* NV_fragment_program are supported).
*/
unsigned num_texture_units;
 
/**
* Number of generic vertex program attribs. If GL_ARB_vertex_program
* is not supported, this will be zero. Otherwise it will be the value
* queries by calling \c glGetProgramiv with \c GL_VERTEX_PROGRAM_ARB
* and \c GL_MAX_PROGRAM_ATTRIBS_ARB.
*/
unsigned num_vertex_program_attribs;
 
/**
* \n Methods for implementing various GL functions.
*
* These method pointers are only valid \c array_info_cache_valid is set.
* When each function starts, it much check \c array_info_cache_valid.
* If it is not set, it must call \c fill_array_info_cache and call
* the new method.
*
* \sa fill_array_info_cache
*
* \todo
* Write code to plug these functions directly into the dispatch table.
*/
/*@{ */
void (*DrawArrays) (GLenum, GLint, GLsizei);
void (*DrawElements) (GLenum mode, GLsizei count, GLenum type,
const GLvoid * indices);
/*@} */
 
struct array_stack_state *stack;
unsigned active_texture_unit_stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
unsigned stack_index;
};
 
#endif /* _INDIRECT_VA_PRIVATE_ */
/contrib/sdk/sources/Mesa/src/glx/indirect_vertex_program.c
0,0 → 1,293
/*
* (C) Copyright IBM Corporation 2005
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* IBM,
* AND/OR THEIR 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 <inttypes.h>
#include <GL/gl.h>
#include "indirect.h"
#include "glxclient.h"
#include "indirect_vertex_array.h"
#include <GL/glxproto.h>
 
#if !defined(__GNUC__)
# define __builtin_expect(x, y) x
#endif
 
static void
do_vertex_attrib_enable(GLuint index, GLboolean val)
{
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
 
if (!__glXSetArrayEnable(state, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB,
index, val)) {
__glXSetError(gc, GL_INVALID_ENUM);
}
}
 
 
void
__indirect_glEnableVertexAttribArray(GLuint index)
{
do_vertex_attrib_enable(index, GL_TRUE);
}
 
 
void
__indirect_glDisableVertexAttribArray(GLuint index)
{
do_vertex_attrib_enable(index, GL_FALSE);
}
 
 
static void
get_parameter(unsigned opcode, unsigned size, GLenum target, GLuint index,
void *params)
{
struct glx_context *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
const GLuint cmdlen = 12;
 
if (__builtin_expect(dpy != NULL, 1)) {
GLubyte const *pc = __glXSetupVendorRequest(gc,
X_GLXVendorPrivateWithReply,
opcode, cmdlen);
 
*((GLenum *) (pc + 0)) = target;
*((GLuint *) (pc + 4)) = index;
*((GLuint *) (pc + 8)) = 0;
 
(void) __glXReadReply(dpy, size, params, GL_FALSE);
UnlockDisplay(dpy);
SyncHandle();
}
return;
}
 
 
void
__indirect_glGetProgramEnvParameterfvARB(GLenum target, GLuint index,
GLfloat * params)
{
get_parameter(1296, 4, target, index, params);
}
 
 
void
__indirect_glGetProgramEnvParameterdvARB(GLenum target, GLuint index,
GLdouble * params)
{
get_parameter(1297, 8, target, index, params);
}
 
 
void
__indirect_glGetProgramLocalParameterfvARB(GLenum target, GLuint index,
GLfloat * params)
{
get_parameter(1305, 4, target, index, params);
}
 
 
void
__indirect_glGetProgramLocalParameterdvARB(GLenum target, GLuint index,
GLdouble * params)
{
get_parameter(1306, 8, target, index, params);
}
 
 
void
__indirect_glGetVertexAttribPointerv(GLuint index, GLenum pname,
GLvoid ** pointer)
{
struct glx_context *const gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
 
if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB) {
__glXSetError(gc, GL_INVALID_ENUM);
}
 
if (!__glXGetArrayPointer(state, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB,
index, pointer)) {
__glXSetError(gc, GL_INVALID_VALUE);
}
}
 
 
/**
* Get the selected attribute from the vertex array state vector.
*
* \returns
* On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned.
*/
static GLboolean
get_attrib_array_data(__GLXattribute * state, GLuint index, GLenum cap,
GLintptr * data)
{
GLboolean retval = GL_FALSE;
const GLenum attrib = GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB;
 
switch (cap) {
case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB:
retval = __glXGetArrayEnable(state, attrib, index, data);
break;
 
case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB:
retval = __glXGetArraySize(state, attrib, index, data);
break;
 
case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB:
retval = __glXGetArrayStride(state, attrib, index, data);
break;
 
case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB:
retval = __glXGetArrayType(state, attrib, index, data);
break;
 
case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB:
retval = __glXGetArrayNormalized(state, attrib, index, data);
break;
}
 
 
return retval;
}
 
 
static void
get_vertex_attrib(struct glx_context * gc, unsigned vop,
GLuint index, GLenum pname, xReply * reply)
{
Display *const dpy = gc->currentDpy;
GLubyte *const pc = __glXSetupVendorRequest(gc,
X_GLXVendorPrivateWithReply,
vop, 8);
 
*((uint32_t *) (pc + 0)) = index;
*((uint32_t *) (pc + 4)) = pname;
 
(void) _XReply(dpy, reply, 0, False);
}
 
 
void
__indirect_glGetVertexAttribiv(GLuint index, GLenum pname, GLint * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
xGLXSingleReply reply;
 
 
get_vertex_attrib(gc, 1303, index, pname, (xReply *) & reply);
 
if (reply.size != 0) {
GLintptr data;
 
 
if (get_attrib_array_data(state, index, pname, &data)) {
*params = (GLint) data;
}
else {
if (reply.size == 1) {
*params = (GLint) reply.pad3;
}
else {
_XRead(dpy, (void *) params, 4 * reply.size);
}
}
}
 
UnlockDisplay(dpy);
SyncHandle();
}
 
 
void
__indirect_glGetVertexAttribfv(GLuint index, GLenum pname,
GLfloat * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
xGLXSingleReply reply;
 
 
get_vertex_attrib(gc, 1302, index, pname, (xReply *) & reply);
 
if (reply.size != 0) {
GLintptr data;
 
 
if (get_attrib_array_data(state, index, pname, &data)) {
*params = (GLfloat) data;
}
else {
if (reply.size == 1) {
(void) memcpy(params, &reply.pad3, sizeof(GLfloat));
}
else {
_XRead(dpy, (void *) params, 4 * reply.size);
}
}
}
 
UnlockDisplay(dpy);
SyncHandle();
}
 
 
void
__indirect_glGetVertexAttribdv(GLuint index, GLenum pname,
GLdouble * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
xGLXSingleReply reply;
 
 
get_vertex_attrib(gc, 1301, index, pname, (xReply *) & reply);
 
if (reply.size != 0) {
GLintptr data;
 
 
if (get_attrib_array_data(state, index, pname, &data)) {
*params = (GLdouble) data;
}
else {
if (reply.size == 1) {
(void) memcpy(params, &reply.pad3, sizeof(GLdouble));
}
else {
_XRead(dpy, (void *) params, 8 * reply.size);
}
}
}
 
UnlockDisplay(dpy);
SyncHandle();
}
/contrib/sdk/sources/Mesa/src/glx/indirect_window_pos.c
0,0 → 1,112
/*
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
* (C) Copyright IBM Corporation 2004
* 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
* PRECISION INSIGHT, IBM,
* AND/OR THEIR 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 <GL/gl.h>
#include "indirect.h"
 
void
__indirect_glWindowPos2d(GLdouble x, GLdouble y)
{
__indirect_glWindowPos3f(x, y, 0.0);
}
 
void
__indirect_glWindowPos2i(GLint x, GLint y)
{
__indirect_glWindowPos3f(x, y, 0.0);
}
 
void
__indirect_glWindowPos2f(GLfloat x, GLfloat y)
{
__indirect_glWindowPos3f(x, y, 0.0);
}
 
void
__indirect_glWindowPos2s(GLshort x, GLshort y)
{
__indirect_glWindowPos3f(x, y, 0.0);
}
 
void
__indirect_glWindowPos2dv(const GLdouble * p)
{
__indirect_glWindowPos3f(p[0], p[1], 0.0);
}
 
void
__indirect_glWindowPos2fv(const GLfloat * p)
{
__indirect_glWindowPos3f(p[0], p[1], 0.0);
}
 
void
__indirect_glWindowPos2iv(const GLint * p)
{
__indirect_glWindowPos3f(p[0], p[1], 0.0);
}
 
void
__indirect_glWindowPos2sv(const GLshort * p)
{
__indirect_glWindowPos3f(p[0], p[1], 0.0);
}
 
void
__indirect_glWindowPos3d(GLdouble x, GLdouble y, GLdouble z)
{
__indirect_glWindowPos3f(x, y, z);
}
 
void
__indirect_glWindowPos3i(GLint x, GLint y, GLint z)
{
__indirect_glWindowPos3f(x, y, z);
}
 
void
__indirect_glWindowPos3s(GLshort x, GLshort y, GLshort z)
{
__indirect_glWindowPos3f(x, y, z);
}
 
void
__indirect_glWindowPos3dv(const GLdouble * p)
{
__indirect_glWindowPos3f(p[0], p[1], p[2]);
}
 
void
__indirect_glWindowPos3iv(const GLint * p)
{
__indirect_glWindowPos3f(p[0], p[1], p[2]);
}
 
void
__indirect_glWindowPos3sv(const GLshort * p)
{
__indirect_glWindowPos3f(p[0], p[1], p[2]);
}
/contrib/sdk/sources/Mesa/src/glx/packrender.h
0,0 → 1,243
#ifndef __GLX_packrender_h__
#define __GLX_packrender_h__
 
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
#include "glxclient.h"
 
/*
** The macros in this header convert the client machine's native data types to
** wire protocol data types. The header is part of the porting layer of the
** client library, and it is intended that hardware vendors will rewrite this
** header to suit their own machines.
*/
 
/*
** Pad a count of bytes to the nearest multiple of 4. The X protocol
** transfers data in 4 byte quantities, so this macro is used to
** insure the right amount of data being sent.
*/
#define __GLX_PAD(a) (((a)+3) & ~3)
 
/*
** Network size parameters
*/
#define sz_double 8
 
/* Setup for all commands */
#define __GLX_DECLARE_VARIABLES() \
struct glx_context *gc; \
GLubyte *pc, *pixelHeaderPC; \
GLuint compsize, cmdlen
 
#define __GLX_LOAD_VARIABLES() \
gc = __glXGetCurrentContext(); \
pc = gc->pc; \
/* Muffle compilers */ \
cmdlen = 0; (void)cmdlen; \
compsize = 0; (void)compsize; \
pixelHeaderPC = 0; (void)pixelHeaderPC
 
/*
** Variable sized command support macro. This macro is used by calls
** that are potentially larger than __GLX_SMALL_RENDER_CMD_SIZE.
** Because of their size, they may not automatically fit in the buffer.
** If the buffer can't hold the command then it is flushed so that
** the command will fit in the next buffer.
*/
#define __GLX_BEGIN_VARIABLE(opcode,size) \
if (pc + (size) > gc->bufEnd) { \
pc = __glXFlushRenderBuffer(gc, pc); \
} \
__GLX_PUT_SHORT(0,size); \
__GLX_PUT_SHORT(2,opcode)
 
#define __GLX_BEGIN_VARIABLE_LARGE(opcode,size) \
pc = __glXFlushRenderBuffer(gc, pc); \
__GLX_PUT_LONG(0,size); \
__GLX_PUT_LONG(4,opcode)
 
#define __GLX_BEGIN_VARIABLE_WITH_PIXEL(opcode,size) \
if (pc + (size) > gc->bufEnd) { \
pc = __glXFlushRenderBuffer(gc, pc); \
} \
__GLX_PUT_SHORT(0,size); \
__GLX_PUT_SHORT(2,opcode); \
pc += __GLX_RENDER_HDR_SIZE; \
pixelHeaderPC = pc; \
pc += __GLX_PIXEL_HDR_SIZE
 
#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(opcode,size) \
pc = __glXFlushRenderBuffer(gc, pc); \
__GLX_PUT_LONG(0,size); \
__GLX_PUT_LONG(4,opcode); \
pc += __GLX_RENDER_LARGE_HDR_SIZE; \
pixelHeaderPC = pc; \
pc += __GLX_PIXEL_HDR_SIZE
 
#define __GLX_BEGIN_VARIABLE_WITH_PIXEL_3D(opcode,size) \
if (pc + (size) > gc->bufEnd) { \
pc = __glXFlushRenderBuffer(gc, pc); \
} \
__GLX_PUT_SHORT(0,size); \
__GLX_PUT_SHORT(2,opcode); \
pc += __GLX_RENDER_HDR_SIZE; \
pixelHeaderPC = pc; \
pc += __GLX_PIXEL_3D_HDR_SIZE
 
#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL_3D(opcode,size) \
pc = __glXFlushRenderBuffer(gc, pc); \
__GLX_PUT_LONG(0,size); \
__GLX_PUT_LONG(4,opcode); \
pc += __GLX_RENDER_LARGE_HDR_SIZE; \
pixelHeaderPC = pc; \
pc += __GLX_PIXEL_3D_HDR_SIZE
 
/*
** Fixed size command support macro. This macro is used by calls that
** are never larger than __GLX_SMALL_RENDER_CMD_SIZE. Because they
** always fit in the buffer, and because the buffer promises to
** maintain enough room for them, we don't need to check for space
** before doing the storage work.
*/
#define __GLX_BEGIN(opcode,size) \
__GLX_PUT_SHORT(0,size); \
__GLX_PUT_SHORT(2,opcode)
 
/*
** Finish a rendering command by advancing the pc. If the pc is now past
** the limit pointer then there is no longer room for a
** __GLX_SMALL_RENDER_CMD_SIZE sized command, which will break the
** assumptions present in the __GLX_BEGIN macro. In this case the
** rendering buffer is flushed out into the X protocol stream (which may
** or may not do I/O).
*/
#define __GLX_END(size) \
pc += size; \
if (pc > gc->limit) { \
(void) __glXFlushRenderBuffer(gc, pc); \
} else { \
gc->pc = pc; \
}
 
/* Array copy macros */
#define __GLX_MEM_COPY(dest,src,bytes) \
if (src && dest) \
memcpy(dest, src, bytes)
 
/* Single item copy macros */
#define __GLX_PUT_CHAR(offset,a) \
*((INT8 *) (pc + offset)) = a
 
#ifndef _CRAY
#define __GLX_PUT_SHORT(offset,a) \
*((INT16 *) (pc + offset)) = a
 
#define __GLX_PUT_LONG(offset,a) \
*((INT32 *) (pc + offset)) = a
 
#define __GLX_PUT_FLOAT(offset,a) \
*((FLOAT32 *) (pc + offset)) = a
 
#else
#define __GLX_PUT_SHORT(offset,a) \
{ GLubyte *cp = (pc+offset); \
int shift = (64-16) - ((int)(cp) >> (64-6)); \
*(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); }
 
#define __GLX_PUT_LONG(offset,a) \
{ GLubyte *cp = (pc+offset); \
int shift = (64-32) - ((int)(cp) >> (64-6)); \
*(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); }
 
#define __GLX_PUT_FLOAT(offset,a) \
gl_put_float((pc + offset),a)
 
#define __GLX_PUT_DOUBLE(offset,a) \
gl_put_double(pc + offset, a)
 
extern void gl_put_float( /*GLubyte *, struct cray_single */ );
extern void gl_put_double( /*GLubyte *, struct cray_double */ );
#endif
 
#ifndef _CRAY
 
#ifdef __GLX_ALIGN64
/*
** This can certainly be done better for a particular machine
** architecture!
*/
#define __GLX_PUT_DOUBLE(offset,a) \
__GLX_MEM_COPY(pc + offset, &a, 8)
#else
#define __GLX_PUT_DOUBLE(offset,a) \
*((FLOAT64 *) (pc + offset)) = a
#endif
 
#endif
 
#define __GLX_PUT_CHAR_ARRAY(offset,a,alen) \
__GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT8)
 
#ifndef _CRAY
#define __GLX_PUT_SHORT_ARRAY(offset,a,alen) \
__GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT16)
 
#define __GLX_PUT_LONG_ARRAY(offset,a,alen) \
__GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT32)
 
#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen) \
__GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT32)
 
#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \
__GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT64)
 
#else
#define __GLX_PUT_SHORT_ARRAY(offset,a,alen) \
gl_put_short_array((GLubyte *)(pc + offset), a, alen * __GLX_SIZE_INT16)
 
#define __GLX_PUT_LONG_ARRAY(offset,a,alen) \
gl_put_long_array((GLubyte *)(pc + offset), (long *)a, alen * __GLX_SIZE_INT32)
 
#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen) \
gl_put_float_array((GLubyte *)(pc + offset), (float *)a, alen * __GLX_SIZE_FLOAT32)
 
#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \
gl_put_double_array((GLubyte *)(pc + offset), (double *)a, alen * __GLX_SIZE_FLOAT64)
 
extern gl_put_short_array(GLubyte *, short *, int);
extern gl_put_long_array(GLubyte *, long *, int);
extern gl_put_float_array(GLubyte *, float *, int);
extern gl_put_double_array(GLubyte *, double *, int);
 
#endif /* _CRAY */
 
#endif /* !__GLX_packrender_h__ */
/contrib/sdk/sources/Mesa/src/glx/packsingle.h
0,0 → 1,213
#ifndef __GLX_packsingle_h__
#define __GLX_packsingle_h__
 
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
#include "packrender.h"
 
/*
** The macros in this header convert wire protocol data types to the client
** machine's native data types. The header is part of the porting layer of
** the client library, and it is intended that hardware vendors will rewrite
** this header to suit their own machines.
*/
 
/*
** Dummy define to make the GetReqExtra macro happy. The value is not
** used, but instead the code in __GLX_SINGLE_BEGIN issues its own store
** to req->reqType with the proper code (our extension code).
*/
#define X_GLXSingle 0
 
/* Declare common variables used during a single command */
#define __GLX_SINGLE_DECLARE_VARIABLES() \
struct glx_context *gc = __glXGetCurrentContext(); \
GLubyte *pc, *pixelHeaderPC; \
GLuint compsize, cmdlen; \
Display *dpy = gc->currentDpy; \
xGLXSingleReq *req
 
#define __GLX_SINGLE_LOAD_VARIABLES() \
pc = gc->pc; \
/* Muffle compilers */ \
pixelHeaderPC = 0; (void)pixelHeaderPC; \
compsize = 0; (void)compsize; \
cmdlen = 0; (void)cmdlen
 
/* Start a single command */
#define __GLX_SINGLE_BEGIN(opcode,bytes) \
if (dpy) { \
(void) __glXFlushRenderBuffer(gc, pc); \
LockDisplay(dpy); \
GetReqExtra(GLXSingle,bytes,req); \
req->reqType = gc->majorOpcode; \
req->glxCode = opcode; \
req->contextTag = gc->currentContextTag; \
pc = ((GLubyte *)(req) + sz_xGLXSingleReq)
 
/* End a single command */
#define __GLX_SINGLE_END() \
UnlockDisplay(dpy); \
SyncHandle(); \
}
 
/* Store data to sending for a single command */
#define __GLX_SINGLE_PUT_CHAR(offset,a) \
*((INT8 *) (pc + offset)) = a
 
#ifndef CRAY
#define __GLX_SINGLE_PUT_SHORT(offset,a) \
*((INT16 *) (pc + offset)) = a
 
#define __GLX_SINGLE_PUT_LONG(offset,a) \
*((INT32 *) (pc + offset)) = a
 
#define __GLX_SINGLE_PUT_FLOAT(offset,a) \
*((FLOAT32 *) (pc + offset)) = a
 
#else
#define __GLX_SINGLE_PUT_SHORT(offset,a) \
{ GLubyte *cp = (pc+offset); \
int shift = (64-16) - ((int)(cp) >> (64-6)); \
*(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); }
 
#define __GLX_SINGLE_PUT_LONG(offset,a) \
{ GLubyte *cp = (pc+offset); \
int shift = (64-32) - ((int)(cp) >> (64-6)); \
*(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); }
 
#define __GLX_SINGLE_PUT_FLOAT(offset,a) \
gl_put_float(pc + offset, a)
#endif
 
/* Read support macros */
#define __GLX_SINGLE_READ_XREPLY() \
(void) _XReply(dpy, (xReply*) &reply, 0, False)
 
#define __GLX_SINGLE_GET_RETVAL(a,cast) \
a = (cast) reply.retval
 
#define __GLX_SINGLE_GET_SIZE(a) \
a = (GLint) reply.size
 
#ifndef _CRAY
#define __GLX_SINGLE_GET_CHAR(p) \
*p = *(GLbyte *)&reply.pad3;
 
#define __GLX_SINGLE_GET_SHORT(p) \
*p = *(GLshort *)&reply.pad3;
 
#define __GLX_SINGLE_GET_LONG(p) \
*p = *(GLint *)&reply.pad3;
 
#define __GLX_SINGLE_GET_FLOAT(p) \
*p = *(GLfloat *)&reply.pad3;
 
#else
#define __GLX_SINGLE_GET_CHAR(p) \
*p = reply.pad3 >> 24;
 
#define __GLX_SINGLE_GET_SHORT(p) \
{int t = reply.pad3 >> 16; \
*p = (t & 0x8000) ? (t | ~0xffff) : (t & 0xffff);}
 
#define __GLX_SINGLE_GET_LONG(p) \
{int t = reply.pad3; \
*p = (t & 0x80000000) ? (t | ~0xffffffff) : (t & 0xffffffff);}
 
#define PAD3OFFSET 16
#define __GLX_SINGLE_GET_FLOAT(p) \
*p = gl_ntoh_float((GLubyte *)&reply + PAD3OFFSET);
 
#define __GLX_SINGLE_GET_DOUBLE(p) \
*p = gl_ntoh_double((GLubyte *)&reply + PAD3OFFSET);
 
extern float gl_ntoh_float(GLubyte *);
extern float gl_ntoh_double(GLubyte *);
#endif
 
#ifndef _CRAY
 
#ifdef __GLX_ALIGN64
#define __GLX_SINGLE_GET_DOUBLE(p) \
__GLX_MEM_COPY(p, &reply.pad3, 8)
#else
#define __GLX_SINGLE_GET_DOUBLE(p) \
*p = *(GLdouble *)&reply.pad3
#endif
 
#endif
 
/* Get an array of typed data */
#define __GLX_SINGLE_GET_VOID_ARRAY(a,alen) \
{ \
GLint slop = alen*__GLX_SIZE_INT8 & 3; \
_XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
if (slop) _XEatData(dpy,4-slop); \
}
 
#define __GLX_SINGLE_GET_CHAR_ARRAY(a,alen) \
{ \
GLint slop = alen*__GLX_SIZE_INT8 & 3; \
_XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
if (slop) _XEatData(dpy,4-slop); \
}
 
 
#define __GLX_SINGLE_GET_SHORT_ARRAY(a,alen) \
{ \
GLint slop = (alen*__GLX_SIZE_INT16) & 3; \
_XRead(dpy,(char *)a,alen*__GLX_SIZE_INT16); \
if (slop) _XEatData(dpy,4-slop); \
}
 
#define __GLX_SINGLE_GET_LONG_ARRAY(a,alen) \
_XRead(dpy,(char *)a,alen*__GLX_SIZE_INT32);
 
#ifndef _CRAY
#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
_XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32);
 
#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
_XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64);
 
#else
#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
gl_get_float_array(dpy,a,alen);
 
#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
gl_get_double_array(dpy, a, alen);
 
extern void gl_get_float_array(Display * dpy, float *a, int alen);
extern void gl_get_double_array(Display * dpy, double *a, int alen);
#endif
 
#endif /* !__GLX_packsingle_h__ */
/contrib/sdk/sources/Mesa/src/glx/pixel.c
0,0 → 1,461
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
#include "packrender.h"
 
static const GLubyte MsbToLsbTable[256] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
};
 
static const GLubyte LowBitsMask[9] = {
0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff,
};
 
static const GLubyte HighBitsMask[9] = {
0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff,
};
 
 
/*
** Copy bitmap data from clients packed memory applying unpacking modes as the
** data is transfered into the destImage buffer. Return in modes the
** set of pixel modes that are to be done by the server.
*/
static void
FillBitmap(struct glx_context * gc, GLint width, GLint height,
GLenum format, const GLvoid * userdata, GLubyte * destImage)
{
const __GLXattribute *state = gc->client_state_private;
GLint rowLength = state->storeUnpack.rowLength;
GLint alignment = state->storeUnpack.alignment;
GLint skipPixels = state->storeUnpack.skipPixels;
GLint skipRows = state->storeUnpack.skipRows;
GLint lsbFirst = state->storeUnpack.lsbFirst;
GLint elementsLeft, bitOffset, currentByte, nextByte, highBitMask;
GLint lowBitMask, i;
GLint components, groupsPerRow, rowSize, padding, elementsPerRow;
const GLubyte *start, *iter;
 
if (rowLength > 0) {
groupsPerRow = rowLength;
}
else {
groupsPerRow = width;
}
components = __glElementsPerGroup(format, GL_BITMAP);
rowSize = (groupsPerRow * components + 7) >> 3;
padding = (rowSize % alignment);
if (padding) {
rowSize += alignment - padding;
}
start = ((const GLubyte *) userdata) + skipRows * rowSize +
((skipPixels * components) >> 3);
bitOffset = (skipPixels * components) & 7;
highBitMask = LowBitsMask[8 - bitOffset];
lowBitMask = HighBitsMask[bitOffset];
elementsPerRow = width * components;
for (i = 0; i < height; i++) {
elementsLeft = elementsPerRow;
iter = start;
while (elementsLeft) {
/* First retrieve low bits from current byte */
if (lsbFirst) {
currentByte = MsbToLsbTable[iter[0]];
}
else {
currentByte = iter[0];
}
if (bitOffset) {
/* Need to read next byte to finish current byte */
if (elementsLeft > (8 - bitOffset)) {
if (lsbFirst) {
nextByte = MsbToLsbTable[iter[1]];
}
else {
nextByte = iter[1];
}
currentByte =
((currentByte & highBitMask) << bitOffset) |
((nextByte & lowBitMask) >> (8 - bitOffset));
}
else {
currentByte = ((currentByte & highBitMask) << bitOffset);
}
}
if (elementsLeft >= 8) {
*destImage = currentByte;
elementsLeft -= 8;
}
else {
*destImage = currentByte & HighBitsMask[elementsLeft];
elementsLeft = 0;
}
destImage++;
iter++;
}
start += rowSize;
}
}
 
/*
** Extract array from user's data applying all pixel store modes.
** The internal packed array format used has LSB_FIRST = FALSE and
** ALIGNMENT = 1.
*/
void
__glFillImage(struct glx_context * gc, GLint dim, GLint width, GLint height,
GLint depth, GLenum format, GLenum type,
const GLvoid * userdata, GLubyte * newimage, GLubyte * modes)
{
const __GLXattribute *state = gc->client_state_private;
GLint rowLength = state->storeUnpack.rowLength;
GLint imageHeight = state->storeUnpack.imageHeight;
GLint alignment = state->storeUnpack.alignment;
GLint skipPixels = state->storeUnpack.skipPixels;
GLint skipRows = state->storeUnpack.skipRows;
GLint skipImages = state->storeUnpack.skipImages;
GLint swapBytes = state->storeUnpack.swapEndian;
GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize;
GLint elementsPerRow, imageSize, rowsPerImage, h, i, j, k;
const GLubyte *start, *iter, *itera, *iterb, *iterc;
GLubyte *iter2;
 
if (type == GL_BITMAP) {
FillBitmap(gc, width, height, format, userdata, newimage);
}
else {
components = __glElementsPerGroup(format, type);
if (rowLength > 0) {
groupsPerRow = rowLength;
}
else {
groupsPerRow = width;
}
if (imageHeight > 0) {
rowsPerImage = imageHeight;
}
else {
rowsPerImage = height;
}
 
elementSize = __glBytesPerElement(type);
groupSize = elementSize * components;
if (elementSize == 1)
swapBytes = 0;
 
rowSize = groupsPerRow * groupSize;
padding = (rowSize % alignment);
if (padding) {
rowSize += alignment - padding;
}
imageSize = rowSize * rowsPerImage;
start = ((const GLubyte *) userdata) + skipImages * imageSize +
skipRows * rowSize + skipPixels * groupSize;
iter2 = newimage;
elementsPerRow = width * components;
 
if (swapBytes) {
itera = start;
for (h = 0; h < depth; h++) {
iterb = itera;
for (i = 0; i < height; i++) {
iterc = iterb;
for (j = 0; j < elementsPerRow; j++) {
for (k = 1; k <= elementSize; k++) {
iter2[k - 1] = iterc[elementSize - k];
}
iter2 += elementSize;
iterc += elementSize;
}
iterb += rowSize;
}
itera += imageSize;
}
}
else {
itera = start;
for (h = 0; h < depth; h++) {
if (rowSize == elementsPerRow * elementSize) {
/* Ha! This is mondo easy! */
__GLX_MEM_COPY(iter2, itera,
elementsPerRow * elementSize * height);
iter2 += elementsPerRow * elementSize * height;
}
else {
iter = itera;
for (i = 0; i < height; i++) {
__GLX_MEM_COPY(iter2, iter, elementsPerRow * elementSize);
iter2 += elementsPerRow * elementSize;
iter += rowSize;
}
}
itera += imageSize;
}
}
}
 
/* Setup store modes that describe what we just did */
if (modes) {
if (dim < 3) {
(void) memcpy(modes, __glXDefaultPixelStore + 4, 20);
}
else {
(void) memcpy(modes, __glXDefaultPixelStore + 0, 36);
}
}
}
 
/*
** Empty a bitmap in LSB_FIRST=GL_FALSE and ALIGNMENT=4 format packing it
** into the clients memory using the pixel store PACK modes.
*/
static void
EmptyBitmap(struct glx_context * gc, GLint width, GLint height,
GLenum format, const GLubyte * sourceImage, GLvoid * userdata)
{
const __GLXattribute *state = gc->client_state_private;
GLint rowLength = state->storePack.rowLength;
GLint alignment = state->storePack.alignment;
GLint skipPixels = state->storePack.skipPixels;
GLint skipRows = state->storePack.skipRows;
GLint lsbFirst = state->storePack.lsbFirst;
GLint components, groupsPerRow, rowSize, padding, elementsPerRow;
GLint sourceRowSize, sourcePadding, sourceSkip;
GLubyte *start, *iter;
GLint elementsLeft, bitOffset, currentByte, highBitMask, lowBitMask;
GLint writeMask, i;
GLubyte writeByte;
 
components = __glElementsPerGroup(format, GL_BITMAP);
if (rowLength > 0) {
groupsPerRow = rowLength;
}
else {
groupsPerRow = width;
}
 
rowSize = (groupsPerRow * components + 7) >> 3;
padding = (rowSize % alignment);
if (padding) {
rowSize += alignment - padding;
}
sourceRowSize = (width * components + 7) >> 3;
sourcePadding = (sourceRowSize % 4);
if (sourcePadding) {
sourceSkip = 4 - sourcePadding;
}
else {
sourceSkip = 0;
}
start = ((GLubyte *) userdata) + skipRows * rowSize +
((skipPixels * components) >> 3);
bitOffset = (skipPixels * components) & 7;
highBitMask = LowBitsMask[8 - bitOffset];
lowBitMask = HighBitsMask[bitOffset];
elementsPerRow = width * components;
for (i = 0; i < height; i++) {
elementsLeft = elementsPerRow;
iter = start;
writeMask = highBitMask;
writeByte = 0;
while (elementsLeft) {
/* Set up writeMask (to write to current byte) */
if (elementsLeft + bitOffset < 8) {
/* Need to trim writeMask */
writeMask &= HighBitsMask[bitOffset + elementsLeft];
}
 
if (lsbFirst) {
currentByte = MsbToLsbTable[iter[0]];
}
else {
currentByte = iter[0];
}
 
if (bitOffset) {
writeByte |= (sourceImage[0] >> bitOffset);
currentByte = (currentByte & ~writeMask) |
(writeByte & writeMask);
writeByte = (sourceImage[0] << (8 - bitOffset));
}
else {
currentByte = (currentByte & ~writeMask) |
(sourceImage[0] & writeMask);
}
 
if (lsbFirst) {
iter[0] = MsbToLsbTable[currentByte];
}
else {
iter[0] = currentByte;
}
 
if (elementsLeft >= 8) {
elementsLeft -= 8;
}
else {
elementsLeft = 0;
}
sourceImage++;
iter++;
writeMask = 0xff;
}
if (writeByte) {
/* Some data left over that still needs writing */
writeMask &= lowBitMask;
if (lsbFirst) {
currentByte = MsbToLsbTable[iter[0]];
}
else {
currentByte = iter[0];
}
currentByte = (currentByte & ~writeMask) | (writeByte & writeMask);
if (lsbFirst) {
iter[0] = MsbToLsbTable[currentByte];
}
else {
iter[0] = currentByte;
}
}
start += rowSize;
sourceImage += sourceSkip;
}
}
 
/*
** Insert array into user's data applying all pixel store modes.
** The packed array format from the server is LSB_FIRST = FALSE,
** SWAP_BYTES = the current pixel storage pack mode, and ALIGNMENT = 4.
** Named __glEmptyImage() because it is the opposite of __glFillImage().
*/
/* ARGSUSED */
void
__glEmptyImage(struct glx_context * gc, GLint dim, GLint width, GLint height,
GLint depth, GLenum format, GLenum type,
const GLubyte * sourceImage, GLvoid * userdata)
{
const __GLXattribute *state = gc->client_state_private;
GLint rowLength = state->storePack.rowLength;
GLint imageHeight = state->storePack.imageHeight;
GLint alignment = state->storePack.alignment;
GLint skipPixels = state->storePack.skipPixels;
GLint skipRows = state->storePack.skipRows;
GLint skipImages = state->storePack.skipImages;
GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize;
GLint elementsPerRow, sourceRowSize, sourcePadding, h, i;
GLint imageSize, rowsPerImage;
GLubyte *start, *iter, *itera;
 
if (type == GL_BITMAP) {
EmptyBitmap(gc, width, height, format, sourceImage, userdata);
}
else {
components = __glElementsPerGroup(format, type);
if (rowLength > 0) {
groupsPerRow = rowLength;
}
else {
groupsPerRow = width;
}
if (imageHeight > 0) {
rowsPerImage = imageHeight;
}
else {
rowsPerImage = height;
}
elementSize = __glBytesPerElement(type);
groupSize = elementSize * components;
rowSize = groupsPerRow * groupSize;
padding = (rowSize % alignment);
if (padding) {
rowSize += alignment - padding;
}
sourceRowSize = width * groupSize;
sourcePadding = (sourceRowSize % 4);
if (sourcePadding) {
sourceRowSize += 4 - sourcePadding;
}
imageSize = sourceRowSize * rowsPerImage;
start = ((GLubyte *) userdata) + skipImages * imageSize +
skipRows * rowSize + skipPixels * groupSize;
elementsPerRow = width * components;
 
itera = start;
for (h = 0; h < depth; h++) {
if ((rowSize == sourceRowSize) && (sourcePadding == 0)) {
/* Ha! This is mondo easy! */
__GLX_MEM_COPY(itera, sourceImage,
elementsPerRow * elementSize * height);
sourceImage += elementsPerRow * elementSize * height;
}
else {
iter = itera;
for (i = 0; i < height; i++) {
__GLX_MEM_COPY(iter, sourceImage,
elementsPerRow * elementSize);
sourceImage += sourceRowSize;
iter += rowSize;
}
}
itera += imageSize;
}
}
}
/contrib/sdk/sources/Mesa/src/glx/pixelstore.c
0,0 → 1,352
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
#include "glxclient.h"
#include "indirect.h"
 
#if !defined(__GNUC__)
# define __builtin_expect(x, y) x
#endif
 
/**
* Send glPixelStore command to the server
*
* \param gc Current GLX context
* \param sop Either \c X_GLsop_PixelStoref or \c X_GLsop_PixelStorei
* \param pname Selector of which pixel parameter is to be set.
* \param param Value that \c pname is set to.
*
* \sa __indirect_glPixelStorei, __indirect_glPixelStoref
*/
static void
send_PixelStore(struct glx_context * gc, unsigned sop, GLenum pname,
const void *param)
{
Display *const dpy = gc->currentDpy;
const GLuint cmdlen = 8;
if (__builtin_expect(dpy != NULL, 1)) {
GLubyte const *pc = __glXSetupSingleRequest(gc, sop, cmdlen);
(void) memcpy((void *) (pc + 0), (void *) (&pname), 4);
(void) memcpy((void *) (pc + 4), param, 4);
UnlockDisplay(dpy);
SyncHandle();
}
return;
}
 
/*
** Specify parameters that control the storage format of pixel arrays.
*/
void
__indirect_glPixelStoref(GLenum pname, GLfloat param)
{
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = gc->client_state_private;
Display *dpy = gc->currentDpy;
GLuint a;
 
if (!dpy)
return;
 
switch (pname) {
case GL_PACK_ROW_LENGTH:
a = (GLuint) (param + 0.5);
if (((GLint) a) < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storePack.rowLength = a;
break;
case GL_PACK_IMAGE_HEIGHT:
a = (GLuint) (param + 0.5);
if (((GLint) a) < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storePack.imageHeight = a;
break;
case GL_PACK_SKIP_ROWS:
a = (GLuint) (param + 0.5);
if (((GLint) a) < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storePack.skipRows = a;
break;
case GL_PACK_SKIP_PIXELS:
a = (GLuint) (param + 0.5);
if (((GLint) a) < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storePack.skipPixels = a;
break;
case GL_PACK_SKIP_IMAGES:
a = (GLuint) (param + 0.5);
if (((GLint) a) < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storePack.skipImages = a;
break;
case GL_PACK_ALIGNMENT:
a = (GLint) (param + 0.5);
switch (a) {
case 1:
case 2:
case 4:
case 8:
state->storePack.alignment = a;
break;
default:
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
break;
case GL_PACK_SWAP_BYTES:
state->storePack.swapEndian = (param != 0);
break;
case GL_PACK_LSB_FIRST:
state->storePack.lsbFirst = (param != 0);
break;
 
case GL_UNPACK_ROW_LENGTH:
a = (GLuint) (param + 0.5);
if (((GLint) a) < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storeUnpack.rowLength = a;
break;
case GL_UNPACK_IMAGE_HEIGHT:
a = (GLuint) (param + 0.5);
if (((GLint) a) < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storeUnpack.imageHeight = a;
break;
case GL_UNPACK_SKIP_ROWS:
a = (GLuint) (param + 0.5);
if (((GLint) a) < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storeUnpack.skipRows = a;
break;
case GL_UNPACK_SKIP_PIXELS:
a = (GLuint) (param + 0.5);
if (((GLint) a) < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storeUnpack.skipPixels = a;
break;
case GL_UNPACK_SKIP_IMAGES:
a = (GLuint) (param + 0.5);
if (((GLint) a) < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storeUnpack.skipImages = a;
break;
case GL_UNPACK_ALIGNMENT:
a = (GLint) (param + 0.5);
switch (a) {
case 1:
case 2:
case 4:
case 8:
state->storeUnpack.alignment = a;
break;
default:
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
break;
case GL_UNPACK_SWAP_BYTES:
state->storeUnpack.swapEndian = (param != 0);
break;
case GL_UNPACK_LSB_FIRST:
state->storeUnpack.lsbFirst = (param != 0);
break;
 
/* Group all of the pixel store modes that need to be sent to the
* server here. Care must be used to only send modes to the server that
* won't affect the size of the data sent to or received from the
* server. GL_PACK_INVERT_MESA is safe in this respect, but other,
* future modes may not be.
*/
case GL_PACK_INVERT_MESA:
send_PixelStore(gc, X_GLsop_PixelStoref, pname, &param);
break;
 
default:
__glXSetError(gc, GL_INVALID_ENUM);
break;
}
}
 
void
__indirect_glPixelStorei(GLenum pname, GLint param)
{
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = gc->client_state_private;
Display *dpy = gc->currentDpy;
 
if (!dpy)
return;
 
switch (pname) {
case GL_PACK_ROW_LENGTH:
if (param < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storePack.rowLength = param;
break;
case GL_PACK_IMAGE_HEIGHT:
if (param < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storePack.imageHeight = param;
break;
case GL_PACK_SKIP_ROWS:
if (param < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storePack.skipRows = param;
break;
case GL_PACK_SKIP_PIXELS:
if (param < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storePack.skipPixels = param;
break;
case GL_PACK_SKIP_IMAGES:
if (param < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storePack.skipImages = param;
break;
case GL_PACK_ALIGNMENT:
switch (param) {
case 1:
case 2:
case 4:
case 8:
state->storePack.alignment = param;
break;
default:
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
break;
case GL_PACK_SWAP_BYTES:
state->storePack.swapEndian = (param != 0);
break;
case GL_PACK_LSB_FIRST:
state->storePack.lsbFirst = (param != 0);
break;
 
case GL_UNPACK_ROW_LENGTH:
if (param < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storeUnpack.rowLength = param;
break;
case GL_UNPACK_IMAGE_HEIGHT:
if (param < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storeUnpack.imageHeight = param;
break;
case GL_UNPACK_SKIP_ROWS:
if (param < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storeUnpack.skipRows = param;
break;
case GL_UNPACK_SKIP_PIXELS:
if (param < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storeUnpack.skipPixels = param;
break;
case GL_UNPACK_SKIP_IMAGES:
if (param < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
state->storeUnpack.skipImages = param;
break;
case GL_UNPACK_ALIGNMENT:
switch (param) {
case 1:
case 2:
case 4:
case 8:
state->storeUnpack.alignment = param;
break;
default:
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
break;
case GL_UNPACK_SWAP_BYTES:
state->storeUnpack.swapEndian = (param != 0);
break;
case GL_UNPACK_LSB_FIRST:
state->storeUnpack.lsbFirst = (param != 0);
break;
 
/* Group all of the pixel store modes that need to be sent to the
* server here. Care must be used to only send modes to the server that
* won't affect the size of the data sent to or received from the
* server. GL_PACK_INVERT_MESA is safe in this respect, but other,
* future modes may not be.
*/
case GL_PACK_INVERT_MESA:
send_PixelStore(gc, X_GLsop_PixelStorei, pname, &param);
break;
 
default:
__glXSetError(gc, GL_INVALID_ENUM);
break;
}
}
/contrib/sdk/sources/Mesa/src/glx/render2.c
0,0 → 1,381
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
#include "packrender.h"
#include "indirect.h"
#include "indirect_size.h"
 
/*
** This file contains routines that might need to be transported as
** GLXRender or GLXRenderLarge commands, and these commands don't
** use the pixel header. See renderpix.c for those routines.
*/
 
void
__indirect_glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
GLint order, const GLdouble * pnts)
{
__GLX_DECLARE_VARIABLES();
GLint k;
 
__GLX_LOAD_VARIABLES();
k = __glMap1d_size(target);
if (k == 0) {
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
else if (stride < k || order <= 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
compsize = k * order * __GLX_SIZE_FLOAT64;
cmdlen = 28 + compsize;
if (!gc->currentDpy)
return;
 
if (cmdlen <= gc->maxSmallRenderCommandSize) {
/* Use GLXRender protocol to send small command */
__GLX_BEGIN_VARIABLE(X_GLrop_Map1d, cmdlen);
__GLX_PUT_DOUBLE(4, u1);
__GLX_PUT_DOUBLE(12, u2);
__GLX_PUT_LONG(20, target);
__GLX_PUT_LONG(24, order);
/*
** NOTE: the doubles that follow are not aligned because of 3
** longs preceeding
*/
__glFillMap1d(k, order, stride, pnts, (pc + 28));
__GLX_END(cmdlen);
}
else {
/* Use GLXRenderLarge protocol to send command */
__GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1d, cmdlen + 4);
__GLX_PUT_DOUBLE(8, u1);
__GLX_PUT_DOUBLE(16, u2);
__GLX_PUT_LONG(24, target);
__GLX_PUT_LONG(28, order);
 
/*
** NOTE: the doubles that follow are not aligned because of 3
** longs preceeding
*/
if (stride != k) {
GLubyte *buf;
 
buf = malloc(compsize);
if (!buf) {
__glXSetError(gc, GL_OUT_OF_MEMORY);
return;
}
__glFillMap1d(k, order, stride, pnts, buf);
__glXSendLargeCommand(gc, pc, 32, buf, compsize);
free((char *) buf);
}
else {
/* Data is already packed. Just send it out */
__glXSendLargeCommand(gc, pc, 32, pnts, compsize);
}
}
}
 
void
__indirect_glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
GLint order, const GLfloat * pnts)
{
__GLX_DECLARE_VARIABLES();
GLint k;
 
__GLX_LOAD_VARIABLES();
k = __glMap1f_size(target);
if (k == 0) {
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
else if (stride < k || order <= 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
compsize = k * order * __GLX_SIZE_FLOAT32;
cmdlen = 20 + compsize;
if (!gc->currentDpy)
return;
 
/*
** The order that arguments are packed is different from the order
** for glMap1d.
*/
if (cmdlen <= gc->maxSmallRenderCommandSize) {
/* Use GLXRender protocol to send small command */
__GLX_BEGIN_VARIABLE(X_GLrop_Map1f, cmdlen);
__GLX_PUT_LONG(4, target);
__GLX_PUT_FLOAT(8, u1);
__GLX_PUT_FLOAT(12, u2);
__GLX_PUT_LONG(16, order);
__glFillMap1f(k, order, stride, pnts, (GLubyte *) (pc + 20));
__GLX_END(cmdlen);
}
else {
/* Use GLXRenderLarge protocol to send command */
__GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1f, cmdlen + 4);
__GLX_PUT_LONG(8, target);
__GLX_PUT_FLOAT(12, u1);
__GLX_PUT_FLOAT(16, u2);
__GLX_PUT_LONG(20, order);
 
if (stride != k) {
GLubyte *buf;
 
buf = malloc(compsize);
if (!buf) {
__glXSetError(gc, GL_OUT_OF_MEMORY);
return;
}
__glFillMap1f(k, order, stride, pnts, buf);
__glXSendLargeCommand(gc, pc, 24, buf, compsize);
free((char *) buf);
}
else {
/* Data is already packed. Just send it out */
__glXSendLargeCommand(gc, pc, 24, pnts, compsize);
}
}
}
 
void
__indirect_glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustr,
GLint uord, GLdouble v1, GLdouble v2, GLint vstr,
GLint vord, const GLdouble * pnts)
{
__GLX_DECLARE_VARIABLES();
GLint k;
 
__GLX_LOAD_VARIABLES();
k = __glMap2d_size(target);
if (k == 0) {
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
else if (vstr < k || ustr < k || vord <= 0 || uord <= 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
compsize = k * uord * vord * __GLX_SIZE_FLOAT64;
cmdlen = 48 + compsize;
if (!gc->currentDpy)
return;
 
if (cmdlen <= gc->maxSmallRenderCommandSize) {
/* Use GLXRender protocol to send small command */
__GLX_BEGIN_VARIABLE(X_GLrop_Map2d, cmdlen);
__GLX_PUT_DOUBLE(4, u1);
__GLX_PUT_DOUBLE(12, u2);
__GLX_PUT_DOUBLE(20, v1);
__GLX_PUT_DOUBLE(28, v2);
__GLX_PUT_LONG(36, target);
__GLX_PUT_LONG(40, uord);
__GLX_PUT_LONG(44, vord);
/*
** Pack into a u-major ordering.
** NOTE: the doubles that follow are not aligned because of 5
** longs preceeding
*/
__glFillMap2d(k, uord, vord, ustr, vstr, pnts, (GLdouble *) (pc + 48));
__GLX_END(cmdlen);
}
else {
/* Use GLXRenderLarge protocol to send command */
__GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2d, cmdlen + 4);
__GLX_PUT_DOUBLE(8, u1);
__GLX_PUT_DOUBLE(16, u2);
__GLX_PUT_DOUBLE(24, v1);
__GLX_PUT_DOUBLE(32, v2);
__GLX_PUT_LONG(40, target);
__GLX_PUT_LONG(44, uord);
__GLX_PUT_LONG(48, vord);
 
/*
** NOTE: the doubles that follow are not aligned because of 5
** longs preceeding
*/
if ((vstr != k) || (ustr != k * vord)) {
GLdouble *buf;
 
buf = malloc(compsize);
if (!buf) {
__glXSetError(gc, GL_OUT_OF_MEMORY);
return;
}
/*
** Pack into a u-major ordering.
*/
__glFillMap2d(k, uord, vord, ustr, vstr, pnts, buf);
__glXSendLargeCommand(gc, pc, 52, buf, compsize);
free((char *) buf);
}
else {
/* Data is already packed. Just send it out */
__glXSendLargeCommand(gc, pc, 52, pnts, compsize);
}
}
}
 
void
__indirect_glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustr,
GLint uord, GLfloat v1, GLfloat v2, GLint vstr, GLint vord,
const GLfloat * pnts)
{
__GLX_DECLARE_VARIABLES();
GLint k;
 
__GLX_LOAD_VARIABLES();
k = __glMap2f_size(target);
if (k == 0) {
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
else if (vstr < k || ustr < k || vord <= 0 || uord <= 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
compsize = k * uord * vord * __GLX_SIZE_FLOAT32;
cmdlen = 32 + compsize;
if (!gc->currentDpy)
return;
 
/*
** The order that arguments are packed is different from the order
** for glMap2d.
*/
if (cmdlen <= gc->maxSmallRenderCommandSize) {
/* Use GLXRender protocol to send small command */
__GLX_BEGIN_VARIABLE(X_GLrop_Map2f, cmdlen);
__GLX_PUT_LONG(4, target);
__GLX_PUT_FLOAT(8, u1);
__GLX_PUT_FLOAT(12, u2);
__GLX_PUT_LONG(16, uord);
__GLX_PUT_FLOAT(20, v1);
__GLX_PUT_FLOAT(24, v2);
__GLX_PUT_LONG(28, vord);
/*
** Pack into a u-major ordering.
*/
__glFillMap2f(k, uord, vord, ustr, vstr, pnts, (GLfloat *) (pc + 32));
__GLX_END(cmdlen);
}
else {
/* Use GLXRenderLarge protocol to send command */
__GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2f, cmdlen + 4);
__GLX_PUT_LONG(8, target);
__GLX_PUT_FLOAT(12, u1);
__GLX_PUT_FLOAT(16, u2);
__GLX_PUT_LONG(20, uord);
__GLX_PUT_FLOAT(24, v1);
__GLX_PUT_FLOAT(28, v2);
__GLX_PUT_LONG(32, vord);
 
if ((vstr != k) || (ustr != k * vord)) {
GLfloat *buf;
 
buf = malloc(compsize);
if (!buf) {
__glXSetError(gc, GL_OUT_OF_MEMORY);
return;
}
/*
** Pack into a u-major ordering.
*/
__glFillMap2f(k, uord, vord, ustr, vstr, pnts, buf);
__glXSendLargeCommand(gc, pc, 36, buf, compsize);
free((char *) buf);
}
else {
/* Data is already packed. Just send it out */
__glXSendLargeCommand(gc, pc, 36, pnts, compsize);
}
}
}
 
void
__indirect_glEnable(GLenum cap)
{
__GLX_DECLARE_VARIABLES();
 
__GLX_LOAD_VARIABLES();
if (!gc->currentDpy)
return;
 
switch (cap) {
case GL_COLOR_ARRAY:
case GL_EDGE_FLAG_ARRAY:
case GL_INDEX_ARRAY:
case GL_NORMAL_ARRAY:
case GL_TEXTURE_COORD_ARRAY:
case GL_VERTEX_ARRAY:
case GL_SECONDARY_COLOR_ARRAY:
case GL_FOG_COORD_ARRAY:
__indirect_glEnableClientState(cap);
return;
default:
break;
}
 
__GLX_BEGIN(X_GLrop_Enable, 8);
__GLX_PUT_LONG(4, cap);
__GLX_END(8);
}
 
void
__indirect_glDisable(GLenum cap)
{
__GLX_DECLARE_VARIABLES();
 
__GLX_LOAD_VARIABLES();
if (!gc->currentDpy)
return;
 
switch (cap) {
case GL_COLOR_ARRAY:
case GL_EDGE_FLAG_ARRAY:
case GL_INDEX_ARRAY:
case GL_NORMAL_ARRAY:
case GL_TEXTURE_COORD_ARRAY:
case GL_VERTEX_ARRAY:
case GL_SECONDARY_COLOR_ARRAY:
case GL_FOG_COORD_ARRAY:
__indirect_glDisableClientState(cap);
return;
default:
break;
}
 
__GLX_BEGIN(X_GLrop_Disable, 8);
__GLX_PUT_LONG(4, cap);
__GLX_END(8);
}
/contrib/sdk/sources/Mesa/src/glx/renderpix.c
0,0 → 1,198
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
/*
* (C) Copyright IBM Corporation 2005
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* IBM,
* AND/OR THEIR 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 "packrender.h"
#include "indirect.h"
 
/**
* Send a large image to the server. If necessary, a buffer is allocated
* to hold the unpacked data that is copied from the clients memory.
*
* \param gc Current GLX context
* \param compsize Size, in bytes, of the image portion
* \param dim Number of dimensions of the image
* \param width Width of the image
* \param height Height of the image, must be 1 for 1D images
* \param depth Depth of the image, must be 1 for 1D or 2D images
* \param format Format of the image
* \param type Data type of the image
* \param src Pointer to the image data
* \param pc Pointer to end of the command header
* \param modes Pointer to the pixel unpack data
*
* \todo
* Modify this function so that \c NULL images are sent using
* \c __glXSendLargeChunk instead of __glXSendLargeCommand. Doing this
* will eliminate the need to allocate a buffer for that case.
*/
void
__glXSendLargeImage(struct glx_context * gc, GLint compsize, GLint dim,
GLint width, GLint height, GLint depth,
GLenum format, GLenum type, const GLvoid * src,
GLubyte * pc, GLubyte * modes)
{
/* Allocate a temporary holding buffer */
GLubyte *buf = malloc(compsize);
if (!buf) {
__glXSetError(gc, GL_OUT_OF_MEMORY);
return;
}
 
/* Apply pixel store unpack modes to copy data into buf */
if (src != NULL) {
(*gc->fillImage) (gc, dim, width, height, depth, format, type,
src, buf, modes);
}
else {
if (dim < 3) {
(void) memcpy(modes, __glXDefaultPixelStore + 4, 20);
}
else {
(void) memcpy(modes, __glXDefaultPixelStore + 0, 36);
}
}
 
/* Send large command */
__glXSendLargeCommand(gc, gc->pc, pc - gc->pc, buf, compsize);
 
/* Free buffer */
free((char *) buf);
}
 
/************************************************************************/
 
/**
* Implement GLX protocol for \c glSeparableFilter2D.
*/
void
__indirect_glSeparableFilter2D(GLenum target, GLenum internalformat,
GLsizei width, GLsizei height, GLenum format,
GLenum type, const GLvoid * row,
const GLvoid * column)
{
__GLX_DECLARE_VARIABLES();
GLuint compsize2, hdrlen, totalhdrlen, image1len, image2len;
 
__GLX_LOAD_VARIABLES();
compsize = __glImageSize(width, 1, 1, format, type, 0);
compsize2 = __glImageSize(height, 1, 1, format, type, 0);
totalhdrlen = __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE);
hdrlen = __GLX_PAD(__GLX_CONV_FILT_HDR_SIZE);
image1len = __GLX_PAD(compsize);
image2len = __GLX_PAD(compsize2);
cmdlen = totalhdrlen + image1len + image2len;
if (!gc->currentDpy)
return;
 
if (cmdlen <= gc->maxSmallRenderCommandSize) {
/* Use GLXRender protocol to send small command */
__GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_SeparableFilter2D, cmdlen);
__GLX_PUT_LONG(0, target);
__GLX_PUT_LONG(4, internalformat);
__GLX_PUT_LONG(8, width);
__GLX_PUT_LONG(12, height);
__GLX_PUT_LONG(16, format);
__GLX_PUT_LONG(20, type);
pc += hdrlen;
if (compsize > 0) {
(*gc->fillImage) (gc, 1, width, 1, 1, format, type,
row, pc, pixelHeaderPC);
pc += image1len;
}
if (compsize2 > 0) {
(*gc->fillImage) (gc, 1, height, 1, 1, format, type,
column, pc, NULL);
pc += image2len;
}
if ((compsize == 0) && (compsize2 == 0)) {
/* Setup default store modes */
(void) memcpy(pixelHeaderPC, __glXDefaultPixelStore + 4, 20);
}
__GLX_END(0);
}
else {
GLubyte *buf;
const GLint bufsize = image1len + image2len;
 
/* Use GLXRenderLarge protocol to send command */
__GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_SeparableFilter2D,
cmdlen + 4);
__GLX_PUT_LONG(0, target);
__GLX_PUT_LONG(4, internalformat);
__GLX_PUT_LONG(8, width);
__GLX_PUT_LONG(12, height);
__GLX_PUT_LONG(16, format);
__GLX_PUT_LONG(20, type);
pc += hdrlen;
 
/* Allocate a temporary holding buffer */
buf = malloc(bufsize);
if (!buf) {
__glXSetError(gc, GL_OUT_OF_MEMORY);
return;
}
(*gc->fillImage) (gc, 1, width, 1, 1, format, type, row, buf,
pixelHeaderPC);
 
(*gc->fillImage) (gc, 1, height, 1, 1, format, type, column,
buf + image1len, pixelHeaderPC);
 
/* Send large command */
__glXSendLargeCommand(gc, gc->pc, (GLint) (pc - gc->pc), buf,
bufsize);
/* Free buffer */
free((char *) buf);
}
}
/contrib/sdk/sources/Mesa/src/glx/single2.c
0,0 → 1,951
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
#include <stdio.h>
#include <assert.h>
#include "glxclient.h"
#include "packsingle.h"
#include "glxextensions.h"
#include "indirect.h"
#include "indirect_vertex_array.h"
#include "glapi.h"
#include <xcb/xcb.h>
#include <xcb/glx.h>
#include <X11/Xlib-xcb.h>
 
#if !defined(__GNUC__)
# define __builtin_expect(x, y) x
#endif
 
/* Used for GL_ARB_transpose_matrix */
static void
TransposeMatrixf(GLfloat m[16])
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < i; j++) {
GLfloat tmp = m[i * 4 + j];
m[i * 4 + j] = m[j * 4 + i];
m[j * 4 + i] = tmp;
}
}
}
 
/* Used for GL_ARB_transpose_matrix */
static void
TransposeMatrixb(GLboolean m[16])
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < i; j++) {
GLboolean tmp = m[i * 4 + j];
m[i * 4 + j] = m[j * 4 + i];
m[j * 4 + i] = tmp;
}
}
}
 
/* Used for GL_ARB_transpose_matrix */
static void
TransposeMatrixd(GLdouble m[16])
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < i; j++) {
GLdouble tmp = m[i * 4 + j];
m[i * 4 + j] = m[j * 4 + i];
m[j * 4 + i] = tmp;
}
}
}
 
/* Used for GL_ARB_transpose_matrix */
static void
TransposeMatrixi(GLint m[16])
{
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < i; j++) {
GLint tmp = m[i * 4 + j];
m[i * 4 + j] = m[j * 4 + i];
m[j * 4 + i] = tmp;
}
}
}
 
 
/**
* Remap a transpose-matrix enum to a non-transpose-matrix enum. Enums
* that are not transpose-matrix enums are unaffected.
*/
static GLenum
RemapTransposeEnum(GLenum e)
{
switch (e) {
case GL_TRANSPOSE_MODELVIEW_MATRIX:
case GL_TRANSPOSE_PROJECTION_MATRIX:
case GL_TRANSPOSE_TEXTURE_MATRIX:
return e - (GL_TRANSPOSE_MODELVIEW_MATRIX - GL_MODELVIEW_MATRIX);
case GL_TRANSPOSE_COLOR_MATRIX:
return GL_COLOR_MATRIX;
default:
return e;
};
}
 
 
GLenum
__indirect_glGetError(void)
{
__GLX_SINGLE_DECLARE_VARIABLES();
GLuint retval = GL_NO_ERROR;
xGLXGetErrorReply reply;
 
if (gc->error) {
/* Use internal error first */
retval = gc->error;
gc->error = GL_NO_ERROR;
return retval;
}
 
__GLX_SINGLE_LOAD_VARIABLES();
__GLX_SINGLE_BEGIN(X_GLsop_GetError, 0);
__GLX_SINGLE_READ_XREPLY();
retval = reply.error;
__GLX_SINGLE_END();
 
return retval;
}
 
 
/**
* Get the selected attribute from the client state.
*
* \returns
* On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned.
*/
static GLboolean
get_client_data(struct glx_context * gc, GLenum cap, GLintptr * data)
{
GLboolean retval = GL_TRUE;
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
const GLint tex_unit = __glXGetActiveTextureUnit(state);
 
 
switch (cap) {
case GL_VERTEX_ARRAY:
case GL_NORMAL_ARRAY:
case GL_COLOR_ARRAY:
case GL_INDEX_ARRAY:
case GL_EDGE_FLAG_ARRAY:
case GL_SECONDARY_COLOR_ARRAY:
case GL_FOG_COORD_ARRAY:
retval = __glXGetArrayEnable(state, cap, 0, data);
break;
 
case GL_VERTEX_ARRAY_SIZE:
retval = __glXGetArraySize(state, GL_VERTEX_ARRAY, 0, data);
break;
case GL_COLOR_ARRAY_SIZE:
retval = __glXGetArraySize(state, GL_COLOR_ARRAY, 0, data);
break;
case GL_SECONDARY_COLOR_ARRAY_SIZE:
retval = __glXGetArraySize(state, GL_SECONDARY_COLOR_ARRAY, 0, data);
break;
 
case GL_VERTEX_ARRAY_TYPE:
retval = __glXGetArrayType(state, GL_VERTEX_ARRAY, 0, data);
break;
case GL_NORMAL_ARRAY_TYPE:
retval = __glXGetArrayType(state, GL_NORMAL_ARRAY, 0, data);
break;
case GL_INDEX_ARRAY_TYPE:
retval = __glXGetArrayType(state, GL_INDEX_ARRAY, 0, data);
break;
case GL_COLOR_ARRAY_TYPE:
retval = __glXGetArrayType(state, GL_COLOR_ARRAY, 0, data);
break;
case GL_SECONDARY_COLOR_ARRAY_TYPE:
retval = __glXGetArrayType(state, GL_SECONDARY_COLOR_ARRAY, 0, data);
break;
case GL_FOG_COORD_ARRAY_TYPE:
retval = __glXGetArrayType(state, GL_FOG_COORD_ARRAY, 0, data);
break;
 
case GL_VERTEX_ARRAY_STRIDE:
retval = __glXGetArrayStride(state, GL_VERTEX_ARRAY, 0, data);
break;
case GL_NORMAL_ARRAY_STRIDE:
retval = __glXGetArrayStride(state, GL_NORMAL_ARRAY, 0, data);
break;
case GL_INDEX_ARRAY_STRIDE:
retval = __glXGetArrayStride(state, GL_INDEX_ARRAY, 0, data);
break;
case GL_EDGE_FLAG_ARRAY_STRIDE:
retval = __glXGetArrayStride(state, GL_EDGE_FLAG_ARRAY, 0, data);
break;
case GL_COLOR_ARRAY_STRIDE:
retval = __glXGetArrayStride(state, GL_COLOR_ARRAY, 0, data);
break;
case GL_SECONDARY_COLOR_ARRAY_STRIDE:
retval = __glXGetArrayStride(state, GL_SECONDARY_COLOR_ARRAY, 0, data);
break;
case GL_FOG_COORD_ARRAY_STRIDE:
retval = __glXGetArrayStride(state, GL_FOG_COORD_ARRAY, 0, data);
break;
 
case GL_TEXTURE_COORD_ARRAY:
retval =
__glXGetArrayEnable(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
break;
case GL_TEXTURE_COORD_ARRAY_SIZE:
retval =
__glXGetArraySize(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
break;
case GL_TEXTURE_COORD_ARRAY_TYPE:
retval =
__glXGetArrayType(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
break;
case GL_TEXTURE_COORD_ARRAY_STRIDE:
retval =
__glXGetArrayStride(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
break;
 
case GL_MAX_ELEMENTS_VERTICES:
case GL_MAX_ELEMENTS_INDICES:
retval = GL_TRUE;
*data = ~0UL;
break;
 
 
case GL_PACK_ROW_LENGTH:
*data = (GLintptr) state->storePack.rowLength;
break;
case GL_PACK_IMAGE_HEIGHT:
*data = (GLintptr) state->storePack.imageHeight;
break;
case GL_PACK_SKIP_ROWS:
*data = (GLintptr) state->storePack.skipRows;
break;
case GL_PACK_SKIP_PIXELS:
*data = (GLintptr) state->storePack.skipPixels;
break;
case GL_PACK_SKIP_IMAGES:
*data = (GLintptr) state->storePack.skipImages;
break;
case GL_PACK_ALIGNMENT:
*data = (GLintptr) state->storePack.alignment;
break;
case GL_PACK_SWAP_BYTES:
*data = (GLintptr) state->storePack.swapEndian;
break;
case GL_PACK_LSB_FIRST:
*data = (GLintptr) state->storePack.lsbFirst;
break;
case GL_UNPACK_ROW_LENGTH:
*data = (GLintptr) state->storeUnpack.rowLength;
break;
case GL_UNPACK_IMAGE_HEIGHT:
*data = (GLintptr) state->storeUnpack.imageHeight;
break;
case GL_UNPACK_SKIP_ROWS:
*data = (GLintptr) state->storeUnpack.skipRows;
break;
case GL_UNPACK_SKIP_PIXELS:
*data = (GLintptr) state->storeUnpack.skipPixels;
break;
case GL_UNPACK_SKIP_IMAGES:
*data = (GLintptr) state->storeUnpack.skipImages;
break;
case GL_UNPACK_ALIGNMENT:
*data = (GLintptr) state->storeUnpack.alignment;
break;
case GL_UNPACK_SWAP_BYTES:
*data = (GLintptr) state->storeUnpack.swapEndian;
break;
case GL_UNPACK_LSB_FIRST:
*data = (GLintptr) state->storeUnpack.lsbFirst;
break;
case GL_CLIENT_ATTRIB_STACK_DEPTH:
*data = (GLintptr) (gc->attributes.stackPointer - gc->attributes.stack);
break;
case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
*data = (GLintptr) __GL_CLIENT_ATTRIB_STACK_DEPTH;
break;
case GL_CLIENT_ACTIVE_TEXTURE:
*data = (GLintptr) (tex_unit + GL_TEXTURE0);
break;
 
default:
retval = GL_FALSE;
break;
}
 
 
return retval;
}
 
 
void
__indirect_glGetBooleanv(GLenum val, GLboolean * b)
{
const GLenum origVal = val;
__GLX_SINGLE_DECLARE_VARIABLES();
xGLXSingleReply reply;
 
val = RemapTransposeEnum(val);
 
__GLX_SINGLE_LOAD_VARIABLES();
__GLX_SINGLE_BEGIN(X_GLsop_GetBooleanv, 4);
__GLX_SINGLE_PUT_LONG(0, val);
__GLX_SINGLE_READ_XREPLY();
__GLX_SINGLE_GET_SIZE(compsize);
 
if (compsize == 0) {
/*
** Error occured; don't modify user's buffer.
*/
}
else {
GLintptr data;
 
/*
** We still needed to send the request to the server in order to
** find out whether it was legal to make a query (it's illegal,
** for example, to call a query between glBegin() and glEnd()).
*/
 
if (get_client_data(gc, val, &data)) {
*b = (GLboolean) data;
}
else {
/*
** Not a local value, so use what we got from the server.
*/
if (compsize == 1) {
__GLX_SINGLE_GET_CHAR(b);
}
else {
__GLX_SINGLE_GET_CHAR_ARRAY(b, compsize);
if (val != origVal) {
/* matrix transpose */
TransposeMatrixb(b);
}
}
}
}
__GLX_SINGLE_END();
}
 
void
__indirect_glGetDoublev(GLenum val, GLdouble * d)
{
const GLenum origVal = val;
__GLX_SINGLE_DECLARE_VARIABLES();
xGLXSingleReply reply;
 
val = RemapTransposeEnum(val);
 
__GLX_SINGLE_LOAD_VARIABLES();
__GLX_SINGLE_BEGIN(X_GLsop_GetDoublev, 4);
__GLX_SINGLE_PUT_LONG(0, val);
__GLX_SINGLE_READ_XREPLY();
__GLX_SINGLE_GET_SIZE(compsize);
 
if (compsize == 0) {
/*
** Error occured; don't modify user's buffer.
*/
}
else {
GLintptr data;
 
/*
** We still needed to send the request to the server in order to
** find out whether it was legal to make a query (it's illegal,
** for example, to call a query between glBegin() and glEnd()).
*/
 
if (get_client_data(gc, val, &data)) {
*d = (GLdouble) data;
}
else {
/*
** Not a local value, so use what we got from the server.
*/
if (compsize == 1) {
__GLX_SINGLE_GET_DOUBLE(d);
}
else {
__GLX_SINGLE_GET_DOUBLE_ARRAY(d, compsize);
if (val != origVal) {
/* matrix transpose */
TransposeMatrixd(d);
}
}
}
}
__GLX_SINGLE_END();
}
 
void
__indirect_glGetFloatv(GLenum val, GLfloat * f)
{
const GLenum origVal = val;
__GLX_SINGLE_DECLARE_VARIABLES();
xGLXSingleReply reply;
 
val = RemapTransposeEnum(val);
 
__GLX_SINGLE_LOAD_VARIABLES();
__GLX_SINGLE_BEGIN(X_GLsop_GetFloatv, 4);
__GLX_SINGLE_PUT_LONG(0, val);
__GLX_SINGLE_READ_XREPLY();
__GLX_SINGLE_GET_SIZE(compsize);
 
if (compsize == 0) {
/*
** Error occured; don't modify user's buffer.
*/
}
else {
GLintptr data;
 
/*
** We still needed to send the request to the server in order to
** find out whether it was legal to make a query (it's illegal,
** for example, to call a query between glBegin() and glEnd()).
*/
 
if (get_client_data(gc, val, &data)) {
*f = (GLfloat) data;
}
else {
/*
** Not a local value, so use what we got from the server.
*/
if (compsize == 1) {
__GLX_SINGLE_GET_FLOAT(f);
}
else {
__GLX_SINGLE_GET_FLOAT_ARRAY(f, compsize);
if (val != origVal) {
/* matrix transpose */
TransposeMatrixf(f);
}
}
}
}
__GLX_SINGLE_END();
}
 
void
__indirect_glGetIntegerv(GLenum val, GLint * i)
{
const GLenum origVal = val;
__GLX_SINGLE_DECLARE_VARIABLES();
xGLXSingleReply reply;
 
val = RemapTransposeEnum(val);
 
__GLX_SINGLE_LOAD_VARIABLES();
__GLX_SINGLE_BEGIN(X_GLsop_GetIntegerv, 4);
__GLX_SINGLE_PUT_LONG(0, val);
__GLX_SINGLE_READ_XREPLY();
__GLX_SINGLE_GET_SIZE(compsize);
 
if (compsize == 0) {
/*
** Error occured; don't modify user's buffer.
*/
}
else {
GLintptr data;
 
/*
** We still needed to send the request to the server in order to
** find out whether it was legal to make a query (it's illegal,
** for example, to call a query between glBegin() and glEnd()).
*/
 
if (get_client_data(gc, val, &data)) {
*i = (GLint) data;
}
else {
/*
** Not a local value, so use what we got from the server.
*/
if (compsize == 1) {
__GLX_SINGLE_GET_LONG(i);
}
else {
__GLX_SINGLE_GET_LONG_ARRAY(i, compsize);
if (val != origVal) {
/* matrix transpose */
TransposeMatrixi(i);
}
}
}
}
__GLX_SINGLE_END();
}
 
/*
** Send all pending commands to server.
*/
void
__indirect_glFlush(void)
{
__GLX_SINGLE_DECLARE_VARIABLES();
 
if (!dpy)
return;
 
__GLX_SINGLE_LOAD_VARIABLES();
__GLX_SINGLE_BEGIN(X_GLsop_Flush, 0);
__GLX_SINGLE_END();
 
/* And finally flush the X protocol data */
XFlush(dpy);
}
 
void
__indirect_glFeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer)
{
__GLX_SINGLE_DECLARE_VARIABLES();
 
if (!dpy)
return;
 
__GLX_SINGLE_LOAD_VARIABLES();
__GLX_SINGLE_BEGIN(X_GLsop_FeedbackBuffer, 8);
__GLX_SINGLE_PUT_LONG(0, size);
__GLX_SINGLE_PUT_LONG(4, type);
__GLX_SINGLE_END();
 
gc->feedbackBuf = buffer;
}
 
void
__indirect_glSelectBuffer(GLsizei numnames, GLuint * buffer)
{
__GLX_SINGLE_DECLARE_VARIABLES();
 
if (!dpy)
return;
 
__GLX_SINGLE_LOAD_VARIABLES();
__GLX_SINGLE_BEGIN(X_GLsop_SelectBuffer, 4);
__GLX_SINGLE_PUT_LONG(0, numnames);
__GLX_SINGLE_END();
 
gc->selectBuf = buffer;
}
 
GLint
__indirect_glRenderMode(GLenum mode)
{
__GLX_SINGLE_DECLARE_VARIABLES();
GLint retval = 0;
xGLXRenderModeReply reply;
 
if (!dpy)
return -1;
 
__GLX_SINGLE_LOAD_VARIABLES();
__GLX_SINGLE_BEGIN(X_GLsop_RenderMode, 4);
__GLX_SINGLE_PUT_LONG(0, mode);
__GLX_SINGLE_READ_XREPLY();
__GLX_SINGLE_GET_RETVAL(retval, GLint);
 
if (reply.newMode != mode) {
/*
** Switch to new mode did not take effect, therefore an error
** occured. When an error happens the server won't send us any
** other data.
*/
}
else {
/* Read the feedback or selection data */
if (gc->renderMode == GL_FEEDBACK) {
__GLX_SINGLE_GET_SIZE(compsize);
__GLX_SINGLE_GET_FLOAT_ARRAY(gc->feedbackBuf, compsize);
}
else if (gc->renderMode == GL_SELECT) {
__GLX_SINGLE_GET_SIZE(compsize);
__GLX_SINGLE_GET_LONG_ARRAY(gc->selectBuf, compsize);
}
gc->renderMode = mode;
}
__GLX_SINGLE_END();
 
return retval;
}
 
void
__indirect_glFinish(void)
{
__GLX_SINGLE_DECLARE_VARIABLES();
xGLXSingleReply reply;
 
__GLX_SINGLE_LOAD_VARIABLES();
__GLX_SINGLE_BEGIN(X_GLsop_Finish, 0);
__GLX_SINGLE_READ_XREPLY();
__GLX_SINGLE_END();
}
 
 
/**
* Extract the major and minor version numbers from a version string.
*/
static void
version_from_string(const char *ver, int *major_version, int *minor_version)
{
const char *end;
long major;
long minor;
 
major = strtol(ver, (char **) &end, 10);
minor = strtol(end + 1, NULL, 10);
*major_version = major;
*minor_version = minor;
}
 
 
const GLubyte *
__indirect_glGetString(GLenum name)
{
struct glx_context *gc = __glXGetCurrentContext();
Display *dpy = gc->currentDpy;
GLubyte *s = NULL;
 
if (!dpy)
return 0;
 
/*
** Return the cached copy if the string has already been fetched
*/
switch (name) {
case GL_VENDOR:
if (gc->vendor)
return gc->vendor;
break;
case GL_RENDERER:
if (gc->renderer)
return gc->renderer;
break;
case GL_VERSION:
if (gc->version)
return gc->version;
break;
case GL_EXTENSIONS:
if (gc->extensions)
return gc->extensions;
break;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return 0;
}
 
/*
** Get requested string from server
*/
 
(void) __glXFlushRenderBuffer(gc, gc->pc);
s = (GLubyte *) __glXGetString(dpy, gc->majorOpcode, gc->currentContextTag,
name);
if (!s) {
/* Throw data on the floor */
__glXSetError(gc, GL_OUT_OF_MEMORY);
}
else {
/*
** Update local cache
*/
switch (name) {
case GL_VENDOR:
gc->vendor = s;
break;
 
case GL_RENDERER:
gc->renderer = s;
break;
 
case GL_VERSION:{
int client_major;
int client_minor;
 
version_from_string((char *) s,
&gc->server_major, &gc->server_minor);
__glXGetGLVersion(&client_major, &client_minor);
 
if ((gc->server_major < client_major)
|| ((gc->server_major == client_major)
&& (gc->server_minor <= client_minor))) {
gc->version = s;
}
else {
/* Allow 7 bytes for the client-side GL version. This allows
* for upto version 999.999. I'm not holding my breath for
* that one! The extra 4 is for the ' ()\0' that will be
* added.
*/
const size_t size = 7 + strlen((char *) s) + 4;
 
gc->version = malloc(size);
if (gc->version == NULL) {
/* If we couldn't allocate memory for the new string,
* make a best-effort and just copy the client-side version
* to the string and use that. It probably doesn't
* matter what is done here. If there not memory available
* for a short string, the system is probably going to die
* soon anyway.
*/
snprintf((char *) s, strlen((char *) s) + 1, "%u.%u",
client_major, client_minor);
gc->version = s;
}
else {
snprintf((char *) gc->version, size, "%u.%u (%s)",
client_major, client_minor, s);
free(s);
s = gc->version;
}
}
break;
}
 
case GL_EXTENSIONS:{
int major = 1;
int minor = 0;
 
/* This code is currently disabled. I was reminded that some
* vendors intentionally exclude some extensions from their
* extension string that are part of the core version they
* advertise. In particular, on Nvidia drivers this means that
* the functionality is supported by the driver, but is not
* hardware accelerated. For example, a TNT will show core
* version 1.5, but most of the post-1.2 functionality is a
* software fallback.
*
* I don't want to break applications that rely on this odd
* behavior. At the same time, the code is written and tested,
* so I didn't want to throw it away. Therefore, the code is here
* but disabled. In the future, we may wish to and an environment
* variable to enable it.
*/
 
#if 0
/* Call glGetString just to make sure that gc->server_major and
* gc->server_minor are set. This version may be higher than we
* can completely support, but it may imply support for some
* extensions that we can support.
*
* For example, at the time of this writing, the client-side
* library only supports upto core GL version 1.2. However, cubic
* textures, multitexture, multisampling, and some other 1.3
* features are supported. If the server reports back version
* 1.3, but does not report all of those extensions, we will
* enable them.
*/
(void *) glGetString(GL_VERSION);
major = gc->server_major, minor = gc->server_minor;
#endif
 
__glXCalculateUsableGLExtensions(gc, (char *) s, major, minor);
free(s);
s = gc->extensions;
break;
}
}
}
return s;
}
 
GLboolean
__indirect_glIsEnabled(GLenum cap)
{
__GLX_SINGLE_DECLARE_VARIABLES();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
xGLXSingleReply reply;
GLboolean retval = 0;
GLintptr enable;
 
if (!dpy)
return 0;
 
switch (cap) {
case GL_VERTEX_ARRAY:
case GL_NORMAL_ARRAY:
case GL_COLOR_ARRAY:
case GL_INDEX_ARRAY:
case GL_EDGE_FLAG_ARRAY:
case GL_SECONDARY_COLOR_ARRAY:
case GL_FOG_COORD_ARRAY:
retval = __glXGetArrayEnable(state, cap, 0, &enable);
assert(retval);
return (GLboolean) enable;
break;
case GL_TEXTURE_COORD_ARRAY:
retval = __glXGetArrayEnable(state, GL_TEXTURE_COORD_ARRAY,
__glXGetActiveTextureUnit(state), &enable);
assert(retval);
return (GLboolean) enable;
break;
}
 
__GLX_SINGLE_LOAD_VARIABLES();
__GLX_SINGLE_BEGIN(X_GLsop_IsEnabled, 4);
__GLX_SINGLE_PUT_LONG(0, cap);
__GLX_SINGLE_READ_XREPLY();
__GLX_SINGLE_GET_RETVAL(retval, GLboolean);
__GLX_SINGLE_END();
return retval;
}
 
void
__indirect_glGetPointerv(GLenum pname, void **params)
{
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
Display *dpy = gc->currentDpy;
 
if (!dpy)
return;
 
switch (pname) {
case GL_VERTEX_ARRAY_POINTER:
case GL_NORMAL_ARRAY_POINTER:
case GL_COLOR_ARRAY_POINTER:
case GL_INDEX_ARRAY_POINTER:
case GL_EDGE_FLAG_ARRAY_POINTER:
__glXGetArrayPointer(state, pname - GL_VERTEX_ARRAY_POINTER
+ GL_VERTEX_ARRAY, 0, params);
return;
case GL_TEXTURE_COORD_ARRAY_POINTER:
__glXGetArrayPointer(state, GL_TEXTURE_COORD_ARRAY,
__glXGetActiveTextureUnit(state), params);
return;
case GL_SECONDARY_COLOR_ARRAY_POINTER:
case GL_FOG_COORD_ARRAY_POINTER:
__glXGetArrayPointer(state, pname - GL_FOG_COORD_ARRAY_POINTER
+ GL_FOG_COORD_ARRAY, 0, params);
return;
case GL_FEEDBACK_BUFFER_POINTER:
*params = (void *) gc->feedbackBuf;
return;
case GL_SELECTION_BUFFER_POINTER:
*params = (void *) gc->selectBuf;
return;
default:
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
}
 
 
 
/**
* This was previously auto-generated, but we need to special-case
* how we handle writing into the 'residences' buffer when n%4!=0.
*/
#define X_GLsop_AreTexturesResident 143
GLboolean
__indirect_glAreTexturesResident(GLsizei n, const GLuint * textures,
GLboolean * residences)
{
struct glx_context *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
GLboolean retval = (GLboolean) 0;
if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
xcb_connection_t *c = XGetXCBConnection(dpy);
xcb_glx_are_textures_resident_reply_t *reply;
(void) __glXFlushRenderBuffer(gc, gc->pc);
reply =
xcb_glx_are_textures_resident_reply(c,
xcb_glx_are_textures_resident
(c, gc->currentContextTag, n,
textures), NULL);
(void) memcpy(residences, xcb_glx_are_textures_resident_data(reply),
xcb_glx_are_textures_resident_data_length(reply) *
sizeof(GLboolean));
retval = reply->ret_val;
free(reply);
}
return retval;
}
 
 
/**
* This was previously auto-generated, but we need to special-case
* how we handle writing into the 'residences' buffer when n%4!=0.
*/
#define X_GLvop_AreTexturesResidentEXT 11
GLboolean
glAreTexturesResidentEXT(GLsizei n, const GLuint * textures,
GLboolean * residences)
{
struct glx_context *const gc = __glXGetCurrentContext();
 
if (gc->isDirect) {
const _glapi_proc *const table = (_glapi_proc *) GET_DISPATCH();
PFNGLARETEXTURESRESIDENTEXTPROC p =
(PFNGLARETEXTURESRESIDENTEXTPROC) table[332];
 
return p(n, textures, residences);
}
else {
struct glx_context *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
GLboolean retval = (GLboolean) 0;
const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
GLubyte const *pc =
__glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
X_GLvop_AreTexturesResidentEXT,
cmdlen);
(void) memcpy((void *) (pc + 0), (void *) (&n), 4);
(void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4));
if (n & 3) {
/* see comments in __indirect_glAreTexturesResident() */
GLboolean *res4 = malloc((n + 3) & ~3);
retval = (GLboolean) __glXReadReply(dpy, 1, res4, GL_TRUE);
memcpy(residences, res4, n);
free(res4);
}
else {
retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_TRUE);
}
UnlockDisplay(dpy);
SyncHandle();
}
return retval;
}
}
/contrib/sdk/sources/Mesa/src/glx/singlepix.c
0,0 → 1,193
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
#include "packsingle.h"
#include "indirect.h"
#include "glapi.h"
#include "glthread.h"
#include <GL/glxproto.h>
 
void
__indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type,
GLvoid * row, GLvoid * column, GLvoid * span)
{
__GLX_SINGLE_DECLARE_VARIABLES();
const __GLXattribute *state;
xGLXGetSeparableFilterReply reply;
GLubyte *rowBuf, *colBuf;
 
if (!dpy)
return;
__GLX_SINGLE_LOAD_VARIABLES();
state = gc->client_state_private;
 
/* Send request */
__GLX_SINGLE_BEGIN(X_GLsop_GetSeparableFilter, __GLX_PAD(13));
__GLX_SINGLE_PUT_LONG(0, target);
__GLX_SINGLE_PUT_LONG(4, format);
__GLX_SINGLE_PUT_LONG(8, type);
__GLX_SINGLE_PUT_CHAR(12, state->storePack.swapEndian);
__GLX_SINGLE_READ_XREPLY();
compsize = reply.length << 2;
 
if (compsize != 0) {
GLint width, height;
GLint widthsize, heightsize;
 
width = reply.width;
height = reply.height;
 
widthsize = __glImageSize(width, 1, 1, format, type, 0);
heightsize = __glImageSize(height, 1, 1, format, type, 0);
 
/* Allocate a holding buffer to transform the data from */
rowBuf = malloc(widthsize);
if (!rowBuf) {
/* Throw data away */
_XEatData(dpy, compsize);
__glXSetError(gc, GL_OUT_OF_MEMORY);
UnlockDisplay(dpy);
SyncHandle();
return;
}
else {
__GLX_SINGLE_GET_CHAR_ARRAY(((char *) rowBuf), widthsize);
__glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row);
free((char *) rowBuf);
}
colBuf = malloc(heightsize);
if (!colBuf) {
/* Throw data away */
_XEatData(dpy, compsize - __GLX_PAD(widthsize));
__glXSetError(gc, GL_OUT_OF_MEMORY);
UnlockDisplay(dpy);
SyncHandle();
return;
}
else {
__GLX_SINGLE_GET_CHAR_ARRAY(((char *) colBuf), heightsize);
__glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column);
free((char *) colBuf);
}
}
else {
/*
** don't modify user's buffer.
*/
}
__GLX_SINGLE_END();
 
}
 
 
/* it is defined to gl_dispatch_stub_NNN in indirect.h */
void gl_dispatch_stub_GetSeparableFilterEXT (GLenum target, GLenum format,
GLenum type, GLvoid * row,
GLvoid * column, GLvoid * span)
{
struct glx_context *const gc = __glXGetCurrentContext();
 
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (gc->isDirect) {
const _glapi_proc *const table = (_glapi_proc *) GET_DISPATCH();
PFNGLGETSEPARABLEFILTEREXTPROC p =
(PFNGLGETSEPARABLEFILTEREXTPROC) table[359];
 
p(target, format, type, row, column, span);
return;
}
else
#endif
{
Display *const dpy = gc->currentDpy;
const GLuint cmdlen = __GLX_PAD(13);
 
if (dpy != NULL) {
const __GLXattribute *const state = gc->client_state_private;
xGLXGetSeparableFilterReply reply;
GLubyte const *pc =
__glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
X_GLvop_GetSeparableFilterEXT, cmdlen);
unsigned compsize;
 
 
(void) memcpy((void *) (pc + 0), (void *) (&target), 4);
(void) memcpy((void *) (pc + 4), (void *) (&format), 4);
(void) memcpy((void *) (pc + 8), (void *) (&type), 4);
*(int8_t *) (pc + 12) = state->storePack.swapEndian;
 
(void) _XReply(dpy, (xReply *) & reply, 0, False);
 
compsize = reply.length << 2;
 
if (compsize != 0) {
const GLint width = reply.width;
const GLint height = reply.height;
const GLint widthsize =
__glImageSize(width, 1, 1, format, type, 0);
const GLint heightsize =
__glImageSize(height, 1, 1, format, type, 0);
GLubyte *const buf =
malloc((widthsize > heightsize) ? widthsize : heightsize);
 
if (buf == NULL) {
/* Throw data away */
_XEatData(dpy, compsize);
__glXSetError(gc, GL_OUT_OF_MEMORY);
 
UnlockDisplay(dpy);
SyncHandle();
return;
}
else {
int extra;
 
extra = 4 - (widthsize & 3);
_XRead(dpy, (char *) buf, widthsize);
if (extra < 4) {
_XEatData(dpy, extra);
}
 
__glEmptyImage(gc, 1, width, 1, 1, format, type, buf, row);
 
extra = 4 - (heightsize & 3);
_XRead(dpy, (char *) buf, heightsize);
if (extra < 4) {
_XEatData(dpy, extra);
}
 
__glEmptyImage(gc, 1, height, 1, 1, format, type, buf, column);
 
free((char *) buf);
}
}
}
}
}
/contrib/sdk/sources/Mesa/src/glx/tests/Makefile.am
0,0 → 1,26
if HAVE_SHARED_GLAPI
AM_CFLAGS = $(PTHREAD_CFLAGS)
AM_CPPFLAGS = \
-I$(top_srcdir)/src/gtest/include \
-I$(top_srcdir)/src/mapi \
-I$(top_srcdir)/src/mesa \
-I$(top_srcdir)/src/glx \
-I$(top_srcdir)/include \
$(X11_CFLAGS)
 
TESTS = glx-test
check_PROGRAMS = glx-test
 
glx_test_SOURCES = \
clientinfo_unittest.cpp \
create_context_unittest.cpp \
enum_sizes.cpp \
fake_glx_screen.cpp \
indirect_api.cpp
 
glx_test_LDADD = \
$(top_builddir)/src/glx/libglx.la \
$(top_builddir)/src/gtest/libgtest.la \
$(top_builddir)/src/mapi/shared-glapi/libglapi.la \
$(PTHREAD_LIBS)
endif
/contrib/sdk/sources/Mesa/src/glx/tests/Makefile.in
0,0 → 1,1151
# Makefile.in generated by automake 1.14 from Makefile.am.
# @configure_input@
 
# Copyright (C) 1994-2013 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@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
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@
target_triplet = @target@
@HAVE_SHARED_GLAPI_TRUE@TESTS = glx-test$(EXEEXT)
@HAVE_SHARED_GLAPI_TRUE@check_PROGRAMS = glx-test$(EXEEXT)
subdir = src/glx/tests
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/bin/depcomp $(top_srcdir)/bin/test-driver
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_bison.m4 \
$(top_srcdir)/m4/ax_prog_cc_for_build.m4 \
$(top_srcdir)/m4/ax_prog_cxx_for_build.m4 \
$(top_srcdir)/m4/ax_prog_flex.m4 \
$(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/ax_python_module.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__glx_test_SOURCES_DIST = clientinfo_unittest.cpp \
create_context_unittest.cpp enum_sizes.cpp fake_glx_screen.cpp \
indirect_api.cpp
@HAVE_SHARED_GLAPI_TRUE@am_glx_test_OBJECTS = \
@HAVE_SHARED_GLAPI_TRUE@ clientinfo_unittest.$(OBJEXT) \
@HAVE_SHARED_GLAPI_TRUE@ create_context_unittest.$(OBJEXT) \
@HAVE_SHARED_GLAPI_TRUE@ enum_sizes.$(OBJEXT) \
@HAVE_SHARED_GLAPI_TRUE@ fake_glx_screen.$(OBJEXT) \
@HAVE_SHARED_GLAPI_TRUE@ indirect_api.$(OBJEXT)
glx_test_OBJECTS = $(am_glx_test_OBJECTS)
am__DEPENDENCIES_1 =
@HAVE_SHARED_GLAPI_TRUE@glx_test_DEPENDENCIES = \
@HAVE_SHARED_GLAPI_TRUE@ $(top_builddir)/src/glx/libglx.la \
@HAVE_SHARED_GLAPI_TRUE@ $(top_builddir)/src/gtest/libgtest.la \
@HAVE_SHARED_GLAPI_TRUE@ $(top_builddir)/src/mapi/shared-glapi/libglapi.la \
@HAVE_SHARED_GLAPI_TRUE@ $(am__DEPENDENCIES_1)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/bin/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
AM_V_CXX = $(am__v_CXX_@AM_V@)
am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
am__v_CXX_0 = @echo " CXX " $@;
am__v_CXX_1 =
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
am__v_CXXLD_0 = @echo " CXXLD " $@;
am__v_CXXLD_1 =
SOURCES = $(glx_test_SOURCES)
DIST_SOURCES = $(am__glx_test_SOURCES_DIST)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__tty_colors_dummy = \
mgn= red= grn= lgn= blu= brg= std=; \
am__color_tests=no
am__tty_colors = { \
$(am__tty_colors_dummy); \
if test "X$(AM_COLOR_TESTS)" = Xno; then \
am__color_tests=no; \
elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
am__color_tests=yes; \
elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
am__color_tests=yes; \
fi; \
if test $$am__color_tests = yes; then \
red=''; \
grn=''; \
lgn=''; \
blu=''; \
mgn=''; \
brg=''; \
std=''; \
fi; \
}
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__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__recheck_rx = ^[ ]*:recheck:[ ]*
am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
# A command that, given a newline-separated list of test names on the
# standard input, print the name of the tests that are to be re-run
# upon "make recheck".
am__list_recheck_tests = $(AWK) '{ \
recheck = 1; \
while ((rc = (getline line < ($$0 ".trs"))) != 0) \
{ \
if (rc < 0) \
{ \
if ((getline line2 < ($$0 ".log")) < 0) \
recheck = 0; \
break; \
} \
else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
{ \
recheck = 0; \
break; \
} \
else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
{ \
break; \
} \
}; \
if (recheck) \
print $$0; \
close ($$0 ".trs"); \
close ($$0 ".log"); \
}'
# A command that, given a newline-separated list of test names on the
# standard input, create the global log from their .trs and .log files.
am__create_global_log = $(AWK) ' \
function fatal(msg) \
{ \
print "fatal: making $@: " msg | "cat >&2"; \
exit 1; \
} \
function rst_section(header) \
{ \
print header; \
len = length(header); \
for (i = 1; i <= len; i = i + 1) \
printf "="; \
printf "\n\n"; \
} \
{ \
copy_in_global_log = 1; \
global_test_result = "RUN"; \
while ((rc = (getline line < ($$0 ".trs"))) != 0) \
{ \
if (rc < 0) \
fatal("failed to read from " $$0 ".trs"); \
if (line ~ /$(am__global_test_result_rx)/) \
{ \
sub("$(am__global_test_result_rx)", "", line); \
sub("[ ]*$$", "", line); \
global_test_result = line; \
} \
else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
copy_in_global_log = 0; \
}; \
if (copy_in_global_log) \
{ \
rst_section(global_test_result ": " $$0); \
while ((rc = (getline line < ($$0 ".log"))) != 0) \
{ \
if (rc < 0) \
fatal("failed to read from " $$0 ".log"); \
print line; \
}; \
printf "\n"; \
}; \
close ($$0 ".trs"); \
close ($$0 ".log"); \
}'
# Restructured Text title.
am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
# Solaris 10 'make', and several other traditional 'make' implementations,
# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
# by disabling -e (using the XSI extension "set +e") if it's set.
am__sh_e_setup = case $$- in *e*) set +e;; esac
# Default flags passed to test drivers.
am__common_driver_flags = \
--color-tests "$$am__color_tests" \
--enable-hard-errors "$$am__enable_hard_errors" \
--expect-failure "$$am__expect_failure"
# To be inserted before the command running the test. Creates the
# directory for the log if needed. Stores in $dir the directory
# containing $f, in $tst the test, in $log the log. Executes the
# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
# passes TESTS_ENVIRONMENT. Set up options for the wrapper that
# will run the test scripts (or their associated LOG_COMPILER, if
# thy have one).
am__check_pre = \
$(am__sh_e_setup); \
$(am__vpath_adj_setup) $(am__vpath_adj) \
$(am__tty_colors); \
srcdir=$(srcdir); export srcdir; \
case "$@" in \
*/*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \
*) am__odir=.;; \
esac; \
test "x$$am__odir" = x"." || test -d "$$am__odir" \
|| $(MKDIR_P) "$$am__odir" || exit $$?; \
if test -f "./$$f"; then dir=./; \
elif test -f "$$f"; then dir=; \
else dir="$(srcdir)/"; fi; \
tst=$$dir$$f; log='$@'; \
if test -n '$(DISABLE_HARD_ERRORS)'; then \
am__enable_hard_errors=no; \
else \
am__enable_hard_errors=yes; \
fi; \
case " $(XFAIL_TESTS) " in \
*[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
am__expect_failure=yes;; \
*) \
am__expect_failure=no;; \
esac; \
$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
# A shell command to get the names of the tests scripts with any registered
# extension removed (i.e., equivalently, the names of the test logs, with
# the '.log' extension removed). The result is saved in the shell variable
# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
# since that might cause problem with VPATH rewrites for suffix-less tests.
# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
am__set_TESTS_bases = \
bases='$(TEST_LOGS)'; \
bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
bases=`echo $$bases`
RECHECK_LOGS = $(TEST_LOGS)
AM_RECURSIVE_TARGETS = check recheck
TEST_SUITE_LOG = test-suite.log
TEST_EXTENSIONS = @EXEEXT@ .test
LOG_DRIVER = $(SHELL) $(top_srcdir)/bin/test-driver
LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
am__set_b = \
case '$@' in \
*/*) \
case '$*' in \
*/*) b='$*';; \
*) b=`echo '$@' | sed 's/\.log$$//'`; \
esac;; \
*) \
b='$*';; \
esac
am__test_logs1 = $(TESTS:=.log)
am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
TEST_LOGS = $(am__test_logs2:.test.log=.log)
TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/bin/test-driver
TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
$(TEST_LOG_FLAGS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_EXEEXT = @BUILD_EXEEXT@
BUILD_OBJEXT = @BUILD_OBJEXT@
CC = @CC@
CCAS = @CCAS@
CCASDEPMODE = @CCASDEPMODE@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CC_FOR_BUILD = @CC_FOR_BUILD@
CFLAGS = @CFLAGS@
CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
CLANG_RESOURCE_DIR = @CLANG_RESOURCE_DIR@
CLOCK_LIB = @CLOCK_LIB@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
CPP_FOR_BUILD = @CPP_FOR_BUILD@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXCPPFLAGS_FOR_BUILD = @CXXCPPFLAGS_FOR_BUILD@
CXXCPP_FOR_BUILD = @CXXCPP_FOR_BUILD@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CXXFLAGS_FOR_BUILD = @CXXFLAGS_FOR_BUILD@
CXX_FOR_BUILD = @CXX_FOR_BUILD@
CYGPATH_W = @CYGPATH_W@
DEFINES = @DEFINES@
DEFINES_FOR_BUILD = @DEFINES_FOR_BUILD@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DLOPEN_LIBS = @DLOPEN_LIBS@
DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
DRIGL_CFLAGS = @DRIGL_CFLAGS@
DRIGL_LIBS = @DRIGL_LIBS@
DRI_DRIVER_INSTALL_DIR = @DRI_DRIVER_INSTALL_DIR@
DRI_DRIVER_SEARCH_DIR = @DRI_DRIVER_SEARCH_DIR@
DRI_LIB_DEPS = @DRI_LIB_DEPS@
DRI_PC_REQ_PRIV = @DRI_PC_REQ_PRIV@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGL_CFLAGS = @EGL_CFLAGS@
EGL_CLIENT_APIS = @EGL_CLIENT_APIS@
EGL_DRIVER_INSTALL_DIR = @EGL_DRIVER_INSTALL_DIR@
EGL_LIB_DEPS = @EGL_LIB_DEPS@
EGL_LIB_GLOB = @EGL_LIB_GLOB@
EGL_LIB_NAME = @EGL_LIB_NAME@
EGL_NATIVE_PLATFORM = @EGL_NATIVE_PLATFORM@
EGL_PLATFORMS = @EGL_PLATFORMS@
EGREP = @EGREP@
ELF_LIB = @ELF_LIB@
EXEEXT = @EXEEXT@
EXPAT_INCLUDES = @EXPAT_INCLUDES@
FGREP = @FGREP@
FREEDRENO_CFLAGS = @FREEDRENO_CFLAGS@
FREEDRENO_LIBS = @FREEDRENO_LIBS@
GALLIUM_DRI_LIB_DEPS = @GALLIUM_DRI_LIB_DEPS@
GALLIUM_PIPE_LOADER_DEFINES = @GALLIUM_PIPE_LOADER_DEFINES@
GALLIUM_PIPE_LOADER_LIBS = @GALLIUM_PIPE_LOADER_LIBS@
GALLIUM_PIPE_LOADER_XCB_CFLAGS = @GALLIUM_PIPE_LOADER_XCB_CFLAGS@
GALLIUM_PIPE_LOADER_XCB_LIBS = @GALLIUM_PIPE_LOADER_XCB_LIBS@
GBM_PC_LIB_PRIV = @GBM_PC_LIB_PRIV@
GBM_PC_REQ_PRIV = @GBM_PC_REQ_PRIV@
GLAPI_LIB_GLOB = @GLAPI_LIB_GLOB@
GLAPI_LIB_NAME = @GLAPI_LIB_NAME@
GLESv1_CM_LIB_DEPS = @GLESv1_CM_LIB_DEPS@
GLESv1_CM_LIB_GLOB = @GLESv1_CM_LIB_GLOB@
GLESv1_CM_LIB_NAME = @GLESv1_CM_LIB_NAME@
GLESv1_CM_PC_LIB_PRIV = @GLESv1_CM_PC_LIB_PRIV@
GLESv2_LIB_DEPS = @GLESv2_LIB_DEPS@
GLESv2_LIB_GLOB = @GLESv2_LIB_GLOB@
GLESv2_LIB_NAME = @GLESv2_LIB_NAME@
GLESv2_PC_LIB_PRIV = @GLESv2_PC_LIB_PRIV@
GLPROTO_CFLAGS = @GLPROTO_CFLAGS@
GLPROTO_LIBS = @GLPROTO_LIBS@
GLX_TLS = @GLX_TLS@
GL_LIB = @GL_LIB@
GL_LIB_DEPS = @GL_LIB_DEPS@
GL_LIB_GLOB = @GL_LIB_GLOB@
GL_LIB_NAME = @GL_LIB_NAME@
GL_PC_CFLAGS = @GL_PC_CFLAGS@
GL_PC_LIB_PRIV = @GL_PC_LIB_PRIV@
GL_PC_REQ_PRIV = @GL_PC_REQ_PRIV@
GREP = @GREP@
HAVE_XF86VIDMODE = @HAVE_XF86VIDMODE@
INDENT = @INDENT@
INDENT_FLAGS = @INDENT_FLAGS@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTEL_CFLAGS = @INTEL_CFLAGS@
INTEL_LIBS = @INTEL_LIBS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBCLC_INCLUDEDIR = @LIBCLC_INCLUDEDIR@
LIBCLC_LIBEXECDIR = @LIBCLC_LIBEXECDIR@
LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
LIBDRM_LIBS = @LIBDRM_LIBS@
LIBDRM_XORG_CFLAGS = @LIBDRM_XORG_CFLAGS@
LIBDRM_XORG_LIBS = @LIBDRM_XORG_LIBS@
LIBKMS_XORG_CFLAGS = @LIBKMS_XORG_CFLAGS@
LIBKMS_XORG_LIBS = @LIBKMS_XORG_LIBS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@
LIBUDEV_LIBS = @LIBUDEV_LIBS@
LIB_DIR = @LIB_DIR@
LIPO = @LIPO@
LLVM_BINDIR = @LLVM_BINDIR@
LLVM_CFLAGS = @LLVM_CFLAGS@
LLVM_CONFIG = @LLVM_CONFIG@
LLVM_CPPFLAGS = @LLVM_CPPFLAGS@
LLVM_CXXFLAGS = @LLVM_CXXFLAGS@
LLVM_INCLUDEDIR = @LLVM_INCLUDEDIR@
LLVM_LDFLAGS = @LLVM_LDFLAGS@
LLVM_LIBDIR = @LLVM_LIBDIR@
LLVM_LIBS = @LLVM_LIBS@
LLVM_VERSION = @LLVM_VERSION@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKE = @MAKE@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MESA_LLVM = @MESA_LLVM@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
NOUVEAU_CFLAGS = @NOUVEAU_CFLAGS@
NOUVEAU_LIBS = @NOUVEAU_LIBS@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OPENCL_LIB_INSTALL_DIR = @OPENCL_LIB_INSTALL_DIR@
OSMESA_LIB = @OSMESA_LIB@
OSMESA_LIB_DEPS = @OSMESA_LIB_DEPS@
OSMESA_LIB_NAME = @OSMESA_LIB_NAME@
OSMESA_MESA_DEPS = @OSMESA_MESA_DEPS@
OSMESA_PC_LIB_PRIV = @OSMESA_PC_LIB_PRIV@
OSMESA_PC_REQ = @OSMESA_PC_REQ@
OSMESA_VERSION = @OSMESA_VERSION@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
POSIX_SHELL = @POSIX_SHELL@
PTHREAD_CC = @PTHREAD_CC@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
PYTHON2 = @PYTHON2@
RADEON_CFLAGS = @RADEON_CFLAGS@
RADEON_LIBS = @RADEON_LIBS@
RANLIB = @RANLIB@
SED = @SED@
SELINUX_LIBS = @SELINUX_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VDPAU_CFLAGS = @VDPAU_CFLAGS@
VDPAU_LIBS = @VDPAU_LIBS@
VDPAU_LIB_INSTALL_DIR = @VDPAU_LIB_INSTALL_DIR@
VDPAU_MAJOR = @VDPAU_MAJOR@
VDPAU_MINOR = @VDPAU_MINOR@
VERSION = @VERSION@
VG_LIB_DEPS = @VG_LIB_DEPS@
VG_LIB_GLOB = @VG_LIB_GLOB@
VG_LIB_NAME = @VG_LIB_NAME@
VG_PC_LIB_PRIV = @VG_PC_LIB_PRIV@
VISIBILITY_CFLAGS = @VISIBILITY_CFLAGS@
VISIBILITY_CXXFLAGS = @VISIBILITY_CXXFLAGS@
WAYLAND_CFLAGS = @WAYLAND_CFLAGS@
WAYLAND_LIBS = @WAYLAND_LIBS@
WAYLAND_SCANNER = @WAYLAND_SCANNER@
X11_INCLUDES = @X11_INCLUDES@
XA_MAJOR = @XA_MAJOR@
XA_MINOR = @XA_MINOR@
XA_TINY = @XA_TINY@
XA_VERSION = @XA_VERSION@
XCB_DRI2_CFLAGS = @XCB_DRI2_CFLAGS@
XCB_DRI2_LIBS = @XCB_DRI2_LIBS@
XEXT_CFLAGS = @XEXT_CFLAGS@
XEXT_LIBS = @XEXT_LIBS@
XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
XLIBGL_CFLAGS = @XLIBGL_CFLAGS@
XLIBGL_LIBS = @XLIBGL_LIBS@
XORG_CFLAGS = @XORG_CFLAGS@
XORG_DRIVER_INSTALL_DIR = @XORG_DRIVER_INSTALL_DIR@
XORG_LIBS = @XORG_LIBS@
XVMC_CFLAGS = @XVMC_CFLAGS@
XVMC_LIBS = @XVMC_LIBS@
XVMC_LIB_INSTALL_DIR = @XVMC_LIB_INSTALL_DIR@
XVMC_MAJOR = @XVMC_MAJOR@
XVMC_MINOR = @XVMC_MINOR@
YACC = @YACC@
YFLAGS = @YFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_CXX_FOR_BUILD = @ac_ct_CXX_FOR_BUILD@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
ax_pthread_config = @ax_pthread_config@
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 = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
@HAVE_SHARED_GLAPI_TRUE@AM_CFLAGS = $(PTHREAD_CFLAGS)
@HAVE_SHARED_GLAPI_TRUE@AM_CPPFLAGS = \
@HAVE_SHARED_GLAPI_TRUE@ -I$(top_srcdir)/src/gtest/include \
@HAVE_SHARED_GLAPI_TRUE@ -I$(top_srcdir)/src/mapi \
@HAVE_SHARED_GLAPI_TRUE@ -I$(top_srcdir)/src/mesa \
@HAVE_SHARED_GLAPI_TRUE@ -I$(top_srcdir)/src/glx \
@HAVE_SHARED_GLAPI_TRUE@ -I$(top_srcdir)/include \
@HAVE_SHARED_GLAPI_TRUE@ $(X11_CFLAGS)
 
@HAVE_SHARED_GLAPI_TRUE@glx_test_SOURCES = \
@HAVE_SHARED_GLAPI_TRUE@ clientinfo_unittest.cpp \
@HAVE_SHARED_GLAPI_TRUE@ create_context_unittest.cpp \
@HAVE_SHARED_GLAPI_TRUE@ enum_sizes.cpp \
@HAVE_SHARED_GLAPI_TRUE@ fake_glx_screen.cpp \
@HAVE_SHARED_GLAPI_TRUE@ indirect_api.cpp
 
@HAVE_SHARED_GLAPI_TRUE@glx_test_LDADD = \
@HAVE_SHARED_GLAPI_TRUE@ $(top_builddir)/src/glx/libglx.la \
@HAVE_SHARED_GLAPI_TRUE@ $(top_builddir)/src/gtest/libgtest.la \
@HAVE_SHARED_GLAPI_TRUE@ $(top_builddir)/src/mapi/shared-glapi/libglapi.la \
@HAVE_SHARED_GLAPI_TRUE@ $(PTHREAD_LIBS)
 
all: all-am
 
.SUFFIXES:
.SUFFIXES: .cpp .lo .log .o .obj .test .test$(EXEEXT) .trs
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/glx/tests/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign src/glx/tests/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
 
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
 
clean-checkPROGRAMS:
@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
rm -f $$list || exit $$?; \
test -n "$(EXEEXT)" || exit 0; \
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
 
glx-test$(EXEEXT): $(glx_test_OBJECTS) $(glx_test_DEPENDENCIES) $(EXTRA_glx_test_DEPENDENCIES)
@rm -f glx-test$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(glx_test_OBJECTS) $(glx_test_LDADD) $(LIBS)
 
mostlyclean-compile:
-rm -f *.$(OBJEXT)
 
distclean-compile:
-rm -f *.tab.c
 
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clientinfo_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/create_context_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enum_sizes.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fake_glx_screen.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indirect_api.Po@am__quote@
 
.cpp.o:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
 
.cpp.obj:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
.cpp.lo:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
 
mostlyclean-libtool:
-rm -f *.lo
 
clean-libtool:
-rm -rf .libs _libs
 
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
 
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
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-am
 
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
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"
cscopelist: cscopelist-am
 
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
 
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
# Recover from deleted '.trs' file; this should ensure that
# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
# to avoid problems with "make -n".
.log.trs:
rm -f $< $@
$(MAKE) $(AM_MAKEFLAGS) $<
 
# Leading 'am--fnord' is there to ensure the list of targets does not
# expand to empty, as could happen e.g. with make check TESTS=''.
am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
am--force-recheck:
@:
 
$(TEST_SUITE_LOG): $(TEST_LOGS)
@$(am__set_TESTS_bases); \
am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
redo_bases=`for i in $$bases; do \
am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
done`; \
if test -n "$$redo_bases"; then \
redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
if $(am__make_dryrun); then :; else \
rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
fi; \
fi; \
if test -n "$$am__remaking_logs"; then \
echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
"recursion detected" >&2; \
else \
am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
fi; \
if $(am__make_dryrun); then :; else \
st=0; \
errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
for i in $$redo_bases; do \
test -f $$i.trs && test -r $$i.trs \
|| { echo "$$errmsg $$i.trs" >&2; st=1; }; \
test -f $$i.log && test -r $$i.log \
|| { echo "$$errmsg $$i.log" >&2; st=1; }; \
done; \
test $$st -eq 0 || exit 1; \
fi
@$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
ws='[ ]'; \
results=`for b in $$bases; do echo $$b.trs; done`; \
test -n "$$results" || results=/dev/null; \
all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
if test `expr $$fail + $$xpass + $$error` -eq 0; then \
success=true; \
else \
success=false; \
fi; \
br='==================='; br=$$br$$br$$br$$br; \
result_count () \
{ \
if test x"$$1" = x"--maybe-color"; then \
maybe_colorize=yes; \
elif test x"$$1" = x"--no-color"; then \
maybe_colorize=no; \
else \
echo "$@: invalid 'result_count' usage" >&2; exit 4; \
fi; \
shift; \
desc=$$1 count=$$2; \
if test $$maybe_colorize = yes && test $$count -gt 0; then \
color_start=$$3 color_end=$$std; \
else \
color_start= color_end=; \
fi; \
echo "$${color_start}# $$desc $$count$${color_end}"; \
}; \
create_testsuite_report () \
{ \
result_count $$1 "TOTAL:" $$all "$$brg"; \
result_count $$1 "PASS: " $$pass "$$grn"; \
result_count $$1 "SKIP: " $$skip "$$blu"; \
result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
result_count $$1 "FAIL: " $$fail "$$red"; \
result_count $$1 "XPASS:" $$xpass "$$red"; \
result_count $$1 "ERROR:" $$error "$$mgn"; \
}; \
{ \
echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
$(am__rst_title); \
create_testsuite_report --no-color; \
echo; \
echo ".. contents:: :depth: 2"; \
echo; \
for b in $$bases; do echo $$b; done \
| $(am__create_global_log); \
} >$(TEST_SUITE_LOG).tmp || exit 1; \
mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
if $$success; then \
col="$$grn"; \
else \
col="$$red"; \
test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
fi; \
echo "$${col}$$br$${std}"; \
echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
echo "$${col}$$br$${std}"; \
create_testsuite_report --maybe-color; \
echo "$$col$$br$$std"; \
if $$success; then :; else \
echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
if test -n "$(PACKAGE_BUGREPORT)"; then \
echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
fi; \
echo "$$col$$br$$std"; \
fi; \
$$success || exit 1
 
check-TESTS:
@list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
@list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
@test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
@set +e; $(am__set_TESTS_bases); \
log_list=`for i in $$bases; do echo $$i.log; done`; \
trs_list=`for i in $$bases; do echo $$i.trs; done`; \
log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
exit $$?;
recheck: all $(check_PROGRAMS)
@test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
@set +e; $(am__set_TESTS_bases); \
bases=`for i in $$bases; do echo $$i; done \
| $(am__list_recheck_tests)` || exit 1; \
log_list=`for i in $$bases; do echo $$i.log; done`; \
log_list=`echo $$log_list`; \
$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
am__force_recheck=am--force-recheck \
TEST_LOGS="$$log_list"; \
exit $$?
glx-test.log: glx-test$(EXEEXT)
@p='glx-test$(EXEEXT)'; \
b='glx-test'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
.test.log:
@p='$<'; \
$(am__set_b); \
$(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
@am__EXEEXT_TRUE@.test$(EXEEXT).log:
@am__EXEEXT_TRUE@ @p='$<'; \
@am__EXEEXT_TRUE@ $(am__set_b); \
@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
 
distdir: $(DISTFILES)
@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
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
 
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
-test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
-test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs)
-test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
 
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."
clean: clean-am
 
clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
mostlyclean-am
 
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
 
dvi: dvi-am
 
dvi-am:
 
html: html-am
 
html-am:
 
info: info-am
 
info-am:
 
install-data-am:
 
install-dvi: install-dvi-am
 
install-dvi-am:
 
install-exec-am:
 
install-html: install-html-am
 
install-html-am:
 
install-info: install-info-am
 
install-info-am:
 
install-man:
 
install-pdf: install-pdf-am
 
install-pdf-am:
 
install-ps: install-ps-am
 
install-ps-am:
 
installcheck-am:
 
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
 
mostlyclean: mostlyclean-am
 
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
 
pdf: pdf-am
 
pdf-am:
 
ps: ps-am
 
ps-am:
 
uninstall-am:
 
.MAKE: check-am install-am install-strip
 
.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \
clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \
ctags ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am 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-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
recheck tags tags-am uninstall uninstall-am
 
 
# 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:
/contrib/sdk/sources/Mesa/src/glx/tests/clientinfo_unittest.cpp
0,0 → 1,723
/*
* Copyright © 2011 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <gtest/gtest.h>
#include <string.h>
 
extern "C" {
#include "glxclient.h"
}
 
#include <xcb/glx.h>
 
#include "mock_xdisplay.h"
#include "fake_glx_screen.h"
 
/**
* \name Wrappers around some X structures to make the more usable for tests
*/
/*@{*/
class fake_glx_screen;
 
class fake_glx_display : public glx_display {
public:
fake_glx_display(mock_XDisplay *dpy, int major, int minor)
{
this->next = 0;
this->dpy = dpy;
this->majorOpcode = 0;
this->majorVersion = major;
this->minorVersion = minor;
this->serverGLXvendor = 0;
this->serverGLXversion = 0;
this->glXDrawHash = 0;
 
this->screens = new glx_screen *[dpy->nscreens];
memset(this->screens, 0, sizeof(struct glx_screen *) * dpy->nscreens);
}
 
~fake_glx_display()
{
for (int i = 0; i < this->dpy->nscreens; i++) {
if (this->screens[i] != NULL)
delete this->screens[i];
}
 
delete [] this->screens;
}
 
void init_screen(int i, const char *ext);
};
 
class glX_send_client_info_test : public ::testing::Test {
public:
glX_send_client_info_test();
virtual ~glX_send_client_info_test();
virtual void SetUp();
 
void common_protocol_expected_false_test(unsigned major, unsigned minor,
const char *glx_ext, bool *value);
 
void common_protocol_expected_true_test(unsigned major, unsigned minor,
const char *glx_ext, bool *value);
 
void create_single_screen_display(unsigned major, unsigned minor,
const char *glx_ext);
 
void destroy_display();
 
protected:
fake_glx_display *glx_dpy;
mock_XDisplay *display;
};
 
void
fake_glx_display::init_screen(int i, const char *ext)
{
if (this->screens[i] != NULL)
delete this->screens[i];
 
this->screens[i] = new fake_glx_screen(this, i, ext);
}
/*@}*/
 
static const char ext[] = "GL_XXX_dummy";
 
static bool ClientInfo_was_sent;
static bool SetClientInfoARB_was_sent;
static bool SetClientInfo2ARB_was_sent;
static xcb_connection_t *connection_used;
static int gl_ext_length;
static char *gl_ext_string;
static int glx_ext_length;
static char *glx_ext_string;
static int num_gl_versions;
static uint32_t *gl_versions;
static int glx_major;
static int glx_minor;
 
extern "C" xcb_connection_t *
XGetXCBConnection(Display *dpy)
{
return (xcb_connection_t *) 0xdeadbeef;
}
 
extern "C" xcb_void_cookie_t
xcb_glx_client_info(xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version,
uint32_t str_len,
const char *string)
{
xcb_void_cookie_t cookie;
 
ClientInfo_was_sent = true;
connection_used = c;
 
gl_ext_string = (char *) malloc(str_len);
memcpy(gl_ext_string, string, str_len);
gl_ext_length = str_len;
 
glx_major = major_version;
glx_minor = minor_version;
 
cookie.sequence = 0;
return cookie;
}
 
extern "C" xcb_void_cookie_t
xcb_glx_set_client_info_arb(xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version,
uint32_t num_versions,
uint32_t gl_str_len,
uint32_t glx_str_len,
const uint32_t *versions,
const char *gl_string,
const char *glx_string)
{
xcb_void_cookie_t cookie;
 
SetClientInfoARB_was_sent = true;
connection_used = c;
 
gl_ext_string = new char[gl_str_len];
memcpy(gl_ext_string, gl_string, gl_str_len);
gl_ext_length = gl_str_len;
 
glx_ext_string = new char[glx_str_len];
memcpy(glx_ext_string, glx_string, glx_str_len);
glx_ext_length = glx_str_len;
 
gl_versions = new uint32_t[num_versions * 2];
memcpy(gl_versions, versions, sizeof(uint32_t) * num_versions * 2);
num_gl_versions = num_versions;
 
glx_major = major_version;
glx_minor = minor_version;
 
cookie.sequence = 0;
return cookie;
}
 
extern "C" xcb_void_cookie_t
xcb_glx_set_client_info_2arb(xcb_connection_t *c,
uint32_t major_version,
uint32_t minor_version,
uint32_t num_versions,
uint32_t gl_str_len,
uint32_t glx_str_len,
const uint32_t *versions,
const char *gl_string,
const char *glx_string)
{
xcb_void_cookie_t cookie;
 
SetClientInfo2ARB_was_sent = true;
connection_used = c;
 
gl_ext_string = new char[gl_str_len];
memcpy(gl_ext_string, gl_string, gl_str_len);
gl_ext_length = gl_str_len;
 
glx_ext_string = new char[glx_str_len];
memcpy(glx_ext_string, glx_string, glx_str_len);
glx_ext_length = glx_str_len;
 
gl_versions = new uint32_t[num_versions * 3];
memcpy(gl_versions, versions, sizeof(uint32_t) * num_versions * 3);
num_gl_versions = num_versions;
 
glx_major = major_version;
glx_minor = minor_version;
 
cookie.sequence = 0;
return cookie;
}
 
extern "C" char *
__glXGetClientGLExtensionString()
{
char *str = (char *) malloc(sizeof(ext));
 
memcpy(str, ext, sizeof(ext));
return str;
}
 
glX_send_client_info_test::glX_send_client_info_test()
: glx_dpy(0), display(0)
{
/* empty */
}
 
glX_send_client_info_test::~glX_send_client_info_test()
{
if (glx_dpy)
delete glx_dpy;
 
if (display)
delete display;
}
 
void
glX_send_client_info_test::destroy_display()
{
if (this->glx_dpy != NULL) {
if (this->glx_dpy->screens != NULL) {
for (int i = 0; i < this->display->nscreens; i++) {
delete [] this->glx_dpy->screens[i]->serverGLXexts;
delete this->glx_dpy->screens[i];
}
 
delete [] this->glx_dpy->screens;
}
 
delete this->glx_dpy;
delete this->display;
}
}
 
void
glX_send_client_info_test::SetUp()
{
ClientInfo_was_sent = false;
SetClientInfoARB_was_sent = false;
SetClientInfo2ARB_was_sent = false;
connection_used = (xcb_connection_t *) ~0;
gl_ext_length = 0;
gl_ext_string = (char *) 0;
glx_ext_length = 0;
glx_ext_string = (char *) 0;
num_gl_versions = 0;
gl_versions = (uint32_t *) 0;
glx_major = 0;
glx_minor = 0;
}
 
void
glX_send_client_info_test::create_single_screen_display(unsigned major,
unsigned minor,
const char *glx_ext)
{
this->display = new mock_XDisplay(1);
 
this->glx_dpy = new fake_glx_display(this->display, major, minor);
this->glx_dpy->init_screen(0, glx_ext);
}
 
void
glX_send_client_info_test::common_protocol_expected_false_test(unsigned major,
unsigned minor,
const char *glx_ext,
bool *value)
{
create_single_screen_display(major, minor, glx_ext);
__glX_send_client_info(this->glx_dpy);
EXPECT_FALSE(*value);
}
 
void
glX_send_client_info_test::common_protocol_expected_true_test(unsigned major,
unsigned minor,
const char *glx_ext,
bool *value)
{
create_single_screen_display(major, minor, glx_ext);
__glX_send_client_info(this->glx_dpy);
EXPECT_TRUE(*value);
}
 
TEST_F(glX_send_client_info_test, doesnt_send_ClientInfo_for_1_0)
{
/* The glXClientInfo protocol was added in GLX 1.1. Verify that no
* glXClientInfo is sent to a GLX server that only has GLX 1.0.
*/
common_protocol_expected_false_test(1, 0, "", &ClientInfo_was_sent);
}
 
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_0)
{
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is
* sent to a GLX server that only has GLX 1.0 regardless of the extension
* setting.
*/
common_protocol_expected_false_test(1, 0,
"GLX_ARB_create_context",
&SetClientInfoARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_1)
{
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is
* sent to a GLX server that only has GLX 1.0 regardless of the extension
* setting.
*/
common_protocol_expected_false_test(1, 1,
"GLX_ARB_create_context",
&SetClientInfoARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_4_with_empty_extensions)
{
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is
* sent to a GLX server that has GLX 1.4 but has an empty extension string
* (i.e., no extensions at all).
*/
common_protocol_expected_false_test(1, 4,
"",
&SetClientInfoARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_4_without_extension)
{
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is
* sent to a GLX server that has GLX 1.4 but doesn't have the extension.
*/
common_protocol_expected_false_test(1, 4,
"GLX_EXT_texture_from_pixmap",
&SetClientInfoARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_4_with_wrong_extension)
{
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is
* sent to a GLX server that has GLX 1.4 but does not have the extension.
*
* This test differs from
* doesnt_send_SetClientInfoARB_for_1_4_without_extension in that an
* extension exists that looks like the correct extension but isn't.
*/
common_protocol_expected_false_test(1, 4,
"GLX_ARB_create_context2",
&SetClientInfoARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfoARB_for_1_4_with_profile_extension)
{
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context extension. Verify that no glXSetClientInfoARB is
* sent to a GLX server that has GLX 1.4 but does not have the extension.
*
* This test differs from
* doesnt_send_SetClientInfoARB_for_1_4_without_extension in that an
* extension exists that looks like the correct extension but isn't.
*/
common_protocol_expected_false_test(1, 4,
"GLX_ARB_create_context_profile",
&SetClientInfoARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_0)
{
/* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context_profile extension. Verify that no
* glXSetClientInfo2ARB is sent to a GLX server that only has GLX 1.0
* regardless of the extension setting.
*/
common_protocol_expected_false_test(1, 0,
"GLX_ARB_create_context_profile",
&SetClientInfo2ARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_1)
{
/* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context_profile extension. Verify that no
* glXSetClientInfo2ARB is sent to a GLX server that only has GLX 1.1
* regardless of the extension setting.
*/
common_protocol_expected_false_test(1, 1,
"GLX_ARB_create_context_profile",
&SetClientInfo2ARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_4_with_empty_extensions)
{
/* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context_profile extension. Verify that no
* glXSetClientInfo2ARB is sent to a GLX server that has GLX 1.4 but has an
* empty extension string (i.e., no extensions at all).
*/
common_protocol_expected_false_test(1, 4,
"",
&SetClientInfo2ARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_4_without_extension)
{
/* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context_profile extension. Verify that no
* glXSetClientInfo2ARB is sent to a GLX server that has GLX 1.4 but
* doesn't have the extension.
*/
common_protocol_expected_false_test(1, 4,
"GLX_EXT_texture_from_pixmap",
&SetClientInfo2ARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, doesnt_send_SetClientInfo2ARB_for_1_4_with_wrong_extension)
{
/* The glXSetClientInfo2ARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context_profile extension. Verify that no
* glXSetClientInfo2ARB is sent to a GLX server that has GLX 1.4 but does
* not have the extension.
*
* This test differs from
* doesnt_send_SetClientInfo2ARB_for_1_4_without_extension in that an
* extension exists that looks like the correct extension but isn't.
*/
common_protocol_expected_false_test(1, 4,
"GLX_ARB_create_context_profile2",
&SetClientInfo2ARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, does_send_ClientInfo_for_1_1)
{
/* The glXClientInfo protocol was added in GLX 1.1. Verify that
* glXClientInfo is sent to a GLX server that has GLX 1.1.
*/
common_protocol_expected_true_test(1, 1,
"",
&ClientInfo_was_sent);
}
 
TEST_F(glX_send_client_info_test, does_send_SetClientInfoARB_for_1_4_with_extension)
{
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context extension. Verify that glXSetClientInfoARB is
* sent to a GLX server that has GLX 1.4 and the extension.
*/
common_protocol_expected_true_test(1, 4,
"GLX_ARB_create_context",
&SetClientInfoARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, does_send_SetClientInfo2ARB_for_1_4_with_just_profile_extension)
{
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context extension. Verify that glXSetClientInfoARB is
* sent to a GLX server that has GLX 1.4 and the extension.
*/
common_protocol_expected_true_test(1, 4,
"GLX_ARB_create_context_profile",
&SetClientInfo2ARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, does_send_SetClientInfo2ARB_for_1_4_with_both_extensions)
{
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context extension. Verify that glXSetClientInfoARB is
* sent to a GLX server that has GLX 1.4 and the extension.
*/
common_protocol_expected_true_test(1, 4,
"GLX_ARB_create_context "
"GLX_ARB_create_context_profile",
&SetClientInfo2ARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, does_send_SetClientInfo2ARB_for_1_4_with_both_extensions_reversed)
{
/* The glXSetClientInfoARB protocol was added in GLX 1.4 with the
* GLX_ARB_create_context extension. Verify that glXSetClientInfoARB is
* sent to a GLX server that has GLX 1.4 and the extension.
*/
common_protocol_expected_true_test(1, 4,
"GLX_ARB_create_context_profile "
"GLX_ARB_create_context",
&SetClientInfo2ARB_was_sent);
}
 
TEST_F(glX_send_client_info_test, uses_correct_connection)
{
create_single_screen_display(1, 1, "");
__glX_send_client_info(this->glx_dpy);
EXPECT_EQ((xcb_connection_t *) 0xdeadbeef, connection_used);
}
 
TEST_F(glX_send_client_info_test, sends_correct_gl_extension_string)
{
create_single_screen_display(1, 1, "");
__glX_send_client_info(this->glx_dpy);
 
ASSERT_EQ((int) sizeof(ext), gl_ext_length);
ASSERT_NE((char *) 0, gl_ext_string);
EXPECT_EQ(0, memcmp(gl_ext_string, ext, sizeof(ext)));
}
 
TEST_F(glX_send_client_info_test, gl_versions_are_sane)
{
create_single_screen_display(1, 4, "GLX_ARB_create_context");
__glX_send_client_info(this->glx_dpy);
 
ASSERT_NE(0, num_gl_versions);
 
unsigned versions_below_3_0 = 0;
for (int i = 0; i < num_gl_versions; i++) {
EXPECT_LT(0u, gl_versions[i * 2]);
EXPECT_GE(4u, gl_versions[i * 2]);
 
/* Verify that the minor version advertised with the major version makes
* sense.
*/
switch (gl_versions[i * 2]) {
case 1:
EXPECT_GE(5u, gl_versions[i * 2 + 1]);
versions_below_3_0++;
break;
case 2:
EXPECT_GE(1u, gl_versions[i * 2 + 1]);
versions_below_3_0++;
break;
case 3:
EXPECT_GE(3u, gl_versions[i * 2 + 1]);
break;
case 4:
EXPECT_GE(2u, gl_versions[i * 2 + 1]);
break;
}
}
 
/* From the GLX_ARB_create_context spec:
*
* "Only the highest supported version below 3.0 should be sent, since
* OpenGL 2.1 is backwards compatible with all earlier versions."
*/
EXPECT_LE(versions_below_3_0, 1u);
}
 
TEST_F(glX_send_client_info_test, gl_versions_and_profiles_are_sane)
{
create_single_screen_display(1, 4, "GLX_ARB_create_context_profile");
__glX_send_client_info(this->glx_dpy);
 
ASSERT_NE(0, num_gl_versions);
 
const uint32_t all_valid_bits = GLX_CONTEXT_CORE_PROFILE_BIT_ARB
| GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
 
unsigned versions_below_3_0 = 0;
 
for (int i = 0; i < num_gl_versions; i++) {
EXPECT_LT(0u, gl_versions[i * 3]);
EXPECT_GE(4u, gl_versions[i * 3]);
 
/* Verify that the minor version advertised with the major version makes
* sense.
*/
switch (gl_versions[i * 3]) {
case 1:
EXPECT_GE(5u, gl_versions[i * 3 + 1]);
EXPECT_EQ(0u, gl_versions[i * 3 + 2]);
versions_below_3_0++;
break;
case 2:
EXPECT_GE(1u, gl_versions[i * 3 + 1]);
EXPECT_EQ(0u, gl_versions[i * 3 + 2]);
versions_below_3_0++;
break;
case 3:
EXPECT_GE(3u, gl_versions[i * 3 + 1]);
 
/* Profiles were not introduced until OpenGL 3.2.
*/
if (gl_versions[i * 3 + 1] < 2) {
EXPECT_EQ(0u, gl_versions[i * 3 + 2]);
} else {
EXPECT_EQ(0u, gl_versions[i * 3 + 2] & ~all_valid_bits);
}
break;
case 4:
EXPECT_GE(2u, gl_versions[i * 3 + 1]);
EXPECT_EQ(0u, gl_versions[i * 3 + 2] & ~all_valid_bits);
break;
}
}
 
/* From the GLX_ARB_create_context_profile spec:
*
* "Only the highest supported version below 3.0 should be sent, since
* OpenGL 2.1 is backwards compatible with all earlier versions."
*/
EXPECT_LE(versions_below_3_0, 1u);
}
 
TEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_1)
{
create_single_screen_display(1, 1, "");
__glX_send_client_info(this->glx_dpy);
 
EXPECT_EQ(1, glx_major);
EXPECT_EQ(4, glx_minor);
}
 
TEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_4)
{
create_single_screen_display(1, 4, "");
__glX_send_client_info(this->glx_dpy);
 
EXPECT_EQ(1, glx_major);
EXPECT_EQ(4, glx_minor);
}
 
TEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_4_with_ARB_create_context)
{
create_single_screen_display(1, 4, "GLX_ARB_create_context");
__glX_send_client_info(this->glx_dpy);
 
EXPECT_EQ(1, glx_major);
EXPECT_EQ(4, glx_minor);
}
 
TEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_4_with_ARB_create_context_profile)
{
create_single_screen_display(1, 4, "GLX_ARB_create_context_profile");
__glX_send_client_info(this->glx_dpy);
 
EXPECT_EQ(1, glx_major);
EXPECT_EQ(4, glx_minor);
}
 
TEST_F(glX_send_client_info_test, glx_version_is_1_4_for_1_5)
{
create_single_screen_display(1, 5, "");
__glX_send_client_info(this->glx_dpy);
 
EXPECT_EQ(1, glx_major);
EXPECT_EQ(4, glx_minor);
}
 
TEST_F(glX_send_client_info_test, glx_extensions_has_GLX_ARB_create_context)
{
create_single_screen_display(1, 4, "GLX_ARB_create_context");
__glX_send_client_info(this->glx_dpy);
 
ASSERT_NE(0, glx_ext_length);
ASSERT_NE((char *) 0, glx_ext_string);
 
bool found_GLX_ARB_create_context = false;
const char *const needle = "GLX_ARB_create_context";
const unsigned len = strlen(needle);
char *haystack = glx_ext_string;
while (haystack != NULL) {
char *match = strstr(haystack, needle);
 
if (match[len] == '\0' || match[len] == ' ') {
found_GLX_ARB_create_context = true;
break;
}
 
haystack = match + len;
}
 
EXPECT_TRUE(found_GLX_ARB_create_context);
}
 
TEST_F(glX_send_client_info_test, glx_extensions_has_GLX_ARB_create_context_profile)
{
create_single_screen_display(1, 4, "GLX_ARB_create_context_profile");
__glX_send_client_info(this->glx_dpy);
 
ASSERT_NE(0, glx_ext_length);
ASSERT_NE((char *) 0, glx_ext_string);
 
bool found_GLX_ARB_create_context_profile = false;
const char *const needle = "GLX_ARB_create_context_profile";
const unsigned len = strlen(needle);
char *haystack = glx_ext_string;
while (haystack != NULL) {
char *match = strstr(haystack, needle);
 
if (match[len] == '\0' || match[len] == ' ') {
found_GLX_ARB_create_context_profile = true;
break;
}
 
haystack = match + len;
}
 
EXPECT_TRUE(found_GLX_ARB_create_context_profile);
}
/contrib/sdk/sources/Mesa/src/glx/tests/create_context_unittest.cpp
0,0 → 1,513
/*
* Copyright © 2011 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <gtest/gtest.h>
#include <string.h>
 
extern "C" {
#include "glxclient.h"
#include "glx_error.h"
}
 
#include <xcb/glx.h>
#include "mock_xdisplay.h"
#include "fake_glx_screen.h"
 
static bool CreateContextAttribsARB_was_sent;
static xcb_glx_create_context_attribs_arb_request_t req;
static uint32_t sent_attribs[1024];
static uint32_t next_id;
 
 
struct glx_screen *psc;
 
extern "C" Bool
glx_context_init(struct glx_context *gc,
struct glx_screen *psc, struct glx_config *config)
{
gc->majorOpcode = 123;
gc->screen = psc->scr;
gc->psc = psc;
gc->config = config;
gc->isDirect = GL_TRUE;
gc->currentContextTag = -1;
 
return GL_TRUE;
}
 
extern "C" struct glx_screen *
GetGLXScreenConfigs(Display * dpy, int scrn)
{
(void) dpy;
(void) scrn;
return psc;
}
 
extern "C" uint32_t
xcb_generate_id(xcb_connection_t *c)
{
(void) c;
 
return next_id++;
}
 
extern "C" xcb_void_cookie_t
xcb_glx_create_context_attribs_arb_checked(xcb_connection_t *c,
xcb_glx_context_t context,
uint32_t fbconfig,
uint32_t screen,
uint32_t share_list,
uint8_t is_direct,
uint32_t num_attribs,
const uint32_t *attribs)
{
(void) c;
 
CreateContextAttribsARB_was_sent = true;
req.context = context;
req.fbconfig = fbconfig;
req.screen = screen;
req.share_list = share_list;
req.is_direct = is_direct;
req.num_attribs = num_attribs;
 
if (num_attribs != 0 && attribs != NULL)
memcpy(sent_attribs, attribs, num_attribs * 2 * sizeof(uint32_t));
 
xcb_void_cookie_t cookie;
cookie.sequence = 0xbadc0de;
 
return cookie;
}
 
extern "C" xcb_generic_error_t *
xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie)
{
return NULL;
}
 
extern "C" void
__glXSendErrorForXcb(Display * dpy, const xcb_generic_error_t *err)
{
}
 
extern "C" void
__glXSendError(Display * dpy, int_fast8_t errorCode, uint_fast32_t resourceID,
uint_fast16_t minorCode, bool coreX11error)
{
}
 
class glXCreateContextAttribARB_test : public ::testing::Test {
public:
virtual void SetUp();
 
/**
* Replace the existing screen with a direct-rendering screen
*/
void use_direct_rendering_screen();
 
mock_XDisplay *dpy;
struct glx_config fbc;
};
 
void
glXCreateContextAttribARB_test::SetUp()
{
CreateContextAttribsARB_was_sent = false;
memset(&req, 0, sizeof(req));
next_id = 99;
fake_glx_context::contexts_allocated = 0;
psc = new fake_glx_screen(NULL, 0, "");
 
this->dpy = new mock_XDisplay(1);
 
memset(&this->fbc, 0, sizeof(this->fbc));
this->fbc.fbconfigID = 0xbeefcafe;
}
 
void
glXCreateContextAttribARB_test::use_direct_rendering_screen()
{
struct glx_screen *direct_psc =
new fake_glx_screen_direct(psc->display,
psc->scr,
psc->serverGLXexts);
 
delete psc;
psc = direct_psc;
}
 
/**
* \name Verify detection of client-side errors
*/
/*@{*/
TEST_F(glXCreateContextAttribARB_test, NULL_display_returns_None)
{
GLXContext ctx =
glXCreateContextAttribsARB(NULL, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
EXPECT_EQ(None, ctx);
EXPECT_EQ(0, fake_glx_context::contexts_allocated);
}
 
TEST_F(glXCreateContextAttribARB_test, NULL_fbconfig_returns_None)
{
GLXContext ctx =
glXCreateContextAttribsARB(this->dpy, NULL, 0, False, NULL);
 
EXPECT_EQ(None, ctx);
EXPECT_EQ(0, fake_glx_context::contexts_allocated);
}
 
TEST_F(glXCreateContextAttribARB_test, NULL_screen_returns_None)
{
delete psc;
psc = NULL;
 
GLXContext ctx =
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
EXPECT_EQ(None, ctx);
EXPECT_EQ(0, fake_glx_context::contexts_allocated);
}
/*@}*/
 
/**
* \name Verify that correct protocol bits are sent to the server.
*/
/*@{*/
TEST_F(glXCreateContextAttribARB_test, does_send_protocol)
{
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
EXPECT_TRUE(CreateContextAttribsARB_was_sent);
}
 
TEST_F(glXCreateContextAttribARB_test, sent_correct_context)
{
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
EXPECT_EQ(99u, req.context);
}
 
TEST_F(glXCreateContextAttribARB_test, sent_correct_fbconfig)
{
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
EXPECT_EQ(0xbeefcafe, req.fbconfig);
}
 
TEST_F(glXCreateContextAttribARB_test, sent_correct_share_list)
{
GLXContext share =
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
ASSERT_NE((GLXContext) 0, share);
 
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, share,
False, NULL);
 
struct glx_context *glx_ctx = (struct glx_context *) share;
EXPECT_EQ(glx_ctx->xid, req.share_list);
}
 
TEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_indirect_screen_and_direct_set_to_true)
{
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
True, NULL);
 
EXPECT_FALSE(req.is_direct);
}
 
TEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_indirect_screen_and_direct_set_to_false)
{
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
EXPECT_FALSE(req.is_direct);
}
 
TEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_direct_screen_and_direct_set_to_true)
{
this->use_direct_rendering_screen();
 
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
True, NULL);
 
EXPECT_TRUE(req.is_direct);
}
 
TEST_F(glXCreateContextAttribARB_test, sent_correct_is_direct_for_direct_screen_and_direct_set_to_false)
{
this->use_direct_rendering_screen();
 
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
EXPECT_FALSE(req.is_direct);
}
 
TEST_F(glXCreateContextAttribARB_test, sent_correct_screen)
{
this->fbc.screen = 7;
psc->scr = 7;
 
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
EXPECT_EQ(7u, req.screen);
}
 
TEST_F(glXCreateContextAttribARB_test, sent_correct_num_attribs)
{
/* Use zeros in the second half of each attribute pair to try and trick the
* implementation into termiating the list early.
*
* Use non-zero in the second half of the last attribute pair to try and
* trick the implementation into not terminating the list early enough.
*/
static const int attribs[] = {
1, 0,
2, 0,
3, 0,
4, 0,
0, 6,
0, 0
};
 
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, attribs);
 
EXPECT_EQ(4u, req.num_attribs);
}
 
TEST_F(glXCreateContextAttribARB_test, sent_correct_num_attribs_empty_list)
{
static const int attribs[] = {
0,
};
 
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, attribs);
 
EXPECT_EQ(0u, req.num_attribs);
}
 
TEST_F(glXCreateContextAttribARB_test, sent_correct_num_attribs_NULL_list_pointer)
{
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
EXPECT_EQ(0u, req.num_attribs);
}
 
TEST_F(glXCreateContextAttribARB_test, sent_correct_attrib_list)
{
int attribs[] = {
GLX_RENDER_TYPE, GLX_RGBA_TYPE,
GLX_CONTEXT_MAJOR_VERSION_ARB, 1,
GLX_CONTEXT_MINOR_VERSION_ARB, 2,
0
};
 
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, attribs);
 
for (unsigned i = 0; i < 6; i++) {
EXPECT_EQ((uint32_t) attribs[i], sent_attribs[i]);
}
}
/*@}*/
 
/**
* \name Verify details of the returned GLXContext
*/
/*@{*/
TEST_F(glXCreateContextAttribARB_test, correct_context)
{
GLXContext ctx =
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
/* Since the server did not return an error, the GLXContext should not be
* NULL.
*/
EXPECT_NE((GLXContext)0, ctx);
 
/* It shouldn't be the XID of the context either.
*/
EXPECT_NE((GLXContext)99, ctx);
}
 
TEST_F(glXCreateContextAttribARB_test, correct_context_xid)
{
GLXContext ctx =
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
/* Since the server did not return an error, the GLXContext should not be
* NULL.
*/
ASSERT_NE((GLXContext)0, ctx);
 
struct glx_context *glx_ctx = (struct glx_context *) ctx;
EXPECT_EQ(99u, glx_ctx->xid);
}
 
TEST_F(glXCreateContextAttribARB_test, correct_context_share_xid)
{
GLXContext first =
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
ASSERT_NE((GLXContext) 0, first);
 
GLXContext second =
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, first,
False, NULL);
 
ASSERT_NE((GLXContext) 0, second);
 
struct glx_context *share = (struct glx_context *) first;
struct glx_context *ctx = (struct glx_context *) second;
EXPECT_EQ(share->xid, ctx->share_xid);
}
 
TEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_indirect_screen_and_direct_set_to_true)
{
GLXContext ctx =
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
True, NULL);
 
ASSERT_NE((GLXContext) 0, ctx);
 
struct glx_context *gc = (struct glx_context *) ctx;
 
EXPECT_FALSE(gc->isDirect);
}
 
TEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_indirect_screen_and_direct_set_to_false)
{
GLXContext ctx =
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
ASSERT_NE((GLXContext) 0, ctx);
 
struct glx_context *gc = (struct glx_context *) ctx;
 
EXPECT_FALSE(gc->isDirect);
}
 
TEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_direct_screen_and_direct_set_to_true)
{
this->use_direct_rendering_screen();
 
GLXContext ctx =
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
True, NULL);
 
ASSERT_NE((GLXContext) 0, ctx);
 
struct glx_context *gc = (struct glx_context *) ctx;
 
EXPECT_TRUE(gc->isDirect);
}
 
TEST_F(glXCreateContextAttribARB_test, correct_context_isDirect_for_direct_screen_and_direct_set_to_false)
{
this->use_direct_rendering_screen();
 
GLXContext ctx =
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
ASSERT_NE((GLXContext) 0, ctx);
 
struct glx_context *gc = (struct glx_context *) ctx;
 
EXPECT_FALSE(gc->isDirect);
}
 
TEST_F(glXCreateContextAttribARB_test, correct_indirect_context_client_state_private)
{
GLXContext ctx =
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
ASSERT_NE((GLXContext) 0, ctx);
 
struct glx_context *gc = (struct glx_context *) ctx;
 
ASSERT_FALSE(gc->isDirect);
EXPECT_EQ((struct __GLXattributeRec *) 0xcafebabe,
gc->client_state_private);
}
 
TEST_F(glXCreateContextAttribARB_test, correct_indirect_context_config)
{
GLXContext ctx =
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
ASSERT_NE((GLXContext) 0, ctx);
 
struct glx_context *gc = (struct glx_context *) ctx;
 
EXPECT_EQ(&this->fbc, gc->config);
}
 
TEST_F(glXCreateContextAttribARB_test, correct_context_screen_number)
{
this->fbc.screen = 7;
psc->scr = 7;
 
GLXContext ctx =
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
ASSERT_NE((GLXContext) 0, ctx);
 
struct glx_context *gc = (struct glx_context *) ctx;
 
EXPECT_EQ(7, gc->screen);
}
 
TEST_F(glXCreateContextAttribARB_test, correct_context_screen_pointer)
{
GLXContext ctx =
glXCreateContextAttribsARB(this->dpy, (GLXFBConfig) &this->fbc, 0,
False, NULL);
 
ASSERT_NE((GLXContext) 0, ctx);
 
struct glx_context *gc = (struct glx_context *) ctx;
 
EXPECT_EQ(psc, gc->psc);
}
/*@}*/
/contrib/sdk/sources/Mesa/src/glx/tests/enum_sizes.cpp
0,0 → 1,556
/*
* Copyright © 2012 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
 
/**
* \file enum_sizes.cpp
* Validate the generated code in indirect_size.c
*
* The functions in indirect_size.c determine how many data values are
* associated with each enumerant that can be passed to various OpenGL
* functions. Tests in this file probe each function in indirect_size.c with
* each of the possible valid enums and verify that the correct size is
* returned. Tests in this file also probe each function in indirect_size.c
* with a larger number of \b invalid enums and verify that zero is returned.
*/
 
#include <gtest/gtest.h>
#include <GL/gl.h>
extern "C" {
#include "../indirect_size.h"
}
 
TEST(ValidEnumSizes, CallLists)
{
EXPECT_EQ(1, __glCallLists_size(GL_BYTE));
EXPECT_EQ(1, __glCallLists_size(GL_UNSIGNED_BYTE));
EXPECT_EQ(2, __glCallLists_size(GL_SHORT));
EXPECT_EQ(2, __glCallLists_size(GL_UNSIGNED_SHORT));
EXPECT_EQ(2, __glCallLists_size(GL_2_BYTES));
EXPECT_EQ(2, __glCallLists_size(GL_HALF_FLOAT));
EXPECT_EQ(3, __glCallLists_size(GL_3_BYTES));
EXPECT_EQ(4, __glCallLists_size(GL_INT));
EXPECT_EQ(4, __glCallLists_size(GL_UNSIGNED_INT));
EXPECT_EQ(4, __glCallLists_size(GL_FLOAT));
EXPECT_EQ(4, __glCallLists_size(GL_4_BYTES));
}
 
TEST(InvalidEnumSizes, CallLists)
{
for (unsigned i = 0; i < 0x10004; i++) {
switch (i) {
case GL_BYTE:
case GL_UNSIGNED_BYTE:
case GL_SHORT:
case GL_UNSIGNED_SHORT:
case GL_2_BYTES:
case GL_HALF_FLOAT:
case GL_3_BYTES:
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
case GL_4_BYTES:
break;
default:
EXPECT_EQ(0, __glCallLists_size(i)) << "i = 0x" <<
std::setw(4) << std::setfill('0') << std::hex << i;
}
}
}
 
TEST(ValidEnumSizes, Fogfv)
{
EXPECT_EQ(1, __glFogfv_size(GL_FOG_INDEX));
EXPECT_EQ(1, __glFogfv_size(GL_FOG_DENSITY));
EXPECT_EQ(1, __glFogfv_size(GL_FOG_START));
EXPECT_EQ(1, __glFogfv_size(GL_FOG_END));
EXPECT_EQ(1, __glFogfv_size(GL_FOG_MODE));
EXPECT_EQ(1, __glFogfv_size(GL_FOG_OFFSET_VALUE_SGIX));
EXPECT_EQ(1, __glFogfv_size(GL_FOG_DISTANCE_MODE_NV));
EXPECT_EQ(4, __glFogfv_size(GL_FOG_COLOR));
}
 
TEST(InvalidEnumSizes, Fogfv)
{
for (unsigned i = 0; i < 0x10004; i++) {
switch (i) {
case GL_FOG_INDEX:
case GL_FOG_DENSITY:
case GL_FOG_START:
case GL_FOG_END:
case GL_FOG_MODE:
case GL_FOG_OFFSET_VALUE_SGIX:
case GL_FOG_DISTANCE_MODE_NV:
case GL_FOG_COLOR:
break;
default:
EXPECT_EQ(0, __glFogfv_size(i)) << "i = 0x" <<
std::setw(4) << std::setfill('0') << std::hex << i;
}
}
}
 
TEST(ValidEnumSizes, Lightfv)
{
EXPECT_EQ(1, __glLightfv_size(GL_SPOT_EXPONENT));
EXPECT_EQ(1, __glLightfv_size(GL_SPOT_CUTOFF));
EXPECT_EQ(1, __glLightfv_size(GL_CONSTANT_ATTENUATION));
EXPECT_EQ(1, __glLightfv_size(GL_LINEAR_ATTENUATION));
EXPECT_EQ(1, __glLightfv_size(GL_QUADRATIC_ATTENUATION));
EXPECT_EQ(3, __glLightfv_size(GL_SPOT_DIRECTION));
EXPECT_EQ(4, __glLightfv_size(GL_AMBIENT));
EXPECT_EQ(4, __glLightfv_size(GL_DIFFUSE));
EXPECT_EQ(4, __glLightfv_size(GL_SPECULAR));
EXPECT_EQ(4, __glLightfv_size(GL_POSITION));
}
 
TEST(InvalidEnumSizes, Lightfv)
{
for (unsigned i = 0; i < 0x10004; i++) {
switch (i) {
case GL_SPOT_EXPONENT:
case GL_SPOT_CUTOFF:
case GL_CONSTANT_ATTENUATION:
case GL_LINEAR_ATTENUATION:
case GL_QUADRATIC_ATTENUATION:
case GL_SPOT_DIRECTION:
case GL_AMBIENT:
case GL_DIFFUSE:
case GL_SPECULAR:
case GL_POSITION:
break;
default:
EXPECT_EQ(0, __glLightfv_size(i)) << "i = 0x" <<
std::setw(4) << std::setfill('0') << std::hex << i;
}
}
}
 
TEST(ValidEnumSizes, LightModelfv)
{
EXPECT_EQ(1, __glLightModelfv_size(GL_LIGHT_MODEL_LOCAL_VIEWER));
EXPECT_EQ(1, __glLightModelfv_size(GL_LIGHT_MODEL_TWO_SIDE));
EXPECT_EQ(1, __glLightModelfv_size(GL_LIGHT_MODEL_COLOR_CONTROL));
EXPECT_EQ(1, __glLightModelfv_size(GL_LIGHT_MODEL_COLOR_CONTROL_EXT));
EXPECT_EQ(4, __glLightModelfv_size(GL_LIGHT_MODEL_AMBIENT));
}
 
TEST(InvalidEnumSizes, LightModelfv)
{
for (unsigned i = 0; i < 0x10004; i++) {
switch (i) {
case GL_LIGHT_MODEL_LOCAL_VIEWER:
case GL_LIGHT_MODEL_TWO_SIDE:
case GL_LIGHT_MODEL_COLOR_CONTROL:
/* case GL_LIGHT_MODEL_COLOR_CONTROL_EXT:*/
case GL_LIGHT_MODEL_AMBIENT:
break;
default:
EXPECT_EQ(0, __glLightModelfv_size(i)) << "i = 0x" <<
std::setw(4) << std::setfill('0') << std::hex << i;
}
}
}
 
TEST(ValidEnumSizes, Materialfv)
{
EXPECT_EQ(1, __glMaterialfv_size(GL_SHININESS));
EXPECT_EQ(3, __glMaterialfv_size(GL_COLOR_INDEXES));
EXPECT_EQ(4, __glMaterialfv_size(GL_AMBIENT));
EXPECT_EQ(4, __glMaterialfv_size(GL_DIFFUSE));
EXPECT_EQ(4, __glMaterialfv_size(GL_SPECULAR));
EXPECT_EQ(4, __glMaterialfv_size(GL_EMISSION));
EXPECT_EQ(4, __glMaterialfv_size(GL_AMBIENT_AND_DIFFUSE));
}
 
TEST(InvalidEnumSizes, Materialfv)
{
for (unsigned i = 0; i < 0x10004; i++) {
switch (i) {
case GL_SHININESS:
case GL_COLOR_INDEXES:
case GL_AMBIENT:
case GL_DIFFUSE:
case GL_SPECULAR:
case GL_EMISSION:
case GL_AMBIENT_AND_DIFFUSE:
break;
default:
EXPECT_EQ(0, __glMaterialfv_size(i)) << "i = 0x" <<
std::setw(4) << std::setfill('0') << std::hex << i;
}
}
}
 
TEST(ValidEnumSizes, TexParameterfv)
{
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MAG_FILTER));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MIN_FILTER));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_WRAP_S));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_WRAP_T));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_PRIORITY));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_WRAP_R));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_COMPARE_FAIL_VALUE_ARB));
EXPECT_EQ(1, __glTexParameterfv_size(GL_SHADOW_AMBIENT_SGIX));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MIN_LOD));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MAX_LOD));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_BASE_LEVEL));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MAX_LEVEL));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_CLIPMAP_FRAME_SGIX));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_LOD_BIAS_S_SGIX));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_LOD_BIAS_T_SGIX));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_LOD_BIAS_R_SGIX));
EXPECT_EQ(1, __glTexParameterfv_size(GL_GENERATE_MIPMAP));
EXPECT_EQ(1, __glTexParameterfv_size(GL_GENERATE_MIPMAP_SGIS));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_COMPARE_SGIX));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_COMPARE_OPERATOR_SGIX));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MAX_CLAMP_S_SGIX));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MAX_CLAMP_T_SGIX));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MAX_CLAMP_R_SGIX));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_MAX_ANISOTROPY_EXT));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_LOD_BIAS));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_LOD_BIAS_EXT));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_STORAGE_HINT_APPLE));
EXPECT_EQ(1, __glTexParameterfv_size(GL_STORAGE_PRIVATE_APPLE));
EXPECT_EQ(1, __glTexParameterfv_size(GL_STORAGE_CACHED_APPLE));
EXPECT_EQ(1, __glTexParameterfv_size(GL_STORAGE_SHARED_APPLE));
EXPECT_EQ(1, __glTexParameterfv_size(GL_DEPTH_TEXTURE_MODE));
EXPECT_EQ(1, __glTexParameterfv_size(GL_DEPTH_TEXTURE_MODE_ARB));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_COMPARE_MODE));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_COMPARE_MODE_ARB));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_COMPARE_FUNC));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_COMPARE_FUNC_ARB));
EXPECT_EQ(1, __glTexParameterfv_size(GL_TEXTURE_UNSIGNED_REMAP_MODE_NV));
EXPECT_EQ(2, __glTexParameterfv_size(GL_TEXTURE_CLIPMAP_CENTER_SGIX));
EXPECT_EQ(2, __glTexParameterfv_size(GL_TEXTURE_CLIPMAP_OFFSET_SGIX));
EXPECT_EQ(3, __glTexParameterfv_size(GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX));
EXPECT_EQ(4, __glTexParameterfv_size(GL_TEXTURE_BORDER_COLOR));
EXPECT_EQ(4, __glTexParameterfv_size(GL_POST_TEXTURE_FILTER_BIAS_SGIX));
EXPECT_EQ(4, __glTexParameterfv_size(GL_POST_TEXTURE_FILTER_SCALE_SGIX));
}
 
TEST(InvalidEnumSizes, TexParameterfv)
{
for (unsigned i = 0; i < 0x10004; i++) {
switch (i) {
case GL_TEXTURE_MAG_FILTER:
case GL_TEXTURE_MIN_FILTER:
case GL_TEXTURE_WRAP_S:
case GL_TEXTURE_WRAP_T:
case GL_TEXTURE_PRIORITY:
case GL_TEXTURE_WRAP_R:
case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
/* case GL_SHADOW_AMBIENT_SGIX:*/
case GL_TEXTURE_MIN_LOD:
case GL_TEXTURE_MAX_LOD:
case GL_TEXTURE_BASE_LEVEL:
case GL_TEXTURE_MAX_LEVEL:
case GL_TEXTURE_CLIPMAP_FRAME_SGIX:
case GL_TEXTURE_LOD_BIAS_S_SGIX:
case GL_TEXTURE_LOD_BIAS_T_SGIX:
case GL_TEXTURE_LOD_BIAS_R_SGIX:
case GL_GENERATE_MIPMAP:
/* case GL_GENERATE_MIPMAP_SGIS:*/
case GL_TEXTURE_COMPARE_SGIX:
case GL_TEXTURE_COMPARE_OPERATOR_SGIX:
case GL_TEXTURE_MAX_CLAMP_S_SGIX:
case GL_TEXTURE_MAX_CLAMP_T_SGIX:
case GL_TEXTURE_MAX_CLAMP_R_SGIX:
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
case GL_TEXTURE_LOD_BIAS:
/* case GL_TEXTURE_LOD_BIAS_EXT:*/
case GL_TEXTURE_STORAGE_HINT_APPLE:
case GL_STORAGE_PRIVATE_APPLE:
case GL_STORAGE_CACHED_APPLE:
case GL_STORAGE_SHARED_APPLE:
case GL_DEPTH_TEXTURE_MODE:
/* case GL_DEPTH_TEXTURE_MODE_ARB:*/
case GL_TEXTURE_COMPARE_MODE:
/* case GL_TEXTURE_COMPARE_MODE_ARB:*/
case GL_TEXTURE_COMPARE_FUNC:
/* case GL_TEXTURE_COMPARE_FUNC_ARB:*/
case GL_TEXTURE_UNSIGNED_REMAP_MODE_NV:
case GL_TEXTURE_CLIPMAP_CENTER_SGIX:
case GL_TEXTURE_CLIPMAP_OFFSET_SGIX:
case GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX:
case GL_TEXTURE_BORDER_COLOR:
case GL_POST_TEXTURE_FILTER_BIAS_SGIX:
case GL_POST_TEXTURE_FILTER_SCALE_SGIX:
break;
default:
EXPECT_EQ(0, __glTexParameterfv_size(i)) << "i = 0x" <<
std::setw(4) << std::setfill('0') << std::hex << i;
}
}
}
 
TEST(ValidEnumSizes, TexEnvfv)
{
EXPECT_EQ(1, __glTexEnvfv_size(GL_ALPHA_SCALE));
EXPECT_EQ(1, __glTexEnvfv_size(GL_TEXTURE_ENV_MODE));
EXPECT_EQ(1, __glTexEnvfv_size(GL_TEXTURE_LOD_BIAS));
EXPECT_EQ(1, __glTexEnvfv_size(GL_COMBINE_RGB));
EXPECT_EQ(1, __glTexEnvfv_size(GL_COMBINE_ALPHA));
EXPECT_EQ(1, __glTexEnvfv_size(GL_RGB_SCALE));
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE0_RGB));
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE1_RGB));
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE2_RGB));
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE3_RGB_NV));
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE0_ALPHA));
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE1_ALPHA));
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE2_ALPHA));
EXPECT_EQ(1, __glTexEnvfv_size(GL_SOURCE3_ALPHA_NV));
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND0_RGB));
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND1_RGB));
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND2_RGB));
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND3_RGB_NV));
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND0_ALPHA));
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND1_ALPHA));
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND2_ALPHA));
EXPECT_EQ(1, __glTexEnvfv_size(GL_OPERAND3_ALPHA_NV));
EXPECT_EQ(1, __glTexEnvfv_size(GL_BUMP_TARGET_ATI));
EXPECT_EQ(1, __glTexEnvfv_size(GL_COORD_REPLACE_ARB));
EXPECT_EQ(1, __glTexEnvfv_size(GL_COORD_REPLACE_NV));
EXPECT_EQ(4, __glTexEnvfv_size(GL_TEXTURE_ENV_COLOR));
}
 
TEST(InvalidEnumSizes, TexEnvfv)
{
for (unsigned i = 0; i < 0x10004; i++) {
switch (i) {
case GL_ALPHA_SCALE:
case GL_TEXTURE_ENV_MODE:
case GL_TEXTURE_LOD_BIAS:
case GL_COMBINE_RGB:
case GL_COMBINE_ALPHA:
case GL_RGB_SCALE:
case GL_SOURCE0_RGB:
case GL_SOURCE1_RGB:
case GL_SOURCE2_RGB:
case GL_SOURCE3_RGB_NV:
case GL_SOURCE0_ALPHA:
case GL_SOURCE1_ALPHA:
case GL_SOURCE2_ALPHA:
case GL_SOURCE3_ALPHA_NV:
case GL_OPERAND0_RGB:
case GL_OPERAND1_RGB:
case GL_OPERAND2_RGB:
case GL_OPERAND3_RGB_NV:
case GL_OPERAND0_ALPHA:
case GL_OPERAND1_ALPHA:
case GL_OPERAND2_ALPHA:
case GL_OPERAND3_ALPHA_NV:
case GL_BUMP_TARGET_ATI:
case GL_COORD_REPLACE_ARB:
/* case GL_COORD_REPLACE_NV:*/
case GL_TEXTURE_ENV_COLOR:
break;
default:
EXPECT_EQ(0, __glTexEnvfv_size(i)) << "i = 0x" <<
std::setw(4) << std::setfill('0') << std::hex << i;
}
}
}
 
TEST(ValidEnumSizes, TexGendv)
{
EXPECT_EQ(1, __glTexGendv_size(GL_TEXTURE_GEN_MODE));
EXPECT_EQ(4, __glTexGendv_size(GL_OBJECT_PLANE));
EXPECT_EQ(4, __glTexGendv_size(GL_EYE_PLANE));
}
 
TEST(InvalidEnumSizes, TexGendv)
{
for (unsigned i = 0; i < 0x10004; i++) {
switch (i) {
case GL_TEXTURE_GEN_MODE:
case GL_OBJECT_PLANE:
case GL_EYE_PLANE:
break;
default:
EXPECT_EQ(0, __glTexGendv_size(i)) << "i = 0x" <<
std::setw(4) << std::setfill('0') << std::hex << i;
}
}
}
 
TEST(ValidEnumSizes, Map1d)
{
EXPECT_EQ(1, __glMap1d_size(GL_MAP1_INDEX));
EXPECT_EQ(1, __glMap1d_size(GL_MAP1_TEXTURE_COORD_1));
EXPECT_EQ(2, __glMap1d_size(GL_MAP1_TEXTURE_COORD_2));
EXPECT_EQ(3, __glMap1d_size(GL_MAP1_NORMAL));
EXPECT_EQ(3, __glMap1d_size(GL_MAP1_TEXTURE_COORD_3));
EXPECT_EQ(3, __glMap1d_size(GL_MAP1_VERTEX_3));
EXPECT_EQ(4, __glMap1d_size(GL_MAP1_COLOR_4));
EXPECT_EQ(4, __glMap1d_size(GL_MAP1_TEXTURE_COORD_4));
EXPECT_EQ(4, __glMap1d_size(GL_MAP1_VERTEX_4));
}
 
TEST(InvalidEnumSizes, Map1d)
{
for (unsigned i = 0; i < 0x10004; i++) {
switch (i) {
case GL_MAP1_INDEX:
case GL_MAP1_TEXTURE_COORD_1:
case GL_MAP1_TEXTURE_COORD_2:
case GL_MAP1_NORMAL:
case GL_MAP1_TEXTURE_COORD_3:
case GL_MAP1_VERTEX_3:
case GL_MAP1_COLOR_4:
case GL_MAP1_TEXTURE_COORD_4:
case GL_MAP1_VERTEX_4:
break;
default:
EXPECT_EQ(0, __glMap1d_size(i)) << "i = 0x" <<
std::setw(4) << std::setfill('0') << std::hex << i;
}
}
}
 
TEST(ValidEnumSizes, Map2d)
{
EXPECT_EQ(1, __glMap2d_size(GL_MAP2_INDEX));
EXPECT_EQ(1, __glMap2d_size(GL_MAP2_TEXTURE_COORD_1));
EXPECT_EQ(2, __glMap2d_size(GL_MAP2_TEXTURE_COORD_2));
EXPECT_EQ(3, __glMap2d_size(GL_MAP2_NORMAL));
EXPECT_EQ(3, __glMap2d_size(GL_MAP2_TEXTURE_COORD_3));
EXPECT_EQ(3, __glMap2d_size(GL_MAP2_VERTEX_3));
EXPECT_EQ(4, __glMap2d_size(GL_MAP2_COLOR_4));
EXPECT_EQ(4, __glMap2d_size(GL_MAP2_TEXTURE_COORD_4));
EXPECT_EQ(4, __glMap2d_size(GL_MAP2_VERTEX_4));
}
 
TEST(InvalidEnumSizes, Map2d)
{
for (unsigned i = 0; i < 0x10004; i++) {
switch (i) {
case GL_MAP2_INDEX:
case GL_MAP2_TEXTURE_COORD_1:
case GL_MAP2_TEXTURE_COORD_2:
case GL_MAP2_NORMAL:
case GL_MAP2_TEXTURE_COORD_3:
case GL_MAP2_VERTEX_3:
case GL_MAP2_COLOR_4:
case GL_MAP2_TEXTURE_COORD_4:
case GL_MAP2_VERTEX_4:
break;
default:
EXPECT_EQ(0, __glMap2d_size(i)) << "i = 0x" <<
std::setw(4) << std::setfill('0') << std::hex << i;
}
}
}
 
TEST(ValidEnumSizes, ColorTableParameterfv)
{
EXPECT_EQ(4, __glColorTableParameterfv_size(GL_COLOR_TABLE_SCALE));
EXPECT_EQ(4, __glColorTableParameterfv_size(GL_COLOR_TABLE_BIAS));
}
 
TEST(InvalidEnumSizes, ColorTableParameterfv)
{
for (unsigned i = 0; i < 0x10004; i++) {
switch (i) {
case GL_COLOR_TABLE_SCALE:
case GL_COLOR_TABLE_BIAS:
break;
default:
EXPECT_EQ(0, __glColorTableParameterfv_size(i)) << "i = 0x" <<
std::setw(4) << std::setfill('0') << std::hex << i;
}
}
}
 
TEST(ValidEnumSizes, ConvolutionParameterfv)
{
EXPECT_EQ(1, __glConvolutionParameterfv_size(GL_CONVOLUTION_BORDER_MODE));
EXPECT_EQ(1, __glConvolutionParameterfv_size(GL_CONVOLUTION_BORDER_MODE_EXT));
EXPECT_EQ(4, __glConvolutionParameterfv_size(GL_CONVOLUTION_FILTER_SCALE));
EXPECT_EQ(4, __glConvolutionParameterfv_size(GL_CONVOLUTION_FILTER_SCALE_EXT));
EXPECT_EQ(4, __glConvolutionParameterfv_size(GL_CONVOLUTION_FILTER_BIAS));
EXPECT_EQ(4, __glConvolutionParameterfv_size(GL_CONVOLUTION_FILTER_BIAS_EXT));
EXPECT_EQ(4, __glConvolutionParameterfv_size(GL_CONVOLUTION_BORDER_COLOR));
EXPECT_EQ(4, __glConvolutionParameterfv_size(GL_CONVOLUTION_BORDER_COLOR_HP));
}
 
TEST(InvalidEnumSizes, ConvolutionParameterfv)
{
for (unsigned i = 0; i < 0x10004; i++) {
switch (i) {
case GL_CONVOLUTION_BORDER_MODE:
/* case GL_CONVOLUTION_BORDER_MODE_EXT:*/
case GL_CONVOLUTION_FILTER_SCALE:
/* case GL_CONVOLUTION_FILTER_SCALE_EXT:*/
case GL_CONVOLUTION_FILTER_BIAS:
/* case GL_CONVOLUTION_FILTER_BIAS_EXT:*/
case GL_CONVOLUTION_BORDER_COLOR:
/* case GL_CONVOLUTION_BORDER_COLOR_HP:*/
break;
default:
EXPECT_EQ(0, __glConvolutionParameterfv_size(i)) << "i = 0x" <<
std::setw(4) << std::setfill('0') << std::hex << i;
}
}
}
 
TEST(ValidEnumSizes, PointParameterfv)
{
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SIZE_MIN));
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SIZE_MIN_ARB));
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SIZE_MIN_SGIS));
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SIZE_MAX));
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SIZE_MAX_ARB));
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SIZE_MAX_SGIS));
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_FADE_THRESHOLD_SIZE));
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_FADE_THRESHOLD_SIZE_ARB));
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_FADE_THRESHOLD_SIZE_SGIS));
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SPRITE_R_MODE_NV));
EXPECT_EQ(1, __glPointParameterfv_size(GL_POINT_SPRITE_COORD_ORIGIN));
EXPECT_EQ(3, __glPointParameterfv_size(GL_POINT_DISTANCE_ATTENUATION));
EXPECT_EQ(3, __glPointParameterfv_size(GL_POINT_DISTANCE_ATTENUATION_ARB));
}
 
TEST(InvalidEnumSizes, PointParameterfv)
{
for (unsigned i = 0; i < 0x10004; i++) {
switch (i) {
case GL_POINT_SIZE_MIN:
/* case GL_POINT_SIZE_MIN_ARB:*/
/* case GL_POINT_SIZE_MIN_SGIS:*/
case GL_POINT_SIZE_MAX:
/* case GL_POINT_SIZE_MAX_ARB:*/
/* case GL_POINT_SIZE_MAX_SGIS:*/
case GL_POINT_FADE_THRESHOLD_SIZE:
/* case GL_POINT_FADE_THRESHOLD_SIZE_ARB:*/
/* case GL_POINT_FADE_THRESHOLD_SIZE_SGIS:*/
case GL_POINT_SPRITE_R_MODE_NV:
case GL_POINT_SPRITE_COORD_ORIGIN:
case GL_POINT_DISTANCE_ATTENUATION:
/* case GL_POINT_DISTANCE_ATTENUATION_ARB:*/
break;
default:
EXPECT_EQ(0, __glPointParameterfv_size(i)) << "i = 0x" <<
std::setw(4) << std::setfill('0') << std::hex << i;
}
}
}
/contrib/sdk/sources/Mesa/src/glx/tests/fake_glx_screen.cpp
0,0 → 1,72
/*
* Copyright © 2011 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include "fake_glx_screen.h"
 
struct glx_screen_vtable fake_glx_screen::vt = {
indirect_create_context,
indirect_create_context_attribs
};
 
struct glx_screen_vtable fake_glx_screen_direct::vt = {
fake_glx_context_direct::create,
fake_glx_context_direct::create_attribs
};
 
const struct glx_context_vtable fake_glx_context::vt = {
fake_glx_context::destroy,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
};
 
int fake_glx_context::contexts_allocated = 0;
 
extern "C" struct glx_context *
indirect_create_context(struct glx_screen *psc, struct glx_config *mode,
struct glx_context *shareList, int renderType)
{
(void) shareList;
(void) renderType;
 
return new fake_glx_context(psc, mode);
}
 
extern "C" struct glx_context *
indirect_create_context_attribs(struct glx_screen *base,
struct glx_config *config_base,
struct glx_context *shareList,
unsigned num_attribs,
const uint32_t *attribs,
unsigned *error)
{
(void) num_attribs;
(void) attribs;
(void) error;
 
return indirect_create_context(base, config_base, shareList, 0);
}
/contrib/sdk/sources/Mesa/src/glx/tests/fake_glx_screen.h
0,0 → 1,134
/*
* Copyright © 2011 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
extern "C" {
#include "glxclient.h"
};
 
class fake_glx_screen : public glx_screen {
public:
fake_glx_screen(struct glx_display *glx_dpy, int num, const char *ext)
{
this->vtable = &fake_glx_screen::vt;
this->serverGLXexts = 0;
this->effectiveGLXexts = 0;
this->display = 0;
this->dpy = 0;
this->scr = num;
this->visuals = 0;
this->configs = 0;
 
this->display = glx_dpy;
this->dpy = (glx_dpy != NULL) ? glx_dpy->dpy : NULL;
 
this->serverGLXexts = new char[strlen(ext) + 1];
strcpy((char *) this->serverGLXexts, ext);
}
 
~fake_glx_screen()
{
delete [] this->serverGLXexts;
}
 
private:
static struct glx_screen_vtable vt;
};
 
class fake_glx_screen_direct : public fake_glx_screen {
public:
fake_glx_screen_direct(struct glx_display *glx_dpy, int num,
const char *ext)
: fake_glx_screen(glx_dpy, num, ext)
{
this->vtable = &fake_glx_screen_direct::vt;
}
 
private:
static struct glx_screen_vtable vt;
};
 
class fake_glx_context : public glx_context {
public:
fake_glx_context(struct glx_screen *psc, struct glx_config *mode)
{
contexts_allocated++;
 
this->vtable = &fake_glx_context::vt;
this->majorOpcode = 123;
this->screen = psc->scr;
this->psc = psc;
this->config = mode;
this->isDirect = false;
this->currentContextTag = -1;
 
this->client_state_private = (struct __GLXattributeRec *) 0xcafebabe;
}
 
~fake_glx_context()
{
contexts_allocated--;
}
 
/** Number of context that are allocated (and not freed). */
static int contexts_allocated;
 
private:
static const struct glx_context_vtable vt;
 
static void destroy(struct glx_context *gc)
{
delete gc;
}
};
 
class fake_glx_context_direct : public fake_glx_context {
public:
fake_glx_context_direct(struct glx_screen *psc, struct glx_config *mode)
: fake_glx_context(psc, mode)
{
this->isDirect = True;
}
 
static glx_context *create(struct glx_screen *psc, struct glx_config *mode,
struct glx_context *shareList, int renderType)
{
(void) shareList;
(void) renderType;
 
return new fake_glx_context_direct(psc, mode);
}
 
static glx_context *create_attribs(struct glx_screen *psc,
struct glx_config *mode,
struct glx_context *shareList,
unsigned num_attribs,
const uint32_t *attribs,
unsigned *error)
{
(void) shareList;
(void) num_attribs;
(void) attribs;
 
*error = 0;
return new fake_glx_context_direct(psc, mode);
}
};
/contrib/sdk/sources/Mesa/src/glx/tests/indirect_api.cpp
0,0 → 1,1522
/*
* Copyright © 2012 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
 
/**
* \file indirect_api.cpp
* Validate the generated code in indirect_init.c
*
* Tests various apsects of the dispatch table generated by
* \c __glXNewIndirectAPI.
*
* * No entry in the table should be \c NULL.
*
* * Entries in the table that correspond to "known" functions with GLX
* protocol should point to the correct function.
*
* * Entries beyond the end of the "known" part of the table (i.e., entries
* that can be allocated by drivers for extensions) should point to a
* no-op function.
*
* * Entries in the table that correspond to "known" functions that lack
* GLX protocol should point to a no-op function.
*
* Very few entries in the last catogory are tests. See \c OpenGL_20_is_nop.
*/
 
#include <gtest/gtest.h>
#include "main/glheader.h"
extern "C" {
#include "../indirect_init.h"
#include "glapi/glapi.h"
#include "../../mesa/main/dispatch.h"
}
 
static const void *nil = 0;
 
#define EXTRA_DISPATCH 111
 
static bool dispatch_table_size_was_queried = false;
 
extern "C" GLuint
_glapi_get_dispatch_table_size(void)
{
dispatch_table_size_was_queried = true;
return _gloffset_COUNT + EXTRA_DISPATCH;
}
 
/**
* \name Indirect-rendering function stubs
*
* These are necessary so that indirect_init.c doesn't try to link with
* indirect.c. Linking with indirect.c would require linking with various X
* libraries and a bunch of other stuff. While this is ugly, it does simplify
* the build quite a bit.
*/
/*@{*/
extern "C" {
void __indirect_glAccum(void) { }
void __indirect_glAlphaFunc(void) { }
void __indirect_glBegin(void) { }
void __indirect_glBitmap(void) { }
void __indirect_glBlendFunc(void) { }
void __indirect_glCallList(void) { }
void __indirect_glCallLists(void) { }
void __indirect_glClear(void) { }
void __indirect_glClearAccum(void) { }
void __indirect_glClearColor(void) { }
void __indirect_glClearDepth(void) { }
void __indirect_glClearIndex(void) { }
void __indirect_glClearStencil(void) { }
void __indirect_glClipPlane(void) { }
void __indirect_glColor3b(void) { }
void __indirect_glColor3bv(void) { }
void __indirect_glColor3d(void) { }
void __indirect_glColor3dv(void) { }
void __indirect_glColor3f(void) { }
void __indirect_glColor3fv(void) { }
void __indirect_glColor3i(void) { }
void __indirect_glColor3iv(void) { }
void __indirect_glColor3s(void) { }
void __indirect_glColor3sv(void) { }
void __indirect_glColor3ub(void) { }
void __indirect_glColor3ubv(void) { }
void __indirect_glColor3ui(void) { }
void __indirect_glColor3uiv(void) { }
void __indirect_glColor3us(void) { }
void __indirect_glColor3usv(void) { }
void __indirect_glColor4b(void) { }
void __indirect_glColor4bv(void) { }
void __indirect_glColor4d(void) { }
void __indirect_glColor4dv(void) { }
void __indirect_glColor4f(void) { }
void __indirect_glColor4fv(void) { }
void __indirect_glColor4i(void) { }
void __indirect_glColor4iv(void) { }
void __indirect_glColor4s(void) { }
void __indirect_glColor4sv(void) { }
void __indirect_glColor4ub(void) { }
void __indirect_glColor4ubv(void) { }
void __indirect_glColor4ui(void) { }
void __indirect_glColor4uiv(void) { }
void __indirect_glColor4us(void) { }
void __indirect_glColor4usv(void) { }
void __indirect_glColorMask(void) { }
void __indirect_glColorMaterial(void) { }
void __indirect_glCopyPixels(void) { }
void __indirect_glCullFace(void) { }
void __indirect_glDeleteLists(void) { }
void __indirect_glDepthFunc(void) { }
void __indirect_glDepthMask(void) { }
void __indirect_glDepthRange(void) { }
void __indirect_glDisable(void) { }
void __indirect_glDrawBuffer(void) { }
void __indirect_glDrawPixels(void) { }
void __indirect_glEdgeFlag(void) { }
void __indirect_glEdgeFlagv(void) { }
void __indirect_glEnable(void) { }
void __indirect_glEnd(void) { }
void __indirect_glEndList(void) { }
void __indirect_glEvalCoord1d(void) { }
void __indirect_glEvalCoord1dv(void) { }
void __indirect_glEvalCoord1f(void) { }
void __indirect_glEvalCoord1fv(void) { }
void __indirect_glEvalCoord2d(void) { }
void __indirect_glEvalCoord2dv(void) { }
void __indirect_glEvalCoord2f(void) { }
void __indirect_glEvalCoord2fv(void) { }
void __indirect_glEvalMesh1(void) { }
void __indirect_glEvalMesh2(void) { }
void __indirect_glEvalPoint1(void) { }
void __indirect_glEvalPoint2(void) { }
void __indirect_glFeedbackBuffer(void) { }
void __indirect_glFinish(void) { }
void __indirect_glFlush(void) { }
void __indirect_glFogf(void) { }
void __indirect_glFogfv(void) { }
void __indirect_glFogi(void) { }
void __indirect_glFogiv(void) { }
void __indirect_glFrontFace(void) { }
void __indirect_glFrustum(void) { }
void __indirect_glGenLists(void) { }
void __indirect_glGetBooleanv(void) { }
void __indirect_glGetClipPlane(void) { }
void __indirect_glGetDoublev(void) { }
void __indirect_glGetError(void) { }
void __indirect_glGetFloatv(void) { }
void __indirect_glGetIntegerv(void) { }
void __indirect_glGetLightfv(void) { }
void __indirect_glGetLightiv(void) { }
void __indirect_glGetMapdv(void) { }
void __indirect_glGetMapfv(void) { }
void __indirect_glGetMapiv(void) { }
void __indirect_glGetMaterialfv(void) { }
void __indirect_glGetMaterialiv(void) { }
void __indirect_glGetPixelMapfv(void) { }
void __indirect_glGetPixelMapuiv(void) { }
void __indirect_glGetPixelMapusv(void) { }
void __indirect_glGetPolygonStipple(void) { }
void __indirect_glGetString(void) { }
void __indirect_glGetTexEnvfv(void) { }
void __indirect_glGetTexEnviv(void) { }
void __indirect_glGetTexGendv(void) { }
void __indirect_glGetTexGenfv(void) { }
void __indirect_glGetTexGeniv(void) { }
void __indirect_glGetTexImage(void) { }
void __indirect_glGetTexLevelParameterfv(void) { }
void __indirect_glGetTexLevelParameteriv(void) { }
void __indirect_glGetTexParameterfv(void) { }
void __indirect_glGetTexParameteriv(void) { }
void __indirect_glHint(void) { }
void __indirect_glIndexMask(void) { }
void __indirect_glIndexd(void) { }
void __indirect_glIndexdv(void) { }
void __indirect_glIndexf(void) { }
void __indirect_glIndexfv(void) { }
void __indirect_glIndexi(void) { }
void __indirect_glIndexiv(void) { }
void __indirect_glIndexs(void) { }
void __indirect_glIndexsv(void) { }
void __indirect_glInitNames(void) { }
void __indirect_glIsEnabled(void) { }
void __indirect_glIsList(void) { }
void __indirect_glLightModelf(void) { }
void __indirect_glLightModelfv(void) { }
void __indirect_glLightModeli(void) { }
void __indirect_glLightModeliv(void) { }
void __indirect_glLightf(void) { }
void __indirect_glLightfv(void) { }
void __indirect_glLighti(void) { }
void __indirect_glLightiv(void) { }
void __indirect_glLineStipple(void) { }
void __indirect_glLineWidth(void) { }
void __indirect_glListBase(void) { }
void __indirect_glLoadIdentity(void) { }
void __indirect_glLoadMatrixd(void) { }
void __indirect_glLoadMatrixf(void) { }
void __indirect_glLoadName(void) { }
void __indirect_glLogicOp(void) { }
void __indirect_glMap1d(void) { }
void __indirect_glMap1f(void) { }
void __indirect_glMap2d(void) { }
void __indirect_glMap2f(void) { }
void __indirect_glMapGrid1d(void) { }
void __indirect_glMapGrid1f(void) { }
void __indirect_glMapGrid2d(void) { }
void __indirect_glMapGrid2f(void) { }
void __indirect_glMaterialf(void) { }
void __indirect_glMaterialfv(void) { }
void __indirect_glMateriali(void) { }
void __indirect_glMaterialiv(void) { }
void __indirect_glMatrixMode(void) { }
void __indirect_glMultMatrixd(void) { }
void __indirect_glMultMatrixf(void) { }
void __indirect_glNewList(void) { }
void __indirect_glNormal3b(void) { }
void __indirect_glNormal3bv(void) { }
void __indirect_glNormal3d(void) { }
void __indirect_glNormal3dv(void) { }
void __indirect_glNormal3f(void) { }
void __indirect_glNormal3fv(void) { }
void __indirect_glNormal3i(void) { }
void __indirect_glNormal3iv(void) { }
void __indirect_glNormal3s(void) { }
void __indirect_glNormal3sv(void) { }
void __indirect_glOrtho(void) { }
void __indirect_glPassThrough(void) { }
void __indirect_glPixelMapfv(void) { }
void __indirect_glPixelMapuiv(void) { }
void __indirect_glPixelMapusv(void) { }
void __indirect_glPixelStoref(void) { }
void __indirect_glPixelStorei(void) { }
void __indirect_glPixelTransferf(void) { }
void __indirect_glPixelTransferi(void) { }
void __indirect_glPixelZoom(void) { }
void __indirect_glPointSize(void) { }
void __indirect_glPolygonMode(void) { }
void __indirect_glPolygonStipple(void) { }
void __indirect_glPopAttrib(void) { }
void __indirect_glPopMatrix(void) { }
void __indirect_glPopName(void) { }
void __indirect_glPushAttrib(void) { }
void __indirect_glPushMatrix(void) { }
void __indirect_glPushName(void) { }
void __indirect_glRasterPos2d(void) { }
void __indirect_glRasterPos2dv(void) { }
void __indirect_glRasterPos2f(void) { }
void __indirect_glRasterPos2fv(void) { }
void __indirect_glRasterPos2i(void) { }
void __indirect_glRasterPos2iv(void) { }
void __indirect_glRasterPos2s(void) { }
void __indirect_glRasterPos2sv(void) { }
void __indirect_glRasterPos3d(void) { }
void __indirect_glRasterPos3dv(void) { }
void __indirect_glRasterPos3f(void) { }
void __indirect_glRasterPos3fv(void) { }
void __indirect_glRasterPos3i(void) { }
void __indirect_glRasterPos3iv(void) { }
void __indirect_glRasterPos3s(void) { }
void __indirect_glRasterPos3sv(void) { }
void __indirect_glRasterPos4d(void) { }
void __indirect_glRasterPos4dv(void) { }
void __indirect_glRasterPos4f(void) { }
void __indirect_glRasterPos4fv(void) { }
void __indirect_glRasterPos4i(void) { }
void __indirect_glRasterPos4iv(void) { }
void __indirect_glRasterPos4s(void) { }
void __indirect_glRasterPos4sv(void) { }
void __indirect_glReadBuffer(void) { }
void __indirect_glReadPixels(void) { }
void __indirect_glRectd(void) { }
void __indirect_glRectdv(void) { }
void __indirect_glRectf(void) { }
void __indirect_glRectfv(void) { }
void __indirect_glRecti(void) { }
void __indirect_glRectiv(void) { }
void __indirect_glRects(void) { }
void __indirect_glRectsv(void) { }
void __indirect_glRenderMode(void) { }
void __indirect_glRotated(void) { }
void __indirect_glRotatef(void) { }
void __indirect_glScaled(void) { }
void __indirect_glScalef(void) { }
void __indirect_glScissor(void) { }
void __indirect_glSelectBuffer(void) { }
void __indirect_glShadeModel(void) { }
void __indirect_glStencilFunc(void) { }
void __indirect_glStencilMask(void) { }
void __indirect_glStencilOp(void) { }
void __indirect_glTexCoord1d(void) { }
void __indirect_glTexCoord1dv(void) { }
void __indirect_glTexCoord1f(void) { }
void __indirect_glTexCoord1fv(void) { }
void __indirect_glTexCoord1i(void) { }
void __indirect_glTexCoord1iv(void) { }
void __indirect_glTexCoord1s(void) { }
void __indirect_glTexCoord1sv(void) { }
void __indirect_glTexCoord2d(void) { }
void __indirect_glTexCoord2dv(void) { }
void __indirect_glTexCoord2f(void) { }
void __indirect_glTexCoord2fv(void) { }
void __indirect_glTexCoord2i(void) { }
void __indirect_glTexCoord2iv(void) { }
void __indirect_glTexCoord2s(void) { }
void __indirect_glTexCoord2sv(void) { }
void __indirect_glTexCoord3d(void) { }
void __indirect_glTexCoord3dv(void) { }
void __indirect_glTexCoord3f(void) { }
void __indirect_glTexCoord3fv(void) { }
void __indirect_glTexCoord3i(void) { }
void __indirect_glTexCoord3iv(void) { }
void __indirect_glTexCoord3s(void) { }
void __indirect_glTexCoord3sv(void) { }
void __indirect_glTexCoord4d(void) { }
void __indirect_glTexCoord4dv(void) { }
void __indirect_glTexCoord4f(void) { }
void __indirect_glTexCoord4fv(void) { }
void __indirect_glTexCoord4i(void) { }
void __indirect_glTexCoord4iv(void) { }
void __indirect_glTexCoord4s(void) { }
void __indirect_glTexCoord4sv(void) { }
void __indirect_glTexEnvf(void) { }
void __indirect_glTexEnvfv(void) { }
void __indirect_glTexEnvi(void) { }
void __indirect_glTexEnviv(void) { }
void __indirect_glTexGend(void) { }
void __indirect_glTexGendv(void) { }
void __indirect_glTexGenf(void) { }
void __indirect_glTexGenfv(void) { }
void __indirect_glTexGeni(void) { }
void __indirect_glTexGeniv(void) { }
void __indirect_glTexImage1D(void) { }
void __indirect_glTexImage2D(void) { }
void __indirect_glTexParameterf(void) { }
void __indirect_glTexParameterfv(void) { }
void __indirect_glTexParameteri(void) { }
void __indirect_glTexParameteriv(void) { }
void __indirect_glTranslated(void) { }
void __indirect_glTranslatef(void) { }
void __indirect_glVertex2d(void) { }
void __indirect_glVertex2dv(void) { }
void __indirect_glVertex2f(void) { }
void __indirect_glVertex2fv(void) { }
void __indirect_glVertex2i(void) { }
void __indirect_glVertex2iv(void) { }
void __indirect_glVertex2s(void) { }
void __indirect_glVertex2sv(void) { }
void __indirect_glVertex3d(void) { }
void __indirect_glVertex3dv(void) { }
void __indirect_glVertex3f(void) { }
void __indirect_glVertex3fv(void) { }
void __indirect_glVertex3i(void) { }
void __indirect_glVertex3iv(void) { }
void __indirect_glVertex3s(void) { }
void __indirect_glVertex3sv(void) { }
void __indirect_glVertex4d(void) { }
void __indirect_glVertex4dv(void) { }
void __indirect_glVertex4f(void) { }
void __indirect_glVertex4fv(void) { }
void __indirect_glVertex4i(void) { }
void __indirect_glVertex4iv(void) { }
void __indirect_glVertex4s(void) { }
void __indirect_glVertex4sv(void) { }
void __indirect_glViewport(void) { }
void __indirect_glAreTexturesResident(void) { }
void __indirect_glArrayElement(void) { }
void __indirect_glBindTexture(void) { }
void __indirect_glColorPointer(void) { }
void __indirect_glCopyTexImage1D(void) { }
void __indirect_glCopyTexImage2D(void) { }
void __indirect_glCopyTexSubImage1D(void) { }
void __indirect_glCopyTexSubImage2D(void) { }
void __indirect_glDeleteTextures(void) { }
void __indirect_glDisableClientState(void) { }
void __indirect_glDrawArrays(void) { }
void __indirect_glDrawElements(void) { }
void __indirect_glEdgeFlagPointer(void) { }
void __indirect_glEnableClientState(void) { }
void __indirect_glGenTextures(void) { }
void __indirect_glGetPointerv(void) { }
void __indirect_glIndexPointer(void) { }
void __indirect_glIndexub(void) { }
void __indirect_glIndexubv(void) { }
void __indirect_glInterleavedArrays(void) { }
void __indirect_glIsTexture(void) { }
void __indirect_glNormalPointer(void) { }
void __indirect_glPolygonOffset(void) { }
void __indirect_glPopClientAttrib(void) { }
void __indirect_glPrioritizeTextures(void) { }
void __indirect_glPushClientAttrib(void) { }
void __indirect_glTexCoordPointer(void) { }
void __indirect_glTexSubImage1D(void) { }
void __indirect_glTexSubImage2D(void) { }
void __indirect_glVertexPointer(void) { }
void __indirect_glBlendColor(void) { }
void __indirect_glBlendEquation(void) { }
void __indirect_glColorSubTable(void) { }
void __indirect_glColorTable(void) { }
void __indirect_glColorTableParameterfv(void) { }
void __indirect_glColorTableParameteriv(void) { }
void __indirect_glConvolutionFilter1D(void) { }
void __indirect_glConvolutionFilter2D(void) { }
void __indirect_glConvolutionParameterf(void) { }
void __indirect_glConvolutionParameterfv(void) { }
void __indirect_glConvolutionParameteri(void) { }
void __indirect_glConvolutionParameteriv(void) { }
void __indirect_glCopyColorSubTable(void) { }
void __indirect_glCopyColorTable(void) { }
void __indirect_glCopyConvolutionFilter1D(void) { }
void __indirect_glCopyConvolutionFilter2D(void) { }
void __indirect_glCopyTexSubImage3D(void) { }
void __indirect_glDrawRangeElements(void) { }
void __indirect_glGetColorTable(void) { }
void __indirect_glGetColorTableParameterfv(void) { }
void __indirect_glGetColorTableParameteriv(void) { }
void __indirect_glGetConvolutionFilter(void) { }
void __indirect_glGetConvolutionParameterfv(void) { }
void __indirect_glGetConvolutionParameteriv(void) { }
void __indirect_glGetHistogram(void) { }
void __indirect_glGetHistogramParameterfv(void) { }
void __indirect_glGetHistogramParameteriv(void) { }
void __indirect_glGetMinmax(void) { }
void __indirect_glGetMinmaxParameterfv(void) { }
void __indirect_glGetMinmaxParameteriv(void) { }
void __indirect_glGetSeparableFilter(void) { }
void __indirect_glHistogram(void) { }
void __indirect_glMinmax(void) { }
void __indirect_glResetHistogram(void) { }
void __indirect_glResetMinmax(void) { }
void __indirect_glSeparableFilter2D(void) { }
void __indirect_glTexImage3D(void) { }
void __indirect_glTexSubImage3D(void) { }
void __indirect_glActiveTexture(void) { }
void __indirect_glClientActiveTexture(void) { }
void __indirect_glMultiTexCoord1d(void) { }
void __indirect_glMultiTexCoord1dv(void) { }
void __indirect_glMultiTexCoord1fARB(void) { }
void __indirect_glMultiTexCoord1fvARB(void) { }
void __indirect_glMultiTexCoord1i(void) { }
void __indirect_glMultiTexCoord1iv(void) { }
void __indirect_glMultiTexCoord1s(void) { }
void __indirect_glMultiTexCoord1sv(void) { }
void __indirect_glMultiTexCoord2d(void) { }
void __indirect_glMultiTexCoord2dv(void) { }
void __indirect_glMultiTexCoord2fARB(void) { }
void __indirect_glMultiTexCoord2fvARB(void) { }
void __indirect_glMultiTexCoord2i(void) { }
void __indirect_glMultiTexCoord2iv(void) { }
void __indirect_glMultiTexCoord2s(void) { }
void __indirect_glMultiTexCoord2sv(void) { }
void __indirect_glMultiTexCoord3d(void) { }
void __indirect_glMultiTexCoord3dv(void) { }
void __indirect_glMultiTexCoord3fARB(void) { }
void __indirect_glMultiTexCoord3fvARB(void) { }
void __indirect_glMultiTexCoord3i(void) { }
void __indirect_glMultiTexCoord3iv(void) { }
void __indirect_glMultiTexCoord3s(void) { }
void __indirect_glMultiTexCoord3sv(void) { }
void __indirect_glMultiTexCoord4d(void) { }
void __indirect_glMultiTexCoord4dv(void) { }
void __indirect_glMultiTexCoord4fARB(void) { }
void __indirect_glMultiTexCoord4fvARB(void) { }
void __indirect_glMultiTexCoord4i(void) { }
void __indirect_glMultiTexCoord4iv(void) { }
void __indirect_glMultiTexCoord4s(void) { }
void __indirect_glMultiTexCoord4sv(void) { }
void __indirect_glLoadTransposeMatrixd(void) { }
void __indirect_glLoadTransposeMatrixf(void) { }
void __indirect_glMultTransposeMatrixd(void) { }
void __indirect_glMultTransposeMatrixf(void) { }
void __indirect_glSampleCoverage(void) { }
void __indirect_glCompressedTexImage1D(void) { }
void __indirect_glCompressedTexImage2D(void) { }
void __indirect_glCompressedTexImage3D(void) { }
void __indirect_glCompressedTexSubImage1D(void) { }
void __indirect_glCompressedTexSubImage2D(void) { }
void __indirect_glCompressedTexSubImage3D(void) { }
void __indirect_glGetCompressedTexImage(void) { }
void __indirect_glDisableVertexAttribArray(void) { }
void __indirect_glEnableVertexAttribArray(void) { }
void __indirect_glGetProgramEnvParameterdvARB(void) { }
void __indirect_glGetProgramEnvParameterfvARB(void) { }
void __indirect_glGetProgramLocalParameterdvARB(void) { }
void __indirect_glGetProgramLocalParameterfvARB(void) { }
void __indirect_glGetProgramStringARB(void) { }
void __indirect_glGetProgramivARB(void) { }
void __indirect_glGetVertexAttribdv(void) { }
void __indirect_glGetVertexAttribfv(void) { }
void __indirect_glGetVertexAttribiv(void) { }
void __indirect_glProgramEnvParameter4dARB(void) { }
void __indirect_glProgramEnvParameter4dvARB(void) { }
void __indirect_glProgramEnvParameter4fARB(void) { }
void __indirect_glProgramEnvParameter4fvARB(void) { }
void __indirect_glProgramLocalParameter4dARB(void) { }
void __indirect_glProgramLocalParameter4dvARB(void) { }
void __indirect_glProgramLocalParameter4fARB(void) { }
void __indirect_glProgramLocalParameter4fvARB(void) { }
void __indirect_glProgramStringARB(void) { }
void __indirect_glVertexAttrib1d(void) { }
void __indirect_glVertexAttrib1dv(void) { }
void __indirect_glVertexAttrib1fARB(void) { }
void __indirect_glVertexAttrib1fvARB(void) { }
void __indirect_glVertexAttrib1s(void) { }
void __indirect_glVertexAttrib1sv(void) { }
void __indirect_glVertexAttrib2d(void) { }
void __indirect_glVertexAttrib2dv(void) { }
void __indirect_glVertexAttrib2fARB(void) { }
void __indirect_glVertexAttrib2fvARB(void) { }
void __indirect_glVertexAttrib2s(void) { }
void __indirect_glVertexAttrib2sv(void) { }
void __indirect_glVertexAttrib3d(void) { }
void __indirect_glVertexAttrib3dv(void) { }
void __indirect_glVertexAttrib3fARB(void) { }
void __indirect_glVertexAttrib3fvARB(void) { }
void __indirect_glVertexAttrib3s(void) { }
void __indirect_glVertexAttrib3sv(void) { }
void __indirect_glVertexAttrib4Nbv(void) { }
void __indirect_glVertexAttrib4Niv(void) { }
void __indirect_glVertexAttrib4Nsv(void) { }
void __indirect_glVertexAttrib4Nub(void) { }
void __indirect_glVertexAttrib4Nubv(void) { }
void __indirect_glVertexAttrib4Nuiv(void) { }
void __indirect_glVertexAttrib4Nusv(void) { }
void __indirect_glVertexAttrib4bv(void) { }
void __indirect_glVertexAttrib4d(void) { }
void __indirect_glVertexAttrib4dv(void) { }
void __indirect_glVertexAttrib4fARB(void) { }
void __indirect_glVertexAttrib4fvARB(void) { }
void __indirect_glVertexAttrib4iv(void) { }
void __indirect_glVertexAttrib4s(void) { }
void __indirect_glVertexAttrib4sv(void) { }
void __indirect_glVertexAttrib4ubv(void) { }
void __indirect_glVertexAttrib4uiv(void) { }
void __indirect_glVertexAttrib4usv(void) { }
void __indirect_glVertexAttribPointer(void) { }
void __indirect_glBeginQuery(void) { }
void __indirect_glDeleteQueries(void) { }
void __indirect_glEndQuery(void) { }
void __indirect_glGenQueries(void) { }
void __indirect_glGetQueryObjectiv(void) { }
void __indirect_glGetQueryObjectuiv(void) { }
void __indirect_glGetQueryiv(void) { }
void __indirect_glIsQuery(void) { }
void __indirect_glDrawBuffers(void) { }
void __indirect_glClampColor(void) { }
void __indirect_glRenderbufferStorageMultisample(void) { }
void __indirect_glSampleMaskSGIS(void) { }
void __indirect_glSamplePatternSGIS(void) { }
void __indirect_glColorPointerEXT(void) { }
void __indirect_glEdgeFlagPointerEXT(void) { }
void __indirect_glIndexPointerEXT(void) { }
void __indirect_glNormalPointerEXT(void) { }
void __indirect_glTexCoordPointerEXT(void) { }
void __indirect_glVertexPointerEXT(void) { }
void __indirect_glPointParameterf(void) { }
void __indirect_glPointParameterfv(void) { }
void __indirect_glSecondaryColor3b(void) { }
void __indirect_glSecondaryColor3bv(void) { }
void __indirect_glSecondaryColor3d(void) { }
void __indirect_glSecondaryColor3dv(void) { }
void __indirect_glSecondaryColor3fEXT(void) { }
void __indirect_glSecondaryColor3fvEXT(void) { }
void __indirect_glSecondaryColor3i(void) { }
void __indirect_glSecondaryColor3iv(void) { }
void __indirect_glSecondaryColor3s(void) { }
void __indirect_glSecondaryColor3sv(void) { }
void __indirect_glSecondaryColor3ub(void) { }
void __indirect_glSecondaryColor3ubv(void) { }
void __indirect_glSecondaryColor3ui(void) { }
void __indirect_glSecondaryColor3uiv(void) { }
void __indirect_glSecondaryColor3us(void) { }
void __indirect_glSecondaryColor3usv(void) { }
void __indirect_glSecondaryColorPointer(void) { }
void __indirect_glMultiDrawArrays(void) { }
void __indirect_glMultiDrawElementsEXT(void) { }
void __indirect_glFogCoordPointer(void) { }
void __indirect_glFogCoordd(void) { }
void __indirect_glFogCoorddv(void) { }
void __indirect_glFogCoordfEXT(void) { }
void __indirect_glFogCoordfvEXT(void) { }
void __indirect_glBlendFuncSeparate(void) { }
void __indirect_glWindowPos2d(void) { }
void __indirect_glWindowPos2dv(void) { }
void __indirect_glWindowPos2f(void) { }
void __indirect_glWindowPos2fv(void) { }
void __indirect_glWindowPos2i(void) { }
void __indirect_glWindowPos2iv(void) { }
void __indirect_glWindowPos2s(void) { }
void __indirect_glWindowPos2sv(void) { }
void __indirect_glWindowPos3d(void) { }
void __indirect_glWindowPos3dv(void) { }
void __indirect_glWindowPos3f(void) { }
void __indirect_glWindowPos3fv(void) { }
void __indirect_glWindowPos3i(void) { }
void __indirect_glWindowPos3iv(void) { }
void __indirect_glWindowPos3s(void) { }
void __indirect_glWindowPos3sv(void) { }
void __indirect_glAreProgramsResidentNV(void) { }
void __indirect_glBindProgramARB(void) { }
void __indirect_glDeleteProgramsARB(void) { }
void __indirect_glExecuteProgramNV(void) { }
void __indirect_glGenProgramsARB(void) { }
void __indirect_glGetProgramParameterdvNV(void) { }
void __indirect_glGetProgramParameterfvNV(void) { }
void __indirect_glGetProgramStringNV(void) { }
void __indirect_glGetProgramivNV(void) { }
void __indirect_glGetTrackMatrixivNV(void) { }
void __indirect_glGetVertexAttribPointerv(void) { }
void __indirect_glGetVertexAttribdvNV(void) { }
void __indirect_glGetVertexAttribfvNV(void) { }
void __indirect_glGetVertexAttribivNV(void) { }
void __indirect_glIsProgramARB(void) { }
void __indirect_glLoadProgramNV(void) { }
void __indirect_glProgramParameters4dvNV(void) { }
void __indirect_glProgramParameters4fvNV(void) { }
void __indirect_glRequestResidentProgramsNV(void) { }
void __indirect_glTrackMatrixNV(void) { }
void __indirect_glVertexAttrib1dNV(void) { }
void __indirect_glVertexAttrib1dvNV(void) { }
void __indirect_glVertexAttrib1fNV(void) { }
void __indirect_glVertexAttrib1fvNV(void) { }
void __indirect_glVertexAttrib1sNV(void) { }
void __indirect_glVertexAttrib1svNV(void) { }
void __indirect_glVertexAttrib2dNV(void) { }
void __indirect_glVertexAttrib2dvNV(void) { }
void __indirect_glVertexAttrib2fNV(void) { }
void __indirect_glVertexAttrib2fvNV(void) { }
void __indirect_glVertexAttrib2sNV(void) { }
void __indirect_glVertexAttrib2svNV(void) { }
void __indirect_glVertexAttrib3dNV(void) { }
void __indirect_glVertexAttrib3dvNV(void) { }
void __indirect_glVertexAttrib3fNV(void) { }
void __indirect_glVertexAttrib3fvNV(void) { }
void __indirect_glVertexAttrib3sNV(void) { }
void __indirect_glVertexAttrib3svNV(void) { }
void __indirect_glVertexAttrib4dNV(void) { }
void __indirect_glVertexAttrib4dvNV(void) { }
void __indirect_glVertexAttrib4fNV(void) { }
void __indirect_glVertexAttrib4fvNV(void) { }
void __indirect_glVertexAttrib4sNV(void) { }
void __indirect_glVertexAttrib4svNV(void) { }
void __indirect_glVertexAttrib4ubNV(void) { }
void __indirect_glVertexAttrib4ubvNV(void) { }
void __indirect_glVertexAttribPointerNV(void) { }
void __indirect_glVertexAttribs1dvNV(void) { }
void __indirect_glVertexAttribs1fvNV(void) { }
void __indirect_glVertexAttribs1svNV(void) { }
void __indirect_glVertexAttribs2dvNV(void) { }
void __indirect_glVertexAttribs2fvNV(void) { }
void __indirect_glVertexAttribs2svNV(void) { }
void __indirect_glVertexAttribs3dvNV(void) { }
void __indirect_glVertexAttribs3fvNV(void) { }
void __indirect_glVertexAttribs3svNV(void) { }
void __indirect_glVertexAttribs4dvNV(void) { }
void __indirect_glVertexAttribs4fvNV(void) { }
void __indirect_glVertexAttribs4svNV(void) { }
void __indirect_glVertexAttribs4ubvNV(void) { }
void __indirect_glPointParameteri(void) { }
void __indirect_glPointParameteriv(void) { }
void __indirect_glActiveStencilFaceEXT(void) { }
void __indirect_glGetProgramNamedParameterdvNV(void) { }
void __indirect_glGetProgramNamedParameterfvNV(void) { }
void __indirect_glProgramNamedParameter4dNV(void) { }
void __indirect_glProgramNamedParameter4dvNV(void) { }
void __indirect_glProgramNamedParameter4fNV(void) { }
void __indirect_glProgramNamedParameter4fvNV(void) { }
void __indirect_glBlendEquationSeparate(void) { }
void __indirect_glBindFramebufferEXT(void) { }
void __indirect_glBindRenderbufferEXT(void) { }
void __indirect_glBindFramebuffer(void) { }
void __indirect_glBindRenderbuffer(void) { }
void __indirect_glCheckFramebufferStatus(void) { }
void __indirect_glDeleteFramebuffers(void) { }
void __indirect_glDeleteRenderbuffers(void) { }
void __indirect_glFramebufferRenderbuffer(void) { }
void __indirect_glFramebufferTexture1D(void) { }
void __indirect_glFramebufferTexture2D(void) { }
void __indirect_glFramebufferTexture3D(void) { }
void __indirect_glGenFramebuffers(void) { }
void __indirect_glGenRenderbuffers(void) { }
void __indirect_glGenerateMipmap(void) { }
void __indirect_glGetFramebufferAttachmentParameteriv(void) { }
void __indirect_glGetRenderbufferParameteriv(void) { }
void __indirect_glIsFramebuffer(void) { }
void __indirect_glIsRenderbuffer(void) { }
void __indirect_glRenderbufferStorage(void) { }
void __indirect_glBlitFramebuffer(void) { }
void __indirect_glFramebufferTextureLayer(void) { }
}
/*@}*/
 
class IndirectAPI : public ::testing::Test {
public:
virtual void SetUp();
virtual void TearDown();
 
_glapi_proc *table;
};
 
void
IndirectAPI::SetUp()
{
this->table = (_glapi_proc *) __glXNewIndirectAPI();
}
 
void
IndirectAPI::TearDown()
{
free(this->table);
this->table = NULL;
}
 
TEST_F(IndirectAPI, DispatchTableSizeWasQueried)
{
dispatch_table_size_was_queried = false;
 
/* __glXNewIndirectAPI determines the size of the dispatch table by calling
* _glapi_get_dispatch_table_size. Our stub version of this function sets
* a flag so that we can detect that __glXNewIndirectAPI called it.
*/
EXPECT_FALSE(dispatch_table_size_was_queried);
_glapi_table *table = __glXNewIndirectAPI();
EXPECT_TRUE(dispatch_table_size_was_queried);
 
/* Since a second dispatch table was created, it must be freed by hand.
*/
free(table);
}
 
TEST_F(IndirectAPI, NoNullEntries)
{
const unsigned entries = _glapi_get_dispatch_table_size();
 
/* There should not be any NULL entries in the dispatch table. All entires
* should either point to a real implementation or to a no-op function.
*/
for (unsigned i = 0; i < entries; i++) {
EXPECT_NE(nil, table[i]);
}
}
 
TEST_F(IndirectAPI, OpenGL_10)
{
EXPECT_EQ((_glapi_proc) __indirect_glAccum, table[_gloffset_Accum]);
EXPECT_EQ((_glapi_proc) __indirect_glAlphaFunc, table[_gloffset_AlphaFunc]);
EXPECT_EQ((_glapi_proc) __indirect_glBegin, table[_gloffset_Begin]);
EXPECT_EQ((_glapi_proc) __indirect_glBitmap, table[_gloffset_Bitmap]);
EXPECT_EQ((_glapi_proc) __indirect_glBlendFunc, table[_gloffset_BlendFunc]);
EXPECT_EQ((_glapi_proc) __indirect_glCallList, table[_gloffset_CallList]);
EXPECT_EQ((_glapi_proc) __indirect_glCallLists, table[_gloffset_CallLists]);
EXPECT_EQ((_glapi_proc) __indirect_glClear, table[_gloffset_Clear]);
EXPECT_EQ((_glapi_proc) __indirect_glClearAccum, table[_gloffset_ClearAccum]);
EXPECT_EQ((_glapi_proc) __indirect_glClearColor, table[_gloffset_ClearColor]);
EXPECT_EQ((_glapi_proc) __indirect_glClearDepth, table[_gloffset_ClearDepth]);
EXPECT_EQ((_glapi_proc) __indirect_glClearIndex, table[_gloffset_ClearIndex]);
EXPECT_EQ((_glapi_proc) __indirect_glClearStencil, table[_gloffset_ClearStencil]);
EXPECT_EQ((_glapi_proc) __indirect_glClipPlane, table[_gloffset_ClipPlane]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3b, table[_gloffset_Color3b]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3bv, table[_gloffset_Color3bv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3d, table[_gloffset_Color3d]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3dv, table[_gloffset_Color3dv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3f, table[_gloffset_Color3f]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3fv, table[_gloffset_Color3fv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3i, table[_gloffset_Color3i]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3iv, table[_gloffset_Color3iv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3s, table[_gloffset_Color3s]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3sv, table[_gloffset_Color3sv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3ub, table[_gloffset_Color3ub]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3ubv, table[_gloffset_Color3ubv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3ui, table[_gloffset_Color3ui]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3uiv, table[_gloffset_Color3uiv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3us, table[_gloffset_Color3us]);
EXPECT_EQ((_glapi_proc) __indirect_glColor3usv, table[_gloffset_Color3usv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4b, table[_gloffset_Color4b]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4bv, table[_gloffset_Color4bv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4d, table[_gloffset_Color4d]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4dv, table[_gloffset_Color4dv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4f, table[_gloffset_Color4f]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4fv, table[_gloffset_Color4fv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4i, table[_gloffset_Color4i]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4iv, table[_gloffset_Color4iv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4s, table[_gloffset_Color4s]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4sv, table[_gloffset_Color4sv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4ub, table[_gloffset_Color4ub]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4ubv, table[_gloffset_Color4ubv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4ui, table[_gloffset_Color4ui]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4uiv, table[_gloffset_Color4uiv]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4us, table[_gloffset_Color4us]);
EXPECT_EQ((_glapi_proc) __indirect_glColor4usv, table[_gloffset_Color4usv]);
EXPECT_EQ((_glapi_proc) __indirect_glColorMask, table[_gloffset_ColorMask]);
EXPECT_EQ((_glapi_proc) __indirect_glColorMaterial, table[_gloffset_ColorMaterial]);
EXPECT_EQ((_glapi_proc) __indirect_glCopyPixels, table[_gloffset_CopyPixels]);
EXPECT_EQ((_glapi_proc) __indirect_glCullFace, table[_gloffset_CullFace]);
EXPECT_EQ((_glapi_proc) __indirect_glDeleteLists, table[_gloffset_DeleteLists]);
EXPECT_EQ((_glapi_proc) __indirect_glDepthFunc, table[_gloffset_DepthFunc]);
EXPECT_EQ((_glapi_proc) __indirect_glDepthMask, table[_gloffset_DepthMask]);
EXPECT_EQ((_glapi_proc) __indirect_glDepthRange, table[_gloffset_DepthRange]);
EXPECT_EQ((_glapi_proc) __indirect_glDisable, table[_gloffset_Disable]);
EXPECT_EQ((_glapi_proc) __indirect_glDrawBuffer, table[_gloffset_DrawBuffer]);
EXPECT_EQ((_glapi_proc) __indirect_glDrawPixels, table[_gloffset_DrawPixels]);
EXPECT_EQ((_glapi_proc) __indirect_glEdgeFlag, table[_gloffset_EdgeFlag]);
EXPECT_EQ((_glapi_proc) __indirect_glEdgeFlagv, table[_gloffset_EdgeFlagv]);
EXPECT_EQ((_glapi_proc) __indirect_glEnable, table[_gloffset_Enable]);
EXPECT_EQ((_glapi_proc) __indirect_glEnd, table[_gloffset_End]);
EXPECT_EQ((_glapi_proc) __indirect_glEndList, table[_gloffset_EndList]);
EXPECT_EQ((_glapi_proc) __indirect_glEvalCoord1d, table[_gloffset_EvalCoord1d]);
EXPECT_EQ((_glapi_proc) __indirect_glEvalCoord1dv, table[_gloffset_EvalCoord1dv]);
EXPECT_EQ((_glapi_proc) __indirect_glEvalCoord1f, table[_gloffset_EvalCoord1f]);
EXPECT_EQ((_glapi_proc) __indirect_glEvalCoord1fv, table[_gloffset_EvalCoord1fv]);
EXPECT_EQ((_glapi_proc) __indirect_glEvalCoord2d, table[_gloffset_EvalCoord2d]);
EXPECT_EQ((_glapi_proc) __indirect_glEvalCoord2dv, table[_gloffset_EvalCoord2dv]);
EXPECT_EQ((_glapi_proc) __indirect_glEvalCoord2f, table[_gloffset_EvalCoord2f]);
EXPECT_EQ((_glapi_proc) __indirect_glEvalCoord2fv, table[_gloffset_EvalCoord2fv]);
EXPECT_EQ((_glapi_proc) __indirect_glEvalMesh1, table[_gloffset_EvalMesh1]);
EXPECT_EQ((_glapi_proc) __indirect_glEvalMesh2, table[_gloffset_EvalMesh2]);
EXPECT_EQ((_glapi_proc) __indirect_glEvalPoint1, table[_gloffset_EvalPoint1]);
EXPECT_EQ((_glapi_proc) __indirect_glEvalPoint2, table[_gloffset_EvalPoint2]);
EXPECT_EQ((_glapi_proc) __indirect_glFeedbackBuffer, table[_gloffset_FeedbackBuffer]);
EXPECT_EQ((_glapi_proc) __indirect_glFinish, table[_gloffset_Finish]);
EXPECT_EQ((_glapi_proc) __indirect_glFlush, table[_gloffset_Flush]);
EXPECT_EQ((_glapi_proc) __indirect_glFogf, table[_gloffset_Fogf]);
EXPECT_EQ((_glapi_proc) __indirect_glFogfv, table[_gloffset_Fogfv]);
EXPECT_EQ((_glapi_proc) __indirect_glFogi, table[_gloffset_Fogi]);
EXPECT_EQ((_glapi_proc) __indirect_glFogiv, table[_gloffset_Fogiv]);
EXPECT_EQ((_glapi_proc) __indirect_glFrontFace, table[_gloffset_FrontFace]);
EXPECT_EQ((_glapi_proc) __indirect_glFrustum, table[_gloffset_Frustum]);
EXPECT_EQ((_glapi_proc) __indirect_glGenLists, table[_gloffset_GenLists]);
EXPECT_EQ((_glapi_proc) __indirect_glGetBooleanv, table[_gloffset_GetBooleanv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetClipPlane, table[_gloffset_GetClipPlane]);
EXPECT_EQ((_glapi_proc) __indirect_glGetDoublev, table[_gloffset_GetDoublev]);
EXPECT_EQ((_glapi_proc) __indirect_glGetError, table[_gloffset_GetError]);
EXPECT_EQ((_glapi_proc) __indirect_glGetFloatv, table[_gloffset_GetFloatv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetIntegerv, table[_gloffset_GetIntegerv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetLightfv, table[_gloffset_GetLightfv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetLightiv, table[_gloffset_GetLightiv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetMapdv, table[_gloffset_GetMapdv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetMapfv, table[_gloffset_GetMapfv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetMapiv, table[_gloffset_GetMapiv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetMaterialfv, table[_gloffset_GetMaterialfv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetMaterialiv, table[_gloffset_GetMaterialiv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetPixelMapfv, table[_gloffset_GetPixelMapfv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetPixelMapuiv, table[_gloffset_GetPixelMapuiv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetPixelMapusv, table[_gloffset_GetPixelMapusv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetPolygonStipple, table[_gloffset_GetPolygonStipple]);
EXPECT_EQ((_glapi_proc) __indirect_glGetString, table[_gloffset_GetString]);
EXPECT_EQ((_glapi_proc) __indirect_glGetTexEnvfv, table[_gloffset_GetTexEnvfv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetTexEnviv, table[_gloffset_GetTexEnviv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetTexGendv, table[_gloffset_GetTexGendv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetTexGenfv, table[_gloffset_GetTexGenfv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetTexGeniv, table[_gloffset_GetTexGeniv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetTexImage, table[_gloffset_GetTexImage]);
EXPECT_EQ((_glapi_proc) __indirect_glGetTexLevelParameterfv, table[_gloffset_GetTexLevelParameterfv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetTexLevelParameteriv, table[_gloffset_GetTexLevelParameteriv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetTexParameterfv, table[_gloffset_GetTexParameterfv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetTexParameteriv, table[_gloffset_GetTexParameteriv]);
EXPECT_EQ((_glapi_proc) __indirect_glHint, table[_gloffset_Hint]);
EXPECT_EQ((_glapi_proc) __indirect_glIndexMask, table[_gloffset_IndexMask]);
EXPECT_EQ((_glapi_proc) __indirect_glIndexd, table[_gloffset_Indexd]);
EXPECT_EQ((_glapi_proc) __indirect_glIndexdv, table[_gloffset_Indexdv]);
EXPECT_EQ((_glapi_proc) __indirect_glIndexf, table[_gloffset_Indexf]);
EXPECT_EQ((_glapi_proc) __indirect_glIndexfv, table[_gloffset_Indexfv]);
EXPECT_EQ((_glapi_proc) __indirect_glIndexi, table[_gloffset_Indexi]);
EXPECT_EQ((_glapi_proc) __indirect_glIndexiv, table[_gloffset_Indexiv]);
EXPECT_EQ((_glapi_proc) __indirect_glIndexs, table[_gloffset_Indexs]);
EXPECT_EQ((_glapi_proc) __indirect_glIndexsv, table[_gloffset_Indexsv]);
EXPECT_EQ((_glapi_proc) __indirect_glInitNames, table[_gloffset_InitNames]);
EXPECT_EQ((_glapi_proc) __indirect_glIsEnabled, table[_gloffset_IsEnabled]);
EXPECT_EQ((_glapi_proc) __indirect_glIsList, table[_gloffset_IsList]);
EXPECT_EQ((_glapi_proc) __indirect_glLightModelf, table[_gloffset_LightModelf]);
EXPECT_EQ((_glapi_proc) __indirect_glLightModelfv, table[_gloffset_LightModelfv]);
EXPECT_EQ((_glapi_proc) __indirect_glLightModeli, table[_gloffset_LightModeli]);
EXPECT_EQ((_glapi_proc) __indirect_glLightModeliv, table[_gloffset_LightModeliv]);
EXPECT_EQ((_glapi_proc) __indirect_glLightf, table[_gloffset_Lightf]);
EXPECT_EQ((_glapi_proc) __indirect_glLightfv, table[_gloffset_Lightfv]);
EXPECT_EQ((_glapi_proc) __indirect_glLighti, table[_gloffset_Lighti]);
EXPECT_EQ((_glapi_proc) __indirect_glLightiv, table[_gloffset_Lightiv]);
EXPECT_EQ((_glapi_proc) __indirect_glLineStipple, table[_gloffset_LineStipple]);
EXPECT_EQ((_glapi_proc) __indirect_glLineWidth, table[_gloffset_LineWidth]);
EXPECT_EQ((_glapi_proc) __indirect_glListBase, table[_gloffset_ListBase]);
EXPECT_EQ((_glapi_proc) __indirect_glLoadIdentity, table[_gloffset_LoadIdentity]);
EXPECT_EQ((_glapi_proc) __indirect_glLoadMatrixd, table[_gloffset_LoadMatrixd]);
EXPECT_EQ((_glapi_proc) __indirect_glLoadMatrixf, table[_gloffset_LoadMatrixf]);
EXPECT_EQ((_glapi_proc) __indirect_glLoadName, table[_gloffset_LoadName]);
EXPECT_EQ((_glapi_proc) __indirect_glLogicOp, table[_gloffset_LogicOp]);
EXPECT_EQ((_glapi_proc) __indirect_glMap1d, table[_gloffset_Map1d]);
EXPECT_EQ((_glapi_proc) __indirect_glMap1f, table[_gloffset_Map1f]);
EXPECT_EQ((_glapi_proc) __indirect_glMap2d, table[_gloffset_Map2d]);
EXPECT_EQ((_glapi_proc) __indirect_glMap2f, table[_gloffset_Map2f]);
EXPECT_EQ((_glapi_proc) __indirect_glMapGrid1d, table[_gloffset_MapGrid1d]);
EXPECT_EQ((_glapi_proc) __indirect_glMapGrid1f, table[_gloffset_MapGrid1f]);
EXPECT_EQ((_glapi_proc) __indirect_glMapGrid2d, table[_gloffset_MapGrid2d]);
EXPECT_EQ((_glapi_proc) __indirect_glMapGrid2f, table[_gloffset_MapGrid2f]);
EXPECT_EQ((_glapi_proc) __indirect_glMaterialf, table[_gloffset_Materialf]);
EXPECT_EQ((_glapi_proc) __indirect_glMaterialfv, table[_gloffset_Materialfv]);
EXPECT_EQ((_glapi_proc) __indirect_glMateriali, table[_gloffset_Materiali]);
EXPECT_EQ((_glapi_proc) __indirect_glMaterialiv, table[_gloffset_Materialiv]);
EXPECT_EQ((_glapi_proc) __indirect_glMatrixMode, table[_gloffset_MatrixMode]);
EXPECT_EQ((_glapi_proc) __indirect_glMultMatrixd, table[_gloffset_MultMatrixd]);
EXPECT_EQ((_glapi_proc) __indirect_glMultMatrixf, table[_gloffset_MultMatrixf]);
EXPECT_EQ((_glapi_proc) __indirect_glNewList, table[_gloffset_NewList]);
EXPECT_EQ((_glapi_proc) __indirect_glNormal3b, table[_gloffset_Normal3b]);
EXPECT_EQ((_glapi_proc) __indirect_glNormal3bv, table[_gloffset_Normal3bv]);
EXPECT_EQ((_glapi_proc) __indirect_glNormal3d, table[_gloffset_Normal3d]);
EXPECT_EQ((_glapi_proc) __indirect_glNormal3dv, table[_gloffset_Normal3dv]);
EXPECT_EQ((_glapi_proc) __indirect_glNormal3f, table[_gloffset_Normal3f]);
EXPECT_EQ((_glapi_proc) __indirect_glNormal3fv, table[_gloffset_Normal3fv]);
EXPECT_EQ((_glapi_proc) __indirect_glNormal3i, table[_gloffset_Normal3i]);
EXPECT_EQ((_glapi_proc) __indirect_glNormal3iv, table[_gloffset_Normal3iv]);
EXPECT_EQ((_glapi_proc) __indirect_glNormal3s, table[_gloffset_Normal3s]);
EXPECT_EQ((_glapi_proc) __indirect_glNormal3sv, table[_gloffset_Normal3sv]);
EXPECT_EQ((_glapi_proc) __indirect_glOrtho, table[_gloffset_Ortho]);
EXPECT_EQ((_glapi_proc) __indirect_glPassThrough, table[_gloffset_PassThrough]);
EXPECT_EQ((_glapi_proc) __indirect_glPixelMapfv, table[_gloffset_PixelMapfv]);
EXPECT_EQ((_glapi_proc) __indirect_glPixelMapuiv, table[_gloffset_PixelMapuiv]);
EXPECT_EQ((_glapi_proc) __indirect_glPixelMapusv, table[_gloffset_PixelMapusv]);
EXPECT_EQ((_glapi_proc) __indirect_glPixelStoref, table[_gloffset_PixelStoref]);
EXPECT_EQ((_glapi_proc) __indirect_glPixelStorei, table[_gloffset_PixelStorei]);
EXPECT_EQ((_glapi_proc) __indirect_glPixelTransferf, table[_gloffset_PixelTransferf]);
EXPECT_EQ((_glapi_proc) __indirect_glPixelTransferi, table[_gloffset_PixelTransferi]);
EXPECT_EQ((_glapi_proc) __indirect_glPixelZoom, table[_gloffset_PixelZoom]);
EXPECT_EQ((_glapi_proc) __indirect_glPointSize, table[_gloffset_PointSize]);
EXPECT_EQ((_glapi_proc) __indirect_glPolygonMode, table[_gloffset_PolygonMode]);
EXPECT_EQ((_glapi_proc) __indirect_glPolygonStipple, table[_gloffset_PolygonStipple]);
EXPECT_EQ((_glapi_proc) __indirect_glPopAttrib, table[_gloffset_PopAttrib]);
EXPECT_EQ((_glapi_proc) __indirect_glPopMatrix, table[_gloffset_PopMatrix]);
EXPECT_EQ((_glapi_proc) __indirect_glPopName, table[_gloffset_PopName]);
EXPECT_EQ((_glapi_proc) __indirect_glPushAttrib, table[_gloffset_PushAttrib]);
EXPECT_EQ((_glapi_proc) __indirect_glPushMatrix, table[_gloffset_PushMatrix]);
EXPECT_EQ((_glapi_proc) __indirect_glPushName, table[_gloffset_PushName]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos2d, table[_gloffset_RasterPos2d]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos2dv, table[_gloffset_RasterPos2dv]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos2f, table[_gloffset_RasterPos2f]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos2fv, table[_gloffset_RasterPos2fv]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos2i, table[_gloffset_RasterPos2i]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos2iv, table[_gloffset_RasterPos2iv]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos2s, table[_gloffset_RasterPos2s]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos2sv, table[_gloffset_RasterPos2sv]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos3d, table[_gloffset_RasterPos3d]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos3dv, table[_gloffset_RasterPos3dv]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos3f, table[_gloffset_RasterPos3f]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos3fv, table[_gloffset_RasterPos3fv]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos3i, table[_gloffset_RasterPos3i]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos3iv, table[_gloffset_RasterPos3iv]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos3s, table[_gloffset_RasterPos3s]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos3sv, table[_gloffset_RasterPos3sv]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos4d, table[_gloffset_RasterPos4d]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos4dv, table[_gloffset_RasterPos4dv]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos4f, table[_gloffset_RasterPos4f]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos4fv, table[_gloffset_RasterPos4fv]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos4i, table[_gloffset_RasterPos4i]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos4iv, table[_gloffset_RasterPos4iv]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos4s, table[_gloffset_RasterPos4s]);
EXPECT_EQ((_glapi_proc) __indirect_glRasterPos4sv, table[_gloffset_RasterPos4sv]);
EXPECT_EQ((_glapi_proc) __indirect_glReadBuffer, table[_gloffset_ReadBuffer]);
EXPECT_EQ((_glapi_proc) __indirect_glReadPixels, table[_gloffset_ReadPixels]);
EXPECT_EQ((_glapi_proc) __indirect_glRectd, table[_gloffset_Rectd]);
EXPECT_EQ((_glapi_proc) __indirect_glRectdv, table[_gloffset_Rectdv]);
EXPECT_EQ((_glapi_proc) __indirect_glRectf, table[_gloffset_Rectf]);
EXPECT_EQ((_glapi_proc) __indirect_glRectfv, table[_gloffset_Rectfv]);
EXPECT_EQ((_glapi_proc) __indirect_glRecti, table[_gloffset_Recti]);
EXPECT_EQ((_glapi_proc) __indirect_glRectiv, table[_gloffset_Rectiv]);
EXPECT_EQ((_glapi_proc) __indirect_glRects, table[_gloffset_Rects]);
EXPECT_EQ((_glapi_proc) __indirect_glRectsv, table[_gloffset_Rectsv]);
EXPECT_EQ((_glapi_proc) __indirect_glRenderMode, table[_gloffset_RenderMode]);
EXPECT_EQ((_glapi_proc) __indirect_glRotated, table[_gloffset_Rotated]);
EXPECT_EQ((_glapi_proc) __indirect_glRotatef, table[_gloffset_Rotatef]);
EXPECT_EQ((_glapi_proc) __indirect_glScaled, table[_gloffset_Scaled]);
EXPECT_EQ((_glapi_proc) __indirect_glScalef, table[_gloffset_Scalef]);
EXPECT_EQ((_glapi_proc) __indirect_glScissor, table[_gloffset_Scissor]);
EXPECT_EQ((_glapi_proc) __indirect_glSelectBuffer, table[_gloffset_SelectBuffer]);
EXPECT_EQ((_glapi_proc) __indirect_glShadeModel, table[_gloffset_ShadeModel]);
EXPECT_EQ((_glapi_proc) __indirect_glStencilFunc, table[_gloffset_StencilFunc]);
EXPECT_EQ((_glapi_proc) __indirect_glStencilMask, table[_gloffset_StencilMask]);
EXPECT_EQ((_glapi_proc) __indirect_glStencilOp, table[_gloffset_StencilOp]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord1d, table[_gloffset_TexCoord1d]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord1dv, table[_gloffset_TexCoord1dv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord1f, table[_gloffset_TexCoord1f]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord1fv, table[_gloffset_TexCoord1fv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord1i, table[_gloffset_TexCoord1i]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord1iv, table[_gloffset_TexCoord1iv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord1s, table[_gloffset_TexCoord1s]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord1sv, table[_gloffset_TexCoord1sv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord2d, table[_gloffset_TexCoord2d]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord2dv, table[_gloffset_TexCoord2dv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord2f, table[_gloffset_TexCoord2f]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord2fv, table[_gloffset_TexCoord2fv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord2i, table[_gloffset_TexCoord2i]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord2iv, table[_gloffset_TexCoord2iv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord2s, table[_gloffset_TexCoord2s]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord2sv, table[_gloffset_TexCoord2sv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord3d, table[_gloffset_TexCoord3d]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord3dv, table[_gloffset_TexCoord3dv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord3f, table[_gloffset_TexCoord3f]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord3fv, table[_gloffset_TexCoord3fv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord3i, table[_gloffset_TexCoord3i]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord3iv, table[_gloffset_TexCoord3iv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord3s, table[_gloffset_TexCoord3s]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord3sv, table[_gloffset_TexCoord3sv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord4d, table[_gloffset_TexCoord4d]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord4dv, table[_gloffset_TexCoord4dv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord4f, table[_gloffset_TexCoord4f]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord4fv, table[_gloffset_TexCoord4fv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord4i, table[_gloffset_TexCoord4i]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord4iv, table[_gloffset_TexCoord4iv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord4s, table[_gloffset_TexCoord4s]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoord4sv, table[_gloffset_TexCoord4sv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexEnvf, table[_gloffset_TexEnvf]);
EXPECT_EQ((_glapi_proc) __indirect_glTexEnvfv, table[_gloffset_TexEnvfv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexEnvi, table[_gloffset_TexEnvi]);
EXPECT_EQ((_glapi_proc) __indirect_glTexEnviv, table[_gloffset_TexEnviv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexGend, table[_gloffset_TexGend]);
EXPECT_EQ((_glapi_proc) __indirect_glTexGendv, table[_gloffset_TexGendv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexGenf, table[_gloffset_TexGenf]);
EXPECT_EQ((_glapi_proc) __indirect_glTexGenfv, table[_gloffset_TexGenfv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexGeni, table[_gloffset_TexGeni]);
EXPECT_EQ((_glapi_proc) __indirect_glTexGeniv, table[_gloffset_TexGeniv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexImage1D, table[_gloffset_TexImage1D]);
EXPECT_EQ((_glapi_proc) __indirect_glTexImage2D, table[_gloffset_TexImage2D]);
EXPECT_EQ((_glapi_proc) __indirect_glTexParameterf, table[_gloffset_TexParameterf]);
EXPECT_EQ((_glapi_proc) __indirect_glTexParameterfv, table[_gloffset_TexParameterfv]);
EXPECT_EQ((_glapi_proc) __indirect_glTexParameteri, table[_gloffset_TexParameteri]);
EXPECT_EQ((_glapi_proc) __indirect_glTexParameteriv, table[_gloffset_TexParameteriv]);
EXPECT_EQ((_glapi_proc) __indirect_glTranslated, table[_gloffset_Translated]);
EXPECT_EQ((_glapi_proc) __indirect_glTranslatef, table[_gloffset_Translatef]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex2d, table[_gloffset_Vertex2d]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex2dv, table[_gloffset_Vertex2dv]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex2f, table[_gloffset_Vertex2f]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex2fv, table[_gloffset_Vertex2fv]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex2i, table[_gloffset_Vertex2i]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex2iv, table[_gloffset_Vertex2iv]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex2s, table[_gloffset_Vertex2s]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex2sv, table[_gloffset_Vertex2sv]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex3d, table[_gloffset_Vertex3d]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex3dv, table[_gloffset_Vertex3dv]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex3f, table[_gloffset_Vertex3f]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex3fv, table[_gloffset_Vertex3fv]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex3i, table[_gloffset_Vertex3i]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex3iv, table[_gloffset_Vertex3iv]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex3s, table[_gloffset_Vertex3s]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex3sv, table[_gloffset_Vertex3sv]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex4d, table[_gloffset_Vertex4d]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex4dv, table[_gloffset_Vertex4dv]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex4f, table[_gloffset_Vertex4f]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex4fv, table[_gloffset_Vertex4fv]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex4i, table[_gloffset_Vertex4i]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex4iv, table[_gloffset_Vertex4iv]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex4s, table[_gloffset_Vertex4s]);
EXPECT_EQ((_glapi_proc) __indirect_glVertex4sv, table[_gloffset_Vertex4sv]);
EXPECT_EQ((_glapi_proc) __indirect_glViewport, table[_gloffset_Viewport]);
}
 
TEST_F(IndirectAPI, OpenGL_11)
{
EXPECT_EQ((_glapi_proc) __indirect_glAreTexturesResident, table[_gloffset_AreTexturesResident]);
EXPECT_EQ((_glapi_proc) __indirect_glArrayElement, table[_gloffset_ArrayElement]);
EXPECT_EQ((_glapi_proc) __indirect_glBindTexture, table[_gloffset_BindTexture]);
EXPECT_EQ((_glapi_proc) __indirect_glColorPointer, table[_gloffset_ColorPointer]);
EXPECT_EQ((_glapi_proc) __indirect_glCopyTexImage1D, table[_gloffset_CopyTexImage1D]);
EXPECT_EQ((_glapi_proc) __indirect_glCopyTexImage2D, table[_gloffset_CopyTexImage2D]);
EXPECT_EQ((_glapi_proc) __indirect_glCopyTexSubImage1D, table[_gloffset_CopyTexSubImage1D]);
EXPECT_EQ((_glapi_proc) __indirect_glCopyTexSubImage2D, table[_gloffset_CopyTexSubImage2D]);
EXPECT_EQ((_glapi_proc) __indirect_glDeleteTextures, table[_gloffset_DeleteTextures]);
EXPECT_EQ((_glapi_proc) __indirect_glDisableClientState, table[_gloffset_DisableClientState]);
EXPECT_EQ((_glapi_proc) __indirect_glDrawArrays, table[_gloffset_DrawArrays]);
EXPECT_EQ((_glapi_proc) __indirect_glDrawElements, table[_gloffset_DrawElements]);
EXPECT_EQ((_glapi_proc) __indirect_glEdgeFlagPointer, table[_gloffset_EdgeFlagPointer]);
EXPECT_EQ((_glapi_proc) __indirect_glEnableClientState, table[_gloffset_EnableClientState]);
EXPECT_EQ((_glapi_proc) __indirect_glGenTextures, table[_gloffset_GenTextures]);
EXPECT_EQ((_glapi_proc) __indirect_glGetPointerv, table[_gloffset_GetPointerv]);
EXPECT_EQ((_glapi_proc) __indirect_glIndexPointer, table[_gloffset_IndexPointer]);
EXPECT_EQ((_glapi_proc) __indirect_glIndexub, table[_gloffset_Indexub]);
EXPECT_EQ((_glapi_proc) __indirect_glIndexubv, table[_gloffset_Indexubv]);
EXPECT_EQ((_glapi_proc) __indirect_glInterleavedArrays, table[_gloffset_InterleavedArrays]);
EXPECT_EQ((_glapi_proc) __indirect_glIsTexture, table[_gloffset_IsTexture]);
EXPECT_EQ((_glapi_proc) __indirect_glNormalPointer, table[_gloffset_NormalPointer]);
EXPECT_EQ((_glapi_proc) __indirect_glPolygonOffset, table[_gloffset_PolygonOffset]);
EXPECT_EQ((_glapi_proc) __indirect_glPopClientAttrib, table[_gloffset_PopClientAttrib]);
EXPECT_EQ((_glapi_proc) __indirect_glPrioritizeTextures, table[_gloffset_PrioritizeTextures]);
EXPECT_EQ((_glapi_proc) __indirect_glPushClientAttrib, table[_gloffset_PushClientAttrib]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoordPointer, table[_gloffset_TexCoordPointer]);
EXPECT_EQ((_glapi_proc) __indirect_glTexSubImage1D, table[_gloffset_TexSubImage1D]);
EXPECT_EQ((_glapi_proc) __indirect_glTexSubImage2D, table[_gloffset_TexSubImage2D]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexPointer, table[_gloffset_VertexPointer]);
}
 
TEST_F(IndirectAPI, OpenGL_12)
{
EXPECT_EQ((_glapi_proc) __indirect_glBlendColor, table[_gloffset_BlendColor]);
EXPECT_EQ((_glapi_proc) __indirect_glBlendEquation, table[_gloffset_BlendEquation]);
EXPECT_EQ((_glapi_proc) __indirect_glColorSubTable, table[_gloffset_ColorSubTable]);
EXPECT_EQ((_glapi_proc) __indirect_glColorTable, table[_gloffset_ColorTable]);
EXPECT_EQ((_glapi_proc) __indirect_glColorTableParameterfv, table[_gloffset_ColorTableParameterfv]);
EXPECT_EQ((_glapi_proc) __indirect_glColorTableParameteriv, table[_gloffset_ColorTableParameteriv]);
EXPECT_EQ((_glapi_proc) __indirect_glConvolutionFilter1D, table[_gloffset_ConvolutionFilter1D]);
EXPECT_EQ((_glapi_proc) __indirect_glConvolutionFilter2D, table[_gloffset_ConvolutionFilter2D]);
EXPECT_EQ((_glapi_proc) __indirect_glConvolutionParameterf, table[_gloffset_ConvolutionParameterf]);
EXPECT_EQ((_glapi_proc) __indirect_glConvolutionParameterfv, table[_gloffset_ConvolutionParameterfv]);
EXPECT_EQ((_glapi_proc) __indirect_glConvolutionParameteri, table[_gloffset_ConvolutionParameteri]);
EXPECT_EQ((_glapi_proc) __indirect_glConvolutionParameteriv, table[_gloffset_ConvolutionParameteriv]);
EXPECT_EQ((_glapi_proc) __indirect_glCopyColorSubTable, table[_gloffset_CopyColorSubTable]);
EXPECT_EQ((_glapi_proc) __indirect_glCopyColorTable, table[_gloffset_CopyColorTable]);
EXPECT_EQ((_glapi_proc) __indirect_glCopyConvolutionFilter1D, table[_gloffset_CopyConvolutionFilter1D]);
EXPECT_EQ((_glapi_proc) __indirect_glCopyConvolutionFilter2D, table[_gloffset_CopyConvolutionFilter2D]);
EXPECT_EQ((_glapi_proc) __indirect_glCopyTexSubImage3D, table[_gloffset_CopyTexSubImage3D]);
EXPECT_EQ((_glapi_proc) __indirect_glDrawRangeElements, table[_gloffset_DrawRangeElements]);
EXPECT_EQ((_glapi_proc) __indirect_glGetColorTable, table[_gloffset_GetColorTable]);
EXPECT_EQ((_glapi_proc) __indirect_glGetColorTableParameterfv, table[_gloffset_GetColorTableParameterfv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetColorTableParameteriv, table[_gloffset_GetColorTableParameteriv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetConvolutionFilter, table[_gloffset_GetConvolutionFilter]);
EXPECT_EQ((_glapi_proc) __indirect_glGetConvolutionParameterfv, table[_gloffset_GetConvolutionParameterfv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetConvolutionParameteriv, table[_gloffset_GetConvolutionParameteriv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetHistogram, table[_gloffset_GetHistogram]);
EXPECT_EQ((_glapi_proc) __indirect_glGetHistogramParameterfv, table[_gloffset_GetHistogramParameterfv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetHistogramParameteriv, table[_gloffset_GetHistogramParameteriv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetMinmax, table[_gloffset_GetMinmax]);
EXPECT_EQ((_glapi_proc) __indirect_glGetMinmaxParameterfv, table[_gloffset_GetMinmaxParameterfv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetMinmaxParameteriv, table[_gloffset_GetMinmaxParameteriv]);
EXPECT_EQ((_glapi_proc) __indirect_glGetSeparableFilter, table[_gloffset_GetSeparableFilter]);
EXPECT_EQ((_glapi_proc) __indirect_glHistogram, table[_gloffset_Histogram]);
EXPECT_EQ((_glapi_proc) __indirect_glMinmax, table[_gloffset_Minmax]);
EXPECT_EQ((_glapi_proc) __indirect_glResetHistogram, table[_gloffset_ResetHistogram]);
EXPECT_EQ((_glapi_proc) __indirect_glResetMinmax, table[_gloffset_ResetMinmax]);
EXPECT_EQ((_glapi_proc) __indirect_glSeparableFilter2D, table[_gloffset_SeparableFilter2D]);
EXPECT_EQ((_glapi_proc) __indirect_glTexImage3D, table[_gloffset_TexImage3D]);
EXPECT_EQ((_glapi_proc) __indirect_glTexSubImage3D, table[_gloffset_TexSubImage3D]);
}
 
TEST_F(IndirectAPI, OpenGL_20_is_nop)
{
_glapi_proc const nop = table[_gloffset_COUNT];
 
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glAttachShader")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glCreateProgram")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glCreateShader")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glDeleteProgram")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glDeleteShader")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glDetachShader")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glGetAttachedShaders")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glGetProgramInfoLog")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glGetProgramiv")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glGetShaderInfoLog")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glGetShaderiv")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glIsProgram")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glIsShader")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glStencilFuncSeparate")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glStencilMaskSeparate")]);
EXPECT_EQ(nop, table[_glapi_get_proc_offset("glStencilOpSeparate")]);
}
 
TEST_F(IndirectAPI, ARB_multitexture)
{
EXPECT_EQ((_glapi_proc) __indirect_glActiveTexture, table[_gloffset_ActiveTexture]);
EXPECT_EQ((_glapi_proc) __indirect_glClientActiveTexture, table[_gloffset_ClientActiveTexture]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord1d, table[_gloffset_MultiTexCoord1d]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord1dv, table[_gloffset_MultiTexCoord1dv]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord1fARB, table[_gloffset_MultiTexCoord1fARB]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord1fvARB, table[_gloffset_MultiTexCoord1fvARB]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord1i, table[_gloffset_MultiTexCoord1i]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord1iv, table[_gloffset_MultiTexCoord1iv]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord1s, table[_gloffset_MultiTexCoord1s]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord1sv, table[_gloffset_MultiTexCoord1sv]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord2d, table[_gloffset_MultiTexCoord2d]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord2dv, table[_gloffset_MultiTexCoord2dv]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord2fARB, table[_gloffset_MultiTexCoord2fARB]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord2fvARB, table[_gloffset_MultiTexCoord2fvARB]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord2i, table[_gloffset_MultiTexCoord2i]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord2iv, table[_gloffset_MultiTexCoord2iv]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord2s, table[_gloffset_MultiTexCoord2s]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord2sv, table[_gloffset_MultiTexCoord2sv]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord3d, table[_gloffset_MultiTexCoord3d]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord3dv, table[_gloffset_MultiTexCoord3dv]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord3fARB, table[_gloffset_MultiTexCoord3fARB]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord3fvARB, table[_gloffset_MultiTexCoord3fvARB]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord3i, table[_gloffset_MultiTexCoord3i]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord3iv, table[_gloffset_MultiTexCoord3iv]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord3s, table[_gloffset_MultiTexCoord3s]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord3sv, table[_gloffset_MultiTexCoord3sv]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord4d, table[_gloffset_MultiTexCoord4d]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord4dv, table[_gloffset_MultiTexCoord4dv]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord4fARB, table[_gloffset_MultiTexCoord4fARB]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord4fvARB, table[_gloffset_MultiTexCoord4fvARB]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord4i, table[_gloffset_MultiTexCoord4i]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord4iv, table[_gloffset_MultiTexCoord4iv]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord4s, table[_gloffset_MultiTexCoord4s]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiTexCoord4sv, table[_gloffset_MultiTexCoord4sv]);
}
 
TEST_F(IndirectAPI, ARB_transpose_matrix)
{
EXPECT_EQ((_glapi_proc) __indirect_glLoadTransposeMatrixd, table[_glapi_get_proc_offset("glLoadTransposeMatrixdARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glLoadTransposeMatrixf, table[_glapi_get_proc_offset("glLoadTransposeMatrixfARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glMultTransposeMatrixd, table[_glapi_get_proc_offset("glMultTransposeMatrixdARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glMultTransposeMatrixf, table[_glapi_get_proc_offset("glMultTransposeMatrixfARB")]);
}
 
TEST_F(IndirectAPI, ARB_multisample)
{
EXPECT_EQ((_glapi_proc) __indirect_glSampleCoverage, table[_glapi_get_proc_offset("glSampleCoverageARB")]);
}
 
TEST_F(IndirectAPI, ARB_texture_compression)
{
EXPECT_EQ((_glapi_proc) __indirect_glCompressedTexImage1D, table[_glapi_get_proc_offset("glCompressedTexImage1DARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glCompressedTexImage2D, table[_glapi_get_proc_offset("glCompressedTexImage2DARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glCompressedTexImage3D, table[_glapi_get_proc_offset("glCompressedTexImage3DARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glCompressedTexSubImage1D, table[_glapi_get_proc_offset("glCompressedTexSubImage1DARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glCompressedTexSubImage2D, table[_glapi_get_proc_offset("glCompressedTexSubImage2DARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glCompressedTexSubImage3D, table[_glapi_get_proc_offset("glCompressedTexSubImage3DARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetCompressedTexImage, table[_glapi_get_proc_offset("glGetCompressedTexImageARB")]);
}
 
TEST_F(IndirectAPI, ARB_vertex_program)
{
EXPECT_EQ((_glapi_proc) __indirect_glDisableVertexAttribArray, table[_glapi_get_proc_offset("glDisableVertexAttribArrayARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glEnableVertexAttribArray, table[_glapi_get_proc_offset("glEnableVertexAttribArrayARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetProgramEnvParameterdvARB, table[_glapi_get_proc_offset("glGetProgramEnvParameterdvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetProgramEnvParameterfvARB, table[_glapi_get_proc_offset("glGetProgramEnvParameterfvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetProgramLocalParameterdvARB, table[_glapi_get_proc_offset("glGetProgramLocalParameterdvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetProgramLocalParameterfvARB, table[_glapi_get_proc_offset("glGetProgramLocalParameterfvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetProgramStringARB, table[_glapi_get_proc_offset("glGetProgramStringARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetProgramivARB, table[_glapi_get_proc_offset("glGetProgramivARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetVertexAttribdv, table[_glapi_get_proc_offset("glGetVertexAttribdvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetVertexAttribfv, table[_glapi_get_proc_offset("glGetVertexAttribfvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetVertexAttribiv, table[_glapi_get_proc_offset("glGetVertexAttribivARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramEnvParameter4dARB, table[_glapi_get_proc_offset("glProgramEnvParameter4dARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramEnvParameter4dvARB, table[_glapi_get_proc_offset("glProgramEnvParameter4dvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramEnvParameter4fARB, table[_glapi_get_proc_offset("glProgramEnvParameter4fARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramEnvParameter4fvARB, table[_glapi_get_proc_offset("glProgramEnvParameter4fvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramLocalParameter4dARB, table[_glapi_get_proc_offset("glProgramLocalParameter4dARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramLocalParameter4dvARB, table[_glapi_get_proc_offset("glProgramLocalParameter4dvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramLocalParameter4fARB, table[_glapi_get_proc_offset("glProgramLocalParameter4fARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramLocalParameter4fvARB, table[_glapi_get_proc_offset("glProgramLocalParameter4fvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramStringARB, table[_glapi_get_proc_offset("glProgramStringARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib1d, table[_glapi_get_proc_offset("glVertexAttrib1dARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib1dv, table[_glapi_get_proc_offset("glVertexAttrib1dvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib1fARB, table[_glapi_get_proc_offset("glVertexAttrib1fARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib1fvARB, table[_glapi_get_proc_offset("glVertexAttrib1fvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib1s, table[_glapi_get_proc_offset("glVertexAttrib1sARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib1sv, table[_glapi_get_proc_offset("glVertexAttrib1svARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib2d, table[_glapi_get_proc_offset("glVertexAttrib2dARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib2dv, table[_glapi_get_proc_offset("glVertexAttrib2dvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib2fARB, table[_glapi_get_proc_offset("glVertexAttrib2fARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib2fvARB, table[_glapi_get_proc_offset("glVertexAttrib2fvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib2s, table[_glapi_get_proc_offset("glVertexAttrib2sARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib2sv, table[_glapi_get_proc_offset("glVertexAttrib2svARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib3d, table[_glapi_get_proc_offset("glVertexAttrib3dARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib3dv, table[_glapi_get_proc_offset("glVertexAttrib3dvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib3fARB, table[_glapi_get_proc_offset("glVertexAttrib3fARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib3fvARB, table[_glapi_get_proc_offset("glVertexAttrib3fvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib3s, table[_glapi_get_proc_offset("glVertexAttrib3sARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib3sv, table[_glapi_get_proc_offset("glVertexAttrib3svARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4Nbv, table[_glapi_get_proc_offset("glVertexAttrib4NbvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4Niv, table[_glapi_get_proc_offset("glVertexAttrib4NivARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4Nsv, table[_glapi_get_proc_offset("glVertexAttrib4NsvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4Nub, table[_glapi_get_proc_offset("glVertexAttrib4NubARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4Nubv, table[_glapi_get_proc_offset("glVertexAttrib4NubvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4Nuiv, table[_glapi_get_proc_offset("glVertexAttrib4NuivARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4Nusv, table[_glapi_get_proc_offset("glVertexAttrib4NusvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4bv, table[_glapi_get_proc_offset("glVertexAttrib4bvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4d, table[_glapi_get_proc_offset("glVertexAttrib4dARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4dv, table[_glapi_get_proc_offset("glVertexAttrib4dvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4fARB, table[_glapi_get_proc_offset("glVertexAttrib4fARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4fvARB, table[_glapi_get_proc_offset("glVertexAttrib4fvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4iv, table[_glapi_get_proc_offset("glVertexAttrib4ivARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4s, table[_glapi_get_proc_offset("glVertexAttrib4sARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4sv, table[_glapi_get_proc_offset("glVertexAttrib4svARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4ubv, table[_glapi_get_proc_offset("glVertexAttrib4ubvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4uiv, table[_glapi_get_proc_offset("glVertexAttrib4uivARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4usv, table[_glapi_get_proc_offset("glVertexAttrib4usvARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribPointer, table[_glapi_get_proc_offset("glVertexAttribPointerARB")]);
}
 
TEST_F(IndirectAPI, ARB_occlusion_query)
{
EXPECT_EQ((_glapi_proc) __indirect_glBeginQuery, table[_glapi_get_proc_offset("glBeginQueryARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glDeleteQueries, table[_glapi_get_proc_offset("glDeleteQueriesARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glEndQuery, table[_glapi_get_proc_offset("glEndQueryARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glGenQueries, table[_glapi_get_proc_offset("glGenQueriesARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetQueryObjectiv, table[_glapi_get_proc_offset("glGetQueryObjectivARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetQueryObjectuiv, table[_glapi_get_proc_offset("glGetQueryObjectuivARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetQueryiv, table[_glapi_get_proc_offset("glGetQueryivARB")]);
EXPECT_EQ((_glapi_proc) __indirect_glIsQuery, table[_glapi_get_proc_offset("glIsQueryARB")]);
}
 
TEST_F(IndirectAPI, ARB_draw_buffers)
{
EXPECT_EQ((_glapi_proc) __indirect_glDrawBuffers, table[_glapi_get_proc_offset("glDrawBuffersARB")]);
}
 
TEST_F(IndirectAPI, ARB_color_buffer_float)
{
EXPECT_EQ((_glapi_proc) __indirect_glClampColor, table[_glapi_get_proc_offset("glClampColorARB")]);
}
 
TEST_F(IndirectAPI, ARB_framebuffer_object)
{
EXPECT_EQ((_glapi_proc) __indirect_glRenderbufferStorageMultisample, table[_glapi_get_proc_offset("glRenderbufferStorageMultisample")]);
}
 
TEST_F(IndirectAPI, SGIS_multisample)
{
EXPECT_EQ((_glapi_proc) __indirect_glSampleMaskSGIS, table[_glapi_get_proc_offset("glSampleMaskSGIS")]);
EXPECT_EQ((_glapi_proc) __indirect_glSamplePatternSGIS, table[_glapi_get_proc_offset("glSamplePatternSGIS")]);
}
 
TEST_F(IndirectAPI, EXT_vertex_array)
{
EXPECT_EQ((_glapi_proc) __indirect_glColorPointerEXT, table[_glapi_get_proc_offset("glColorPointerEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glEdgeFlagPointerEXT, table[_glapi_get_proc_offset("glEdgeFlagPointerEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glIndexPointerEXT, table[_glapi_get_proc_offset("glIndexPointerEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glNormalPointerEXT, table[_glapi_get_proc_offset("glNormalPointerEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glTexCoordPointerEXT, table[_glapi_get_proc_offset("glTexCoordPointerEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexPointerEXT, table[_glapi_get_proc_offset("glVertexPointerEXT")]);
}
 
TEST_F(IndirectAPI, EXT_point_parameters)
{
EXPECT_EQ((_glapi_proc) __indirect_glPointParameterf, table[_glapi_get_proc_offset("glPointParameterfEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glPointParameterfv, table[_glapi_get_proc_offset("glPointParameterfvEXT")]);
}
 
TEST_F(IndirectAPI, EXT_secondary_color)
{
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3b, table[_glapi_get_proc_offset("glSecondaryColor3bEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3bv, table[_glapi_get_proc_offset("glSecondaryColor3bvEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3d, table[_glapi_get_proc_offset("glSecondaryColor3dEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3dv, table[_glapi_get_proc_offset("glSecondaryColor3dvEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3fEXT, table[_glapi_get_proc_offset("glSecondaryColor3fEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3fvEXT, table[_glapi_get_proc_offset("glSecondaryColor3fvEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3i, table[_glapi_get_proc_offset("glSecondaryColor3iEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3iv, table[_glapi_get_proc_offset("glSecondaryColor3ivEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3s, table[_glapi_get_proc_offset("glSecondaryColor3sEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3sv, table[_glapi_get_proc_offset("glSecondaryColor3svEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3ub, table[_glapi_get_proc_offset("glSecondaryColor3ubEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3ubv, table[_glapi_get_proc_offset("glSecondaryColor3ubvEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3ui, table[_glapi_get_proc_offset("glSecondaryColor3uiEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3uiv, table[_glapi_get_proc_offset("glSecondaryColor3uivEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3us, table[_glapi_get_proc_offset("glSecondaryColor3usEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColor3usv, table[_glapi_get_proc_offset("glSecondaryColor3usvEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glSecondaryColorPointer, table[_glapi_get_proc_offset("glSecondaryColorPointerEXT")]);
}
 
TEST_F(IndirectAPI, EXT_multi_draw_arrays)
{
EXPECT_EQ((_glapi_proc) __indirect_glMultiDrawArrays, table[_glapi_get_proc_offset("glMultiDrawArraysEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glMultiDrawElementsEXT, table[_glapi_get_proc_offset("glMultiDrawElementsEXT")]);
}
 
TEST_F(IndirectAPI, EXT_fog_coord)
{
EXPECT_EQ((_glapi_proc) __indirect_glFogCoordPointer, table[_glapi_get_proc_offset("glFogCoordPointerEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glFogCoordd, table[_glapi_get_proc_offset("glFogCoorddEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glFogCoorddv, table[_glapi_get_proc_offset("glFogCoorddvEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glFogCoordfEXT, table[_glapi_get_proc_offset("glFogCoordfEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glFogCoordfvEXT, table[_glapi_get_proc_offset("glFogCoordfvEXT")]);
}
 
TEST_F(IndirectAPI, EXT_blend_func_separate)
{
EXPECT_EQ((_glapi_proc) __indirect_glBlendFuncSeparate, table[_glapi_get_proc_offset("glBlendFuncSeparateEXT")]);
}
 
TEST_F(IndirectAPI, MESA_window_pos)
{
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos2d, table[_glapi_get_proc_offset("glWindowPos2dMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos2dv, table[_glapi_get_proc_offset("glWindowPos2dvMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos2f, table[_glapi_get_proc_offset("glWindowPos2fMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos2fv, table[_glapi_get_proc_offset("glWindowPos2fvMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos2i, table[_glapi_get_proc_offset("glWindowPos2iMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos2iv, table[_glapi_get_proc_offset("glWindowPos2ivMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos2s, table[_glapi_get_proc_offset("glWindowPos2sMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos2sv, table[_glapi_get_proc_offset("glWindowPos2svMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos3d, table[_glapi_get_proc_offset("glWindowPos3dMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos3dv, table[_glapi_get_proc_offset("glWindowPos3dvMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos3f, table[_glapi_get_proc_offset("glWindowPos3fMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos3fv, table[_glapi_get_proc_offset("glWindowPos3fvMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos3i, table[_glapi_get_proc_offset("glWindowPos3iMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos3iv, table[_glapi_get_proc_offset("glWindowPos3ivMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos3s, table[_glapi_get_proc_offset("glWindowPos3sMESA")]);
EXPECT_EQ((_glapi_proc) __indirect_glWindowPos3sv, table[_glapi_get_proc_offset("glWindowPos3svMESA")]);
}
 
TEST_F(IndirectAPI, NV_vertex_program)
{
EXPECT_EQ((_glapi_proc) __indirect_glAreProgramsResidentNV, table[_glapi_get_proc_offset("glAreProgramsResidentNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glBindProgramARB, table[_glapi_get_proc_offset("glBindProgramNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glDeleteProgramsARB, table[_glapi_get_proc_offset("glDeleteProgramsNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glExecuteProgramNV, table[_glapi_get_proc_offset("glExecuteProgramNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glGenProgramsARB, table[_glapi_get_proc_offset("glGenProgramsNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetProgramParameterdvNV, table[_glapi_get_proc_offset("glGetProgramParameterdvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetProgramParameterfvNV, table[_glapi_get_proc_offset("glGetProgramParameterfvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetProgramStringNV, table[_glapi_get_proc_offset("glGetProgramStringNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetProgramivNV, table[_glapi_get_proc_offset("glGetProgramivNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetTrackMatrixivNV, table[_glapi_get_proc_offset("glGetTrackMatrixivNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetVertexAttribPointerv, table[_glapi_get_proc_offset("glGetVertexAttribPointervNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetVertexAttribdvNV, table[_glapi_get_proc_offset("glGetVertexAttribdvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetVertexAttribfvNV, table[_glapi_get_proc_offset("glGetVertexAttribfvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetVertexAttribivNV, table[_glapi_get_proc_offset("glGetVertexAttribivNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glIsProgramARB, table[_glapi_get_proc_offset("glIsProgramNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glLoadProgramNV, table[_glapi_get_proc_offset("glLoadProgramNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramParameters4dvNV, table[_glapi_get_proc_offset("glProgramParameters4dvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramParameters4fvNV, table[_glapi_get_proc_offset("glProgramParameters4fvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glRequestResidentProgramsNV, table[_glapi_get_proc_offset("glRequestResidentProgramsNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glTrackMatrixNV, table[_glapi_get_proc_offset("glTrackMatrixNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib1dNV, table[_glapi_get_proc_offset("glVertexAttrib1dNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib1dvNV, table[_glapi_get_proc_offset("glVertexAttrib1dvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib1fNV, table[_glapi_get_proc_offset("glVertexAttrib1fNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib1fvNV, table[_glapi_get_proc_offset("glVertexAttrib1fvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib1sNV, table[_glapi_get_proc_offset("glVertexAttrib1sNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib1svNV, table[_glapi_get_proc_offset("glVertexAttrib1svNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib2dNV, table[_glapi_get_proc_offset("glVertexAttrib2dNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib2dvNV, table[_glapi_get_proc_offset("glVertexAttrib2dvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib2fNV, table[_glapi_get_proc_offset("glVertexAttrib2fNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib2fvNV, table[_glapi_get_proc_offset("glVertexAttrib2fvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib2sNV, table[_glapi_get_proc_offset("glVertexAttrib2sNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib2svNV, table[_glapi_get_proc_offset("glVertexAttrib2svNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib3dNV, table[_glapi_get_proc_offset("glVertexAttrib3dNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib3dvNV, table[_glapi_get_proc_offset("glVertexAttrib3dvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib3fNV, table[_glapi_get_proc_offset("glVertexAttrib3fNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib3fvNV, table[_glapi_get_proc_offset("glVertexAttrib3fvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib3sNV, table[_glapi_get_proc_offset("glVertexAttrib3sNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib3svNV, table[_glapi_get_proc_offset("glVertexAttrib3svNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4dNV, table[_glapi_get_proc_offset("glVertexAttrib4dNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4dvNV, table[_glapi_get_proc_offset("glVertexAttrib4dvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4fNV, table[_glapi_get_proc_offset("glVertexAttrib4fNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4fvNV, table[_glapi_get_proc_offset("glVertexAttrib4fvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4sNV, table[_glapi_get_proc_offset("glVertexAttrib4sNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4svNV, table[_glapi_get_proc_offset("glVertexAttrib4svNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4ubNV, table[_glapi_get_proc_offset("glVertexAttrib4ubNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttrib4ubvNV, table[_glapi_get_proc_offset("glVertexAttrib4ubvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribPointerNV, table[_glapi_get_proc_offset("glVertexAttribPointerNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribs1dvNV, table[_glapi_get_proc_offset("glVertexAttribs1dvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribs1fvNV, table[_glapi_get_proc_offset("glVertexAttribs1fvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribs1svNV, table[_glapi_get_proc_offset("glVertexAttribs1svNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribs2dvNV, table[_glapi_get_proc_offset("glVertexAttribs2dvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribs2fvNV, table[_glapi_get_proc_offset("glVertexAttribs2fvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribs2svNV, table[_glapi_get_proc_offset("glVertexAttribs2svNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribs3dvNV, table[_glapi_get_proc_offset("glVertexAttribs3dvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribs3fvNV, table[_glapi_get_proc_offset("glVertexAttribs3fvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribs3svNV, table[_glapi_get_proc_offset("glVertexAttribs3svNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribs4dvNV, table[_glapi_get_proc_offset("glVertexAttribs4dvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribs4fvNV, table[_glapi_get_proc_offset("glVertexAttribs4fvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribs4svNV, table[_glapi_get_proc_offset("glVertexAttribs4svNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glVertexAttribs4ubvNV, table[_glapi_get_proc_offset("glVertexAttribs4ubvNV")]);
}
 
TEST_F(IndirectAPI, NV_point_sprite)
{
EXPECT_EQ((_glapi_proc) __indirect_glPointParameteri, table[_glapi_get_proc_offset("glPointParameteriNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glPointParameteriv, table[_glapi_get_proc_offset("glPointParameterivNV")]);
}
 
TEST_F(IndirectAPI, EXT_stencil_two_side)
{
EXPECT_EQ((_glapi_proc) __indirect_glActiveStencilFaceEXT, table[_glapi_get_proc_offset("glActiveStencilFaceEXT")]);
}
 
TEST_F(IndirectAPI, NV_fragment_program)
{
EXPECT_EQ((_glapi_proc) __indirect_glGetProgramNamedParameterdvNV, table[_glapi_get_proc_offset("glGetProgramNamedParameterdvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetProgramNamedParameterfvNV, table[_glapi_get_proc_offset("glGetProgramNamedParameterfvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramNamedParameter4dNV, table[_glapi_get_proc_offset("glProgramNamedParameter4dNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramNamedParameter4dvNV, table[_glapi_get_proc_offset("glProgramNamedParameter4dvNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramNamedParameter4fNV, table[_glapi_get_proc_offset("glProgramNamedParameter4fNV")]);
EXPECT_EQ((_glapi_proc) __indirect_glProgramNamedParameter4fvNV, table[_glapi_get_proc_offset("glProgramNamedParameter4fvNV")]);
}
 
TEST_F(IndirectAPI, EXT_blend_equation_separate)
{
EXPECT_EQ((_glapi_proc) __indirect_glBlendEquationSeparate, table[_glapi_get_proc_offset("glBlendEquationSeparateEXT")]);
}
 
TEST_F(IndirectAPI, EXT_framebuffer_object)
{
EXPECT_EQ((_glapi_proc) __indirect_glBindFramebufferEXT, table[_glapi_get_proc_offset("glBindFramebufferEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glBindRenderbufferEXT, table[_glapi_get_proc_offset("glBindRenderbufferEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glBindFramebuffer, table[_glapi_get_proc_offset("glBindFramebuffer")]);
EXPECT_EQ((_glapi_proc) __indirect_glBindRenderbuffer, table[_glapi_get_proc_offset("glBindRenderbuffer")]);
EXPECT_EQ((_glapi_proc) __indirect_glCheckFramebufferStatus, table[_glapi_get_proc_offset("glCheckFramebufferStatusEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glDeleteFramebuffers, table[_glapi_get_proc_offset("glDeleteFramebuffersEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glDeleteRenderbuffers, table[_glapi_get_proc_offset("glDeleteRenderbuffersEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glFramebufferRenderbuffer, table[_glapi_get_proc_offset("glFramebufferRenderbufferEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glFramebufferTexture1D, table[_glapi_get_proc_offset("glFramebufferTexture1DEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glFramebufferTexture2D, table[_glapi_get_proc_offset("glFramebufferTexture2DEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glFramebufferTexture3D, table[_glapi_get_proc_offset("glFramebufferTexture3DEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glGenFramebuffers, table[_glapi_get_proc_offset("glGenFramebuffersEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glGenRenderbuffers, table[_glapi_get_proc_offset("glGenRenderbuffersEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glGenerateMipmap, table[_glapi_get_proc_offset("glGenerateMipmapEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetFramebufferAttachmentParameteriv, table[_glapi_get_proc_offset("glGetFramebufferAttachmentParameterivEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glGetRenderbufferParameteriv, table[_glapi_get_proc_offset("glGetRenderbufferParameterivEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glIsFramebuffer, table[_glapi_get_proc_offset("glIsFramebufferEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glIsRenderbuffer, table[_glapi_get_proc_offset("glIsRenderbufferEXT")]);
EXPECT_EQ((_glapi_proc) __indirect_glRenderbufferStorage, table[_glapi_get_proc_offset("glRenderbufferStorageEXT")]);
}
 
TEST_F(IndirectAPI, EXT_framebuffer_blit)
{
EXPECT_EQ((_glapi_proc) __indirect_glBlitFramebuffer, table[_glapi_get_proc_offset("glBlitFramebufferEXT")]);
}
 
TEST_F(IndirectAPI, EXT_texture_array)
{
EXPECT_EQ((_glapi_proc) __indirect_glFramebufferTextureLayer, table[_glapi_get_proc_offset("glFramebufferTextureLayerEXT")]);
}
/contrib/sdk/sources/Mesa/src/glx/tests/mock_xdisplay.h
0,0 → 1,32
/*
* Copyright © 2011 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <X11/X.h>
 
class mock_XDisplay : public _XDisplay {
public:
mock_XDisplay(int nscreens)
{
memset(this, 0, sizeof(struct _XDisplay));
this->nscreens = nscreens;
}
};
/contrib/sdk/sources/Mesa/src/glx/vertarr.c
0,0 → 1,212
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
 
#include "glxclient.h"
#include "indirect.h"
#include "indirect_vertex_array.h"
 
 
/*****************************************************************************/
 
/**
* \name Vertex array pointer bridge functions
*
* When EXT_vertex_array was moved into the core GL spec, the \c count
* parameter was lost. This libGL really only wants to implement the GL 1.1
* version, but we need to support applications that were written to the old
* interface. These bridge functions are part of the glue that makes this
* happen.
*/
/*@{*/
void
__indirect_glColorPointerEXT(GLint size, GLenum type, GLsizei stride,
GLsizei count, const GLvoid * pointer)
{
(void) count;
__indirect_glColorPointer(size, type, stride, pointer);
}
 
void
__indirect_glEdgeFlagPointerEXT(GLsizei stride,
GLsizei count, const GLboolean * pointer)
{
(void) count;
__indirect_glEdgeFlagPointer(stride, pointer);
}
 
void
__indirect_glIndexPointerEXT(GLenum type, GLsizei stride,
GLsizei count, const GLvoid * pointer)
{
(void) count;
__indirect_glIndexPointer(type, stride, pointer);
}
 
void
__indirect_glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
const GLvoid * pointer)
{
(void) count;
__indirect_glNormalPointer(type, stride, pointer);
}
 
void
__indirect_glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
GLsizei count, const GLvoid * pointer)
{
(void) count;
__indirect_glTexCoordPointer(size, type, stride, pointer);
}
 
void
__indirect_glVertexPointerEXT(GLint size, GLenum type, GLsizei stride,
GLsizei count, const GLvoid * pointer)
{
(void) count;
__indirect_glVertexPointer(size, type, stride, pointer);
}
 
/*@}*/
 
/*****************************************************************************/
 
void
__indirect_glInterleavedArrays(GLenum format, GLsizei stride,
const GLvoid * pointer)
{
struct glx_context *gc = __glXGetCurrentContext();
__GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
 
#define NONE {0, 0, 0}
#define F(x) {GL_FLOAT, x, x * sizeof(GLfloat)}
#define UB4 {GL_UNSIGNED_BYTE, 4, 4 * sizeof(GLubyte)}
 
/* Each row in this array describes the elements of a particular
* interleaved array mode. Each column describes, in the order in which
* they appear in the interleaved arrays, one of the four possible types
* of vertex data that can appear in an interleaved array.
*/
struct
{
/**
* The enum describing the GL type, as would be passed to the
* appropriate gl*Pointer function.
*/
GLushort type;
 
/**
* Number of elements in the subarray, as would be passed (as the
* \c size parameter) to the appropriate gl*Pointer function.
*/
GLubyte count;
 
/**
* True size of a single element in the subarray, as would be passed
* (as the \c stride parameter) to the appropriate gl*Pointer
* function.
*/
GLubyte size;
}
static const modes[14][4] = {
/* texture color normal vertex */
{NONE, NONE, NONE, F(2)}, /* GL_V2F */
{NONE, NONE, NONE, F(3)}, /* GL_V3F */
{NONE, UB4, NONE, F(2)}, /* GL_C4UB_V2F */
{NONE, UB4, NONE, F(3)}, /* GL_C4UB_V3F */
{NONE, F(3), NONE, F(3)}, /* GL_C3F_V3F */
{NONE, NONE, F(3), F(3)}, /* GL_N3F_V3F */
{NONE, F(4), F(3), F(3)}, /* GL_C4F_N3F_V3F */
{F(2), NONE, NONE, F(3)}, /* GL_T2F_V3F */
{F(4), NONE, NONE, F(4)}, /* GL_T4F_V4F */
{F(2), UB4, NONE, F(3)}, /* GL_T2F_C4UB_V3F */
{F(2), F(3), NONE, F(3)}, /* GL_T2F_C3F_V3F */
{F(2), NONE, F(3), F(3)}, /* GL_T2F_N3F_V3F */
{F(2), F(4), F(3), F(3)}, /* GL_T2F_C4F_N3F_V3F */
{F(4), F(4), F(3), F(4)}, /* GL_T4F_C4F_N3F_V4F */
};
#undef NONE
#undef F
#undef UB4
 
GLint trueStride, size;
int offsets[4];
unsigned i;
const int idx = format - GL_V2F;
 
 
/* All valid formats are on the range [GL_V2F, GL_V2F+0x0D]. Since idx
* is just the format biased by -GL_V2F, all valid idx values are on the
* range [0, 0x0D].
*/
if ((idx < 0) || (idx > 0x0D)) {
__glXSetError(gc, GL_INVALID_ENUM);
return;
}
 
if (stride < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
}
 
 
/* If the 'count' for a subarray is non-zero, then the offset of its
* first element is at the currently accumulated 'size'.
*/
size = 0;
for (i = 0; i < 4; i++) {
offsets[i] = (modes[idx][i].count != 0) ? size : -1;
size += modes[idx][i].size;
}
 
trueStride = (stride == 0) ? size : stride;
 
__glXArrayDisableAll(state);
 
if (offsets[0] >= 0) {
__indirect_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
__indirect_glTexCoordPointer(modes[idx][0].count, GL_FLOAT,
trueStride, (const char *) pointer);
}
if (offsets[1] >= 0) {
__indirect_glEnableClientState(GL_COLOR_ARRAY);
__indirect_glColorPointer(modes[idx][1].count, modes[idx][1].type,
trueStride,
(const char *) pointer + offsets[1]);
}
if (offsets[2] >= 0) {
__indirect_glEnableClientState(GL_NORMAL_ARRAY);
__indirect_glNormalPointer(GL_FLOAT, trueStride,
(const char *) pointer + offsets[2]);
}
__indirect_glEnableClientState(GL_VERTEX_ARRAY);
__indirect_glVertexPointer(modes[idx][3].count, GL_FLOAT,
trueStride,
(const char *) pointer + offsets[3]);
}
/contrib/sdk/sources/Mesa/src/glx/xf86dri.h
0,0 → 1,124
/**************************************************************************
 
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, 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 PRECISION INSIGHT 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.
 
**************************************************************************/
 
/**
* \file xf86dri.h
* Protocol numbers and function prototypes for DRI X protocol.
*
* \author Kevin E. Martin <martin@valinux.com>
* \author Jens Owen <jens@tungstengraphics.com>
* \author Rickard E. (Rik) Faith <faith@valinux.com>
*/
 
#ifndef _XF86DRI_H_
#define _XF86DRI_H_
 
#include <X11/Xfuncproto.h>
#include <xf86drm.h>
 
#define X_XF86DRIQueryVersion 0
#define X_XF86DRIQueryDirectRenderingCapable 1
#define X_XF86DRIOpenConnection 2
#define X_XF86DRICloseConnection 3
#define X_XF86DRIGetClientDriverName 4
#define X_XF86DRICreateContext 5
#define X_XF86DRIDestroyContext 6
#define X_XF86DRICreateDrawable 7
#define X_XF86DRIDestroyDrawable 8
#define X_XF86DRIGetDrawableInfo 9
#define X_XF86DRIGetDeviceInfo 10
#define X_XF86DRIAuthConnection 11
#define X_XF86DRIOpenFullScreen 12 /* Deprecated */
#define X_XF86DRICloseFullScreen 13 /* Deprecated */
 
#define XF86DRINumberEvents 0
 
#define XF86DRIClientNotLocal 0
#define XF86DRIOperationNotSupported 1
#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1)
 
#ifndef _XF86DRI_SERVER_
 
_XFUNCPROTOBEGIN
Bool XF86DRIQueryExtension(Display * dpy, int *event_base,
int *error_base);
 
Bool XF86DRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion,
int *patchVersion);
 
Bool XF86DRIQueryDirectRenderingCapable(Display * dpy, int screen,
Bool * isCapable);
 
Bool XF86DRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA,
char **busIDString);
 
Bool XF86DRIAuthConnection(Display * dpy, int screen, drm_magic_t magic);
 
Bool XF86DRICloseConnection(Display * dpy, int screen);
 
Bool XF86DRIGetClientDriverName(Display * dpy, int screen,
int *ddxDriverMajorVersion,
int *ddxDriverMinorVersion,
int *ddxDriverPatchVersion,
char **clientDriverName);
 
Bool XF86DRICreateContext(Display * dpy, int screen, Visual * visual,
XID * ptr_to_returned_context_id,
drm_context_t * hHWContext);
 
Bool XF86DRICreateContextWithConfig(Display * dpy, int screen, int configID,
XID * ptr_to_returned_context_id,
drm_context_t * hHWContext);
 
extern Bool XF86DRIDestroyContext(Display * dpy, int screen, XID context_id);
 
extern Bool XF86DRICreateDrawable(Display * dpy, int screen,
XID drawable, drm_drawable_t * hHWDrawable);
 
extern Bool XF86DRIDestroyDrawable(Display * dpy, int screen, XID drawable);
 
Bool XF86DRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable,
unsigned int *index, unsigned int *stamp,
int *X, int *Y, int *W, int *H,
int *numClipRects, drm_clip_rect_t ** pClipRects,
int *backX, int *backY,
int *numBackClipRects,
drm_clip_rect_t ** pBackClipRects);
 
Bool XF86DRIGetDeviceInfo(Display * dpy, int screen,
drm_handle_t * hFrameBuffer, int *fbOrigin,
int *fbSize, int *fbStride, int *devPrivateSize,
void **pDevPrivate);
 
Bool XF86DRIOpenFullScreen(Display * dpy, int screen, Drawable drawable);
 
Bool XF86DRICloseFullScreen(Display * dpy, int screen, Drawable drawable);
 
_XFUNCPROTOEND
#endif /* _XF86DRI_SERVER_ */
#endif /* _XF86DRI_H_ */
/contrib/sdk/sources/Mesa/src/glx/xf86dristr.h
0,0 → 1,367
/**************************************************************************
 
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
Copyright 2000 VA Linux Systems, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
**************************************************************************/
 
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Jens Owen <jens@tungstengraphics.com>
* Rickard E. (Rik) Fiath <faith@valinux.com>
*
*/
 
#ifndef _XF86DRISTR_H_
#define _XF86DRISTR_H_
 
#include "xf86dri.h"
 
#define XF86DRINAME "XFree86-DRI"
 
/* The DRI version number. This was originally set to be the same of the
* XFree86 version number. However, this version is really indepedent of
* the XFree86 version.
*
* Version History:
* 4.0.0: Original
* 4.0.1: Patch to bump clipstamp when windows are destroyed, 28 May 02
* 4.1.0: Add transition from single to multi in DRMInfo rec, 24 Jun 02
*/
#define XF86DRI_MAJOR_VERSION 4
#define XF86DRI_MINOR_VERSION 1
#define XF86DRI_PATCH_VERSION 0
 
typedef struct _XF86DRIQueryVersion
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIQueryVersion */
CARD16 length B16;
} xXF86DRIQueryVersionReq;
#define sz_xXF86DRIQueryVersionReq 4
 
typedef struct
{
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD16 majorVersion B16; /* major version of DRI protocol */
CARD16 minorVersion B16; /* minor version of DRI protocol */
CARD32 patchVersion B32; /* patch version of DRI protocol */
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xXF86DRIQueryVersionReply;
#define sz_xXF86DRIQueryVersionReply 32
 
typedef struct _XF86DRIQueryDirectRenderingCapable
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
CARD16 length B16;
CARD32 screen B32;
} xXF86DRIQueryDirectRenderingCapableReq;
#define sz_xXF86DRIQueryDirectRenderingCapableReq 8
 
typedef struct
{
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
BOOL isCapable;
BOOL pad2;
BOOL pad3;
BOOL pad4;
CARD32 pad5 B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
CARD32 pad8 B32;
CARD32 pad9 B32;
} xXF86DRIQueryDirectRenderingCapableReply;
#define sz_xXF86DRIQueryDirectRenderingCapableReply 32
 
typedef struct _XF86DRIOpenConnection
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIOpenConnection */
CARD16 length B16;
CARD32 screen B32;
} xXF86DRIOpenConnectionReq;
#define sz_xXF86DRIOpenConnectionReq 8
 
typedef struct
{
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 hSAREALow B32;
CARD32 hSAREAHigh B32;
CARD32 busIdStringLength B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
CARD32 pad8 B32;
} xXF86DRIOpenConnectionReply;
#define sz_xXF86DRIOpenConnectionReply 32
 
typedef struct _XF86DRIAuthConnection
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICloseConnection */
CARD16 length B16;
CARD32 screen B32;
CARD32 magic B32;
} xXF86DRIAuthConnectionReq;
#define sz_xXF86DRIAuthConnectionReq 12
 
typedef struct
{
BYTE type;
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 authenticated B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xXF86DRIAuthConnectionReply;
#define zx_xXF86DRIAuthConnectionReply 32
 
typedef struct _XF86DRICloseConnection
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICloseConnection */
CARD16 length B16;
CARD32 screen B32;
} xXF86DRICloseConnectionReq;
#define sz_xXF86DRICloseConnectionReq 8
 
typedef struct _XF86DRIGetClientDriverName
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIGetClientDriverName */
CARD16 length B16;
CARD32 screen B32;
} xXF86DRIGetClientDriverNameReq;
#define sz_xXF86DRIGetClientDriverNameReq 8
 
typedef struct
{
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 ddxDriverMajorVersion B32;
CARD32 ddxDriverMinorVersion B32;
CARD32 ddxDriverPatchVersion B32;
CARD32 clientDriverNameLength B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xXF86DRIGetClientDriverNameReply;
#define sz_xXF86DRIGetClientDriverNameReply 32
 
typedef struct _XF86DRICreateContext
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICreateContext */
CARD16 length B16;
CARD32 screen B32;
CARD32 visual B32;
CARD32 context B32;
} xXF86DRICreateContextReq;
#define sz_xXF86DRICreateContextReq 16
 
typedef struct
{
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 hHWContext B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xXF86DRICreateContextReply;
#define sz_xXF86DRICreateContextReply 32
 
typedef struct _XF86DRIDestroyContext
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIDestroyContext */
CARD16 length B16;
CARD32 screen B32;
CARD32 context B32;
} xXF86DRIDestroyContextReq;
#define sz_xXF86DRIDestroyContextReq 12
 
typedef struct _XF86DRICreateDrawable
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICreateDrawable */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xXF86DRICreateDrawableReq;
#define sz_xXF86DRICreateDrawableReq 12
 
typedef struct
{
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 hHWDrawable B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xXF86DRICreateDrawableReply;
#define sz_xXF86DRICreateDrawableReply 32
 
typedef struct _XF86DRIDestroyDrawable
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIDestroyDrawable */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xXF86DRIDestroyDrawableReq;
#define sz_xXF86DRIDestroyDrawableReq 12
 
typedef struct _XF86DRIGetDrawableInfo
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIGetDrawableInfo */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xXF86DRIGetDrawableInfoReq;
#define sz_xXF86DRIGetDrawableInfoReq 12
 
typedef struct
{
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 drawableTableIndex B32;
CARD32 drawableTableStamp B32;
INT16 drawableX B16;
INT16 drawableY B16;
INT16 drawableWidth B16;
INT16 drawableHeight B16;
CARD32 numClipRects B32;
INT16 backX B16;
INT16 backY B16;
CARD32 numBackClipRects B32;
} xXF86DRIGetDrawableInfoReply;
 
#define sz_xXF86DRIGetDrawableInfoReply 36
 
 
typedef struct _XF86DRIGetDeviceInfo
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIGetDeviceInfo */
CARD16 length B16;
CARD32 screen B32;
} xXF86DRIGetDeviceInfoReq;
#define sz_xXF86DRIGetDeviceInfoReq 8
 
typedef struct
{
BYTE type; /* X_Reply */
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 hFrameBufferLow B32;
CARD32 hFrameBufferHigh B32;
CARD32 framebufferOrigin B32;
CARD32 framebufferSize B32;
CARD32 framebufferStride B32;
CARD32 devPrivateSize B32;
} xXF86DRIGetDeviceInfoReply;
#define sz_xXF86DRIGetDeviceInfoReply 32
 
typedef struct _XF86DRIOpenFullScreen
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRIOpenFullScreen */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xXF86DRIOpenFullScreenReq;
#define sz_xXF86DRIOpenFullScreenReq 12
 
typedef struct
{
BYTE type;
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 isFullScreen B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
} xXF86DRIOpenFullScreenReply;
#define sz_xXF86DRIOpenFullScreenReply 32
 
typedef struct _XF86DRICloseFullScreen
{
CARD8 reqType; /* always DRIReqCode */
CARD8 driReqType; /* always X_DRICloseFullScreen */
CARD16 length B16;
CARD32 screen B32;
CARD32 drawable B32;
} xXF86DRICloseFullScreenReq;
#define sz_xXF86DRICloseFullScreenReq 12
 
typedef struct
{
BYTE type;
BOOL pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 pad2 B32;
CARD32 pad3 B32;
CARD32 pad4 B32;
CARD32 pad5 B32;
CARD32 pad6 B32;
CARD32 pad7 B32;
} xXF86DRICloseFullScreenReply;
#define sz_xXF86DRICloseFullScreenReply 32
 
 
#endif /* _XF86DRISTR_H_ */
/contrib/sdk/sources/Mesa/src/glx/xfont.c
0,0 → 1,375
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
 
 
/* xfonts.c -- glXUseXFont() for Mesa written by
* Copyright (C) 1995 Thorsten.Ohl @ Physik.TH-Darmstadt.de
*/
 
/*
This was take from Mesa and modified to work in the real GLX structure.
It provides a fully client side implementation of glXUseXFont and is
called by that routine when direct rendering is enabled.
*/
 
#ifdef GLX_DIRECT_RENDERING
 
#include "glxclient.h"
 
/* Some debugging info. */
 
#ifdef DEBUG
#undef _R
#undef _G
#undef _B
#include <ctype.h>
 
int debug_xfonts = 0;
 
static void
dump_char_struct(XCharStruct * ch, char *prefix)
{
printf("%slbearing = %d, rbearing = %d, width = %d\n",
prefix, ch->lbearing, ch->rbearing, ch->width);
printf("%sascent = %d, descent = %d, attributes = %u\n",
prefix, ch->ascent, ch->descent, (unsigned int) ch->attributes);
}
 
static void
dump_font_struct(XFontStruct * font)
{
printf("ascent = %d, descent = %d\n", font->ascent, font->descent);
printf("char_or_byte2 = (%u,%u)\n",
font->min_char_or_byte2, font->max_char_or_byte2);
printf("byte1 = (%u,%u)\n", font->min_byte1, font->max_byte1);
printf("all_chars_exist = %s\n", font->all_chars_exist ? "True" : "False");
printf("default_char = %c (\\%03o)\n",
(char) (isprint(font->default_char) ? font->default_char : ' '),
font->default_char);
dump_char_struct(&font->min_bounds, "min> ");
dump_char_struct(&font->max_bounds, "max> ");
#if 0
for (c = font->min_char_or_byte2; c <= font->max_char_or_byte2; c++) {
char prefix[8];
sprintf(prefix, "%d> ", c);
dump_char_struct(&font->per_char[c], prefix);
}
#endif
}
 
static void
dump_bitmap(unsigned int width, unsigned int height, GLubyte * bitmap)
{
unsigned int x, y;
 
printf(" ");
for (x = 0; x < 8 * width; x++)
printf("%o", 7 - (x % 8));
putchar('\n');
for (y = 0; y < height; y++) {
printf("%3o:", y);
for (x = 0; x < 8 * width; x++)
putchar((bitmap[width * (height - y - 1) + x / 8] & (1 << (7 - (x %
8))))
? '*' : '.');
printf(" ");
for (x = 0; x < width; x++)
printf("0x%02x, ", bitmap[width * (height - y - 1) + x]);
putchar('\n');
}
}
#endif /* DEBUG */
 
 
/* Implementation. */
 
/* Fill a BITMAP with a character C from thew current font
in the graphics context GC. WIDTH is the width in bytes
and HEIGHT is the height in bits.
 
Note that the generated bitmaps must be used with
 
glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
 
Possible optimizations:
 
* use only one reusable pixmap with the maximum dimensions.
* draw the entire font into a single pixmap (careful with
proportional fonts!).
*/
 
 
/*
* Generate OpenGL-compatible bitmap.
*/
static void
fill_bitmap(Display * dpy, Window win, GC gc,
unsigned int width, unsigned int height,
int x0, int y0, unsigned int c, GLubyte * bitmap)
{
XImage *image;
unsigned int x, y;
Pixmap pixmap;
XChar2b char2b;
 
pixmap = XCreatePixmap(dpy, win, 8 * width, height, 1);
XSetForeground(dpy, gc, 0);
XFillRectangle(dpy, pixmap, gc, 0, 0, 8 * width, height);
XSetForeground(dpy, gc, 1);
 
char2b.byte1 = (c >> 8) & 0xff;
char2b.byte2 = (c & 0xff);
 
XDrawString16(dpy, pixmap, gc, x0, y0, &char2b, 1);
 
image = XGetImage(dpy, pixmap, 0, 0, 8 * width, height, 1, XYPixmap);
if (image) {
/* Fill the bitmap (X11 and OpenGL are upside down wrt each other). */
for (y = 0; y < height; y++)
for (x = 0; x < 8 * width; x++)
if (XGetPixel(image, x, y))
bitmap[width * (height - y - 1) + x / 8] |=
(1 << (7 - (x % 8)));
XDestroyImage(image);
}
 
XFreePixmap(dpy, pixmap);
}
 
/*
* determine if a given glyph is valid and return the
* corresponding XCharStruct.
*/
static XCharStruct *
isvalid(XFontStruct * fs, int which)
{
unsigned int rows, pages;
int byte1 = 0, byte2 = 0;
int i, valid = 1;
 
rows = fs->max_byte1 - fs->min_byte1 + 1;
pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
 
if (rows == 1) {
/* "linear" fonts */
if ((fs->min_char_or_byte2 > which) || (fs->max_char_or_byte2 < which))
valid = 0;
}
else {
/* "matrix" fonts */
byte2 = which & 0xff;
byte1 = which >> 8;
if ((fs->min_char_or_byte2 > byte2) ||
(fs->max_char_or_byte2 < byte2) ||
(fs->min_byte1 > byte1) || (fs->max_byte1 < byte1))
valid = 0;
}
 
if (valid) {
if (fs->per_char) {
if (rows == 1) {
/* "linear" fonts */
return (fs->per_char + (which - fs->min_char_or_byte2));
}
else {
/* "matrix" fonts */
i = ((byte1 - fs->min_byte1) * pages) +
(byte2 - fs->min_char_or_byte2);
return (fs->per_char + i);
}
}
else {
return (&fs->min_bounds);
}
}
return (NULL);
}
 
_X_HIDDEN void
DRI_glXUseXFont(struct glx_context *CC, Font font, int first, int count, int listbase)
{
Display *dpy;
Window win;
Pixmap pixmap;
GC gc;
XGCValues values;
unsigned long valuemask;
XFontStruct *fs;
 
GLint swapbytes, lsbfirst, rowlength;
GLint skiprows, skippixels, alignment;
 
unsigned int max_width, max_height, max_bm_width, max_bm_height;
GLubyte *bm;
 
int i;
 
dpy = CC->currentDpy;
win = CC->currentDrawable;
 
fs = XQueryFont(dpy, font);
if (!fs) {
__glXSetError(CC, GL_INVALID_VALUE);
return;
}
 
/* Allocate a bitmap that can fit all characters. */
max_width = fs->max_bounds.rbearing - fs->min_bounds.lbearing;
max_height = fs->max_bounds.ascent + fs->max_bounds.descent;
max_bm_width = (max_width + 7) / 8;
max_bm_height = max_height;
 
bm = malloc((max_bm_width * max_bm_height) * sizeof(GLubyte));
if (!bm) {
XFreeFontInfo(NULL, fs, 1);
__glXSetError(CC, GL_OUT_OF_MEMORY);
return;
}
 
#if 0
/* get the page info */
pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
firstchar = (fs->min_byte1 << 8) + fs->min_char_or_byte2;
lastchar = (fs->max_byte1 << 8) + fs->max_char_or_byte2;
rows = fs->max_byte1 - fs->min_byte1 + 1;
unsigned int first_char, last_char, pages, rows;
#endif
 
/* Save the current packing mode for bitmaps. */
glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
 
/* Enforce a standard packing mode which is compatible with
fill_bitmap() from above. This is actually the default mode,
except for the (non)alignment. */
glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
 
pixmap = XCreatePixmap(dpy, win, 10, 10, 1);
values.foreground = BlackPixel(dpy, DefaultScreen(dpy));
values.background = WhitePixel(dpy, DefaultScreen(dpy));
values.font = fs->fid;
valuemask = GCForeground | GCBackground | GCFont;
gc = XCreateGC(dpy, pixmap, valuemask, &values);
XFreePixmap(dpy, pixmap);
 
#ifdef DEBUG
if (debug_xfonts)
dump_font_struct(fs);
#endif
 
for (i = 0; i < count; i++) {
unsigned int width, height, bm_width, bm_height;
GLfloat x0, y0, dx, dy;
XCharStruct *ch;
int x, y;
unsigned int c = first + i;
int list = listbase + i;
int valid;
 
/* check on index validity and get the bounds */
ch = isvalid(fs, c);
if (!ch) {
ch = &fs->max_bounds;
valid = 0;
}
else {
valid = 1;
}
 
#ifdef DEBUG
if (debug_xfonts) {
char s[7];
sprintf(s, isprint(c) ? "%c> " : "\\%03o> ", c);
dump_char_struct(ch, s);
}
#endif
 
/* glBitmap()' parameters:
straight from the glXUseXFont(3) manpage. */
width = ch->rbearing - ch->lbearing;
height = ch->ascent + ch->descent;
x0 = -ch->lbearing;
y0 = ch->descent - 1;
dx = ch->width;
dy = 0;
 
/* X11's starting point. */
x = -ch->lbearing;
y = ch->ascent;
 
/* Round the width to a multiple of eight. We will use this also
for the pixmap for capturing the X11 font. This is slightly
inefficient, but it makes the OpenGL part real easy. */
bm_width = (width + 7) / 8;
bm_height = height;
 
glNewList(list, GL_COMPILE);
if (valid && (bm_width > 0) && (bm_height > 0)) {
 
memset(bm, '\0', bm_width * bm_height);
fill_bitmap(dpy, win, gc, bm_width, bm_height, x, y, c, bm);
 
glBitmap(width, height, x0, y0, dx, dy, bm);
#ifdef DEBUG
if (debug_xfonts) {
printf("width/height = %u/%u\n", width, height);
printf("bm_width/bm_height = %u/%u\n", bm_width, bm_height);
dump_bitmap(bm_width, bm_height, bm);
}
#endif
}
else {
glBitmap(0, 0, 0.0, 0.0, dx, dy, NULL);
}
glEndList();
}
 
free(bm);
XFreeFontInfo(NULL, fs, 1);
XFreeGC(dpy, gc);
 
/* Restore saved packing modes. */
glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
}
 
#endif