diff options
662 files changed, 20760 insertions, 23335 deletions
@@ -186,6 +186,14 @@ LIB_NAME = MesaLib-$(VERSION) DEMO_NAME = MesaDemos-$(VERSION) GLUT_NAME = MesaGLUT-$(VERSION) +# This is part of MAIN_FILES +MAIN_ES_FILES = \ + $(DIRECTORY)/src/mesa/es/Makefile \ + $(DIRECTORY)/src/mesa/es/sources.mak \ + $(DIRECTORY)/src/mesa/main/*.xml \ + $(DIRECTORY)/src/mesa/main/*.py \ + $(DIRECTORY)/src/mesa/main/*.dtd + MAIN_FILES = \ $(DIRECTORY)/Makefile* \ $(DIRECTORY)/configure \ @@ -219,8 +227,6 @@ MAIN_FILES = \ $(DIRECTORY)/include/GL/vms_x_fix.h \ $(DIRECTORY)/include/GL/wglext.h \ $(DIRECTORY)/include/GL/wmesa.h \ - $(DIRECTORY)/include/VG/*.h \ - $(DIRECTORY)/include/KHR/*.h \ $(DIRECTORY)/src/glsl/Makefile \ $(DIRECTORY)/src/glsl/Makefile.template \ $(DIRECTORY)/src/glsl/SConscript \ @@ -233,9 +239,9 @@ MAIN_FILES = \ $(DIRECTORY)/src/mesa/gl.pc.in \ $(DIRECTORY)/src/mesa/osmesa.pc.in \ $(DIRECTORY)/src/mesa/depend \ + $(MAIN_ES_FILES) \ $(DIRECTORY)/src/mesa/main/*.[chS] \ $(DIRECTORY)/src/mesa/main/descrip.mms \ - $(DIRECTORY)/src/mesa/glapi/*.[chS] \ $(DIRECTORY)/src/mesa/math/*.[ch] \ $(DIRECTORY)/src/mesa/math/descrip.mms \ $(DIRECTORY)/src/mesa/shader/*.[chly] \ @@ -289,31 +295,40 @@ MAIN_FILES = \ $(DIRECTORY)/progs/util/sampleMakefile \ $(DIRECTORY)/windows/VC8/ -ES_FILES = \ +MAPI_FILES = \ $(DIRECTORY)/include/GLES/*.h \ $(DIRECTORY)/include/GLES2/*.h \ - $(DIRECTORY)/src/mesa/glapi/gen/*.xml \ - $(DIRECTORY)/src/mesa/glapi/gen/*.py \ - $(DIRECTORY)/src/mesa/glapi/gen/*.dtd \ - $(DIRECTORY)/src/mesa/es/glapi/Makefile \ - $(DIRECTORY)/src/mesa/es/glapi/*.xml \ - $(DIRECTORY)/src/mesa/es/glapi/*.py \ - $(DIRECTORY)/src/mesa/es/state_tracker/*.[ch] \ - $(DIRECTORY)/src/mesa/es/main/*.[ch] \ - $(DIRECTORY)/src/mesa/es/main/*.xml \ - $(DIRECTORY)/src/mesa/es/main/*.py \ - $(DIRECTORY)/src/mesa/es/main/*.dtd \ - $(DIRECTORY)/src/mesa/es/Makefile \ - $(DIRECTORY)/src/mesa/es/sources.mak \ + $(DIRECTORY)/include/VG/*.h \ + $(DIRECTORY)/src/mapi/es?api/Makefile \ + $(DIRECTORY)/src/mapi/es?api/*.pc.in \ + $(DIRECTORY)/src/mapi/glapi/gen/Makefile \ + $(DIRECTORY)/src/mapi/glapi/gen/*.xml \ + $(DIRECTORY)/src/mapi/glapi/gen/*.py \ + $(DIRECTORY)/src/mapi/glapi/gen/*.dtd \ + $(DIRECTORY)/src/mapi/glapi/gen-es/Makefile \ + $(DIRECTORY)/src/mapi/glapi/gen-es/*.xml \ + $(DIRECTORY)/src/mapi/glapi/gen-es/*.py \ + $(DIRECTORY)/src/mapi/glapi/Makefile \ + $(DIRECTORY)/src/mapi/glapi/SConscript \ + $(DIRECTORY)/src/mapi/glapi/sources.mak \ + $(DIRECTORY)/src/mapi/glapi/*.[chS] \ + $(DIRECTORY)/src/mapi/mapi/mapi_abi.py \ + $(DIRECTORY)/src/mapi/mapi/sources.mak \ + $(DIRECTORY)/src/mapi/mapi/*.[ch] \ + $(DIRECTORY)/src/mapi/vgapi/Makefile \ + $(DIRECTORY)/src/mapi/vgapi/vgapi.csv \ + $(DIRECTORY)/src/mapi/vgapi/vg.pc.in \ + $(DIRECTORY)/src/mapi/vgapi/*.h EGL_FILES = \ + $(DIRECTORY)/include/KHR/*.h \ $(DIRECTORY)/include/EGL/*.h \ $(DIRECTORY)/src/egl/Makefile \ $(DIRECTORY)/src/egl/*/Makefile \ $(DIRECTORY)/src/egl/*/Makefile.template \ $(DIRECTORY)/src/egl/*/*.[ch] \ $(DIRECTORY)/src/egl/*/*/Makefile \ - $(DIRECTORY)/src/egl/*/*/*.[ch] \ + $(DIRECTORY)/src/egl/*/*/*.[ch] GALLIUM_FILES = \ $(DIRECTORY)/src/mesa/state_tracker/*[ch] \ @@ -325,8 +340,6 @@ GALLIUM_FILES = \ $(DIRECTORY)/src/gallium/*/Makefile \ $(DIRECTORY)/src/gallium/*/SConscript \ $(DIRECTORY)/src/gallium/*/*/Makefile \ - $(DIRECTORY)/src/gallium/*/*/Makefile.egl \ - $(DIRECTORY)/src/gallium/*/*/Makefile.template \ $(DIRECTORY)/src/gallium/*/*/SConscript \ $(DIRECTORY)/src/gallium/*/*/*.[ch] \ $(DIRECTORY)/src/gallium/*/*/*.py \ @@ -334,9 +347,7 @@ GALLIUM_FILES = \ $(DIRECTORY)/src/gallium/*/*/*/Makefile \ $(DIRECTORY)/src/gallium/*/*/*/SConscript \ $(DIRECTORY)/src/gallium/*/*/*/*.[ch] \ - $(DIRECTORY)/src/gallium/*/*/*/*.py \ - $(DIRECTORY)/src/gallium/*/*/*/*/Makefile \ - $(DIRECTORY)/src/gallium/*/*/*/*/*.[ch] \ + $(DIRECTORY)/src/gallium/*/*/*/*.py DRI_FILES = \ @@ -467,6 +478,7 @@ DEPEND_FILES = \ LIB_FILES = \ $(MAIN_FILES) \ + $(MAPI_FILES) \ $(ES_FILES) \ $(EGL_FILES) \ $(GALLIUM_FILES) \ diff --git a/SConstruct b/SConstruct index 3a4ff9a3fac..c843b41b0dc 100644 --- a/SConstruct +++ b/SConstruct @@ -31,6 +31,7 @@ import common # Configuration options default_statetrackers = 'mesa' +default_targets = 'none' if common.default_platform in ('linux', 'freebsd', 'darwin'): default_drivers = 'softpipe,failover,svga,i915,i965,trace,identity,llvmpipe' @@ -54,6 +55,28 @@ opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers, opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys, ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'graw-xlib'])) +opts.Add(ListVariable('targets', 'driver targets to build', default_targets, + ['dri-i915', + 'dri-i965', + 'dri-nouveau', + 'dri-radeong', + 'dri-swrast', + 'dri-vmwgfx', + 'egl-i915', + 'egl-i965', + 'egl-nouveau', + 'egl-radeon', + 'egl-swrast', + 'egl-vmwgfx', + 'graw-xlib', + 'libgl-gdi', + 'libgl-xlib', + 'xorg-i915', + 'xorg-i965', + 'xorg-nouveau', + 'xorg-radeon', + 'xorg-vmwgfx'])) + opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0'))) env = Environment( @@ -102,9 +125,11 @@ Export([ ####################################################################### # Environment setup -# Always build trace, identity, softpipe, and llvmpipe (where possible) +# Always build trace, rbug, identity, softpipe, and llvmpipe (where possible) if 'trace' not in env['drivers']: env['drivers'].append('trace') +if 'rbug' not in env['drivers']: + env['drivers'].append('rbug') if 'identity' not in env['drivers']: env['drivers'].append('identity') if 'softpipe' not in env['drivers']: @@ -151,10 +176,11 @@ if platform in ('posix', 'linux', 'freebsd', 'darwin'): '_SVID_SOURCE', '_BSD_SOURCE', '_GNU_SOURCE', - 'PTHREADS', 'HAVE_POSIX_MEMALIGN', ]) + if gcc: + env.Append(CFLAGS = ['-fvisibility=hidden']) if platform == 'darwin': env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE']) env.Append(LIBS = [ diff --git a/common.py b/common.py index 742dabf4c45..bdca375f8b0 100644 --- a/common.py +++ b/common.py @@ -3,6 +3,7 @@ import os import os.path +import re import subprocess import sys import platform as _platform @@ -28,22 +29,38 @@ _machine_map = { 'ppc' : 'ppc', 'x86_64': 'x86_64', } + + +# find default_machine value if 'PROCESSOR_ARCHITECTURE' in os.environ: default_machine = os.environ['PROCESSOR_ARCHITECTURE'] else: default_machine = _platform.machine() default_machine = _machine_map.get(default_machine, 'generic') + +# find default_llvm value if 'LLVM' in os.environ: default_llvm = 'yes' else: + # Search sys.argv[] for a "platform=foo" argument since we don't have + # an 'env' variable at this point. + platform = default_platform + pattern = re.compile("(platform=)(.*)") + for arg in sys.argv: + m = pattern.match(arg) + if m: + platform = m.group(2) + default_llvm = 'no' try: - if subprocess.call(['llvm-config', '--version'], stdout=subprocess.PIPE) == 0: + if platform != 'windows' and subprocess.call(['llvm-config', '--version'], stdout=subprocess.PIPE) == 0: default_llvm = 'yes' except: pass + +# find default_dri value if default_platform in ('linux', 'freebsd'): default_dri = 'yes' elif default_platform in ('winddk', 'windows', 'wince', 'darwin'): diff --git a/configs/autoconf.in b/configs/autoconf.in index 119aadb6d4f..0b5be0c2cae 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -16,6 +16,7 @@ PIC_FLAGS = @PIC_FLAGS@ DEFINES = @DEFINES@ API_DEFINES = @API_DEFINES@ APIS = @APIS@ +GLES_OVERLAY = @GLES_OVERLAY@ CFLAGS = @CPPFLAGS@ @CFLAGS@ \ $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES) CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@ \ @@ -36,7 +37,6 @@ LLVM_LIBS = @LLVM_LIBS@ # Source selection MESA_ASM_SOURCES = @MESA_ASM_SOURCES@ GLAPI_ASM_SOURCES = @GLAPI_ASM_SOURCES@ -ES_SOURCES = @ES1_SOURCES@ @ES2_SOURCES@ # Misc tools and flags MAKE = @MAKE@ @@ -58,6 +58,7 @@ GLW_LIB = GLw OSMESA_LIB = @OSMESA_LIB@ GLESv1_CM_LIB = GLESv1_CM GLESv2_LIB = GLESv2 +VG_LIB = OpenVG # Library names (actual file names) GL_LIB_NAME = @GL_LIB_NAME@ @@ -68,6 +69,7 @@ OSMESA_LIB_NAME = @OSMESA_LIB_NAME@ EGL_LIB_NAME = @EGL_LIB_NAME@ GLESv1_CM_LIB_NAME = @GLESv1_CM_LIB_NAME@ GLESv2_LIB_NAME = @GLESv2_LIB_NAME@ +VG_LIB_NAME = @VG_LIB_NAME@ # Globs used to install the lib and all symlinks GL_LIB_GLOB = @GL_LIB_GLOB@ @@ -78,6 +80,7 @@ OSMESA_LIB_GLOB = @OSMESA_LIB_GLOB@ EGL_LIB_GLOB = @EGL_LIB_GLOB@ GLESv1_CM_LIB_GLOB = @GLESv1_CM_LIB_GLOB@ GLESv2_LIB_GLOB = @GLESv2_LIB_GLOB@ +VG_LIB_GLOB = @VG_LIB_GLOB@ # Directories to build LIB_DIR = @LIB_DIR@ @@ -99,6 +102,7 @@ PROGRAM_DIRS = @PROGRAM_DIRS@ # Driver specific build vars DRI_DIRS = @DRI_DIRS@ EGL_DISPLAYS = @EGL_DISPLAYS@ +EGL_CLIENT_APIS = @EGL_CLIENT_APIS@ # Dependencies X11_INCLUDES = @X11_INCLUDES@ @@ -121,6 +125,7 @@ GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @GLW_MESA_DEPS@ \ APP_LIB_DEPS = $(EXTRA_LIB_PATH) @APP_LIB_DEPS@ GLESv1_CM_LIB_DEPS = $(EXTRA_LIB_PATH) @GLESv1_LIB_DEPS@ GLESv2_LIB_DEPS = $(EXTRA_LIB_PATH) @GLESv2_LIB_DEPS@ +VG_LIB_DEPS = $(EXTRA_LIB_PATH) @VG_LIB_DEPS@ # DRI dependencies DRI_LIB_DEPS = $(EXTRA_LIB_PATH) @DRI_LIB_DEPS@ @@ -169,8 +174,11 @@ GLW_PC_LIB_PRIV = @GLW_PC_LIB_PRIV@ GLW_PC_CFLAGS = @GLW_PC_CFLAGS@ OSMESA_PC_REQ = @OSMESA_PC_REQ@ OSMESA_PC_LIB_PRIV = @OSMESA_PC_LIB_PRIV@ -GLESv1_CM_PC_LIB_PRIV = @GLESv2_PC_LIB_PRIV@ +GLESv1_CM_PC_LIB_PRIV = @GLESv1_CM_PC_LIB_PRIV@ GLESv2_PC_LIB_PRIV = @GLESv2_PC_LIB_PRIV@ +EGL_PC_REQ_PRIV = @GL_PC_REQ_PRIV@ +EGL_PC_LIB_PRIV = @GL_PC_LIB_PRIV@ +EGL_PC_CFLAGS = @GL_PC_CFLAGS@ EGL_DRI2_CFLAGS = @EGL_DRI2_CFLAGS@ EGL_DRI2_LIBS = @EGL_DRI2_LIBS@ diff --git a/configs/darwin b/configs/darwin index e5196848776..0af77c7d31d 100644 --- a/configs/darwin +++ b/configs/darwin @@ -52,7 +52,7 @@ GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXmu -lXt -lXi -lm # omit glw lib for now: -SRC_DIRS = glsl glx/apple mesa gallium glu glut/glx glew +SRC_DIRS = glsl mapi/glapi mapi/vgapi glx/apple mesa gallium glu glut/glx glew GLU_DIRS = sgi DRIVER_DIRS = osmesa #DRIVER_DIRS = dri diff --git a/configs/default b/configs/default index dd701de0401..f0395ce7d9e 100644 --- a/configs/default +++ b/configs/default @@ -56,6 +56,9 @@ GLEW_LIB = GLEW GLW_LIB = GLw OSMESA_LIB = OSMesa EGL_LIB = EGL +GLESv1_CM_LIB = GLESv1_CM +GLESv2_LIB = GLESv2 +VG_LIB = OpenVG # Library names (actual file names) @@ -66,6 +69,9 @@ GLEW_LIB_NAME = lib$(GLEW_LIB).a GLW_LIB_NAME = lib$(GLW_LIB).so OSMESA_LIB_NAME = lib$(OSMESA_LIB).so EGL_LIB_NAME = lib$(EGL_LIB).so +GLESv1_CM_LIB_NAME = lib$(GLESv1_CM_LIB).so +GLESv2_LIB_NAME = lib$(GLESv2_LIB).so +VG_LIB_NAME = lib$(VG_LIB).so # globs used to install the lib and all symlinks GL_LIB_GLOB = $(GL_LIB_NAME)* @@ -74,6 +80,9 @@ GLUT_LIB_GLOB = $(GLUT_LIB_NAME)* GLW_LIB_GLOB = $(GLW_LIB_NAME)* OSMESA_LIB_GLOB = $(OSMESA_LIB_NAME)* EGL_LIB_GLOB = $(EGL_LIB_NAME)* +GLESv1_CM_LIB_GLOB = $(GLESv1_CM_LIB_NAME)* +GLESv2_LIB_GLOB = $(GLESv2_LIB_NAME)* +VG_LIB_GLOB = $(VG_LIB_NAME)* # Optional assembly language optimization files for libGL MESA_ASM_SOURCES = @@ -86,7 +95,8 @@ MOTIF_CFLAGS = -I/usr/include/Motif1.2 # Directories to build LIB_DIR = lib -SRC_DIRS = glsl mesa gallium egl gallium/winsys gallium/targets glu glut/glx glew glw +SRC_DIRS = glsl mapi/glapi mapi/vgapi mesa \ + gallium egl gallium/winsys gallium/targets glu glut/glx glew glw GLU_DIRS = sgi DRIVER_DIRS = x11 osmesa # Which subdirs under $(TOP)/progs/ to enter: @@ -98,7 +108,7 @@ EGL_DRIVERS_DIRS = glx # Gallium directories and GALLIUM_DIRS = auxiliary drivers state_trackers GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a -GALLIUM_DRIVERS_DIRS = softpipe trace identity i915 i965 svga r300 nvfx nv50 failover +GALLIUM_DRIVERS_DIRS = softpipe trace rbug identity i915 i965 svga r300 nvfx nv50 failover GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) GALLIUM_WINSYS_DIRS = sw sw/xlib GALLIUM_TARGET_DIRS = libgl-xlib @@ -106,6 +116,7 @@ GALLIUM_STATE_TRACKERS_DIRS = glx vega # native displays EGL should support EGL_DISPLAYS = x11 +EGL_CLIENT_APIS = $(GL_LIB) # Library dependencies #EXTRA_LIB_PATH ?= @@ -116,6 +127,9 @@ GLU_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm GLUT_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXmu -lXi -lm GLW_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lXt -lX11 APP_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm +GLESv1_CM_LIB_DEPS = $(EXTRA_LIB_PATH) -lpthread +GLESv2_LIB_DEPS = $(EXTRA_LIB_PATH) -lpthread +VG_LIB_DEPS = $(EXTRA_LIB_PATH) -lpthread # Program dependencies - specific GL/glut libraries added in Makefiles APP_LIB_DEPS = -lm @@ -153,3 +167,12 @@ GLW_PC_LIB_PRIV = GLW_PC_CFLAGS = OSMESA_PC_REQ = OSMESA_PC_LIB_PRIV = +GLESv1_CM_PC_REQ_PRIV = +GLESv1_CM_PC_LIB_PRIV = +GLESv1_CM_PC_CFLAGS = +GLESv2_PC_REQ_PRIV = +GLESv2_PC_LIB_PRIV = +GLESv2_PC_CFLAGS = +VG_PC_REQ_PRIV = +VG_PC_LIB_PRIV = +VG_PC_CFLAGS = diff --git a/configs/linux-cell b/configs/linux-cell index 0908dba9e05..2b0c41ed6ac 100644 --- a/configs/linux-cell +++ b/configs/linux-cell @@ -6,7 +6,7 @@ CONFIG_NAME = linux-cell # Omiting other gallium drivers: -GALLIUM_DRIVERS_DIRS = cell softpipe trace identity +GALLIUM_DRIVERS_DIRS = cell softpipe trace rbug identity # Compiler and flags @@ -37,7 +37,8 @@ CXXFLAGS = $(COMMON_C_CPP_FLAGS) # Omitting glw here: -SRC_DIRS = glsl mesa gallium gallium/winsys gallium/targets glu glut/glx glew +SRC_DIRS = glsl mapi/glapi mapi/vgapi mesa \ + gallium gallium/winsys gallium/targets glu glut/glx glew # Build no traditional Mesa drivers: DRIVER_DIRS = diff --git a/configs/linux-opengl-es b/configs/linux-opengl-es index 6984aa9b2cd..fb65c02277d 100644 --- a/configs/linux-opengl-es +++ b/configs/linux-opengl-es @@ -6,7 +6,8 @@ CONFIG_NAME = linux-opengl-es # Directories to build LIB_DIR = lib -SRC_DIRS = egl glsl mesa/es gallium gallium/winsys gallium/targets +SRC_DIRS = egl glsl mapi/es1api mapi/es2api mesa/es \ + gallium gallium/winsys gallium/targets PROGRAM_DIRS = egl/eglut egl/opengles1 egl/opengles2 # egl st needs this @@ -22,7 +23,7 @@ GALLIUM_DRIVERS_DIRS = softpipe GALLIUM_STATE_TRACKERS_DIRS = es # build egl_x11_{swrast,i915}.so -GALLIUM_DRIVERS_DIRS += trace i915 +GALLIUM_DRIVERS_DIRS += trace rbug i915 GALLIUM_STATE_TRACKERS_DIRS += egl GALLIUM_WINSYS_DIRS += drm/intel GALLIUM_TARGET_DIRS += egl-swrast egl-i915 diff --git a/configs/linux-osmesa b/configs/linux-osmesa index 3015f5fcbb1..c183171efc9 100644 --- a/configs/linux-osmesa +++ b/configs/linux-osmesa @@ -17,7 +17,7 @@ CFLAGS += -fno-strict-aliasing CXXFLAGS += -fno-strict-aliasing # Directories -SRC_DIRS = glsl mesa glu +SRC_DIRS = mapi/glapi glsl mesa glu DRIVER_DIRS = osmesa PROGRAM_DIRS = osdemos diff --git a/configs/linux-osmesa16 b/configs/linux-osmesa16 index 090ca273099..161bd577008 100644 --- a/configs/linux-osmesa16 +++ b/configs/linux-osmesa16 @@ -20,7 +20,7 @@ OSMESA_LIB_NAME = libOSMesa16.so # Directories -SRC_DIRS = glsl mesa glu +SRC_DIRS = mapi/glapi glsl mesa glu DRIVER_DIRS = osmesa PROGRAM_DIRS = diff --git a/configs/linux-osmesa32 b/configs/linux-osmesa32 index 63de7f9a460..ff1b189b806 100644 --- a/configs/linux-osmesa32 +++ b/configs/linux-osmesa32 @@ -20,7 +20,7 @@ OSMESA_LIB_NAME = libOSMesa32.so # Directories -SRC_DIRS = glsl mesa glu +SRC_DIRS = mapi/glapi glsl mesa glu DRIVER_DIRS = osmesa PROGRAM_DIRS = diff --git a/configure.ac b/configure.ac index 354c220b5c9..eb3460e9eb6 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_PREREQ([2.59]) dnl Versioning - scrape the version from configs/default m4_define([mesa_version], - [m4_esyscmd([${MAKE-make} -s -f bin/version.mk version | tr -d '\n'])]) + [m4_esyscmd([${MAKE-make} -s -f bin/version.mk version | tr -d '\n' | tr -d '\r'])]) m4_ifval(mesa_version,, [m4_fatal([Failed to get the Mesa version from `make -f bin/version.mk version`])]) @@ -265,7 +265,7 @@ else darwin* ) LIB_EXTENSION='dylib' ;; cygwin* ) - LIB_EXTENSION='dll' ;; + LIB_EXTENSION='dll.a' ;; aix* ) LIB_EXTENSION='a' ;; * ) @@ -281,6 +281,7 @@ OSMESA_LIB_NAME='lib$(OSMESA_LIB).'${LIB_EXTENSION} EGL_LIB_NAME='lib$(EGL_LIB).'${LIB_EXTENSION} GLESv1_CM_LIB_NAME='lib$(GLESv1_CM_LIB).'${LIB_EXTENSION} GLESv2_LIB_NAME='lib$(GLESv2_LIB).'${LIB_EXTENSION} +VG_LIB_NAME='lib$(VG_LIB).'${LIB_EXTENSION} GL_LIB_GLOB='lib$(GL_LIB).*'${LIB_EXTENSION}'*' GLU_LIB_GLOB='lib$(GLU_LIB).*'${LIB_EXTENSION}'*' @@ -290,6 +291,7 @@ OSMESA_LIB_GLOB='lib$(OSMESA_LIB).*'${LIB_EXTENSION}'*' EGL_LIB_GLOB='lib$(EGL_LIB).*'${LIB_EXTENSION}'*' GLESv1_CM_LIB_GLOB='lib$(GLESv1_CM_LIB).*'${LIB_EXTENSION}'*' GLESv2_LIB_GLOB='lib$(GLESv2_LIB).*'${LIB_EXTENSION}'*' +VG_LIB_GLOB='lib$(VG_LIB).*'${LIB_EXTENSION}'*' AC_SUBST([GL_LIB_NAME]) AC_SUBST([GLU_LIB_NAME]) @@ -299,6 +301,7 @@ AC_SUBST([OSMESA_LIB_NAME]) AC_SUBST([EGL_LIB_NAME]) AC_SUBST([GLESv1_CM_LIB_NAME]) AC_SUBST([GLESv2_LIB_NAME]) +AC_SUBST([VG_LIB_NAME]) AC_SUBST([GL_LIB_GLOB]) AC_SUBST([GLU_LIB_GLOB]) @@ -308,6 +311,7 @@ AC_SUBST([OSMESA_LIB_GLOB]) AC_SUBST([EGL_LIB_GLOB]) AC_SUBST([GLESv1_CM_LIB_GLOB]) AC_SUBST([GLESv2_LIB_GLOB]) +AC_SUBST([VG_LIB_GLOB]) dnl dnl Arch/platform-specific settings @@ -463,14 +467,14 @@ dnl Driver specific build directories dnl dnl this variable will be prepended to SRC_DIRS and is not exported -CORE_DIRS="glsl mesa" +CORE_DIRS="mapi/glapi glsl mesa" SRC_DIRS="glew" GLU_DIRS="sgi" GALLIUM_DIRS="auxiliary drivers state_trackers" GALLIUM_TARGET_DIRS="" GALLIUM_WINSYS_DIRS="sw" -GALLIUM_DRIVERS_DIRS="softpipe failover trace identity" +GALLIUM_DRIVERS_DIRS="softpipe failover trace rbug identity" GALLIUM_STATE_TRACKERS_DIRS="" case "$mesa_driver" in @@ -678,7 +682,10 @@ AC_SUBST([GL_PC_LIB_PRIV]) AC_SUBST([GL_PC_CFLAGS]) AC_SUBST([DRI_PC_REQ_PRIV]) AC_SUBST([GLESv1_LIB_DEPS]) +AC_SUBST([GLESv1_CM_PC_LIB_PRIV]) AC_SUBST([GLESv2_LIB_DEPS]) +AC_SUBST([GLESv2_PC_LIB_PRIV]) + dnl dnl More X11 setup @@ -742,11 +749,15 @@ AC_ARG_ENABLE([gles2], [enable support for OpenGL ES 2.x API @<:@default=no@:>@])], [enable_gles2="$enableval"], [enable_gles2=no]) +AC_ARG_ENABLE([gles-overlay], + [AS_HELP_STRING([--enable-gles-overlay], + [build separate OpenGL ES only libraries @<:@default=no@:>@])], + [enable_gles_overlay="$enableval"], + [enable_gles_overlay=no]) API_DEFINES="" APIS="" -ES1_SOURCES="" -ES2_SOURCES="" +GLES_OVERLAY=0 if test "x$enable_opengl" = xno; then API_DEFINES="$API_DEFINES -DFEATURE_GL=0" else @@ -756,20 +767,21 @@ fi if test "x$enable_gles1" = xyes; then API_DEFINES="$API_DEFINES -DFEATURE_ES1=1" APIS="$APIS es1" - ES1_SOURCES='$(ES1_SOURCES)' fi if test "x$enable_gles2" = xyes; then API_DEFINES="$API_DEFINES -DFEATURE_ES2=1" APIS="$APIS es2" - ES2_SOURCES='$(ES2_SOURCES)' fi -if test "x$enable_gles1" = xyes -o "x$enable_gles2" = xyes; then - SRC_DIRS="$SRC_DIRS gles" +if test "x$enable_gles_overlay" = xyes -o \ + "x$enable_gles1" = xyes -o "x$enable_gles2" = xyes; then + CORE_DIRS="mapi/es1api mapi/es2api $CORE_DIRS" + if test "x$enable_gles_overlay" = xyes; then + GLES_OVERLAY=1 + fi fi AC_SUBST([API_DEFINES]) AC_SUBST([APIS]) -AC_SUBST([ES1_SOURCES]) -AC_SUBST([ES2_SOURCES]) +AC_SUBST([GLES_OVERLAY]) dnl If $with_dri_drivers is yes, directories will be added through dnl platform checks @@ -1251,6 +1263,12 @@ AC_SUBST([LLVM_LIBS]) AC_SUBST([LLVM_LDFLAGS]) AC_SUBST([LLVM_VERSION]) +VG_LIB_DEPS="" +EGL_CLIENT_APIS='$(GL_LIB)' +if test "x$enable_gles_overlay" = xyes; then + EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(GLESv1_CM_LIB) $(GLESv2_LIB)' +fi + dnl dnl Gallium state trackers configuration dnl @@ -1287,11 +1305,9 @@ yes) ;; *) # verify the requested state tracker exist - state_trackers=`IFS=', '; echo $with_state_trackers` - for tracker in $state_trackers; do - test -d "$srcdir/src/gallium/state_trackers/$tracker" || \ - AC_MSG_ERROR([state tracker '$tracker' doesn't exist]) - + state_trackers="" + _state_trackers=`IFS=', '; echo $with_state_trackers` + for tracker in $_state_trackers; do case "$tracker" in dri) if test "x$mesa_driver" != xdri; then @@ -1311,15 +1327,45 @@ yes) HAVE_ST_XORG="yes" ;; es) - # mesa/es is required to build es state tracker - CORE_DIRS="$CORE_DIRS mesa/es" + AC_MSG_WARN([state tracker 'es' has been replaced by --enable-gles-overlay]) + + if test "x$enable_gles_overlay" != xyes; then + if test "x$enable_gles1" != xyes -a "x$enable_gles2" != xyes; then + CORE_DIRS="mapi/es1api mapi/es2api $CORE_DIRS" + fi + GLES_OVERLAY=1 + EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(GLESv1_CM_LIB) $(GLESv2_LIB)' + fi + tracker="" + ;; + vega) + CORE_DIRS="$CORE_DIRS mapi/vgapi" + VG_LIB_DEPS="$VG_LIB_DEPS -lpthread" + EGL_CLIENT_APIS="$EGL_CLIENT_APIS "'$(VG_LIB)' ;; esac + + if test -n "$tracker"; then + test -d "$srcdir/src/gallium/state_trackers/$tracker" || \ + AC_MSG_ERROR([state tracker '$tracker' doesn't exist]) + if test -n "$state_trackers"; then + state_trackers="$state_trackers $tracker" + else + state_trackers="$tracker" + fi + fi done GALLIUM_STATE_TRACKERS_DIRS="$state_trackers" ;; esac +AC_SUBST([VG_LIB_DEPS]) +AC_SUBST([EGL_CLIENT_APIS]) + +if test "x$HAVE_ST_EGL" = xyes; then + GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS egl-apis" +fi + if test "x$HAVE_ST_XORG" = xyes; then PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1], HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71", @@ -1404,7 +1450,7 @@ if test "x$enable_gallium_llvm" = xyes; then fi LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags` GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe" - DEFINES="$DEFINES -DMESA_LLVM -D__STDC_CONSTANT_MACROS" + DEFINES="$DEFINES -DGALLIUM_LLVMPIPE -D__STDC_CONSTANT_MACROS" MESA_LLVM=1 else MESA_LLVM=0 @@ -1575,6 +1621,9 @@ if echo "$SRC_DIRS" | grep 'gallium' >/dev/null 2>&1; then echo " Winsys dirs: $GALLIUM_WINSYS_DIRS" echo " Driver dirs: $GALLIUM_DRIVERS_DIRS" echo " Trackers dirs: $GALLIUM_STATE_TRACKERS_DIRS" + if test "x$HAVE_ST_EGL" = xyes; then + echo " EGL client APIs: $EGL_CLIENT_APIS" + fi else echo " Gallium: no" fi @@ -1585,6 +1634,7 @@ echo " Shared libs: $enable_shared" echo " Static libs: $enable_static" if test "$enable_egl" = yes; then echo " EGL: $EGL_DRIVERS_DIRS" + echo " EGL displays: $EGL_DISPLAYS" else echo " EGL: no" fi diff --git a/docs/GL3.txt b/docs/GL3.txt index 386619e2f7c..7659a0c73e8 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -14,7 +14,7 @@ GL 3.0: GLSL changes (GL_EXT_gpu_shader4, etc) not started Conditional rendering (GL_NV_conditional_render) DONE (swrast & softpipe) -Map buffer subranges (GL_APPLE_flush_buffer_range) not started +Map buffer subranges (GL_ARB_map_buffer_range) DONE Float textures, renderbuffers some infrastructure done (incl. GL_EXT_packed_float, GL_EXT_shared_exponent) Framebuffer objects (GL_EXT_framebuffer_object) DONE @@ -27,14 +27,14 @@ Per-buffer blend and masks (GL_EXT_draw_buffers2) DONE GL_EXT_texture_compression_rgtc not started Red and red/green texture formats Ian? Transform feedback (GL_EXT_transform_feedback) ~50% done + glBindFragDataLocation, glGetFragDataLocation, + glBindBufferRange, glBindBufferBase commands Vertex array objects (GL_APPLE_vertex_array_object) DONE sRGB framebuffer format (GL_EXT_framebuffer_sRGB) not started glClearBuffer commands DONE, except for dispatch glGetStringi command DONE, except for dispatch glTexParameterI, glGetTexParameterI commands DONE, except for dispatch glVertexAttribI commands not started -glBindFragDataLocation, glGetFragDataLocation cmds not started -glBindBufferRange, glBindBufferBase commands DONE GL 3.1: @@ -65,6 +65,37 @@ Frag depth clamp (GL_ARB_depth_clamp) DONE Fence objects (GL_ARB_sync) DONE +GL 3.3: + +GLSL 3.30 not started +GL_ARB_blend_func_extended not started +GL_ARB_explicit_attrib_location not started +GL_ARB_occlusion_query2 not started +GL_ARB_sampler_objects not started +GL_ARB_texture_rgb10_a2ui not started +GL_ARB_texture_swizzle DONE (same as EXT version) +GL_ARB_timer_query DONE (only Xlib sw driver) +GL_ARB_instanced_arrays not started +GL_ARB_vertex_type_2_10_10_10_rev not started + + +GL 4.0: + +GLSL 4.0 not started +GL_ARB_texture_query_lod not started +GL_ARB_draw_buffers_blend not started +GL_ARB_draw_indirect not started +GL_ARB_gpu_shader_fp64 not started +GL_ARB_sample_shading not started +GL_ARB_shader_subroutine not started +GL_ARB_tessellation_shader not started +GL_ARB_texture_buffer_object_rgb32 not started +GL_ARB_texture_cube_map_array not started +GL_ARB_texture_gather not started +GL_ARB_transform_feedback2 not started + + + More info about these features and the work involved can be found at http://dri.freedesktop.org/wiki/MissingFunctionality diff --git a/docs/egl.html b/docs/egl.html index e960309fc47..ad3b850f2ad 100644 --- a/docs/egl.html +++ b/docs/egl.html @@ -32,13 +32,13 @@ cards.</p> the Gallium driver for your hardware. For example</p> <pre> - $ ./configure --with-state-trackers=egl,es,vega --enable-gallium-{swrast,intel} + $ ./configure --enable-gles-overlay --with-state-trackers=egl,vega --enable-gallium-{swrast,intel} </pre> -<p>The main library will be enabled by default. The <code>egl</code> state +<p>The main library and OpenGL is enabled by default. The first option enables +<a href="opengles.html">OpenGL ES 1.x and 2.x</a>. The <code>egl</code> state tracker is needed by a number of EGL drivers. EGL drivers will be covered -later. The <a href="opengles.html">es state tracker</a> provides OpenGL ES 1.x -and 2.x and the <a href="openvg.html">vega state tracker</a> provides OpenVG +later. The <a href="openvg.html">vega state tracker</a> provides OpenVG 1.x.</p> </li> @@ -46,8 +46,8 @@ and 2.x and the <a href="openvg.html">vega state tracker</a> provides OpenVG </ol> <p>In the given example, it will build and install <code>libEGL</code>, -<code>libGLESv1_CM</code>, <code>libGLESv2</code>, <code>libOpenVG</code>, and -one or more EGL drivers.</p> +<code>libGL</code>, <code>libGLESv1_CM</code>, <code>libGLESv2</code>, +<code>libOpenVG</code>, and one or more EGL drivers.</p> <h3>Configure Options</h3> @@ -83,9 +83,26 @@ bare KMS (kernel modesetting).</p> <li><code>--with-state-trackers</code> <p>The argument is a comma separated string. It is usually used to specify the -rendering APIs, like OpenGL ES or OpenVG, to build. But it should be noted -that a number of EGL drivers depend on the <code>egl</code> state tracker. -They will <em>not</em> be built without the <code>egl</code> state tracker.</p> +rendering APIs, such as OpenVG, to build. But it should be noted that a number +of EGL drivers depend on the <code>egl</code> state tracker. They will +<em>not</em> be built without the <code>egl</code> state tracker.</p> + +</li> + +<li><code>--enable-gles-overlay</code> + +<p>OpenGL and OpenGL ES are not controlled by +<code>--with-state-trackers</code>. OpenGL is always built. To build OpenGL +ES, this option must be explicitly given.</p> + +</li> + +<li><code>--enable-gles1</code> and <code>--enable-gles2</code> + +<p>Unlike <code>--enable-gles-overlay</code>, which builds one library for each +rendering API, these options enable OpenGL ES support in OpenGL. The result is +one big library that supports multiple APIs. This is used by DRI drivers and +<code>egl_dri2</code> EGL driver. </li> @@ -99,25 +116,17 @@ software rendering automatically.</p> </li> </ul> -<h3>OpenGL</h3> - -<p>The OpenGL state tracker is not built in the above example. It should be -noted that the classic <code>libGL</code> is not a state tracker and cannot be -used with EGL (unless the EGL driver in use is <code>egl_glx</code>). To build -the OpenGL state tracker, one may append <code>glx</code> to -<code>--with-state-trackers</code> and manually build -<code>src/gallium/targets/libgl-xlib/</code>.</p> - <h2>Use EGL</h2> -<p>The demos for OpenGL ES and OpenVG can be found in <code>progs/es1/</code>, -<code>progs/es2/</code> and <code>progs/openvg/</code>. You can use them to -test your build. For example,</p> +<p>There are demos for the client APIs supported by EGL. They can be found in +<code>progs/egl/</code>, You can use them to test your build. For example,</p> <pre> - $ cd progs/es1/xegl + $ cd progs/egl/eglut + $ make + $ cd ../opengles1 $ make - $ ./torus + $ ./torus_x11 </pre> <h3>Environment Variables</h3> diff --git a/docs/opengles.html b/docs/opengles.html index fc41e6771c1..63cc1146a2e 100644 --- a/docs/opengles.html +++ b/docs/opengles.html @@ -1,68 +1,69 @@ <html> -<title>OpenGL ES State Trackers</title> +<title>OpenGL ES</title> <head><link rel="stylesheet" type="text/css" href="mesa.css"></head> <body> -<h1>OpenGL ES State Trackers</h1> +<h1>OpenGL ES</h1> -<p>The current version of the OpenGL ES state trackers implement OpenGL ES 1.1 and OpenGL ES 2.0. -More informations about OpenGL ES can be found at -<a href="http://www.khronos.org/opengles/" target="_parent"> -http://www.khronos.org/opengles/</a>.</p> - -<p>The OpenGL ES state trackers depends on the Gallium architecture and a -working EGL implementation. Please refer to <a href="egl.html">Mesa EGL</a> -for more information about EGL.</p> +<p>Mesa implements OpenGL ES 1.1 and OpenGL ES 2.0. More informations about +OpenGL ES can be found at <a href="http://www.khronos.org/opengles/" +target="_parent"> http://www.khronos.org/opengles/</a>.</p> +<p>OpenGL ES depends on a working EGL implementation. Please refer to +<a href="egl.html">Mesa EGL</a> for more information about EGL.</p> <h2>Build the Libraries</h2> <ol> -<li>Run <code>configure</code> with <code>--with-state-trackers=egl,es</code> and enable the Gallium driver for your hardware.</li> +<li>Run <code>configure</code> with <code>--enable-gles-overlay</code> and enable the Gallium driver for your hardware.</li> +<li>Build and install Mesa as usual.</li> +</ol> + +Alternatively, if XCB-DRI2 is installed on the system, one can use +<code>egl_dri2</code> EGL driver with OpenGL|ES-enabled DRI drivers + +<ol> +<li>Run <code>configure</code> with <code>--enable-gles1 --enable-gles2</code>.</li> <li>Build and install Mesa as usual.</li> </ol> -<p>It will install libGLESv1_CM, libGLESv2, libEGL, and one or more EGL drivers for your hardware.</p> +<p>Both methods will install libGLESv1_CM, libGLESv2, libEGL, and one or more +EGL drivers for your hardware.</p> + <h2>Run the Demos</h2> -<p>There are some demos in <code>progs/es1/</code> and <code>progs/es2/</code>. You can use them to test your build. For example,</p> +<p>There are some demos in <code>progs/egl/</code>. You can use them to test +your build. For example,</p> <pre> - $ cd progs/es1/xegl + $ cd progs/egl/eglut + $ make + $ cd ../opengles1 $ make - $ ./torus + $ ./torus_x11 </pre> <h2>Developers</h2> -<p>The core of OpenGL ES state trackers is the ES overlay. It is located in -<code>src/mesa/es/</code>.</p> - -<h3>Structure</h3> +<h3>Internal Libraries</h3> -<p>The ES overlay uses as much code as possible from Mesa. It has its own glapi XMLs to describe the APIs of OpenGL ES. The ES overlay can be built parallelly with Mesa, and they will give</p> - -<table border="1"> - <tr><td>Library Name</td><td>Usage</td><td>Source</td></tr> - <tr><td>libmesagallium.a</td><td>OpenGL state tracker</td><td>Mesa</td></tr> - <tr><td>libes1gallium.a</td><td>OpenGL ES 1.x state tracker</td><td>ES overlay</td></tr> - <tr><td>libes2gallium.a</td><td>OpenGL ES 2.x state tracker</td><td>ES overlay</td></tr> - <tr><td>libglapi.a</td><td>OpenGL API</td><td>Mesa</td></tr> - <tr><td>libes1api.a</td><td>OpenGL ES 1.x API</td><td>ES overlay</td></tr> - <tr><td>libes2api.a</td><td>OpenGL ES 2.x API</td><td>ES overlay</td></tr> +<table border="1" style="text-align: center;"> + <tr><td>Library Name</td><td>Used By</td><td>Enabled</td><td>OpenGL</td><td>OpenGL ES 1.x</td><td>OpenGL ES 2.x</td></tr> + <tr><td><code>libmesa.a</td><td>Classic DRI drivers</td><td>y</td><td>y</td><td>--enable-gles1</td><td>--enable-gles2</td></tr> + <tr><td><code>libmesagallium.a</td><td>Gallium EGL and DRI drivers</td><td>y</td><td>y</td><td>--enable-gles1</td><td>--enable-gles2</td></tr> + <tr><td><code>libes1gallium.a</td><td>Gallium EGL drivers</td><td>--enable-gles-overlay</td><td>n</td><td>y</td><td>n</td></tr> + <tr><td><code>libes2gallium.a</td><td>Gallium EGL drivers</td><td>--enable-gles-overlay</td><td>n</td><td>n</td><td>y</td></tr> </table> -<p>The OpenGL ES state trackers and APIs are then used by <code>src/gallium/state_trackers/es/</code> to create the final libraries.</p> - <h3>Dispatch Table</h3> -<p>The ES overlay uses an additional indirection when dispatching fucntions</p> +<p>OpenGL ES has an additional indirection when dispatching fucntions</p> <pre> Mesa: glFoo() --> _mesa_Foo() - ES overlay: glFoo() --> _es_Foo() --> _mesa_Foo() + OpenGL ES: glFoo() --> _es_Foo() --> _mesa_Foo() </pre> <p>The indirection serves several purposes</p> @@ -73,7 +74,7 @@ for more information about EGL.</p> <li>When a function is not available in Mesa, or accepts arguments that are not available in OpenGL, it provides its own implementation.</li> </ul> -<p>Other than the last case, the ES overlay uses <code>APIspec.xml</code> to generate functions to check and/or converts the arguments.</p> +<p>Other than the last case, OpenGL ES uses <code>APIspec.xml</code> to generate functions to check and/or converts the arguments.</p> </body> </html> diff --git a/docs/relnotes-7.8.2.html b/docs/relnotes-7.8.2.html index 2194b651b73..e1b0f2d2791 100644 --- a/docs/relnotes-7.8.2.html +++ b/docs/relnotes-7.8.2.html @@ -8,7 +8,7 @@ <body bgcolor="#eeeeee"> -<H1>Mesa 7.8.2 Release Notes / April, 5, 2010</H1> +<H1>Mesa 7.8.2 Release Notes / (date tbd)</H1> <p> Mesa 7.8.2 is a bug fix release which fixes bugs found since the 7.8.1 release. @@ -43,6 +43,7 @@ tbd <h2>Bug fixes</h2> <ul> <li>Fixed Gallium glDrawPixels(GL_DEPTH_COMPONENT). +<li>Fixed Gallium Cell driver to buildable, runable state </ul> diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h index a9e598d6dd6..e9f5a49b488 100644 --- a/include/EGL/eglext.h +++ b/include/EGL/eglext.h @@ -227,6 +227,25 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOPYCONTEXTMESA) (EGLDisplay dpy, EGLCont #define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 #endif + +#ifndef EGL_NOK_swap_region +#define EGL_NOK_swap_region 1 + +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint* rects); +#endif + +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOK) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint* rects); +#endif + + +#ifndef EGL_NOK_texture_from_pixmap +#define EGL_NOK_texture_from_pixmap 1 + +#define EGL_Y_INVERTED_NOK 0x307F +#endif /* EGL_NOK_texture_from_pixmap */ + + #ifdef __cplusplus } #endif diff --git a/include/GL/glew.h b/include/GL/glew.h index 04b8f7ed21f..189270e64d8 100644 --- a/include/GL/glew.h +++ b/include/GL/glew.h @@ -197,7 +197,14 @@ typedef _W64 int ptrdiff_t; */ #include <stddef.h> + +/* SGI MIPSPro doesn't like stdint.h in C++ mode */ + +#if defined(__sgi) && !defined(__GNUC__) +#include <inttypes.h> +#else #include <stdint.h> +#endif #define GLEW_APIENTRY_DEFINED #define APIENTRY @@ -1459,9 +1466,9 @@ typedef void (GLAPIENTRY * PFNGLFOGCOORDFVPROC) (const GLfloat *coord); typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, GLfloat *params); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVPROC) (GLenum pname, GLint *params); +typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); @@ -2248,6 +2255,9 @@ typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint, GLint, GLenum #define GL_SIGNED_NORMALIZED 0x8F9C #define GL_PRIMITIVE_RESTART 0x8F9D #define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum, GLint, GLsizei, GLsizei); typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum, GLsizei, GLenum, const GLvoid*, GLsizei); @@ -2303,6 +2313,63 @@ typedef void (GLAPIENTRY * PFNGLGETINTEGER64I_VPROC) (GLenum, GLuint, GLint64 *) #endif /* GL_VERSION_3_2 */ +/* ----------------------------- GL_VERSION_3_3 ---------------------------- */ + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 + +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_RGB10_A2UI 0x906F + +#define GLEW_VERSION_3_3 GLEW_GET_VAR(__GLEW_VERSION_3_3) + +#endif /* GL_VERSION_3_3 */ + +/* ----------------------------- GL_VERSION_4_0 ---------------------------- */ + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 + +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS 0x8F9F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F + +typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (GLAPIENTRY * PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGPROC) (GLclampf value); + +#define glBlendEquationSeparatei GLEW_GET_FUN(__glewBlendEquationSeparatei) +#define glBlendEquationi GLEW_GET_FUN(__glewBlendEquationi) +#define glBlendFuncSeparatei GLEW_GET_FUN(__glewBlendFuncSeparatei) +#define glBlendFunci GLEW_GET_FUN(__glewBlendFunci) +#define glMinSampleShading GLEW_GET_FUN(__glewMinSampleShading) + +#define GLEW_VERSION_4_0 GLEW_GET_VAR(__GLEW_VERSION_4_0) + +#endif /* GL_VERSION_4_0 */ + /* -------------------------- GL_3DFX_multisample -------------------------- */ #ifndef GL_3DFX_multisample @@ -2342,6 +2409,15 @@ typedef void (GLAPIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); #endif /* GL_3DFX_texture_compression_FXT1 */ +/* ----------------------- GL_AMD_conservative_depth ----------------------- */ + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 + +#define GLEW_AMD_conservative_depth GLEW_GET_VAR(__GLEW_AMD_conservative_depth) + +#endif /* GL_AMD_conservative_depth */ + /* ----------------------- GL_AMD_draw_buffers_blend ----------------------- */ #ifndef GL_AMD_draw_buffers_blend @@ -2404,6 +2480,26 @@ typedef void (GLAPIENTRY * PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monito #endif /* GL_AMD_performance_monitor */ +/* ------------------ GL_AMD_seamless_cubemap_per_texture ------------------ */ + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 + +#define GL_TEXTURE_CUBE_MAP_SEAMLESS_ARB 0x884F + +#define GLEW_AMD_seamless_cubemap_per_texture GLEW_GET_VAR(__GLEW_AMD_seamless_cubemap_per_texture) + +#endif /* GL_AMD_seamless_cubemap_per_texture */ + +/* ---------------------- GL_AMD_shader_stencil_export --------------------- */ + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 + +#define GLEW_AMD_shader_stencil_export GLEW_GET_VAR(__GLEW_AMD_shader_stencil_export) + +#endif /* GL_AMD_shader_stencil_export */ + /* ------------------------ GL_AMD_texture_texture4 ------------------------ */ #ifndef GL_AMD_texture_texture4 @@ -2463,9 +2559,9 @@ typedef void (GLAPIENTRY * PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); #ifndef GL_APPLE_element_array #define GL_APPLE_element_array 1 -#define GL_ELEMENT_ARRAY_APPLE 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); @@ -2690,6 +2786,7 @@ typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); #define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F #define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE 0x8520 #define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 #define GL_STORAGE_CACHED_APPLE 0x85BE #define GL_STORAGE_SHARED_APPLE 0x85BF @@ -2754,6 +2851,26 @@ typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuin #endif /* GL_APPLE_ycbcr_422 */ +/* ----------------------- GL_ARB_blend_func_extended ---------------------- */ + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 + +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC + +typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const char * name); +typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const char * name); + +#define glBindFragDataLocationIndexed GLEW_GET_FUN(__glewBindFragDataLocationIndexed) +#define glGetFragDataIndex GLEW_GET_FUN(__glewGetFragDataIndex) + +#define GLEW_ARB_blend_func_extended GLEW_GET_VAR(__GLEW_ARB_blend_func_extended) + +#endif /* GL_ARB_blend_func_extended */ + /* ----------------------- GL_ARB_color_buffer_float ----------------------- */ #ifndef GL_ARB_color_buffer_float @@ -2906,6 +3023,24 @@ typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, G #endif /* GL_ARB_draw_elements_base_vertex */ +/* -------------------------- GL_ARB_draw_indirect ------------------------- */ + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 + +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 + +typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void* indirect); +typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void* indirect); + +#define glDrawArraysIndirect GLEW_GET_FUN(__glewDrawArraysIndirect) +#define glDrawElementsIndirect GLEW_GET_FUN(__glewDrawElementsIndirect) + +#define GLEW_ARB_draw_indirect GLEW_GET_VAR(__GLEW_ARB_draw_indirect) + +#endif /* GL_ARB_draw_indirect */ + /* ------------------------- GL_ARB_draw_instanced ------------------------- */ #ifndef GL_ARB_draw_instanced @@ -2921,6 +3056,15 @@ typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsi #endif /* GL_ARB_draw_instanced */ +/* -------------------- GL_ARB_explicit_attrib_location -------------------- */ + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 + +#define GLEW_ARB_explicit_attrib_location GLEW_GET_VAR(__GLEW_ARB_explicit_attrib_location) + +#endif /* GL_ARB_explicit_attrib_location */ + /* ------------------- GL_ARB_fragment_coord_conventions ------------------- */ #ifndef GL_ARB_fragment_coord_conventions @@ -3153,6 +3297,31 @@ typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenu #endif /* GL_ARB_geometry_shader4 */ +/* --------------------------- GL_ARB_gpu_shader5 -------------------------- */ + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 + +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 + +#define GLEW_ARB_gpu_shader5 GLEW_GET_VAR(__GLEW_ARB_gpu_shader5) + +#endif /* GL_ARB_gpu_shader5 */ + +/* ------------------------- GL_ARB_gpu_shader_fp64 ------------------------ */ + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 + +#define GLEW_ARB_gpu_shader_fp64 GLEW_GET_VAR(__GLEW_ARB_gpu_shader_fp64) + +#endif /* GL_ARB_gpu_shader_fp64 */ + /* ------------------------ GL_ARB_half_float_pixel ------------------------ */ #ifndef GL_ARB_half_float_pixel @@ -3568,6 +3737,17 @@ typedef GLboolean (GLAPIENTRY * PFNGLISQUERYARBPROC) (GLuint id); #endif /* GL_ARB_occlusion_query */ +/* ------------------------ GL_ARB_occlusion_query2 ------------------------ */ + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 + +#define GL_ANY_SAMPLES_PASSED 0x8C2F + +#define GLEW_ARB_occlusion_query2 GLEW_GET_VAR(__GLEW_ARB_occlusion_query2) + +#endif /* GL_ARB_occlusion_query2 */ + /* ----------------------- GL_ARB_pixel_buffer_object ---------------------- */ #ifndef GL_ARB_pixel_buffer_object @@ -3648,6 +3828,47 @@ typedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value); #endif /* GL_ARB_sample_shading */ +/* ------------------------- GL_ARB_sampler_objects ------------------------ */ + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 + +#define GL_SAMPLER_BINDING 0x8919 + +typedef void (GLAPIENTRY * PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (GLAPIENTRY * PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint * samplers); +typedef void (GLAPIENTRY * PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint* samplers); +typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint* params); +typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint* params); +typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat* params); +typedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint* params); +typedef GLboolean (GLAPIENTRY * PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint* params); +typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint* params); +typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat* params); +typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint* params); + +#define glBindSampler GLEW_GET_FUN(__glewBindSampler) +#define glDeleteSamplers GLEW_GET_FUN(__glewDeleteSamplers) +#define glGenSamplers GLEW_GET_FUN(__glewGenSamplers) +#define glGetSamplerParameterIiv GLEW_GET_FUN(__glewGetSamplerParameterIiv) +#define glGetSamplerParameterIuiv GLEW_GET_FUN(__glewGetSamplerParameterIuiv) +#define glGetSamplerParameterfv GLEW_GET_FUN(__glewGetSamplerParameterfv) +#define glGetSamplerParameteriv GLEW_GET_FUN(__glewGetSamplerParameteriv) +#define glIsSampler GLEW_GET_FUN(__glewIsSampler) +#define glSamplerParameterIiv GLEW_GET_FUN(__glewSamplerParameterIiv) +#define glSamplerParameterIuiv GLEW_GET_FUN(__glewSamplerParameterIuiv) +#define glSamplerParameterf GLEW_GET_FUN(__glewSamplerParameterf) +#define glSamplerParameterfv GLEW_GET_FUN(__glewSamplerParameterfv) +#define glSamplerParameteri GLEW_GET_FUN(__glewSamplerParameteri) +#define glSamplerParameteriv GLEW_GET_FUN(__glewSamplerParameteriv) + +#define GLEW_ARB_sampler_objects GLEW_GET_VAR(__GLEW_ARB_sampler_objects) + +#endif /* GL_ARB_sampler_objects */ + /* ------------------------ GL_ARB_seamless_cube_map ----------------------- */ #ifndef GL_ARB_seamless_cube_map @@ -3659,6 +3880,15 @@ typedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value); #endif /* GL_ARB_seamless_cube_map */ +/* ----------------------- GL_ARB_shader_bit_encoding ---------------------- */ + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 + +#define GLEW_ARB_shader_bit_encoding GLEW_GET_VAR(__GLEW_ARB_shader_bit_encoding) + +#endif /* GL_ARB_shader_bit_encoding */ + /* ------------------------- GL_ARB_shader_objects ------------------------- */ #ifndef GL_ARB_shader_objects @@ -3786,6 +4016,43 @@ typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj) #endif /* GL_ARB_shader_objects */ +/* ------------------------ GL_ARB_shader_subroutine ----------------------- */ + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 + +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B + +typedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei* length, char *name); +typedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei* length, char *name); +typedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint* values); +typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint* values); +typedef GLuint (GLAPIENTRY * PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const char* name); +typedef GLint (GLAPIENTRY * PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const char* name); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint* params); +typedef void (GLAPIENTRY * PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint* indices); + +#define glGetActiveSubroutineName GLEW_GET_FUN(__glewGetActiveSubroutineName) +#define glGetActiveSubroutineUniformName GLEW_GET_FUN(__glewGetActiveSubroutineUniformName) +#define glGetActiveSubroutineUniformiv GLEW_GET_FUN(__glewGetActiveSubroutineUniformiv) +#define glGetProgramStageiv GLEW_GET_FUN(__glewGetProgramStageiv) +#define glGetSubroutineIndex GLEW_GET_FUN(__glewGetSubroutineIndex) +#define glGetSubroutineUniformLocation GLEW_GET_FUN(__glewGetSubroutineUniformLocation) +#define glGetUniformSubroutineuiv GLEW_GET_FUN(__glewGetUniformSubroutineuiv) +#define glUniformSubroutinesuiv GLEW_GET_FUN(__glewUniformSubroutinesuiv) + +#define GLEW_ARB_shader_subroutine GLEW_GET_VAR(__GLEW_ARB_shader_subroutine) + +#endif /* GL_ARB_shader_subroutine */ + /* ----------------------- GL_ARB_shader_texture_lod ----------------------- */ #ifndef GL_ARB_shader_texture_lod @@ -3806,6 +4073,33 @@ typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj) #endif /* GL_ARB_shading_language_100 */ +/* -------------------- GL_ARB_shading_language_include -------------------- */ + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 + +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA + +typedef void (GLAPIENTRY * PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const char ** path, const GLint *length); +typedef void (GLAPIENTRY * PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const char* name); +typedef void (GLAPIENTRY * PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const char* name, GLsizei bufSize, GLint *stringlen, char *string); +typedef void (GLAPIENTRY * PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const char* name, GLenum pname, GLint *params); +typedef GLboolean (GLAPIENTRY * PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const char* name); +typedef void (GLAPIENTRY * PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const char* name, GLint stringlen, const char *string); + +#define glCompileShaderIncludeARB GLEW_GET_FUN(__glewCompileShaderIncludeARB) +#define glDeleteNamedStringARB GLEW_GET_FUN(__glewDeleteNamedStringARB) +#define glGetNamedStringARB GLEW_GET_FUN(__glewGetNamedStringARB) +#define glGetNamedStringivARB GLEW_GET_FUN(__glewGetNamedStringivARB) +#define glIsNamedStringARB GLEW_GET_FUN(__glewIsNamedStringARB) +#define glNamedStringARB GLEW_GET_FUN(__glewNamedStringARB) + +#define GLEW_ARB_shading_language_include GLEW_GET_VAR(__GLEW_ARB_shading_language_include) + +#endif /* GL_ARB_shading_language_include */ + /* ----------------------------- GL_ARB_shadow ----------------------------- */ #ifndef GL_ARB_shadow @@ -3871,6 +4165,54 @@ typedef void (GLAPIENTRY * PFNGLWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GL #endif /* GL_ARB_sync */ +/* ----------------------- GL_ARB_tessellation_shader ---------------------- */ + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 + +#define GL_PATCHES 0xE +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A + +typedef void (GLAPIENTRY * PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat* values); +typedef void (GLAPIENTRY * PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); + +#define glPatchParameterfv GLEW_GET_FUN(__glewPatchParameterfv) +#define glPatchParameteri GLEW_GET_FUN(__glewPatchParameteri) + +#define GLEW_ARB_tessellation_shader GLEW_GET_VAR(__GLEW_ARB_tessellation_shader) + +#endif /* GL_ARB_tessellation_shader */ + /* ---------------------- GL_ARB_texture_border_clamp ---------------------- */ #ifndef GL_ARB_texture_border_clamp @@ -3901,6 +4243,15 @@ typedef void (GLAPIENTRY * PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum interna #endif /* GL_ARB_texture_buffer_object */ +/* ------------------- GL_ARB_texture_buffer_object_rgb32 ------------------ */ + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 + +#define GLEW_ARB_texture_buffer_object_rgb32 GLEW_GET_VAR(__GLEW_ARB_texture_buffer_object_rgb32) + +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + /* ----------------------- GL_ARB_texture_compression ---------------------- */ #ifndef GL_ARB_texture_compression @@ -3938,6 +4289,20 @@ typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GL #endif /* GL_ARB_texture_compression */ +/* -------------------- GL_ARB_texture_compression_bptc -------------------- */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 + +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F + +#define GLEW_ARB_texture_compression_bptc GLEW_GET_VAR(__GLEW_ARB_texture_compression_bptc) + +#endif /* GL_ARB_texture_compression_bptc */ + /* -------------------- GL_ARB_texture_compression_rgtc -------------------- */ #ifndef GL_ARB_texture_compression_rgtc @@ -4217,6 +4582,104 @@ typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsiz #endif /* GL_ARB_texture_rg */ +/* ----------------------- GL_ARB_texture_rgb10_a2ui ----------------------- */ + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 + +#define GL_RGB10_A2UI 0x906F + +#define GLEW_ARB_texture_rgb10_a2ui GLEW_GET_VAR(__GLEW_ARB_texture_rgb10_a2ui) + +#endif /* GL_ARB_texture_rgb10_a2ui */ + +/* ------------------------- GL_ARB_texture_swizzle ------------------------ */ + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 + +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 + +#define GLEW_ARB_texture_swizzle GLEW_GET_VAR(__GLEW_ARB_texture_swizzle) + +#endif /* GL_ARB_texture_swizzle */ + +/* --------------------------- GL_ARB_timer_query -------------------------- */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 + +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 + +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64* params); +typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64* params); +typedef void (GLAPIENTRY * PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); + +#define glGetQueryObjecti64v GLEW_GET_FUN(__glewGetQueryObjecti64v) +#define glGetQueryObjectui64v GLEW_GET_FUN(__glewGetQueryObjectui64v) +#define glQueryCounter GLEW_GET_FUN(__glewQueryCounter) + +#define GLEW_ARB_timer_query GLEW_GET_VAR(__GLEW_ARB_timer_query) + +#endif /* GL_ARB_timer_query */ + +/* ----------------------- GL_ARB_transform_feedback2 ---------------------- */ + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 + +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 + +typedef void (GLAPIENTRY * PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (GLAPIENTRY * PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint* ids); +typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +typedef void (GLAPIENTRY * PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint* ids); +typedef GLboolean (GLAPIENTRY * PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (GLAPIENTRY * PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (GLAPIENTRY * PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); + +#define glBindTransformFeedback GLEW_GET_FUN(__glewBindTransformFeedback) +#define glDeleteTransformFeedbacks GLEW_GET_FUN(__glewDeleteTransformFeedbacks) +#define glDrawTransformFeedback GLEW_GET_FUN(__glewDrawTransformFeedback) +#define glGenTransformFeedbacks GLEW_GET_FUN(__glewGenTransformFeedbacks) +#define glIsTransformFeedback GLEW_GET_FUN(__glewIsTransformFeedback) +#define glPauseTransformFeedback GLEW_GET_FUN(__glewPauseTransformFeedback) +#define glResumeTransformFeedback GLEW_GET_FUN(__glewResumeTransformFeedback) + +#define GLEW_ARB_transform_feedback2 GLEW_GET_VAR(__GLEW_ARB_transform_feedback2) + +#endif /* GL_ARB_transform_feedback2 */ + +/* ----------------------- GL_ARB_transform_feedback3 ---------------------- */ + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 + +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +#define GL_MAX_VERTEX_STREAMS 0x8E71 + +typedef void (GLAPIENTRY * PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (GLAPIENTRY * PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (GLAPIENTRY * PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params); + +#define glBeginQueryIndexed GLEW_GET_FUN(__glewBeginQueryIndexed) +#define glDrawTransformFeedbackStream GLEW_GET_FUN(__glewDrawTransformFeedbackStream) +#define glEndQueryIndexed GLEW_GET_FUN(__glewEndQueryIndexed) +#define glGetQueryIndexediv GLEW_GET_FUN(__glewGetQueryIndexediv) + +#define GLEW_ARB_transform_feedback3 GLEW_GET_VAR(__GLEW_ARB_transform_feedback3) + +#endif /* GL_ARB_transform_feedback3 */ + /* ------------------------ GL_ARB_transpose_matrix ------------------------ */ #ifndef GL_ARB_transpose_matrix @@ -4720,6 +5183,96 @@ typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programO #endif /* GL_ARB_vertex_shader */ +/* ------------------- GL_ARB_vertex_type_2_10_10_10_rev ------------------- */ + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 + +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_INT_2_10_10_10_REV 0x8D9F + +typedef void (GLAPIENTRY * PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (GLAPIENTRY * PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint* color); +typedef void (GLAPIENTRY * PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (GLAPIENTRY * PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint* color); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint* coords); +typedef void (GLAPIENTRY * PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (GLAPIENTRY * PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint* coords); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint* color); +typedef void (GLAPIENTRY * PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (GLAPIENTRY * PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint* coords); +typedef void (GLAPIENTRY * PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (GLAPIENTRY * PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint* coords); +typedef void (GLAPIENTRY * PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (GLAPIENTRY * PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint* coords); +typedef void (GLAPIENTRY * PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (GLAPIENTRY * PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint* coords); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value); +typedef void (GLAPIENTRY * PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (GLAPIENTRY * PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint* value); +typedef void (GLAPIENTRY * PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (GLAPIENTRY * PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint* value); +typedef void (GLAPIENTRY * PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (GLAPIENTRY * PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint* value); + +#define glColorP3ui GLEW_GET_FUN(__glewColorP3ui) +#define glColorP3uiv GLEW_GET_FUN(__glewColorP3uiv) +#define glColorP4ui GLEW_GET_FUN(__glewColorP4ui) +#define glColorP4uiv GLEW_GET_FUN(__glewColorP4uiv) +#define glMultiTexCoordP1ui GLEW_GET_FUN(__glewMultiTexCoordP1ui) +#define glMultiTexCoordP1uiv GLEW_GET_FUN(__glewMultiTexCoordP1uiv) +#define glMultiTexCoordP2ui GLEW_GET_FUN(__glewMultiTexCoordP2ui) +#define glMultiTexCoordP2uiv GLEW_GET_FUN(__glewMultiTexCoordP2uiv) +#define glMultiTexCoordP3ui GLEW_GET_FUN(__glewMultiTexCoordP3ui) +#define glMultiTexCoordP3uiv GLEW_GET_FUN(__glewMultiTexCoordP3uiv) +#define glMultiTexCoordP4ui GLEW_GET_FUN(__glewMultiTexCoordP4ui) +#define glMultiTexCoordP4uiv GLEW_GET_FUN(__glewMultiTexCoordP4uiv) +#define glNormalP3ui GLEW_GET_FUN(__glewNormalP3ui) +#define glNormalP3uiv GLEW_GET_FUN(__glewNormalP3uiv) +#define glSecondaryColorP3ui GLEW_GET_FUN(__glewSecondaryColorP3ui) +#define glSecondaryColorP3uiv GLEW_GET_FUN(__glewSecondaryColorP3uiv) +#define glTexCoordP1ui GLEW_GET_FUN(__glewTexCoordP1ui) +#define glTexCoordP1uiv GLEW_GET_FUN(__glewTexCoordP1uiv) +#define glTexCoordP2ui GLEW_GET_FUN(__glewTexCoordP2ui) +#define glTexCoordP2uiv GLEW_GET_FUN(__glewTexCoordP2uiv) +#define glTexCoordP3ui GLEW_GET_FUN(__glewTexCoordP3ui) +#define glTexCoordP3uiv GLEW_GET_FUN(__glewTexCoordP3uiv) +#define glTexCoordP4ui GLEW_GET_FUN(__glewTexCoordP4ui) +#define glTexCoordP4uiv GLEW_GET_FUN(__glewTexCoordP4uiv) +#define glVertexAttribP1ui GLEW_GET_FUN(__glewVertexAttribP1ui) +#define glVertexAttribP1uiv GLEW_GET_FUN(__glewVertexAttribP1uiv) +#define glVertexAttribP2ui GLEW_GET_FUN(__glewVertexAttribP2ui) +#define glVertexAttribP2uiv GLEW_GET_FUN(__glewVertexAttribP2uiv) +#define glVertexAttribP3ui GLEW_GET_FUN(__glewVertexAttribP3ui) +#define glVertexAttribP3uiv GLEW_GET_FUN(__glewVertexAttribP3uiv) +#define glVertexAttribP4ui GLEW_GET_FUN(__glewVertexAttribP4ui) +#define glVertexAttribP4uiv GLEW_GET_FUN(__glewVertexAttribP4uiv) +#define glVertexP2ui GLEW_GET_FUN(__glewVertexP2ui) +#define glVertexP2uiv GLEW_GET_FUN(__glewVertexP2uiv) +#define glVertexP3ui GLEW_GET_FUN(__glewVertexP3ui) +#define glVertexP3uiv GLEW_GET_FUN(__glewVertexP3uiv) +#define glVertexP4ui GLEW_GET_FUN(__glewVertexP4ui) +#define glVertexP4uiv GLEW_GET_FUN(__glewVertexP4uiv) + +#define GLEW_ARB_vertex_type_2_10_10_10_rev GLEW_GET_VAR(__GLEW_ARB_vertex_type_2_10_10_10_rev) + +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ + /* --------------------------- GL_ARB_window_pos --------------------------- */ #ifndef GL_ARB_window_pos @@ -5635,6 +6188,10 @@ typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint #ifndef GL_EXT_cull_vertex #define GL_EXT_cull_vertex 1 +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC + typedef void (GLAPIENTRY * PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble* params); typedef void (GLAPIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params); @@ -7034,6 +7591,77 @@ typedef void (GLAPIENTRY * PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint pr #endif /* GL_EXT_separate_specular_color */ +/* --------------------- GL_EXT_shader_image_load_store -------------------- */ + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 + +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF + +typedef void (GLAPIENTRY * PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (GLAPIENTRY * PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); + +#define glBindImageTextureEXT GLEW_GET_FUN(__glewBindImageTextureEXT) +#define glMemoryBarrierEXT GLEW_GET_FUN(__glewMemoryBarrierEXT) + +#define GLEW_EXT_shader_image_load_store GLEW_GET_VAR(__GLEW_EXT_shader_image_load_store) + +#endif /* GL_EXT_shader_image_load_store */ + /* -------------------------- GL_EXT_shadow_funcs -------------------------- */ #ifndef GL_EXT_shadow_funcs @@ -7772,6 +8400,46 @@ typedef void (GLAPIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, #endif /* GL_EXT_vertex_array_bgra */ +/* ----------------------- GL_EXT_vertex_attrib_64bit ---------------------- */ + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 + +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE + +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble* params); +typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer); + +#define glGetVertexAttribLdvEXT GLEW_GET_FUN(__glewGetVertexAttribLdvEXT) +#define glVertexArrayVertexAttribLOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribLOffsetEXT) +#define glVertexAttribL1dEXT GLEW_GET_FUN(__glewVertexAttribL1dEXT) +#define glVertexAttribL1dvEXT GLEW_GET_FUN(__glewVertexAttribL1dvEXT) +#define glVertexAttribL2dEXT GLEW_GET_FUN(__glewVertexAttribL2dEXT) +#define glVertexAttribL2dvEXT GLEW_GET_FUN(__glewVertexAttribL2dvEXT) +#define glVertexAttribL3dEXT GLEW_GET_FUN(__glewVertexAttribL3dEXT) +#define glVertexAttribL3dvEXT GLEW_GET_FUN(__glewVertexAttribL3dvEXT) +#define glVertexAttribL4dEXT GLEW_GET_FUN(__glewVertexAttribL4dEXT) +#define glVertexAttribL4dvEXT GLEW_GET_FUN(__glewVertexAttribL4dvEXT) +#define glVertexAttribLPointerEXT GLEW_GET_FUN(__glewVertexAttribLPointerEXT) + +#define GLEW_EXT_vertex_attrib_64bit GLEW_GET_VAR(__GLEW_EXT_vertex_attrib_64bit) + +#endif /* GL_EXT_vertex_attrib_64bit */ + /* -------------------------- GL_EXT_vertex_shader ------------------------- */ #ifndef GL_EXT_vertex_shader @@ -8801,6 +9469,137 @@ typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum targe #endif /* GL_NV_gpu_program4 */ +/* --------------------------- GL_NV_gpu_program5 -------------------------- */ + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 + +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D + +#define GLEW_NV_gpu_program5 GLEW_GET_VAR(__GLEW_NV_gpu_program5) + +#endif /* GL_NV_gpu_program5 */ + +/* ------------------------- GL_NV_gpu_program_fp64 ------------------------ */ + +#ifndef GL_NV_gpu_program_fp64 +#define GL_NV_gpu_program_fp64 1 + +#define GLEW_NV_gpu_program_fp64 GLEW_GET_VAR(__GLEW_NV_gpu_program_fp64) + +#endif /* GL_NV_gpu_program_fp64 */ + +/* --------------------------- GL_NV_gpu_shader5 --------------------------- */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 + +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB + +typedef void (GLAPIENTRY * PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT* params); +typedef void (GLAPIENTRY * PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT* params); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (GLAPIENTRY * PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (GLAPIENTRY * PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (GLAPIENTRY * PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (GLAPIENTRY * PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (GLAPIENTRY * PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (GLAPIENTRY * PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (GLAPIENTRY * PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value); +typedef void (GLAPIENTRY * PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (GLAPIENTRY * PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); + +#define glGetUniformi64vNV GLEW_GET_FUN(__glewGetUniformi64vNV) +#define glGetUniformui64vNV GLEW_GET_FUN(__glewGetUniformui64vNV) +#define glProgramUniform1i64NV GLEW_GET_FUN(__glewProgramUniform1i64NV) +#define glProgramUniform1i64vNV GLEW_GET_FUN(__glewProgramUniform1i64vNV) +#define glProgramUniform1ui64NV GLEW_GET_FUN(__glewProgramUniform1ui64NV) +#define glProgramUniform1ui64vNV GLEW_GET_FUN(__glewProgramUniform1ui64vNV) +#define glProgramUniform2i64NV GLEW_GET_FUN(__glewProgramUniform2i64NV) +#define glProgramUniform2i64vNV GLEW_GET_FUN(__glewProgramUniform2i64vNV) +#define glProgramUniform2ui64NV GLEW_GET_FUN(__glewProgramUniform2ui64NV) +#define glProgramUniform2ui64vNV GLEW_GET_FUN(__glewProgramUniform2ui64vNV) +#define glProgramUniform3i64NV GLEW_GET_FUN(__glewProgramUniform3i64NV) +#define glProgramUniform3i64vNV GLEW_GET_FUN(__glewProgramUniform3i64vNV) +#define glProgramUniform3ui64NV GLEW_GET_FUN(__glewProgramUniform3ui64NV) +#define glProgramUniform3ui64vNV GLEW_GET_FUN(__glewProgramUniform3ui64vNV) +#define glProgramUniform4i64NV GLEW_GET_FUN(__glewProgramUniform4i64NV) +#define glProgramUniform4i64vNV GLEW_GET_FUN(__glewProgramUniform4i64vNV) +#define glProgramUniform4ui64NV GLEW_GET_FUN(__glewProgramUniform4ui64NV) +#define glProgramUniform4ui64vNV GLEW_GET_FUN(__glewProgramUniform4ui64vNV) +#define glUniform1i64NV GLEW_GET_FUN(__glewUniform1i64NV) +#define glUniform1i64vNV GLEW_GET_FUN(__glewUniform1i64vNV) +#define glUniform1ui64NV GLEW_GET_FUN(__glewUniform1ui64NV) +#define glUniform1ui64vNV GLEW_GET_FUN(__glewUniform1ui64vNV) +#define glUniform2i64NV GLEW_GET_FUN(__glewUniform2i64NV) +#define glUniform2i64vNV GLEW_GET_FUN(__glewUniform2i64vNV) +#define glUniform2ui64NV GLEW_GET_FUN(__glewUniform2ui64NV) +#define glUniform2ui64vNV GLEW_GET_FUN(__glewUniform2ui64vNV) +#define glUniform3i64NV GLEW_GET_FUN(__glewUniform3i64NV) +#define glUniform3i64vNV GLEW_GET_FUN(__glewUniform3i64vNV) +#define glUniform3ui64NV GLEW_GET_FUN(__glewUniform3ui64NV) +#define glUniform3ui64vNV GLEW_GET_FUN(__glewUniform3ui64vNV) +#define glUniform4i64NV GLEW_GET_FUN(__glewUniform4i64NV) +#define glUniform4i64vNV GLEW_GET_FUN(__glewUniform4i64vNV) +#define glUniform4ui64NV GLEW_GET_FUN(__glewUniform4ui64NV) +#define glUniform4ui64vNV GLEW_GET_FUN(__glewUniform4ui64vNV) + +#define GLEW_NV_gpu_shader5 GLEW_GET_VAR(__GLEW_NV_gpu_shader5) + +#endif /* GL_NV_gpu_shader5 */ + /* ---------------------------- GL_NV_half_float --------------------------- */ #ifndef GL_NV_half_float @@ -9212,7 +10011,6 @@ typedef void (GLAPIENTRY * PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT* params); typedef void (GLAPIENTRY * PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT* result); typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT* params); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT* params); typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); typedef GLboolean (GLAPIENTRY * PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); typedef void (GLAPIENTRY * PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); @@ -9227,7 +10025,6 @@ typedef void (GLAPIENTRY * PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei cou #define glGetBufferParameterui64vNV GLEW_GET_FUN(__glewGetBufferParameterui64vNV) #define glGetIntegerui64vNV GLEW_GET_FUN(__glewGetIntegerui64vNV) #define glGetNamedBufferParameterui64vNV GLEW_GET_FUN(__glewGetNamedBufferParameterui64vNV) -#define glGetUniformui64vNV GLEW_GET_FUN(__glewGetUniformui64vNV) #define glIsBufferResidentNV GLEW_GET_FUN(__glewIsBufferResidentNV) #define glIsNamedBufferResidentNV GLEW_GET_FUN(__glewIsNamedBufferResidentNV) #define glMakeBufferNonResidentNV GLEW_GET_FUN(__glewMakeBufferNonResidentNV) @@ -9243,6 +10040,21 @@ typedef void (GLAPIENTRY * PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei cou #endif /* GL_NV_shader_buffer_load */ +/* ---------------------- GL_NV_tessellation_program5 ---------------------- */ + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 + +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 + +#define GLEW_NV_tessellation_program5 GLEW_GET_VAR(__GLEW_NV_tessellation_program5) + +#endif /* GL_NV_tessellation_program5 */ + /* -------------------------- GL_NV_texgen_emboss -------------------------- */ #ifndef GL_NV_texgen_emboss @@ -9599,6 +10411,58 @@ typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, void* p #endif /* GL_NV_vertex_array_range2 */ +/* ------------------- GL_NV_vertex_attrib_integer_64bit ------------------- */ + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 + +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F + +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT* params); +typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT* params); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT* v); +typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); + +#define glGetVertexAttribLi64vNV GLEW_GET_FUN(__glewGetVertexAttribLi64vNV) +#define glGetVertexAttribLui64vNV GLEW_GET_FUN(__glewGetVertexAttribLui64vNV) +#define glVertexAttribL1i64NV GLEW_GET_FUN(__glewVertexAttribL1i64NV) +#define glVertexAttribL1i64vNV GLEW_GET_FUN(__glewVertexAttribL1i64vNV) +#define glVertexAttribL1ui64NV GLEW_GET_FUN(__glewVertexAttribL1ui64NV) +#define glVertexAttribL1ui64vNV GLEW_GET_FUN(__glewVertexAttribL1ui64vNV) +#define glVertexAttribL2i64NV GLEW_GET_FUN(__glewVertexAttribL2i64NV) +#define glVertexAttribL2i64vNV GLEW_GET_FUN(__glewVertexAttribL2i64vNV) +#define glVertexAttribL2ui64NV GLEW_GET_FUN(__glewVertexAttribL2ui64NV) +#define glVertexAttribL2ui64vNV GLEW_GET_FUN(__glewVertexAttribL2ui64vNV) +#define glVertexAttribL3i64NV GLEW_GET_FUN(__glewVertexAttribL3i64NV) +#define glVertexAttribL3i64vNV GLEW_GET_FUN(__glewVertexAttribL3i64vNV) +#define glVertexAttribL3ui64NV GLEW_GET_FUN(__glewVertexAttribL3ui64NV) +#define glVertexAttribL3ui64vNV GLEW_GET_FUN(__glewVertexAttribL3ui64vNV) +#define glVertexAttribL4i64NV GLEW_GET_FUN(__glewVertexAttribL4i64NV) +#define glVertexAttribL4i64vNV GLEW_GET_FUN(__glewVertexAttribL4i64vNV) +#define glVertexAttribL4ui64NV GLEW_GET_FUN(__glewVertexAttribL4ui64NV) +#define glVertexAttribL4ui64vNV GLEW_GET_FUN(__glewVertexAttribL4ui64vNV) +#define glVertexAttribLFormatNV GLEW_GET_FUN(__glewVertexAttribLFormatNV) + +#define GLEW_NV_vertex_attrib_integer_64bit GLEW_GET_VAR(__GLEW_NV_vertex_attrib_integer_64bit) + +#endif /* GL_NV_vertex_attrib_integer_64bit */ + /* ------------------- GL_NV_vertex_buffer_unified_memory ------------------ */ #ifndef GL_NV_vertex_buffer_unified_memory @@ -11441,6 +12305,12 @@ GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREPROC __glewFramebufferTexture; GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERI64VPROC __glewGetBufferParameteri64v; GLEW_FUN_EXPORT PFNGLGETINTEGER64I_VPROC __glewGetInteger64i_v; +GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEIPROC __glewBlendEquationSeparatei; +GLEW_FUN_EXPORT PFNGLBLENDEQUATIONIPROC __glewBlendEquationi; +GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEIPROC __glewBlendFuncSeparatei; +GLEW_FUN_EXPORT PFNGLBLENDFUNCIPROC __glewBlendFunci; +GLEW_FUN_EXPORT PFNGLMINSAMPLESHADINGPROC __glewMinSampleShading; + GLEW_FUN_EXPORT PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX; GLEW_FUN_EXPORT PFNGLBLENDEQUATIONINDEXEDAMDPROC __glewBlendEquationIndexedAMD; @@ -11505,6 +12375,9 @@ GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1FAPPLEPROC __glewMapVertexAttrib1fAPPLE; GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2DAPPLEPROC __glewMapVertexAttrib2dAPPLE; GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2FAPPLEPROC __glewMapVertexAttrib2fAPPLE; +GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONINDEXEDPROC __glewBindFragDataLocationIndexed; +GLEW_FUN_EXPORT PFNGLGETFRAGDATAINDEXPROC __glewGetFragDataIndex; + GLEW_FUN_EXPORT PFNGLCLAMPCOLORARBPROC __glewClampColorARB; GLEW_FUN_EXPORT PFNGLCOPYBUFFERSUBDATAPROC __glewCopyBufferSubData; @@ -11521,6 +12394,9 @@ GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC __glewDrawElementsInsta GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC __glewDrawRangeElementsBaseVertex; GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC __glewMultiDrawElementsBaseVertex; +GLEW_FUN_EXPORT PFNGLDRAWARRAYSINDIRECTPROC __glewDrawArraysIndirect; +GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINDIRECTPROC __glewDrawElementsIndirect; + GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB; GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB; @@ -11647,6 +12523,21 @@ GLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXPROC __glewProvokingVertex; GLEW_FUN_EXPORT PFNGLMINSAMPLESHADINGARBPROC __glewMinSampleShadingARB; +GLEW_FUN_EXPORT PFNGLBINDSAMPLERPROC __glewBindSampler; +GLEW_FUN_EXPORT PFNGLDELETESAMPLERSPROC __glewDeleteSamplers; +GLEW_FUN_EXPORT PFNGLGENSAMPLERSPROC __glewGenSamplers; +GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIIVPROC __glewGetSamplerParameterIiv; +GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIUIVPROC __glewGetSamplerParameterIuiv; +GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERFVPROC __glewGetSamplerParameterfv; +GLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIVPROC __glewGetSamplerParameteriv; +GLEW_FUN_EXPORT PFNGLISSAMPLERPROC __glewIsSampler; +GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIIVPROC __glewSamplerParameterIiv; +GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIUIVPROC __glewSamplerParameterIuiv; +GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERFPROC __glewSamplerParameterf; +GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERFVPROC __glewSamplerParameterfv; +GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIPROC __glewSamplerParameteri; +GLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIVPROC __glewSamplerParameteriv; + GLEW_FUN_EXPORT PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB; GLEW_FUN_EXPORT PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB; GLEW_FUN_EXPORT PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB; @@ -11687,6 +12578,22 @@ GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB; GLEW_FUN_EXPORT PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB; GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB; +GLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINENAMEPROC __glewGetActiveSubroutineName; +GLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC __glewGetActiveSubroutineUniformName; +GLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC __glewGetActiveSubroutineUniformiv; +GLEW_FUN_EXPORT PFNGLGETPROGRAMSTAGEIVPROC __glewGetProgramStageiv; +GLEW_FUN_EXPORT PFNGLGETSUBROUTINEINDEXPROC __glewGetSubroutineIndex; +GLEW_FUN_EXPORT PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC __glewGetSubroutineUniformLocation; +GLEW_FUN_EXPORT PFNGLGETUNIFORMSUBROUTINEUIVPROC __glewGetUniformSubroutineuiv; +GLEW_FUN_EXPORT PFNGLUNIFORMSUBROUTINESUIVPROC __glewUniformSubroutinesuiv; + +GLEW_FUN_EXPORT PFNGLCOMPILESHADERINCLUDEARBPROC __glewCompileShaderIncludeARB; +GLEW_FUN_EXPORT PFNGLDELETENAMEDSTRINGARBPROC __glewDeleteNamedStringARB; +GLEW_FUN_EXPORT PFNGLGETNAMEDSTRINGARBPROC __glewGetNamedStringARB; +GLEW_FUN_EXPORT PFNGLGETNAMEDSTRINGIVARBPROC __glewGetNamedStringivARB; +GLEW_FUN_EXPORT PFNGLISNAMEDSTRINGARBPROC __glewIsNamedStringARB; +GLEW_FUN_EXPORT PFNGLNAMEDSTRINGARBPROC __glewNamedStringARB; + GLEW_FUN_EXPORT PFNGLCLIENTWAITSYNCPROC __glewClientWaitSync; GLEW_FUN_EXPORT PFNGLDELETESYNCPROC __glewDeleteSync; GLEW_FUN_EXPORT PFNGLFENCESYNCPROC __glewFenceSync; @@ -11695,6 +12602,9 @@ GLEW_FUN_EXPORT PFNGLGETSYNCIVPROC __glewGetSynciv; GLEW_FUN_EXPORT PFNGLISSYNCPROC __glewIsSync; GLEW_FUN_EXPORT PFNGLWAITSYNCPROC __glewWaitSync; +GLEW_FUN_EXPORT PFNGLPATCHPARAMETERFVPROC __glewPatchParameterfv; +GLEW_FUN_EXPORT PFNGLPATCHPARAMETERIPROC __glewPatchParameteri; + GLEW_FUN_EXPORT PFNGLTEXBUFFERARBPROC __glewTexBufferARB; GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB; @@ -11710,6 +12620,23 @@ GLEW_FUN_EXPORT PFNGLSAMPLEMASKIPROC __glewSampleMaski; GLEW_FUN_EXPORT PFNGLTEXIMAGE2DMULTISAMPLEPROC __glewTexImage2DMultisample; GLEW_FUN_EXPORT PFNGLTEXIMAGE3DMULTISAMPLEPROC __glewTexImage3DMultisample; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VPROC __glewGetQueryObjecti64v; +GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VPROC __glewGetQueryObjectui64v; +GLEW_FUN_EXPORT PFNGLQUERYCOUNTERPROC __glewQueryCounter; + +GLEW_FUN_EXPORT PFNGLBINDTRANSFORMFEEDBACKPROC __glewBindTransformFeedback; +GLEW_FUN_EXPORT PFNGLDELETETRANSFORMFEEDBACKSPROC __glewDeleteTransformFeedbacks; +GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKPROC __glewDrawTransformFeedback; +GLEW_FUN_EXPORT PFNGLGENTRANSFORMFEEDBACKSPROC __glewGenTransformFeedbacks; +GLEW_FUN_EXPORT PFNGLISTRANSFORMFEEDBACKPROC __glewIsTransformFeedback; +GLEW_FUN_EXPORT PFNGLPAUSETRANSFORMFEEDBACKPROC __glewPauseTransformFeedback; +GLEW_FUN_EXPORT PFNGLRESUMETRANSFORMFEEDBACKPROC __glewResumeTransformFeedback; + +GLEW_FUN_EXPORT PFNGLBEGINQUERYINDEXEDPROC __glewBeginQueryIndexed; +GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC __glewDrawTransformFeedbackStream; +GLEW_FUN_EXPORT PFNGLENDQUERYINDEXEDPROC __glewEndQueryIndexed; +GLEW_FUN_EXPORT PFNGLGETQUERYINDEXEDIVPROC __glewGetQueryIndexediv; + GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB; GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB; GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB; @@ -11821,6 +12748,45 @@ GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB; GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB; GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB; +GLEW_FUN_EXPORT PFNGLCOLORP3UIPROC __glewColorP3ui; +GLEW_FUN_EXPORT PFNGLCOLORP3UIVPROC __glewColorP3uiv; +GLEW_FUN_EXPORT PFNGLCOLORP4UIPROC __glewColorP4ui; +GLEW_FUN_EXPORT PFNGLCOLORP4UIVPROC __glewColorP4uiv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP1UIPROC __glewMultiTexCoordP1ui; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP1UIVPROC __glewMultiTexCoordP1uiv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP2UIPROC __glewMultiTexCoordP2ui; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP2UIVPROC __glewMultiTexCoordP2uiv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP3UIPROC __glewMultiTexCoordP3ui; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP3UIVPROC __glewMultiTexCoordP3uiv; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP4UIPROC __glewMultiTexCoordP4ui; +GLEW_FUN_EXPORT PFNGLMULTITEXCOORDP4UIVPROC __glewMultiTexCoordP4uiv; +GLEW_FUN_EXPORT PFNGLNORMALP3UIPROC __glewNormalP3ui; +GLEW_FUN_EXPORT PFNGLNORMALP3UIVPROC __glewNormalP3uiv; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLORP3UIPROC __glewSecondaryColorP3ui; +GLEW_FUN_EXPORT PFNGLSECONDARYCOLORP3UIVPROC __glewSecondaryColorP3uiv; +GLEW_FUN_EXPORT PFNGLTEXCOORDP1UIPROC __glewTexCoordP1ui; +GLEW_FUN_EXPORT PFNGLTEXCOORDP1UIVPROC __glewTexCoordP1uiv; +GLEW_FUN_EXPORT PFNGLTEXCOORDP2UIPROC __glewTexCoordP2ui; +GLEW_FUN_EXPORT PFNGLTEXCOORDP2UIVPROC __glewTexCoordP2uiv; +GLEW_FUN_EXPORT PFNGLTEXCOORDP3UIPROC __glewTexCoordP3ui; +GLEW_FUN_EXPORT PFNGLTEXCOORDP3UIVPROC __glewTexCoordP3uiv; +GLEW_FUN_EXPORT PFNGLTEXCOORDP4UIPROC __glewTexCoordP4ui; +GLEW_FUN_EXPORT PFNGLTEXCOORDP4UIVPROC __glewTexCoordP4uiv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP1UIPROC __glewVertexAttribP1ui; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP1UIVPROC __glewVertexAttribP1uiv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP2UIPROC __glewVertexAttribP2ui; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP2UIVPROC __glewVertexAttribP2uiv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP3UIPROC __glewVertexAttribP3ui; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP3UIVPROC __glewVertexAttribP3uiv; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP4UIPROC __glewVertexAttribP4ui; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBP4UIVPROC __glewVertexAttribP4uiv; +GLEW_FUN_EXPORT PFNGLVERTEXP2UIPROC __glewVertexP2ui; +GLEW_FUN_EXPORT PFNGLVERTEXP2UIVPROC __glewVertexP2uiv; +GLEW_FUN_EXPORT PFNGLVERTEXP3UIPROC __glewVertexP3ui; +GLEW_FUN_EXPORT PFNGLVERTEXP3UIVPROC __glewVertexP3uiv; +GLEW_FUN_EXPORT PFNGLVERTEXP4UIPROC __glewVertexP4ui; +GLEW_FUN_EXPORT PFNGLVERTEXP4UIVPROC __glewVertexP4uiv; + GLEW_FUN_EXPORT PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB; GLEW_FUN_EXPORT PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB; @@ -12359,6 +13325,9 @@ GLEW_FUN_EXPORT PFNGLACTIVEPROGRAMEXTPROC __glewActiveProgramEXT; GLEW_FUN_EXPORT PFNGLCREATESHADERPROGRAMEXTPROC __glewCreateShaderProgramEXT; GLEW_FUN_EXPORT PFNGLUSESHADERPROGRAMEXTPROC __glewUseShaderProgramEXT; +GLEW_FUN_EXPORT PFNGLBINDIMAGETEXTUREEXTPROC __glewBindImageTextureEXT; +GLEW_FUN_EXPORT PFNGLMEMORYBARRIEREXTPROC __glewMemoryBarrierEXT; + GLEW_FUN_EXPORT PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT; GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT; @@ -12406,6 +13375,18 @@ GLEW_FUN_EXPORT PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT; GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT; GLEW_FUN_EXPORT PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLDVEXTPROC __glewGetVertexAttribLdvEXT; +GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC __glewVertexArrayVertexAttribLOffsetEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DEXTPROC __glewVertexAttribL1dEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DVEXTPROC __glewVertexAttribL1dvEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DEXTPROC __glewVertexAttribL2dEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DVEXTPROC __glewVertexAttribL2dvEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DEXTPROC __glewVertexAttribL3dEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DVEXTPROC __glewVertexAttribL3dvEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DEXTPROC __glewVertexAttribL4dEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DVEXTPROC __glewVertexAttribL4dvEXT; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBLPOINTEREXTPROC __glewVertexAttribLPointerEXT; + GLEW_FUN_EXPORT PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT; GLEW_FUN_EXPORT PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT; GLEW_FUN_EXPORT PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT; @@ -12572,6 +13553,41 @@ GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParamete GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV; GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV; +GLEW_FUN_EXPORT PFNGLGETUNIFORMI64VNVPROC __glewGetUniformi64vNV; +GLEW_FUN_EXPORT PFNGLGETUNIFORMUI64VNVPROC __glewGetUniformui64vNV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64NVPROC __glewProgramUniform1i64NV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64VNVPROC __glewProgramUniform1i64vNV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64NVPROC __glewProgramUniform1ui64NV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64VNVPROC __glewProgramUniform1ui64vNV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64NVPROC __glewProgramUniform2i64NV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64VNVPROC __glewProgramUniform2i64vNV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64NVPROC __glewProgramUniform2ui64NV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64VNVPROC __glewProgramUniform2ui64vNV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64NVPROC __glewProgramUniform3i64NV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64VNVPROC __glewProgramUniform3i64vNV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64NVPROC __glewProgramUniform3ui64NV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64VNVPROC __glewProgramUniform3ui64vNV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64NVPROC __glewProgramUniform4i64NV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64VNVPROC __glewProgramUniform4i64vNV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64NVPROC __glewProgramUniform4ui64NV; +GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64VNVPROC __glewProgramUniform4ui64vNV; +GLEW_FUN_EXPORT PFNGLUNIFORM1I64NVPROC __glewUniform1i64NV; +GLEW_FUN_EXPORT PFNGLUNIFORM1I64VNVPROC __glewUniform1i64vNV; +GLEW_FUN_EXPORT PFNGLUNIFORM1UI64NVPROC __glewUniform1ui64NV; +GLEW_FUN_EXPORT PFNGLUNIFORM1UI64VNVPROC __glewUniform1ui64vNV; +GLEW_FUN_EXPORT PFNGLUNIFORM2I64NVPROC __glewUniform2i64NV; +GLEW_FUN_EXPORT PFNGLUNIFORM2I64VNVPROC __glewUniform2i64vNV; +GLEW_FUN_EXPORT PFNGLUNIFORM2UI64NVPROC __glewUniform2ui64NV; +GLEW_FUN_EXPORT PFNGLUNIFORM2UI64VNVPROC __glewUniform2ui64vNV; +GLEW_FUN_EXPORT PFNGLUNIFORM3I64NVPROC __glewUniform3i64NV; +GLEW_FUN_EXPORT PFNGLUNIFORM3I64VNVPROC __glewUniform3i64vNV; +GLEW_FUN_EXPORT PFNGLUNIFORM3UI64NVPROC __glewUniform3ui64NV; +GLEW_FUN_EXPORT PFNGLUNIFORM3UI64VNVPROC __glewUniform3ui64vNV; +GLEW_FUN_EXPORT PFNGLUNIFORM4I64NVPROC __glewUniform4i64NV; +GLEW_FUN_EXPORT PFNGLUNIFORM4I64VNVPROC __glewUniform4i64vNV; +GLEW_FUN_EXPORT PFNGLUNIFORM4UI64NVPROC __glewUniform4ui64NV; +GLEW_FUN_EXPORT PFNGLUNIFORM4UI64VNVPROC __glewUniform4ui64vNV; + GLEW_FUN_EXPORT PFNGLCOLOR3HNVPROC __glewColor3hNV; GLEW_FUN_EXPORT PFNGLCOLOR3HVNVPROC __glewColor3hvNV; GLEW_FUN_EXPORT PFNGLCOLOR4HNVPROC __glewColor4hNV; @@ -12667,7 +13683,6 @@ GLEW_FUN_EXPORT PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStagePar GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERUI64VNVPROC __glewGetBufferParameterui64vNV; GLEW_FUN_EXPORT PFNGLGETINTEGERUI64VNVPROC __glewGetIntegerui64vNV; GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC __glewGetNamedBufferParameterui64vNV; -GLEW_FUN_EXPORT PFNGLGETUNIFORMUI64VNVPROC __glewGetUniformui64vNV; GLEW_FUN_EXPORT PFNGLISBUFFERRESIDENTNVPROC __glewIsBufferResidentNV; GLEW_FUN_EXPORT PFNGLISNAMEDBUFFERRESIDENTNVPROC __glewIsNamedBufferResidentNV; GLEW_FUN_EXPORT PFNGLMAKEBUFFERNONRESIDENTNVPROC __glewMakeBufferNonResidentNV; @@ -12704,6 +13719,26 @@ GLEW_FUN_EXPORT PFNGLRESUMETRANSFORMFEEDBACKNVPROC __glewResumeTransformFeedback GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV; GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLI64VNVPROC __glewGetVertexAttribLi64vNV; +GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLUI64VNVPROC __glewGetVertexAttribLui64vNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1I64NVPROC __glewVertexAttribL1i64NV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1I64VNVPROC __glewVertexAttribL1i64vNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64NVPROC __glewVertexAttribL1ui64NV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64VNVPROC __glewVertexAttribL1ui64vNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2I64NVPROC __glewVertexAttribL2i64NV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2I64VNVPROC __glewVertexAttribL2i64vNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2UI64NVPROC __glewVertexAttribL2ui64NV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2UI64VNVPROC __glewVertexAttribL2ui64vNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3I64NVPROC __glewVertexAttribL3i64NV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3I64VNVPROC __glewVertexAttribL3i64vNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3UI64NVPROC __glewVertexAttribL3ui64NV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3UI64VNVPROC __glewVertexAttribL3ui64vNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4I64NVPROC __glewVertexAttribL4i64NV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4I64VNVPROC __glewVertexAttribL4i64vNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4UI64NVPROC __glewVertexAttribL4ui64NV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4UI64VNVPROC __glewVertexAttribL4ui64vNV; +GLEW_FUN_EXPORT PFNGLVERTEXATTRIBLFORMATNVPROC __glewVertexAttribLFormatNV; + GLEW_FUN_EXPORT PFNGLBUFFERADDRESSRANGENVPROC __glewBufferAddressRangeNV; GLEW_FUN_EXPORT PFNGLCOLORFORMATNVPROC __glewColorFormatNV; GLEW_FUN_EXPORT PFNGLEDGEFLAGFORMATNVPROC __glewEdgeFlagFormatNV; @@ -12936,11 +13971,16 @@ GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_1; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_0; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_1; GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_2; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_3; +GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_0; GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_tbuffer; GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_texture_compression_FXT1; +GLEW_VAR_EXPORT GLboolean __GLEW_AMD_conservative_depth; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_draw_buffers_blend; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_performance_monitor; +GLEW_VAR_EXPORT GLboolean __GLEW_AMD_seamless_cubemap_per_texture; +GLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_stencil_export; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_texture_texture4; GLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_tessellator; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_aux_depth_stencil; @@ -12960,6 +14000,7 @@ GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_object; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_range; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_program_evaluators; GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_ycbcr_422; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_blend_func_extended; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_color_buffer_float; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_compatibility; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_copy_buffer; @@ -12969,7 +14010,9 @@ GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_texture; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers_blend; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_elements_base_vertex; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_indirect; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_instanced; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_explicit_attrib_location; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_coord_conventions; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program_shadow; @@ -12977,6 +14020,8 @@ GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_sRGB; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_geometry_shader4; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader5; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader_fp64; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_pixel; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_imaging; @@ -12986,21 +14031,29 @@ GLEW_VAR_EXPORT GLboolean __GLEW_ARB_matrix_palette; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multisample; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multitexture; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query2; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_pixel_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_parameters; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_sprite; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_provoking_vertex; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sample_shading; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sampler_objects; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_seamless_cube_map; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_bit_encoding; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_objects; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_subroutine; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_texture_lod; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_100; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_include; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow_ambient; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sync; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_tessellation_shader; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_border_clamp; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object_rgb32; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_bptc; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_rgtc; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map_array; @@ -13016,6 +14069,11 @@ GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_non_power_of_two; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_query_lod; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rectangle; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rg; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rgb10_a2ui; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_swizzle; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_timer_query; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback2; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback3; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transpose_matrix; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_uniform_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_bgra; @@ -13024,6 +14082,7 @@ GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_blend; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_buffer_object; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_program; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_shader; +GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_type_2_10_10_10_rev; GLEW_VAR_EXPORT GLboolean __GLEW_ARB_window_pos; GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_point_sprites; GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_combine3; @@ -13103,6 +14162,7 @@ GLEW_VAR_EXPORT GLboolean __GLEW_EXT_scene_marker; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_secondary_color; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_shader_objects; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_specular_color; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shader_image_load_store; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shadow_funcs; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shared_texture_palette; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_clear_tag; @@ -13138,6 +14198,7 @@ GLEW_VAR_EXPORT GLboolean __GLEW_EXT_timer_query; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_transform_feedback; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array_bgra; +GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_attrib_64bit; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_shader; GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_weighting; GLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_frame_terminator; @@ -13182,6 +14243,9 @@ GLEW_VAR_EXPORT GLboolean __GLEW_NV_framebuffer_multisample_coverage; GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_program4; GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_shader4; GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program4; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program5; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program_fp64; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_shader5; GLEW_VAR_EXPORT GLboolean __GLEW_NV_half_float; GLEW_VAR_EXPORT GLboolean __GLEW_NV_light_max_exponent; GLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_filter_hint; @@ -13196,6 +14260,7 @@ GLEW_VAR_EXPORT GLboolean __GLEW_NV_primitive_restart; GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners; GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_buffer_load; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_tessellation_program5; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_emboss; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_reflection; GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_barrier; @@ -13210,6 +14275,7 @@ GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback; GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback2; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range2; +GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_attrib_integer_64bit; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_buffer_unified_memory; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program; GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program1_1; diff --git a/include/GL/glxew.h b/include/GL/glxew.h index f19e573f84d..637ef1eaab7 100644 --- a/include/GL/glxew.h +++ b/include/GL/glxew.h @@ -83,13 +83,16 @@ #ifdef __glxext_h_ #error glxext.h included before glxew.h #endif -#ifdef GLX_H + +#if defined(GLX_H) || defined(__GLX_glx_h__) || defined(__glx_h__) #error glx.h included before glxew.h #endif #define __glxext_h_ -#define __GLX_glx_h__ + #define GLX_H +#define __GLX_glx_h__ +#define __glx_h__ #include <X11/Xlib.h> #include <X11/Xutil.h> @@ -421,6 +424,17 @@ extern void ( * glXGetProcAddressARB (const GLubyte *procName)) (void); #endif /* GLX_ARB_multisample */ +/* ---------------------- GLX_ARB_vertex_buffer_object --------------------- */ + +#ifndef GLX_ARB_vertex_buffer_object +#define GLX_ARB_vertex_buffer_object 1 + +#define GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095 + +#define GLXEW_ARB_vertex_buffer_object GLXEW_GET_VAR(__GLXEW_ARB_vertex_buffer_object) + +#endif /* GLX_ARB_vertex_buffer_object */ + /* ----------------------- GLX_ATI_pixel_format_float ---------------------- */ #ifndef GLX_ATI_pixel_format_float @@ -644,6 +658,20 @@ typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display* display, GLXDrawable dr #endif /* GLX_EXT_visual_rating */ +/* -------------------------- GLX_INTEL_swap_event ------------------------- */ + +#ifndef GLX_INTEL_swap_event +#define GLX_INTEL_swap_event 1 + +#define GLX_EXCHANGE_COMPLETE_INTEL 0x8180 +#define GLX_COPY_COMPLETE_INTEL 0x8181 +#define GLX_FLIP_COMPLETE_INTEL 0x8182 +#define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000 + +#define GLXEW_INTEL_swap_event GLXEW_GET_VAR(__GLXEW_INTEL_swap_event) + +#endif /* GLX_INTEL_swap_event */ + /* -------------------------- GLX_MESA_agp_offset -------------------------- */ #ifndef GLX_MESA_agp_offset @@ -1369,6 +1397,7 @@ GLXEW_EXPORT GLboolean __GLXEW_ARB_fbconfig_float; GLXEW_EXPORT GLboolean __GLXEW_ARB_framebuffer_sRGB; GLXEW_EXPORT GLboolean __GLXEW_ARB_get_proc_address; GLXEW_EXPORT GLboolean __GLXEW_ARB_multisample; +GLXEW_EXPORT GLboolean __GLXEW_ARB_vertex_buffer_object; GLXEW_EXPORT GLboolean __GLXEW_ATI_pixel_format_float; GLXEW_EXPORT GLboolean __GLXEW_ATI_render_texture; GLXEW_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float; @@ -1379,6 +1408,7 @@ GLXEW_EXPORT GLboolean __GLXEW_EXT_swap_control; GLXEW_EXPORT GLboolean __GLXEW_EXT_texture_from_pixmap; GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_info; GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_rating; +GLXEW_EXPORT GLboolean __GLXEW_INTEL_swap_event; GLXEW_EXPORT GLboolean __GLXEW_MESA_agp_offset; GLXEW_EXPORT GLboolean __GLXEW_MESA_copy_sub_buffer; GLXEW_EXPORT GLboolean __GLXEW_MESA_pixmap_colormap; diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 172669e3955..e4c2b3a3eba 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -428,6 +428,26 @@ struct __DRIswrastLoaderExtensionRec { }; /** + * Invalidate loader extension. The presence of this extension + * indicates to the DRI driver that the loader will call invalidate in + * the __DRI2_FLUSH extension, whenever the needs to query for new + * buffers. This means that the DRI driver can drop the polling in + * glViewport(). + * + * The extension doesn't provide any functionality, it's only use to + * indicate to the driver that it can use the new semantics. A DRI + * driver can use this to switch between the different semantics or + * just refuse to initialize if this extension isn't present. + */ +#define __DRI_USE_INVALIDATE "DRI_UseInvalidate" +#define __DRI_USE_INVALIDATE_VERSION 1 + +typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension; +struct __DRIuseInvalidateExtensionRec { + __DRIextension base; +}; + +/** * The remaining extensions describe driver extensions, immediately * available interfaces provided by the driver. To start using the * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for diff --git a/progs/demos/engine.c b/progs/demos/engine.c index a4148357d49..ee7d5c154a9 100644 --- a/progs/demos/engine.c +++ b/progs/demos/engine.c @@ -832,6 +832,7 @@ DrawBox(void) glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); + glLineWidth(1.0); glColor3f(1, 1, 1); diff --git a/progs/egl/eglut/eglut.c b/progs/egl/eglut/eglut.c index b9b5e6e5a8c..ff7d8df7182 100644 --- a/progs/egl/eglut/eglut.c +++ b/progs/egl/eglut/eglut.c @@ -84,8 +84,10 @@ _eglutChooseConfig(void) renderable_type = 0x0; if (_eglut->api_mask & EGLUT_OPENGL_BIT) renderable_type |= EGL_OPENGL_BIT; - if (_eglut->api_mask & (EGLUT_OPENGL_ES1_BIT | EGLUT_OPENGL_ES2_BIT)) + if (_eglut->api_mask & EGLUT_OPENGL_ES1_BIT) renderable_type |= EGL_OPENGL_ES_BIT; + if (_eglut->api_mask & EGLUT_OPENGL_ES2_BIT) + renderable_type |= EGL_OPENGL_ES2_BIT; if (_eglut->api_mask & EGLUT_OPENVG_BIT) renderable_type |= EGL_OPENVG_BIT; config_attribs[i++] = renderable_type; diff --git a/progs/egl/opengl/Makefile b/progs/egl/opengl/Makefile index 79cd5fc6533..a49255bbb2e 100644 --- a/progs/egl/opengl/Makefile +++ b/progs/egl/opengl/Makefile @@ -7,9 +7,9 @@ include $(TOP)/configs/current INCLUDE_DIRS = -I$(TOP)/include $(X11_CFLAGS) HEADERS = $(TOP)/include/GLES/egl.h -LIB_DEP = $(TOP)/$(LIB_DIR)/libEGL.so +LIB_DEP = $(TOP)/$(LIB_DIR)/$(EGL_LIB_NAME) -LIBS = -L$(TOP)/$(LIB_DIR) -lEGL -lGL -lm +LIBS = -L$(TOP)/$(LIB_DIR) -l$(EGL_LIB) -l$(GL_LIB) -lm EGLUT_DIR = $(TOP)/progs/egl/eglut diff --git a/progs/egl/opengl/eglgears.c b/progs/egl/opengl/eglgears.c index 28da9c0ac74..430deb26e5e 100644 --- a/progs/egl/opengl/eglgears.c +++ b/progs/egl/opengl/eglgears.c @@ -33,6 +33,10 @@ #include "eglut.h" +#ifndef M_PI +#define M_PI 3.14159265 +#endif + static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; static GLint gear1, gear2, gear3; static GLfloat angle = 0.0; diff --git a/progs/egl/opengles1/Makefile b/progs/egl/opengles1/Makefile index 593145d4bf2..e7802f80034 100644 --- a/progs/egl/opengles1/Makefile +++ b/progs/egl/opengles1/Makefile @@ -12,13 +12,13 @@ HEADERS = $(TOP)/include/GLES/egl.h ES1_LIB_DEPS = \ - $(TOP)/$(LIB_DIR)/libEGL.so \ - $(TOP)/$(LIB_DIR)/libGLESv1_CM.so + $(TOP)/$(LIB_DIR)/$(EGL_LIB_NAME) \ + $(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_NAME) ES1_LIBS = \ - -L$(TOP)/$(LIB_DIR) -lEGL \ - -L$(TOP)/$(LIB_DIR) -lGLESv1_CM $(LIBDRM_LIB) $(X11_LIBS) + -L$(TOP)/$(LIB_DIR) -l$(EGL_LIB) -l$(GLESv1_CM_LIB) \ + $(LIBDRM_LIB) $(X11_LIBS) EGLUT_DIR = $(TOP)/progs/egl/eglut diff --git a/progs/egl/opengles1/pbuffer.c b/progs/egl/opengles1/pbuffer.c index 60f864445af..1b4dbb666f4 100644 --- a/progs/egl/opengles1/pbuffer.c +++ b/progs/egl/opengles1/pbuffer.c @@ -22,6 +22,9 @@ #include <EGL/egl.h> +#ifndef M_PI +#define M_PI 3.14159265 +#endif static int WinWidth = 300, WinHeight = 300; diff --git a/progs/egl/opengles1/render_tex.c b/progs/egl/opengles1/render_tex.c index 0200fa4cb06..cd2abbd51b7 100644 --- a/progs/egl/opengles1/render_tex.c +++ b/progs/egl/opengles1/render_tex.c @@ -22,6 +22,10 @@ #include <EGL/egl.h> +#ifndef M_PI +#define M_PI 3.14159265 +#endif + static int TexWidth = 256, TexHeight = 256; static int WinWidth = 300, WinHeight = 300; diff --git a/progs/egl/opengles1/torus.c b/progs/egl/opengles1/torus.c index 8f262b53d6c..18ddff3fe4a 100644 --- a/progs/egl/opengles1/torus.c +++ b/progs/egl/opengles1/torus.c @@ -17,6 +17,10 @@ #include "eglut.h" +#ifndef M_PI +#define M_PI 3.14159265 +#endif + static const struct { GLenum internalFormat; const char *name; diff --git a/progs/egl/opengles2/Makefile b/progs/egl/opengles2/Makefile index 89feb34acc1..bf14513d7fb 100644 --- a/progs/egl/opengles2/Makefile +++ b/progs/egl/opengles2/Makefile @@ -14,13 +14,13 @@ HEADERS = $(TOP)/include/GLES/egl.h ES2_LIB_DEPS = \ - $(TOP)/$(LIB_DIR)/libEGL.so \ - $(TOP)/$(LIB_DIR)/libGLESv2.so + $(TOP)/$(LIB_DIR)/$(EGL_LIB_NAME) \ + $(TOP)/$(LIB_DIR)/$(GLESv2_LIB_NAME) ES2_LIBS = \ - -L$(TOP)/$(LIB_DIR) -lEGL \ - -L$(TOP)/$(LIB_DIR) -lGLESv2 $(LIBDRM_LIB) $(X11_LIBS) \ + -L$(TOP)/$(LIB_DIR) -l$(EGL_LIB) -l$(GLESv2_LIB) \ + $(LIBDRM_LIB) $(X11_LIBS) PROGRAMS = \ es2_info \ diff --git a/progs/egl/opengles2/es2gears.c b/progs/egl/opengles2/es2gears.c index 8e7a3e52490..6bd6594320a 100644 --- a/progs/egl/opengles2/es2gears.c +++ b/progs/egl/opengles2/es2gears.c @@ -46,6 +46,10 @@ #include <EGL/eglext.h> #include "eglut.h" +#ifndef M_PI +#define M_PI 3.14159265 +#endif + struct gear { GLfloat *vertices; GLuint vbo; diff --git a/progs/egl/opengles2/tri.c b/progs/egl/opengles2/tri.c index 8981d8a7e21..812dbf031e4 100644 --- a/progs/egl/opengles2/tri.c +++ b/progs/egl/opengles2/tri.c @@ -29,6 +29,10 @@ #include <EGL/egl.h> +#ifndef M_PI +#define M_PI 3.14159265 +#endif + #define FLOAT_TO_FIXED(X) ((X) * 65535.0) diff --git a/progs/egl/openvg/Makefile b/progs/egl/openvg/Makefile index 3b11933db26..9a96ccc45f7 100644 --- a/progs/egl/openvg/Makefile +++ b/progs/egl/openvg/Makefile @@ -3,7 +3,7 @@ TOP = ../../.. include $(TOP)/configs/current -VG_LIBS=-lm -lEGL -lOpenVG -L$(TOP)/lib -L$(TOP)/lib/gallium +VG_LIBS=-lm -L$(TOP)/$(LIB_DIR) -l$(EGL_LIB) -l$(VG_LIB) INCLUDE_DIRS = -I$(TOP)/include $(X11_CFLAGS) EGLUT_DIR = $(TOP)/progs/egl/eglut diff --git a/progs/rbug/README b/progs/rbug/README index 0eb0a5de9a5..ee6ae4247fb 100644 --- a/progs/rbug/README +++ b/progs/rbug/README @@ -15,7 +15,7 @@ To build, build a normal gallium build and from this directory do the following. = Usage = Make sure that you driver has trace integration, see -src/gallium/driver/trace/README for more information about that. Then from on +src/gallium/driver/rbug/README for more information about that. Then from on the computer that you want to debug do: export GALLIUM_RBUG=true @@ -24,7 +24,10 @@ the computer that you want to debug do: From the debugging computer launch apps form this directory. Currently ip addresses are hardcoded and you need to edit the application, but that will -change in the future. +change in the future. For a more advanced gui application see: + + http://cgit.freedesktop.org/mesa/rbug-gui + = Testing = diff --git a/progs/tests/Makefile b/progs/tests/Makefile index 0f938f9b0c1..f8473e64e21 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -134,6 +134,9 @@ INCLUDES = -I. -I$(TOP)/include UTIL_FILES = readtex.h readtex.c +GL_API_XML = $(TOP)/src/mapi/glapi/gen/gl_API.xml + + ##### TARGETS ##### default: $(UTIL_FILES) $(PROGS) @@ -160,7 +163,7 @@ clean: # auto code generation getprocaddress: getprocaddress.c getproclist.h -getproclist.h: $(TOP)/src/mesa/glapi/gen/gl_API.xml getprocaddress.c getprocaddress.py +getproclist.h: $(GL_API_XML) getprocaddress.c getprocaddress.py python getprocaddress.py > getproclist.h arraytexture: arraytexture.o readtex.o diff --git a/progs/tests/copypixrate.c b/progs/tests/copypixrate.c index f63d59f3cec..e7d83437214 100644 --- a/progs/tests/copypixrate.c +++ b/progs/tests/copypixrate.c @@ -270,6 +270,9 @@ main(int argc, char *argv[]) printf("Draw Buffer: %s\n", (Buffer == GL_BACK) ? "Back" : "Front"); Init(); + printf("Mode: %s\n", (UseBlit ? "glBlitFramebuffer" : "glCopyPixels")); + printf("Alpha Test: %s\n", (AlphaTest ? "yes" : "no")); + glutMainLoop(); return 0; } diff --git a/progs/tests/getprocaddress.c b/progs/tests/getprocaddress.c index 38ca7000df2..f7903d2bf88 100644 --- a/progs/tests/getprocaddress.c +++ b/progs/tests/getprocaddress.c @@ -1189,6 +1189,7 @@ exercise_buffer_objects(enum Map_Buffer_Usage usage) GLint bufferMapped; static GLubyte data[BUFFER_DATA_SIZE] = {0}; float *dataPtr = NULL; + const char *extensions = (const char *) glGetString(GL_EXTENSIONS); /* Get the function pointers we need. These are from * GL_ARB_vertex_buffer_object and are required in all @@ -1216,6 +1217,9 @@ exercise_buffer_objects(enum Map_Buffer_Usage usage) * we're given Use_Map_Buffer_Range. Test it before using it. */ DECLARE_GLFUNC_PTR(BufferParameteriAPPLE, PFNGLBUFFERPARAMETERIAPPLEPROC); + if (!strstr("GL_APPLE_flush_buffer_range", extensions)) { + BufferParameteriAPPLE = NULL; + } /* Make sure we have all the function pointers we need. */ if (GenBuffersARB == NULL || @@ -1286,7 +1290,7 @@ exercise_buffer_objects(enum Map_Buffer_Usage usage) * using MapBufferRange, we first have to flush the range we modified. */ if (usage == Use_Map_Buffer_Range) { - (*FlushMappedBufferRange)(GL_ARRAY_BUFFER_ARB, 4, 16); + (*FlushMappedBufferRange)(GL_ARRAY_BUFFER_ARB, 0, 16); } if (!(*UnmapBufferARB)(GL_ARRAY_BUFFER_ARB)) { fprintf(stderr, "%s: UnmapBuffer failed\n", __FUNCTION__); @@ -1720,19 +1724,22 @@ static GLboolean test_CompressedTexImage3DARB(generic_func func) { (void) func; - return exercise_CompressedTextures(GL_TEXTURE_3D); + /*return exercise_CompressedTextures(GL_TEXTURE_3D);*/ + return GL_TRUE; } static GLboolean test_CompressedTexSubImage3DARB(generic_func func) { (void) func; - return exercise_CompressedTextures(GL_TEXTURE_3D); + /*return exercise_CompressedTextures(GL_TEXTURE_3D);*/ + return GL_TRUE; } static GLboolean test_GetCompressedTexImageARB(generic_func func) { (void) func; - return exercise_CompressedTextures(GL_TEXTURE_3D); + /*return exercise_CompressedTextures(GL_TEXTURE_3D);*/ + return GL_TRUE; } /* Wrappers on exercise_fences(). */ diff --git a/progs/tests/getprocaddress.py b/progs/tests/getprocaddress.py index 60111cb8010..c421f90cb68 100644 --- a/progs/tests/getprocaddress.py +++ b/progs/tests/getprocaddress.py @@ -3,8 +3,10 @@ # Helper for the getprocaddress.c test. +glapi_xml_path = "../../src/mapi/glapi/gen/" + import sys, getopt, re -sys.path.append("../../src/mesa/glapi/gen" ) +sys.path.append(glapi_xml_path) import gl_XML import license @@ -74,7 +76,7 @@ static struct name_test_pair functions[] = {""" if __name__ == '__main__': - file_name = "../../src/mesa/glapi/gen/gl_API.xml" + file_name = glapi_xml_path + "gl_API.xml" try: (args, trail) = getopt.getopt(sys.argv[1:], "f:") diff --git a/progs/vpglsl/func.glsl b/progs/vpglsl/func.glsl new file mode 100644 index 00000000000..05539880fd8 --- /dev/null +++ b/progs/vpglsl/func.glsl @@ -0,0 +1,33 @@ +#version 120 +const int KernelSize = 16; +uniform float KernelValue1f[KernelSize]; + + +float add_two(float a, float b) +{ + if (a > b) + return a - b; + else + return a + b; +} + +vec4 func(vec4 x) +{ + int i; + vec4 tmp = gl_Color; + vec4 sum = x; + + for (i = 0; i < KernelSize; ++i) { + sum = vec4( add_two(sum.x, KernelValue1f[i]) ); + } + return sum; +} + +void main(void) +{ + vec4 sum = vec4(0.0); + + sum = func(sum); + gl_Position = gl_Vertex; + gl_FrontColor = sum; +} diff --git a/progs/vpglsl/func2.glsl b/progs/vpglsl/func2.glsl new file mode 100644 index 00000000000..df964ed6f02 --- /dev/null +++ b/progs/vpglsl/func2.glsl @@ -0,0 +1,54 @@ +#version 120 +const int KernelSize = 16; +uniform float KernelValue1f[KernelSize]; + + +float add_two(float a, float b) +{ + if (a > b) + return a - b; + else + return a + b; +} + +vec4 myfunc(vec4 x, vec4 mult, vec4 c) +{ + if (x.x >= 0.5) { + return mult * c; + } else { + return mult + c; + } +} + +vec4 func2(vec4 x) +{ + int i; + vec4 color = vec4(0); + for (i = 0; i < KernelSize; ++i) { + vec4 tmp = vec4(1./KernelSize); + color += myfunc(x, tmp, gl_Color); + } + return x * color; +} + +vec4 func(vec4 x) +{ + int i; + vec4 tmp = gl_Color; + vec4 sum = x; + + for (i = 0; i < KernelSize; ++i) { + sum = vec4( add_two(sum.x, KernelValue1f[i]) ); + } + sum = func2(sum); + return sum; +} + +void main(void) +{ + vec4 sum = vec4(0.0); + + sum = func(sum); + gl_Position = gl_Vertex; + gl_FrontColor = sum; +} diff --git a/progs/xdemos/glxinfo.c b/progs/xdemos/glxinfo.c index b656e58924e..b774f504aec 100644 --- a/progs/xdemos/glxinfo.c +++ b/progs/xdemos/glxinfo.c @@ -35,6 +35,7 @@ #define GLX_GLXEXT_PROTOTYPES +#include <assert.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <GL/gl.h> @@ -99,6 +100,8 @@ struct visual_attribs int accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize; int numSamples, numMultisample; int visualCaveat; + int floatComponents; + int srgb; }; @@ -642,9 +645,29 @@ visual_render_type_name(int type) return "rgba|ci"; default: return ""; - } + } } +static const char * +caveat_string(int caveat) +{ + switch (caveat) { +#ifdef GLX_EXT_visual_rating + case GLX_SLOW_VISUAL_EXT: + return "Slow"; + case GLX_NON_CONFORMANT_VISUAL_EXT: + return "Ncon"; + case GLX_NONE_EXT: + /* fall-through */ +#endif + case 0: + /* fall-through */ + default: + return "None"; + } +} + + static GLboolean get_visual_attribs(Display *dpy, XVisualInfo *vInfo, struct visual_attribs *attribs) @@ -728,6 +751,12 @@ get_visual_attribs(Display *dpy, XVisualInfo *vInfo, attribs->visualCaveat = 0; #endif +#if defined(GLX_EXT_framebuffer_sRGB) + if (ext && strstr(ext, "GLX_EXT_framebuffer_sRGB")) { + glXGetConfig(dpy, vInfo, GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, &attribs->srgb); + } +#endif + return GL_TRUE; } @@ -759,20 +788,24 @@ static GLboolean get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig, struct visual_attribs *attribs) { + const char *ext = glXQueryExtensionsString(dpy, 0); int visual_type; + XVisualInfo *vInfo; memset(attribs, 0, sizeof(struct visual_attribs)); glXGetFBConfigAttrib(dpy, fbconfig, GLX_FBCONFIG_ID, &attribs->id); -#if 0 - attribs->depth = vInfo->depth; - attribs->redMask = vInfo->red_mask; - attribs->greenMask = vInfo->green_mask; - attribs->blueMask = vInfo->blue_mask; - attribs->colormapSize = vInfo->colormap_size; - attribs->bitsPerRGB = vInfo->bits_per_rgb; -#endif + vInfo = glXGetVisualFromFBConfig(dpy, fbconfig); + + if (vInfo != NULL) { + attribs->depth = vInfo->depth; + attribs->redMask = vInfo->red_mask; + attribs->greenMask = vInfo->green_mask; + attribs->blueMask = vInfo->blue_mask; + attribs->colormapSize = vInfo->colormap_size; + attribs->bitsPerRGB = vInfo->bits_per_rgb; + } glXGetFBConfigAttrib(dpy, fbconfig, GLX_X_VISUAL_TYPE, &visual_type); attribs->klass = glx_token_to_visual_class(visual_type); @@ -813,6 +846,24 @@ get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig, glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLES, &attribs->numSamples); glXGetFBConfigAttrib(dpy, fbconfig, GLX_CONFIG_CAVEAT, &attribs->visualCaveat); +#if defined(GLX_NV_float_buffer) + if (ext && strstr(ext, "GLX_NV_float_buffer")) { + glXGetFBConfigAttrib(dpy, fbconfig, GLX_FLOAT_COMPONENTS_NV, &attribs->floatComponents); + } +#endif +#if defined(GLX_ARB_fbconfig_float) + if (ext && strstr(ext, "GLX_ARB_fbconfig_float")) { + if (attribs->render_type & GLX_RGBA_FLOAT_BIT_ARB) { + attribs->floatComponents = True; + } + } +#endif + +#if defined(GLX_EXT_framebuffer_sRGB) + if (ext && strstr(ext, "GLX_EXT_framebuffer_sRGB")) { + glXGetFBConfigAttrib(dpy, fbconfig, GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, &attribs->srgb); + } +#endif return GL_TRUE; } @@ -830,9 +881,11 @@ print_visual_attribs_verbose(const struct visual_attribs *attribs) attribs->bufferSize, attribs->level, visual_render_type_name(attribs->render_type), attribs->doubleBuffer, attribs->stereo); - printf(" rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n", + printf(" rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d float=%c sRGB=%c\n", attribs->redSize, attribs->greenSize, - attribs->blueSize, attribs->alphaSize); + attribs->blueSize, attribs->alphaSize, + attribs->floatComponents ? 'Y' : 'N', + attribs->srgb ? 'Y' : 'N'); printf(" auxBuffers=%d depthSize=%d stencilSize=%d\n", attribs->auxBuffers, attribs->depthSize, attribs->stencilSize); printf(" accum: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n", @@ -863,30 +916,18 @@ print_visual_attribs_verbose(const struct visual_attribs *attribs) static void print_visual_attribs_short_header(void) { - printf(" visual x bf lv rg d st colorbuffer ax dp st accumbuffer ms cav\n"); - printf(" id dep cl sp sz l ci b ro r g b a bf th cl r g b a ns b eat\n"); - printf("----------------------------------------------------------------------\n"); + printf(" visual x bf lv rg d st colorbuffer sr ax dp st accumbuffer ms cav\n"); + printf(" id dep cl sp sz l ci b ro r g b a F gb bf th cl r g b a ns b eat\n"); + printf("----------------------------------------------------------------------------\n"); } static void print_visual_attribs_short(const struct visual_attribs *attribs) { - char *caveat = NULL; -#ifdef GLX_EXT_visual_rating - if (attribs->visualCaveat == GLX_NONE_EXT || attribs->visualCaveat == 0) - caveat = "None"; - else if (attribs->visualCaveat == GLX_SLOW_VISUAL_EXT) - caveat = "Slow"; - else if (attribs->visualCaveat == GLX_NON_CONFORMANT_VISUAL_EXT) - caveat = "Ncon"; - else - caveat = "None"; -#else - caveat = "None"; -#endif + const char *caveat = caveat_string(attribs->visualCaveat); - printf("0x%02x %2d %2s %2d %2d %2d %c%c %c %c %2d %2d %2d %2d %2d %2d %2d", + printf("0x%03x %2d %2s %2d %3d %2d %c%c %c %c %2d %2d %2d %2d %c %c %2d %2d %2d", attribs->id, attribs->depth, visual_class_abbrev(attribs->klass), @@ -899,6 +940,8 @@ print_visual_attribs_short(const struct visual_attribs *attribs) attribs->stereo ? 'y' : '.', attribs->redSize, attribs->greenSize, attribs->blueSize, attribs->alphaSize, + attribs->floatComponents ? 'f' : '.', + attribs->srgb ? 's' : '.', attribs->auxBuffers, attribs->depthSize, attribs->stencilSize @@ -916,16 +959,18 @@ print_visual_attribs_short(const struct visual_attribs *attribs) static void print_visual_attribs_long_header(void) { - printf("Vis Vis Visual Trans buff lev render DB ste r g b a aux dep ste accum buffers MS MS\n"); - printf(" ID Depth Type parent size el type reo sz sz sz sz buf th ncl r g b a num bufs\n"); - printf("----------------------------------------------------------------------------------------------------\n"); + printf("Vis Vis Visual Trans buff lev render DB ste r g b a s aux dep ste accum buffer MS MS \n"); + printf(" ID Depth Type parent size el type reo sz sz sz sz flt rgb buf th ncl r g b a num bufs caveats\n"); + printf("--------------------------------------------------------------------------------------------------------------------\n"); } static void print_visual_attribs_long(const struct visual_attribs *attribs) { - printf("0x%2x %2d %-11s %2d %2d %2d %4s %3d %3d %3d %3d %3d %3d", + const char *caveat = caveat_string(attribs->visualCaveat); + + printf("0x%3x %2d %-11s %2d %3d %2d %4s %3d %3d %3d %3d %3d %3d", attribs->id, attribs->depth, visual_class_name(attribs->klass), @@ -939,13 +984,16 @@ print_visual_attribs_long(const struct visual_attribs *attribs) attribs->blueSize, attribs->alphaSize ); - printf(" %3d %4d %2d %3d %3d %3d %3d %2d %2d\n", + printf(" %c %c %3d %4d %2d %3d %3d %3d %3d %2d %2d %6s\n", + attribs->floatComponents ? 'f' : '.', + attribs->srgb ? 's' : '.', attribs->auxBuffers, attribs->depthSize, attribs->stencilSize, attribs->accumRedSize, attribs->accumGreenSize, attribs->accumBlueSize, attribs->accumAlphaSize, - attribs->numSamples, attribs->numMultisample + attribs->numSamples, attribs->numMultisample, + caveat ); } diff --git a/scons/crossmingw.py b/scons/crossmingw.py index 9533b2b362c..8adc8f5c970 100644 --- a/scons/crossmingw.py +++ b/scons/crossmingw.py @@ -42,7 +42,7 @@ import SCons.Tool import SCons.Util # This is what we search for to find mingw: -prefixes = SCons.Util.Split(""" +prefixes32 = SCons.Util.Split(""" mingw32- mingw32msvc- i386-mingw32- @@ -55,8 +55,17 @@ prefixes = SCons.Util.Split(""" i686-mingw32msvc- i686-pc-mingw32- """) +prefixes64 = SCons.Util.Split(""" + amd64-mingw32- + amd64-mingw32msvc- + amd64-pc-mingw32- +""") def find(env): + if env['machine'] == 'x86_64': + prefixes = prefixes64 + else: + prefixes = prefixes32 for prefix in prefixes: # First search in the SCons path and then the OS path: if env.WhereIs(prefix + 'gcc') or SCons.Util.WhereIs(prefix + 'gcc'): diff --git a/src/SConscript b/src/SConscript index cf6db730da2..b72491d96f2 100644 --- a/src/SConscript +++ b/src/SConscript @@ -1,6 +1,7 @@ Import('*') SConscript('glsl/SConscript') +SConscript('mapi/glapi/SConscript') if 'mesa' in env['statetrackers']: SConscript('mesa/SConscript') diff --git a/src/egl/drivers/Makefile.template b/src/egl/drivers/Makefile.template index e9a614ce62d..08e82c65e9b 100644 --- a/src/egl/drivers/Makefile.template +++ b/src/egl/drivers/Makefile.template @@ -12,20 +12,21 @@ # -EGL_DRIVER_PATH = $(TOP)/$(LIB_DIR)/$(EGL_DRIVER) +EGL_DRIVER_PATH = $(TOP)/$(LIB_DIR)/egl/$(EGL_DRIVER) EGL_OBJECTS = $(EGL_SOURCES:.c=.o) default: depend $(EGL_DRIVER_PATH) $(EGL_DRIVER_PATH): $(EGL_DRIVER) - $(INSTALL) $< $(TOP)/$(LIB_DIR) + @$(INSTALL) -d $(TOP)/$(LIB_DIR)/egl + $(INSTALL) $< $(TOP)/$(LIB_DIR)/egl $(EGL_DRIVER): $(EGL_OBJECTS) Makefile $(TOP)/src/egl/drivers/Makefile.template @$(MKLIB) -o $(EGL_DRIVER) -noprefix \ -linker '$(CC)' -ldflags '$(LDFLAGS)' \ -L$(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \ - $(EGL_OBJECTS) $(EGL_LIBS) + $(EGL_OBJECTS) $(EGL_LIBS) -l$(EGL_LIB) .c.o: $(CC) -c $(EGL_INCLUDES) $(CFLAGS) $(EGL_CFLAGS) $< -o $@ diff --git a/src/egl/drivers/dri/Makefile b/src/egl/drivers/dri/Makefile index 7339c97c77d..c3aacff1cfe 100644 --- a/src/egl/drivers/dri/Makefile +++ b/src/egl/drivers/dri/Makefile @@ -11,9 +11,9 @@ INCLUDE_DIRS = \ $(shell pkg-config --cflags-only-I libdrm) \ -I$(TOP)/include \ -I$(TOP)/include/GL/internal \ + -I$(TOP)/src/mapi \ -I$(TOP)/src/mesa \ -I$(TOP)/src/mesa/main \ - -I$(TOP)/src/mesa/glapi \ -I$(TOP)/src/mesa/math \ -I$(TOP)/src/mesa/transform \ -I$(TOP)/src/mesa/shader \ diff --git a/src/egl/drivers/dri2/Makefile b/src/egl/drivers/dri2/Makefile index 129e67b8c66..4e760aec4c8 100644 --- a/src/egl/drivers/dri2/Makefile +++ b/src/egl/drivers/dri2/Makefile @@ -9,7 +9,7 @@ EGL_SOURCES = egl_dri2.c EGL_INCLUDES = \ -I$(TOP)/include \ -I$(TOP)/src/egl/main \ - -I$(TOP)/src/mesa \ + -I$(TOP)/src/mapi \ -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" \ $(EGL_DRI2_CFLAGS) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 69f3c28c9e4..eb9a6510ed0 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -51,6 +51,8 @@ #include "eglsurface.h" #include "eglimage.h" +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) + struct dri2_egl_driver { _EGLDriver base; @@ -163,7 +165,7 @@ EGLint dri2_to_egl_attribute_map[] = { 0, /* __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA */ 0, /* __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE */ 0, /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */ - 0, /* __DRI_ATTRIB_YINVERTED */ + EGL_Y_INVERTED_NOK, /* __DRI_ATTRIB_YINVERTED */ }; static void @@ -415,12 +417,6 @@ dri2_get_buffers_with_format(__DRIdrawable * driDrawable, return dri2_surf->buffers; } -#ifdef GLX_USE_TLS -static const char dri_driver_format[] = "%.*s/tls/%s_dri.so"; -#else -static const char dri_driver_format[] = "%.*s/%s_dri.so"; -#endif - static const char dri_driver_path[] = DEFAULT_DRIVER_DIR; struct dri2_extension_match { @@ -678,19 +674,28 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp, dri2_dpy->driver = NULL; end = search_paths + strlen(search_paths); for (p = search_paths; p < end && dri2_dpy->driver == NULL; p = next + 1) { + int len; next = strchr(p, ':'); if (next == NULL) next = end; + len = next - p; +#if GLX_USE_TLS snprintf(path, sizeof path, - dri_driver_format, (int) (next - p), p, dri2_dpy->driver_name); + "%.*s/tls/%s_dri.so", len, p, dri2_dpy->driver_name); dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); - if (dri2_dpy->driver == NULL) - _eglLog(_EGL_DEBUG, "failed to open %s: %s\n", path, dlerror()); +#endif + if (dri2_dpy->driver == NULL) { + snprintf(path, sizeof path, + "%.*s/%s_dri.so", len, p, dri2_dpy->driver_name); + dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); + if (dri2_dpy->driver == NULL) + _eglLog(_EGL_DEBUG, "failed to open %s: %s\n", path, dlerror()); + } } if (dri2_dpy->driver == NULL) { - _eglLog(_EGL_FATAL, + _eglLog(_EGL_WARNING, "DRI2: failed to open any driver (search paths %s)", search_paths); goto cleanup_conn; @@ -699,7 +704,7 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp, _eglLog(_EGL_DEBUG, "DRI2: dlopen(%s)", path); extensions = dlsym(dri2_dpy->driver, __DRI_DRIVER_EXTENSIONS); if (extensions == NULL) { - _eglLog(_EGL_FATAL, + _eglLog(_EGL_WARNING, "DRI2: driver exports no extensions (%s)", dlerror()); goto cleanup_driver; } @@ -709,7 +714,7 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp, dri2_dpy->fd = open(dri2_dpy->device_name, O_RDWR); if (dri2_dpy->fd == -1) { - _eglLog(_EGL_FATAL, + _eglLog(_EGL_WARNING, "DRI2: could not open %s (%s)", dri2_dpy->device_name, strerror(errno)); goto cleanup_driver; @@ -748,7 +753,7 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp, &dri2_dpy->driver_configs, dri2_dpy); if (dri2_dpy->dri_screen == NULL) { - _eglLog(_EGL_FATAL, "DRI2: failed to create dri screen"); + _eglLog(_EGL_WARNING, "DRI2: failed to create dri screen"); goto cleanup_fd; } @@ -778,6 +783,8 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp, disp->Extensions.KHR_image_pixmap = EGL_TRUE; disp->Extensions.KHR_gl_renderbuffer_image = EGL_TRUE; disp->Extensions.KHR_gl_texture_2D_image = EGL_TRUE; + disp->Extensions.NOK_swap_region = EGL_TRUE; + disp->Extensions.NOK_texture_from_pixmap = EGL_TRUE; /* we're supporting EGL 1.4 */ *major = 1; @@ -1067,7 +1074,8 @@ dri2_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp, } static EGLBoolean -dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) +dri2_copy_region(_EGLDriver *drv, _EGLDisplay *disp, + _EGLSurface *draw, xcb_xfixes_region_t region) { struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv); struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); @@ -1099,7 +1107,7 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) cookie = xcb_dri2_copy_region_unchecked(dri2_dpy->conn, dri2_surf->drawable, - dri2_surf->region, + region, XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT, XCB_DRI2_ATTACHMENT_BUFFER_FAKE_FRONT_LEFT); free(xcb_dri2_copy_region_reply(dri2_dpy->conn, cookie, NULL)); @@ -1107,6 +1115,44 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) return EGL_TRUE; } +static EGLBoolean +dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) +{ + struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw); + + return dri2_copy_region(drv, disp, draw, dri2_surf->region); +} + +static EGLBoolean +dri2_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw, + EGLint numRects, const EGLint *rects) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw); + EGLBoolean ret; + xcb_xfixes_region_t region; + xcb_rectangle_t rectangles[16]; + int i; + + if (numRects > ARRAY_SIZE(rectangles)) + return dri2_copy_region(drv, disp, draw, dri2_surf->region); + + /* FIXME: Invert y here? */ + for (i = 0; i < numRects; i++) { + rectangles[i].x = rects[i * 4]; + rectangles[i].y = rects[i * 4 + 1]; + rectangles[i].width = rects[i * 4 + 2]; + rectangles[i].height = rects[i * 4 + 3]; + } + + region = xcb_generate_id(dri2_dpy->conn); + xcb_xfixes_create_region(dri2_dpy->conn, region, numRects, rectangles); + ret = dri2_copy_region(drv, disp, draw, region); + xcb_xfixes_destroy_region(dri2_dpy->conn, region); + + return ret; +} + /* * Called from eglGetProcAddress() via drv->API.GetProcAddress(). */ @@ -1187,19 +1233,8 @@ dri2_bind_tex_image(_EGLDriver *drv, ctx = _eglGetCurrentContext(); dri2_ctx = dri2_egl_context(ctx); - if (buffer != EGL_BACK_BUFFER) { - _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); - return EGL_FALSE; - } - - /* We allow binding pixmaps too... Not conformat, but we can do it - * for free and it's useful for X compositors. Supposedly there's - * a EGL_NOKIA_texture_from_pixmap extension that allows that, but - * I couldn't find it at this time. */ - if ((dri2_surf->base.Type & (EGL_PBUFFER_BIT | EGL_PIXMAP_BIT)) == 0) { - _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); + if (!_eglBindTexImage(drv, disp, surf, buffer)) return EGL_FALSE; - } switch (dri2_surf->base.TextureFormat) { case EGL_TEXTURE_RGB: @@ -1209,8 +1244,7 @@ dri2_bind_tex_image(_EGLDriver *drv, format = __DRI_TEXTURE_FORMAT_RGBA; break; default: - _eglError(EGL_BAD_MATCH, "eglBindTexImage"); - return EGL_FALSE; + assert(0); } switch (dri2_surf->base.TextureTarget) { @@ -1218,15 +1252,14 @@ dri2_bind_tex_image(_EGLDriver *drv, target = GL_TEXTURE_2D; break; default: - _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); - return EGL_FALSE; + assert(0); } (*dri2_dpy->tex_buffer->setTexBuffer2)(dri2_ctx->dri_context, target, format, dri2_surf->dri_drawable); - return dri2_surf->base.BoundToTexture = EGL_TRUE; + return EGL_TRUE; } static EGLBoolean @@ -1396,6 +1429,7 @@ _eglMain(const char *args) if (!dri2_drv) return NULL; + memset(dri2_drv, 0, sizeof *dri2_drv); _eglInitDriverFallbacks(&dri2_drv->base); dri2_drv->base.API.Initialize = dri2_initialize; dri2_drv->base.API.Terminate = dri2_terminate; @@ -1414,6 +1448,7 @@ _eglMain(const char *args) dri2_drv->base.API.ReleaseTexImage = dri2_release_tex_image; dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr; dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr; + dri2_drv->base.API.SwapBuffersRegionNOK = dri2_swap_buffers_region; dri2_drv->base.Name = "DRI2"; dri2_drv->base.Unload = dri2_unload; diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 3cbfebe4881..e08ef5f2228 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -41,6 +41,7 @@ #include "eglconfigutil.h" #include "eglconfig.h" #include "eglcontext.h" +#include "egldefines.h" #include "egldisplay.h" #include "egldriver.h" #include "eglcurrent.h" @@ -48,7 +49,6 @@ #include "eglsurface.h" #define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #ifndef GLX_VERSION_1_4 #error "GL/glx.h must be equal to or greater than GLX 1.4" diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 3b4ebf7fec4..82fd855b1d5 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -82,10 +82,27 @@ install-headers: $(INSTALL) -m 644 $(TOP)/include/EGL/*.h \ $(DESTDIR)$(INSTALL_INC_DIR)/EGL -install: default install-headers +PKG_CONFIG_DIR = $(INSTALL_LIB_DIR)/pkgconfig + +gl_pcedit = sed \ + -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \ + -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \ + -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \ + -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' \ + -e 's,@EGL_PC_REQ_PRIV@,$(EGL_PC_REQ_PRIV),' \ + -e 's,@EGL_PC_LIB_PRIV@,$(EGL_PC_LIB_PRIV),' \ + -e 's,@EGL_PC_CFLAGS@,$(EGL_PC_CFLAGS),' \ + -e 's,@EGL_LIB@,$(EGL_LIB),' + +egl.pc: egl.pc.in + $(gl_pcedit) $< > $@ + +install: default install-headers egl.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(MINSTALL) $(TOP)/$(LIB_DIR)/$(EGL_LIB_GLOB) \ $(DESTDIR)$(INSTALL_LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(PKG_CONFIG_DIR) + $(INSTALL) -m 644 egl.pc $(DESTDIR)$(PKG_CONFIG_DIR) clean: -rm -f *.o diff --git a/src/egl/main/egl.pc.in b/src/egl/main/egl.pc.in new file mode 100644 index 00000000000..2855a4980a0 --- /dev/null +++ b/src/egl/main/egl.pc.in @@ -0,0 +1,12 @@ +prefix=@INSTALL_DIR@ +exec_prefix=${prefix} +libdir=@INSTALL_LIB_DIR@ +includedir=@INSTALL_INC_DIR@ + +Name: egl +Description: Mesa EGL library +Requires.private: @EGL_PC_REQ_PRIV@ +Version: @VERSION@ +Libs: -L${libdir} -l@EGL_LIB@ +Libs.private: @EGL_PC_LIB_PRIV@ +Cflags: -I${includedir} @EGL_PC_CFLAGS@ diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 647be652207..1a533e0880b 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -261,7 +261,7 @@ EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) { _EGLDisplay *disp = _eglLockDisplay(dpy); - EGLint major_int, minor_int; + EGLint major_int = 0, minor_int = 0; if (!disp) RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE); @@ -272,13 +272,15 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) if (!drv) { _eglPreloadDrivers(); drv = _eglMatchDriver(disp); - if (!drv) - RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE); + /* Initialize the particular display now */ + if (drv && !drv->API.Initialize(drv, disp, &major_int, &minor_int)) + RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE); } - - /* Initialize the particular display now */ - if (!drv->API.Initialize(drv, disp, &major_int, &minor_int)) - RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE); + if (!drv) + /* Load and initialize the first default driver that works */ + drv = _eglLoadDefaultDriver(disp, &major_int, &minor_int); + if (!drv) + RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE); disp->APImajor = major_int; disp->APIminor = minor_int; @@ -836,6 +838,9 @@ eglGetProcAddress(const char *procname) { "eglCreateImageKHR", (_EGLProc) eglCreateImageKHR }, { "eglDestroyImageKHR", (_EGLProc) eglDestroyImageKHR }, #endif /* EGL_KHR_image_base */ +#ifdef EGL_NOK_swap_region + { "eglSwapBuffersRegionNOK", (_EGLProc) eglSwapBuffersRegionNOK }, +#endif { NULL, NULL } }; EGLint i; @@ -1244,3 +1249,32 @@ eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) #endif /* EGL_KHR_image_base */ + + +#ifdef EGL_NOK_swap_region + +EGLBoolean +eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface, + EGLint numRects, const EGLint *rects) +{ + _EGLContext *ctx = _eglGetCurrentContext(); + _EGLDisplay *disp = _eglLockDisplay(dpy); + _EGLSurface *surf = _eglLookupSurface(surface, disp); + _EGLDriver *drv; + EGLBoolean ret; + + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); + + /* surface must be bound to current context in EGL 1.4 */ + if (!ctx || !_eglIsContextLinked(ctx) || surf != ctx->DrawSurface) + RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); + + if (drv->API.SwapBuffersRegionNOK) + ret = drv->API.SwapBuffersRegionNOK(drv, disp, surf, numRects, rects); + else + ret = drv->API.SwapBuffers(drv, disp, surf); + + RETURN_EGL_EVAL(disp, ret); +} + +#endif /* EGL_NOK_swap_region */ diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index 3e2ba8dd415..d8c8b49a49d 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -76,6 +76,9 @@ typedef _EGLImage *(*CreateImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLCo typedef EGLBoolean (*DestroyImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image); #endif /* EGL_KHR_image_base */ +#ifdef EGL_NOK_swap_region +typedef EGLBoolean (*SwapBuffersRegionNOK_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint numRects, const EGLint *rects); +#endif /** * The API dispatcher jumps through these functions @@ -134,6 +137,10 @@ struct _egl_api CreateImageKHR_t CreateImageKHR; DestroyImageKHR_t DestroyImageKHR; #endif /* EGL_KHR_image_base */ + +#ifdef EGL_NOK_swap_region + SwapBuffersRegionNOK_t SwapBuffersRegionNOK; +#endif }; #endif /* EGLAPI_INCLUDED */ diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 21d13cba904..fa947d76887 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -13,7 +13,6 @@ #define MIN2(A, B) (((A) < (B)) ? (A) : (B)) -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) /** @@ -224,7 +223,12 @@ static const struct { 0 }, { EGL_NONE, ATTRIB_TYPE_PSEUDO, ATTRIB_CRITERION_IGNORE, - 0 } + 0 }, + + { EGL_Y_INVERTED_NOK, ATTRIB_TYPE_BOOLEAN, + ATTRIB_CRITERION_EXACT, + EGL_DONT_CARE }, + }; @@ -479,6 +483,28 @@ _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria) return matched; } +static INLINE EGLBoolean +_eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr) +{ + if (_eglIndexConfig(conf, attr) < 0) + return EGL_FALSE; + + /* there are some holes in the range */ + switch (attr) { + case 0x3030 /* a gap before EGL_SAMPLES */: + case EGL_NONE: +#ifdef EGL_VERSION_1_4 + case EGL_MATCH_NATIVE_PIXMAP: +#endif + return EGL_FALSE; + case EGL_Y_INVERTED_NOK: + return conf->Display->Extensions.NOK_texture_from_pixmap; + default: + break; + } + + return EGL_TRUE; +} /** * Initialize a criteria config from the given attribute list. @@ -501,15 +527,13 @@ _eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list) /* parse the list */ for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i += 2) { - EGLint idx; - attr = attrib_list[i]; val = attrib_list[i + 1]; - idx = _eglIndexConfig(conf, attr); - if (idx < 0) - return EGL_FALSE; - conf->Storage[idx] = val; + if (!_eglIsConfigAttribValid(conf, attr)) + return EGL_FALSE; + + SET_CONFIG_ATTRIB(conf, attr, val); /* rememeber some attributes for post-processing */ switch (attr) { @@ -782,28 +806,6 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list, } -static INLINE EGLBoolean -_eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr) -{ - if (_eglIndexConfig(conf, attr) < 0) - return EGL_FALSE; - - /* there are some holes in the range */ - switch (attr) { - case 0x3030 /* a gap before EGL_SAMPLES */: - case EGL_NONE: -#ifdef EGL_VERSION_1_4 - case EGL_MATCH_NATIVE_PIXMAP: -#endif - return EGL_FALSE; - default: - break; - } - - return EGL_TRUE; -} - - /** * Fallback for eglGetConfigAttrib. */ diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h index ced060f7797..ca63c40d3d7 100644 --- a/src/egl/main/eglconfig.h +++ b/src/egl/main/eglconfig.h @@ -8,16 +8,24 @@ #define _EGL_CONFIG_FIRST_ATTRIB EGL_BUFFER_SIZE #define _EGL_CONFIG_LAST_ATTRIB EGL_CONFORMANT -#define _EGL_CONFIG_NUM_ATTRIBS \ +#define _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS \ (_EGL_CONFIG_LAST_ATTRIB - _EGL_CONFIG_FIRST_ATTRIB + 1) -#define _EGL_CONFIG_STORAGE_SIZE _EGL_CONFIG_NUM_ATTRIBS +/* Attributes outside the contiguous block: + * + * EGL_Y_INVERTED_NOK + */ +#define _EGL_CONFIG_FIRST_EXTRA_ATTRIB _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS +#define _EGL_CONFIG_NUM_EXTRA_ATTRIBS 1 + +#define _EGL_CONFIG_NUM_ATTRIBS \ + _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS + _EGL_CONFIG_NUM_EXTRA_ATTRIBS struct _egl_config { _EGLDisplay *Display; - EGLint Storage[_EGL_CONFIG_STORAGE_SIZE]; + EGLint Storage[_EGL_CONFIG_NUM_ATTRIBS]; }; @@ -37,10 +45,15 @@ _eglIndexConfig(const _EGLConfig *conf, EGLint key) { (void) conf; if (key >= _EGL_CONFIG_FIRST_ATTRIB && - key < _EGL_CONFIG_FIRST_ATTRIB + _EGL_CONFIG_NUM_ATTRIBS) + key < _EGL_CONFIG_FIRST_ATTRIB + _EGL_CONFIG_NUM_CONTIGUOUS_ATTRIBS) return key - _EGL_CONFIG_FIRST_ATTRIB; - else + + switch (key) { + case EGL_Y_INVERTED_NOK: + return _EGL_CONFIG_FIRST_EXTRA_ATTRIB; + default: return -1; + } } diff --git a/src/egl/main/egldefines.h b/src/egl/main/egldefines.h index 8fc2301b795..4ecd4c1420c 100644 --- a/src/egl/main/egldefines.h +++ b/src/egl/main/egldefines.h @@ -40,6 +40,7 @@ #define _EGL_VENDOR_STRING "Mesa Project" +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) #endif /* EGLDEFINES_INCLUDED */ diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 21bf22b5fee..42e305f91ac 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -46,6 +46,8 @@ struct _egl_extensions EGLBoolean KHR_gl_texture_cubemap_image; EGLBoolean KHR_gl_texture_3D_image; EGLBoolean KHR_gl_renderbuffer_image; + EGLBoolean NOK_swap_region; + EGLBoolean NOK_texture_from_pixmap; char String[_EGL_MAX_EXTENSIONS_LEN]; }; diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 6384242b093..566554d51dc 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -36,7 +36,9 @@ /* XXX Need to decide how to do dynamic name lookup on Windows */ -static const char DefaultDriverName[] = "TBD"; +static const char DefaultDriverNames[] = { + "TBD", +}; typedef HMODULE lib_handle; @@ -63,7 +65,10 @@ library_suffix(void) #elif defined(_EGL_PLATFORM_POSIX) -static const char DefaultDriverName[] = "egl_glx"; +static const char *DefaultDriverNames[] = { + "egl_dri2", + "egl_glx" +}; typedef void * lib_handle; @@ -87,32 +92,6 @@ library_suffix(void) } -#else /* _EGL_PLATFORM_NO_OS */ - - -static const char DefaultDriverName[] = "builtin"; - -typedef void *lib_handle; - -static INLINE void * -open_library(const char *filename) -{ - return (void *) filename; -} - -static INLINE void -close_library(void *lib) -{ -} - - -static const char * -library_suffix(void) -{ - return NULL; -} - - #endif @@ -157,12 +136,6 @@ _eglOpenLibrary(const char *driverPath, lib_handle *handle) else { error = dlerror(); } -#else /* _EGL_PLATFORM_NO_OS */ - /* must be the default driver name */ - if (strcmp(driverPath, DefaultDriverName) == 0) - mainFunc = (_EGLMain_t) _eglMain; - else - error = "not builtin driver"; #endif if (!lib) { @@ -293,9 +266,9 @@ _eglLoaderFile(const char *dir, size_t len, void *loader_data) len += flen; path[len] = '\0'; - drv = _eglLoadDriver(path, NULL); - /* fix the path and load again */ - if (!drv && library_suffix()) { + if (library_suffix() == NULL || strstr(path, library_suffix())) + drv = _eglLoadDriver(path, NULL); + else { const char *suffix = library_suffix(); size_t slen = strlen(suffix); const char *p; @@ -306,6 +279,8 @@ _eglLoaderFile(const char *dir, size_t len, void *loader_data) if (need_suffix && len + slen + 1 <= sizeof(path)) { strcpy(path + len, suffix); drv = _eglLoadDriver(path, NULL); + } else { + drv = NULL; } } if (!drv) @@ -518,17 +493,6 @@ _eglPreloadDisplayDrivers(void) /** - * Preload the default driver. - */ -static EGLBoolean -_eglPreloadDefaultDriver(void) -{ - return (_eglPreloadForEach(_eglGetSearchPath(), - _eglLoaderFile, (void *) DefaultDriverName) > 0); -} - - -/** * Preload drivers. * * This function loads the driver modules and creates the corresponding @@ -549,15 +513,13 @@ _eglPreloadDrivers(void) } loaded = (_eglPreloadUserDriver() || - _eglPreloadDisplayDrivers() || - _eglPreloadDefaultDriver()); + _eglPreloadDisplayDrivers()); _eglUnlockMutex(_eglGlobal.Mutex); return loaded; } - /** * Unload preloaded drivers. */ @@ -588,6 +550,30 @@ _eglUnloadDrivers(void) _eglGlobal.NumDrivers = 0; } +_EGLDriver * +_eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor) +{ + _EGLDriver *drv = NULL; + int i; + + _eglLockMutex(_eglGlobal.Mutex); + + for (i = 0; i < ARRAY_SIZE(DefaultDriverNames); i++) { + _eglPreloadForEach(_eglGetSearchPath(), + _eglLoaderFile, (void *) DefaultDriverNames[i]); + if (_eglGlobal.NumDrivers == 0) + continue; + drv = _eglGlobal.Drivers[0]; + if (drv->API.Initialize(drv, dpy, major, minor)) + break; + _eglUnloadDrivers(); + } + + _eglUnlockMutex(_eglGlobal.Mutex); + + return drv; +} + /** * Plug all the available fallback routines into the given driver's @@ -653,6 +639,21 @@ _eglInitDriverFallbacks(_EGLDriver *drv) /** + * Invoke a callback function on each EGL search path. + * + * The first argument of the callback function is the name of the search path. + * The second argument is the length of the name. + */ +void +_eglSearchPathForEach(EGLBoolean (*callback)(const char *, size_t, void *), + void *callback_data) +{ + const char *search_path = _eglGetSearchPath(); + _eglPreloadForEach(search_path, callback, callback_data); +} + + +/** * Set the probe cache at the given key. * * A key, instead of a _EGLDriver, is used to allow the probe cache to be share diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 55686681dcb..8b34c43b924 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -84,11 +84,20 @@ extern void _eglUnloadDrivers(void); +extern _EGLDriver * +_eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor); + + PUBLIC void _eglInitDriverFallbacks(_EGLDriver *drv); PUBLIC void +_eglSearchPathForEach(EGLBoolean (*callback)(const char *, size_t, void *), + void *callback_data); + + +PUBLIC void _eglSetProbeCache(EGLint key, const void *val); diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 5182b18e226..e63819e08a2 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -6,9 +6,6 @@ #include "eglmutex.h" -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - - static _EGL_DECLARE_MUTEX(_eglGlobalMutex); struct _egl_global _eglGlobal = { diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index 984e426686e..e62a9e7de8c 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -96,6 +96,8 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy) _EGL_CHECK_EXTENSION(KHR_gl_texture_3D_image); _EGL_CHECK_EXTENSION(KHR_gl_renderbuffer_image); + _EGL_CHECK_EXTENSION(NOK_swap_region); + _EGL_CHECK_EXTENSION(NOK_texture_from_pixmap); #undef _EGL_CHECK_EXTENSION } diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 8026a6314d3..d46bdb0672e 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -36,12 +36,17 @@ _eglClampSwapInterval(_EGLSurface *surf, EGLint interval) static EGLint _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) { + _EGLDisplay *dpy = surf->Resource.Display; EGLint type = surf->Type; + EGLint texture_type = EGL_PBUFFER_BIT; EGLint i, err = EGL_SUCCESS; if (!attrib_list) return EGL_SUCCESS; + if (dpy->Extensions.NOK_texture_from_pixmap) + texture_type |= EGL_PIXMAP_BIT; + for (i = 0; attrib_list[i] != EGL_NONE; i++) { EGLint attr = attrib_list[i++]; EGLint val = attrib_list[i]; @@ -125,7 +130,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) surf->LargestPbuffer = !!val; break; case EGL_TEXTURE_FORMAT: - if (type != EGL_PBUFFER_BIT) { + if (!(type & texture_type)) { err = EGL_BAD_ATTRIBUTE; break; } @@ -143,7 +148,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) surf->TextureFormat = val; break; case EGL_TEXTURE_TARGET: - if (type != EGL_PBUFFER_BIT) { + if (!(type & texture_type)) { err = EGL_BAD_ATTRIBUTE; break; } @@ -160,7 +165,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) surf->TextureTarget = val; break; case EGL_MIPMAP_TEXTURE: - if (type != EGL_PBUFFER_BIT) { + if (!(type & texture_type)) { err = EGL_BAD_ATTRIBUTE; break; } @@ -452,11 +457,16 @@ EGLBoolean _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer) { + EGLint texture_type = EGL_PBUFFER_BIT; + /* Just do basic error checking and return success/fail. * Drivers must implement the real stuff. */ - if (surface->Type != EGL_PBUFFER_BIT) { + if (dpy->Extensions.NOK_texture_from_pixmap) + texture_type |= EGL_PIXMAP_BIT; + + if (!(surface->Type & texture_type)) { _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); return EGL_FALSE; } @@ -466,6 +476,11 @@ _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, return EGL_FALSE; } + if (surface->TextureTarget == EGL_NO_TEXTURE) { + _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + return EGL_FALSE; + } + if (buffer != EGL_BACK_BUFFER) { _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); return EGL_FALSE; diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index 0a00035730f..8f520dcdf65 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -83,7 +83,7 @@ extern EGLBoolean _eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint value); -extern EGLBoolean +PUBLIC extern EGLBoolean _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer); diff --git a/src/gallium/SConscript b/src/gallium/SConscript index 6c0e7a518d1..e5e9578b5e4 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -25,4 +25,4 @@ SConscript('targets/SConscript') if platform != 'embedded': SConscript('tests/unit/SConscript') - #SConscript('tests/raw/SConscript') + #SConscript('tests/graw/SConscript') diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index e0d9b313544..1abf12e95bd 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -168,7 +168,8 @@ GALLIVM_SOURCES = \ draw/draw_pt_fetch_shade_pipeline_llvm.c \ draw/draw_llvm_translate.c -GALLIVM_CPP_SOURCES = +GALLIVM_CPP_SOURCES = \ + gallivm/lp_bld_misc.cpp GENERATED_SOURCES = \ indices/u_indices_gen.c \ diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index 29a1bd0ecba..7039d5f0c55 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -205,6 +205,7 @@ if env['llvm']: 'gallivm/lp_bld_intr.c', 'gallivm/lp_bld_logic.c', 'gallivm/lp_bld_init.c', + 'gallivm/lp_bld_misc.cpp', 'gallivm/lp_bld_pack.c', 'gallivm/lp_bld_printf.c', 'gallivm/lp_bld_sample.c', diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 02abddf1491..61980c3e4f5 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -566,7 +566,7 @@ draw_get_rasterizer_no_cull( struct draw_context *draw, memset(&rast, 0, sizeof(rast)); rast.scissor = scissor; rast.flatshade = flatshade; - rast.front_winding = PIPE_WINDING_CCW; + rast.front_ccw = 1; rast.gl_rasterization_rules = draw->rasterizer->gl_rasterization_rules; draw->rasterizer_no_cull[scissor][flatshade] = diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index ea9b7c90a51..7ea51621f72 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -12,6 +12,7 @@ #include "gallivm/lp_bld_printf.h" #include "tgsi/tgsi_exec.h" +#include "tgsi/tgsi_dump.h" #include "util/u_cpu_detect.h" #include "util/u_string.h" @@ -21,6 +22,34 @@ #define DEBUG_STORE 0 +/** cast wrapper */ +static INLINE draw_jit_vert_func_elts +voidptr_to_draw_vert_func_elts(void *v) +{ + union { + void *v; + draw_jit_vert_func_elts f; + } u; + assert(sizeof(u.v) == sizeof(u.f)); + u.v = v; + return u.f; +} + + +/** cast wrapper */ +static INLINE draw_jit_vert_func +voidptr_to_draw_jit_vert_func(void *v) +{ + union { + void *v; + draw_jit_vert_func f; + } u; + assert(sizeof(u.v) == sizeof(u.f)); + u.v = v; + return u.f; +} + + /* generates the draw jit function */ static void draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *var); @@ -161,9 +190,16 @@ create_vertex_header(struct draw_llvm *llvm, int data_elems) struct draw_llvm * draw_llvm_create(struct draw_context *draw) { - struct draw_llvm *llvm = CALLOC_STRUCT( draw_llvm ); + struct draw_llvm *llvm; +#ifdef PIPE_ARCH_X86 util_cpu_detect(); + /* require SSE2 due to LLVM PR6960. */ + if (!util_cpu_caps.has_sse2) + return NULL; +#endif + + llvm = CALLOC_STRUCT( draw_llvm ); llvm->draw = draw; llvm->engine = draw->engine; @@ -179,27 +215,34 @@ draw_llvm_create(struct draw_context *draw) llvm->pass = LLVMCreateFunctionPassManager(llvm->provider); LLVMAddTargetData(llvm->target, llvm->pass); - /* These are the passes currently listed in llvm-c/Transforms/Scalar.h, - * but there are more on SVN. */ - /* TODO: Add more passes */ - LLVMAddCFGSimplificationPass(llvm->pass); - LLVMAddPromoteMemoryToRegisterPass(llvm->pass); - LLVMAddConstantPropagationPass(llvm->pass); - if(util_cpu_caps.has_sse4_1) { - /* FIXME: There is a bug in this pass, whereby the combination of fptosi - * and sitofp (necessary for trunc/floor/ceil/round implementation) - * somehow becomes invalid code. + + if ((gallivm_debug & GALLIVM_DEBUG_NO_OPT) == 0) { + /* These are the passes currently listed in llvm-c/Transforms/Scalar.h, + * but there are more on SVN. */ + /* TODO: Add more passes */ + LLVMAddCFGSimplificationPass(llvm->pass); + LLVMAddPromoteMemoryToRegisterPass(llvm->pass); + LLVMAddConstantPropagationPass(llvm->pass); + if(util_cpu_caps.has_sse4_1) { + /* FIXME: There is a bug in this pass, whereby the combination of fptosi + * and sitofp (necessary for trunc/floor/ceil/round implementation) + * somehow becomes invalid code. + */ + LLVMAddInstructionCombiningPass(llvm->pass); + } + LLVMAddGVNPass(llvm->pass); + } else { + /* We need at least this pass to prevent the backends to fail in + * unexpected ways. */ - LLVMAddInstructionCombiningPass(llvm->pass); + LLVMAddPromoteMemoryToRegisterPass(llvm->pass); } - LLVMAddGVNPass(llvm->pass); init_globals(llvm); - -#if 0 - LLVMDumpModule(llvm->module); -#endif + if (gallivm_debug & GALLIVM_DEBUG_IR) { + LLVMDumpModule(llvm->module); + } return llvm; } @@ -248,7 +291,10 @@ generate_vs(struct draw_llvm *llvm, num_vs = 4; /* number of vertices per block */ #endif - /*tgsi_dump(tokens, 0);*/ + if (gallivm_debug & GALLIVM_DEBUG_IR) { + tgsi_dump(tokens, 0); + } + lp_build_tgsi_soa(builder, tokens, vs_type, @@ -579,6 +625,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant) struct lp_type vs_type = lp_type_float_vec(32); const int max_vertices = 4; LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS]; + void *code; arg_types[0] = llvm->context_ptr_type; /* context */ arg_types[1] = llvm->vertex_header_ptr_type; /* vertex_header */ @@ -684,21 +731,24 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant) */ #ifdef DEBUG if(LLVMVerifyFunction(variant->function, LLVMPrintMessageAction)) { - LLVMDumpValue(variant->function); + lp_debug_dump_value(variant->function); assert(0); } #endif LLVMRunFunctionPassManager(llvm->pass, variant->function); - if (0) { - LLVMDumpValue(variant->function); + if (gallivm_debug & GALLIVM_DEBUG_IR) { + lp_debug_dump_value(variant->function); debug_printf("\n"); } - variant->jit_func = (draw_jit_vert_func)LLVMGetPointerToGlobal(llvm->draw->engine, variant->function); - if (0) - lp_disassemble(variant->jit_func); + code = LLVMGetPointerToGlobal(llvm->draw->engine, variant->function); + variant->jit_func = voidptr_to_draw_jit_vert_func(code); + + if (gallivm_debug & GALLIVM_DEBUG_ASM) { + lp_disassemble(code); + } } @@ -721,6 +771,7 @@ draw_llvm_generate_elts(struct draw_llvm *llvm, struct draw_llvm_variant *varian const int max_vertices = 4; LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS]; LLVMValueRef fetch_max; + void *code; arg_types[0] = llvm->context_ptr_type; /* context */ arg_types[1] = llvm->vertex_header_ptr_type; /* vertex_header */ @@ -835,22 +886,24 @@ draw_llvm_generate_elts(struct draw_llvm *llvm, struct draw_llvm_variant *varian */ #ifdef DEBUG if(LLVMVerifyFunction(variant->function_elts, LLVMPrintMessageAction)) { - LLVMDumpValue(variant->function_elts); + lp_debug_dump_value(variant->function_elts); assert(0); } #endif LLVMRunFunctionPassManager(llvm->pass, variant->function_elts); - if (0) { - LLVMDumpValue(variant->function_elts); + if (gallivm_debug & GALLIVM_DEBUG_IR) { + lp_debug_dump_value(variant->function_elts); debug_printf("\n"); } - variant->jit_func_elts = (draw_jit_vert_func_elts)LLVMGetPointerToGlobal( - llvm->draw->engine, variant->function_elts); - if (0) - lp_disassemble(variant->jit_func_elts); + code = LLVMGetPointerToGlobal(llvm->draw->engine, variant->function_elts); + variant->jit_func_elts = voidptr_to_draw_vert_func_elts(code); + + if (gallivm_debug & GALLIVM_DEBUG_ASM) { + lp_disassemble(code); + } } void diff --git a/src/gallium/auxiliary/draw/draw_pipe.c b/src/gallium/auxiliary/draw/draw_pipe.c index 64c35025081..7ea04e38193 100644 --- a/src/gallium/auxiliary/draw/draw_pipe.c +++ b/src/gallium/auxiliary/draw/draw_pipe.c @@ -170,7 +170,25 @@ static void do_triangle( struct draw_context *draw, * Set up macros for draw_pt_decompose.h template code. * This code uses vertex indexes / elements. */ -#define QUAD(i0,i1,i2,i3) \ + +/* emit first quad vertex as first vertex in triangles */ +#define QUAD_FIRST_PV(i0,i1,i2,i3) \ + do_triangle( draw, \ + ( DRAW_PIPE_RESET_STIPPLE | \ + DRAW_PIPE_EDGE_FLAG_0 | \ + DRAW_PIPE_EDGE_FLAG_1 ), \ + verts + stride * elts[i0], \ + verts + stride * elts[i1], \ + verts + stride * elts[i2]); \ + do_triangle( draw, \ + ( DRAW_PIPE_EDGE_FLAG_1 | \ + DRAW_PIPE_EDGE_FLAG_2 ), \ + verts + stride * elts[i0], \ + verts + stride * elts[i2], \ + verts + stride * elts[i3]) + +/* emit last quad vertex as last vertex in triangles */ +#define QUAD_LAST_PV(i0,i1,i2,i3) \ do_triangle( draw, \ ( DRAW_PIPE_RESET_STIPPLE | \ DRAW_PIPE_EDGE_FLAG_0 | \ @@ -261,9 +279,27 @@ void draw_pipeline_run( struct draw_context *draw, /* * Set up macros for draw_pt_decompose.h template code. - * This code is for non-indexed rendering (no elts). + * This code is for non-indexed (aka linear) rendering (no elts). */ -#define QUAD(i0,i1,i2,i3) \ + +/* emit first quad vertex as first vertex in triangles */ +#define QUAD_FIRST_PV(i0,i1,i2,i3) \ + do_triangle( draw, \ + ( DRAW_PIPE_RESET_STIPPLE | \ + DRAW_PIPE_EDGE_FLAG_0 | \ + DRAW_PIPE_EDGE_FLAG_1 ), \ + verts + stride * ((i0) & ~DRAW_PIPE_FLAG_MASK), \ + verts + stride * (i1), \ + verts + stride * (i2)); \ + do_triangle( draw, \ + ( DRAW_PIPE_EDGE_FLAG_1 | \ + DRAW_PIPE_EDGE_FLAG_2 ), \ + verts + stride * ((i0) & ~DRAW_PIPE_FLAG_MASK), \ + verts + stride * (i2), \ + verts + stride * (i3)) + +/* emit last quad vertex as last vertex in triangles */ +#define QUAD_LAST_PV(i0,i1,i2,i3) \ do_triangle( draw, \ ( DRAW_PIPE_RESET_STIPPLE | \ DRAW_PIPE_EDGE_FLAG_0 | \ diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c index 51a6115ebf5..df8d82e367d 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_clip.c +++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c @@ -157,6 +157,10 @@ static void interp( const struct clip_stage *clip, } +/** + * Emit a post-clip polygon to the next pipeline stage. The polygon + * will be convex and the provoking vertex will always be vertex[0]. + */ static void emit_poly( struct draw_stage *stage, struct vertex_header **inlist, unsigned n, @@ -164,10 +168,18 @@ static void emit_poly( struct draw_stage *stage, { struct prim_header header; unsigned i; + ushort edge_first, edge_middle, edge_last; - const ushort edge_first = DRAW_PIPE_EDGE_FLAG_2; - const ushort edge_middle = DRAW_PIPE_EDGE_FLAG_0; - const ushort edge_last = DRAW_PIPE_EDGE_FLAG_1; + if (stage->draw->rasterizer->flatshade_first) { + edge_first = DRAW_PIPE_EDGE_FLAG_0; + edge_middle = DRAW_PIPE_EDGE_FLAG_1; + edge_last = DRAW_PIPE_EDGE_FLAG_2; + } + else { + edge_first = DRAW_PIPE_EDGE_FLAG_2; + edge_middle = DRAW_PIPE_EDGE_FLAG_0; + edge_last = DRAW_PIPE_EDGE_FLAG_1; + } /* later stages may need the determinant, but only the sign matters */ header.det = origPrim->det; @@ -175,9 +187,17 @@ static void emit_poly( struct draw_stage *stage, header.pad = 0; for (i = 2; i < n; i++, header.flags = edge_middle) { - header.v[0] = inlist[i-1]; - header.v[1] = inlist[i]; - header.v[2] = inlist[0]; /* keep in v[2] for flatshading */ + /* order the triangle verts to respect the provoking vertex mode */ + if (stage->draw->rasterizer->flatshade_first) { + header.v[0] = inlist[0]; /* the provoking vertex */ + header.v[1] = inlist[i-1]; + header.v[2] = inlist[i]; + } + else { + header.v[0] = inlist[i-1]; + header.v[1] = inlist[i]; + header.v[2] = inlist[0]; /* the provoking vertex */ + } if (i == n-1) header.flags |= edge_last; @@ -185,7 +205,8 @@ static void emit_poly( struct draw_stage *stage, if (0) { const struct draw_vertex_shader *vs = stage->draw->vs.vertex_shader; uint j, k; - debug_printf("Clipped tri:\n"); + debug_printf("Clipped tri: (flat-shade-first = %d)\n", + stage->draw->rasterizer->flatshade_first); for (j = 0; j < 3; j++) { for (k = 0; k < vs->info.num_outputs; k++) { debug_printf(" Vert %d: Attr %d: %f %f %f %f\n", j, k, @@ -291,12 +312,21 @@ do_clip_tri( struct draw_stage *stage, } } - /* If flat-shading, copy color to new provoking vertex. + /* If flat-shading, copy provoking vertex color to polygon vertex[0] */ - if (clipper->flat && inlist[0] != header->v[2]) { - inlist[0] = dup_vert(stage, inlist[0], tmpnr++); - - copy_colors(stage, inlist[0], header->v[2]); + if (clipper->flat) { + if (stage->draw->rasterizer->flatshade_first) { + if (inlist[0] != header->v[0]) { + inlist[0] = dup_vert(stage, inlist[0], tmpnr++); + copy_colors(stage, inlist[0], header->v[0]); + } + } + else { + if (inlist[0] != header->v[2]) { + inlist[0] = dup_vert(stage, inlist[0], tmpnr++); + copy_colors(stage, inlist[0], header->v[2]); + } + } } /* Emit the polygon as triangles to the setup stage: diff --git a/src/gallium/auxiliary/draw/draw_pipe_cull.c b/src/gallium/auxiliary/draw/draw_pipe_cull.c index dc66c65a56c..bf84ce30ed1 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_cull.c +++ b/src/gallium/auxiliary/draw/draw_pipe_cull.c @@ -40,7 +40,8 @@ struct cull_stage { struct draw_stage stage; - unsigned winding; /**< which winding(s) to cull (one of PIPE_WINDING_x) */ + unsigned cull_face; /**< which face(s) to cull (one of PIPE_FACE_x) */ + unsigned front_ccw; }; @@ -73,9 +74,12 @@ static void cull_tri( struct draw_stage *stage, /* if det < 0 then Z points toward the camera and the triangle is * counter-clockwise winding. */ - unsigned winding = (header->det < 0) ? PIPE_WINDING_CCW : PIPE_WINDING_CW; + unsigned ccw = (header->det < 0); + unsigned face = ((ccw == cull_stage(stage)->front_ccw) ? + PIPE_FACE_FRONT : + PIPE_FACE_BACK); - if ((winding & cull_stage(stage)->winding) == 0) { + if ((face & cull_stage(stage)->cull_face) == 0) { /* triangle is not culled, pass to next stage */ stage->next->tri( stage->next, header ); } @@ -88,7 +92,8 @@ static void cull_first_tri( struct draw_stage *stage, { struct cull_stage *cull = cull_stage(stage); - cull->winding = stage->draw->rasterizer->cull_mode; + cull->cull_face = stage->draw->rasterizer->cull_face; + cull->front_ccw = stage->draw->rasterizer->front_ccw; stage->tri = cull_tri; stage->tri( stage, header ); diff --git a/src/gallium/auxiliary/draw/draw_pipe_twoside.c b/src/gallium/auxiliary/draw/draw_pipe_twoside.c index eef0238b157..808b2fb0b58 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_twoside.c +++ b/src/gallium/auxiliary/draw/draw_pipe_twoside.c @@ -141,7 +141,7 @@ static void twoside_first_tri( struct draw_stage *stage, * if the triangle is back-facing (negative). * sign = -1 for CCW, +1 for CW */ - twoside->sign = (stage->draw->rasterizer->front_winding == PIPE_WINDING_CCW) ? -1.0f : 1.0f; + twoside->sign = stage->draw->rasterizer->front_ccw ? -1.0f : 1.0f; stage->tri = twoside_tri; stage->tri( stage, header ); diff --git a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c index 03bb842e20a..e333d26a932 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c +++ b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c @@ -105,6 +105,23 @@ static void lines( struct draw_stage *stage, } +/** For debugging */ +static void +print_header_flags(unsigned flags) +{ + debug_printf("header->flags = "); + if (flags & DRAW_PIPE_RESET_STIPPLE) + debug_printf("RESET_STIPPLE "); + if (flags & DRAW_PIPE_EDGE_FLAG_0) + debug_printf("EDGE_FLAG_0 "); + if (flags & DRAW_PIPE_EDGE_FLAG_1) + debug_printf("EDGE_FLAG_1 "); + if (flags & DRAW_PIPE_EDGE_FLAG_2) + debug_printf("EDGE_FLAG_2 "); + debug_printf("\n"); +} + + /* Unfilled tri: * * Note edgeflags in the vertex struct is not sufficient as we will @@ -117,8 +134,12 @@ static void unfilled_tri( struct draw_stage *stage, struct prim_header *header ) { struct unfilled_stage *unfilled = unfilled_stage(stage); - unsigned mode = unfilled->mode[header->det >= 0.0]; + unsigned cw = header->det >= 0.0; + unsigned mode = unfilled->mode[cw]; + if (0) + print_header_flags(header->flags); + switch (mode) { case PIPE_POLYGON_MODE_FILL: stage->next->tri( stage->next, header ); @@ -139,9 +160,10 @@ static void unfilled_first_tri( struct draw_stage *stage, struct prim_header *header ) { struct unfilled_stage *unfilled = unfilled_stage(stage); + const struct pipe_rasterizer_state *rast = stage->draw->rasterizer; - unfilled->mode[0] = stage->draw->rasterizer->fill_ccw; /* front */ - unfilled->mode[1] = stage->draw->rasterizer->fill_cw; /* back */ + unfilled->mode[0] = rast->front_ccw ? rast->fill_front : rast->fill_back; + unfilled->mode[1] = rast->front_ccw ? rast->fill_back : rast->fill_front; stage->tri = unfilled_tri; stage->tri( stage, header ); diff --git a/src/gallium/auxiliary/draw/draw_pipe_validate.c b/src/gallium/auxiliary/draw/draw_pipe_validate.c index 2a50af7a414..eafa29276ff 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_validate.c +++ b/src/gallium/auxiliary/draw/draw_pipe_validate.c @@ -122,12 +122,14 @@ draw_need_pipeline(const struct draw_context *draw, return TRUE; /* unfilled polygons */ - if (rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL || - rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL) + if (rasterizer->fill_front != PIPE_POLYGON_MODE_FILL || + rasterizer->fill_back != PIPE_POLYGON_MODE_FILL) return TRUE; /* polygon offset */ - if (rasterizer->offset_cw || rasterizer->offset_ccw) + if (rasterizer->offset_point || + rasterizer->offset_line || + rasterizer->offset_tri) return TRUE; /* two-side lighting */ @@ -222,8 +224,8 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) next = draw->pipeline.pstipple; } - if (rast->fill_cw != PIPE_POLYGON_MODE_FILL || - rast->fill_ccw != PIPE_POLYGON_MODE_FILL) { + if (rast->fill_front != PIPE_POLYGON_MODE_FILL || + rast->fill_back != PIPE_POLYGON_MODE_FILL) { draw->pipeline.unfilled->next = next; next = draw->pipeline.unfilled; precalc_flat = TRUE; /* only needed for triangles really */ @@ -235,8 +237,9 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) next = draw->pipeline.flatshade; } - if (rast->offset_cw || - rast->offset_ccw) { + if (rast->offset_point || + rast->offset_line || + rast->offset_tri) { draw->pipeline.offset->next = next; next = draw->pipeline.offset; need_det = TRUE; @@ -255,7 +258,7 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) * to less work emitting vertices, smaller vertex buffers, etc. * It's difficult to say whether this will be true in general. */ - if (need_det || rast->cull_mode) { + if (need_det || rast->cull_face != PIPE_FACE_NONE) { draw->pipeline.cull->next = next; next = draw->pipeline.cull; } diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c index abbf6247ab8..3c93c9014a6 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c +++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c @@ -159,19 +159,8 @@ vbuf_tri( struct draw_stage *stage, check_space( vbuf, 3 ); - if (vbuf->stage.draw->rasterizer->flatshade_first) { - /* Put provoking vertex in position expected by the driver. - * Emit last provoking vertex in first pos. - * Swap verts 0 & 1 to preserve polygon winding. - */ - vbuf->indices[vbuf->nr_indices++] = emit_vertex( vbuf, prim->v[2] ); - vbuf->indices[vbuf->nr_indices++] = emit_vertex( vbuf, prim->v[0] ); - vbuf->indices[vbuf->nr_indices++] = emit_vertex( vbuf, prim->v[1] ); - } - else { - for (i = 0; i < 3; i++) { - vbuf->indices[vbuf->nr_indices++] = emit_vertex( vbuf, prim->v[i] ); - } + for (i = 0; i < 3; i++) { + vbuf->indices[vbuf->nr_indices++] = emit_vertex( vbuf, prim->v[i] ); } } @@ -335,9 +324,9 @@ vbuf_flush_vertices( struct vbuf_stage *vbuf ) if (vbuf->nr_indices) { - vbuf->render->draw(vbuf->render, - vbuf->indices, - vbuf->nr_indices ); + vbuf->render->draw_elements(vbuf->render, + vbuf->indices, + vbuf->nr_indices ); vbuf->nr_indices = 0; } diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c index ab167065815..d7ac95b7405 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c +++ b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c @@ -77,8 +77,11 @@ static void wideline_line( struct draw_stage *stage, const float dx = fabsf(pos0[0] - pos2[0]); const float dy = fabsf(pos0[1] - pos2[1]); + const boolean gl_rasterization_rules = + stage->draw->rasterizer->gl_rasterization_rules; + /* small tweak to meet GL specification */ - const float bias = 0.125f; + const float bias = gl_rasterization_rules ? 0.125f : 0.0f; /* * Draw wide line as a quad (two tris) by "stretching" the line along @@ -92,19 +95,21 @@ static void wideline_line( struct draw_stage *stage, pos1[1] = pos1[1] + half_width - bias; pos2[1] = pos2[1] - half_width - bias; pos3[1] = pos3[1] + half_width - bias; - if (pos0[0] < pos2[0]) { - /* left to right line */ - pos0[0] -= 0.5f; - pos1[0] -= 0.5f; - pos2[0] -= 0.5f; - pos3[0] -= 0.5f; - } - else { - /* right to left line */ - pos0[0] += 0.5f; - pos1[0] += 0.5f; - pos2[0] += 0.5f; - pos3[0] += 0.5f; + if (gl_rasterization_rules) { + if (pos0[0] < pos2[0]) { + /* left to right line */ + pos0[0] -= 0.5f; + pos1[0] -= 0.5f; + pos2[0] -= 0.5f; + pos3[0] -= 0.5f; + } + else { + /* right to left line */ + pos0[0] += 0.5f; + pos1[0] += 0.5f; + pos2[0] += 0.5f; + pos3[0] += 0.5f; + } } } else { @@ -113,19 +118,21 @@ static void wideline_line( struct draw_stage *stage, pos1[0] = pos1[0] + half_width + bias; pos2[0] = pos2[0] - half_width + bias; pos3[0] = pos3[0] + half_width + bias; - if (pos0[1] < pos2[1]) { - /* top to bottom line */ - pos0[1] -= 0.5f; - pos1[1] -= 0.5f; - pos2[1] -= 0.5f; - pos3[1] -= 0.5f; - } - else { - /* bottom to top line */ - pos0[1] += 0.5f; - pos1[1] += 0.5f; - pos2[1] += 0.5f; - pos3[1] += 0.5f; + if (gl_rasterization_rules) { + if (pos0[1] < pos2[1]) { + /* top to bottom line */ + pos0[1] -= 0.5f; + pos1[1] -= 0.5f; + pos2[1] -= 0.5f; + pos3[1] -= 0.5f; + } + else { + /* bottom to top line */ + pos0[1] += 0.5f; + pos1[1] += 0.5f; + pos2[1] += 0.5f; + pos3[1] += 0.5f; + } } } diff --git a/src/gallium/auxiliary/draw/draw_pt_decompose.h b/src/gallium/auxiliary/draw/draw_pt_decompose.h index 3c44f7c11ee..52f9593d46e 100644 --- a/src/gallium/auxiliary/draw/draw_pt_decompose.h +++ b/src/gallium/auxiliary/draw/draw_pt_decompose.h @@ -47,33 +47,26 @@ static void FUNC( ARGS, case PIPE_PRIM_TRIANGLES: for (i = 0; i+2 < count; i += 3) { - if (flatfirst) { - /* put provoking vertex in last pos for clipper */ - TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, - (i + 1), - (i + 2), - (i + 0 )); - } - else { - TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, - (i + 0), - (i + 1), - (i + 2 )); - } + TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, + (i + 0), + (i + 1), + (i + 2 )); } break; case PIPE_PRIM_TRIANGLE_STRIP: if (flatfirst) { for (i = 0; i+2 < count; i++) { + /* Emit first triangle vertex as first triangle vertex */ TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, + (i + 0), (i + 1 + (i&1)), - (i + 2 - (i&1)), - (i + 0) ); + (i + 2 - (i&1)) ); } } else { for (i = 0; i+2 < count; i++) { + /* Emit last triangle vertex as last triangle vertex */ TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, (i + 0 + (i&1)), (i + 1 - (i&1)), @@ -87,9 +80,9 @@ static void FUNC( ARGS, if (flatfirst) { for (i = 0; i+2 < count; i++) { TRIANGLE( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_ALL, + (i + 1), (i + 2), - 0, - (i + 1) ); + 0 ); } } else { @@ -105,24 +98,52 @@ static void FUNC( ARGS, case PIPE_PRIM_QUADS: - for (i = 0; i+3 < count; i += 4) { - QUAD( (i + 0), - (i + 1), - (i + 2), - (i + 3)); + /* GL quads don't follow provoking vertex convention */ + if (flatfirst) { + for (i = 0; i+3 < count; i += 4) { + /* emit last quad vertex as first triangle vertex */ + QUAD_FIRST_PV( (i + 3), + (i + 0), + (i + 1), + (i + 2) ); + } + } + else { + for (i = 0; i+3 < count; i += 4) { + /* emit last quad vertex as last triangle vertex */ + QUAD_LAST_PV( (i + 0), + (i + 1), + (i + 2), + (i + 3) ); + } } break; case PIPE_PRIM_QUAD_STRIP: - for (i = 0; i+3 < count; i += 2) { - QUAD( (i + 2), - (i + 0), - (i + 1), - (i + 3)); + /* GL quad strips don't follow provoking vertex convention */ + if (flatfirst) { + for (i = 0; i+3 < count; i += 2) { + /* emit last quad vertex as first triangle vertex */ + QUAD_FIRST_PV( (i + 3), + (i + 2), + (i + 0), + (i + 1) ); + + } + } + else { + for (i = 0; i+3 < count; i += 2) { + /* emit last quad vertex as last triangle vertex */ + QUAD_LAST_PV( (i + 2), + (i + 0), + (i + 1), + (i + 3) ); + } } break; case PIPE_PRIM_POLYGON: + /* GL polygons don't follow provoking vertex convention */ { /* These bitflags look a little odd because we submit the * vertices as (1,2,0) to satisfy flatshade requirements. @@ -138,10 +159,20 @@ static void FUNC( ARGS, if (i + 3 == count) flags |= edge_last; - TRIANGLE( flags, - (i + 1), - (i + 2), - (0)); + if (flatfirst) { + /* emit first polygon vertex as first triangle vertex */ + TRIANGLE( flags, + (0), + (i + 1), + (i + 2) ); + } + else { + /* emit first polygon vertex as last triangle vertex */ + TRIANGLE( flags, + (i + 1), + (i + 2), + (0)); + } } } break; @@ -156,7 +187,8 @@ static void FUNC( ARGS, #undef TRIANGLE -#undef QUAD +#undef QUAD_FIRST_PV +#undef QUAD_LAST_PV #undef POINT #undef LINE #undef FUNC diff --git a/src/gallium/auxiliary/draw/draw_pt_emit.c b/src/gallium/auxiliary/draw/draw_pt_emit.c index ad48fa39a4f..f623c0743da 100644 --- a/src/gallium/auxiliary/draw/draw_pt_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_emit.c @@ -190,9 +190,9 @@ void draw_pt_emit( struct pt_emit *emit, 0, vertex_count - 1 ); - render->draw(render, - elts, - count); + render->draw_elements(render, + elts, + count); render->release_vertices(render); } diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c index d7735bf1ac9..5158c6341c0 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c @@ -254,9 +254,9 @@ static void fetch_emit_run( struct draw_pt_middle_end *middle, /* XXX: Draw arrays path to avoid re-emitting index list again and * again. */ - draw->render->draw( draw->render, - draw_elts, - draw_count ); + draw->render->draw_elements( draw->render, + draw_elts, + draw_count ); /* Done -- that was easy, wasn't it: */ @@ -363,9 +363,9 @@ static boolean fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle, /* XXX: Draw arrays path to avoid re-emitting index list again and * again. */ - draw->render->draw( draw->render, - draw_elts, - draw_count ); + draw->render->draw_elements( draw->render, + draw_elts, + draw_count ); /* Done -- that was easy, wasn't it: */ diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c index cbb5b6c9605..f0fc591bf55 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c @@ -307,9 +307,9 @@ fse_run(struct draw_pt_middle_end *middle, draw->render->unmap_vertices( draw->render, 0, (ushort)(fetch_count - 1) ); - draw->render->draw( draw->render, - draw_elts, - draw_count ); + draw->render->draw_elements( draw->render, + draw_elts, + draw_count ); draw->render->release_vertices( draw->render ); @@ -357,9 +357,9 @@ static boolean fse_run_linear_elts( struct draw_pt_middle_end *middle, hw_verts ); - draw->render->draw( draw->render, - draw_elts, - draw_count ); + draw->render->draw_elements( draw->render, + draw_elts, + draw_count ); draw->render->unmap_vertices( draw->render, 0, (ushort)(count - 1) ); diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c index 6d00b0fbd44..d56889b5f65 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c @@ -32,7 +32,6 @@ #include "draw/draw_vertex.h" #include "draw/draw_pt.h" #include "draw/draw_vs.h" -#include "draw/draw_gs.h" #include "draw/draw_llvm.h" diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c index 37ffbac4f92..6a48e61e624 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache.c +++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c @@ -183,8 +183,16 @@ vcache_quad( struct vcache_frontend *vcache, unsigned i2, unsigned i3 ) { - vcache_triangle( vcache, i0, i1, i3 ); - vcache_triangle( vcache, i1, i2, i3 ); + if (vcache->draw->rasterizer->flatshade_first) { + /* pass last quad vertex as first triangle vertex */ + vcache_triangle( vcache, i3, i0, i1 ); + vcache_triangle( vcache, i3, i1, i2 ); + } + else { + /* pass last quad vertex as last triangle vertex */ + vcache_triangle( vcache, i0, i1, i3 ); + vcache_triangle( vcache, i1, i2, i3 ); + } } static INLINE void @@ -195,18 +203,20 @@ vcache_ef_quad( struct vcache_frontend *vcache, unsigned i3 ) { if (vcache->draw->rasterizer->flatshade_first) { + /* pass last quad vertex as first triangle vertex */ vcache_triangle_flags( vcache, ( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_0 | DRAW_PIPE_EDGE_FLAG_1 ), - i0, i1, i2 ); + i3, i0, i1 ); vcache_triangle_flags( vcache, - ( DRAW_PIPE_EDGE_FLAG_2 | - DRAW_PIPE_EDGE_FLAG_1 ), - i0, i2, i3 ); + ( DRAW_PIPE_EDGE_FLAG_1 | + DRAW_PIPE_EDGE_FLAG_2 ), + i3, i1, i2 ); } else { + /* pass last quad vertex as last triangle vertex */ vcache_triangle_flags( vcache, ( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_0 | diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h index f7a63de3ba9..dac68ad4398 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h +++ b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h @@ -142,20 +142,21 @@ static void FUNC( struct draw_pt_front_end *frontend, /* These bitflags look a little odd because we submit the * vertices as (1,2,0) to satisfy flatshade requirements. */ - const ushort edge_first = DRAW_PIPE_EDGE_FLAG_2; - const ushort edge_middle = DRAW_PIPE_EDGE_FLAG_0; - const ushort edge_last = DRAW_PIPE_EDGE_FLAG_1; ushort edge_next, edge_finish; if (flatfirst) { - flags = DRAW_PIPE_RESET_STIPPLE | edge_middle | edge_last; - edge_next = edge_last; - edge_finish = edge_first; + flags = (DRAW_PIPE_RESET_STIPPLE | + DRAW_PIPE_EDGE_FLAG_1 | + DRAW_PIPE_EDGE_FLAG_2); + edge_next = DRAW_PIPE_EDGE_FLAG_2; + edge_finish = DRAW_PIPE_EDGE_FLAG_0; } else { - flags = DRAW_PIPE_RESET_STIPPLE | edge_first | edge_middle; - edge_next = edge_middle; - edge_finish = edge_last; + flags = (DRAW_PIPE_RESET_STIPPLE | + DRAW_PIPE_EDGE_FLAG_2 | + DRAW_PIPE_EDGE_FLAG_0); + edge_next = DRAW_PIPE_EDGE_FLAG_0; + edge_finish = DRAW_PIPE_EDGE_FLAG_1; } for (i = 0; i+2 < count; i++, flags = edge_next) { diff --git a/src/gallium/auxiliary/draw/draw_vbuf.h b/src/gallium/auxiliary/draw/draw_vbuf.h index cccd3bf4358..83ae26a9c2b 100644 --- a/src/gallium/auxiliary/draw/draw_vbuf.h +++ b/src/gallium/auxiliary/draw/draw_vbuf.h @@ -98,14 +98,14 @@ struct vbuf_render { boolean (*set_primitive)( struct vbuf_render *, unsigned prim ); /** - * DrawElements, note indices are ushort. The driver must complete - * this call, if necessary splitting the index list itself. + * Draw indexed primitives. Note that indices are ushort. The driver + * must complete this call, if necessary splitting the index list itself. */ - void (*draw)( struct vbuf_render *, - const ushort *indices, - uint nr_indices ); + void (*draw_elements)( struct vbuf_render *, + const ushort *indices, + uint nr_indices ); - /* Draw Arrays path too. + /* Draw non-indexed primitives. */ void (*draw_arrays)( struct vbuf_render *, unsigned start, diff --git a/src/gallium/auxiliary/gallivm/f.cpp b/src/gallium/auxiliary/gallivm/f.cpp new file mode 100644 index 00000000000..5eb09c01ab3 --- /dev/null +++ b/src/gallium/auxiliary/gallivm/f.cpp @@ -0,0 +1,85 @@ +/************************************************************************** + * + * (C) Copyright VMware, Inc 2010. + * (C) Copyright John Maddock 2006. + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + **************************************************************************/ + + +/* + * This file allows to compute the minimax polynomial coefficients we use + * for fast exp2/log2. + * + * How to use this source: + * + * - Download and abuild the NTL library from + * http://shoup.net/ntl/download.html + * + * - Download boost source code matching to your distro. + * + * - Goto libs/math/minimax and replace f.cpp with this file. + * + * - Build as + * + * g++ -o minimax -I /path/to/ntl/include main.cpp f.cpp /path/to/ntl/src/ntl.a -lboost_math_tr1 + * + * - Run as + * + * ./minimax + * + * - For example, to compute exp2 5th order polynomial between [0, 1] do: + * + * variant 1 + * range 0 1 + * order 5 0 + * steps 200 + * info + * + * - For more info see + * http://www.boost.org/doc/libs/1_36_0/libs/math/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/minimax.html + */ + +#define L22 +#include <boost/math/bindings/rr.hpp> +#include <boost/math/tools/polynomial.hpp> + +#include <cmath> + + +boost::math::ntl::RR f(const boost::math::ntl::RR& x, int variant) +{ + static const boost::math::ntl::RR tiny = boost::math::tools::min_value<boost::math::ntl::RR>() * 64; + + switch(variant) + { + case 0: + // log2(x)/(x - 1) + return log(x)/log(2.0)/(x - 1.0); + + case 1: + // exp2(x) + return exp(x*log(2.0)); + } + + return 0; +} + + +void show_extra( + const boost::math::tools::polynomial<boost::math::ntl::RR>& n, + const boost::math::tools::polynomial<boost::math::ntl::RR>& d, + const boost::math::ntl::RR& x_offset, + const boost::math::ntl::RR& y_offset, + int variant) +{ + switch(variant) + { + default: + // do nothing here... + ; + } +} + diff --git a/src/gallium/auxiliary/gallivm/lp_bld.h b/src/gallium/auxiliary/gallivm/lp_bld.h index 2fa682f4009..8103bc917fc 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld.h +++ b/src/gallium/auxiliary/gallivm/lp_bld.h @@ -35,6 +35,17 @@ #define LP_BLD_H +/** + * @file + * LLVM IR building helpers interfaces. + * + * We use LLVM-C bindings for now. They are not documented, but follow the C++ + * interfaces very closely, and appear to be complete enough for code + * genration. See + * http://npcontemplation.blogspot.com/2008/06/secret-of-llvm-c-bindings.html + * for a standalone example. + */ + #include <llvm-c/Core.h> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index f372a48846f..b55c863aa04 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -54,6 +54,7 @@ #include "lp_bld_type.h" #include "lp_bld_const.h" #include "lp_bld_intr.h" +#include "lp_bld_init.h" /* for lp_build_engine */ #include "lp_bld_logic.h" #include "lp_bld_pack.h" #include "lp_bld_debug.h" @@ -239,7 +240,7 @@ lp_build_sum_vector(struct lp_build_context *bld, { const struct lp_type type = bld->type; LLVMValueRef index, res; - int i; + unsigned i; if (a == bld->zero) return bld->zero; @@ -675,26 +676,13 @@ lp_build_abs(struct lp_build_context *bld, if(type.floating) { /* Mask out the sign bit */ - if (type.length == 1) { - LLVMTypeRef int_type = LLVMIntType(type.width); - LLVMTypeRef float_type = LLVMFloatType(); - unsigned long long absMask = ~(1ULL << (type.width - 1)); - LLVMValueRef mask = LLVMConstInt(int_type, absMask, 0); - a = LLVMBuildBitCast(bld->builder, a, int_type, ""); - a = LLVMBuildAnd(bld->builder, a, mask, ""); - a = LLVMBuildBitCast(bld->builder, a, float_type, ""); - return a; - } - else { - /* vector of floats */ - LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); - unsigned long long absMask = ~(1ULL << (type.width - 1)); - LLVMValueRef mask = lp_build_const_int_vec(type, ((unsigned long long) absMask)); - a = LLVMBuildBitCast(bld->builder, a, int_vec_type, ""); - a = LLVMBuildAnd(bld->builder, a, mask, ""); - a = LLVMBuildBitCast(bld->builder, a, vec_type, ""); - return a; - } + LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); + unsigned long long absMask = ~(1ULL << (type.width - 1)); + LLVMValueRef mask = lp_build_const_int_vec(type, ((unsigned long long) absMask)); + a = LLVMBuildBitCast(bld->builder, a, int_vec_type, ""); + a = LLVMBuildAnd(bld->builder, a, mask, ""); + a = LLVMBuildBitCast(bld->builder, a, vec_type, ""); + return a; } if(type.width*type.length == 128 && util_cpu_caps.has_ssse3) { @@ -742,17 +730,9 @@ lp_build_sgn(struct lp_build_context *bld, LLVMValueRef one; unsigned long long maskBit = (unsigned long long)1 << (type.width - 1); - if (type.length == 1) { - int_type = lp_build_int_elem_type(type); - vec_type = lp_build_elem_type(type); - mask = LLVMConstInt(int_type, maskBit, 0); - } - else { - /* vector */ - int_type = lp_build_int_vec_type(type); - vec_type = lp_build_vec_type(type); - mask = lp_build_const_int_vec(type, maskBit); - } + int_type = lp_build_int_vec_type(type); + vec_type = lp_build_vec_type(type); + mask = lp_build_const_int_vec(type, maskBit); /* Take the sign bit and add it to 1 constant */ sign = LLVMBuildBitCast(bld->builder, a, int_type, ""); @@ -819,21 +799,11 @@ lp_build_int_to_float(struct lp_build_context *bld, LLVMValueRef a) { const struct lp_type type = bld->type; + LLVMTypeRef vec_type = lp_build_vec_type(type); assert(type.floating); - /*assert(lp_check_value(type, a));*/ - if (type.length == 1) { - LLVMTypeRef float_type = LLVMFloatType(); - return LLVMBuildSIToFP(bld->builder, a, float_type, ""); - } - else { - LLVMTypeRef vec_type = lp_build_vec_type(type); - /*LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);*/ - LLVMValueRef res; - res = LLVMBuildSIToFP(bld->builder, a, vec_type, ""); - return res; - } + return LLVMBuildSIToFP(bld->builder, a, vec_type, ""); } @@ -887,7 +857,7 @@ lp_build_trunc(struct lp_build_context *bld, assert(type.floating); assert(lp_check_value(type, a)); - if(util_cpu_caps.has_sse4_1) + if (util_cpu_caps.has_sse4_1 && type.width*type.length == 128) return lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_TRUNCATE); else { LLVMTypeRef vec_type = lp_build_vec_type(type); @@ -909,7 +879,7 @@ lp_build_round(struct lp_build_context *bld, assert(type.floating); assert(lp_check_value(type, a)); - if(util_cpu_caps.has_sse4_1) + if (util_cpu_caps.has_sse4_1 && type.width*type.length == 128) return lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_NEAREST); else { LLVMTypeRef vec_type = lp_build_vec_type(type); @@ -928,15 +898,9 @@ lp_build_floor(struct lp_build_context *bld, const struct lp_type type = bld->type; assert(type.floating); + assert(lp_check_value(type, a)); - if (type.length == 1) { - LLVMValueRef res; - res = lp_build_ifloor(bld, a); - res = LLVMBuildSIToFP(bld->builder, res, LLVMFloatType(), ""); - return res; - } - - if(util_cpu_caps.has_sse4_1) + if (util_cpu_caps.has_sse4_1 && type.width*type.length == 128) return lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_FLOOR); else { LLVMTypeRef vec_type = lp_build_vec_type(type); @@ -957,7 +921,7 @@ lp_build_ceil(struct lp_build_context *bld, assert(type.floating); assert(lp_check_value(type, a)); - if(util_cpu_caps.has_sse4_1) + if (util_cpu_caps.has_sse4_1 && type.width*type.length == 128) return lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_CEIL); else { LLVMTypeRef vec_type = lp_build_vec_type(type); @@ -991,18 +955,12 @@ lp_build_itrunc(struct lp_build_context *bld, LLVMValueRef a) { const struct lp_type type = bld->type; + LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); assert(type.floating); + assert(lp_check_value(type, a)); - if (type.length == 1) { - LLVMTypeRef int_type = LLVMIntType(type.width); - return LLVMBuildFPToSI(bld->builder, a, int_type, ""); - } - else { - LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); - assert(lp_check_value(type, a)); - return LLVMBuildFPToSI(bld->builder, a, int_vec_type, ""); - } + return LLVMBuildFPToSI(bld->builder, a, int_vec_type, ""); } @@ -1019,17 +977,9 @@ lp_build_iround(struct lp_build_context *bld, assert(type.floating); - if (type.length == 1) { - /* scalar float to int */ - LLVMTypeRef int_type = LLVMIntType(type.width); - /* XXX we want rounding here! */ - res = LLVMBuildFPToSI(bld->builder, a, int_type, ""); - return res; - } - assert(lp_check_value(type, a)); - if(util_cpu_caps.has_sse4_1) { + if (util_cpu_caps.has_sse4_1 && type.width*type.length == 128) { res = lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_NEAREST); } else { @@ -1069,17 +1019,9 @@ lp_build_ifloor(struct lp_build_context *bld, LLVMValueRef res; assert(type.floating); - - if (type.length == 1) { - /* scalar float to int */ - LLVMTypeRef int_type = LLVMIntType(type.width); - res = LLVMBuildFPToSI(bld->builder, a, int_type, ""); - return res; - } - assert(lp_check_value(type, a)); - if(util_cpu_caps.has_sse4_1) { + if (util_cpu_caps.has_sse4_1 && type.width*type.length == 128) { res = lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_FLOOR); } else { @@ -1127,10 +1069,11 @@ lp_build_iceil(struct lp_build_context *bld, assert(type.floating); assert(lp_check_value(type, a)); - if(util_cpu_caps.has_sse4_1) { + if (util_cpu_caps.has_sse4_1 && type.width*type.length == 128) { res = lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_CEIL); } else { + /* TODO: mimic lp_build_ifloor() here */ assert(0); res = bld->undef; } @@ -1228,6 +1171,92 @@ lp_build_rsqrt(struct lp_build_context *bld, } +#ifdef PIPE_OS_WINDOWS + +/* + * XXX: X86 backend translates llvm.cos.v4f32 to 4 calls to CRT's cosf() + * which is neither efficient nor does the CRT linkage work on Windows + * causing segmentation fault. + * + * XXX: With LLVM 2.7 both schemes cause an assertion failure. + */ +static LLVMValueRef +lp_build_sincos(struct lp_build_context *bld, + const char *name, + float (*func)(float), + LLVMValueRef a) +{ + LLVMModuleRef module = + LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(bld->builder))); + LLVMValueRef function; + LLVMValueRef res; + unsigned i; + + assert(bld->type.floating); + assert(bld->type.width == 32); + + function = LLVMGetNamedFunction(module, name); + if (!function) { + LLVMTypeRef ret_type; + LLVMTypeRef arg_types[1]; + LLVMTypeRef function_type; + + ret_type = LLVMFloatType(); + arg_types[0] = LLVMFloatType(); + function_type = LLVMFunctionType(ret_type, arg_types, Elements(arg_types), 0); + function = LLVMAddFunction(module, name, function_type); + + LLVMSetFunctionCallConv(function, LLVMCCallConv); + LLVMSetLinkage(function, LLVMPrivateLinkage); + + assert(LLVMIsDeclaration(function)); + + LLVMAddGlobalMapping(lp_build_engine, function, func); + } + + res = bld->undef; + + for (i = 0; i < bld->type.length; ++i) { + LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0); + LLVMValueRef args[1]; + LLVMValueRef tmp; + + args[0] = LLVMBuildExtractElement(bld->builder, a, index, ""); + + tmp = LLVMBuildCall(bld->builder, function, args, Elements(args), ""); + + res = LLVMBuildInsertElement(bld->builder, res, tmp, index, ""); + } + + return res; +} + +static float c_cosf( float f ) +{ + return (float) cos( (double) f ); +} + +static float c_sinf( float f ) +{ + return (float) sin( (double) f ); +} + +LLVMValueRef +lp_build_cos(struct lp_build_context *bld, + LLVMValueRef a) +{ + return lp_build_sincos(bld, "cosf", &c_cosf, a); +} + +LLVMValueRef +lp_build_sin(struct lp_build_context *bld, + LLVMValueRef a) +{ + return lp_build_sincos(bld, "sinf", &c_sinf, a); +} + +#else /* !PIPE_OS_WINDOWS */ + /** * Generate cos(a) */ @@ -1235,14 +1264,6 @@ LLVMValueRef lp_build_cos(struct lp_build_context *bld, LLVMValueRef a) { -#ifdef PIPE_OS_WINDOWS - /* - * FIXME: X86 backend translates llvm.cos.v4f32 to 4 calls to CRT's cosf() - * which is neither efficient nor does the CRT linkage work on Windows - * causing segmentation fault. So simply disable the code for now. - */ - return bld->one; -#else const struct lp_type type = bld->type; LLVMTypeRef vec_type = lp_build_vec_type(type); char intrinsic[32]; @@ -1253,7 +1274,6 @@ lp_build_cos(struct lp_build_context *bld, util_snprintf(intrinsic, sizeof intrinsic, "llvm.cos.v%uf%u", type.length, type.width); return lp_build_intrinsic_unary(bld->builder, intrinsic, vec_type, a); -#endif } @@ -1264,14 +1284,6 @@ LLVMValueRef lp_build_sin(struct lp_build_context *bld, LLVMValueRef a) { -#ifdef PIPE_OS_WINDOWS - /* - * FIXME: X86 backend translates llvm.sin.v4f32 to 4 calls to CRT's sinf() - * which is neither efficient nor does the CRT linkage work on Windows - * causing segmentation fault. So simply disable the code for now. - */ - return bld->zero; -#else const struct lp_type type = bld->type; LLVMTypeRef vec_type = lp_build_vec_type(type); char intrinsic[32]; @@ -1282,9 +1294,10 @@ lp_build_sin(struct lp_build_context *bld, util_snprintf(intrinsic, sizeof intrinsic, "llvm.sin.v%uf%u", type.length, type.width); return lp_build_intrinsic_unary(bld->builder, intrinsic, vec_type, a); -#endif } +#endif /* !PIPE_OS_WINDOWS */ + /** * Generate pow(x, y) @@ -1346,7 +1359,6 @@ lp_build_polynomial(struct lp_build_context *bld, unsigned num_coeffs) { const struct lp_type type = bld->type; - LLVMTypeRef float_type = LLVMFloatType(); LLVMValueRef res = NULL; unsigned i; @@ -1358,10 +1370,7 @@ lp_build_polynomial(struct lp_build_context *bld, for (i = num_coeffs; i--; ) { LLVMValueRef coeff; - if (type.length == 1) - coeff = LLVMConstReal(float_type, coeffs[i]); - else - coeff = lp_build_const_vec(type, coeffs[i]); + coeff = lp_build_const_vec(type, coeffs[i]); if(res) res = lp_build_add(bld, coeff, lp_build_mul(bld, x, res)); @@ -1377,17 +1386,31 @@ lp_build_polynomial(struct lp_build_context *bld, /** - * Minimax polynomial fit of 2**x, in range [-0.5, 0.5[ + * Minimax polynomial fit of 2**x, in range [0, 1[ */ const double lp_build_exp2_polynomial[] = { #if EXP_POLY_DEGREE == 5 - 9.9999994e-1, 6.9315308e-1, 2.4015361e-1, 5.5826318e-2, 8.9893397e-3, 1.8775767e-3 + 0.999999999690134838155, + 0.583974334321735217258, + 0.164553105719676828492, + 0.0292811063701710962255, + 0.00354944426657875141846, + 0.000296253726543423377365 #elif EXP_POLY_DEGREE == 4 - 1.0000026, 6.9300383e-1, 2.4144275e-1, 5.2011464e-2, 1.3534167e-2 + 1.00000001502262084505, + 0.563586057338685991394, + 0.150436017652442413623, + 0.0243220604213317927308, + 0.0025359088446580436489 #elif EXP_POLY_DEGREE == 3 - 9.9992520e-1, 6.9583356e-1, 2.2606716e-1, 7.8024521e-2 + 0.999925218562710312959, + 0.695833540494823811697, + 0.226067155427249155588, + 0.0780245226406372992967 #elif EXP_POLY_DEGREE == 2 - 1.0017247, 6.5763628e-1, 3.3718944e-1 + 1.00172476321474503578, + 0.657636275736077639316, + 0.33718943461968720704 #else #error #endif @@ -1421,17 +1444,16 @@ lp_build_exp2_approx(struct lp_build_context *bld, x = lp_build_min(bld, x, lp_build_const_vec(type, 129.0)); x = lp_build_max(bld, x, lp_build_const_vec(type, -126.99999)); - /* ipart = int(x - 0.5) */ - ipart = LLVMBuildSub(bld->builder, x, lp_build_const_vec(type, 0.5f), ""); - ipart = LLVMBuildFPToSI(bld->builder, ipart, int_vec_type, ""); + /* ipart = floor(x) */ + ipart = lp_build_floor(bld, x); /* fpart = x - ipart */ - fpart = LLVMBuildSIToFP(bld->builder, ipart, vec_type, ""); - fpart = LLVMBuildSub(bld->builder, x, fpart, ""); + fpart = LLVMBuildSub(bld->builder, x, ipart, ""); } if(p_exp2_int_part || p_exp2) { /* expipart = (float) (1 << ipart) */ + ipart = LLVMBuildFPToSI(bld->builder, ipart, int_vec_type, ""); expipart = LLVMBuildAdd(bld->builder, ipart, lp_build_const_int_vec(type, 127), ""); expipart = LLVMBuildShl(bld->builder, expipart, lp_build_const_int_vec(type, 23), ""); expipart = LLVMBuildBitCast(bld->builder, expipart, vec_type, ""); @@ -1472,13 +1494,27 @@ lp_build_exp2(struct lp_build_context *bld, */ const double lp_build_log2_polynomial[] = { #if LOG_POLY_DEGREE == 6 - 3.11578814719469302614, -3.32419399085241980044, 2.59883907202499966007, -1.23152682416275988241, 0.318212422185251071475, -0.0344359067839062357313 + 3.11578814719469302614, + -3.32419399085241980044, + 2.59883907202499966007, + -1.23152682416275988241, + 0.318212422185251071475, + -0.0344359067839062357313 #elif LOG_POLY_DEGREE == 5 - 2.8882704548164776201, -2.52074962577807006663, 1.48116647521213171641, -0.465725644288844778798, 0.0596515482674574969533 + 2.8882704548164776201, + -2.52074962577807006663, + 1.48116647521213171641, + -0.465725644288844778798, + 0.0596515482674574969533 #elif LOG_POLY_DEGREE == 4 - 2.61761038894603480148, -1.75647175389045657003, 0.688243882994381274313, -0.107254423828329604454 + 2.61761038894603480148, + -1.75647175389045657003, + 0.688243882994381274313, + -0.107254423828329604454 #elif LOG_POLY_DEGREE == 3 - 2.28330284476918490682, -1.04913055217340124191, 0.204446009836232697516 + 2.28330284476918490682, + -1.04913055217340124191, + 0.204446009836232697516 #else #error #endif @@ -1558,89 +1594,11 @@ lp_build_log2_approx(struct lp_build_context *bld, } -/** scalar version of above function */ -static void -lp_build_float_log2_approx(struct lp_build_context *bld, - LLVMValueRef x, - LLVMValueRef *p_exp, - LLVMValueRef *p_floor_log2, - LLVMValueRef *p_log2) -{ - const struct lp_type type = bld->type; - LLVMTypeRef float_type = LLVMFloatType(); - LLVMTypeRef int_type = LLVMIntType(type.width); - - LLVMValueRef expmask = LLVMConstInt(int_type, 0x7f800000, 0); - LLVMValueRef mantmask = LLVMConstInt(int_type, 0x007fffff, 0); - LLVMValueRef one = LLVMConstBitCast(bld->one, int_type); - - LLVMValueRef i = NULL; - LLVMValueRef exp = NULL; - LLVMValueRef mant = NULL; - LLVMValueRef logexp = NULL; - LLVMValueRef logmant = NULL; - LLVMValueRef res = NULL; - - if(p_exp || p_floor_log2 || p_log2) { - /* TODO: optimize the constant case */ - if(LLVMIsConstant(x)) - debug_printf("%s: inefficient/imprecise constant arithmetic\n", - __FUNCTION__); - - assert(type.floating && type.width == 32); - - i = LLVMBuildBitCast(bld->builder, x, int_type, ""); - - /* exp = (float) exponent(x) */ - exp = LLVMBuildAnd(bld->builder, i, expmask, ""); - } - - if(p_floor_log2 || p_log2) { - LLVMValueRef c23 = LLVMConstInt(int_type, 23, 0); - LLVMValueRef c127 = LLVMConstInt(int_type, 127, 0); - logexp = LLVMBuildLShr(bld->builder, exp, c23, ""); - logexp = LLVMBuildSub(bld->builder, logexp, c127, ""); - logexp = LLVMBuildSIToFP(bld->builder, logexp, float_type, ""); - } - - if(p_log2) { - /* mant = (float) mantissa(x) */ - mant = LLVMBuildAnd(bld->builder, i, mantmask, ""); - mant = LLVMBuildOr(bld->builder, mant, one, ""); - mant = LLVMBuildBitCast(bld->builder, mant, float_type, ""); - - logmant = lp_build_polynomial(bld, mant, lp_build_log2_polynomial, - Elements(lp_build_log2_polynomial)); - - /* This effectively increases the polynomial degree by one, but ensures that log2(1) == 0*/ - logmant = LLVMBuildMul(bld->builder, logmant, LLVMBuildSub(bld->builder, mant, bld->one, ""), ""); - - res = LLVMBuildAdd(bld->builder, logmant, logexp, ""); - } - - if(p_exp) { - exp = LLVMBuildBitCast(bld->builder, exp, float_type, ""); - *p_exp = exp; - } - - if(p_floor_log2) - *p_floor_log2 = logexp; - - if(p_log2) - *p_log2 = res; -} - - LLVMValueRef lp_build_log2(struct lp_build_context *bld, LLVMValueRef x) { LLVMValueRef res; - if (bld->type.length == 1) { - lp_build_float_log2_approx(bld, x, NULL, NULL, &res); - } - else { - lp_build_log2_approx(bld, x, NULL, NULL, &res); - } + lp_build_log2_approx(bld, x, NULL, NULL, &res); return res; } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.c b/src/gallium/auxiliary/gallivm/lp_bld_const.c index 57843e9a60c..031ce9d1a37 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_const.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_const.c @@ -301,6 +301,9 @@ lp_build_const_vec(struct lp_type type, elems[0] = LLVMConstInt(elem_type, val*dscale + 0.5, 0); } + if (type.length == 1) + return elems[0]; + for(i = 1; i < type.length; ++i) elems[i] = elems[0]; @@ -321,6 +324,9 @@ lp_build_const_int_vec(struct lp_type type, for(i = 0; i < type.length; ++i) elems[i] = LLVMConstInt(elem_type, val, type.sign ? 1 : 0); + if (type.length == 1) + return elems[0]; + return LLVMConstVector(elems, type.length); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.h b/src/gallium/auxiliary/gallivm/lp_bld_debug.h index 7b010cbdb09..858002b34fe 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_debug.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.h @@ -36,6 +36,19 @@ #include "util/u_string.h" +#define GALLIVM_DEBUG_TGSI 0x1 +#define GALLIVM_DEBUG_IR 0x2 +#define GALLIVM_DEBUG_ASM 0x4 +#define GALLIVM_DEBUG_NO_OPT 0x8 + + +#ifdef DEBUG +extern unsigned gallivm_debug; +#else +#define gallivm_debug 0 +#endif + + static INLINE void lp_build_name(LLVMValueRef val, const char *format, ...) { @@ -53,6 +66,10 @@ lp_build_name(LLVMValueRef val, const char *format, ...) } +void +lp_debug_dump_value(LLVMValueRef value); + + boolean lp_check_alignment(const void *ptr, unsigned alignment); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.c b/src/gallium/auxiliary/gallivm/lp_bld_flow.c index 8f15b1d287d..823a8ec7b70 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_flow.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.c @@ -821,8 +821,11 @@ lp_build_alloca(LLVMBuilderRef builder, LLVMBuilderRef first_builder = LLVMCreateBuilder(); LLVMValueRef res; - LLVMPositionBuilderAtEnd(first_builder, first_block); - LLVMPositionBuilderBefore(first_builder, first_instr); + if (first_instr) { + LLVMPositionBuilderBefore(first_builder, first_instr); + } else { + LLVMPositionBuilderAtEnd(first_builder, first_block); + } res = LLVMBuildAlloca(first_builder, type, name); @@ -840,7 +843,7 @@ lp_build_alloca(LLVMBuilderRef builder, * first block may prevent the X86 backend from successfully align the stack as * required. * - * Also the scalarrepl pass is supossedly more powerful and can promote + * Also the scalarrepl pass is supposedly more powerful and can promote * arrays in many cases. * * See also: @@ -859,7 +862,11 @@ lp_build_array_alloca(LLVMBuilderRef builder, LLVMBuilderRef first_builder = LLVMCreateBuilder(); LLVMValueRef res; - LLVMPositionBuilderBefore(first_builder, first_instr); + if (first_instr) { + LLVMPositionBuilderBefore(first_builder, first_instr); + } else { + LLVMPositionBuilderAtEnd(first_builder, first_block); + } res = LLVMBuildArrayAlloca(first_builder, type, count, name); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format.h b/src/gallium/auxiliary/gallivm/lp_bld_format.h index 085937588ff..5f5036e7bdc 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_format.h @@ -40,6 +40,7 @@ struct util_format_description; struct lp_type; +struct lp_build_context; /* @@ -70,16 +71,16 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder, void lp_build_format_swizzle_soa(const struct util_format_description *format_desc, - struct lp_type type, + struct lp_build_context *bld, const LLVMValueRef *unswizzled, - LLVMValueRef *swizzled); + LLVMValueRef swizzled_out[4]); void lp_build_unpack_rgba_soa(LLVMBuilderRef builder, const struct util_format_description *format_desc, struct lp_type type, LLVMValueRef packed, - LLVMValueRef *rgba); + LLVMValueRef rgba_out[4]); void @@ -90,7 +91,7 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder, LLVMValueRef offsets, LLVMValueRef i, LLVMValueRef j, - LLVMValueRef *rgba); + LLVMValueRef rgba_out[4]); #endif /* !LP_BLD_FORMAT_H */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c index 6257e9a4047..eb492042387 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c @@ -47,7 +47,8 @@ /** * Unpack a single pixel into its RGBA components. * - * @param packed integer. + * @param desc the pixel format for the packed pixel value + * @param packed integer pixel in a format such as PIPE_FORMAT_B8G8R8A8_UNORM * * @return RGBA in a 4 floats vector. */ @@ -62,9 +63,9 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder, LLVMValueRef scales[4]; LLVMValueRef swizzles[4]; LLVMValueRef aux[4]; - bool normalized; + boolean normalized; int empty_channel; - bool needs_uitofp; + boolean needs_uitofp; unsigned shift; unsigned i; @@ -79,7 +80,10 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder, if (desc->block.bits < 32) packed = LLVMBuildZExt(builder, packed, LLVMInt32Type(), ""); - /* Broadcast the packed value to all four channels */ + /* Broadcast the packed value to all four channels + * before: packed = BGRA + * after: packed = {BGRA, BGRA, BGRA, BGRA} + */ packed = LLVMBuildInsertElement(builder, LLVMGetUndef(LLVMVectorType(LLVMInt32Type(), 4)), packed, @@ -96,6 +100,8 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder, needs_uitofp = FALSE; empty_channel = -1; shift = 0; + + /* Loop over 4 color components */ for (i = 0; i < 4; ++i) { unsigned bits = desc->channel[i].size; @@ -128,8 +134,13 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder, shift += bits; } + /* Ex: convert packed = {BGRA, BGRA, BGRA, BGRA} + * into masked = {B, G, R, A} + */ shifted = LLVMBuildLShr(builder, packed, LLVMConstVector(shifts, 4), ""); masked = LLVMBuildAnd(builder, shifted, LLVMConstVector(masks, 4), ""); + + if (!needs_uitofp) { /* UIToFP can't be expressed in SSE2 */ casted = LLVMBuildSIToFP(builder, masked, LLVMVectorType(LLVMFloatType(), 4), ""); @@ -137,6 +148,11 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder, casted = LLVMBuildUIToFP(builder, masked, LLVMVectorType(LLVMFloatType(), 4), ""); } + /* At this point 'casted' may be a vector of floats such as + * {255.0, 255.0, 255.0, 255.0}. Next, if the pixel values are normalized + * we'll scale this to {1.0, 1.0, 1.0, 1.0}. + */ + if (normalized) scaled = LLVMBuildMul(builder, casted, LLVMConstVector(scales, 4), ""); else @@ -145,6 +161,7 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder, for (i = 0; i < 4; ++i) aux[i] = LLVMGetUndef(LLVMFloatType()); + /* Build swizzles vector to put components into R,G,B,A order */ for (i = 0; i < 4; ++i) { enum util_format_swizzle swizzle; @@ -185,7 +202,8 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder, } } - return LLVMBuildShuffleVector(builder, scaled, LLVMConstVector(aux, 4), LLVMConstVector(swizzles, 4), ""); + return LLVMBuildShuffleVector(builder, scaled, LLVMConstVector(aux, 4), + LLVMConstVector(swizzles, 4), ""); } @@ -208,7 +226,7 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder, LLVMValueRef shifted, casted, scaled, unswizzled; LLVMValueRef shifts[4]; LLVMValueRef scales[4]; - bool normalized; + boolean normalized; unsigned shift; unsigned i, j; @@ -292,10 +310,29 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder, } +typedef void (*fetch_func)(float *, const uint8_t *, unsigned, unsigned); + +/** cast wrapper */ +static void * +fetch_func_ptr_to_voidptr(fetch_func f) +{ + union { + void *v; + fetch_func f; + } u; + u.f = f; + return u.v; +} + + /** * Fetch a pixel into a 4 float AoS. * - * i and j are the sub-block pixel coordinates. + * \param format_desc describes format of the image we're fetching from + * \param ptr address of the pixel block (or the texel if uncompressed) + * \param i, j the sub-block pixel coordinates. For non-compressed formats + * these will always be (0,). + * \return valueRef with the float[4] RGBA pixel */ LLVMValueRef lp_build_fetch_rgba_aos(LLVMBuilderRef builder, @@ -368,7 +405,8 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder, assert(LLVMIsDeclaration(function)); - LLVMAddGlobalMapping(lp_build_engine, function, format_desc->fetch_rgba_float); + LLVMAddGlobalMapping(lp_build_engine, function, + fetch_func_ptr_to_voidptr(format_desc->fetch_rgba_float)); } tmp = lp_build_alloca(builder, LLVMVectorType(LLVMFloatType(), 4), ""); @@ -384,7 +422,7 @@ lp_build_fetch_rgba_aos(LLVMBuilderRef builder, args[2] = i; args[3] = j; - LLVMBuildCall(builder, function, args, 4, ""); + LLVMBuildCall(builder, function, args, Elements(args), ""); return LLVMBuildLoad(builder, tmp, ""); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c index 26b947b3b1c..e1b94adc85a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c @@ -26,6 +26,8 @@ **************************************************************************/ +#include "pipe/p_defines.h" + #include "util/u_format.h" #include "util/u_memory.h" #include "util/u_string.h" @@ -33,51 +35,38 @@ #include "lp_bld_type.h" #include "lp_bld_const.h" #include "lp_bld_conv.h" +#include "lp_bld_swizzle.h" #include "lp_bld_sample.h" /* for lp_build_gather */ #include "lp_bld_format.h" -static LLVMValueRef -lp_build_format_swizzle_chan_soa(struct lp_type type, - const LLVMValueRef *unswizzled, - enum util_format_swizzle swizzle) -{ - switch (swizzle) { - case UTIL_FORMAT_SWIZZLE_X: - case UTIL_FORMAT_SWIZZLE_Y: - case UTIL_FORMAT_SWIZZLE_Z: - case UTIL_FORMAT_SWIZZLE_W: - return unswizzled[swizzle]; - case UTIL_FORMAT_SWIZZLE_0: - return lp_build_zero(type); - case UTIL_FORMAT_SWIZZLE_1: - return lp_build_one(type); - case UTIL_FORMAT_SWIZZLE_NONE: - return lp_build_undef(type); - default: - assert(0); - return lp_build_undef(type); - } -} - - void lp_build_format_swizzle_soa(const struct util_format_description *format_desc, - struct lp_type type, + struct lp_build_context *bld, const LLVMValueRef *unswizzled, - LLVMValueRef *swizzled) + LLVMValueRef swizzled_out[4]) { - if(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) { + assert(UTIL_FORMAT_SWIZZLE_0 == PIPE_SWIZZLE_ZERO); + assert(UTIL_FORMAT_SWIZZLE_1 == PIPE_SWIZZLE_ONE); + + if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) { + /* + * Return zzz1 for depth-stencil formats. + * + * XXX: Allow to control the depth swizzle with an additional parameter, + * as the caller may wish another depth swizzle, or retain the stencil + * value. + */ enum util_format_swizzle swizzle = format_desc->swizzle[0]; - LLVMValueRef depth = lp_build_format_swizzle_chan_soa(type, unswizzled, swizzle); - swizzled[2] = swizzled[1] = swizzled[0] = depth; - swizzled[3] = lp_build_one(type); + LLVMValueRef depth = lp_build_swizzle_soa_channel(bld, unswizzled, swizzle); + swizzled_out[2] = swizzled_out[1] = swizzled_out[0] = depth; + swizzled_out[3] = bld->one; } else { unsigned chan; for (chan = 0; chan < 4; ++chan) { enum util_format_swizzle swizzle = format_desc->swizzle[chan]; - swizzled[chan] = lp_build_format_swizzle_chan_soa(type, unswizzled, swizzle); + swizzled_out[chan] = lp_build_swizzle_soa_channel(bld, unswizzled, swizzle); } } } @@ -100,14 +89,20 @@ lp_build_format_swizzle_soa(const struct util_format_description *format_desc, * It requires that a packed pixel fits into an element of the output * channels. The common case is when converting pixel with a depth of 32 bit or * less into floats. + * + * \param format_desc the format of the 'packed' incoming pixel vector + * \param type the desired type for rgba_out (type.length = n, above) + * \param packed the incoming vector of packed pixels + * \param rgba_out returns the SoA R,G,B,A vectors */ void lp_build_unpack_rgba_soa(LLVMBuilderRef builder, const struct util_format_description *format_desc, struct lp_type type, LLVMValueRef packed, - LLVMValueRef *rgba) + LLVMValueRef rgba_out[4]) { + struct lp_build_context bld; LLVMValueRef inputs[4]; unsigned start; unsigned chan; @@ -120,11 +115,13 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder, assert(type.floating); assert(type.width == 32); + lp_build_context_init(&bld, builder, type); + /* Decode the input vector components */ start = 0; for (chan = 0; chan < format_desc->nr_channels; ++chan) { - unsigned width = format_desc->channel[chan].size; - unsigned stop = start + width; + const unsigned width = format_desc->channel[chan].size; + const unsigned stop = start + width; LLVMValueRef input; input = packed; @@ -250,14 +247,24 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder, start = stop; } - lp_build_format_swizzle_soa(format_desc, type, inputs, rgba); + lp_build_format_swizzle_soa(format_desc, &bld, inputs, rgba_out); } /** - * Fetch a pixel into a SoA. + * Fetch a texels from a texture, returning them in SoA layout. * - * i and j are the sub-block pixel coordinates. + * \param type the desired return type for 'rgba'. The vector length + * is the number of texels to fetch + * + * \param base_ptr points to start of the texture image block. For non- + * compressed formats, this simply points to the texel. + * For compressed formats, it points to the start of the + * compressed data block. + * + * \param i, j the sub-block pixel coordinates. For non-compressed formats + * these will always be (0,0). For compressed formats, i will + * be in [0, block_width-1] and j will be in [0, block_height-1]. */ void lp_build_fetch_rgba_soa(LLVMBuilderRef builder, @@ -267,7 +274,7 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder, LLVMValueRef offset, LLVMValueRef i, LLVMValueRef j, - LLVMValueRef *rgba) + LLVMValueRef rgba_out[4]) { if (format_desc->layout == UTIL_FORMAT_LAYOUT_PLAIN && @@ -281,7 +288,7 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder, { /* * The packed pixel fits into an element of the destination format. Put - * the packed pixels into a vector and estract each component for all + * the packed pixels into a vector and extract each component for all * vector elements in parallel. */ @@ -289,6 +296,7 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder, /* * gather the texels from the texture + * Ex: packed = {BGRA, BGRA, BGRA, BGRA}. */ packed = lp_build_gather(builder, type.length, @@ -302,16 +310,16 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder, lp_build_unpack_rgba_soa(builder, format_desc, type, - packed, rgba); + packed, rgba_out); } else { /* * Fallback to calling lp_build_fetch_rgba_aos for each pixel. * - * This is not the most efficient way of fetching pixels, as - * we miss some opportunities to do vectorization, but this it is a - * convenient for formats or scenarios for which there was no opportunity - * or incentive to optimize. + * This is not the most efficient way of fetching pixels, as we + * miss some opportunities to do vectorization, but this is + * convenient for formats or scenarios for which there was no + * opportunity or incentive to optimize. */ unsigned k, chan; @@ -319,9 +327,10 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder, assert(type.floating); for (chan = 0; chan < 4; ++chan) { - rgba[chan] = lp_build_undef(type); + rgba_out[chan] = lp_build_undef(type); } + /* loop over number of pixels */ for(k = 0; k < type.length; ++k) { LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), k, 0); LLVMValueRef offset_elem; @@ -335,16 +344,19 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder, i_elem = LLVMBuildExtractElement(builder, i, index, ""); j_elem = LLVMBuildExtractElement(builder, j, index, ""); - tmp = lp_build_fetch_rgba_aos(builder, format_desc, ptr, i_elem, j_elem); + /* Get a single float[4]={R,G,B,A} pixel */ + tmp = lp_build_fetch_rgba_aos(builder, format_desc, ptr, + i_elem, j_elem); /* - * AoS to SoA + * Insert the AoS tmp value channels into the SoA result vectors at + * position = 'index'. */ - for (chan = 0; chan < 4; ++chan) { LLVMValueRef chan_val = LLVMConstInt(LLVMInt32Type(), chan, 0), tmp_chan = LLVMBuildExtractElement(builder, tmp, chan_val, ""); - rgba[chan] = LLVMBuildInsertElement(builder, rgba[chan], tmp_chan, index, ""); + rgba_out[chan] = LLVMBuildInsertElement(builder, rgba_out[chan], + tmp_chan, index, ""); } } } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 5067d0a164f..bd080f397aa 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -29,9 +29,23 @@ #include "pipe/p_compiler.h" #include "util/u_cpu_detect.h" #include "util/u_debug.h" +#include "lp_bld_debug.h" #include "lp_bld_init.h" +#ifdef DEBUG +unsigned gallivm_debug = 0; + +static const struct debug_named_value lp_bld_debug_flags[] = { + { "tgsi", GALLIVM_DEBUG_TGSI }, + { "ir", GALLIVM_DEBUG_IR }, + { "asm", GALLIVM_DEBUG_ASM }, + { "nopt", GALLIVM_DEBUG_NO_OPT }, + {NULL, 0} +}; +#endif + + LLVMModuleRef lp_build_module = NULL; LLVMExecutionEngineRef lp_build_engine = NULL; LLVMModuleProviderRef lp_build_provider = NULL; @@ -41,6 +55,10 @@ LLVMTargetDataRef lp_build_target = NULL; void lp_build_init(void) { +#ifdef DEBUG + gallivm_debug = debug_get_flags_option("GALLIVM_DEBUG", lp_bld_debug_flags, 0 ); +#endif + LLVMInitializeNativeTarget(); LLVMLinkInJIT(); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_limits.h b/src/gallium/auxiliary/gallivm/lp_bld_limits.h index e095a0abe3a..369c8121b5c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_limits.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_limits.h @@ -42,6 +42,8 @@ #define LP_MAX_TGSI_IMMEDIATES 256 +#define LP_MAX_TGSI_PREDS 16 + /** * Maximum control flow nesting * diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp new file mode 100644 index 00000000000..db0ca606e58 --- /dev/null +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -0,0 +1,100 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * THE 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, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + + +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS +#endif + +#ifndef __STDC_CONSTANT_MACROS +#define __STDC_CONSTANT_MACROS +#endif + +#include "llvm-c/Core.h" + +#include "pipe/p_config.h" +#include "util/u_debug.h" + + +#if (defined(PIPE_OS_WINDOWS) && !defined(PIPE_CC_MSVC)) || defined(PIPE_OS_EMBDDED) + +#include "llvm/Support/raw_ostream.h" + +class raw_debug_ostream : + public llvm::raw_ostream +{ + uint64_t pos; + + void write_impl(const char *Ptr, size_t Size); + uint64_t current_pos() { return pos; } + uint64_t current_pos() const { return pos; } + +#if HAVE_LLVM >= 0x207 + uint64_t preferred_buffer_size() { return 512; } +#else + size_t preferred_buffer_size() { return 512; } +#endif +}; + + +void +raw_debug_ostream::write_impl(const char *Ptr, size_t Size) +{ + if (Size > 0) { + char *lastPtr = (char *)&Ptr[Size]; + char last = *lastPtr; + *lastPtr = 0; + _debug_printf("%*s", Size, Ptr); + *lastPtr = last; + pos += Size; + } +} + + +/** + * Same as LLVMDumpValue, but through our debugging channels. + */ +extern "C" void +lp_debug_dump_value(LLVMValueRef value) +{ + raw_debug_ostream os; + llvm::unwrap(value)->print(os); + os.flush(); +} + + +#else + + +extern "C" void +lp_debug_dump_value(LLVMValueRef value) +{ + LLVMDumpValue(value); +} + + +#endif diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index 195a4953ab1..c7f9b1083b1 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -120,10 +120,12 @@ lp_sampler_static_state(struct lp_sampler_static_state *state, /** * Gather elements from scatter positions in memory into a single vector. + * Use for fetching texels from a texture. + * For SSE, typical values are length=4, src_width=32, dst_width=32. * - * @param src_width src element width - * @param dst_width result element width (source will be expanded to fit) - * @param length length of the offsets, + * @param length length of the offsets + * @param src_width src element width in bits + * @param dst_width result element width in bits (src will be expanded to fit) * @param base_ptr base pointer, should be a i8 pointer type. * @param offsets vector with offsets */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index 955b1d21ee5..51e98ab2f9e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -56,14 +56,14 @@ struct lp_sampler_static_state { /* pipe_sampler_view's state */ enum pipe_format format; - unsigned swizzle_r:3; + unsigned swizzle_r:3; /**< PIPE_SWIZZLE_* */ unsigned swizzle_g:3; unsigned swizzle_b:3; unsigned swizzle_a:3; /* pipe_texture's state */ - unsigned target:3; - unsigned pot_width:1; + unsigned target:3; /**< PIPE_TEXTURE_* */ + unsigned pot_width:1; /**< is the width a power of two? */ unsigned pot_height:1; unsigned pot_depth:1; @@ -97,40 +97,40 @@ struct lp_sampler_dynamic_state /** Obtain the base texture width. */ LLVMValueRef - (*width)( struct lp_sampler_dynamic_state *state, + (*width)( const struct lp_sampler_dynamic_state *state, LLVMBuilderRef builder, unsigned unit); /** Obtain the base texture height. */ LLVMValueRef - (*height)( struct lp_sampler_dynamic_state *state, + (*height)( const struct lp_sampler_dynamic_state *state, LLVMBuilderRef builder, unsigned unit); /** Obtain the base texture depth. */ LLVMValueRef - (*depth)( struct lp_sampler_dynamic_state *state, + (*depth)( const struct lp_sampler_dynamic_state *state, LLVMBuilderRef builder, unsigned unit); /** Obtain the number of mipmap levels (minus one). */ LLVMValueRef - (*last_level)( struct lp_sampler_dynamic_state *state, + (*last_level)( const struct lp_sampler_dynamic_state *state, LLVMBuilderRef builder, unsigned unit); LLVMValueRef - (*row_stride)( struct lp_sampler_dynamic_state *state, + (*row_stride)( const struct lp_sampler_dynamic_state *state, LLVMBuilderRef builder, unsigned unit); LLVMValueRef - (*img_stride)( struct lp_sampler_dynamic_state *state, + (*img_stride)( const struct lp_sampler_dynamic_state *state, LLVMBuilderRef builder, unsigned unit); LLVMValueRef - (*data_ptr)( struct lp_sampler_dynamic_state *state, + (*data_ptr)( const struct lp_sampler_dynamic_state *state, LLVMBuilderRef builder, unsigned unit); @@ -177,7 +177,7 @@ lp_build_sample_soa(LLVMBuilderRef builder, const LLVMValueRef *ddy, LLVMValueRef lod_bias, LLVMValueRef explicit_lod, - LLVMValueRef *texel); + LLVMValueRef texel_out[4]); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 3f0ea05b795..bc7213db8b3 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -186,50 +186,18 @@ texture_dims(enum pipe_texture_target tex) } -static LLVMValueRef -lp_build_swizzle_chan_soa(struct lp_type type, - const LLVMValueRef *unswizzled, - enum util_format_swizzle swizzle) -{ - switch (swizzle) { - case PIPE_SWIZZLE_RED: - case PIPE_SWIZZLE_GREEN: - case PIPE_SWIZZLE_BLUE: - case PIPE_SWIZZLE_ALPHA: - return unswizzled[swizzle]; - case PIPE_SWIZZLE_ZERO: - return lp_build_zero(type); - case PIPE_SWIZZLE_ONE: - return lp_build_one(type); - default: - assert(0); - return lp_build_undef(type); - } -} - - static void -lp_build_swizzle_soa(struct lp_build_sample_context *bld, - LLVMValueRef *texel) +apply_sampler_swizzle(struct lp_build_sample_context *bld, + LLVMValueRef *texel) { - LLVMValueRef unswizzled[4]; unsigned char swizzles[4]; - unsigned chan; - - for (chan = 0; chan < 4; ++chan) { - unswizzled[chan] = texel[chan]; - } swizzles[0] = bld->static_state->swizzle_r; swizzles[1] = bld->static_state->swizzle_g; swizzles[2] = bld->static_state->swizzle_b; swizzles[3] = bld->static_state->swizzle_a; - for (chan = 0; chan < 4; ++chan) { - unsigned swizzle = swizzles[chan]; - texel[chan] = lp_build_swizzle_chan_soa(bld->texel_type, - unswizzled, swizzle); - } + lp_build_swizzle_soa_inplace(&bld->texel_bld, texel, swizzles); } @@ -254,7 +222,7 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, LLVMValueRef y_stride, LLVMValueRef z_stride, LLVMValueRef data_ptr, - LLVMValueRef *texel) + LLVMValueRef texel_out[4]) { const int dims = texture_dims(bld->static_state->target); struct lp_build_context *int_coord_bld = &bld->int_coord_bld; @@ -343,9 +311,9 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, bld->texel_type, data_ptr, offset, i, j, - texel); + texel_out); - lp_build_swizzle_soa(bld, texel); + apply_sampler_swizzle(bld, texel_out); /* * Note: if we find an app which frequently samples the texture border @@ -369,8 +337,8 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, LLVMValueRef border_chan = lp_build_const_vec(bld->texel_type, bld->static_state->border_color[chan]); - texel[chan] = lp_build_select(&bld->texel_bld, use_border, - border_chan, texel[chan]); + texel_out[chan] = lp_build_select(&bld->texel_bld, use_border, + border_chan, texel_out[chan]); } } } @@ -950,7 +918,8 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, } else { const int dims = texture_dims(bld->static_state->target); - LLVMValueRef dsdx, dsdy, dtdx, dtdy, drdx, drdy; + LLVMValueRef dsdx, dsdy; + LLVMValueRef dtdx = NULL, dtdy = NULL, drdx = NULL, drdy = NULL; LLVMValueRef rho; /* @@ -1078,8 +1047,10 @@ lp_build_linear_mip_levels(struct lp_build_sample_context *bld, int_bld->zero, last_level); /* compute level 1 and clamp to legal range of levels */ - *level1_out = lp_build_add(int_bld, *level0_out, int_bld->one); - *level1_out = lp_build_min(int_bld, *level1_out, last_level); + level = lp_build_add(int_bld, level, int_bld->one); + *level1_out = lp_build_clamp(int_bld, level, + int_bld->zero, + last_level); *weight_out = lp_build_fract(float_bld, lod); } @@ -1830,7 +1801,7 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, LLVMValueRef height, LLVMValueRef stride_array, LLVMValueRef data_array, - LLVMValueRef *texel) + LLVMValueRef texel_out[4]) { LLVMBuilderRef builder = bld->builder; struct lp_build_context i32, h16, u8n; @@ -2023,17 +1994,17 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, packed, unswizzled); lp_build_format_swizzle_soa(bld->format_desc, - bld->texel_type, unswizzled, - texel); + &bld->texel_bld, + unswizzled, texel_out); - lp_build_swizzle_soa(bld, texel); + apply_sampler_swizzle(bld, texel_out); } static void lp_build_sample_compare(struct lp_build_sample_context *bld, LLVMValueRef p, - LLVMValueRef *texel) + LLVMValueRef texel[4]) { struct lp_build_context *texel_bld = &bld->texel_bld; LLVMValueRef res; @@ -2071,14 +2042,14 @@ lp_build_sample_compare(struct lp_build_sample_context *bld, */ static void lp_build_sample_nop(struct lp_build_sample_context *bld, - LLVMValueRef *texel) + LLVMValueRef texel_out[4]) { struct lp_build_context *texel_bld = &bld->texel_bld; unsigned chan; for (chan = 0; chan < 4; chan++) { /*lp_bld_mov(texel_bld, texel, texel_bld->one);*/ - texel[chan] = texel_bld->one; + texel_out[chan] = texel_bld->one; } } @@ -2101,7 +2072,7 @@ lp_build_sample_soa(LLVMBuilderRef builder, const LLVMValueRef *ddy, LLVMValueRef lod_bias, /* optional */ LLVMValueRef explicit_lod, /* optional */ - LLVMValueRef *texel) + LLVMValueRef texel_out[4]) { struct lp_build_sample_context bld; LLVMValueRef width, width_vec; @@ -2113,6 +2084,11 @@ lp_build_sample_soa(LLVMBuilderRef builder, LLVMValueRef t; LLVMValueRef r; + if (0) { + enum pipe_format fmt = static_state->format; + debug_printf("Sample from %s\n", util_format_name(fmt)); + } + /* Setup our build context */ memset(&bld, 0, sizeof bld); bld.builder = builder; @@ -2153,7 +2129,7 @@ lp_build_sample_soa(LLVMBuilderRef builder, if (0) { /* For debug: no-op texture sampling */ - lp_build_sample_nop(&bld, texel); + lp_build_sample_nop(&bld, texel_out); } else if (util_format_is_rgba8_variant(bld.format_desc) && static_state->target == PIPE_TEXTURE_2D && @@ -2164,7 +2140,7 @@ lp_build_sample_soa(LLVMBuilderRef builder, is_simple_wrap_mode(static_state->wrap_t)) { /* special case */ lp_build_sample_2d_linear_aos(&bld, s, t, width_vec, height_vec, - row_stride_array, data_array, texel); + row_stride_array, data_array, texel_out); } else { lp_build_sample_general(&bld, unit, s, t, r, ddx, ddy, @@ -2173,8 +2149,8 @@ lp_build_sample_soa(LLVMBuilderRef builder, width_vec, height_vec, depth_vec, row_stride_array, img_stride_array, data_array, - texel); + texel_out); } - lp_build_sample_compare(&bld, r, texel); + lp_build_sample_compare(&bld, r, texel_out); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c index 278c838eaca..3c8a7bc09ea 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c @@ -60,21 +60,38 @@ lp_build_broadcast(LLVMBuilderRef builder, } +/** + * Broadcast + */ LLVMValueRef lp_build_broadcast_scalar(struct lp_build_context *bld, LLVMValueRef scalar) { const struct lp_type type = bld->type; - LLVMValueRef res; - unsigned i; - res = bld->undef; - for(i = 0; i < type.length; ++i) { - LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0); - res = LLVMBuildInsertElement(bld->builder, res, scalar, index, ""); - } + assert(lp_check_elem_type(type, LLVMTypeOf(scalar))); - return res; + if (type.length == 1) { + return scalar; + } + else { + LLVMValueRef res; +#if HAVE_LLVM >= 0x207 + res = LLVMBuildInsertElement(bld->builder, bld->undef, scalar, + LLVMConstInt(LLVMInt32Type(), 0, 0), ""); + res = LLVMBuildShuffleVector(bld->builder, res, bld->undef, + lp_build_const_int_vec(type, 0), ""); +#else + /* XXX: The above path provokes a bug in LLVM 2.6 */ + unsigned i; + res = bld->undef; + for(i = 0; i < type.length; ++i) { + LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0); + res = LLVMBuildInsertElement(bld->builder, res, scalar, index, ""); + } +#endif + return res; + } } @@ -237,3 +254,78 @@ lp_build_swizzle2_aos(struct lp_build_context *bld, } +/** + * Extended swizzle of a single channel of a SoA vector. + * + * @param bld building context + * @param unswizzled array with the 4 unswizzled values + * @param swizzle one of the PIPE_SWIZZLE_* + * + * @return the swizzled value. + */ +LLVMValueRef +lp_build_swizzle_soa_channel(struct lp_build_context *bld, + const LLVMValueRef *unswizzled, + unsigned swizzle) +{ + switch (swizzle) { + case PIPE_SWIZZLE_RED: + case PIPE_SWIZZLE_GREEN: + case PIPE_SWIZZLE_BLUE: + case PIPE_SWIZZLE_ALPHA: + return unswizzled[swizzle]; + case PIPE_SWIZZLE_ZERO: + return bld->zero; + case PIPE_SWIZZLE_ONE: + return bld->one; + default: + assert(0); + return bld->undef; + } +} + + +/** + * Extended swizzle of a SoA vector. + * + * @param bld building context + * @param unswizzled array with the 4 unswizzled values + * @param swizzles array of PIPE_SWIZZLE_* + * @param swizzled output swizzled values + */ +void +lp_build_swizzle_soa(struct lp_build_context *bld, + const LLVMValueRef *unswizzled, + const unsigned char swizzles[4], + LLVMValueRef *swizzled) +{ + unsigned chan; + + for (chan = 0; chan < 4; ++chan) { + swizzled[chan] = lp_build_swizzle_soa_channel(bld, unswizzled, + swizzles[chan]); + } +} + + +/** + * Do an extended swizzle of a SoA vector inplace. + * + * @param bld building context + * @param values intput/output array with the 4 values + * @param swizzles array of PIPE_SWIZZLE_* + */ +void +lp_build_swizzle_soa_inplace(struct lp_build_context *bld, + LLVMValueRef *values, + const unsigned char swizzles[4]) +{ + LLVMValueRef unswizzled[4]; + unsigned chan; + + for (chan = 0; chan < 4; ++chan) { + unswizzled[chan] = values[chan]; + } + + lp_build_swizzle_soa(bld, unswizzled, swizzles, values); +} diff --git a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h index 138ca620e63..4f4fa777c93 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h @@ -88,4 +88,23 @@ lp_build_swizzle2_aos(struct lp_build_context *bld, const unsigned char swizzle[4]); +LLVMValueRef +lp_build_swizzle_soa_channel(struct lp_build_context *bld, + const LLVMValueRef *unswizzled, + unsigned swizzle); + + +void +lp_build_swizzle_soa(struct lp_build_context *bld, + const LLVMValueRef *unswizzled, + const unsigned char swizzles[4], + LLVMValueRef *swizzled); + + +void +lp_build_swizzle_soa_inplace(struct lp_build_context *bld, + LLVMValueRef *values, + const unsigned char swizzles[4]); + + #endif /* !LP_BLD_SWIZZLE_H */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index 5ce1385c480..4d415b6d416 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -59,7 +59,7 @@ struct lp_build_sampler_soa (*destroy)( struct lp_build_sampler_soa *sampler ); void - (*emit_fetch_texel)( struct lp_build_sampler_soa *sampler, + (*emit_fetch_texel)( const struct lp_build_sampler_soa *sampler, LLVMBuilderRef builder, struct lp_type type, unsigned unit, @@ -83,7 +83,7 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, const LLVMValueRef (*inputs)[4], LLVMValueRef (*outputs)[4], struct lp_build_sampler_soa *sampler, - struct tgsi_shader_info *info); + const struct tgsi_shader_info *info); #endif /* LP_BLD_TGSI_H */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 0b1a28a7ab7..40ea94c4935 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -81,6 +81,8 @@ #define QUAD_BOTTOM_LEFT 2 #define QUAD_BOTTOM_RIGHT 3 +#define LP_MAX_INSTRUCTIONS 256 + struct lp_exec_mask { struct lp_build_context *bld; @@ -93,18 +95,24 @@ struct lp_exec_mask { int cond_stack_size; LLVMValueRef cond_mask; - LLVMValueRef break_stack[LP_MAX_TGSI_NESTING]; - int break_stack_size; - LLVMValueRef break_mask; - - LLVMValueRef cont_stack[LP_MAX_TGSI_NESTING]; - int cont_stack_size; + LLVMBasicBlockRef loop_block; LLVMValueRef cont_mask; - - LLVMBasicBlockRef loop_stack[LP_MAX_TGSI_NESTING]; + LLVMValueRef break_mask; + LLVMValueRef break_var; + struct { + LLVMBasicBlockRef loop_block; + LLVMValueRef cont_mask; + LLVMValueRef break_mask; + LLVMValueRef break_var; + } loop_stack[LP_MAX_TGSI_NESTING]; int loop_stack_size; - LLVMBasicBlockRef loop_block; + LLVMValueRef ret_mask; + struct { + int pc; + LLVMValueRef ret_mask; + } call_stack[LP_MAX_TGSI_NESTING]; + int call_stack_size; LLVMValueRef exec_mask; }; @@ -113,16 +121,20 @@ struct lp_build_tgsi_soa_context { struct lp_build_context base; + /* Builder for integer masks and indices */ + struct lp_build_context int_bld; + LLVMValueRef consts_ptr; const LLVMValueRef *pos; const LLVMValueRef (*inputs)[NUM_CHANNELS]; LLVMValueRef (*outputs)[NUM_CHANNELS]; - struct lp_build_sampler_soa *sampler; + const struct lp_build_sampler_soa *sampler; LLVMValueRef immediates[LP_MAX_TGSI_IMMEDIATES][NUM_CHANNELS]; LLVMValueRef temps[LP_MAX_TGSI_TEMPS][NUM_CHANNELS]; LLVMValueRef addr[LP_MAX_TGSI_ADDRS][NUM_CHANNELS]; + LLVMValueRef preds[LP_MAX_TGSI_PREDS][NUM_CHANNELS]; /* we allocate an array of temps if we have indirect * addressing and then the temps above is unused */ @@ -131,6 +143,9 @@ struct lp_build_tgsi_soa_context struct lp_build_mask_context *mask; struct lp_exec_mask exec_mask; + + struct tgsi_full_instruction *instructions; + uint max_instructions; }; static const unsigned char @@ -163,10 +178,11 @@ static void lp_exec_mask_init(struct lp_exec_mask *mask, struct lp_build_context mask->has_mask = FALSE; mask->cond_stack_size = 0; mask->loop_stack_size = 0; - mask->break_stack_size = 0; - mask->cont_stack_size = 0; + mask->call_stack_size = 0; mask->int_vec_type = lp_build_int_vec_type(mask->bld->type); + mask->exec_mask = mask->ret_mask = mask->break_mask = mask->cont_mask = mask->cond_mask = + LLVMConstAllOnes(mask->int_vec_type); } static void lp_exec_mask_update(struct lp_exec_mask *mask) @@ -186,34 +202,45 @@ static void lp_exec_mask_update(struct lp_exec_mask *mask) } else mask->exec_mask = mask->cond_mask; + if (mask->call_stack_size) { + mask->exec_mask = LLVMBuildAnd(mask->bld->builder, + mask->exec_mask, + mask->ret_mask, + "callmask"); + } mask->has_mask = (mask->cond_stack_size > 0 || - mask->loop_stack_size > 0); + mask->loop_stack_size > 0 || + mask->call_stack_size > 0); } static void lp_exec_mask_cond_push(struct lp_exec_mask *mask, LLVMValueRef val) { assert(mask->cond_stack_size < LP_MAX_TGSI_NESTING); + if (mask->cond_stack_size == 0) { + assert(mask->cond_mask == LLVMConstAllOnes(mask->int_vec_type)); + } mask->cond_stack[mask->cond_stack_size++] = mask->cond_mask; - mask->cond_mask = LLVMBuildBitCast(mask->bld->builder, val, - mask->int_vec_type, ""); + assert(LLVMTypeOf(val) == mask->int_vec_type); + mask->cond_mask = val; lp_exec_mask_update(mask); } static void lp_exec_mask_cond_invert(struct lp_exec_mask *mask) { - LLVMValueRef prev_mask = mask->cond_stack[mask->cond_stack_size - 1]; - LLVMValueRef inv_mask = LLVMBuildNot(mask->bld->builder, - mask->cond_mask, ""); - - /* means that we didn't have any mask before and that - * we were fully enabled */ - if (mask->cond_stack_size <= 1) { - prev_mask = LLVMConstAllOnes(mask->int_vec_type); + LLVMValueRef prev_mask; + LLVMValueRef inv_mask; + + assert(mask->cond_stack_size); + prev_mask = mask->cond_stack[mask->cond_stack_size - 1]; + if (mask->cond_stack_size == 1) { + assert(prev_mask == LLVMConstAllOnes(mask->int_vec_type)); } + inv_mask = LLVMBuildNot(mask->bld->builder, mask->cond_mask, ""); + mask->cond_mask = LLVMBuildAnd(mask->bld->builder, inv_mask, prev_mask, ""); @@ -222,31 +249,37 @@ static void lp_exec_mask_cond_invert(struct lp_exec_mask *mask) static void lp_exec_mask_cond_pop(struct lp_exec_mask *mask) { + assert(mask->cond_stack_size); mask->cond_mask = mask->cond_stack[--mask->cond_stack_size]; lp_exec_mask_update(mask); } static void lp_exec_bgnloop(struct lp_exec_mask *mask) { + if (mask->loop_stack_size == 0) { + assert(mask->loop_block == NULL); + assert(mask->cont_mask == LLVMConstAllOnes(mask->int_vec_type)); + assert(mask->break_mask == LLVMConstAllOnes(mask->int_vec_type)); + assert(mask->break_var == NULL); + } - if (mask->cont_stack_size == 0) - mask->cont_mask = LLVMConstAllOnes(mask->int_vec_type); - if (mask->break_stack_size == 0) - mask->break_mask = LLVMConstAllOnes(mask->int_vec_type); - if (mask->cond_stack_size == 0) - mask->cond_mask = LLVMConstAllOnes(mask->int_vec_type); + assert(mask->loop_stack_size < LP_MAX_TGSI_NESTING); - assert(mask->break_stack_size < LP_MAX_TGSI_NESTING); - assert(mask->cont_stack_size < LP_MAX_TGSI_NESTING); - assert(mask->break_stack_size < LP_MAX_TGSI_NESTING); + mask->loop_stack[mask->loop_stack_size].loop_block = mask->loop_block; + mask->loop_stack[mask->loop_stack_size].cont_mask = mask->cont_mask; + mask->loop_stack[mask->loop_stack_size].break_mask = mask->break_mask; + mask->loop_stack[mask->loop_stack_size].break_var = mask->break_var; + ++mask->loop_stack_size; + + mask->break_var = lp_build_alloca(mask->bld->builder, mask->int_vec_type, ""); + LLVMBuildStore(mask->bld->builder, mask->break_mask, mask->break_var); - mask->break_stack[mask->break_stack_size++] = mask->break_mask; - mask->cont_stack[mask->cont_stack_size++] = mask->cont_mask; - mask->loop_stack[mask->loop_stack_size++] = mask->loop_block; mask->loop_block = lp_build_insert_new_block(mask->bld->builder, "bgnloop"); LLVMBuildBr(mask->bld->builder, mask->loop_block); LLVMPositionBuilderAtEnd(mask->bld->builder, mask->loop_block); + mask->break_mask = LLVMBuildLoad(mask->bld->builder, mask->break_var, ""); + lp_exec_mask_update(mask); } @@ -286,11 +319,24 @@ static void lp_exec_endloop(struct lp_exec_mask *mask) assert(mask->break_mask); + /* + * Restore the cont_mask, but don't pop + */ + assert(mask->loop_stack_size); + mask->cont_mask = mask->loop_stack[mask->loop_stack_size - 1].cont_mask; + lp_exec_mask_update(mask); + + /* + * Unlike the continue mask, the break_mask must be preserved across loop + * iterations + */ + LLVMBuildStore(mask->bld->builder, mask->break_mask, mask->break_var); + /* i1cond = (mask == 0) */ i1cond = LLVMBuildICmp( mask->bld->builder, LLVMIntNE, - LLVMBuildBitCast(mask->bld->builder, mask->break_mask, reg_type, ""), + LLVMBuildBitCast(mask->bld->builder, mask->exec_mask, reg_type, ""), LLVMConstNull(reg_type), ""); endloop = lp_build_insert_new_block(mask->bld->builder, "endloop"); @@ -300,15 +346,12 @@ static void lp_exec_endloop(struct lp_exec_mask *mask) LLVMPositionBuilderAtEnd(mask->bld->builder, endloop); - mask->loop_block = mask->loop_stack[--mask->loop_stack_size]; - /* pop the cont mask */ - if (mask->cont_stack_size) { - mask->cont_mask = mask->cont_stack[--mask->cont_stack_size]; - } - /* pop the break mask */ - if (mask->break_stack_size) { - mask->break_mask = mask->break_stack[--mask->break_stack_size]; - } + assert(mask->loop_stack_size); + --mask->loop_stack_size; + mask->loop_block = mask->loop_stack[mask->loop_stack_size].loop_block; + mask->cont_mask = mask->loop_stack[mask->loop_stack_size].cont_mask; + mask->break_mask = mask->loop_stack[mask->loop_stack_size].break_mask; + mask->break_var = mask->loop_stack[mask->loop_stack_size].break_var; lp_exec_mask_update(mask); } @@ -319,15 +362,25 @@ static void lp_exec_endloop(struct lp_exec_mask *mask) * (0 means don't store this bit, 1 means do store). */ static void lp_exec_mask_store(struct lp_exec_mask *mask, + LLVMValueRef pred, LLVMValueRef val, LLVMValueRef dst) { + /* Mix the predicate and execution mask */ if (mask->has_mask) { + if (pred) { + pred = LLVMBuildAnd(mask->bld->builder, pred, mask->exec_mask, ""); + } else { + pred = mask->exec_mask; + } + } + + if (pred) { LLVMValueRef real_val, dst_val; dst_val = LLVMBuildLoad(mask->bld->builder, dst, ""); real_val = lp_build_select(mask->bld, - mask->exec_mask, + pred, val, dst_val); LLVMBuildStore(mask->bld->builder, real_val, dst); @@ -335,6 +388,49 @@ static void lp_exec_mask_store(struct lp_exec_mask *mask, LLVMBuildStore(mask->bld->builder, val, dst); } +static void lp_exec_mask_call(struct lp_exec_mask *mask, + int func, + int *pc) +{ + assert(mask->call_stack_size < LP_MAX_TGSI_NESTING); + mask->call_stack[mask->call_stack_size].pc = *pc; + mask->call_stack[mask->call_stack_size].ret_mask = mask->ret_mask; + mask->call_stack_size++; + *pc = func; +} + +static void lp_exec_mask_ret(struct lp_exec_mask *mask, int *pc) +{ + LLVMValueRef exec_mask; + + if (mask->call_stack_size == 0) { + /* returning from main() */ + *pc = -1; + return; + } + exec_mask = LLVMBuildNot(mask->bld->builder, + mask->exec_mask, + "ret"); + + mask->ret_mask = LLVMBuildAnd(mask->bld->builder, + mask->ret_mask, + exec_mask, "ret_full"); + + lp_exec_mask_update(mask); +} + +static void lp_exec_mask_bgnsub(struct lp_exec_mask *mask) +{ +} + +static void lp_exec_mask_endsub(struct lp_exec_mask *mask, int *pc) +{ + assert(mask->call_stack_size); + mask->call_stack_size--; + *pc = mask->call_stack[mask->call_stack_size].pc; + mask->ret_mask = mask->call_stack[mask->call_stack_size].ret_mask; + lp_exec_mask_update(mask); +} static LLVMValueRef emit_ddx(struct lp_build_tgsi_soa_context *bld, @@ -358,15 +454,16 @@ emit_ddy(struct lp_build_tgsi_soa_context *bld, static LLVMValueRef get_temp_ptr(struct lp_build_tgsi_soa_context *bld, unsigned index, - unsigned swizzle, + unsigned chan, boolean is_indirect, LLVMValueRef addr) { + assert(chan < 4); if (!bld->has_indirect_addressing) { - return bld->temps[index][swizzle]; + return bld->temps[index][chan]; } else { LLVMValueRef lindex = - LLVMConstInt(LLVMInt32Type(), index*4 + swizzle, 0); + LLVMConstInt(LLVMInt32Type(), index * 4 + chan, 0); if (is_indirect) lindex = lp_build_add(&bld->base, lindex, addr); return LLVMBuildGEP(bld->base.builder, bld->temps_array, &lindex, 1, ""); @@ -384,34 +481,36 @@ emit_fetch( const unsigned chan_index ) { const struct tgsi_full_src_register *reg = &inst->Src[index]; - unsigned swizzle = tgsi_util_get_full_src_register_swizzle( reg, chan_index ); + const unsigned swizzle = + tgsi_util_get_full_src_register_swizzle(reg, chan_index); LLVMValueRef res; - LLVMValueRef addr; - - switch (swizzle) { - case TGSI_SWIZZLE_X: - case TGSI_SWIZZLE_Y: - case TGSI_SWIZZLE_Z: - case TGSI_SWIZZLE_W: - - if (reg->Register.Indirect) { - LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->base.type); - unsigned swizzle = tgsi_util_get_src_register_swizzle( ®->Indirect, chan_index ); - addr = LLVMBuildLoad(bld->base.builder, - bld->addr[reg->Indirect.Index][swizzle], - ""); - /* for indexing we want integers */ - addr = LLVMBuildFPToSI(bld->base.builder, addr, - int_vec_type, ""); - addr = LLVMBuildExtractElement(bld->base.builder, - addr, LLVMConstInt(LLVMInt32Type(), 0, 0), - ""); - addr = lp_build_mul(&bld->base, addr, LLVMConstInt(LLVMInt32Type(), 4, 0)); - } - - switch (reg->Register.File) { - case TGSI_FILE_CONSTANT: { - LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), reg->Register.Index*4 + swizzle, 0); + LLVMValueRef addr = NULL; + + if (swizzle > 3) { + assert(0 && "invalid swizzle in emit_fetch()"); + return bld->base.undef; + } + + if (reg->Register.Indirect) { + LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->base.type); + unsigned swizzle = tgsi_util_get_src_register_swizzle( ®->Indirect, chan_index ); + addr = LLVMBuildLoad(bld->base.builder, + bld->addr[reg->Indirect.Index][swizzle], + ""); + /* for indexing we want integers */ + addr = LLVMBuildFPToSI(bld->base.builder, addr, + int_vec_type, ""); + addr = LLVMBuildExtractElement(bld->base.builder, + addr, LLVMConstInt(LLVMInt32Type(), 0, 0), + ""); + addr = lp_build_mul(&bld->base, addr, LLVMConstInt(LLVMInt32Type(), 4, 0)); + } + + switch (reg->Register.File) { + case TGSI_FILE_CONSTANT: + { + LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), + reg->Register.Index*4 + swizzle, 0); LLVMValueRef scalar, scalar_ptr; if (reg->Register.Indirect) { @@ -419,24 +518,26 @@ emit_fetch( "\taddr = %d\n", addr);*/ index = lp_build_add(&bld->base, index, addr); } - scalar_ptr = LLVMBuildGEP(bld->base.builder, bld->consts_ptr, &index, 1, ""); + scalar_ptr = LLVMBuildGEP(bld->base.builder, bld->consts_ptr, + &index, 1, ""); scalar = LLVMBuildLoad(bld->base.builder, scalar_ptr, ""); res = lp_build_broadcast_scalar(&bld->base, scalar); - break; } + break; - case TGSI_FILE_IMMEDIATE: - res = bld->immediates[reg->Register.Index][swizzle]; - assert(res); - break; + case TGSI_FILE_IMMEDIATE: + res = bld->immediates[reg->Register.Index][swizzle]; + assert(res); + break; - case TGSI_FILE_INPUT: - res = bld->inputs[reg->Register.Index][swizzle]; - assert(res); - break; + case TGSI_FILE_INPUT: + res = bld->inputs[reg->Register.Index][swizzle]; + assert(res); + break; - case TGSI_FILE_TEMPORARY: { + case TGSI_FILE_TEMPORARY: + { LLVMValueRef temp_ptr = get_temp_ptr(bld, reg->Register.Index, swizzle, reg->Register.Indirect, @@ -444,17 +545,11 @@ emit_fetch( res = LLVMBuildLoad(bld->base.builder, temp_ptr, ""); if(!res) return bld->base.undef; - break; - } - - default: - assert( 0 ); - return bld->base.undef; } break; default: - assert( 0 ); + assert(0 && "invalid src register in emit_fetch()"); return bld->base.undef; } @@ -512,6 +607,73 @@ emit_fetch_deriv( /** + * Predicate. + */ +static void +emit_fetch_predicate( + struct lp_build_tgsi_soa_context *bld, + const struct tgsi_full_instruction *inst, + LLVMValueRef *pred) +{ + unsigned index; + unsigned char swizzles[4]; + LLVMValueRef unswizzled[4] = {NULL, NULL, NULL, NULL}; + LLVMValueRef value; + unsigned chan; + + if (!inst->Instruction.Predicate) { + FOR_EACH_CHANNEL( chan ) { + pred[chan] = NULL; + } + return; + } + + swizzles[0] = inst->Predicate.SwizzleX; + swizzles[1] = inst->Predicate.SwizzleY; + swizzles[2] = inst->Predicate.SwizzleZ; + swizzles[3] = inst->Predicate.SwizzleW; + + index = inst->Predicate.Index; + assert(index < LP_MAX_TGSI_PREDS); + + FOR_EACH_CHANNEL( chan ) { + unsigned swizzle = swizzles[chan]; + + /* + * Only fetch the predicate register channels that are actually listed + * in the swizzles + */ + if (!unswizzled[swizzle]) { + value = LLVMBuildLoad(bld->base.builder, + bld->preds[index][swizzle], ""); + + /* + * Convert the value to an integer mask. + * + * TODO: Short-circuit this comparison -- a D3D setp_xx instructions + * is needlessly causing two comparisons due to storing the intermediate + * result as float vector instead of an integer mask vector. + */ + value = lp_build_compare(bld->base.builder, + bld->base.type, + PIPE_FUNC_NOTEQUAL, + value, + bld->base.zero); + if (inst->Predicate.Negate) { + value = LLVMBuildNot(bld->base.builder, value, ""); + } + + unswizzled[swizzle] = value; + } else { + value = unswizzled[swizzle]; + } + + pred[chan] = value; + } +} + + +/** * Register store. */ static void @@ -520,10 +682,11 @@ emit_store( const struct tgsi_full_instruction *inst, unsigned index, unsigned chan_index, + LLVMValueRef pred, LLVMValueRef value) { const struct tgsi_full_dst_register *reg = &inst->Dst[index]; - LLVMValueRef addr; + LLVMValueRef addr = NULL; switch( inst->Instruction.Saturate ) { case TGSI_SAT_NONE: @@ -560,7 +723,7 @@ emit_store( switch( reg->Register.File ) { case TGSI_FILE_OUTPUT: - lp_exec_mask_store(&bld->exec_mask, value, + lp_exec_mask_store(&bld->exec_mask, pred, value, bld->outputs[reg->Register.Index][chan_index]); break; @@ -569,17 +732,18 @@ emit_store( chan_index, reg->Register.Indirect, addr); - lp_exec_mask_store(&bld->exec_mask, value, temp_ptr); + lp_exec_mask_store(&bld->exec_mask, pred, value, temp_ptr); break; } case TGSI_FILE_ADDRESS: - lp_exec_mask_store(&bld->exec_mask, value, + lp_exec_mask_store(&bld->exec_mask, pred, value, bld->addr[reg->Indirect.Index][chan_index]); break; case TGSI_FILE_PREDICATE: - /* FIXME */ + lp_exec_mask_store(&bld->exec_mask, pred, value, + bld->preds[index][chan_index]); break; default: @@ -789,10 +953,10 @@ emit_declaration( case TGSI_FILE_TEMPORARY: assert(idx < LP_MAX_TGSI_TEMPS); if (bld->has_indirect_addressing) { - LLVMValueRef val = LLVMConstInt(LLVMInt32Type(), - last*4 + 4, 0); + LLVMValueRef array_size = LLVMConstInt(LLVMInt32Type(), + last*4 + 4, 0); bld->temps_array = lp_build_array_alloca(bld->base.builder, - vec_type, val, ""); + vec_type, array_size, ""); } else { for (i = 0; i < NUM_CHANNELS; i++) bld->temps[idx][i] = lp_build_alloca(bld->base.builder, @@ -814,7 +978,10 @@ emit_declaration( break; case TGSI_FILE_PREDICATE: - _debug_printf("warning: predicate registers not yet implemented\n"); + assert(idx < LP_MAX_TGSI_PREDS); + for (i = 0; i < NUM_CHANNELS; i++) + bld->preds[idx][i] = lp_build_alloca(bld->base.builder, + vec_type, ""); break; default: @@ -833,7 +1000,8 @@ static boolean emit_instruction( struct lp_build_tgsi_soa_context *bld, const struct tgsi_full_instruction *inst, - const struct tgsi_opcode_info *info) + const struct tgsi_opcode_info *info, + int *pc) { unsigned chan_index; LLVMValueRef src0, src1, src2; @@ -857,8 +1025,10 @@ emit_instruction( * redundant code. */ + (*pc)++; + assert(info->num_dst <= 1); - if(info->num_dst) { + if (info->num_dst) { FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) { dst0[chan_index] = bld->base.undef; } @@ -1455,16 +1625,18 @@ emit_instruction( break; case TGSI_OPCODE_CAL: - /* FIXME */ - return FALSE; + lp_exec_mask_call(&bld->exec_mask, + inst->Label.Label, + pc); + break; case TGSI_OPCODE_RET: - /* FIXME */ - return FALSE; + lp_exec_mask_ret(&bld->exec_mask, pc); break; case TGSI_OPCODE_END: + *pc = -1; break; case TGSI_OPCODE_SSG: @@ -1630,6 +1802,10 @@ emit_instruction( lp_exec_bgnloop(&bld->exec_mask); break; + case TGSI_OPCODE_BGNSUB: + lp_exec_mask_bgnsub(&bld->exec_mask); + break; + case TGSI_OPCODE_ELSE: lp_exec_mask_cond_invert(&bld->exec_mask); break; @@ -1642,6 +1818,10 @@ emit_instruction( lp_exec_endloop(&bld->exec_mask); break; + case TGSI_OPCODE_ENDSUB: + lp_exec_mask_endsub(&bld->exec_mask, pc); + break; + case TGSI_OPCODE_PUSHA: /* deprecated? */ assert(0); @@ -1754,8 +1934,12 @@ emit_instruction( } if(info->num_dst) { + LLVMValueRef pred[NUM_CHANNELS]; + + emit_fetch_predicate( bld, inst, pred ); + FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) { - emit_store( bld, inst, 0, chan_index, dst0[chan_index]); + emit_store( bld, inst, 0, chan_index, pred[chan_index], dst0[chan_index]); } } @@ -1773,16 +1957,19 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, const LLVMValueRef (*inputs)[NUM_CHANNELS], LLVMValueRef (*outputs)[NUM_CHANNELS], struct lp_build_sampler_soa *sampler, - struct tgsi_shader_info *info) + const struct tgsi_shader_info *info) { struct lp_build_tgsi_soa_context bld; struct tgsi_parse_context parse; uint num_immediates = 0; + uint num_instructions = 0; unsigned i; + int pc = 0; /* Setup build context */ memset(&bld, 0, sizeof bld); lp_build_context_init(&bld.base, builder, type); + lp_build_context_init(&bld.int_bld, builder, lp_int_type(type)); bld.mask = mask; bld.pos = pos; bld.inputs = inputs; @@ -1791,6 +1978,13 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, bld.sampler = sampler; bld.has_indirect_addressing = info->opcode_count[TGSI_OPCODE_ARR] > 0 || info->opcode_count[TGSI_OPCODE_ARL] > 0; + bld.instructions = (struct tgsi_full_instruction *) + MALLOC( LP_MAX_INSTRUCTIONS * sizeof(struct tgsi_full_instruction) ); + bld.max_instructions = LP_MAX_INSTRUCTIONS; + + if (!bld.instructions) { + return; + } lp_exec_mask_init(&bld.exec_mask, &bld.base); @@ -1807,11 +2001,21 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, case TGSI_TOKEN_TYPE_INSTRUCTION: { - unsigned opcode = parse.FullToken.FullInstruction.Instruction.Opcode; - const struct tgsi_opcode_info *opcode_info = tgsi_get_opcode_info(opcode); - if (!emit_instruction( &bld, &parse.FullToken.FullInstruction, opcode_info )) - _debug_printf("warning: failed to translate tgsi opcode %s to LLVM\n", - opcode_info->mnemonic); + /* save expanded instruction */ + if (num_instructions == bld.max_instructions) { + bld.instructions = REALLOC(bld.instructions, + bld.max_instructions + * sizeof(struct tgsi_full_instruction), + (bld.max_instructions + LP_MAX_INSTRUCTIONS) + * sizeof(struct tgsi_full_instruction)); + bld.max_instructions += LP_MAX_INSTRUCTIONS; + } + + memcpy(bld.instructions + num_instructions, + &parse.FullToken.FullInstruction, + sizeof(bld.instructions[0])); + + num_instructions++; } break; @@ -1838,14 +2042,33 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, assert( 0 ); } } + + while (pc != -1) { + struct tgsi_full_instruction *instr = bld.instructions + pc; + const struct tgsi_opcode_info *opcode_info = + tgsi_get_opcode_info(instr->Instruction.Opcode); + if (!emit_instruction( &bld, instr, opcode_info, &pc )) + _debug_printf("warning: failed to translate tgsi opcode %s to LLVM\n", + opcode_info->mnemonic); + } + if (0) { LLVMBasicBlockRef block = LLVMGetInsertBlock(builder); LLVMValueRef function = LLVMGetBasicBlockParent(block); debug_printf("11111111111111111111111111111 \n"); tgsi_dump(tokens, 0); - LLVMDumpValue(function); + lp_debug_dump_value(function); debug_printf("2222222222222222222222222222 \n"); } tgsi_parse_free( &parse ); + + if (0) { + LLVMModuleRef module = LLVMGetGlobalParent( + LLVMGetBasicBlockParent(LLVMGetInsertBlock(bld.base.builder))); + LLVMDumpModule(module); + + } + + FREE( bld.instructions ); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.c b/src/gallium/auxiliary/gallivm/lp_bld_type.c index 796af88caad..aac3a57bc73 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.c @@ -195,6 +195,7 @@ lp_uint_type(struct lp_type type) { struct lp_type res_type; + assert(type.length <= LP_MAX_VECTOR_LENGTH); memset(&res_type, 0, sizeof res_type); res_type.width = type.width; res_type.length = type.length; @@ -211,6 +212,7 @@ lp_int_type(struct lp_type type) { struct lp_type res_type; + assert(type.length <= LP_MAX_VECTOR_LENGTH); memset(&res_type, 0, sizeof res_type); res_type.width = type.width; res_type.length = type.length; @@ -238,6 +240,131 @@ lp_wider_type(struct lp_type type) } +/** + * Return the size of the LLVMType in bits. + * XXX this function doesn't necessarily handle all LLVM types. + */ +unsigned +lp_sizeof_llvm_type(LLVMTypeRef t) +{ + LLVMTypeKind k = LLVMGetTypeKind(t); + + switch (k) { + case LLVMIntegerTypeKind: + return LLVMGetIntTypeWidth(t); + case LLVMFloatTypeKind: + return 8 * sizeof(float); + case LLVMDoubleTypeKind: + return 8 * sizeof(double); + case LLVMVectorTypeKind: + { + LLVMTypeRef elem = LLVMGetElementType(t); + unsigned len = LLVMGetVectorSize(t); + return len * lp_sizeof_llvm_type(elem); + } + break; + case LLVMArrayTypeKind: + { + LLVMTypeRef elem = LLVMGetElementType(t); + unsigned len = LLVMGetArrayLength(t); + return len * lp_sizeof_llvm_type(elem); + } + break; + default: + assert(0 && "Unexpected type in lp_get_llvm_type_size()"); + return 0; + } +} + + +/** + * Return string name for a LLVMTypeKind. Useful for debugging. + */ +const char * +lp_typekind_name(LLVMTypeKind t) +{ + switch (t) { + case LLVMVoidTypeKind: + return "LLVMVoidTypeKind"; + case LLVMFloatTypeKind: + return "LLVMFloatTypeKind"; + case LLVMDoubleTypeKind: + return "LLVMDoubleTypeKind"; + case LLVMX86_FP80TypeKind: + return "LLVMX86_FP80TypeKind"; + case LLVMFP128TypeKind: + return "LLVMFP128TypeKind"; + case LLVMPPC_FP128TypeKind: + return "LLVMPPC_FP128TypeKind"; + case LLVMLabelTypeKind: + return "LLVMLabelTypeKind"; + case LLVMIntegerTypeKind: + return "LLVMIntegerTypeKind"; + case LLVMFunctionTypeKind: + return "LLVMFunctionTypeKind"; + case LLVMStructTypeKind: + return "LLVMStructTypeKind"; + case LLVMArrayTypeKind: + return "LLVMArrayTypeKind"; + case LLVMPointerTypeKind: + return "LLVMPointerTypeKind"; + case LLVMOpaqueTypeKind: + return "LLVMOpaqueTypeKind"; + case LLVMVectorTypeKind: + return "LLVMVectorTypeKind"; + case LLVMMetadataTypeKind: + return "LLVMMetadataTypeKind"; + /* Only in LLVM 2.7 and later??? + case LLVMUnionTypeKind: + return "LLVMUnionTypeKind"; + */ + default: + return "unknown LLVMTypeKind"; + } +} + + +/** + * Print an LLVMTypeRef. Like LLVMDumpValue(). For debugging. + */ +void +lp_dump_llvmtype(LLVMTypeRef t) +{ + LLVMTypeKind k = LLVMGetTypeKind(t); + + if (k == LLVMVectorTypeKind) { + LLVMTypeRef te = LLVMGetElementType(t); + LLVMTypeKind ke = LLVMGetTypeKind(te); + unsigned len = LLVMGetVectorSize(t); + if (ke == LLVMIntegerTypeKind) { + unsigned b = LLVMGetIntTypeWidth(te); + debug_printf("Vector [%u] of %u-bit Integer\n", len, b); + } + else { + debug_printf("Vector [%u] of %s\n", len, lp_typekind_name(ke)); + } + } + else if (k == LLVMArrayTypeKind) { + LLVMTypeRef te = LLVMGetElementType(t); + LLVMTypeKind ke = LLVMGetTypeKind(te); + unsigned len = LLVMGetArrayLength(t); + debug_printf("Array [%u] of %s\n", len, lp_typekind_name(ke)); + } + else if (k == LLVMIntegerTypeKind) { + unsigned b = LLVMGetIntTypeWidth(t); + debug_printf("%u-bit Integer\n", b); + } + else if (k == LLVMPointerTypeKind) { + LLVMTypeRef te = LLVMGetElementType(t); + debug_printf("Pointer to "); + lp_dump_llvmtype(te); + } + else { + debug_printf("%s\n", lp_typekind_name(k)); + } +} + + void lp_build_context_init(struct lp_build_context *bld, LLVMBuilderRef builder, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h index cd59d2faa66..17819d4d32a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h @@ -316,6 +316,18 @@ struct lp_type lp_wider_type(struct lp_type type); +unsigned +lp_sizeof_llvm_type(LLVMTypeRef t); + + +const char * +lp_typekind_name(LLVMTypeKind t); + + +void +lp_dump_llvmtype(LLVMTypeRef t); + + void lp_build_context_init(struct lp_build_context *bld, LLVMBuilderRef builder, diff --git a/src/gallium/auxiliary/indices/.gitignore b/src/gallium/auxiliary/indices/.gitignore new file mode 100644 index 00000000000..73740071451 --- /dev/null +++ b/src/gallium/auxiliary/indices/.gitignore @@ -0,0 +1,2 @@ +u_indices_gen.c +u_unfilled_gen.c diff --git a/src/gallium/auxiliary/indices/u_indices_gen.c b/src/gallium/auxiliary/indices/u_indices_gen.c deleted file mode 100644 index 3c981e5d7f4..00000000000 --- a/src/gallium/auxiliary/indices/u_indices_gen.c +++ /dev/null @@ -1,5129 +0,0 @@ -/* File automatically generated by indices.py */ - -/* - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * 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 - * VMWARE 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 - * Functions to translate and generate index lists - */ - -#include "indices/u_indices.h" -#include "indices/u_indices_priv.h" -#include "pipe/p_compiler.h" -#include "util/u_debug.h" -#include "pipe/p_defines.h" -#include "util/u_memory.h" - - -static unsigned out_size_idx( unsigned index_size ) -{ - switch (index_size) { - case 4: return OUT_UINT; - case 2: return OUT_USHORT; - default: assert(0); return OUT_USHORT; - } -} - -static unsigned in_size_idx( unsigned index_size ) -{ - switch (index_size) { - case 4: return IN_UINT; - case 2: return IN_USHORT; - case 1: return IN_UBYTE; - default: assert(0); return IN_UBYTE; - } -} - - -static u_translate_func translate[IN_COUNT][OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT]; -static u_generate_func generate[OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT]; - - - -static void generate_points_ushort_first2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)(i); - } -} -static void generate_lines_ushort_first2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)(i); - (out+i)[1] = (ushort)(i+1); - } -} -static void generate_linestrip_ushort_first2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)(i); - (out+j)[1] = (ushort)(i+1); - } -} -static void generate_lineloop_ushort_first2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)(i); - (out+j)[1] = (ushort)(i+1); - } - (out+j)[0] = (ushort)(i); - (out+j)[1] = (ushort)(0); -} -static void generate_tris_ushort_first2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)(i); - (out+i)[1] = (ushort)(i+1); - (out+i)[2] = (ushort)(i+2); - } -} -static void generate_tristrip_ushort_first2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)(i); - (out+j)[1] = (ushort)(i+1+(i&1)); - (out+j)[2] = (ushort)(i+2-(i&1)); - } -} -static void generate_trifan_ushort_first2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)(0); - (out+j)[1] = (ushort)(i+1); - (out+j)[2] = (ushort)(i+2); - } -} -static void generate_quads_ushort_first2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)(i+0); - (out+j+0)[1] = (ushort)(i+1); - (out+j+0)[2] = (ushort)(i+3); - (out+j+3)[0] = (ushort)(i+1); - (out+j+3)[1] = (ushort)(i+2); - (out+j+3)[2] = (ushort)(i+3); - } -} -static void generate_quadstrip_ushort_first2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)(i+2); - (out+j+0)[1] = (ushort)(i+0); - (out+j+0)[2] = (ushort)(i+3); - (out+j+3)[0] = (ushort)(i+0); - (out+j+3)[1] = (ushort)(i+1); - (out+j+3)[2] = (ushort)(i+3); - } -} -static void generate_polygon_ushort_first2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)(0); - (out+j)[1] = (ushort)(i+1); - (out+j)[2] = (ushort)(i+2); - } -} -static void generate_points_ushort_first2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)(i); - } -} -static void generate_lines_ushort_first2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)(i+1); - (out+i)[1] = (ushort)(i); - } -} -static void generate_linestrip_ushort_first2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)(i+1); - (out+j)[1] = (ushort)(i); - } -} -static void generate_lineloop_ushort_first2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)(i+1); - (out+j)[1] = (ushort)(i); - } - (out+j)[0] = (ushort)(0); - (out+j)[1] = (ushort)(i); -} -static void generate_tris_ushort_first2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)(i+1); - (out+i)[1] = (ushort)(i+2); - (out+i)[2] = (ushort)(i); - } -} -static void generate_tristrip_ushort_first2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)(i+1+(i&1)); - (out+j)[1] = (ushort)(i+2-(i&1)); - (out+j)[2] = (ushort)(i); - } -} -static void generate_trifan_ushort_first2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)(i+1); - (out+j)[1] = (ushort)(i+2); - (out+j)[2] = (ushort)(0); - } -} -static void generate_quads_ushort_first2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)(i+1); - (out+j+0)[1] = (ushort)(i+3); - (out+j+0)[2] = (ushort)(i+0); - (out+j+3)[0] = (ushort)(i+2); - (out+j+3)[1] = (ushort)(i+3); - (out+j+3)[2] = (ushort)(i+1); - } -} -static void generate_quadstrip_ushort_first2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)(i+0); - (out+j+0)[1] = (ushort)(i+3); - (out+j+0)[2] = (ushort)(i+2); - (out+j+3)[0] = (ushort)(i+1); - (out+j+3)[1] = (ushort)(i+3); - (out+j+3)[2] = (ushort)(i+0); - } -} -static void generate_polygon_ushort_first2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)(i+1); - (out+j)[1] = (ushort)(i+2); - (out+j)[2] = (ushort)(0); - } -} -static void generate_points_ushort_last2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)(i); - } -} -static void generate_lines_ushort_last2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)(i+1); - (out+i)[1] = (ushort)(i); - } -} -static void generate_linestrip_ushort_last2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)(i+1); - (out+j)[1] = (ushort)(i); - } -} -static void generate_lineloop_ushort_last2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)(i+1); - (out+j)[1] = (ushort)(i); - } - (out+j)[0] = (ushort)(0); - (out+j)[1] = (ushort)(i); -} -static void generate_tris_ushort_last2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)(i+2); - (out+i)[1] = (ushort)(i); - (out+i)[2] = (ushort)(i+1); - } -} -static void generate_tristrip_ushort_last2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)(i+2); - (out+j)[1] = (ushort)(i+(i&1)); - (out+j)[2] = (ushort)(i+1-(i&1)); - } -} -static void generate_trifan_ushort_last2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)(i+2); - (out+j)[1] = (ushort)(0); - (out+j)[2] = (ushort)(i+1); - } -} -static void generate_quads_ushort_last2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)(i+3); - (out+j+0)[1] = (ushort)(i+0); - (out+j+0)[2] = (ushort)(i+1); - (out+j+3)[0] = (ushort)(i+3); - (out+j+3)[1] = (ushort)(i+1); - (out+j+3)[2] = (ushort)(i+2); - } -} -static void generate_quadstrip_ushort_last2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)(i+3); - (out+j+0)[1] = (ushort)(i+2); - (out+j+0)[2] = (ushort)(i+0); - (out+j+3)[0] = (ushort)(i+3); - (out+j+3)[1] = (ushort)(i+0); - (out+j+3)[2] = (ushort)(i+1); - } -} -static void generate_polygon_ushort_last2first( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)(0); - (out+j)[1] = (ushort)(i+1); - (out+j)[2] = (ushort)(i+2); - } -} -static void generate_points_ushort_last2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)(i); - } -} -static void generate_lines_ushort_last2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)(i); - (out+i)[1] = (ushort)(i+1); - } -} -static void generate_linestrip_ushort_last2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)(i); - (out+j)[1] = (ushort)(i+1); - } -} -static void generate_lineloop_ushort_last2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)(i); - (out+j)[1] = (ushort)(i+1); - } - (out+j)[0] = (ushort)(i); - (out+j)[1] = (ushort)(0); -} -static void generate_tris_ushort_last2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)(i); - (out+i)[1] = (ushort)(i+1); - (out+i)[2] = (ushort)(i+2); - } -} -static void generate_tristrip_ushort_last2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)(i+(i&1)); - (out+j)[1] = (ushort)(i+1-(i&1)); - (out+j)[2] = (ushort)(i+2); - } -} -static void generate_trifan_ushort_last2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)(0); - (out+j)[1] = (ushort)(i+1); - (out+j)[2] = (ushort)(i+2); - } -} -static void generate_quads_ushort_last2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)(i+0); - (out+j+0)[1] = (ushort)(i+1); - (out+j+0)[2] = (ushort)(i+3); - (out+j+3)[0] = (ushort)(i+1); - (out+j+3)[1] = (ushort)(i+2); - (out+j+3)[2] = (ushort)(i+3); - } -} -static void generate_quadstrip_ushort_last2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)(i+2); - (out+j+0)[1] = (ushort)(i+0); - (out+j+0)[2] = (ushort)(i+3); - (out+j+3)[0] = (ushort)(i+0); - (out+j+3)[1] = (ushort)(i+1); - (out+j+3)[2] = (ushort)(i+3); - } -} -static void generate_polygon_ushort_last2last( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)(i+1); - (out+j)[1] = (ushort)(i+2); - (out+j)[2] = (ushort)(0); - } -} -static void generate_points_uint_first2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)(i); - } -} -static void generate_lines_uint_first2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)(i); - (out+i)[1] = (uint)(i+1); - } -} -static void generate_linestrip_uint_first2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)(i); - (out+j)[1] = (uint)(i+1); - } -} -static void generate_lineloop_uint_first2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)(i); - (out+j)[1] = (uint)(i+1); - } - (out+j)[0] = (uint)(i); - (out+j)[1] = (uint)(0); -} -static void generate_tris_uint_first2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)(i); - (out+i)[1] = (uint)(i+1); - (out+i)[2] = (uint)(i+2); - } -} -static void generate_tristrip_uint_first2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)(i); - (out+j)[1] = (uint)(i+1+(i&1)); - (out+j)[2] = (uint)(i+2-(i&1)); - } -} -static void generate_trifan_uint_first2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)(0); - (out+j)[1] = (uint)(i+1); - (out+j)[2] = (uint)(i+2); - } -} -static void generate_quads_uint_first2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)(i+0); - (out+j+0)[1] = (uint)(i+1); - (out+j+0)[2] = (uint)(i+3); - (out+j+3)[0] = (uint)(i+1); - (out+j+3)[1] = (uint)(i+2); - (out+j+3)[2] = (uint)(i+3); - } -} -static void generate_quadstrip_uint_first2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)(i+2); - (out+j+0)[1] = (uint)(i+0); - (out+j+0)[2] = (uint)(i+3); - (out+j+3)[0] = (uint)(i+0); - (out+j+3)[1] = (uint)(i+1); - (out+j+3)[2] = (uint)(i+3); - } -} -static void generate_polygon_uint_first2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)(0); - (out+j)[1] = (uint)(i+1); - (out+j)[2] = (uint)(i+2); - } -} -static void generate_points_uint_first2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)(i); - } -} -static void generate_lines_uint_first2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)(i+1); - (out+i)[1] = (uint)(i); - } -} -static void generate_linestrip_uint_first2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)(i+1); - (out+j)[1] = (uint)(i); - } -} -static void generate_lineloop_uint_first2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)(i+1); - (out+j)[1] = (uint)(i); - } - (out+j)[0] = (uint)(0); - (out+j)[1] = (uint)(i); -} -static void generate_tris_uint_first2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)(i+1); - (out+i)[1] = (uint)(i+2); - (out+i)[2] = (uint)(i); - } -} -static void generate_tristrip_uint_first2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)(i+1+(i&1)); - (out+j)[1] = (uint)(i+2-(i&1)); - (out+j)[2] = (uint)(i); - } -} -static void generate_trifan_uint_first2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)(i+1); - (out+j)[1] = (uint)(i+2); - (out+j)[2] = (uint)(0); - } -} -static void generate_quads_uint_first2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)(i+1); - (out+j+0)[1] = (uint)(i+3); - (out+j+0)[2] = (uint)(i+0); - (out+j+3)[0] = (uint)(i+2); - (out+j+3)[1] = (uint)(i+3); - (out+j+3)[2] = (uint)(i+1); - } -} -static void generate_quadstrip_uint_first2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)(i+0); - (out+j+0)[1] = (uint)(i+3); - (out+j+0)[2] = (uint)(i+2); - (out+j+3)[0] = (uint)(i+1); - (out+j+3)[1] = (uint)(i+3); - (out+j+3)[2] = (uint)(i+0); - } -} -static void generate_polygon_uint_first2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)(i+1); - (out+j)[1] = (uint)(i+2); - (out+j)[2] = (uint)(0); - } -} -static void generate_points_uint_last2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)(i); - } -} -static void generate_lines_uint_last2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)(i+1); - (out+i)[1] = (uint)(i); - } -} -static void generate_linestrip_uint_last2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)(i+1); - (out+j)[1] = (uint)(i); - } -} -static void generate_lineloop_uint_last2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)(i+1); - (out+j)[1] = (uint)(i); - } - (out+j)[0] = (uint)(0); - (out+j)[1] = (uint)(i); -} -static void generate_tris_uint_last2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)(i+2); - (out+i)[1] = (uint)(i); - (out+i)[2] = (uint)(i+1); - } -} -static void generate_tristrip_uint_last2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)(i+2); - (out+j)[1] = (uint)(i+(i&1)); - (out+j)[2] = (uint)(i+1-(i&1)); - } -} -static void generate_trifan_uint_last2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)(i+2); - (out+j)[1] = (uint)(0); - (out+j)[2] = (uint)(i+1); - } -} -static void generate_quads_uint_last2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)(i+3); - (out+j+0)[1] = (uint)(i+0); - (out+j+0)[2] = (uint)(i+1); - (out+j+3)[0] = (uint)(i+3); - (out+j+3)[1] = (uint)(i+1); - (out+j+3)[2] = (uint)(i+2); - } -} -static void generate_quadstrip_uint_last2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)(i+3); - (out+j+0)[1] = (uint)(i+2); - (out+j+0)[2] = (uint)(i+0); - (out+j+3)[0] = (uint)(i+3); - (out+j+3)[1] = (uint)(i+0); - (out+j+3)[2] = (uint)(i+1); - } -} -static void generate_polygon_uint_last2first( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)(0); - (out+j)[1] = (uint)(i+1); - (out+j)[2] = (uint)(i+2); - } -} -static void generate_points_uint_last2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)(i); - } -} -static void generate_lines_uint_last2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)(i); - (out+i)[1] = (uint)(i+1); - } -} -static void generate_linestrip_uint_last2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)(i); - (out+j)[1] = (uint)(i+1); - } -} -static void generate_lineloop_uint_last2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)(i); - (out+j)[1] = (uint)(i+1); - } - (out+j)[0] = (uint)(i); - (out+j)[1] = (uint)(0); -} -static void generate_tris_uint_last2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)(i); - (out+i)[1] = (uint)(i+1); - (out+i)[2] = (uint)(i+2); - } -} -static void generate_tristrip_uint_last2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)(i+(i&1)); - (out+j)[1] = (uint)(i+1-(i&1)); - (out+j)[2] = (uint)(i+2); - } -} -static void generate_trifan_uint_last2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)(0); - (out+j)[1] = (uint)(i+1); - (out+j)[2] = (uint)(i+2); - } -} -static void generate_quads_uint_last2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)(i+0); - (out+j+0)[1] = (uint)(i+1); - (out+j+0)[2] = (uint)(i+3); - (out+j+3)[0] = (uint)(i+1); - (out+j+3)[1] = (uint)(i+2); - (out+j+3)[2] = (uint)(i+3); - } -} -static void generate_quadstrip_uint_last2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)(i+2); - (out+j+0)[1] = (uint)(i+0); - (out+j+0)[2] = (uint)(i+3); - (out+j+3)[0] = (uint)(i+0); - (out+j+3)[1] = (uint)(i+1); - (out+j+3)[2] = (uint)(i+3); - } -} -static void generate_polygon_uint_last2last( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)(i+1); - (out+j)[1] = (uint)(i+2); - (out+j)[2] = (uint)(0); - } -} -static void translate_points_ubyte2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)in[i]; - } -} -static void translate_lines_ubyte2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)in[i]; - (out+i)[1] = (ushort)in[i+1]; - } -} -static void translate_linestrip_ubyte2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - } -} -static void translate_lineloop_ubyte2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - } - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[0]; -} -static void translate_tris_ubyte2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)in[i]; - (out+i)[1] = (ushort)in[i+1]; - (out+i)[2] = (ushort)in[i+2]; - } -} -static void translate_tristrip_ubyte2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1+(i&1)]; - (out+j)[2] = (ushort)in[i+2-(i&1)]; - } -} -static void translate_trifan_ubyte2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_quads_ubyte2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)in[i+0]; - (out+j+0)[1] = (ushort)in[i+1]; - (out+j+0)[2] = (ushort)in[i+3]; - (out+j+3)[0] = (ushort)in[i+1]; - (out+j+3)[1] = (ushort)in[i+2]; - (out+j+3)[2] = (ushort)in[i+3]; - } -} -static void translate_quadstrip_ubyte2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)in[i+2]; - (out+j+0)[1] = (ushort)in[i+0]; - (out+j+0)[2] = (ushort)in[i+3]; - (out+j+3)[0] = (ushort)in[i+0]; - (out+j+3)[1] = (ushort)in[i+1]; - (out+j+3)[2] = (ushort)in[i+3]; - } -} -static void translate_polygon_ubyte2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_points_ubyte2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)in[i]; - } -} -static void translate_lines_ubyte2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)in[i+1]; - (out+i)[1] = (ushort)in[i]; - } -} -static void translate_linestrip_ubyte2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i]; - } -} -static void translate_lineloop_ubyte2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i]; - } - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i]; -} -static void translate_tris_ubyte2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)in[i+1]; - (out+i)[1] = (ushort)in[i+2]; - (out+i)[2] = (ushort)in[i]; - } -} -static void translate_tristrip_ubyte2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+1+(i&1)]; - (out+j)[1] = (ushort)in[i+2-(i&1)]; - (out+j)[2] = (ushort)in[i]; - } -} -static void translate_trifan_ubyte2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i+2]; - (out+j)[2] = (ushort)in[0]; - } -} -static void translate_quads_ubyte2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)in[i+1]; - (out+j+0)[1] = (ushort)in[i+3]; - (out+j+0)[2] = (ushort)in[i+0]; - (out+j+3)[0] = (ushort)in[i+2]; - (out+j+3)[1] = (ushort)in[i+3]; - (out+j+3)[2] = (ushort)in[i+1]; - } -} -static void translate_quadstrip_ubyte2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)in[i+0]; - (out+j+0)[1] = (ushort)in[i+3]; - (out+j+0)[2] = (ushort)in[i+2]; - (out+j+3)[0] = (ushort)in[i+1]; - (out+j+3)[1] = (ushort)in[i+3]; - (out+j+3)[2] = (ushort)in[i+0]; - } -} -static void translate_polygon_ubyte2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i+2]; - (out+j)[2] = (ushort)in[0]; - } -} -static void translate_points_ubyte2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)in[i]; - } -} -static void translate_lines_ubyte2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)in[i+1]; - (out+i)[1] = (ushort)in[i]; - } -} -static void translate_linestrip_ubyte2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i]; - } -} -static void translate_lineloop_ubyte2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i]; - } - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i]; -} -static void translate_tris_ubyte2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)in[i+2]; - (out+i)[1] = (ushort)in[i]; - (out+i)[2] = (ushort)in[i+1]; - } -} -static void translate_tristrip_ubyte2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+2]; - (out+j)[1] = (ushort)in[i+(i&1)]; - (out+j)[2] = (ushort)in[i+1-(i&1)]; - } -} -static void translate_trifan_ubyte2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+2]; - (out+j)[1] = (ushort)in[0]; - (out+j)[2] = (ushort)in[i+1]; - } -} -static void translate_quads_ubyte2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)in[i+3]; - (out+j+0)[1] = (ushort)in[i+0]; - (out+j+0)[2] = (ushort)in[i+1]; - (out+j+3)[0] = (ushort)in[i+3]; - (out+j+3)[1] = (ushort)in[i+1]; - (out+j+3)[2] = (ushort)in[i+2]; - } -} -static void translate_quadstrip_ubyte2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)in[i+3]; - (out+j+0)[1] = (ushort)in[i+2]; - (out+j+0)[2] = (ushort)in[i+0]; - (out+j+3)[0] = (ushort)in[i+3]; - (out+j+3)[1] = (ushort)in[i+0]; - (out+j+3)[2] = (ushort)in[i+1]; - } -} -static void translate_polygon_ubyte2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_points_ubyte2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)in[i]; - } -} -static void translate_lines_ubyte2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)in[i]; - (out+i)[1] = (ushort)in[i+1]; - } -} -static void translate_linestrip_ubyte2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - } -} -static void translate_lineloop_ubyte2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - } - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[0]; -} -static void translate_tris_ubyte2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)in[i]; - (out+i)[1] = (ushort)in[i+1]; - (out+i)[2] = (ushort)in[i+2]; - } -} -static void translate_tristrip_ubyte2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+(i&1)]; - (out+j)[1] = (ushort)in[i+1-(i&1)]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_trifan_ubyte2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_quads_ubyte2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)in[i+0]; - (out+j+0)[1] = (ushort)in[i+1]; - (out+j+0)[2] = (ushort)in[i+3]; - (out+j+3)[0] = (ushort)in[i+1]; - (out+j+3)[1] = (ushort)in[i+2]; - (out+j+3)[2] = (ushort)in[i+3]; - } -} -static void translate_quadstrip_ubyte2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)in[i+2]; - (out+j+0)[1] = (ushort)in[i+0]; - (out+j+0)[2] = (ushort)in[i+3]; - (out+j+3)[0] = (ushort)in[i+0]; - (out+j+3)[1] = (ushort)in[i+1]; - (out+j+3)[2] = (ushort)in[i+3]; - } -} -static void translate_polygon_ubyte2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i+2]; - (out+j)[2] = (ushort)in[0]; - } -} -static void translate_points_ubyte2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)in[i]; - } -} -static void translate_lines_ubyte2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)in[i]; - (out+i)[1] = (uint)in[i+1]; - } -} -static void translate_linestrip_ubyte2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - } -} -static void translate_lineloop_ubyte2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - } - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[0]; -} -static void translate_tris_ubyte2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)in[i]; - (out+i)[1] = (uint)in[i+1]; - (out+i)[2] = (uint)in[i+2]; - } -} -static void translate_tristrip_ubyte2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1+(i&1)]; - (out+j)[2] = (uint)in[i+2-(i&1)]; - } -} -static void translate_trifan_ubyte2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_quads_ubyte2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)in[i+0]; - (out+j+0)[1] = (uint)in[i+1]; - (out+j+0)[2] = (uint)in[i+3]; - (out+j+3)[0] = (uint)in[i+1]; - (out+j+3)[1] = (uint)in[i+2]; - (out+j+3)[2] = (uint)in[i+3]; - } -} -static void translate_quadstrip_ubyte2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)in[i+2]; - (out+j+0)[1] = (uint)in[i+0]; - (out+j+0)[2] = (uint)in[i+3]; - (out+j+3)[0] = (uint)in[i+0]; - (out+j+3)[1] = (uint)in[i+1]; - (out+j+3)[2] = (uint)in[i+3]; - } -} -static void translate_polygon_ubyte2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_points_ubyte2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)in[i]; - } -} -static void translate_lines_ubyte2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)in[i+1]; - (out+i)[1] = (uint)in[i]; - } -} -static void translate_linestrip_ubyte2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i]; - } -} -static void translate_lineloop_ubyte2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i]; - } - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i]; -} -static void translate_tris_ubyte2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)in[i+1]; - (out+i)[1] = (uint)in[i+2]; - (out+i)[2] = (uint)in[i]; - } -} -static void translate_tristrip_ubyte2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+1+(i&1)]; - (out+j)[1] = (uint)in[i+2-(i&1)]; - (out+j)[2] = (uint)in[i]; - } -} -static void translate_trifan_ubyte2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i+2]; - (out+j)[2] = (uint)in[0]; - } -} -static void translate_quads_ubyte2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)in[i+1]; - (out+j+0)[1] = (uint)in[i+3]; - (out+j+0)[2] = (uint)in[i+0]; - (out+j+3)[0] = (uint)in[i+2]; - (out+j+3)[1] = (uint)in[i+3]; - (out+j+3)[2] = (uint)in[i+1]; - } -} -static void translate_quadstrip_ubyte2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)in[i+0]; - (out+j+0)[1] = (uint)in[i+3]; - (out+j+0)[2] = (uint)in[i+2]; - (out+j+3)[0] = (uint)in[i+1]; - (out+j+3)[1] = (uint)in[i+3]; - (out+j+3)[2] = (uint)in[i+0]; - } -} -static void translate_polygon_ubyte2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i+2]; - (out+j)[2] = (uint)in[0]; - } -} -static void translate_points_ubyte2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)in[i]; - } -} -static void translate_lines_ubyte2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)in[i+1]; - (out+i)[1] = (uint)in[i]; - } -} -static void translate_linestrip_ubyte2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i]; - } -} -static void translate_lineloop_ubyte2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i]; - } - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i]; -} -static void translate_tris_ubyte2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)in[i+2]; - (out+i)[1] = (uint)in[i]; - (out+i)[2] = (uint)in[i+1]; - } -} -static void translate_tristrip_ubyte2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+2]; - (out+j)[1] = (uint)in[i+(i&1)]; - (out+j)[2] = (uint)in[i+1-(i&1)]; - } -} -static void translate_trifan_ubyte2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+2]; - (out+j)[1] = (uint)in[0]; - (out+j)[2] = (uint)in[i+1]; - } -} -static void translate_quads_ubyte2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)in[i+3]; - (out+j+0)[1] = (uint)in[i+0]; - (out+j+0)[2] = (uint)in[i+1]; - (out+j+3)[0] = (uint)in[i+3]; - (out+j+3)[1] = (uint)in[i+1]; - (out+j+3)[2] = (uint)in[i+2]; - } -} -static void translate_quadstrip_ubyte2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)in[i+3]; - (out+j+0)[1] = (uint)in[i+2]; - (out+j+0)[2] = (uint)in[i+0]; - (out+j+3)[0] = (uint)in[i+3]; - (out+j+3)[1] = (uint)in[i+0]; - (out+j+3)[2] = (uint)in[i+1]; - } -} -static void translate_polygon_ubyte2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_points_ubyte2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)in[i]; - } -} -static void translate_lines_ubyte2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)in[i]; - (out+i)[1] = (uint)in[i+1]; - } -} -static void translate_linestrip_ubyte2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - } -} -static void translate_lineloop_ubyte2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - } - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[0]; -} -static void translate_tris_ubyte2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)in[i]; - (out+i)[1] = (uint)in[i+1]; - (out+i)[2] = (uint)in[i+2]; - } -} -static void translate_tristrip_ubyte2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+(i&1)]; - (out+j)[1] = (uint)in[i+1-(i&1)]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_trifan_ubyte2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_quads_ubyte2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)in[i+0]; - (out+j+0)[1] = (uint)in[i+1]; - (out+j+0)[2] = (uint)in[i+3]; - (out+j+3)[0] = (uint)in[i+1]; - (out+j+3)[1] = (uint)in[i+2]; - (out+j+3)[2] = (uint)in[i+3]; - } -} -static void translate_quadstrip_ubyte2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)in[i+2]; - (out+j+0)[1] = (uint)in[i+0]; - (out+j+0)[2] = (uint)in[i+3]; - (out+j+3)[0] = (uint)in[i+0]; - (out+j+3)[1] = (uint)in[i+1]; - (out+j+3)[2] = (uint)in[i+3]; - } -} -static void translate_polygon_ubyte2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i+2]; - (out+j)[2] = (uint)in[0]; - } -} -static void translate_points_ushort2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)in[i]; - } -} -static void translate_lines_ushort2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)in[i]; - (out+i)[1] = (ushort)in[i+1]; - } -} -static void translate_linestrip_ushort2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - } -} -static void translate_lineloop_ushort2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - } - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[0]; -} -static void translate_tris_ushort2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)in[i]; - (out+i)[1] = (ushort)in[i+1]; - (out+i)[2] = (ushort)in[i+2]; - } -} -static void translate_tristrip_ushort2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1+(i&1)]; - (out+j)[2] = (ushort)in[i+2-(i&1)]; - } -} -static void translate_trifan_ushort2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_quads_ushort2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)in[i+0]; - (out+j+0)[1] = (ushort)in[i+1]; - (out+j+0)[2] = (ushort)in[i+3]; - (out+j+3)[0] = (ushort)in[i+1]; - (out+j+3)[1] = (ushort)in[i+2]; - (out+j+3)[2] = (ushort)in[i+3]; - } -} -static void translate_quadstrip_ushort2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)in[i+2]; - (out+j+0)[1] = (ushort)in[i+0]; - (out+j+0)[2] = (ushort)in[i+3]; - (out+j+3)[0] = (ushort)in[i+0]; - (out+j+3)[1] = (ushort)in[i+1]; - (out+j+3)[2] = (ushort)in[i+3]; - } -} -static void translate_polygon_ushort2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_points_ushort2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)in[i]; - } -} -static void translate_lines_ushort2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)in[i+1]; - (out+i)[1] = (ushort)in[i]; - } -} -static void translate_linestrip_ushort2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i]; - } -} -static void translate_lineloop_ushort2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i]; - } - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i]; -} -static void translate_tris_ushort2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)in[i+1]; - (out+i)[1] = (ushort)in[i+2]; - (out+i)[2] = (ushort)in[i]; - } -} -static void translate_tristrip_ushort2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+1+(i&1)]; - (out+j)[1] = (ushort)in[i+2-(i&1)]; - (out+j)[2] = (ushort)in[i]; - } -} -static void translate_trifan_ushort2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i+2]; - (out+j)[2] = (ushort)in[0]; - } -} -static void translate_quads_ushort2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)in[i+1]; - (out+j+0)[1] = (ushort)in[i+3]; - (out+j+0)[2] = (ushort)in[i+0]; - (out+j+3)[0] = (ushort)in[i+2]; - (out+j+3)[1] = (ushort)in[i+3]; - (out+j+3)[2] = (ushort)in[i+1]; - } -} -static void translate_quadstrip_ushort2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)in[i+0]; - (out+j+0)[1] = (ushort)in[i+3]; - (out+j+0)[2] = (ushort)in[i+2]; - (out+j+3)[0] = (ushort)in[i+1]; - (out+j+3)[1] = (ushort)in[i+3]; - (out+j+3)[2] = (ushort)in[i+0]; - } -} -static void translate_polygon_ushort2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i+2]; - (out+j)[2] = (ushort)in[0]; - } -} -static void translate_points_ushort2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)in[i]; - } -} -static void translate_lines_ushort2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)in[i+1]; - (out+i)[1] = (ushort)in[i]; - } -} -static void translate_linestrip_ushort2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i]; - } -} -static void translate_lineloop_ushort2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i]; - } - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i]; -} -static void translate_tris_ushort2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)in[i+2]; - (out+i)[1] = (ushort)in[i]; - (out+i)[2] = (ushort)in[i+1]; - } -} -static void translate_tristrip_ushort2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+2]; - (out+j)[1] = (ushort)in[i+(i&1)]; - (out+j)[2] = (ushort)in[i+1-(i&1)]; - } -} -static void translate_trifan_ushort2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+2]; - (out+j)[1] = (ushort)in[0]; - (out+j)[2] = (ushort)in[i+1]; - } -} -static void translate_quads_ushort2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)in[i+3]; - (out+j+0)[1] = (ushort)in[i+0]; - (out+j+0)[2] = (ushort)in[i+1]; - (out+j+3)[0] = (ushort)in[i+3]; - (out+j+3)[1] = (ushort)in[i+1]; - (out+j+3)[2] = (ushort)in[i+2]; - } -} -static void translate_quadstrip_ushort2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)in[i+3]; - (out+j+0)[1] = (ushort)in[i+2]; - (out+j+0)[2] = (ushort)in[i+0]; - (out+j+3)[0] = (ushort)in[i+3]; - (out+j+3)[1] = (ushort)in[i+0]; - (out+j+3)[2] = (ushort)in[i+1]; - } -} -static void translate_polygon_ushort2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_points_ushort2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)in[i]; - } -} -static void translate_lines_ushort2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)in[i]; - (out+i)[1] = (ushort)in[i+1]; - } -} -static void translate_linestrip_ushort2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - } -} -static void translate_lineloop_ushort2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - } - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[0]; -} -static void translate_tris_ushort2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)in[i]; - (out+i)[1] = (ushort)in[i+1]; - (out+i)[2] = (ushort)in[i+2]; - } -} -static void translate_tristrip_ushort2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+(i&1)]; - (out+j)[1] = (ushort)in[i+1-(i&1)]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_trifan_ushort2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_quads_ushort2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)in[i+0]; - (out+j+0)[1] = (ushort)in[i+1]; - (out+j+0)[2] = (ushort)in[i+3]; - (out+j+3)[0] = (ushort)in[i+1]; - (out+j+3)[1] = (ushort)in[i+2]; - (out+j+3)[2] = (ushort)in[i+3]; - } -} -static void translate_quadstrip_ushort2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)in[i+2]; - (out+j+0)[1] = (ushort)in[i+0]; - (out+j+0)[2] = (ushort)in[i+3]; - (out+j+3)[0] = (ushort)in[i+0]; - (out+j+3)[1] = (ushort)in[i+1]; - (out+j+3)[2] = (ushort)in[i+3]; - } -} -static void translate_polygon_ushort2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i+2]; - (out+j)[2] = (ushort)in[0]; - } -} -static void translate_points_ushort2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)in[i]; - } -} -static void translate_lines_ushort2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)in[i]; - (out+i)[1] = (uint)in[i+1]; - } -} -static void translate_linestrip_ushort2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - } -} -static void translate_lineloop_ushort2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - } - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[0]; -} -static void translate_tris_ushort2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)in[i]; - (out+i)[1] = (uint)in[i+1]; - (out+i)[2] = (uint)in[i+2]; - } -} -static void translate_tristrip_ushort2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1+(i&1)]; - (out+j)[2] = (uint)in[i+2-(i&1)]; - } -} -static void translate_trifan_ushort2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_quads_ushort2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)in[i+0]; - (out+j+0)[1] = (uint)in[i+1]; - (out+j+0)[2] = (uint)in[i+3]; - (out+j+3)[0] = (uint)in[i+1]; - (out+j+3)[1] = (uint)in[i+2]; - (out+j+3)[2] = (uint)in[i+3]; - } -} -static void translate_quadstrip_ushort2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)in[i+2]; - (out+j+0)[1] = (uint)in[i+0]; - (out+j+0)[2] = (uint)in[i+3]; - (out+j+3)[0] = (uint)in[i+0]; - (out+j+3)[1] = (uint)in[i+1]; - (out+j+3)[2] = (uint)in[i+3]; - } -} -static void translate_polygon_ushort2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_points_ushort2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)in[i]; - } -} -static void translate_lines_ushort2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)in[i+1]; - (out+i)[1] = (uint)in[i]; - } -} -static void translate_linestrip_ushort2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i]; - } -} -static void translate_lineloop_ushort2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i]; - } - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i]; -} -static void translate_tris_ushort2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)in[i+1]; - (out+i)[1] = (uint)in[i+2]; - (out+i)[2] = (uint)in[i]; - } -} -static void translate_tristrip_ushort2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+1+(i&1)]; - (out+j)[1] = (uint)in[i+2-(i&1)]; - (out+j)[2] = (uint)in[i]; - } -} -static void translate_trifan_ushort2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i+2]; - (out+j)[2] = (uint)in[0]; - } -} -static void translate_quads_ushort2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)in[i+1]; - (out+j+0)[1] = (uint)in[i+3]; - (out+j+0)[2] = (uint)in[i+0]; - (out+j+3)[0] = (uint)in[i+2]; - (out+j+3)[1] = (uint)in[i+3]; - (out+j+3)[2] = (uint)in[i+1]; - } -} -static void translate_quadstrip_ushort2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)in[i+0]; - (out+j+0)[1] = (uint)in[i+3]; - (out+j+0)[2] = (uint)in[i+2]; - (out+j+3)[0] = (uint)in[i+1]; - (out+j+3)[1] = (uint)in[i+3]; - (out+j+3)[2] = (uint)in[i+0]; - } -} -static void translate_polygon_ushort2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i+2]; - (out+j)[2] = (uint)in[0]; - } -} -static void translate_points_ushort2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)in[i]; - } -} -static void translate_lines_ushort2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)in[i+1]; - (out+i)[1] = (uint)in[i]; - } -} -static void translate_linestrip_ushort2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i]; - } -} -static void translate_lineloop_ushort2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i]; - } - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i]; -} -static void translate_tris_ushort2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)in[i+2]; - (out+i)[1] = (uint)in[i]; - (out+i)[2] = (uint)in[i+1]; - } -} -static void translate_tristrip_ushort2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+2]; - (out+j)[1] = (uint)in[i+(i&1)]; - (out+j)[2] = (uint)in[i+1-(i&1)]; - } -} -static void translate_trifan_ushort2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+2]; - (out+j)[1] = (uint)in[0]; - (out+j)[2] = (uint)in[i+1]; - } -} -static void translate_quads_ushort2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)in[i+3]; - (out+j+0)[1] = (uint)in[i+0]; - (out+j+0)[2] = (uint)in[i+1]; - (out+j+3)[0] = (uint)in[i+3]; - (out+j+3)[1] = (uint)in[i+1]; - (out+j+3)[2] = (uint)in[i+2]; - } -} -static void translate_quadstrip_ushort2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)in[i+3]; - (out+j+0)[1] = (uint)in[i+2]; - (out+j+0)[2] = (uint)in[i+0]; - (out+j+3)[0] = (uint)in[i+3]; - (out+j+3)[1] = (uint)in[i+0]; - (out+j+3)[2] = (uint)in[i+1]; - } -} -static void translate_polygon_ushort2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_points_ushort2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)in[i]; - } -} -static void translate_lines_ushort2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)in[i]; - (out+i)[1] = (uint)in[i+1]; - } -} -static void translate_linestrip_ushort2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - } -} -static void translate_lineloop_ushort2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - } - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[0]; -} -static void translate_tris_ushort2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)in[i]; - (out+i)[1] = (uint)in[i+1]; - (out+i)[2] = (uint)in[i+2]; - } -} -static void translate_tristrip_ushort2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+(i&1)]; - (out+j)[1] = (uint)in[i+1-(i&1)]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_trifan_ushort2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_quads_ushort2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)in[i+0]; - (out+j+0)[1] = (uint)in[i+1]; - (out+j+0)[2] = (uint)in[i+3]; - (out+j+3)[0] = (uint)in[i+1]; - (out+j+3)[1] = (uint)in[i+2]; - (out+j+3)[2] = (uint)in[i+3]; - } -} -static void translate_quadstrip_ushort2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)in[i+2]; - (out+j+0)[1] = (uint)in[i+0]; - (out+j+0)[2] = (uint)in[i+3]; - (out+j+3)[0] = (uint)in[i+0]; - (out+j+3)[1] = (uint)in[i+1]; - (out+j+3)[2] = (uint)in[i+3]; - } -} -static void translate_polygon_ushort2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i+2]; - (out+j)[2] = (uint)in[0]; - } -} -static void translate_points_uint2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)in[i]; - } -} -static void translate_lines_uint2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)in[i]; - (out+i)[1] = (ushort)in[i+1]; - } -} -static void translate_linestrip_uint2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - } -} -static void translate_lineloop_uint2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - } - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[0]; -} -static void translate_tris_uint2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)in[i]; - (out+i)[1] = (ushort)in[i+1]; - (out+i)[2] = (ushort)in[i+2]; - } -} -static void translate_tristrip_uint2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1+(i&1)]; - (out+j)[2] = (ushort)in[i+2-(i&1)]; - } -} -static void translate_trifan_uint2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_quads_uint2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)in[i+0]; - (out+j+0)[1] = (ushort)in[i+1]; - (out+j+0)[2] = (ushort)in[i+3]; - (out+j+3)[0] = (ushort)in[i+1]; - (out+j+3)[1] = (ushort)in[i+2]; - (out+j+3)[2] = (ushort)in[i+3]; - } -} -static void translate_quadstrip_uint2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)in[i+2]; - (out+j+0)[1] = (ushort)in[i+0]; - (out+j+0)[2] = (ushort)in[i+3]; - (out+j+3)[0] = (ushort)in[i+0]; - (out+j+3)[1] = (ushort)in[i+1]; - (out+j+3)[2] = (ushort)in[i+3]; - } -} -static void translate_polygon_uint2ushort_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_points_uint2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)in[i]; - } -} -static void translate_lines_uint2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)in[i+1]; - (out+i)[1] = (ushort)in[i]; - } -} -static void translate_linestrip_uint2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i]; - } -} -static void translate_lineloop_uint2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i]; - } - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i]; -} -static void translate_tris_uint2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)in[i+1]; - (out+i)[1] = (ushort)in[i+2]; - (out+i)[2] = (ushort)in[i]; - } -} -static void translate_tristrip_uint2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+1+(i&1)]; - (out+j)[1] = (ushort)in[i+2-(i&1)]; - (out+j)[2] = (ushort)in[i]; - } -} -static void translate_trifan_uint2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i+2]; - (out+j)[2] = (ushort)in[0]; - } -} -static void translate_quads_uint2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)in[i+1]; - (out+j+0)[1] = (ushort)in[i+3]; - (out+j+0)[2] = (ushort)in[i+0]; - (out+j+3)[0] = (ushort)in[i+2]; - (out+j+3)[1] = (ushort)in[i+3]; - (out+j+3)[2] = (ushort)in[i+1]; - } -} -static void translate_quadstrip_uint2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)in[i+0]; - (out+j+0)[1] = (ushort)in[i+3]; - (out+j+0)[2] = (ushort)in[i+2]; - (out+j+3)[0] = (ushort)in[i+1]; - (out+j+3)[1] = (ushort)in[i+3]; - (out+j+3)[2] = (ushort)in[i+0]; - } -} -static void translate_polygon_uint2ushort_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i+2]; - (out+j)[2] = (ushort)in[0]; - } -} -static void translate_points_uint2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)in[i]; - } -} -static void translate_lines_uint2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)in[i+1]; - (out+i)[1] = (ushort)in[i]; - } -} -static void translate_linestrip_uint2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i]; - } -} -static void translate_lineloop_uint2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i]; - } - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i]; -} -static void translate_tris_uint2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)in[i+2]; - (out+i)[1] = (ushort)in[i]; - (out+i)[2] = (ushort)in[i+1]; - } -} -static void translate_tristrip_uint2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+2]; - (out+j)[1] = (ushort)in[i+(i&1)]; - (out+j)[2] = (ushort)in[i+1-(i&1)]; - } -} -static void translate_trifan_uint2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+2]; - (out+j)[1] = (ushort)in[0]; - (out+j)[2] = (ushort)in[i+1]; - } -} -static void translate_quads_uint2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)in[i+3]; - (out+j+0)[1] = (ushort)in[i+0]; - (out+j+0)[2] = (ushort)in[i+1]; - (out+j+3)[0] = (ushort)in[i+3]; - (out+j+3)[1] = (ushort)in[i+1]; - (out+j+3)[2] = (ushort)in[i+2]; - } -} -static void translate_quadstrip_uint2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)in[i+3]; - (out+j+0)[1] = (ushort)in[i+2]; - (out+j+0)[2] = (ushort)in[i+0]; - (out+j+3)[0] = (ushort)in[i+3]; - (out+j+3)[1] = (ushort)in[i+0]; - (out+j+3)[2] = (ushort)in[i+1]; - } -} -static void translate_polygon_uint2ushort_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_points_uint2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (ushort)in[i]; - } -} -static void translate_lines_uint2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (ushort)in[i]; - (out+i)[1] = (ushort)in[i+1]; - } -} -static void translate_linestrip_uint2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - } -} -static void translate_lineloop_uint2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - } - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[0]; -} -static void translate_tris_uint2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (ushort)in[i]; - (out+i)[1] = (ushort)in[i+1]; - (out+i)[2] = (ushort)in[i+2]; - } -} -static void translate_tristrip_uint2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+(i&1)]; - (out+j)[1] = (ushort)in[i+1-(i&1)]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_trifan_uint2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j)[2] = (ushort)in[i+2]; - } -} -static void translate_quads_uint2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (ushort)in[i+0]; - (out+j+0)[1] = (ushort)in[i+1]; - (out+j+0)[2] = (ushort)in[i+3]; - (out+j+3)[0] = (ushort)in[i+1]; - (out+j+3)[1] = (ushort)in[i+2]; - (out+j+3)[2] = (ushort)in[i+3]; - } -} -static void translate_quadstrip_uint2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (ushort)in[i+2]; - (out+j+0)[1] = (ushort)in[i+0]; - (out+j+0)[2] = (ushort)in[i+3]; - (out+j+3)[0] = (ushort)in[i+0]; - (out+j+3)[1] = (ushort)in[i+1]; - (out+j+3)[2] = (ushort)in[i+3]; - } -} -static void translate_polygon_uint2ushort_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (ushort)in[i+1]; - (out+j)[1] = (ushort)in[i+2]; - (out+j)[2] = (ushort)in[0]; - } -} -static void translate_points_uint2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)in[i]; - } -} -static void translate_lines_uint2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)in[i]; - (out+i)[1] = (uint)in[i+1]; - } -} -static void translate_linestrip_uint2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - } -} -static void translate_lineloop_uint2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - } - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[0]; -} -static void translate_tris_uint2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)in[i]; - (out+i)[1] = (uint)in[i+1]; - (out+i)[2] = (uint)in[i+2]; - } -} -static void translate_tristrip_uint2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1+(i&1)]; - (out+j)[2] = (uint)in[i+2-(i&1)]; - } -} -static void translate_trifan_uint2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_quads_uint2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)in[i+0]; - (out+j+0)[1] = (uint)in[i+1]; - (out+j+0)[2] = (uint)in[i+3]; - (out+j+3)[0] = (uint)in[i+1]; - (out+j+3)[1] = (uint)in[i+2]; - (out+j+3)[2] = (uint)in[i+3]; - } -} -static void translate_quadstrip_uint2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)in[i+2]; - (out+j+0)[1] = (uint)in[i+0]; - (out+j+0)[2] = (uint)in[i+3]; - (out+j+3)[0] = (uint)in[i+0]; - (out+j+3)[1] = (uint)in[i+1]; - (out+j+3)[2] = (uint)in[i+3]; - } -} -static void translate_polygon_uint2uint_first2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_points_uint2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)in[i]; - } -} -static void translate_lines_uint2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)in[i+1]; - (out+i)[1] = (uint)in[i]; - } -} -static void translate_linestrip_uint2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i]; - } -} -static void translate_lineloop_uint2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i]; - } - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i]; -} -static void translate_tris_uint2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)in[i+1]; - (out+i)[1] = (uint)in[i+2]; - (out+i)[2] = (uint)in[i]; - } -} -static void translate_tristrip_uint2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+1+(i&1)]; - (out+j)[1] = (uint)in[i+2-(i&1)]; - (out+j)[2] = (uint)in[i]; - } -} -static void translate_trifan_uint2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i+2]; - (out+j)[2] = (uint)in[0]; - } -} -static void translate_quads_uint2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)in[i+1]; - (out+j+0)[1] = (uint)in[i+3]; - (out+j+0)[2] = (uint)in[i+0]; - (out+j+3)[0] = (uint)in[i+2]; - (out+j+3)[1] = (uint)in[i+3]; - (out+j+3)[2] = (uint)in[i+1]; - } -} -static void translate_quadstrip_uint2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)in[i+0]; - (out+j+0)[1] = (uint)in[i+3]; - (out+j+0)[2] = (uint)in[i+2]; - (out+j+3)[0] = (uint)in[i+1]; - (out+j+3)[1] = (uint)in[i+3]; - (out+j+3)[2] = (uint)in[i+0]; - } -} -static void translate_polygon_uint2uint_first2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i+2]; - (out+j)[2] = (uint)in[0]; - } -} -static void translate_points_uint2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)in[i]; - } -} -static void translate_lines_uint2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)in[i+1]; - (out+i)[1] = (uint)in[i]; - } -} -static void translate_linestrip_uint2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i]; - } -} -static void translate_lineloop_uint2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i]; - } - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i]; -} -static void translate_tris_uint2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)in[i+2]; - (out+i)[1] = (uint)in[i]; - (out+i)[2] = (uint)in[i+1]; - } -} -static void translate_tristrip_uint2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+2]; - (out+j)[1] = (uint)in[i+(i&1)]; - (out+j)[2] = (uint)in[i+1-(i&1)]; - } -} -static void translate_trifan_uint2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+2]; - (out+j)[1] = (uint)in[0]; - (out+j)[2] = (uint)in[i+1]; - } -} -static void translate_quads_uint2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)in[i+3]; - (out+j+0)[1] = (uint)in[i+0]; - (out+j+0)[2] = (uint)in[i+1]; - (out+j+3)[0] = (uint)in[i+3]; - (out+j+3)[1] = (uint)in[i+1]; - (out+j+3)[2] = (uint)in[i+2]; - } -} -static void translate_quadstrip_uint2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)in[i+3]; - (out+j+0)[1] = (uint)in[i+2]; - (out+j+0)[2] = (uint)in[i+0]; - (out+j+3)[0] = (uint)in[i+3]; - (out+j+3)[1] = (uint)in[i+0]; - (out+j+3)[2] = (uint)in[i+1]; - } -} -static void translate_polygon_uint2uint_last2first( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_points_uint2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i++) { - (out+i)[0] = (uint)in[i]; - } -} -static void translate_lines_uint2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=2) { - (out+i)[0] = (uint)in[i]; - (out+i)[1] = (uint)in[i+1]; - } -} -static void translate_linestrip_uint2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=2, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - } -} -static void translate_lineloop_uint2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr - 2; j+=2, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - } - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[0]; -} -static void translate_tris_uint2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (i = 0; i < nr; i+=3) { - (out+i)[0] = (uint)in[i]; - (out+i)[1] = (uint)in[i+1]; - (out+i)[2] = (uint)in[i+2]; - } -} -static void translate_tristrip_uint2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+(i&1)]; - (out+j)[1] = (uint)in[i+1-(i&1)]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_trifan_uint2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j)[2] = (uint)in[i+2]; - } -} -static void translate_quads_uint2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=4) { - (out+j+0)[0] = (uint)in[i+0]; - (out+j+0)[1] = (uint)in[i+1]; - (out+j+0)[2] = (uint)in[i+3]; - (out+j+3)[0] = (uint)in[i+1]; - (out+j+3)[1] = (uint)in[i+2]; - (out+j+3)[2] = (uint)in[i+3]; - } -} -static void translate_quadstrip_uint2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=2) { - (out+j+0)[0] = (uint)in[i+2]; - (out+j+0)[1] = (uint)in[i+0]; - (out+j+0)[2] = (uint)in[i+3]; - (out+j+3)[0] = (uint)in[i+0]; - (out+j+3)[1] = (uint)in[i+1]; - (out+j+3)[2] = (uint)in[i+3]; - } -} -static void translate_polygon_uint2uint_last2last( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=3, i++) { - (out+j)[0] = (uint)in[i+1]; - (out+j)[1] = (uint)in[i+2]; - (out+j)[2] = (uint)in[0]; - } -} -void u_index_init( void ) -{ - static int firsttime = 1; - if (!firsttime) return; - firsttime = 0; -generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = generate_points_ushort_first2first; -generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = generate_lines_ushort_first2first; -generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_ushort_first2first; -generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_ushort_first2first; -generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = generate_tris_ushort_first2first; -generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort_first2first; -generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort_first2first; -generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = generate_quads_ushort_first2first; -generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort_first2first; -generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = generate_polygon_ushort_first2first; -generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = generate_points_ushort_first2last; -generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = generate_lines_ushort_first2last; -generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_ushort_first2last; -generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_ushort_first2last; -generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = generate_tris_ushort_first2last; -generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort_first2last; -generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort_first2last; -generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = generate_quads_ushort_first2last; -generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort_first2last; -generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = generate_polygon_ushort_first2last; -generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = generate_points_ushort_last2first; -generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = generate_lines_ushort_last2first; -generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_ushort_last2first; -generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_ushort_last2first; -generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = generate_tris_ushort_last2first; -generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort_last2first; -generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort_last2first; -generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = generate_quads_ushort_last2first; -generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort_last2first; -generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = generate_polygon_ushort_last2first; -generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = generate_points_ushort_last2last; -generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = generate_lines_ushort_last2last; -generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_ushort_last2last; -generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_ushort_last2last; -generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = generate_tris_ushort_last2last; -generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort_last2last; -generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort_last2last; -generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = generate_quads_ushort_last2last; -generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort_last2last; -generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = generate_polygon_ushort_last2last; -generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = generate_points_uint_first2first; -generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = generate_lines_uint_first2first; -generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_uint_first2first; -generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_uint_first2first; -generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = generate_tris_uint_first2first; -generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint_first2first; -generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint_first2first; -generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = generate_quads_uint_first2first; -generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint_first2first; -generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = generate_polygon_uint_first2first; -generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = generate_points_uint_first2last; -generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = generate_lines_uint_first2last; -generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_uint_first2last; -generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_uint_first2last; -generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = generate_tris_uint_first2last; -generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint_first2last; -generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint_first2last; -generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = generate_quads_uint_first2last; -generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint_first2last; -generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = generate_polygon_uint_first2last; -generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = generate_points_uint_last2first; -generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = generate_lines_uint_last2first; -generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_uint_last2first; -generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_uint_last2first; -generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = generate_tris_uint_last2first; -generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint_last2first; -generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint_last2first; -generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = generate_quads_uint_last2first; -generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint_last2first; -generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = generate_polygon_uint_last2first; -generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = generate_points_uint_last2last; -generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = generate_lines_uint_last2last; -generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_uint_last2last; -generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_uint_last2last; -generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = generate_tris_uint_last2last; -generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint_last2last; -generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint_last2last; -generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = generate_quads_uint_last2last; -generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint_last2last; -generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = generate_polygon_uint_last2last; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ubyte2ushort_first2first; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ubyte2ushort_first2first; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2ushort_first2first; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2ushort_first2first; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort_first2first; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort_first2first; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort_first2first; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort_first2first; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort_first2first; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort_first2first; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ubyte2ushort_first2last; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ubyte2ushort_first2last; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2ushort_first2last; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2ushort_first2last; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort_first2last; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort_first2last; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort_first2last; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort_first2last; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort_first2last; -translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort_first2last; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ubyte2ushort_last2first; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ubyte2ushort_last2first; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2ushort_last2first; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2ushort_last2first; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort_last2first; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort_last2first; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort_last2first; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort_last2first; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort_last2first; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort_last2first; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ubyte2ushort_last2last; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ubyte2ushort_last2last; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2ushort_last2last; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2ushort_last2last; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort_last2last; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort_last2last; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort_last2last; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort_last2last; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort_last2last; -translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort_last2last; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ubyte2uint_first2first; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ubyte2uint_first2first; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2uint_first2first; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2uint_first2first; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint_first2first; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint_first2first; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint_first2first; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint_first2first; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint_first2first; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint_first2first; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ubyte2uint_first2last; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ubyte2uint_first2last; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2uint_first2last; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2uint_first2last; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint_first2last; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint_first2last; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint_first2last; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint_first2last; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint_first2last; -translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint_first2last; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ubyte2uint_last2first; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ubyte2uint_last2first; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2uint_last2first; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2uint_last2first; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint_last2first; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint_last2first; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint_last2first; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint_last2first; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint_last2first; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint_last2first; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ubyte2uint_last2last; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ubyte2uint_last2last; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2uint_last2last; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2uint_last2last; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint_last2last; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint_last2last; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint_last2last; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint_last2last; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint_last2last; -translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint_last2last; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ushort2ushort_first2first; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ushort2ushort_first2first; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2ushort_first2first; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2ushort_first2first; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort_first2first; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort_first2first; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort_first2first; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort_first2first; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort_first2first; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort_first2first; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ushort2ushort_first2last; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ushort2ushort_first2last; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2ushort_first2last; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2ushort_first2last; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort_first2last; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort_first2last; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort_first2last; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort_first2last; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort_first2last; -translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort_first2last; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ushort2ushort_last2first; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ushort2ushort_last2first; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2ushort_last2first; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2ushort_last2first; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort_last2first; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort_last2first; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort_last2first; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort_last2first; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort_last2first; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort_last2first; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ushort2ushort_last2last; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ushort2ushort_last2last; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2ushort_last2last; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2ushort_last2last; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort_last2last; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort_last2last; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort_last2last; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort_last2last; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort_last2last; -translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort_last2last; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ushort2uint_first2first; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ushort2uint_first2first; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2uint_first2first; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2uint_first2first; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint_first2first; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint_first2first; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint_first2first; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ushort2uint_first2first; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint_first2first; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint_first2first; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ushort2uint_first2last; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ushort2uint_first2last; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2uint_first2last; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2uint_first2last; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint_first2last; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint_first2last; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint_first2last; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ushort2uint_first2last; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint_first2last; -translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint_first2last; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ushort2uint_last2first; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ushort2uint_last2first; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2uint_last2first; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2uint_last2first; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint_last2first; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint_last2first; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint_last2first; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ushort2uint_last2first; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint_last2first; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint_last2first; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ushort2uint_last2last; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ushort2uint_last2last; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2uint_last2last; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2uint_last2last; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint_last2last; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint_last2last; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint_last2last; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ushort2uint_last2last; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint_last2last; -translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint_last2last; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_uint2ushort_first2first; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_uint2ushort_first2first; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2ushort_first2first; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2ushort_first2first; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort_first2first; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort_first2first; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort_first2first; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_uint2ushort_first2first; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort_first2first; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort_first2first; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_uint2ushort_first2last; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_uint2ushort_first2last; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2ushort_first2last; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2ushort_first2last; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort_first2last; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort_first2last; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort_first2last; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_uint2ushort_first2last; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort_first2last; -translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort_first2last; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_uint2ushort_last2first; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_uint2ushort_last2first; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2ushort_last2first; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2ushort_last2first; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort_last2first; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort_last2first; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort_last2first; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_uint2ushort_last2first; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort_last2first; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort_last2first; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_uint2ushort_last2last; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_uint2ushort_last2last; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2ushort_last2last; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2ushort_last2last; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort_last2last; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort_last2last; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort_last2last; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_uint2ushort_last2last; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort_last2last; -translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort_last2last; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_uint2uint_first2first; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_uint2uint_first2first; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2uint_first2first; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2uint_first2first; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint_first2first; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint_first2first; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint_first2first; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_uint2uint_first2first; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint_first2first; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint_first2first; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_uint2uint_first2last; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_uint2uint_first2last; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2uint_first2last; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2uint_first2last; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint_first2last; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint_first2last; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint_first2last; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_uint2uint_first2last; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint_first2last; -translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint_first2last; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_uint2uint_last2first; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_uint2uint_last2first; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2uint_last2first; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2uint_last2first; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint_last2first; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint_last2first; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint_last2first; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_uint2uint_last2first; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint_last2first; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint_last2first; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_uint2uint_last2last; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_uint2uint_last2last; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2uint_last2last; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2uint_last2last; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint_last2last; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint_last2last; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint_last2last; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_uint2uint_last2last; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint_last2last; -translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint_last2last; -} -#include "indices/u_indices.c" diff --git a/src/gallium/auxiliary/indices/u_unfilled_gen.c b/src/gallium/auxiliary/indices/u_unfilled_gen.c deleted file mode 100644 index 93897c98deb..00000000000 --- a/src/gallium/auxiliary/indices/u_unfilled_gen.c +++ /dev/null @@ -1,992 +0,0 @@ -/* File automatically generated by u_unfilled_gen.py */ - -/* - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * 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 - * VMWARE 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 - * Functions to translate and generate index lists - */ - -#include "indices/u_indices.h" -#include "indices/u_indices_priv.h" -#include "pipe/p_compiler.h" -#include "util/u_debug.h" -#include "pipe/p_defines.h" -#include "util/u_memory.h" - - -static unsigned out_size_idx( unsigned index_size ) -{ - switch (index_size) { - case 4: return OUT_UINT; - case 2: return OUT_USHORT; - default: assert(0); return OUT_USHORT; - } -} - -static unsigned in_size_idx( unsigned index_size ) -{ - switch (index_size) { - case 4: return IN_UINT; - case 2: return IN_USHORT; - case 1: return IN_UBYTE; - default: assert(0); return IN_UBYTE; - } -} - - -static u_generate_func generate_line[OUT_COUNT][PRIM_COUNT]; -static u_translate_func translate_line[IN_COUNT][OUT_COUNT][PRIM_COUNT]; - - -static void generate_tris_ushort( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=3) { - (out+j)[0] = (ushort)(i); - (out+j)[1] = (ushort)(i+1); - (out+j+2)[0] = (ushort)(i+1); - (out+j+2)[1] = (ushort)(i+2); - (out+j+4)[0] = (ushort)(i+2); - (out+j+4)[1] = (ushort)(i); - } -} -static void generate_tristrip_ushort( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (ushort)(i); - (out+j)[1] = (ushort)(i+1/*+(i&1)*/); - (out+j+2)[0] = (ushort)(i+1/*+(i&1)*/); - (out+j+2)[1] = (ushort)(i+2/*-(i&1)*/); - (out+j+4)[0] = (ushort)(i+2/*-(i&1)*/); - (out+j+4)[1] = (ushort)(i); - } -} -static void generate_trifan_ushort( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (ushort)(0); - (out+j)[1] = (ushort)(i+1); - (out+j+2)[0] = (ushort)(i+1); - (out+j+2)[1] = (ushort)(i+2); - (out+j+4)[0] = (ushort)(i+2); - (out+j+4)[1] = (ushort)(0); - } -} -static void generate_quads_ushort( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=4) { - (out+j)[0] = (ushort)(i+0); - (out+j)[1] = (ushort)(i+1); - (out+j+2)[0] = (ushort)(i+1); - (out+j+2)[1] = (ushort)(i+2); - (out+j+4)[0] = (ushort)(i+2); - (out+j+4)[1] = (ushort)(i+3); - (out+j+6)[0] = (ushort)(i+3); - (out+j+6)[1] = (ushort)(i+0); - } -} -static void generate_quadstrip_ushort( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=2) { - (out+j)[0] = (ushort)(i+2); - (out+j)[1] = (ushort)(i+0); - (out+j+2)[0] = (ushort)(i+0); - (out+j+2)[1] = (ushort)(i+1); - (out+j+4)[0] = (ushort)(i+1); - (out+j+4)[1] = (ushort)(i+3); - (out+j+6)[0] = (ushort)(i+3); - (out+j+6)[1] = (ushort)(i+2); - } -} -static void generate_polygon_ushort( - unsigned nr, - void *_out ) -{ - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (ushort)(0); - (out+j)[1] = (ushort)(i+1); - (out+j+2)[0] = (ushort)(i+1); - (out+j+2)[1] = (ushort)(i+2); - (out+j+4)[0] = (ushort)(i+2); - (out+j+4)[1] = (ushort)(0); - } -} -static void generate_tris_uint( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=3) { - (out+j)[0] = (uint)(i); - (out+j)[1] = (uint)(i+1); - (out+j+2)[0] = (uint)(i+1); - (out+j+2)[1] = (uint)(i+2); - (out+j+4)[0] = (uint)(i+2); - (out+j+4)[1] = (uint)(i); - } -} -static void generate_tristrip_uint( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (uint)(i); - (out+j)[1] = (uint)(i+1/*+(i&1)*/); - (out+j+2)[0] = (uint)(i+1/*+(i&1)*/); - (out+j+2)[1] = (uint)(i+2/*-(i&1)*/); - (out+j+4)[0] = (uint)(i+2/*-(i&1)*/); - (out+j+4)[1] = (uint)(i); - } -} -static void generate_trifan_uint( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (uint)(0); - (out+j)[1] = (uint)(i+1); - (out+j+2)[0] = (uint)(i+1); - (out+j+2)[1] = (uint)(i+2); - (out+j+4)[0] = (uint)(i+2); - (out+j+4)[1] = (uint)(0); - } -} -static void generate_quads_uint( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=4) { - (out+j)[0] = (uint)(i+0); - (out+j)[1] = (uint)(i+1); - (out+j+2)[0] = (uint)(i+1); - (out+j+2)[1] = (uint)(i+2); - (out+j+4)[0] = (uint)(i+2); - (out+j+4)[1] = (uint)(i+3); - (out+j+6)[0] = (uint)(i+3); - (out+j+6)[1] = (uint)(i+0); - } -} -static void generate_quadstrip_uint( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=2) { - (out+j)[0] = (uint)(i+2); - (out+j)[1] = (uint)(i+0); - (out+j+2)[0] = (uint)(i+0); - (out+j+2)[1] = (uint)(i+1); - (out+j+4)[0] = (uint)(i+1); - (out+j+4)[1] = (uint)(i+3); - (out+j+6)[0] = (uint)(i+3); - (out+j+6)[1] = (uint)(i+2); - } -} -static void generate_polygon_uint( - unsigned nr, - void *_out ) -{ - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (uint)(0); - (out+j)[1] = (uint)(i+1); - (out+j+2)[0] = (uint)(i+1); - (out+j+2)[1] = (uint)(i+2); - (out+j+4)[0] = (uint)(i+2); - (out+j+4)[1] = (uint)(0); - } -} -static void translate_tris_ubyte2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=3) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - (out+j+2)[0] = (ushort)in[i+1]; - (out+j+2)[1] = (ushort)in[i+2]; - (out+j+4)[0] = (ushort)in[i+2]; - (out+j+4)[1] = (ushort)in[i]; - } -} -static void translate_tristrip_ubyte2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1/*+(i&1)*/]; - (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/]; - (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/]; - (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/]; - (out+j+4)[1] = (ushort)in[i]; - } -} -static void translate_trifan_ubyte2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j+2)[0] = (ushort)in[i+1]; - (out+j+2)[1] = (ushort)in[i+2]; - (out+j+4)[0] = (ushort)in[i+2]; - (out+j+4)[1] = (ushort)in[0]; - } -} -static void translate_quads_ubyte2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=4) { - (out+j)[0] = (ushort)in[i+0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j+2)[0] = (ushort)in[i+1]; - (out+j+2)[1] = (ushort)in[i+2]; - (out+j+4)[0] = (ushort)in[i+2]; - (out+j+4)[1] = (ushort)in[i+3]; - (out+j+6)[0] = (ushort)in[i+3]; - (out+j+6)[1] = (ushort)in[i+0]; - } -} -static void translate_quadstrip_ubyte2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=2) { - (out+j)[0] = (ushort)in[i+2]; - (out+j)[1] = (ushort)in[i+0]; - (out+j+2)[0] = (ushort)in[i+0]; - (out+j+2)[1] = (ushort)in[i+1]; - (out+j+4)[0] = (ushort)in[i+1]; - (out+j+4)[1] = (ushort)in[i+3]; - (out+j+6)[0] = (ushort)in[i+3]; - (out+j+6)[1] = (ushort)in[i+2]; - } -} -static void translate_polygon_ubyte2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j+2)[0] = (ushort)in[i+1]; - (out+j+2)[1] = (ushort)in[i+2]; - (out+j+4)[0] = (ushort)in[i+2]; - (out+j+4)[1] = (ushort)in[0]; - } -} -static void translate_tris_ubyte2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=3) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - (out+j+2)[0] = (uint)in[i+1]; - (out+j+2)[1] = (uint)in[i+2]; - (out+j+4)[0] = (uint)in[i+2]; - (out+j+4)[1] = (uint)in[i]; - } -} -static void translate_tristrip_ubyte2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1/*+(i&1)*/]; - (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/]; - (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/]; - (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/]; - (out+j+4)[1] = (uint)in[i]; - } -} -static void translate_trifan_ubyte2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j+2)[0] = (uint)in[i+1]; - (out+j+2)[1] = (uint)in[i+2]; - (out+j+4)[0] = (uint)in[i+2]; - (out+j+4)[1] = (uint)in[0]; - } -} -static void translate_quads_ubyte2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=4) { - (out+j)[0] = (uint)in[i+0]; - (out+j)[1] = (uint)in[i+1]; - (out+j+2)[0] = (uint)in[i+1]; - (out+j+2)[1] = (uint)in[i+2]; - (out+j+4)[0] = (uint)in[i+2]; - (out+j+4)[1] = (uint)in[i+3]; - (out+j+6)[0] = (uint)in[i+3]; - (out+j+6)[1] = (uint)in[i+0]; - } -} -static void translate_quadstrip_ubyte2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=2) { - (out+j)[0] = (uint)in[i+2]; - (out+j)[1] = (uint)in[i+0]; - (out+j+2)[0] = (uint)in[i+0]; - (out+j+2)[1] = (uint)in[i+1]; - (out+j+4)[0] = (uint)in[i+1]; - (out+j+4)[1] = (uint)in[i+3]; - (out+j+6)[0] = (uint)in[i+3]; - (out+j+6)[1] = (uint)in[i+2]; - } -} -static void translate_polygon_ubyte2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const ubyte*in = (const ubyte*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j+2)[0] = (uint)in[i+1]; - (out+j+2)[1] = (uint)in[i+2]; - (out+j+4)[0] = (uint)in[i+2]; - (out+j+4)[1] = (uint)in[0]; - } -} -static void translate_tris_ushort2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=3) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - (out+j+2)[0] = (ushort)in[i+1]; - (out+j+2)[1] = (ushort)in[i+2]; - (out+j+4)[0] = (ushort)in[i+2]; - (out+j+4)[1] = (ushort)in[i]; - } -} -static void translate_tristrip_ushort2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1/*+(i&1)*/]; - (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/]; - (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/]; - (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/]; - (out+j+4)[1] = (ushort)in[i]; - } -} -static void translate_trifan_ushort2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j+2)[0] = (ushort)in[i+1]; - (out+j+2)[1] = (ushort)in[i+2]; - (out+j+4)[0] = (ushort)in[i+2]; - (out+j+4)[1] = (ushort)in[0]; - } -} -static void translate_quads_ushort2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=4) { - (out+j)[0] = (ushort)in[i+0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j+2)[0] = (ushort)in[i+1]; - (out+j+2)[1] = (ushort)in[i+2]; - (out+j+4)[0] = (ushort)in[i+2]; - (out+j+4)[1] = (ushort)in[i+3]; - (out+j+6)[0] = (ushort)in[i+3]; - (out+j+6)[1] = (ushort)in[i+0]; - } -} -static void translate_quadstrip_ushort2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=2) { - (out+j)[0] = (ushort)in[i+2]; - (out+j)[1] = (ushort)in[i+0]; - (out+j+2)[0] = (ushort)in[i+0]; - (out+j+2)[1] = (ushort)in[i+1]; - (out+j+4)[0] = (ushort)in[i+1]; - (out+j+4)[1] = (ushort)in[i+3]; - (out+j+6)[0] = (ushort)in[i+3]; - (out+j+6)[1] = (ushort)in[i+2]; - } -} -static void translate_polygon_ushort2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j+2)[0] = (ushort)in[i+1]; - (out+j+2)[1] = (ushort)in[i+2]; - (out+j+4)[0] = (ushort)in[i+2]; - (out+j+4)[1] = (ushort)in[0]; - } -} -static void translate_tris_ushort2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=3) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - (out+j+2)[0] = (uint)in[i+1]; - (out+j+2)[1] = (uint)in[i+2]; - (out+j+4)[0] = (uint)in[i+2]; - (out+j+4)[1] = (uint)in[i]; - } -} -static void translate_tristrip_ushort2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1/*+(i&1)*/]; - (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/]; - (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/]; - (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/]; - (out+j+4)[1] = (uint)in[i]; - } -} -static void translate_trifan_ushort2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j+2)[0] = (uint)in[i+1]; - (out+j+2)[1] = (uint)in[i+2]; - (out+j+4)[0] = (uint)in[i+2]; - (out+j+4)[1] = (uint)in[0]; - } -} -static void translate_quads_ushort2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=4) { - (out+j)[0] = (uint)in[i+0]; - (out+j)[1] = (uint)in[i+1]; - (out+j+2)[0] = (uint)in[i+1]; - (out+j+2)[1] = (uint)in[i+2]; - (out+j+4)[0] = (uint)in[i+2]; - (out+j+4)[1] = (uint)in[i+3]; - (out+j+6)[0] = (uint)in[i+3]; - (out+j+6)[1] = (uint)in[i+0]; - } -} -static void translate_quadstrip_ushort2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=2) { - (out+j)[0] = (uint)in[i+2]; - (out+j)[1] = (uint)in[i+0]; - (out+j+2)[0] = (uint)in[i+0]; - (out+j+2)[1] = (uint)in[i+1]; - (out+j+4)[0] = (uint)in[i+1]; - (out+j+4)[1] = (uint)in[i+3]; - (out+j+6)[0] = (uint)in[i+3]; - (out+j+6)[1] = (uint)in[i+2]; - } -} -static void translate_polygon_ushort2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const ushort*in = (const ushort*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j+2)[0] = (uint)in[i+1]; - (out+j+2)[1] = (uint)in[i+2]; - (out+j+4)[0] = (uint)in[i+2]; - (out+j+4)[1] = (uint)in[0]; - } -} -static void translate_tris_uint2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=3) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1]; - (out+j+2)[0] = (ushort)in[i+1]; - (out+j+2)[1] = (ushort)in[i+2]; - (out+j+4)[0] = (ushort)in[i+2]; - (out+j+4)[1] = (ushort)in[i]; - } -} -static void translate_tristrip_uint2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (ushort)in[i]; - (out+j)[1] = (ushort)in[i+1/*+(i&1)*/]; - (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/]; - (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/]; - (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/]; - (out+j+4)[1] = (ushort)in[i]; - } -} -static void translate_trifan_uint2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j+2)[0] = (ushort)in[i+1]; - (out+j+2)[1] = (ushort)in[i+2]; - (out+j+4)[0] = (ushort)in[i+2]; - (out+j+4)[1] = (ushort)in[0]; - } -} -static void translate_quads_uint2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=4) { - (out+j)[0] = (ushort)in[i+0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j+2)[0] = (ushort)in[i+1]; - (out+j+2)[1] = (ushort)in[i+2]; - (out+j+4)[0] = (ushort)in[i+2]; - (out+j+4)[1] = (ushort)in[i+3]; - (out+j+6)[0] = (ushort)in[i+3]; - (out+j+6)[1] = (ushort)in[i+0]; - } -} -static void translate_quadstrip_uint2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=2) { - (out+j)[0] = (ushort)in[i+2]; - (out+j)[1] = (ushort)in[i+0]; - (out+j+2)[0] = (ushort)in[i+0]; - (out+j+2)[1] = (ushort)in[i+1]; - (out+j+4)[0] = (ushort)in[i+1]; - (out+j+4)[1] = (ushort)in[i+3]; - (out+j+6)[0] = (ushort)in[i+3]; - (out+j+6)[1] = (ushort)in[i+2]; - } -} -static void translate_polygon_uint2ushort( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - ushort *out = (ushort*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (ushort)in[0]; - (out+j)[1] = (ushort)in[i+1]; - (out+j+2)[0] = (ushort)in[i+1]; - (out+j+2)[1] = (ushort)in[i+2]; - (out+j+4)[0] = (ushort)in[i+2]; - (out+j+4)[1] = (ushort)in[0]; - } -} -static void translate_tris_uint2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i+=3) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1]; - (out+j+2)[0] = (uint)in[i+1]; - (out+j+2)[1] = (uint)in[i+2]; - (out+j+4)[0] = (uint)in[i+2]; - (out+j+4)[1] = (uint)in[i]; - } -} -static void translate_tristrip_uint2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (uint)in[i]; - (out+j)[1] = (uint)in[i+1/*+(i&1)*/]; - (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/]; - (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/]; - (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/]; - (out+j+4)[1] = (uint)in[i]; - } -} -static void translate_trifan_uint2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j+2)[0] = (uint)in[i+1]; - (out+j+2)[1] = (uint)in[i+2]; - (out+j+4)[0] = (uint)in[i+2]; - (out+j+4)[1] = (uint)in[0]; - } -} -static void translate_quads_uint2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=4) { - (out+j)[0] = (uint)in[i+0]; - (out+j)[1] = (uint)in[i+1]; - (out+j+2)[0] = (uint)in[i+1]; - (out+j+2)[1] = (uint)in[i+2]; - (out+j+4)[0] = (uint)in[i+2]; - (out+j+4)[1] = (uint)in[i+3]; - (out+j+6)[0] = (uint)in[i+3]; - (out+j+6)[1] = (uint)in[i+0]; - } -} -static void translate_quadstrip_uint2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=8, i+=2) { - (out+j)[0] = (uint)in[i+2]; - (out+j)[1] = (uint)in[i+0]; - (out+j+2)[0] = (uint)in[i+0]; - (out+j+2)[1] = (uint)in[i+1]; - (out+j+4)[0] = (uint)in[i+1]; - (out+j+4)[1] = (uint)in[i+3]; - (out+j+6)[0] = (uint)in[i+3]; - (out+j+6)[1] = (uint)in[i+2]; - } -} -static void translate_polygon_uint2uint( - const void * _in, - unsigned nr, - void *_out ) -{ - const uint*in = (const uint*)_in; - uint *out = (uint*)_out; - unsigned i, j; - (void)j; - for (j = i = 0; j < nr; j+=6, i++) { - (out+j)[0] = (uint)in[0]; - (out+j)[1] = (uint)in[i+1]; - (out+j+2)[0] = (uint)in[i+1]; - (out+j+2)[1] = (uint)in[i+2]; - (out+j+4)[0] = (uint)in[i+2]; - (out+j+4)[1] = (uint)in[0]; - } -} -void u_unfilled_init( void ) -{ - static int firsttime = 1; - if (!firsttime) return; - firsttime = 0; -generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLES] = generate_tris_ushort; -generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort; -generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort; -generate_line[OUT_USHORT][PIPE_PRIM_QUADS] = generate_quads_ushort; -generate_line[OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort; -generate_line[OUT_USHORT][PIPE_PRIM_POLYGON] = generate_polygon_ushort; -generate_line[OUT_UINT][PIPE_PRIM_TRIANGLES] = generate_tris_uint; -generate_line[OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint; -generate_line[OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint; -generate_line[OUT_UINT][PIPE_PRIM_QUADS] = generate_quads_uint; -generate_line[OUT_UINT][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint; -generate_line[OUT_UINT][PIPE_PRIM_POLYGON] = generate_polygon_uint; -translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort; -translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort; -translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort; -translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort; -translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort; -translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort; -translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint; -translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint; -translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint; -translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint; -translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint; -translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint; -translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort; -translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort; -translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort; -translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort; -translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort; -translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort; -translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint; -translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint; -translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint; -translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_ushort2uint; -translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint; -translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint; -translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort; -translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort; -translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort; -translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_uint2ushort; -translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort; -translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort; -translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint; -translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint; -translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint; -translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_uint2uint; -translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint; -translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint; -} -#include "indices/u_unfilled_indices.c" diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h index c09e8a7a76f..0238308d20b 100644 --- a/src/gallium/auxiliary/os/os_thread.h +++ b/src/gallium/auxiliary/os/os_thread.h @@ -40,7 +40,7 @@ #include "util/u_debug.h" /* for assert */ -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN) #include <pthread.h> /* POSIX threads headers */ #include <stdio.h> /* for perror() */ @@ -405,7 +405,7 @@ pipe_semaphore_wait(pipe_semaphore *sema) */ typedef struct { -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN) pthread_key_t key; #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) DWORD key; @@ -420,7 +420,7 @@ typedef struct { static INLINE void pipe_tsd_init(pipe_tsd *tsd) { -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN) if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) { perror("pthread_key_create(): failed to allocate key for thread specific data"); exit(-1); @@ -437,7 +437,7 @@ pipe_tsd_get(pipe_tsd *tsd) if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) { pipe_tsd_init(tsd); } -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN) return pthread_getspecific(tsd->key); #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) assert(0); @@ -454,7 +454,7 @@ pipe_tsd_set(pipe_tsd *tsd, void *value) if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) { pipe_tsd_init(tsd); } -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED) || defined(PIPE_OS_CYGWIN) if (pthread_setspecific(tsd->key, value) != 0) { perror("pthread_set_specific() failed"); exit(-1); diff --git a/src/gallium/auxiliary/os/os_time.c b/src/gallium/auxiliary/os/os_time.c index 6259142bec0..84907215fe6 100644 --- a/src/gallium/auxiliary/os/os_time.c +++ b/src/gallium/auxiliary/os/os_time.c @@ -37,7 +37,7 @@ #if !defined(PIPE_OS_EMBEDDED) -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_CYGWIN) # include <sys/time.h> /* timeval */ #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) # include <windows.h> diff --git a/src/gallium/auxiliary/rbug/README b/src/gallium/auxiliary/rbug/README index d984067893c..c5156438a1b 100644 --- a/src/gallium/auxiliary/rbug/README +++ b/src/gallium/auxiliary/rbug/README @@ -10,7 +10,7 @@ The code currently uses tcp and ip4v for connections. Information about driver integration can be found in: -src/gallium/drivers/trace/README +src/gallium/drivers/rbug/README for information about applications look in: diff --git a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c index 7595214bdf2..9f70b73698a 100644 --- a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c +++ b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c @@ -1743,20 +1743,35 @@ void x86_release_func( struct x86_function *p ) } -void (*x86_get_func( struct x86_function *p ))(void) +static INLINE x86_func +voidptr_to_x86_func(void *v) +{ + union { + void *v; + x86_func f; + } u; + assert(sizeof(u.v) == sizeof(u.f)); + u.v = v; + return u.f; +} + + +x86_func x86_get_func( struct x86_function *p ) { DUMP_END(); if (DISASSEM && p->store) debug_printf("disassemble %p %p\n", p->store, p->csr); if (p->store == p->error_overflow) - return (void (*)(void)) NULL; + return voidptr_to_x86_func(NULL); else - return (void (*)(void)) p->store; + return voidptr_to_x86_func(p->store); } #else +void x86sse_dummy( void ); + void x86sse_dummy( void ) { } diff --git a/src/gallium/auxiliary/rtasm/rtasm_x86sse.h b/src/gallium/auxiliary/rtasm/rtasm_x86sse.h index 319b836ffb1..6208e8f707f 100644 --- a/src/gallium/auxiliary/rtasm/rtasm_x86sse.h +++ b/src/gallium/auxiliary/rtasm/rtasm_x86sse.h @@ -102,6 +102,11 @@ enum sse_cc { #define cc_Z cc_E #define cc_NZ cc_NE + +/** generic pointer to function */ +typedef void (*x86_func)(void); + + /* Begin/end/retrieve function creation: */ @@ -109,7 +114,7 @@ enum sse_cc { void x86_init_func( struct x86_function *p ); void x86_init_func_size( struct x86_function *p, unsigned code_size ); void x86_release_func( struct x86_function *p ); -void (*x86_get_func( struct x86_function *p ))( void ); +x86_func x86_get_func( struct x86_function *p ); /* Debugging: */ diff --git a/src/gallium/auxiliary/target-helpers/wrap_screen.c b/src/gallium/auxiliary/target-helpers/wrap_screen.c index eb475123198..df5d56a53c9 100644 --- a/src/gallium/auxiliary/target-helpers/wrap_screen.c +++ b/src/gallium/auxiliary/target-helpers/wrap_screen.c @@ -33,6 +33,7 @@ #include "target-helpers/wrap_screen.h" #include "trace/tr_public.h" +#include "rbug/rbug_public.h" #include "identity/id_public.h" #include "util/u_debug.h" @@ -56,6 +57,9 @@ gallium_wrap_screen( struct pipe_screen *screen ) /* Trace does its own checking if it should run */ screen = trace_screen_create(screen); + /* Rbug does its own checking if it should run */ + screen = rbug_screen_create(screen); + return screen; } diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c index 1ad183b8dd4..35480076edf 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c @@ -56,7 +56,7 @@ dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...) va_list ap; (void)ctx; va_start(ap, format); - debug_vprintf(format, ap); + _debug_vprintf(format, ap); va_end(ap); } diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 9b1ca7fa851..c15d970b573 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -621,12 +621,10 @@ tgsi_exec_machine_bind_shader( { uint k; struct tgsi_parse_context parse; - struct tgsi_exec_labels *labels = &mach->Labels; struct tgsi_full_instruction *instructions; struct tgsi_full_declaration *declarations; uint maxInstructions = 10, numInstructions = 0; uint maxDeclarations = 10, numDeclarations = 0; - uint instno = 0; #if 0 tgsi_dump(tokens, 0); @@ -637,6 +635,23 @@ tgsi_exec_machine_bind_shader( mach->Tokens = tokens; mach->Samplers = samplers; + if (!tokens) { + /* unbind and free all */ + if (mach->Declarations) { + FREE( mach->Declarations ); + } + mach->Declarations = NULL; + mach->NumDeclarations = 0; + + if (mach->Instructions) { + FREE( mach->Instructions ); + } + mach->Instructions = NULL; + mach->NumInstructions = 0; + + return; + } + k = tgsi_parse_init (&parse, mach->Tokens); if (k != TGSI_PARSE_OK) { debug_printf( "Problem parsing!\n" ); @@ -645,7 +660,6 @@ tgsi_exec_machine_bind_shader( mach->Processor = parse.FullHeader.Processor.Processor; mach->ImmLimit = 0; - labels->count = 0; declarations = (struct tgsi_full_declaration *) MALLOC( maxDeclarations * sizeof(struct tgsi_full_declaration) ); @@ -663,7 +677,6 @@ tgsi_exec_machine_bind_shader( } while( !tgsi_parse_end_of_tokens( &parse ) ) { - uint pointer = parse.Position; uint i; tgsi_parse_token( &parse ); @@ -707,11 +720,6 @@ tgsi_exec_machine_bind_shader( break; case TGSI_TOKEN_TYPE_INSTRUCTION: - assert( labels->count < MAX_LABELS ); - - labels->labels[labels->count][0] = instno; - labels->labels[labels->count][1] = pointer; - labels->count++; /* save expanded instruction */ if (numInstructions == maxInstructions) { @@ -801,7 +809,9 @@ void tgsi_exec_machine_destroy(struct tgsi_exec_machine *mach) { if (mach) { - FREE(mach->Instructions); + if (mach->Instructions) + FREE(mach->Instructions); + if (mach->Declarations) FREE(mach->Declarations); } @@ -3126,7 +3136,7 @@ exec_instruction( break; case TGSI_OPCODE_DIV: - assert( 0 ); + exec_vector_binary(mach, inst, micro_div, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT); break; case TGSI_OPCODE_DP2: diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h index 11bbaf6722e..3caf820af67 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h @@ -37,8 +37,6 @@ extern "C" { #endif -#define MAX_LABELS (4 * 1024) /**< basically, max instructions */ - #define NUM_CHANNELS 4 /* R,G,B,A */ #define QUAD_SIZE 4 /* 4 pixel/quad */ @@ -93,16 +91,6 @@ struct tgsi_sampler float rgba[NUM_CHANNELS][QUAD_SIZE]); }; -/** - * For branching/calling subroutines. - */ -struct tgsi_exec_labels -{ - unsigned labels[MAX_LABELS][2]; - unsigned count; -}; - - #define TGSI_EXEC_NUM_TEMPS 128 #define TGSI_EXEC_NUM_IMMEDIATES 256 @@ -186,10 +174,11 @@ struct tgsi_exec_labels -#define TGSI_EXEC_MAX_COND_NESTING 32 -#define TGSI_EXEC_MAX_LOOP_NESTING 32 -#define TGSI_EXEC_MAX_SWITCH_NESTING 32 -#define TGSI_EXEC_MAX_CALL_NESTING 32 +#define TGSI_EXEC_MAX_NESTING 32 +#define TGSI_EXEC_MAX_COND_NESTING TGSI_EXEC_MAX_NESTING +#define TGSI_EXEC_MAX_LOOP_NESTING TGSI_EXEC_MAX_NESTING +#define TGSI_EXEC_MAX_SWITCH_NESTING TGSI_EXEC_MAX_NESTING +#define TGSI_EXEC_MAX_CALL_NESTING TGSI_EXEC_MAX_NESTING /* The maximum number of input attributes per vertex. For 2D * input register files, this is the stride between two 1D @@ -324,7 +313,6 @@ struct tgsi_exec_machine struct tgsi_full_declaration *Declarations; uint NumDeclarations; - struct tgsi_exec_labels Labels; }; struct tgsi_exec_machine * diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c index cfa2f631bd8..e59e964ffa7 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_info.c +++ b/src/gallium/auxiliary/tgsi/tgsi_info.c @@ -205,3 +205,18 @@ tgsi_get_opcode_name( uint opcode ) return info->mnemonic; } + +const char * +tgsi_get_processor_name( uint processor ) +{ + switch (processor) { + case TGSI_PROCESSOR_VERTEX: + return "vertex shader"; + case TGSI_PROCESSOR_FRAGMENT: + return "fragment shader"; + case TGSI_PROCESSOR_GEOMETRY: + return "geometry shader"; + default: + return "unknown shader type!"; + } +} diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.h b/src/gallium/auxiliary/tgsi/tgsi_info.h index 74713c3b98a..50248884fd0 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_info.h +++ b/src/gallium/auxiliary/tgsi/tgsi_info.h @@ -52,6 +52,9 @@ tgsi_get_opcode_info( uint opcode ); const char * tgsi_get_opcode_name( uint opcode ); +const char * +tgsi_get_processor_name( uint processor ); + #if defined __cplusplus } diff --git a/src/gallium/auxiliary/tgsi/tgsi_ppc.c b/src/gallium/auxiliary/tgsi/tgsi_ppc.c index ad553c71a57..3521847b619 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ppc.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ppc.c @@ -1366,4 +1366,12 @@ tgsi_emit_ppc(const struct tgsi_token *tokens, return ok; } +#else + +void ppc_dummy_func(void); + +void ppc_dummy_func(void) +{ +} + #endif /* PIPE_ARCH_PPC */ diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c index 232fc537c1d..e0c5d3d3d61 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_scan.c +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c @@ -88,10 +88,7 @@ tgsi_scan_shader(const struct tgsi_token *tokens, assert(fullinst->Instruction.Opcode < TGSI_OPCODE_LAST); info->opcode_count[fullinst->Instruction.Opcode]++; - /* special case: scan fragment shaders for use of the fog - * input/attribute. The X component is fog, the Y component - * is the front/back-face flag. - */ + /* check if we read the frag shader FOG or FACE inputs */ if (procType == TGSI_PROCESSOR_FRAGMENT) { uint i; for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) { @@ -109,6 +106,8 @@ tgsi_scan_shader(const struct tgsi_token *tokens, } } } + + info->num_instructions++; } break; diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h b/src/gallium/auxiliary/tgsi/tgsi_scan.h index 741aa7d5c42..27de33f7990 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_scan.h +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h @@ -54,6 +54,7 @@ struct tgsi_shader_info int file_max[TGSI_FILE_COUNT]; /**< highest index of declared registers */ uint immediate_count; /**< number of immediates declared */ + uint num_instructions; uint opcode_count[TGSI_OPCODE_LAST]; /**< opcode histogram */ diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 1071298b497..d5061f8b511 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -1929,20 +1929,32 @@ emit_instruction( break; case TGSI_OPCODE_MUL: + /* do all fetches and adds, storing results in temp regs */ FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { - FETCH( func, *inst, 0, 0, chan_index ); - FETCH( func, *inst, 1, 1, chan_index ); - emit_mul( func, 0, 1 ); - STORE( func, *inst, 0, 0, chan_index ); + int r = chan_index + 1; + FETCH( func, *inst, 0, 0, chan_index ); /* load xmm[0] */ + FETCH( func, *inst, r, 1, chan_index ); /* load xmm[r] */ + emit_mul( func, r, 0 ); /* xmm[r] = xmm[r] * xmm[0] */ + } + /* do all stores of the temp regs */ + FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + int r = chan_index + 1; + STORE( func, *inst, r, 0, chan_index ); /* store xmm[r] */ } break; case TGSI_OPCODE_ADD: + /* do all fetches and adds, storing results in temp regs */ FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { - FETCH( func, *inst, 0, 0, chan_index ); - FETCH( func, *inst, 1, 1, chan_index ); - emit_add( func, 0, 1 ); - STORE( func, *inst, 0, 0, chan_index ); + int r = chan_index + 1; + FETCH( func, *inst, 0, 0, chan_index ); /* load xmm[0] */ + FETCH( func, *inst, r, 1, chan_index ); /* load xmm[r] */ + emit_add( func, r, 0 ); /* xmm[r] = xmm[r] + xmm[0] */ + } + /* do all stores of the temp regs */ + FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + int r = chan_index + 1; + STORE( func, *inst, r, 0, chan_index ); /* store xmm[r] */ } break; @@ -2816,6 +2828,40 @@ static void soa_to_aos( struct x86_function *func, x86_pop( func, x86_make_reg( file_REG32, reg_BX ) ); } + +/** + * Check if the instructions dst register is the same as any src + * register and warn if there's a posible SOA dependency. + */ +static void +check_soa_dependencies(const struct tgsi_full_instruction *inst) +{ + switch (inst->Instruction.Opcode) { + case TGSI_OPCODE_ADD: + case TGSI_OPCODE_MOV: + case TGSI_OPCODE_MUL: + case TGSI_OPCODE_XPD: + /* OK - these opcodes correctly handle SOA dependencies */ + break; + default: + if (tgsi_check_soa_dependencies(inst)) { + uint opcode = inst->Instruction.Opcode; + + /* XXX: we only handle src/dst aliasing in a few opcodes + * currently. Need to use an additional temporay to hold + * the result in the cases where the code is too opaque to + * fix. + */ + if (opcode != TGSI_OPCODE_MOV) { + debug_printf("Warning: src/dst aliasing in instruction" + " is not handled:\n"); + tgsi_dump_instruction(inst, 1); + } + } + } +} + + /** * Translate a TGSI vertex/fragment shader to SSE2 code. * Slightly different things are done for vertex vs. fragment shaders. @@ -2905,27 +2951,14 @@ tgsi_emit_sse2( if (!ok) { uint opcode = parse.FullToken.FullInstruction.Instruction.Opcode; + uint proc = parse.FullHeader.Processor.Processor; debug_printf("failed to translate tgsi opcode %d (%s) to SSE (%s)\n", opcode, tgsi_get_opcode_name(opcode), - parse.FullHeader.Processor.Processor == TGSI_PROCESSOR_VERTEX ? - "vertex shader" : "fragment shader"); + tgsi_get_processor_name(proc)); } - if (tgsi_check_soa_dependencies(&parse.FullToken.FullInstruction)) { - uint opcode = parse.FullToken.FullInstruction.Instruction.Opcode; - - /* XXX: we only handle src/dst aliasing in a few opcodes - * currently. Need to use an additional temporay to hold - * the result in the cases where the code is too opaque to - * fix. - */ - if (opcode != TGSI_OPCODE_MOV) { - debug_printf("Warning: src/dst aliasing in instruction" - " is not handled:\n"); - tgsi_dump_instruction(&parse.FullToken.FullInstruction, 1); - } - } + check_soa_dependencies(&parse.FullToken.FullInstruction); break; case TGSI_TOKEN_TYPE_IMMEDIATE: diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 49b854b1234..5fda808dbef 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -1467,6 +1467,12 @@ const struct tgsi_token *ureg_get_tokens( struct ureg_program *ureg, } +void ureg_free_tokens( const struct tgsi_token *tokens ) +{ + FREE((struct tgsi_token *)tokens); +} + + struct ureg_program *ureg_create( unsigned processor ) { struct ureg_program *ureg = CALLOC_STRUCT( ureg_program ); diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index f32420dd872..055545f3d2a 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -104,6 +104,10 @@ ureg_get_tokens( struct ureg_program *ureg, unsigned *nr_tokens ); +/* Free the tokens created by ureg_get_tokens() */ +void ureg_free_tokens( const struct tgsi_token *tokens ); + + void ureg_destroy( struct ureg_program * ); diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 9df5f9a9d26..d4fbd658f40 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -48,7 +48,6 @@ #include "util/u_sampler.h" #include "util/u_simple_shaders.h" #include "util/u_surface.h" -#include "util/u_rect.h" #include "cso_cache/cso_context.h" @@ -102,8 +101,7 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso) /* rasterizer */ memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer)); - ctx->rasterizer.front_winding = PIPE_WINDING_CW; - ctx->rasterizer.cull_mode = PIPE_WINDING_NONE; + ctx->rasterizer.cull_face = PIPE_FACE_NONE; ctx->rasterizer.gl_rasterization_rules = 1; /* samplers */ diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index d603c7ac06d..e0bd89154cb 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -44,7 +44,6 @@ #include "util/u_blitter.h" #include "util/u_draw_quad.h" #include "util/u_pack_color.h" -#include "util/u_rect.h" #include "util/u_sampler.h" #include "util/u_simple_shaders.h" #include "util/u_surface.h" @@ -70,8 +69,8 @@ struct blitter_context_priv void *vs_tex; /**< Vertex shader which passes {pos, texcoord} to the output.*/ /* Fragment shaders. */ - /* FS which outputs a color to multiple color buffers. */ - void *fs_col[PIPE_MAX_COLOR_BUFS]; + /* The shader at index i outputs color to color buffers 0,1,...,i-1. */ + void *fs_col[PIPE_MAX_COLOR_BUFS+1]; /* FS which outputs a color from a texture, where the index is PIPE_TEXTURE_* to be sampled. */ @@ -176,8 +175,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) /* rasterizer state */ memset(&rs_state, 0, sizeof(rs_state)); - rs_state.front_winding = PIPE_WINDING_CW; - rs_state.cull_mode = PIPE_WINDING_NONE; + rs_state.cull_face = PIPE_FACE_NONE; rs_state.gl_rasterization_rules = 1; rs_state.flatshade = 1; ctx->rs_state = pipe->create_rasterizer_state(pipe, &rs_state); @@ -249,7 +247,7 @@ void util_blitter_destroy(struct blitter_context *blitter) pipe->delete_fs_state(pipe, ctx->fs_texfetch_depth[i]); } - for (i = 0; i < PIPE_MAX_COLOR_BUFS && ctx->fs_col[i]; i++) + for (i = 0; i <= PIPE_MAX_COLOR_BUFS && ctx->fs_col[i]; i++) if (ctx->fs_col[i]) pipe->delete_fs_state(pipe, ctx->fs_col[i]); @@ -496,15 +494,14 @@ static INLINE void *blitter_get_fs_col(struct blitter_context_priv *ctx, unsigned num_cbufs) { struct pipe_context *pipe = ctx->pipe; - unsigned index = num_cbufs ? num_cbufs - 1 : 0; assert(num_cbufs <= PIPE_MAX_COLOR_BUFS); - if (!ctx->fs_col[index]) - ctx->fs_col[index] = + if (!ctx->fs_col[num_cbufs]) + ctx->fs_col[num_cbufs] = util_make_fragment_clonecolor_shader(pipe, num_cbufs); - return ctx->fs_col[index]; + return ctx->fs_col[num_cbufs]; } static INLINE diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index 0de38e791d6..86db2c2e4b4 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -123,8 +123,12 @@ debug_get_bool_option(const char *name, boolean dfault) result = FALSE; else if(!util_strcmp(str, "f")) result = FALSE; + else if(!util_strcmp(str, "F")) + result = FALSE; else if(!util_strcmp(str, "false")) result = FALSE; + else if(!util_strcmp(str, "FALSE")) + result = FALSE; else result = TRUE; diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c b/src/gallium/auxiliary/util/u_debug_symbol.c index 417d0cf04c9..6e250575d66 100644 --- a/src/gallium/auxiliary/util/u_debug_symbol.c +++ b/src/gallium/auxiliary/util/u_debug_symbol.c @@ -67,21 +67,6 @@ BOOL WINAPI j_SymInitialize(HANDLE hProcess, PSTR UserSearchPath, BOOL fInvadePr return FALSE; } -typedef BOOL (WINAPI *PFNSYMCLEANUP)(HANDLE); -static PFNSYMCLEANUP pfnSymCleanup = NULL; - -static -BOOL WINAPI j_SymCleanup(HANDLE hProcess) -{ - if( - (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) && - (pfnSymCleanup || (pfnSymCleanup = (PFNSYMCLEANUP) GetProcAddress(hModule_Imagehlp, "SymCleanup"))) - ) - return pfnSymCleanup(hProcess); - else - return FALSE; -} - typedef DWORD (WINAPI *PFNSYMSETOPTIONS)(DWORD); static PFNSYMSETOPTIONS pfnSymSetOptions = NULL; @@ -97,36 +82,6 @@ DWORD WINAPI j_SymSetOptions(DWORD SymOptions) return FALSE; } -typedef BOOL (WINAPI *PFNSYMUNDNAME)(PIMAGEHLP_SYMBOL, PSTR, DWORD); -static PFNSYMUNDNAME pfnSymUnDName = NULL; - -static -BOOL WINAPI j_SymUnDName(PIMAGEHLP_SYMBOL Symbol, PSTR UnDecName, DWORD UnDecNameLength) -{ - if( - (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) && - (pfnSymUnDName || (pfnSymUnDName = (PFNSYMUNDNAME) GetProcAddress(hModule_Imagehlp, "SymUnDName"))) - ) - return pfnSymUnDName(Symbol, UnDecName, UnDecNameLength); - else - return FALSE; -} - -typedef PFUNCTION_TABLE_ACCESS_ROUTINE PFNSYMFUNCTIONTABLEACCESS; -static PFNSYMFUNCTIONTABLEACCESS pfnSymFunctionTableAccess = NULL; - -static -PVOID WINAPI j_SymFunctionTableAccess(HANDLE hProcess, DWORD AddrBase) -{ - if( - (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) && - (pfnSymFunctionTableAccess || (pfnSymFunctionTableAccess = (PFNSYMFUNCTIONTABLEACCESS) GetProcAddress(hModule_Imagehlp, "SymFunctionTableAccess"))) - ) - return pfnSymFunctionTableAccess(hProcess, AddrBase); - else - return NULL; -} - typedef PGET_MODULE_BASE_ROUTINE PFNSYMGETMODULEBASE; static PFNSYMGETMODULEBASE pfnSymGetModuleBase = NULL; @@ -142,41 +97,6 @@ DWORD WINAPI j_SymGetModuleBase(HANDLE hProcess, DWORD dwAddr) return 0; } -typedef BOOL (WINAPI *PFNSTACKWALK)(DWORD, HANDLE, HANDLE, LPSTACKFRAME, LPVOID, PREAD_PROCESS_MEMORY_ROUTINE, PFUNCTION_TABLE_ACCESS_ROUTINE, PGET_MODULE_BASE_ROUTINE, PTRANSLATE_ADDRESS_ROUTINE); -static PFNSTACKWALK pfnStackWalk = NULL; - -static -BOOL WINAPI j_StackWalk( - DWORD MachineType, - HANDLE hProcess, - HANDLE hThread, - LPSTACKFRAME StackFrame, - PVOID ContextRecord, - PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine, - PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine, - PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine, - PTRANSLATE_ADDRESS_ROUTINE TranslateAddress -) -{ - if( - (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) && - (pfnStackWalk || (pfnStackWalk = (PFNSTACKWALK) GetProcAddress(hModule_Imagehlp, "StackWalk"))) - ) - return pfnStackWalk( - MachineType, - hProcess, - hThread, - StackFrame, - ContextRecord, - ReadMemoryRoutine, - FunctionTableAccessRoutine, - GetModuleBaseRoutine, - TranslateAddress - ); - else - return FALSE; -} - typedef BOOL (WINAPI *PFNSYMGETSYMFROMADDR)(HANDLE, DWORD, LPDWORD, PIMAGEHLP_SYMBOL); static PFNSYMGETSYMFROMADDR pfnSymGetSymFromAddr = NULL; @@ -192,21 +112,6 @@ BOOL WINAPI j_SymGetSymFromAddr(HANDLE hProcess, DWORD Address, PDWORD Displacem return FALSE; } -typedef BOOL (WINAPI *PFNSYMGETLINEFROMADDR)(HANDLE, DWORD, LPDWORD, PIMAGEHLP_LINE); -static PFNSYMGETLINEFROMADDR pfnSymGetLineFromAddr = NULL; - -static -BOOL WINAPI j_SymGetLineFromAddr(HANDLE hProcess, DWORD dwAddr, PDWORD pdwDisplacement, PIMAGEHLP_LINE Line) -{ - if( - (hModule_Imagehlp || (hModule_Imagehlp = LoadLibraryA("IMAGEHLP.DLL"))) && - (pfnSymGetLineFromAddr || (pfnSymGetLineFromAddr = (PFNSYMGETLINEFROMADDR) GetProcAddress(hModule_Imagehlp, "SymGetLineFromAddr"))) - ) - return pfnSymGetLineFromAddr(hProcess, dwAddr, pdwDisplacement, Line); - else - return FALSE; -} - static INLINE boolean debug_symbol_print_imagehlp(const void *addr) diff --git a/src/gallium/auxiliary/util/u_dump.h b/src/gallium/auxiliary/util/u_dump.h index bdc73ac47d2..49536c0d593 100644 --- a/src/gallium/auxiliary/util/u_dump.h +++ b/src/gallium/auxiliary/util/u_dump.h @@ -71,9 +71,15 @@ const char * util_dump_blend_func(unsigned value, boolean shortened); const char * +util_dump_logicop(unsigned value, boolean shortened); + +const char * util_dump_func(unsigned value, boolean shortened); const char * +util_dump_stencil_op(unsigned value, boolean shortened); + +const char * util_dump_tex_target(unsigned value, boolean shortened); const char * diff --git a/src/gallium/auxiliary/util/u_dump_defines.c b/src/gallium/auxiliary/util/u_dump_defines.c index 96a22563473..692d4447c66 100644 --- a/src/gallium/auxiliary/util/u_dump_defines.c +++ b/src/gallium/auxiliary/util/u_dump_defines.c @@ -160,6 +160,49 @@ DEFINE_UTIL_DUMP_CONTINUOUS(blend_func) static const char * +util_dump_logicop_names[] = { + "PIPE_LOGICOP_CLEAR", + "PIPE_LOGICOP_NOR", + "PIPE_LOGICOP_AND_INVERTED", + "PIPE_LOGICOP_COPY_INVERTED", + "PIPE_LOGICOP_AND_REVERSE", + "PIPE_LOGICOP_INVERT", + "PIPE_LOGICOP_XOR", + "PIPE_LOGICOP_NAND", + "PIPE_LOGICOP_AND", + "PIPE_LOGICOP_EQUIV", + "PIPE_LOGICOP_NOOP", + "PIPE_LOGICOP_OR_INVERTED", + "PIPE_LOGICOP_COPY", + "PIPE_LOGICOP_OR_REVERSE", + "PIPE_LOGICOP_OR", + "PIPE_LOGICOP_SET" +}; + +static const char * +util_dump_logicop_short_names[] = { + "clear", + "nor", + "and_inverted", + "copy_inverted", + "and_reverse", + "invert", + "xor", + "nand", + "and", + "equiv", + "noop", + "or_inverted", + "copy", + "or_reverse", + "or", + "set" +}; + +DEFINE_UTIL_DUMP_CONTINUOUS(logicop) + + +static const char * util_dump_func_names[] = { "PIPE_FUNC_NEVER", "PIPE_FUNC_LESS", @@ -187,7 +230,35 @@ DEFINE_UTIL_DUMP_CONTINUOUS(func) static const char * +util_dump_stencil_op_names[] = { + "PIPE_STENCIL_OP_KEEP", + "PIPE_STENCIL_OP_ZERO", + "PIPE_STENCIL_OP_REPLACE", + "PIPE_STENCIL_OP_INCR", + "PIPE_STENCIL_OP_DECR", + "PIPE_STENCIL_OP_INCR_WRAP", + "PIPE_STENCIL_OP_DECR_WRAP", + "PIPE_STENCIL_OP_INVERT" +}; + +static const char * +util_dump_stencil_op_short_names[] = { + "keep", + "zero", + "replace", + "incr", + "decr", + "incr_wrap", + "decr_wrap", + "invert" +}; + +DEFINE_UTIL_DUMP_CONTINUOUS(stencil_op) + + +static const char * util_dump_tex_target_names[] = { + "PIPE_BUFFER", "PIPE_TEXTURE_1D", "PIPE_TEXTURE_2D", "PIPE_TEXTURE_3D", @@ -196,6 +267,7 @@ util_dump_tex_target_names[] = { static const char * util_dump_tex_target_short_names[] = { + "buffer", "1d", "2d", "3d", diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c index 2ce643e90cd..cda5b8ba512 100644 --- a/src/gallium/auxiliary/util/u_dump_state.c +++ b/src/gallium/auxiliary/util/u_dump_state.c @@ -300,12 +300,13 @@ util_dump_rasterizer_state(struct os_stream *stream, const struct pipe_rasterize util_dump_member(stream, bool, state, flatshade); util_dump_member(stream, bool, state, light_twoside); - util_dump_member(stream, uint, state, front_winding); - util_dump_member(stream, uint, state, cull_mode); - util_dump_member(stream, uint, state, fill_cw); - util_dump_member(stream, uint, state, fill_ccw); - util_dump_member(stream, bool, state, offset_cw); - util_dump_member(stream, bool, state, offset_ccw); + util_dump_member(stream, uint, state, front_ccw); + util_dump_member(stream, uint, state, cull_face); + util_dump_member(stream, uint, state, fill_front); + util_dump_member(stream, uint, state, fill_back); + util_dump_member(stream, bool, state, offset_point); + util_dump_member(stream, bool, state, offset_line); + util_dump_member(stream, bool, state, offset_tri); util_dump_member(stream, bool, state, scissor); util_dump_member(stream, bool, state, poly_smooth); util_dump_member(stream, bool, state, poly_stipple_enable); diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 8ba076949b6..fd95bea1a7b 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -367,6 +367,26 @@ util_format_is_plain(enum pipe_format format) } static INLINE boolean +util_format_is_compressed(enum pipe_format format) +{ + const struct util_format_description *desc = util_format_description(format); + + assert(desc); + if (!desc) { + return FALSE; + } + + switch (desc->layout) { + case UTIL_FORMAT_LAYOUT_S3TC: + case UTIL_FORMAT_LAYOUT_RGTC: + /* XXX add other formats in the future */ + return TRUE; + default: + return FALSE; + } +} + +static INLINE boolean util_format_is_s3tc(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index 0c1bbc84c17..6d0016c0ad8 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -37,9 +37,6 @@ ''' -import sys -import math - from u_format_parse import * diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index 7076c676aaf..ddb9f2443d9 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -43,7 +43,7 @@ ZS = 'zs' def is_pot(x): - return (x & (x - 1)) == 0; + return (x & (x - 1)) == 0 VERY_LARGE = 99999999999999999999999 diff --git a/src/gallium/auxiliary/util/u_format_srgb.py b/src/gallium/auxiliary/util/u_format_srgb.py index a4c76dc00b3..3e8000f3687 100644 --- a/src/gallium/auxiliary/util/u_format_srgb.py +++ b/src/gallium/auxiliary/util/u_format_srgb.py @@ -39,7 +39,6 @@ ''' -import sys import math diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 48ee0427261..d19267be72f 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1295,8 +1295,7 @@ util_create_gen_mipmap(struct pipe_context *pipe, /* rasterizer */ memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer)); - ctx->rasterizer.front_winding = PIPE_WINDING_CW; - ctx->rasterizer.cull_mode = PIPE_WINDING_NONE; + ctx->rasterizer.cull_face = PIPE_FACE_NONE; ctx->rasterizer.gl_rasterization_rules = 1; /* sampler state */ diff --git a/src/gallium/auxiliary/util/u_half.py b/src/gallium/auxiliary/util/u_half.py index 8007482e971..915cf3b9273 100644 --- a/src/gallium/auxiliary/util/u_half.py +++ b/src/gallium/auxiliary/util/u_half.py @@ -83,11 +83,11 @@ for i in xrange(1, 1024): # normalize number while (m & 0x00800000) == 0: - e -= 0x00800000; - m <<= 1; + e -= 0x00800000 + m <<= 1 - m &= ~0x00800000; - e += 0x38800000; + m &= ~0x00800000 + e += 0x38800000 value(m | e) # normals diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index a48689ee8be..540305c1465 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -369,6 +369,24 @@ pipe_transfer_destroy( struct pipe_context *context, } +static INLINE boolean util_get_offset( + const struct pipe_rasterizer_state *templ, + unsigned fill_mode) +{ + switch(fill_mode) { + case PIPE_POLYGON_MODE_POINT: + return templ->offset_point; + case PIPE_POLYGON_MODE_LINE: + return templ->offset_line; + case PIPE_POLYGON_MODE_FILL: + return templ->offset_tri; + default: + assert(0); + return FALSE; + } +} + + #ifdef __cplusplus } #endif diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index 6f49a723557..9adf22c471e 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -38,7 +38,6 @@ #include "util/u_format.h" #include "util/u_inlines.h" -#include "util/u_memory.h" #include "util/u_rect.h" #include "util/u_surface.h" diff --git a/src/gallium/auxiliary/util/u_surfaces.c b/src/gallium/auxiliary/util/u_surfaces.c index 668da8c5c27..b5d21570d57 100644 --- a/src/gallium/auxiliary/util/u_surfaces.c +++ b/src/gallium/auxiliary/util/u_surfaces.c @@ -28,7 +28,7 @@ util_surfaces_do_get(struct util_surfaces *us, unsigned surface_struct_size, str { /* or 2D array */ if(!us->u.table) us->u.table = util_hash_table_create(hash, compare); - key = (void *)(((zslice + face) << 8) | level); + key = (void *)(uintptr_t)(((zslice + face) << 8) | level); /* TODO: ouch, should have a get-reference function... * also, shouldn't allocate a two-pointer structure for each item... */ ps = util_hash_table_get(us->u.table, key); diff --git a/src/gallium/auxiliary/util/u_transfer.c b/src/gallium/auxiliary/util/u_transfer.c index bedace3b1dc..69f6fab9504 100644 --- a/src/gallium/auxiliary/util/u_transfer.c +++ b/src/gallium/auxiliary/util/u_transfer.c @@ -35,12 +35,12 @@ void u_default_transfer_inline_write( struct pipe_context *pipe, util_copy_rect(map, resource->format, - transfer->stride, /* bytes? */ + transfer->stride, /* bytes */ 0, 0, box->width, box->height, data, - box->width, /* bytes? texels? */ + stride, /* bytes */ 0, 0); out: diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index ac3c3c7bdbd..89c02b1b703 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -201,9 +201,16 @@ returned). Otherwise, if the ``wait`` parameter is FALSE, the call will not block and the return value will be TRUE if the query has completed or FALSE otherwise. -A common type of query is the occlusion query which counts the number of -fragments/pixels which are written to the framebuffer (and not culled by -Z/stencil/alpha testing or shader KILL instructions). +The most common type of query is the occlusion query, +``PIPE_QUERY_OCCLUSION_COUNTER``, which counts the number of fragments which +are written to the framebuffer without being culled by +:ref:`Depth, Stencil, & Alpha` testing or shader KILL instructions. + +Another type of query, ``PIPE_QUERY_TIME_ELAPSED``, returns the amount of +time, in nanoseconds, the context takes to perform operations. + +Gallium does not guarantee the availability of any query types; one must +always check the capabilities of the :ref:`Screen` first. Conditional Rendering @@ -289,11 +296,6 @@ data to be written to the resource at this point. The returned map points to the start of the mapped range according to the box region, not the beginning of the resource. -.. _transfer_flush_region: -``transfer_flush_region`` If a transfer was created with TRANFER_FLUSH_EXPLICIT, -only the region specified is guaranteed to be written to. This is relative to -the mapped range, not the beginning of the resource. - ``transfer_unmap`` remove the memory mapping for the transfer object. Any pointers into the map should be considered invalid and discarded. @@ -301,6 +303,16 @@ Any pointers into the map should be considered invalid and discarded. Basically get_transfer, transfer_map, data write, transfer_unmap, and transfer_destroy all in one. +.. _transfer_flush_region: + +transfer_flush_region +%%%%%%%%%%%%%%%%%%%%% + +If a transfer was created with ``FLUSH_EXPLICIT``, it will not automatically +be flushed on write or unmap. Flushes must be requested with +``transfer_flush_region``. Flush ranges are relative to the mapped range, not +the beginning of the resource. + .. _pipe_transfer: PIPE_TRANSFER @@ -320,5 +332,4 @@ These flags control the behavior of a transfer object. operations pending on the resource are undefined. Cannot be used with ``READ``. * ``FLUSH_EXPLICIT``: Written ranges will be notified later with - :ref:`transfer_flush_region`. Cannot be used with - ``READ``. + :ref:`transfer_flush_region`. Cannot be used with ``READ``. diff --git a/src/gallium/docs/source/cso/rasterizer.rst b/src/gallium/docs/source/cso/rasterizer.rst index 56a601a8d06..ad1612f93e3 100644 --- a/src/gallium/docs/source/cso/rasterizer.rst +++ b/src/gallium/docs/source/cso/rasterizer.rst @@ -46,6 +46,78 @@ There are several important exceptions to the specification of this rule. second vertex, not the first. This permits each segment of the fan to have a different color. +Polygons +-------- + +light_twoside +^^^^^^^^^^^^^ + +If set, there are per-vertex back-facing colors. The hardware +(perhaps assisted by :ref:`Draw`) should be set up to use this state +along with the front/back information to set the final vertex colors +prior to rasterization. + +The frontface vertex shader color output is marked with TGSI semantic +COLOR[0], and backface COLOR[1]. + +front_ccw + Indicates whether the window order of front-facing polygons is + counter-clockwise (TRUE) or clockwise (FALSE). + +cull_mode + Indicates which faces of polygons to cull, either PIPE_FACE_NONE + (cull no polygons), PIPE_FACE_FRONT (cull front-facing polygons), + PIPE_FACE_BACK (cull back-facing polygons), or + PIPE_FACE_FRONT_AND_BACK (cull all polygons). + +fill_front + Indicates how to fill front-facing polygons, either + PIPE_POLYGON_MODE_FILL, PIPE_POLYGON_MODE_LINE or + PIPE_POLYGON_MODE_POINT. +fill_back + Indicates how to fill back-facing polygons, either + PIPE_POLYGON_MODE_FILL, PIPE_POLYGON_MODE_LINE or + PIPE_POLYGON_MODE_POINT. + +poly_stipple_enable + Whether polygon stippling is enabled. +poly_smooth + Controls OpenGL-style polygon smoothing/antialiasing + +offset_point + If set, point-filled polygons will have polygon offset factors applied +offset_line + If set, line-filled polygons will have polygon offset factors applied +offset_tri + If set, filled polygons will have polygon offset factors applied + +offset_units + Specifies the polygon offset bias +offset_scale + Specifies the polygon offset scale + + + +Lines +----- + +line_width + The width of lines. +line_smooth + Whether lines should be smoothed. Line smoothing is simply anti-aliasing. +line_stipple_enable + Whether line stippling is enabled. +line_stipple_pattern + 16-bit bitfield of on/off flags, used to pattern the line stipple. +line_stipple_factor + When drawing a stippled line, each bit in the stipple pattern is + repeated N times, where N = line_stipple_factor + 1. +line_last_pixel + Controls whether the last pixel in a line is drawn or not. OpenGL + omits the last pixel to avoid double-drawing pixels at the ends of lines + when drawing connected lines. + + Points ------ @@ -89,68 +161,21 @@ coordinates are not generated. Some renderers always internally translate points into quads; this state still affects those renderers by overriding other rasterization state. -Other Members -^^^^^^^^^^^^^ - -light_twoside - If set, there are per-vertex back-facing colors. :ref:`Draw` - uses this state along with the front/back information to set the - final vertex colors prior to rasterization. - -front_winding - Indicates the window order of front-facing polygons, either - PIPE_WINDING_CW or PIPE_WINDING_CCW - -cull_mode - Indicates which polygons to cull, either PIPE_WINDING_NONE (cull no - polygons), PIPE_WINDING_CW (cull clockwise-winding polygons), - PIPE_WINDING_CCW (cull counter clockwise-winding polygons), or - PIPE_WINDING_BOTH (cull all polygons). - -fill_cw - Indicates how to fill clockwise polygons, either PIPE_POLYGON_MODE_FILL, - PIPE_POLYGON_MODE_LINE or PIPE_POLYGON_MODE_POINT. -fill_ccw - Indicates how to fill counter clockwise polygons, either - PIPE_POLYGON_MODE_FILL, PIPE_POLYGON_MODE_LINE or PIPE_POLYGON_MODE_POINT. - -poly_stipple_enable - Whether polygon stippling is enabled. -poly_smooth - Controls OpenGL-style polygon smoothing/antialiasing -offset_cw - If set, clockwise polygons will have polygon offset factors applied -offset_ccw - If set, counter clockwise polygons will have polygon offset factors applied -offset_units - Specifies the polygon offset bias -offset_scale - Specifies the polygon offset scale - -line_width - The width of lines. -line_smooth - Whether lines should be smoothed. Line smoothing is simply anti-aliasing. -line_stipple_enable - Whether line stippling is enabled. -line_stipple_pattern - 16-bit bitfield of on/off flags, used to pattern the line stipple. -line_stipple_factor - When drawing a stippled line, each bit in the stipple pattern is - repeated N times, where N = line_stipple_factor + 1. -line_last_pixel - Controls whether the last pixel in a line is drawn or not. OpenGL - omits the last pixel to avoid double-drawing pixels at the ends of lines - when drawing connected lines. - point_smooth Whether points should be smoothed. Point smoothing turns rectangular points into circles or ovals. point_size_per_vertex - Whether vertices have a point size element. + Whether the vertex shader is expected to have a point size output. + Undefined behaviour is permitted if there is disagreement between + this flag and the actual bound shader. point_size The size of points, if not specified per-vertex. + + +Other Members +------------- + scissor Whether the scissor test is enabled. diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 5a60ee00a69..48d9d570b6f 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -1,3 +1,5 @@ +.. _screen: + Screen ====== @@ -33,6 +35,7 @@ The integer capabilities: * ``MAX_RENDER_TARGETS``: The maximum number of render targets that may be bound. * ``OCCLUSION_QUERY``: Whether occlusion queries are available. +* ``TIMER_QUERY``: Whether timer queries are available. * ``TEXTURE_SHADOW_MAP``: XXX * ``MAX_TEXTURE_2D_LEVELS``: The maximum number of mipmap levels available for a 2D texture. @@ -101,6 +104,22 @@ The floating-point capabilities: * ``GUARD_BAND_LEFT``, ``GUARD_BAND_TOP``, ``GUARD_BAND_RIGHT``, ``GUARD_BAND_BOTTOM``: XXX +Fragment shader limits: + +* ``PIPE_CAP_MAX_FS_INSTRUCTIONS``: The maximum number of instructions. +* ``PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS``: The maximum number of arithmetic instructions. +* ``PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS``: The maximum number of texture instructions. +* ``PIPE_CAP_MAX_FS_TEX_INDIRECTIONS``: The maximum number of texture indirections. +* ``PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH``: The maximum nested control flow depth. +* ``PIPE_CAP_MAX_FS_INPUTS``: The maximum number of input registers. +* ``PIPE_CAP_MAX_FS_CONSTS``: The maximum number of constants. +* ``PIPE_CAP_MAX_FS_TEMPS``: The maximum number of temporary registers. +* ``PIPE_CAP_MAX_FS_ADDRS``: The maximum number of address registers. +* ``PIPE_CAP_MAX_FS_PREDS``: The maximum number of predicate registers. + +Vertex shader limits: + +* ``PIPE_CAP_MAX_VS_*``: Identical to ``PIPE_CAP_MAX_FS_*``. .. _pipe_bind: diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c index 49cece58b8f..411f204f15a 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.c +++ b/src/gallium/drivers/cell/ppu/cell_context.c @@ -73,7 +73,7 @@ cell_destroy_context( struct pipe_context *pipe ) static struct draw_context * cell_draw_create(struct cell_context *cell) { - struct draw_context *draw = draw_create(); + struct draw_context *draw = draw_create(&cell->pipe); #if 0 /* broken */ if (getenv("GALLIUM_CELL_VS")) { diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c index b50a30bee80..6a1e4d8a646 100644 --- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c +++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c @@ -103,7 +103,7 @@ cell_draw_range_elements(struct pipe_context *pipe, draw_set_mapped_vertex_buffer(draw, i, NULL); } if (indexBuffer) { - draw_set_mapped_element_buffer(draw, 0, NULL); + draw_set_mapped_element_buffer(draw, 0, 0, NULL); } /* @@ -122,7 +122,7 @@ cell_draw_elements(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { cell_draw_range_elements( pipe, indexBuffer, - indexSize, indeBias, + indexSize, indexBias, 0, 0xffffffff, mode, start, count ); } diff --git a/src/gallium/drivers/cell/ppu/cell_fence.c b/src/gallium/drivers/cell/ppu/cell_fence.c index eac798e8cf6..34ca864155b 100644 --- a/src/gallium/drivers/cell/ppu/cell_fence.c +++ b/src/gallium/drivers/cell/ppu/cell_fence.c @@ -123,7 +123,7 @@ cell_free_fenced_buffers(struct cell_context *cell, while (node) { struct cell_buffer_node *next = node->next; assert(node->buffer); - pipe_buffer_unmap(ps, node->buffer); + /* XXX need this? pipe_buffer_unmap(ps, node->buffer);*/ #if 0 printf("Unref buffer %p\n", node->buffer); if (node->buffer->reference.count == 1) diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c index ecc9de4df66..03f84d295b5 100644 --- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c +++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c @@ -204,7 +204,7 @@ cell_bind_rasterizer_state(struct pipe_context *pipe, void *rast) struct cell_context *cell = cell_context(pipe); /* pass-through to draw module */ - draw_set_rasterizer_state(cell->draw, rasterizer); + draw_set_rasterizer_state(cell->draw, rasterizer, rast); cell->rasterizer = rasterizer; diff --git a/src/gallium/drivers/cell/ppu/cell_render.c b/src/gallium/drivers/cell/ppu/cell_render.c index 79cb8df82fa..f648482c551 100644 --- a/src/gallium/drivers/cell/ppu/cell_render.c +++ b/src/gallium/drivers/cell/ppu/cell_render.c @@ -152,7 +152,7 @@ cell_flush_prim_buffer(struct cell_context *cell) struct cell_command_render *render = &cell_global.command[i].render; render->prim_type = PIPE_PRIM_TRIANGLES; render->num_verts = cell->prim_buffer.num_verts; - render->front_winding = cell->rasterizer->front_winding; + render->front_ccw = cell->rasterizer->front_ccw; render->vertex_size = cell->vertex_info->size * 4; render->xmin = cell->prim_buffer.xmin; render->ymin = cell->prim_buffer.ymin; diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c index 9bb3abfc9dd..0f12e0667eb 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.c +++ b/src/gallium/drivers/cell/ppu/cell_screen.c @@ -55,7 +55,7 @@ cell_get_name(struct pipe_screen *screen) static int -cell_get_param(struct pipe_screen *screen, int param) +cell_get_param(struct pipe_screen *screen, enum pipe_cap param) { switch (param) { case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: @@ -76,6 +76,8 @@ cell_get_param(struct pipe_screen *screen, int param) return 1; case PIPE_CAP_OCCLUSION_QUERY: return 1; + case PIPE_CAP_TIMER_QUERY: + return 0; case PIPE_CAP_TEXTURE_SHADOW_MAP: return 10; case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: @@ -105,7 +107,7 @@ cell_get_param(struct pipe_screen *screen, int param) static float -cell_get_paramf(struct pipe_screen *screen, int param) +cell_get_paramf(struct pipe_screen *screen, enum pipe_cap param) { switch (param) { case PIPE_CAP_MAX_LINE_WIDTH: diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c index d08334d892b..b3042df7792 100644 --- a/src/gallium/drivers/cell/ppu/cell_texture.c +++ b/src/gallium/drivers/cell/ppu/cell_texture.c @@ -34,7 +34,7 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "util/u_inlines.h" - +#include "util/u_transfer.h" #include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" @@ -42,7 +42,7 @@ #include "cell_context.h" #include "cell_screen.h" #include "cell_state.h" -#include "cell_resource.h" +#include "cell_texture.h" #include "state_tracker/sw_winsys.h" @@ -155,9 +155,9 @@ fail: static void -cell_resource_destroy(struct pipe_resource *pt) +cell_resource_destroy(struct pipe_screen *scrn, struct pipe_resource *pt) { - struct cell_screen *screen = cell_screen(pt->screen); + struct cell_screen *screen = cell_screen(scrn); struct sw_winsys *winsys = screen->winsys; struct cell_resource *ct = cell_resource(pt); @@ -365,10 +365,10 @@ cell_get_transfer(struct pipe_context *ctx, { struct cell_resource *ct = cell_resource(resource); struct cell_transfer *ctrans; - enum pipe_format *format = resource->format; + enum pipe_format format = resource->format; assert(resource); - assert(level <= resource->last_level); + assert(sr.level <= resource->last_level); /* make sure the requested region is in the image bounds */ assert(box->x + box->width <= u_minify(resource->width0, sr.level)); @@ -612,6 +612,24 @@ cell_user_buffer_create(struct pipe_screen *screen, } +static struct pipe_resource * +cell_resource_from_handle(struct pipe_screen *screen, + const struct pipe_resource *templat, + struct winsys_handle *handle) +{ + /* XXX todo */ + return NULL; +} + + +static boolean +cell_resource_get_handle(struct pipe_screen *scree, + struct pipe_resource *tex, + struct winsys_handle *handle) +{ + /* XXX todo */ + return FALSE; +} void @@ -630,7 +648,7 @@ cell_init_screen_texture_funcs(struct pipe_screen *screen) } void -cell_init_transfer_funcs(struct cell_context *cell) +cell_init_texture_transfer_funcs(struct cell_context *cell) { cell->pipe.get_transfer = cell_get_transfer; cell->pipe.transfer_destroy = cell_transfer_destroy; diff --git a/src/gallium/drivers/cell/ppu/cell_vbuf.c b/src/gallium/drivers/cell/ppu/cell_vbuf.c index cfaffb52a85..37b71956482 100644 --- a/src/gallium/drivers/cell/ppu/cell_vbuf.c +++ b/src/gallium/drivers/cell/ppu/cell_vbuf.c @@ -165,9 +165,9 @@ cell_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim) static void -cell_vbuf_draw(struct vbuf_render *vbr, - const ushort *indices, - uint nr_indices) +cell_vbuf_draw_elements(struct vbuf_render *vbr, + const ushort *indices, + uint nr_indices) { struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr); struct cell_context *cell = cvbr->cell; @@ -319,7 +319,7 @@ cell_init_vbuf(struct cell_context *cell) cell->vbuf_render->base.map_vertices = cell_vbuf_map_vertices; cell->vbuf_render->base.unmap_vertices = cell_vbuf_unmap_vertices; cell->vbuf_render->base.set_primitive = cell_vbuf_set_primitive; - cell->vbuf_render->base.draw = cell_vbuf_draw; + cell->vbuf_render->base.draw_elements = cell_vbuf_draw_elements; cell->vbuf_render->base.release_vertices = cell_vbuf_release_vertices; cell->vbuf_render->base.destroy = cell_vbuf_destroy; diff --git a/src/gallium/drivers/cell/spu/spu_tri.c b/src/gallium/drivers/cell/spu/spu_tri.c index f619380d807..efeebca27bb 100644 --- a/src/gallium/drivers/cell/spu/spu_tri.c +++ b/src/gallium/drivers/cell/spu/spu_tri.c @@ -568,7 +568,7 @@ setup_sort_vertices(const qword vs) ASSERT(CELL_FACING_FRONT == 0); ASSERT(CELL_FACING_BACK == 1); setup.facing = (area * sign > 0.0f) - ^ (spu.rasterizer.front_winding == PIPE_WINDING_CW); + ^ (!spu.rasterizer.front_ccw); return TRUE; } diff --git a/src/gallium/drivers/i915/i915_prim_vbuf.c b/src/gallium/drivers/i915/i915_prim_vbuf.c index df9e68af4fc..f8665acbe18 100644 --- a/src/gallium/drivers/i915/i915_prim_vbuf.c +++ b/src/gallium/drivers/i915/i915_prim_vbuf.c @@ -544,9 +544,9 @@ draw_calc_nr_indices(uint nr_indices, unsigned type) } static void -i915_vbuf_render_draw(struct vbuf_render *render, - const ushort *indices, - uint nr_indices) +i915_vbuf_render_draw_elements(struct vbuf_render *render, + const ushort *indices, + uint nr_indices) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); struct i915_context *i915 = i915_render->i915; @@ -638,7 +638,7 @@ i915_vbuf_render_create(struct i915_context *i915) i915_render->base.map_vertices = i915_vbuf_render_map_vertices; i915_render->base.unmap_vertices = i915_vbuf_render_unmap_vertices; i915_render->base.set_primitive = i915_vbuf_render_set_primitive; - i915_render->base.draw = i915_vbuf_render_draw; + i915_render->base.draw_elements = i915_vbuf_render_draw_elements; i915_render->base.draw_arrays = i915_vbuf_render_draw_arrays; i915_render->base.release_vertices = i915_vbuf_render_release_vertices; i915_render->base.destroy = i915_vbuf_render_destroy; diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index c10ba25d2d5..0897a863dbd 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -90,7 +90,7 @@ i915_get_name(struct pipe_screen *screen) } static int -i915_get_param(struct pipe_screen *screen, int param) +i915_get_param(struct pipe_screen *screen, enum pipe_cap param) { switch (param) { case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: @@ -113,6 +113,8 @@ i915_get_param(struct pipe_screen *screen, int param) return 1; case PIPE_CAP_OCCLUSION_QUERY: return 0; + case PIPE_CAP_TIMER_QUERY: + return 0; case PIPE_CAP_TEXTURE_SHADOW_MAP: return 1; case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: @@ -133,7 +135,7 @@ i915_get_param(struct pipe_screen *screen, int param) } static float -i915_get_paramf(struct pipe_screen *screen, int param) +i915_get_paramf(struct pipe_screen *screen, enum pipe_cap param) { switch (param) { case PIPE_CAP_MAX_LINE_WIDTH: diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index e008195a910..e767aa9f8f0 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -686,17 +686,23 @@ i915_create_rasterizer_state(struct pipe_context *pipe, else cso->sc[0] = _3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT; - switch (rasterizer->cull_mode) { - case PIPE_WINDING_NONE: + switch (rasterizer->cull_face) { + case PIPE_FACE_NONE: cso->LIS4 |= S4_CULLMODE_NONE; break; - case PIPE_WINDING_CW: - cso->LIS4 |= S4_CULLMODE_CW; + case PIPE_FACE_FRONT: + if (rasterizer->front_ccw) + cso->LIS4 |= S4_CULLMODE_CCW; + else + cso->LIS4 |= S4_CULLMODE_CW; break; - case PIPE_WINDING_CCW: - cso->LIS4 |= S4_CULLMODE_CCW; + case PIPE_FACE_BACK: + if (rasterizer->front_ccw) + cso->LIS4 |= S4_CULLMODE_CW; + else + cso->LIS4 |= S4_CULLMODE_CCW; break; - case PIPE_WINDING_BOTH: + case PIPE_FACE_FRONT_AND_BACK: cso->LIS4 |= S4_CULLMODE_BOTH; break; } diff --git a/src/gallium/drivers/i965/SConscript b/src/gallium/drivers/i965/SConscript index 85c4d7ed22e..019af682f68 100644 --- a/src/gallium/drivers/i965/SConscript +++ b/src/gallium/drivers/i965/SConscript @@ -50,7 +50,7 @@ i965 = env.ConvenienceLibrary( 'brw_sf_state.c', 'brw_state_batch.c', 'brw_state_cache.c', -# 'brw_state_debug.c', + 'brw_state_debug.c', 'brw_state_upload.c', 'brw_swtnl.c', 'brw_urb.c', diff --git a/src/gallium/drivers/i965/brw_batchbuffer.c b/src/gallium/drivers/i965/brw_batchbuffer.c index 003b1fd5bf0..8b3f46f2c16 100644 --- a/src/gallium/drivers/i965/brw_batchbuffer.c +++ b/src/gallium/drivers/i965/brw_batchbuffer.c @@ -161,7 +161,7 @@ brw_batchbuffer_emit_reloc(struct brw_batchbuffer *batch, int ret; if (batch->ptr - batch->map > batch->buf->size) { - debug_printf("bad relocation ptr %p map %p offset %d size %d\n", + debug_printf("bad relocation ptr %p map %p offset %li size %i\n", batch->ptr, batch->map, batch->ptr - batch->map, batch->buf->size); return PIPE_ERROR_OUT_OF_MEMORY; diff --git a/src/gallium/drivers/i965/brw_pipe_rast.c b/src/gallium/drivers/i965/brw_pipe_rast.c index 2117e91a9e4..4c1a6d7dcdf 100644 --- a/src/gallium/drivers/i965/brw_pipe_rast.c +++ b/src/gallium/drivers/i965/brw_pipe_rast.c @@ -42,7 +42,7 @@ calculate_clip_key_rast( const struct brw_context *brw, key->do_flat_shading = templ->flatshade; - if (templ->cull_mode == PIPE_WINDING_BOTH) { + if (templ->cull_face == PIPE_FACE_FRONT_AND_BACK) { key->clip_mode = BRW_CLIPMODE_REJECT_ALL; return; } @@ -50,12 +50,18 @@ calculate_clip_key_rast( const struct brw_context *brw, key->fill_ccw = CLIP_CULL; key->fill_cw = CLIP_CULL; - if (!(templ->cull_mode & PIPE_WINDING_CCW)) { - key->fill_ccw = translate_fill(templ->fill_ccw); + if (!(templ->cull_face & PIPE_FACE_FRONT)) { + if (templ->front_ccw) + key->fill_ccw = translate_fill(templ->fill_front); + else + key->fill_cw = translate_fill(templ->fill_front); } - if (!(templ->cull_mode & PIPE_WINDING_CW)) { - key->fill_cw = translate_fill(templ->fill_cw); + if (!(templ->cull_face & PIPE_FACE_BACK)) { + if (templ->front_ccw) + key->fill_cw = translate_fill(templ->fill_back); + else + key->fill_ccw = translate_fill(templ->fill_back); } if (key->fill_cw == CLIP_LINE || @@ -66,8 +72,29 @@ calculate_clip_key_rast( const struct brw_context *brw, key->clip_mode = BRW_CLIPMODE_CLIP_NON_REJECTED; } - key->offset_ccw = templ->offset_ccw; - key->offset_cw = templ->offset_cw; + switch (key->fill_cw) { + case CLIP_POINT: + key->offset_cw = templ->offset_point; + break; + case CLIP_LINE: + key->offset_cw = templ->offset_line; + break; + case CLIP_FILL: + key->offset_cw = templ->offset_tri; + break; + } + + switch (key->fill_ccw) { + case CLIP_POINT: + key->offset_ccw = templ->offset_point; + break; + case CLIP_LINE: + key->offset_ccw = templ->offset_line; + break; + case CLIP_FILL: + key->offset_ccw = templ->offset_tri; + break; + } if (templ->light_twoside && key->fill_cw != CLIP_CULL) key->copy_bfc_cw = 1; @@ -111,12 +138,12 @@ static void *brw_create_rasterizer_state( struct pipe_context *pipe, /* Caclculate lookup value for WM IZ table. */ if (templ->line_smooth) { - if (templ->fill_cw == PIPE_POLYGON_MODE_LINE && - templ->fill_ccw == PIPE_POLYGON_MODE_LINE) { + if (templ->fill_front == PIPE_POLYGON_MODE_LINE && + templ->fill_back == PIPE_POLYGON_MODE_LINE) { rast->unfilled_aa_line = AA_ALWAYS; } - else if (templ->fill_cw == PIPE_POLYGON_MODE_LINE || - templ->fill_ccw == PIPE_POLYGON_MODE_LINE) { + else if (templ->fill_front == PIPE_POLYGON_MODE_LINE || + templ->fill_back == PIPE_POLYGON_MODE_LINE) { rast->unfilled_aa_line = AA_SOMETIMES; } else { diff --git a/src/gallium/drivers/i965/brw_resource.c b/src/gallium/drivers/i965/brw_resource.c index 3b9854be588..1efdb1e0b4d 100644 --- a/src/gallium/drivers/i965/brw_resource.c +++ b/src/gallium/drivers/i965/brw_resource.c @@ -13,7 +13,7 @@ brw_resource_create(struct pipe_screen *screen, if (template->target == PIPE_BUFFER) return brw_buffer_create(screen, template); else - return brw_resource_create(screen, template); + return brw_texture_create(screen, template); } diff --git a/src/gallium/drivers/i965/brw_resource_texture.c b/src/gallium/drivers/i965/brw_resource_texture.c index 4fbb0c2484d..ffd0f38672c 100644 --- a/src/gallium/drivers/i965/brw_resource_texture.c +++ b/src/gallium/drivers/i965/brw_resource_texture.c @@ -210,7 +210,7 @@ brw_texture_get_handle(struct pipe_screen *screen, stride = tex->pitch * tex->cpp; - return bscreen->sws->bo_get_handle(tex->bo, whandle, stride); + return bscreen->sws->bo_get_handle(tex->bo, whandle, stride) == PIPE_OK; } diff --git a/src/gallium/drivers/i965/brw_screen.c b/src/gallium/drivers/i965/brw_screen.c index 172e222c057..7a7b9c1a5a9 100644 --- a/src/gallium/drivers/i965/brw_screen.c +++ b/src/gallium/drivers/i965/brw_screen.c @@ -149,7 +149,7 @@ brw_get_name(struct pipe_screen *screen) } static int -brw_get_param(struct pipe_screen *screen, int param) +brw_get_param(struct pipe_screen *screen, enum pipe_cap param) { switch (param) { case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: @@ -172,6 +172,8 @@ brw_get_param(struct pipe_screen *screen, int param) return 1; case PIPE_CAP_OCCLUSION_QUERY: return 0; + case PIPE_CAP_TIMER_QUERY: + return 0; case PIPE_CAP_TEXTURE_SHADOW_MAP: return 1; case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: @@ -192,7 +194,7 @@ brw_get_param(struct pipe_screen *screen, int param) } static float -brw_get_paramf(struct pipe_screen *screen, int param) +brw_get_paramf(struct pipe_screen *screen, enum pipe_cap param) { switch (param) { case PIPE_CAP_MAX_LINE_WIDTH: diff --git a/src/gallium/drivers/i965/brw_sf.c b/src/gallium/drivers/i965/brw_sf.c index 9cceb4dbe52..5abf3848ab4 100644 --- a/src/gallium/drivers/i965/brw_sf.c +++ b/src/gallium/drivers/i965/brw_sf.c @@ -166,8 +166,8 @@ static enum pipe_error upload_sf_prog(struct brw_context *brw) case PIPE_PRIM_TRIANGLES: /* PIPE_NEW_RAST */ - if (rast->fill_cw != PIPE_POLYGON_MODE_FILL || - rast->fill_ccw != PIPE_POLYGON_MODE_FILL) + if (rast->fill_front != PIPE_POLYGON_MODE_FILL || + rast->fill_back != PIPE_POLYGON_MODE_FILL) key.primitive = SF_UNFILLED_TRIS; else key.primitive = SF_TRIANGLES; @@ -187,7 +187,7 @@ static enum pipe_error upload_sf_prog(struct brw_context *brw) key.do_twoside_color = rast->light_twoside; if (key.do_twoside_color) { - key.frontface_ccw = (rast->front_winding == PIPE_WINDING_CCW); + key.frontface_ccw = rast->front_ccw; } if (brw_search_cache(&brw->cache, BRW_SF_PROG, diff --git a/src/gallium/drivers/i965/brw_sf_state.c b/src/gallium/drivers/i965/brw_sf_state.c index 0ad91e03072..6c299a86b49 100644 --- a/src/gallium/drivers/i965/brw_sf_state.c +++ b/src/gallium/drivers/i965/brw_sf_state.c @@ -89,8 +89,8 @@ struct brw_sf_unit_key { unsigned line_smooth:1; unsigned point_sprite:1; unsigned point_attenuated:1; - unsigned front_face:2; - unsigned cull_mode:2; + unsigned front_ccw:1; + unsigned cull_face:2; unsigned flatshade_first:1; unsigned gl_rasterization_rules:1; unsigned line_last_pixel_enable:1; @@ -115,8 +115,8 @@ sf_unit_populate_key(struct brw_context *brw, struct brw_sf_unit_key *key) /* PIPE_NEW_RAST */ key->scissor = rast->scissor; - key->front_face = rast->front_winding; - key->cull_mode = rast->cull_mode; + key->front_ccw = rast->front_ccw; + key->cull_face = rast->cull_face; key->line_smooth = rast->line_smooth; key->line_width = rast->line_width; key->flatshade_first = rast->flatshade_first; @@ -183,22 +183,22 @@ sf_unit_create_from_key(struct brw_context *brw, if (key->scissor) sf.sf6.scissor = 1; - if (key->front_face == PIPE_WINDING_CCW) + if (key->front_ccw) sf.sf5.front_winding = BRW_FRONTWINDING_CCW; else sf.sf5.front_winding = BRW_FRONTWINDING_CW; - switch (key->cull_mode) { - case PIPE_WINDING_CCW: - case PIPE_WINDING_CW: - sf.sf6.cull_mode = (key->front_face == key->cull_mode ? - BRW_CULLMODE_FRONT : - BRW_CULLMODE_BACK); + switch (key->cull_face) { + case PIPE_FACE_FRONT: + sf.sf6.cull_mode = BRW_CULLMODE_FRONT; break; - case PIPE_WINDING_BOTH: + case PIPE_FACE_BACK: + sf.sf6.cull_mode = BRW_CULLMODE_BACK; + break; + case PIPE_FACE_FRONT_AND_BACK: sf.sf6.cull_mode = BRW_CULLMODE_BOTH; break; - case PIPE_WINDING_NONE: + case PIPE_FACE_NONE: sf.sf6.cull_mode = BRW_CULLMODE_NONE; break; default: @@ -284,7 +284,7 @@ static enum pipe_error upload_sf_unit( struct brw_context *brw ) */ total_grf = (align(key.total_grf, 16) / 16 - 1); viewport_transform = 1; - front_winding = (key.front_face == PIPE_WINDING_CCW ? + front_winding = (key.front_ccw ? BRW_FRONTWINDING_CCW : BRW_FRONTWINDING_CW); diff --git a/src/gallium/drivers/i965/brw_wm_state.c b/src/gallium/drivers/i965/brw_wm_state.c index ee970ac75bc..efc2d96be13 100644 --- a/src/gallium/drivers/i965/brw_wm_state.c +++ b/src/gallium/drivers/i965/brw_wm_state.c @@ -128,8 +128,9 @@ wm_unit_populate_key(struct brw_context *brw, struct brw_wm_unit_key *key) key->line_stipple = brw->curr.rast->templ.line_stipple_enable; - key->offset_enable = (brw->curr.rast->templ.offset_cw || - brw->curr.rast->templ.offset_ccw); + key->offset_enable = (brw->curr.rast->templ.offset_point || + brw->curr.rast->templ.offset_line || + brw->curr.rast->templ.offset_tri); key->offset_units = brw->curr.rast->templ.offset_units; key->offset_factor = brw->curr.rast->templ.offset_scale; diff --git a/src/gallium/drivers/identity/id_screen.c b/src/gallium/drivers/identity/id_screen.c index 7082d60d1c9..f71585e06f8 100644 --- a/src/gallium/drivers/identity/id_screen.c +++ b/src/gallium/drivers/identity/id_screen.c @@ -67,7 +67,7 @@ identity_screen_get_vendor(struct pipe_screen *_screen) static int identity_screen_get_param(struct pipe_screen *_screen, - int param) + enum pipe_cap param) { struct identity_screen *id_screen = identity_screen(_screen); struct pipe_screen *screen = id_screen->screen; @@ -78,7 +78,7 @@ identity_screen_get_param(struct pipe_screen *_screen, static float identity_screen_get_paramf(struct pipe_screen *_screen, - int param) + enum pipe_cap param) { struct identity_screen *id_screen = identity_screen(_screen); struct pipe_screen *screen = id_screen->screen; diff --git a/src/gallium/drivers/llvmpipe/Makefile b/src/gallium/drivers/llvmpipe/Makefile index 4ea367597e1..526e85c82e1 100644 --- a/src/gallium/drivers/llvmpipe/Makefile +++ b/src/gallium/drivers/llvmpipe/Makefile @@ -59,7 +59,7 @@ lp_tile_soa.c: lp_tile_soa.py ../../auxiliary/util/u_format_parse.py ../../auxil python lp_tile_soa.py ../../auxiliary/util/u_format.csv > $@ LDFLAGS += $(LLVM_LDFLAGS) -LIBS += $(GL_LIB_DEPS) -L../../auxiliary/ -lgallium libllvmpipe.a $(LLVM_LIBS) +LIBS += -L../../auxiliary/ -lgallium libllvmpipe.a $(LLVM_LIBS) $(GL_LIB_DEPS) LD=g++ $(PROGS): lp_test_main.o libllvmpipe.a diff --git a/src/gallium/drivers/llvmpipe/README b/src/gallium/drivers/llvmpipe/README index 3c3fd386b52..9c874acdedc 100644 --- a/src/gallium/drivers/llvmpipe/README +++ b/src/gallium/drivers/llvmpipe/README @@ -69,7 +69,15 @@ Requirements http://people.freedesktop.org/~jrfonseca/llvm/ and set the LLVM environment variable to the extracted path. - The version of LLVM from SVN ("2.7svn") from mid-March 2010 seems pretty + For MSVC there are two set of binaries: llvm-x.x-msvc32mt.7z and + llvm-x.x-msvc32mtd.7z . + + You have to set the LLVM=/path/to/llvm-x.x-msvc32mtd env var when passing + debug=yes to scons, and LLVM=/path/to/llvm-x.x-msvc32mt when building with + debug=no. This is necessary as LLVM builds as static library so the chosen + MS CRT must match. + + The version of LLVM from SVN ("2.7svn") from mid-March 2010 is pretty stable and has some features not in version 2.6. - scons (optional) diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript index 2911cf2179a..c155558aa54 100644 --- a/src/gallium/drivers/llvmpipe/SConscript +++ b/src/gallium/drivers/llvmpipe/SConscript @@ -85,4 +85,4 @@ if env['platform'] != 'embedded': ) env.InstallProgram(target) - Export('llvmpipe') +Export('llvmpipe') diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend.h b/src/gallium/drivers/llvmpipe/lp_bld_blend.h index ebbdb1a604c..5cecec3d7f9 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_blend.h +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend.h @@ -29,17 +29,6 @@ #define LP_BLD_BLEND_H -/** - * @file - * LLVM IR building helpers interfaces. - * - * We use LLVM-C bindings for now. They are not documented, but follow the C++ - * interfaces very closely, and appear to be complete enough for code - * genration. See - * http://npcontemplation.blogspot.com/2008/06/secret-of-llvm-c-bindings.html - * for a standalone example. - */ - #include "gallivm/lp_bld.h" #include "pipe/p_format.h" @@ -75,6 +64,7 @@ LLVMValueRef lp_build_blend_aos(LLVMBuilderRef builder, const struct pipe_blend_state *blend, struct lp_type type, + unsigned rt, LLVMValueRef src, LLVMValueRef dst, LLVMValueRef const_, @@ -85,6 +75,7 @@ void lp_build_blend_soa(LLVMBuilderRef builder, const struct pipe_blend_state *blend, struct lp_type type, + unsigned rt, LLVMValueRef src[4], LLVMValueRef dst[4], LLVMValueRef const_[4], diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c index 3fa5e51cac5..70d08e71f6e 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c @@ -243,6 +243,9 @@ lp_build_blend_factor(struct lp_build_blend_aos_context *bld, } +/** + * Is (a OP b) == (b OP a)? + */ boolean lp_build_blend_func_commutative(unsigned func) { @@ -305,6 +308,7 @@ LLVMValueRef lp_build_blend_aos(LLVMBuilderRef builder, const struct pipe_blend_state *blend, struct lp_type type, + unsigned rt, LLVMValueRef src, LLVMValueRef dst, LLVMValueRef const_, @@ -314,11 +318,10 @@ lp_build_blend_aos(LLVMBuilderRef builder, LLVMValueRef src_term; LLVMValueRef dst_term; - /* FIXME */ - assert(blend->independent_blend_enable == 0); - assert(blend->rt[0].colormask == 0xf); + /* FIXME: color masking not implemented yet */ + assert(blend->rt[rt].colormask == 0xf); - if(!blend->rt[0].blend_enable) + if(!blend->rt[rt].blend_enable) return src; /* It makes no sense to blend unless values are normalized */ @@ -335,16 +338,16 @@ lp_build_blend_aos(LLVMBuilderRef builder, * combinations it is possible to reorder the operations and therefore saving * some instructions. */ - src_term = lp_build_blend_factor(&bld, src, blend->rt[0].rgb_src_factor, - blend->rt[0].alpha_src_factor, alpha_swizzle); - dst_term = lp_build_blend_factor(&bld, dst, blend->rt[0].rgb_dst_factor, - blend->rt[0].alpha_dst_factor, alpha_swizzle); + src_term = lp_build_blend_factor(&bld, src, blend->rt[rt].rgb_src_factor, + blend->rt[rt].alpha_src_factor, alpha_swizzle); + dst_term = lp_build_blend_factor(&bld, dst, blend->rt[rt].rgb_dst_factor, + blend->rt[rt].alpha_dst_factor, alpha_swizzle); lp_build_name(src_term, "src_term"); lp_build_name(dst_term, "dst_term"); - if(blend->rt[0].rgb_func == blend->rt[0].alpha_func) { - return lp_build_blend_func(&bld.base, blend->rt[0].rgb_func, src_term, dst_term); + if(blend->rt[rt].rgb_func == blend->rt[rt].alpha_func) { + return lp_build_blend_func(&bld.base, blend->rt[rt].rgb_func, src_term, dst_term); } else { /* Seperate RGB / A functions */ @@ -352,8 +355,8 @@ lp_build_blend_aos(LLVMBuilderRef builder, LLVMValueRef rgb; LLVMValueRef alpha; - rgb = lp_build_blend_func(&bld.base, blend->rt[0].rgb_func, src_term, dst_term); - alpha = lp_build_blend_func(&bld.base, blend->rt[0].alpha_func, src_term, dst_term); + rgb = lp_build_blend_func(&bld.base, blend->rt[rt].rgb_func, src_term, dst_term); + alpha = lp_build_blend_func(&bld.base, blend->rt[rt].alpha_func, src_term, dst_term); return lp_build_blend_swizzle(&bld, rgb, alpha, LP_BUILD_BLEND_SWIZZLE_RGBA, alpha_swizzle); } diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c index b7523eb9c13..b9c7a6ceed6 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c @@ -33,8 +33,8 @@ * Blending in SoA is much faster than AoS, especially when separate rgb/alpha * factors/functions are used, since no channel masking/shuffling is necessary * and we can achieve the full throughput of the SIMD operations. Furthermore - * the fragment shader output is also in SoA, so it fits nicely with the rest of - * the fragment pipeline. + * the fragment shader output is also in SoA, so it fits nicely with the rest + * of the fragment pipeline. * * The drawback is that to be displayed the color buffer needs to be in AoS * layout, so we need to tile/untile the color buffer before/after rendering. @@ -77,7 +77,7 @@ /** - * We may the same values several times, so we keep them here to avoid + * We may use the same values several times, so we keep them here to avoid * recomputing them. Also reusing the values allows us to do simplifications * that LLVM optimization passes wouldn't normally be able to do. */ @@ -98,16 +98,22 @@ struct lp_build_blend_soa_context /** * We store all factors in a table in order to eliminate redundant * multiplications later. + * Indexes are: factor[src,dst][color,term][r,g,b,a] */ LLVMValueRef factor[2][2][4]; /** * Table with all terms. + * Indexes are: term[src,dst][r,g,b,a] */ LLVMValueRef term[2][4]; }; +/** + * Build a single SOA blend factor for a color channel. + * \param i the color channel in [0,3] + */ static LLVMValueRef lp_build_blend_soa_factor(struct lp_build_blend_soa_context *bld, unsigned factor, unsigned i) @@ -191,6 +197,7 @@ lp_build_blend_soa_factor(struct lp_build_blend_soa_context *bld, /** * Generate blend code in SOA mode. + * \param rt render target index (to index the blend / colormask state) * \param src src/fragment color * \param dst dst/framebuffer color * \param con constant blend color @@ -200,6 +207,7 @@ void lp_build_blend_soa(LLVMBuilderRef builder, const struct pipe_blend_state *blend, struct lp_type type, + unsigned rt, LLVMValueRef src[4], LLVMValueRef dst[4], LLVMValueRef con[4], @@ -208,6 +216,8 @@ lp_build_blend_soa(LLVMBuilderRef builder, struct lp_build_blend_soa_context bld; unsigned i, j, k; + assert(rt < PIPE_MAX_COLOR_BUFS); + /* Setup build context */ memset(&bld, 0, sizeof bld); lp_build_context_init(&bld.base, builder, type); @@ -218,7 +228,8 @@ lp_build_blend_soa(LLVMBuilderRef builder, } for (i = 0; i < 4; ++i) { - if (blend->rt[0].colormask & (1 << i)) { + /* only compute blending for the color channels enabled for writing */ + if (blend->rt[rt].colormask & (1 << i)) { if (blend->logicop_enable) { if(!type.floating) { res[i] = lp_build_logicop(builder, blend->logicop_func, src[i], dst[i]); @@ -226,10 +237,10 @@ lp_build_blend_soa(LLVMBuilderRef builder, else res[i] = dst[i]; } - else if (blend->rt[0].blend_enable) { - unsigned src_factor = i < 3 ? blend->rt[0].rgb_src_factor : blend->rt[0].alpha_src_factor; - unsigned dst_factor = i < 3 ? blend->rt[0].rgb_dst_factor : blend->rt[0].alpha_dst_factor; - unsigned func = i < 3 ? blend->rt[0].rgb_func : blend->rt[0].alpha_func; + else if (blend->rt[rt].blend_enable) { + unsigned src_factor = i < 3 ? blend->rt[rt].rgb_src_factor : blend->rt[rt].alpha_src_factor; + unsigned dst_factor = i < 3 ? blend->rt[rt].rgb_dst_factor : blend->rt[rt].alpha_dst_factor; + unsigned func = i < 3 ? blend->rt[rt].rgb_func : blend->rt[rt].alpha_func; boolean func_commutative = lp_build_blend_func_commutative(func); /* It makes no sense to blend unless values are normalized */ @@ -269,9 +280,9 @@ lp_build_blend_soa(LLVMBuilderRef builder, /* XXX special case these combos to work around an apparent * bug in LLVM. * This hack disables the check for multiplication by zero - * in lp_bld_mul(). When we optimize away the multiplication, - * something goes wrong during code generation and we segfault - * at runtime. + * in lp_bld_mul(). When we optimize away the + * multiplication, something goes wrong during code + * generation and we segfault at runtime. */ LLVMValueRef zeroSave = bld.base.zero; bld.base.zero = NULL; @@ -287,7 +298,7 @@ lp_build_blend_soa(LLVMBuilderRef builder, /* See if this function has been previously applied */ for(j = 0; j < i; ++j) { - unsigned prev_func = j < 3 ? blend->rt[0].rgb_func : blend->rt[0].alpha_func; + unsigned prev_func = j < 3 ? blend->rt[rt].rgb_func : blend->rt[rt].alpha_func; unsigned func_reverse = lp_build_blend_func_reverse(func, prev_func); if((!func_reverse && diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c b/src/gallium/drivers/llvmpipe/lp_bld_depth.c index 1b59a13c946..e05bbe5011a 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c @@ -72,6 +72,7 @@ #include "gallivm/lp_bld_const.h" #include "gallivm/lp_bld_logic.h" #include "gallivm/lp_bld_flow.h" +#include "gallivm/lp_bld_intr.h" #include "gallivm/lp_bld_debug.h" #include "gallivm/lp_bld_swizzle.h" @@ -445,6 +446,42 @@ get_s_shift_and_mask(const struct util_format_description *format_desc, } +/** + * Perform the occlusion test and increase the counter. + * Test the depth mask. Add the number of channel which has none zero mask + * into the occlusion counter. e.g. maskvalue is {-1, -1, -1, -1}. + * The counter will add 4. + * + * \param type holds element type of the mask vector. + * \param maskvalue is the depth test mask. + * \param counter is a pointer of the uint32 counter. + */ +static void +lp_build_occlusion_count(LLVMBuilderRef builder, + struct lp_type type, + LLVMValueRef maskvalue, + LLVMValueRef counter) +{ + LLVMValueRef countmask = lp_build_const_int_vec(type, 1); + LLVMValueRef countv = LLVMBuildAnd(builder, maskvalue, countmask, "countv"); + LLVMTypeRef i8v16 = LLVMVectorType(LLVMInt8Type(), 16); + LLVMValueRef counti = LLVMBuildBitCast(builder, countv, i8v16, "counti"); + LLVMValueRef maskarray[4] = { + LLVMConstInt(LLVMInt32Type(), 0, 0), + LLVMConstInt(LLVMInt32Type(), 4, 0), + LLVMConstInt(LLVMInt32Type(), 8, 0), + LLVMConstInt(LLVMInt32Type(), 12, 0), + }; + LLVMValueRef shufflemask = LLVMConstVector(maskarray, 4); + LLVMValueRef shufflev = LLVMBuildShuffleVector(builder, counti, LLVMGetUndef(i8v16), shufflemask, "shufflev"); + LLVMValueRef shuffle = LLVMBuildBitCast(builder, shufflev, LLVMInt32Type(), "shuffle"); + LLVMValueRef count = lp_build_intrinsic_unary(builder, "llvm.ctpop.i32", LLVMInt32Type(), shuffle); + LLVMValueRef orig = LLVMBuildLoad(builder, counter, "orig"); + LLVMValueRef incr = LLVMBuildAdd(builder, orig, count, "incr"); + LLVMBuildStore(builder, incr, counter); +} + + /** * Generate code for performing depth and/or stencil tests. @@ -470,7 +507,8 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, LLVMValueRef stencil_refs[2], LLVMValueRef z_src, LLVMValueRef zs_dst_ptr, - LLVMValueRef face) + LLVMValueRef face, + LLVMValueRef counter) { struct lp_build_context bld; struct lp_build_context sbld; @@ -682,4 +720,7 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, if (depth->enabled && stencil[0].enabled) lp_build_mask_update(mask, z_pass); + + if (counter) + lp_build_occlusion_count(builder, type, mask->value, counter); } diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.h b/src/gallium/drivers/llvmpipe/lp_bld_depth.h index 27dd46b625d..e257a5bd7d0 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_depth.h +++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.h @@ -60,7 +60,8 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder, LLVMValueRef stencil_refs[2], LLVMValueRef zs_src, LLVMValueRef zs_dst_ptr, - LLVMValueRef facing); + LLVMValueRef facing, + LLVMValueRef counter); #endif /* !LP_BLD_DEPTH_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h index 4e597b24796..de7fe7a1796 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.h +++ b/src/gallium/drivers/llvmpipe/lp_context.h @@ -82,11 +82,7 @@ struct llvmpipe_context { unsigned dirty; /**< Mask of LP_NEW_x flags */ - /* Counter for occlusion queries. Note this supports overlapping - * queries. - */ - uint64_t occlusion_count; - unsigned active_query_count; + int active_query_count; /** Mapped vertex buffers */ ubyte *mapped_vbuffer[PIPE_MAX_ATTRIBS]; diff --git a/src/gallium/drivers/llvmpipe/lp_debug.h b/src/gallium/drivers/llvmpipe/lp_debug.h index ee818143610..92fb2b3ee5b 100644 --- a/src/gallium/drivers/llvmpipe/lp_debug.h +++ b/src/gallium/drivers/llvmpipe/lp_debug.h @@ -39,16 +39,13 @@ st_print_current(void); #define DEBUG_PIPE 0x1 #define DEBUG_TGSI 0x2 #define DEBUG_TEX 0x4 -#define DEBUG_ASM 0x8 #define DEBUG_SETUP 0x10 #define DEBUG_RAST 0x20 #define DEBUG_QUERY 0x40 #define DEBUG_SCREEN 0x80 -#define DEBUG_JIT 0x100 #define DEBUG_SHOW_TILES 0x200 #define DEBUG_SHOW_SUBTILES 0x400 #define DEBUG_COUNTERS 0x800 -#define DEBUG_NO_LLVM_OPT 0x1000 #ifdef DEBUG diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c b/src/gallium/drivers/llvmpipe/lp_flush.c index 644b821957a..e1425435e19 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.c +++ b/src/gallium/drivers/llvmpipe/lp_flush.c @@ -31,6 +31,7 @@ #include "pipe/p_defines.h" +#include "util/u_string.h" #include "draw/draw_context.h" #include "lp_flush.h" #include "lp_context.h" @@ -71,25 +72,25 @@ llvmpipe_flush( struct pipe_context *pipe, } /* Enable to dump BMPs of the color/depth buffers each frame */ -#if 0 - if (flags & PIPE_FLUSH_FRAME) { - static unsigned frame_no = 1; - char filename[256]; - unsigned i; - - for (i = 0; i < llvmpipe->framebuffer.nr_cbufs; i++) { - util_snprintf(filename, sizeof(filename), "cbuf%u_%u", i, frame_no); - debug_dump_surface_bmp(&llvmpipe->pipe, filename, llvmpipe->framebuffer.cbufs[0]); - } + if (0) { + if (flags & PIPE_FLUSH_FRAME) { + static unsigned frame_no = 1; + char filename[256]; + unsigned i; + + for (i = 0; i < llvmpipe->framebuffer.nr_cbufs; i++) { + util_snprintf(filename, sizeof(filename), "cbuf%u_%u", i, frame_no); + debug_dump_surface_bmp(&llvmpipe->pipe, filename, llvmpipe->framebuffer.cbufs[0]); + } - if (0) { - util_snprintf(filename, sizeof(filename), "zsbuf_%u", frame_no); - debug_dump_surface_bmp(&llvmpipe->pipe, filename, llvmpipe->framebuffer.zsbuf); - } + if (0) { + util_snprintf(filename, sizeof(filename), "zsbuf_%u", frame_no); + debug_dump_surface_bmp(&llvmpipe->pipe, filename, llvmpipe->framebuffer.zsbuf); + } - ++frame_no; + ++frame_no; + } } -#endif } diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index 30e206a2b42..23aa34ddec1 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -38,7 +38,7 @@ #include "util/u_memory.h" #include "util/u_cpu_detect.h" #include "gallivm/lp_bld_init.h" -#include "lp_debug.h" +#include "gallivm/lp_bld_debug.h" #include "lp_screen.h" #include "gallivm/lp_bld_intr.h" #include "lp_jit.h" @@ -151,9 +151,9 @@ lp_jit_init_globals(struct llvmpipe_screen *screen) screen->context_ptr_type = LLVMPointerType(context_type, 0); } -#ifdef DEBUG - LLVMDumpModule(screen->module); -#endif + if (gallivm_debug & GALLIVM_DEBUG_IR) { + LLVMDumpModule(screen->module); + } } @@ -181,7 +181,7 @@ lp_jit_screen_init(struct llvmpipe_screen *screen) screen->pass = LLVMCreateFunctionPassManager(screen->provider); LLVMAddTargetData(screen->target, screen->pass); - if ((LP_DEBUG & DEBUG_NO_LLVM_OPT) == 0) { + if ((gallivm_debug & GALLIVM_DEBUG_NO_OPT) == 0) { /* These are the passes currently listed in llvm-c/Transforms/Scalar.h, * but there are more on SVN. */ /* TODO: Add more passes */ @@ -196,6 +196,11 @@ lp_jit_screen_init(struct llvmpipe_screen *screen) LLVMAddInstructionCombiningPass(screen->pass); } LLVMAddGVNPass(screen->pass); + } else { + /* We need at least this pass to prevent the backends to fail in + * unexpected ways. + */ + LLVMAddPromoteMemoryToRegisterPass(screen->pass); } lp_jit_init_globals(screen); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 5d0268c68c4..8dee0413019 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -146,13 +146,9 @@ enum { lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_BLEND_COLOR, "blend_color") #define lp_jit_context_textures(_builder, _ptr) \ - lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CONTEXT_TEXTURES, "textures") + lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CTX_TEXTURES, "textures") -/** Indexes into jit_function[] array */ -#define RAST_WHOLE 0 -#define RAST_EDGE_TEST 1 - typedef void (*lp_jit_frag_func)(const struct lp_jit_context *context, @@ -169,7 +165,38 @@ typedef void const int32_t c3, const int32_t *step1, const int32_t *step2, - const int32_t *step3); + const int32_t *step3, + uint32_t *counter); + + +/** cast wrapper to avoid compiler warnings */ +static INLINE lp_jit_frag_func +cast_voidptr_to_lp_jit_frag_func(void *v) +{ + union { + void *v; + lp_jit_frag_func f; + } u; + assert(sizeof(u.v) == sizeof(u.f)); + u.v = v; + return u.f; +} + + +/** cast wrapper */ +static INLINE void * +cast_lp_jit_frag_func_to_voidptr(lp_jit_frag_func f) +{ + union { + void *v; + lp_jit_frag_func f; + } u; + assert(sizeof(u.v) == sizeof(u.f)); + u.f = f; + return u.v; +} + + void diff --git a/src/gallium/drivers/llvmpipe/lp_query.c b/src/gallium/drivers/llvmpipe/lp_query.c index 5554285425d..c23e9839063 100644 --- a/src/gallium/drivers/llvmpipe/lp_query.c +++ b/src/gallium/drivers/llvmpipe/lp_query.c @@ -1,6 +1,7 @@ /************************************************************************** * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright 2010 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -18,15 +19,15 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * IN NO EVENT SHALL THE AUTHORS 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. * **************************************************************************/ -/* Author: - * Keith Whitwell <[email protected]> +/* Authors: + * Keith Whitwell, Qicheng Christopher Li, Brian Paul */ #include "draw/draw_context.h" @@ -34,12 +35,10 @@ #include "util/u_memory.h" #include "lp_context.h" #include "lp_query.h" +#include "lp_rast.h" +#include "lp_rast_priv.h" #include "lp_state.h" - -struct llvmpipe_query { - uint64_t start; - uint64_t end; -}; +#include "lp_setup_context.h" static struct llvmpipe_query *llvmpipe_query( struct pipe_query *p ) @@ -51,15 +50,46 @@ static struct pipe_query * llvmpipe_create_query(struct pipe_context *pipe, unsigned type) { + struct llvmpipe_query *pq; + assert(type == PIPE_QUERY_OCCLUSION_COUNTER); - return (struct pipe_query *)CALLOC_STRUCT( llvmpipe_query ); + + pq = CALLOC_STRUCT( llvmpipe_query ); + if (pq) { + pipe_mutex_init(pq->mutex); + } + + return (struct pipe_query *) pq; } static void llvmpipe_destroy_query(struct pipe_context *pipe, struct pipe_query *q) { - FREE(q); + struct llvmpipe_query *pq = llvmpipe_query(q); + pipe_mutex_destroy(pq->mutex); + FREE(pq); +} + + +static boolean +llvmpipe_get_query_result(struct pipe_context *pipe, + struct pipe_query *q, + boolean wait, + uint64_t *result ) +{ + struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe ); + struct llvmpipe_query *pq = llvmpipe_query(q); + + if (!pq->done) { + lp_setup_flush(llvmpipe->setup, TRUE); + } + + if (pq->done) { + *result = pq->result; + } + + return pq->done; } @@ -67,9 +97,23 @@ static void llvmpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q) { struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe ); - struct llvmpipe_query *sq = llvmpipe_query(q); - - sq->start = llvmpipe->occlusion_count; + struct llvmpipe_query *pq = llvmpipe_query(q); + + /* Check if the query is already in the scene. If so, we need to + * flush the scene now. Real apps shouldn't re-use a query in a + * frame of rendering. + */ + if (pq->binned) { + struct pipe_fence_handle *fence; + pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, &fence); + if (fence) { + pipe->screen->fence_finish(pipe->screen, fence, 0); + pipe->screen->fence_reference(pipe->screen, &fence, NULL); + } + } + + lp_setup_begin_query(llvmpipe->setup, pq); + llvmpipe->active_query_count++; llvmpipe->dirty |= LP_NEW_QUERY; } @@ -79,26 +123,16 @@ static void llvmpipe_end_query(struct pipe_context *pipe, struct pipe_query *q) { struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe ); - struct llvmpipe_query *sq = llvmpipe_query(q); + struct llvmpipe_query *pq = llvmpipe_query(q); + lp_setup_end_query(llvmpipe->setup, pq); + + assert(llvmpipe->active_query_count); llvmpipe->active_query_count--; - sq->end = llvmpipe->occlusion_count; llvmpipe->dirty |= LP_NEW_QUERY; } -static boolean -llvmpipe_get_query_result(struct pipe_context *pipe, - struct pipe_query *q, - boolean wait, - uint64_t *result ) -{ - struct llvmpipe_query *sq = llvmpipe_query(q); - *result = sq->end - sq->start; - return TRUE; -} - - void llvmpipe_init_query_funcs(struct llvmpipe_context *llvmpipe ) { llvmpipe->pipe.create_query = llvmpipe_create_query; diff --git a/src/gallium/drivers/llvmpipe/lp_query.h b/src/gallium/drivers/llvmpipe/lp_query.h index fa9fcd87139..721c41cb5c9 100644 --- a/src/gallium/drivers/llvmpipe/lp_query.h +++ b/src/gallium/drivers/llvmpipe/lp_query.h @@ -1,6 +1,7 @@ /************************************************************************** * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright 2010 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -25,14 +26,33 @@ * **************************************************************************/ -/* Author: - * Keith Whitwell +/* Authors: + * Keith Whitwell, Qicheng Christopher Li, Brian Paul */ #ifndef LP_QUERY_H #define LP_QUERY_H +#include <limits.h> +#include "os/os_thread.h" +#include "lp_limits.h" + + struct llvmpipe_context; + + +struct llvmpipe_query { + uint64_t count[LP_MAX_THREADS]; /**< a counter for each thread */ + uint64_t result; /**< total of all counters */ + + pipe_mutex mutex; + unsigned num_tiles, tile_count; + + boolean done; + boolean binned; /**< has this query been binned in the scene? */ +}; + + extern void llvmpipe_init_query_funcs(struct llvmpipe_context * ); diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index a00a592f2fe..6bb868bf1a9 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -34,6 +34,7 @@ #include "lp_debug.h" #include "lp_fence.h" #include "lp_perf.h" +#include "lp_query.h" #include "lp_rast.h" #include "lp_rast_priv.h" #include "lp_tile_soa.h" @@ -442,7 +443,7 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task, color, depth, INT_MIN, INT_MIN, INT_MIN, - NULL, NULL, NULL ); + NULL, NULL, NULL, &task->vis_counter); } } } @@ -502,7 +503,8 @@ void lp_rast_shade_quads( struct lp_rasterizer_task *task, c1, c2, c3, inputs->step[0], inputs->step[1], - inputs->step[2]); + inputs->step[2], + &task->vis_counter); } @@ -602,6 +604,60 @@ lp_rast_fence(struct lp_rasterizer_task *task, } +/** + * Begin a new occlusion query. + * This is a bin command put in all bins. + * Called per thread. + */ +void +lp_rast_begin_query(struct lp_rasterizer_task *task, + const union lp_rast_cmd_arg arg) +{ + /* Reset the the per-task counter */ + task->vis_counter = 0; +} + + +/** + * End the current occlusion query. + * This is a bin command put in all bins. + * Called per thread. + */ +void +lp_rast_end_query(struct lp_rasterizer_task *task, + const union lp_rast_cmd_arg arg) +{ + struct llvmpipe_query *pq = arg.query_obj; + + pipe_mutex_lock(pq->mutex); + { + /* Accumulate the visible fragment counter from this tile in + * the query object. + */ + pq->count[task->thread_index] += task->vis_counter; + + /* check if this is the last tile in the scene */ + pq->tile_count++; + if (pq->tile_count == pq->num_tiles) { + uint i; + + /* sum the per-thread counters for the query */ + pq->result = 0; + for (i = 0; i < LP_MAX_THREADS; i++) { + pq->result += pq->count[i]; + } + + /* reset counters (in case this query is re-used in the scene) */ + memset(pq->count, 0, sizeof(pq->count)); + + pq->tile_count = 0; + pq->binned = FALSE; + pq->done = TRUE; + } + } + pipe_mutex_unlock(pq->mutex); +} + /** @@ -650,6 +706,8 @@ static struct { RAST(set_state), RAST(store_color), RAST(fence), + RAST(begin_query), + RAST(end_query), }; static void @@ -956,3 +1014,5 @@ lp_rast_get_num_threads( struct lp_rasterizer *rast ) { return rast->num_threads; } + + diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h index e2f6f926779..881f475189e 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.h +++ b/src/gallium/drivers/llvmpipe/lp_rast.h @@ -157,6 +157,7 @@ union lp_rast_cmd_arg { uint8_t clear_color[4]; unsigned clear_zstencil; struct lp_fence *fence; + struct llvmpipe_query *query_obj; }; @@ -233,4 +234,11 @@ void lp_rast_store_color( struct lp_rasterizer_task *, const union lp_rast_cmd_arg ); +void lp_rast_begin_query(struct lp_rasterizer_task *, + const union lp_rast_cmd_arg ); + +void lp_rast_end_query(struct lp_rasterizer_task *, + const union lp_rast_cmd_arg ); + + #endif diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h index 5884d12721e..efc013ff3f0 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h +++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h @@ -33,6 +33,7 @@ #include "gallivm/lp_bld_debug.h" #include "lp_rast.h" #include "lp_scene.h" +#include "lp_state.h" #include "lp_texture.h" #include "lp_tile_soa.h" #include "lp_limits.h" @@ -59,6 +60,9 @@ struct lp_rasterizer_task /** "my" index */ unsigned thread_index; + /* occlude counter for visiable pixels */ + uint32_t vis_counter; + pipe_semaphore work_ready; pipe_semaphore work_done; }; @@ -221,7 +225,7 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task, color, depth, INT_MIN, INT_MIN, INT_MIN, - NULL, NULL, NULL ); + NULL, NULL, NULL, &task->vis_counter ); } diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c index 887f2dbad91..59e4c18ad05 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.c +++ b/src/gallium/drivers/llvmpipe/lp_scene.c @@ -30,7 +30,6 @@ #include "util/u_memory.h" #include "util/u_inlines.h" #include "util/u_simple_list.h" -#include "util/u_surface.h" #include "lp_scene.h" #include "lp_scene_queue.h" @@ -210,25 +209,31 @@ lp_scene_reset(struct lp_scene *scene ) -void +struct cmd_block * lp_bin_new_cmd_block( struct cmd_block_list *list ) { struct cmd_block *block = MALLOC_STRUCT(cmd_block); - list->tail->next = block; - list->tail = block; - block->next = NULL; - block->count = 0; + if (block) { + list->tail->next = block; + list->tail = block; + block->next = NULL; + block->count = 0; + } + return block; } -void +struct data_block * lp_bin_new_data_block( struct data_block_list *list ) { struct data_block *block = MALLOC_STRUCT(data_block); - list->tail->next = block; - list->tail = block; - block->next = NULL; - block->used = 0; + if (block) { + list->tail->next = block; + list->tail = block; + block->next = NULL; + block->used = 0; + } + return block; } diff --git a/src/gallium/drivers/llvmpipe/lp_scene.h b/src/gallium/drivers/llvmpipe/lp_scene.h index 9467cd6f16d..22d619fdbc3 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.h +++ b/src/gallium/drivers/llvmpipe/lp_scene.h @@ -158,9 +158,9 @@ boolean lp_scene_is_empty(struct lp_scene *scene ); void lp_scene_reset(struct lp_scene *scene ); -void lp_bin_new_data_block( struct data_block_list *list ); +struct data_block *lp_bin_new_data_block( struct data_block_list *list ); -void lp_bin_new_cmd_block( struct cmd_block_list *list ); +struct cmd_block *lp_bin_new_cmd_block( struct cmd_block_list *list ); unsigned lp_scene_data_size( const struct lp_scene *scene ); @@ -181,15 +181,19 @@ static INLINE void * lp_scene_alloc( struct lp_scene *scene, unsigned size) { struct data_block_list *list = &scene->data; - - if (list->tail->used + size > DATA_BLOCK_SIZE) { - lp_bin_new_data_block( list ); + struct data_block *tail = list->tail; + + if (tail->used + size > DATA_BLOCK_SIZE) { + tail = lp_bin_new_data_block( list ); + if (!tail) { + /* out of memory */ + return NULL; + } } scene->scene_size += size; { - struct data_block *tail = list->tail; ubyte *data = tail->data + tail->used; tail->used += size; return data; @@ -205,15 +209,17 @@ lp_scene_alloc_aligned( struct lp_scene *scene, unsigned size, unsigned alignment ) { struct data_block_list *list = &scene->data; + struct data_block *tail = list->tail; - if (list->tail->used + size + alignment - 1 > DATA_BLOCK_SIZE) { - lp_bin_new_data_block( list ); + if (tail->used + size + alignment - 1 > DATA_BLOCK_SIZE) { + tail = lp_bin_new_data_block( list ); + if (!tail) + return NULL; } scene->scene_size += size; { - struct data_block *tail = list->tail; ubyte *data = tail->data + tail->used; unsigned offset = (((uintptr_t)data + alignment - 1) & ~(alignment - 1)) - (uintptr_t)data; tail->used += offset + size; @@ -257,16 +263,21 @@ lp_scene_bin_command( struct lp_scene *scene, { struct cmd_bin *bin = lp_scene_get_bin(scene, x, y); struct cmd_block_list *list = &bin->commands; + struct cmd_block *tail = list->tail; assert(x < scene->tiles_x); assert(y < scene->tiles_y); - if (list->tail->count == CMD_BLOCK_MAX) { - lp_bin_new_cmd_block( list ); + if (tail->count == CMD_BLOCK_MAX) { + tail = lp_bin_new_cmd_block( list ); + if (!tail) { + /* out of memory - simply ignore this command (for now) */ + return; + } + assert(tail->count == 0); } { - struct cmd_block *tail = list->tail; unsigned i = tail->count; tail->cmd[i] = cmd; tail->arg[i] = arg; diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 5f50446f846..cedc08e9292 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -34,6 +34,7 @@ #include "pipe/p_defines.h" #include "pipe/p_screen.h" +#include "gallivm/lp_bld_limits.h" #include "lp_texture.h" #include "lp_fence.h" #include "lp_jit.h" @@ -52,16 +53,13 @@ static const struct debug_named_value lp_debug_flags[] = { { "pipe", DEBUG_PIPE }, { "tgsi", DEBUG_TGSI }, { "tex", DEBUG_TEX }, - { "asm", DEBUG_ASM }, { "setup", DEBUG_SETUP }, { "rast", DEBUG_RAST }, { "query", DEBUG_QUERY }, { "screen", DEBUG_SCREEN }, - { "jit", DEBUG_JIT }, { "show_tiles", DEBUG_SHOW_TILES }, { "show_subtiles", DEBUG_SHOW_SUBTILES }, { "counters", DEBUG_COUNTERS }, - { "nopt", DEBUG_NO_LLVM_OPT }, {NULL, 0} }; #endif @@ -82,7 +80,7 @@ llvmpipe_get_name(struct pipe_screen *screen) static int -llvmpipe_get_param(struct pipe_screen *screen, int param) +llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) { switch (param) { case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: @@ -107,6 +105,8 @@ llvmpipe_get_param(struct pipe_screen *screen, int param) return PIPE_MAX_COLOR_BUFS; case PIPE_CAP_OCCLUSION_QUERY: return 1; + case PIPE_CAP_TIMER_QUERY: + return 0; case PIPE_CAP_TEXTURE_MIRROR_CLAMP: return 1; case PIPE_CAP_TEXTURE_MIRROR_REPEAT: @@ -124,7 +124,7 @@ llvmpipe_get_param(struct pipe_screen *screen, int param) case PIPE_CAP_BLEND_EQUATION_SEPARATE: return 1; case PIPE_CAP_INDEP_BLEND_ENABLE: - return 0; + return 1; case PIPE_CAP_INDEP_BLEND_FUNC: return 0; case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: @@ -133,14 +133,44 @@ llvmpipe_get_param(struct pipe_screen *screen, int param) case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: return 0; + case PIPE_CAP_MAX_VS_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_TEX_INDIRECTIONS: + case PIPE_CAP_MAX_FS_TEX_INDIRECTIONS: + /* There is no limit in number of instructions beyond available memory */ + return 32768; + case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH: + case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH: + return LP_MAX_TGSI_NESTING; + case PIPE_CAP_MAX_VS_INPUTS: + case PIPE_CAP_MAX_FS_INPUTS: + return PIPE_MAX_ATTRIBS; + case PIPE_CAP_MAX_FS_CONSTS: + case PIPE_CAP_MAX_VS_CONSTS: + /* There is no limit in number of constants beyond available memory */ + return 32768; + case PIPE_CAP_MAX_VS_TEMPS: + case PIPE_CAP_MAX_FS_TEMPS: + return LP_MAX_TGSI_TEMPS; + case PIPE_CAP_MAX_VS_ADDRS: + case PIPE_CAP_MAX_FS_ADDRS: + return LP_MAX_TGSI_ADDRS; + case PIPE_CAP_MAX_VS_PREDS: + case PIPE_CAP_MAX_FS_PREDS: + return LP_MAX_TGSI_PREDS; default: + assert(0); return 0; } } static float -llvmpipe_get_paramf(struct pipe_screen *screen, int param) +llvmpipe_get_paramf(struct pipe_screen *screen, enum pipe_cap param) { switch (param) { case PIPE_CAP_MAX_LINE_WIDTH: @@ -155,7 +185,13 @@ llvmpipe_get_paramf(struct pipe_screen *screen, int param) return 16.0; /* not actually signficant at this time */ case PIPE_CAP_MAX_TEXTURE_LOD_BIAS: return 16.0; /* arbitrary */ + case PIPE_CAP_GUARD_BAND_LEFT: + case PIPE_CAP_GUARD_BAND_TOP: + case PIPE_CAP_GUARD_BAND_RIGHT: + case PIPE_CAP_GUARD_BAND_BOTTOM: + return 0.0; default: + assert(0); return 0; } } @@ -270,7 +306,16 @@ llvmpipe_destroy_screen( struct pipe_screen *_screen ) struct pipe_screen * llvmpipe_create_screen(struct sw_winsys *winsys) { - struct llvmpipe_screen *screen = CALLOC_STRUCT(llvmpipe_screen); + struct llvmpipe_screen *screen; + +#ifdef PIPE_ARCH_X86 + /* require SSE2 due to LLVM PR6960. */ + util_cpu_detect(); + if (!util_cpu_caps.has_sse2) + return NULL; +#endif + + screen = CALLOC_STRUCT(llvmpipe_screen); #ifdef DEBUG LP_DEBUG = debug_get_flags_option("LP_DEBUG", lp_debug_flags, 0 ); diff --git a/src/gallium/drivers/llvmpipe/lp_screen.h b/src/gallium/drivers/llvmpipe/lp_screen.h index 4f394326103..eb40f6823f5 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.h +++ b/src/gallium/drivers/llvmpipe/lp_screen.h @@ -60,10 +60,9 @@ struct llvmpipe_screen unsigned num_threads; - /* Increments whenever textures are modified. Contexts can track - * this. + /* Increments whenever textures are modified. Contexts can track this. */ - unsigned timestamp; + unsigned timestamp; }; diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 1a2cd55b164..656e6cc38a6 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -32,18 +32,20 @@ * lp_setup_flush(). */ +#include <limits.h> + #include "pipe/p_defines.h" #include "util/u_framebuffer.h" #include "util/u_inlines.h" #include "util/u_memory.h" #include "util/u_pack_color.h" -#include "util/u_surface.h" #include "lp_context.h" #include "lp_scene.h" #include "lp_scene_queue.h" #include "lp_texture.h" #include "lp_debug.h" #include "lp_fence.h" +#include "lp_query.h" #include "lp_rast.h" #include "lp_setup_context.h" #include "lp_screen.h" @@ -418,7 +420,8 @@ lp_setup_set_fs_functions( struct lp_setup_context *setup, lp_jit_frag_func jit_function1, boolean opaque ) { - LP_DBG(DEBUG_SETUP, "%s %p\n", __FUNCTION__, (void *) jit_function0); + LP_DBG(DEBUG_SETUP, "%s %p\n", __FUNCTION__, + cast_lp_jit_frag_func_to_voidptr(jit_function0)); /* FIXME: reference count */ setup->fs.current.jit_function[0] = jit_function0; @@ -644,16 +647,19 @@ lp_setup_update_state( struct lp_setup_context *setup ) stored = lp_scene_alloc_aligned(scene, 4 * 16, 16); - /* smear each blend color component across 16 ubyte elements */ - for (i = 0; i < 4; ++i) { - uint8_t c = float_to_ubyte(setup->blend_color.current.color[i]); - for (j = 0; j < 16; ++j) - stored[i*16 + j] = c; - } + if (stored) { + /* smear each blend color component across 16 ubyte elements */ + for (i = 0; i < 4; ++i) { + uint8_t c = float_to_ubyte(setup->blend_color.current.color[i]); + for (j = 0; j < 16; ++j) + stored[i*16 + j] = c; + } - setup->blend_color.stored = stored; + setup->blend_color.stored = stored; + + setup->fs.current.jit_context.blend_color = setup->blend_color.stored; + } - setup->fs.current.jit_context.blend_color = setup->blend_color.stored; setup->dirty |= LP_SETUP_NEW_FS; } @@ -662,17 +668,19 @@ lp_setup_update_state( struct lp_setup_context *setup ) stored = lp_scene_alloc_aligned(scene, 4 * sizeof(int32_t), 16); - stored[0] = (float) setup->scissor.current.minx; - stored[1] = (float) setup->scissor.current.miny; - stored[2] = (float) setup->scissor.current.maxx; - stored[3] = (float) setup->scissor.current.maxy; + if (stored) { + stored[0] = (float) setup->scissor.current.minx; + stored[1] = (float) setup->scissor.current.miny; + stored[2] = (float) setup->scissor.current.maxx; + stored[3] = (float) setup->scissor.current.maxy; - setup->scissor.stored = stored; + setup->scissor.stored = stored; - setup->fs.current.jit_context.scissor_xmin = stored[0]; - setup->fs.current.jit_context.scissor_ymin = stored[1]; - setup->fs.current.jit_context.scissor_xmax = stored[2]; - setup->fs.current.jit_context.scissor_ymax = stored[3]; + setup->fs.current.jit_context.scissor_xmin = stored[0]; + setup->fs.current.jit_context.scissor_ymin = stored[1]; + setup->fs.current.jit_context.scissor_xmax = stored[2]; + setup->fs.current.jit_context.scissor_ymax = stored[3]; + } setup->dirty |= LP_SETUP_NEW_FS; } @@ -852,3 +860,40 @@ fail: return NULL; } + +/** + * Put a BeginQuery command into all bins. + */ +void +lp_setup_begin_query(struct lp_setup_context *setup, + struct llvmpipe_query *pq) +{ + struct lp_scene * scene = lp_setup_get_current_scene(setup); + union lp_rast_cmd_arg cmd_arg; + + /* init the query to its beginning state */ + pq->done = FALSE; + pq->tile_count = 0; + pq->num_tiles = scene->tiles_x * scene->tiles_y; + assert(pq->num_tiles > 0); + + memset(pq->count, 0, sizeof(pq->count)); /* reset all counters */ + + cmd_arg.query_obj = pq; + lp_scene_bin_everywhere(scene, lp_rast_begin_query, cmd_arg); + pq->binned = TRUE; +} + + +/** + * Put an EndQuery command into all bins. + */ +void +lp_setup_end_query(struct lp_setup_context *setup, struct llvmpipe_query *pq) +{ + struct lp_scene * scene = lp_setup_get_current_scene(setup); + union lp_rast_cmd_arg cmd_arg; + + cmd_arg.query_obj = pq; + lp_scene_bin_everywhere(scene, lp_rast_end_query, cmd_arg); +} diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h index e10d37d8d04..10db03b9c69 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.h +++ b/src/gallium/drivers/llvmpipe/lp_setup.h @@ -53,12 +53,15 @@ struct lp_shader_input { }; struct pipe_resource; +struct pipe_query; struct pipe_surface; struct pipe_blend_color; struct pipe_screen; struct pipe_framebuffer_state; struct lp_fragment_shader; struct lp_jit_context; +struct llvmpipe_query; + struct lp_setup_context * lp_setup_create( struct pipe_context *pipe, @@ -140,5 +143,12 @@ void lp_setup_set_vertex_info( struct lp_setup_context *setup, struct vertex_info *info ); +void +lp_setup_begin_query(struct lp_setup_context *setup, + struct llvmpipe_query *pq); + +void +lp_setup_end_query(struct lp_setup_context *setup, + struct llvmpipe_query *pq); #endif diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c index f8a58165733..306cb6e27d2 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c +++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c @@ -205,8 +205,14 @@ static void setup_tri_coefficients( struct lp_setup_context *setup, switch (setup->fs.input[slot].interp) { case LP_INTERP_CONSTANT: - for (i = 0; i < NUM_CHANNELS; i++) - constant_coef(setup, tri, slot+1, v3[vert_attr][i], i); + if (setup->flatshade_first) { + for (i = 0; i < NUM_CHANNELS; i++) + constant_coef(setup, tri, slot+1, v1[vert_attr][i], i); + } + else { + for (i = 0; i < NUM_CHANNELS; i++) + constant_coef(setup, tri, slot+1, v3[vert_attr][i], i); + } break; case LP_INTERP_LINEAR: @@ -665,14 +671,14 @@ void lp_setup_choose_triangle( struct lp_setup_context *setup ) { switch (setup->cullmode) { - case PIPE_WINDING_NONE: + case PIPE_FACE_NONE: setup->triangle = triangle_both; break; - case PIPE_WINDING_CCW: - setup->triangle = triangle_cw; + case PIPE_FACE_BACK: + setup->triangle = setup->ccw_is_frontface ? triangle_ccw : triangle_cw; break; - case PIPE_WINDING_CW: - setup->triangle = triangle_ccw; + case PIPE_FACE_FRONT: + setup->triangle = setup->ccw_is_frontface ? triangle_cw : triangle_ccw; break; default: setup->triangle = triangle_nop; diff --git a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c index 5d3122e8ba2..f6a424f25a8 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c +++ b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c @@ -131,11 +131,12 @@ static INLINE const_float4_ptr get_vert( const void *vertex_buffer, * draw elements / indexed primitives */ static void -lp_setup_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) +lp_setup_draw_elements(struct vbuf_render *vbr, const ushort *indices, uint nr) { struct lp_setup_context *setup = lp_setup_context(vbr); const unsigned stride = setup->vertex_info->size * sizeof(float); const void *vertex_buffer = setup->vertex_buffer; + const boolean flatshade_first = setup->flatshade_first; unsigned i; lp_setup_update_state(setup); @@ -178,35 +179,28 @@ lp_setup_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) break; case PIPE_PRIM_TRIANGLES: - if (setup->flatshade_first) { - for (i = 2; i < nr; i += 3) { - setup->triangle( setup, - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-0], stride), - get_vert(vertex_buffer, indices[i-2], stride) ); - } - } - else { - for (i = 2; i < nr; i += 3) { - setup->triangle( setup, - get_vert(vertex_buffer, indices[i-2], stride), - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-0], stride) ); - } + for (i = 2; i < nr; i += 3) { + setup->triangle( setup, + get_vert(vertex_buffer, indices[i-2], stride), + get_vert(vertex_buffer, indices[i-1], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); } break; case PIPE_PRIM_TRIANGLE_STRIP: - if (setup->flatshade_first) { + if (flatshade_first) { for (i = 2; i < nr; i += 1) { + /* emit first triangle vertex as first triangle vertex */ setup->triangle( setup, + get_vert(vertex_buffer, indices[i-2], stride), get_vert(vertex_buffer, indices[i+(i&1)-1], stride), - get_vert(vertex_buffer, indices[i-(i&1)], stride), - get_vert(vertex_buffer, indices[i-2], stride) ); + get_vert(vertex_buffer, indices[i-(i&1)], stride) ); + } } else { for (i = 2; i < nr; i += 1) { + /* emit last triangle vertex as last triangle vertex */ setup->triangle( setup, get_vert(vertex_buffer, indices[i+(i&1)-2], stride), get_vert(vertex_buffer, indices[i-(i&1)-1], stride), @@ -216,16 +210,18 @@ lp_setup_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) break; case PIPE_PRIM_TRIANGLE_FAN: - if (setup->flatshade_first) { + if (flatshade_first) { for (i = 2; i < nr; i += 1) { + /* emit first non-spoke vertex as first vertex */ setup->triangle( setup, + get_vert(vertex_buffer, indices[i-1], stride), get_vert(vertex_buffer, indices[i-0], stride), - get_vert(vertex_buffer, indices[0], stride), - get_vert(vertex_buffer, indices[i-1], stride) ); + get_vert(vertex_buffer, indices[0], stride) ); } } else { for (i = 2; i < nr; i += 1) { + /* emit last non-spoke vertex as last vertex */ setup->triangle( setup, get_vert(vertex_buffer, indices[0], stride), get_vert(vertex_buffer, indices[i-1], stride), @@ -235,43 +231,88 @@ lp_setup_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) break; case PIPE_PRIM_QUADS: - for (i = 3; i < nr; i += 4) { - setup->triangle( setup, + /* GL quads don't follow provoking vertex convention */ + if (flatshade_first) { + /* emit last quad vertex as first triangle vertex */ + for (i = 3; i < nr; i += 4) { + setup->triangle( setup, + get_vert(vertex_buffer, indices[i-0], stride), + get_vert(vertex_buffer, indices[i-3], stride), + get_vert(vertex_buffer, indices[i-2], stride) ); + + setup->triangle( setup, + get_vert(vertex_buffer, indices[i-0], stride), + get_vert(vertex_buffer, indices[i-2], stride), + get_vert(vertex_buffer, indices[i-1], stride) ); + } + } + else { + /* emit last quad vertex as last triangle vertex */ + for (i = 3; i < nr; i += 4) { + setup->triangle( setup, get_vert(vertex_buffer, indices[i-3], stride), get_vert(vertex_buffer, indices[i-2], stride), get_vert(vertex_buffer, indices[i-0], stride) ); - setup->triangle( setup, - get_vert(vertex_buffer, indices[i-2], stride), - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-0], stride) ); + setup->triangle( setup, + get_vert(vertex_buffer, indices[i-2], stride), + get_vert(vertex_buffer, indices[i-1], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); + } } break; case PIPE_PRIM_QUAD_STRIP: - for (i = 3; i < nr; i += 2) { - setup->triangle( setup, - get_vert(vertex_buffer, indices[i-3], stride), - get_vert(vertex_buffer, indices[i-2], stride), - get_vert(vertex_buffer, indices[i-0], stride) ); - setup->triangle( setup, - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-3], stride), - get_vert(vertex_buffer, indices[i-0], stride) ); + /* GL quad strips don't follow provoking vertex convention */ + if (flatshade_first) { + /* emit last quad vertex as first triangle vertex */ + for (i = 3; i < nr; i += 2) { + setup->triangle( setup, + get_vert(vertex_buffer, indices[i-0], stride), + get_vert(vertex_buffer, indices[i-3], stride), + get_vert(vertex_buffer, indices[i-2], stride) ); + setup->triangle( setup, + get_vert(vertex_buffer, indices[i-0], stride), + get_vert(vertex_buffer, indices[i-1], stride), + get_vert(vertex_buffer, indices[i-3], stride) ); + } + } + else { + /* emit last quad vertex as last triangle vertex */ + for (i = 3; i < nr; i += 2) { + setup->triangle( setup, + get_vert(vertex_buffer, indices[i-3], stride), + get_vert(vertex_buffer, indices[i-2], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); + setup->triangle( setup, + get_vert(vertex_buffer, indices[i-1], stride), + get_vert(vertex_buffer, indices[i-3], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); + } } break; case PIPE_PRIM_POLYGON: /* Almost same as tri fan but the _first_ vertex specifies the flat - * shading color. Note that the first polygon vertex is passed as - * the last triangle vertex here. - * flatshade_first state makes no difference. + * shading color. */ - for (i = 2; i < nr; i += 1) { - setup->triangle( setup, - get_vert(vertex_buffer, indices[i-0], stride), - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[0], stride) ); + if (flatshade_first) { + /* emit first polygon vertex as first triangle vertex */ + for (i = 2; i < nr; i += 1) { + setup->triangle( setup, + get_vert(vertex_buffer, indices[0], stride), + get_vert(vertex_buffer, indices[i-1], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); + } + } + else { + /* emit first polygon vertex as last triangle vertex */ + for (i = 2; i < nr; i += 1) { + setup->triangle( setup, + get_vert(vertex_buffer, indices[i-1], stride), + get_vert(vertex_buffer, indices[i-0], stride), + get_vert(vertex_buffer, indices[0], stride) ); + } } break; @@ -292,6 +333,7 @@ lp_setup_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) const unsigned stride = setup->vertex_info->size * sizeof(float); const void *vertex_buffer = (void *) get_vert(setup->vertex_buffer, start, stride); + const boolean flatshade_first = setup->flatshade_first; unsigned i; lp_setup_update_state(setup); @@ -334,35 +376,27 @@ lp_setup_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) break; case PIPE_PRIM_TRIANGLES: - if (setup->flatshade_first) { - for (i = 2; i < nr; i += 3) { - setup->triangle( setup, - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-0, stride), - get_vert(vertex_buffer, i-2, stride) ); - } - } - else { - for (i = 2; i < nr; i += 3) { - setup->triangle( setup, - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-0, stride) ); - } + for (i = 2; i < nr; i += 3) { + setup->triangle( setup, + get_vert(vertex_buffer, i-2, stride), + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-0, stride) ); } break; case PIPE_PRIM_TRIANGLE_STRIP: - if (setup->flatshade_first) { + if (flatshade_first) { for (i = 2; i < nr; i++) { + /* emit first triangle vertex as first triangle vertex */ setup->triangle( setup, + get_vert(vertex_buffer, i-2, stride), get_vert(vertex_buffer, i+(i&1)-1, stride), - get_vert(vertex_buffer, i-(i&1), stride), - get_vert(vertex_buffer, i-2, stride) ); + get_vert(vertex_buffer, i-(i&1), stride) ); } } else { for (i = 2; i < nr; i++) { + /* emit last triangle vertex as last triangle vertex */ setup->triangle( setup, get_vert(vertex_buffer, i+(i&1)-2, stride), get_vert(vertex_buffer, i-(i&1)-1, stride), @@ -372,16 +406,18 @@ lp_setup_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) break; case PIPE_PRIM_TRIANGLE_FAN: - if (setup->flatshade_first) { + if (flatshade_first) { for (i = 2; i < nr; i += 1) { + /* emit first non-spoke vertex as first vertex */ setup->triangle( setup, + get_vert(vertex_buffer, i-1, stride), get_vert(vertex_buffer, i-0, stride), - get_vert(vertex_buffer, 0, stride), - get_vert(vertex_buffer, i-1, stride) ); + get_vert(vertex_buffer, 0, stride) ); } } else { for (i = 2; i < nr; i += 1) { + /* emit last non-spoke vertex as last vertex */ setup->triangle( setup, get_vert(vertex_buffer, 0, stride), get_vert(vertex_buffer, i-1, stride), @@ -391,42 +427,86 @@ lp_setup_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) break; case PIPE_PRIM_QUADS: - for (i = 3; i < nr; i += 4) { - setup->triangle( setup, - get_vert(vertex_buffer, i-3, stride), - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-0, stride) ); - setup->triangle( setup, - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-0, stride) ); + /* GL quads don't follow provoking vertex convention */ + if (flatshade_first) { + /* emit last quad vertex as first triangle vertex */ + for (i = 3; i < nr; i += 4) { + setup->triangle( setup, + get_vert(vertex_buffer, i-0, stride), + get_vert(vertex_buffer, i-3, stride), + get_vert(vertex_buffer, i-2, stride) ); + setup->triangle( setup, + get_vert(vertex_buffer, i-0, stride), + get_vert(vertex_buffer, i-2, stride), + get_vert(vertex_buffer, i-1, stride) ); + } + } + else { + /* emit last quad vertex as last triangle vertex */ + for (i = 3; i < nr; i += 4) { + setup->triangle( setup, + get_vert(vertex_buffer, i-3, stride), + get_vert(vertex_buffer, i-2, stride), + get_vert(vertex_buffer, i-0, stride) ); + setup->triangle( setup, + get_vert(vertex_buffer, i-2, stride), + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-0, stride) ); + } } break; case PIPE_PRIM_QUAD_STRIP: - for (i = 3; i < nr; i += 2) { - setup->triangle( setup, - get_vert(vertex_buffer, i-3, stride), - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-0, stride) ); - setup->triangle( setup, - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-3, stride), - get_vert(vertex_buffer, i-0, stride) ); + /* GL quad strips don't follow provoking vertex convention */ + if (flatshade_first) { + /* emit last quad vertex as first triangle vertex */ + for (i = 3; i < nr; i += 2) { + setup->triangle( setup, + get_vert(vertex_buffer, i-0, stride), + get_vert(vertex_buffer, i-3, stride), + get_vert(vertex_buffer, i-2, stride) ); + setup->triangle( setup, + get_vert(vertex_buffer, i-0, stride), + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-3, stride) ); + } + } + else { + /* emit last quad vertex as last triangle vertex */ + for (i = 3; i < nr; i += 2) { + setup->triangle( setup, + get_vert(vertex_buffer, i-3, stride), + get_vert(vertex_buffer, i-2, stride), + get_vert(vertex_buffer, i-0, stride) ); + setup->triangle( setup, + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-3, stride), + get_vert(vertex_buffer, i-0, stride) ); + } } break; case PIPE_PRIM_POLYGON: /* Almost same as tri fan but the _first_ vertex specifies the flat - * shading color. Note that the first polygon vertex is passed as - * the last triangle vertex here. - * flatshade_first state makes no difference. + * shading color. */ - for (i = 2; i < nr; i += 1) { - setup->triangle( setup, - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-0, stride), - get_vert(vertex_buffer, 0, stride) ); + if (flatshade_first) { + /* emit first polygon vertex as first triangle vertex */ + for (i = 2; i < nr; i += 1) { + setup->triangle( setup, + get_vert(vertex_buffer, 0, stride), + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-0, stride) ); + } + } + else { + /* emit first polygon vertex as last triangle vertex */ + for (i = 2; i < nr; i += 1) { + setup->triangle( setup, + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-0, stride), + get_vert(vertex_buffer, 0, stride) ); + } } break; @@ -463,7 +543,7 @@ lp_setup_init_vbuf(struct lp_setup_context *setup) setup->base.map_vertices = lp_setup_map_vertices; setup->base.unmap_vertices = lp_setup_unmap_vertices; setup->base.set_primitive = lp_setup_set_primitive; - setup->base.draw = lp_setup_draw; + setup->base.draw_elements = lp_setup_draw_elements; setup->base.draw_arrays = lp_setup_draw_arrays; setup->base.release_vertices = lp_setup_release_vertices; setup->base.destroy = lp_setup_vbuf_destroy; diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h index 18143807c91..bae5de0cb35 100644 --- a/src/gallium/drivers/llvmpipe/lp_state.h +++ b/src/gallium/drivers/llvmpipe/lp_state.h @@ -63,6 +63,11 @@ struct llvmpipe_context; struct lp_fragment_shader; +/** Indexes into jit_function[] array */ +#define RAST_WHOLE 0 +#define RAST_EDGE_TEST 1 + + struct lp_fragment_shader_variant_key { struct pipe_depth_state depth; @@ -73,6 +78,7 @@ struct lp_fragment_shader_variant_key unsigned nr_cbufs:8; unsigned flatshade:1; unsigned scissor:1; + unsigned occlusion_count:1; struct { ubyte colormask; @@ -86,6 +92,8 @@ struct lp_fragment_shader_variant { struct lp_fragment_shader_variant_key key; + boolean opaque; + LLVMValueRef function[2]; lp_jit_frag_func jit_function[2]; diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c b/src/gallium/drivers/llvmpipe/lp_state_derived.c index 113d77ab788..2edfcb28ce6 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_derived.c +++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c @@ -163,7 +163,8 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe ) LP_NEW_DEPTH_STENCIL_ALPHA | LP_NEW_RASTERIZER | LP_NEW_SAMPLER | - LP_NEW_SAMPLER_VIEW)) + LP_NEW_SAMPLER_VIEW | + LP_NEW_QUERY)) llvmpipe_update_fs( llvmpipe ); if (llvmpipe->dirty & LP_NEW_BLEND_COLOR) diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 5f861d6ca4d..9ef78e6badf 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -87,7 +87,6 @@ #include "lp_bld_depth.h" #include "lp_bld_interp.h" #include "lp_context.h" -#include "lp_debug.h" #include "lp_perf.h" #include "lp_screen.h" #include "lp_setup.h" @@ -148,7 +147,8 @@ generate_depth_stencil(LLVMBuilderRef builder, LLVMValueRef stencil_refs[2], LLVMValueRef src, LLVMValueRef dst_ptr, - LLVMValueRef facing) + LLVMValueRef facing, + LLVMValueRef counter) { const struct util_format_description *format_desc; struct lp_type dst_type; @@ -195,7 +195,8 @@ generate_depth_stencil(LLVMBuilderRef builder, stencil_refs, src, dst_ptr, - facing); + facing, + counter); } @@ -400,7 +401,8 @@ generate_fs(struct llvmpipe_context *lp, LLVMValueRef c2, LLVMValueRef step0_ptr, LLVMValueRef step1_ptr, - LLVMValueRef step2_ptr) + LLVMValueRef step2_ptr, + LLVMValueRef counter) { const struct tgsi_token *tokens = shader->base.tokens; LLVMTypeRef vec_type; @@ -466,12 +468,13 @@ generate_fs(struct llvmpipe_context *lp, if (early_depth_stencil_test) generate_depth_stencil(builder, key, type, &mask, - stencil_refs, z, depth_ptr, facing); + stencil_refs, z, depth_ptr, facing, counter); lp_build_tgsi_soa(builder, tokens, type, &mask, consts_ptr, interp->pos, interp->inputs, outputs, sampler, &shader->info); + /* loop over fragment shader outputs/results */ for (attrib = 0; attrib < shader->info.num_outputs; ++attrib) { for(chan = 0; chan < NUM_CHANNELS; ++chan) { if(outputs[attrib][chan]) { @@ -513,7 +516,7 @@ generate_fs(struct llvmpipe_context *lp, if (!early_depth_stencil_test) generate_depth_stencil(builder, key, type, &mask, - stencil_refs, z, depth_ptr, facing); + stencil_refs, z, depth_ptr, facing, counter); lp_build_mask_end(&mask); @@ -528,9 +531,16 @@ generate_fs(struct llvmpipe_context *lp, /** * Generate color blending and color output. + * \param rt the render target index (to index blend, colormask state) + * \param type the pixel color type + * \param context_ptr pointer to the runtime JIT context + * \param mask execution mask (active fragment/pixel mask) + * \param src colors from the fragment shader + * \param dst_ptr the destination color buffer pointer */ static void generate_blend(const struct pipe_blend_state *blend, + unsigned rt, LLVMBuilderRef builder, struct lp_type type, LLVMValueRef context_ptr, @@ -561,6 +571,7 @@ generate_blend(const struct pipe_blend_state *blend, const_ptr = LLVMBuildBitCast(builder, const_ptr, LLVMPointerType(vec_type, 0), ""); + /* load constant blend color and colors from the dest color buffer */ for(chan = 0; chan < 4; ++chan) { LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), chan, 0); con[chan] = LLVMBuildLoad(builder, LLVMBuildGEP(builder, const_ptr, &index, 1, ""), ""); @@ -571,10 +582,12 @@ generate_blend(const struct pipe_blend_state *blend, lp_build_name(dst[chan], "dst.%c", "rgba"[chan]); } - lp_build_blend_soa(builder, blend, type, src, dst, con, res); + /* do blend */ + lp_build_blend_soa(builder, blend, type, rt, src, dst, con, res); + /* store results to color buffer */ for(chan = 0; chan < 4; ++chan) { - if(blend->rt[0].colormask & (1 << chan)) { + if(blend->rt[rt].colormask & (1 << chan)) { LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), chan, 0); lp_build_name(res[chan], "res.%c", "rgba"[chan]); res[chan] = lp_build_select(&bld, mask, res[chan], dst[chan]); @@ -587,20 +600,6 @@ generate_blend(const struct pipe_blend_state *blend, } -/** casting function to avoid compiler warnings */ -static lp_jit_frag_func -cast_voidptr_to_lp_jit_frag_func(void *p) -{ - union { - void *v; - lp_jit_frag_func f; - } tmp; - assert(sizeof(tmp.v) == sizeof(tmp.f)); - tmp.v = p; - return tmp.f; -} - - /** * Generate the runtime callable function for the whole fragment pipeline. * Note that the function which we generate operates on a block of 16 @@ -620,7 +619,7 @@ generate_fragment(struct llvmpipe_context *lp, LLVMTypeRef fs_elem_type; LLVMTypeRef fs_int_vec_type; LLVMTypeRef blend_vec_type; - LLVMTypeRef arg_types[15]; + LLVMTypeRef arg_types[16]; LLVMTypeRef func_type; LLVMTypeRef int32_vec4_type = lp_build_int32_vec4_type(); LLVMValueRef context_ptr; @@ -631,7 +630,7 @@ generate_fragment(struct llvmpipe_context *lp, LLVMValueRef dady_ptr; LLVMValueRef color_ptr_ptr; LLVMValueRef depth_ptr; - LLVMValueRef c0, c1, c2, step0_ptr, step1_ptr, step2_ptr; + LLVMValueRef c0, c1, c2, step0_ptr, step1_ptr, step2_ptr, counter = NULL; LLVMBasicBlockRef block; LLVMBuilderRef builder; LLVMValueRef x0; @@ -641,7 +640,6 @@ generate_fragment(struct llvmpipe_context *lp, LLVMValueRef fs_mask[LP_MAX_VECTOR_LENGTH]; LLVMValueRef fs_out_color[PIPE_MAX_COLOR_BUFS][NUM_CHANNELS][LP_MAX_VECTOR_LENGTH]; LLVMValueRef blend_mask; - LLVMValueRef blend_in_color[NUM_CHANNELS]; LLVMValueRef function; LLVMValueRef facing; unsigned num_fs; @@ -696,6 +694,7 @@ generate_fragment(struct llvmpipe_context *lp, arg_types[12] = LLVMPointerType(int32_vec4_type, 0);/* step0 */ arg_types[13] = LLVMPointerType(int32_vec4_type, 0);/* step1 */ arg_types[14] = LLVMPointerType(int32_vec4_type, 0);/* step2 */ + arg_types[15] = LLVMPointerType(LLVMInt32Type(), 0);/* counter */ func_type = LLVMFunctionType(LLVMVoidType(), arg_types, Elements(arg_types), 0); @@ -734,7 +733,7 @@ generate_fragment(struct llvmpipe_context *lp, lp_build_name(a0_ptr, "a0"); lp_build_name(dadx_ptr, "dadx"); lp_build_name(dady_ptr, "dady"); - lp_build_name(color_ptr_ptr, "color_ptr"); + lp_build_name(color_ptr_ptr, "color_ptr_ptr"); lp_build_name(depth_ptr, "depth"); lp_build_name(c0, "c0"); lp_build_name(c1, "c1"); @@ -743,6 +742,11 @@ generate_fragment(struct llvmpipe_context *lp, lp_build_name(step1_ptr, "step1"); lp_build_name(step2_ptr, "step2"); + if (key->occlusion_count) { + counter = LLVMGetParam(function, 15); + lp_build_name(counter, "counter"); + } + /* * Function body */ @@ -787,7 +791,7 @@ generate_fragment(struct llvmpipe_context *lp, facing, do_tri_test, c0, c1, c2, - step0_ptr, step1_ptr, step2_ptr); + step0_ptr, step1_ptr, step2_ptr, counter); for(cbuf = 0; cbuf < key->nr_cbufs; cbuf++) for(chan = 0; chan < NUM_CHANNELS; ++chan) @@ -801,6 +805,8 @@ generate_fragment(struct llvmpipe_context *lp, for(cbuf = 0; cbuf < key->nr_cbufs; cbuf++) { LLVMValueRef color_ptr; LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), cbuf, 0); + LLVMValueRef blend_in_color[NUM_CHANNELS]; + unsigned rt; /* * Convert the fs's output color and mask to fit to the blending type. @@ -821,10 +827,14 @@ generate_fragment(struct llvmpipe_context *lp, ""); lp_build_name(color_ptr, "color_ptr%d", cbuf); + /* which blend/colormask state to use */ + rt = key->blend.independent_blend_enable ? cbuf : 0; + /* * Blending. */ generate_blend(&key->blend, + rt, builder, blend_type, context_ptr, @@ -842,7 +852,7 @@ generate_fragment(struct llvmpipe_context *lp, #ifdef DEBUG if(LLVMVerifyFunction(function, LLVMPrintMessageAction)) { if (1) - LLVMDumpValue(function); + lp_debug_dump_value(function); abort(); } #endif @@ -851,9 +861,9 @@ generate_fragment(struct llvmpipe_context *lp, if (1) LLVMRunFunctionPassManager(screen->pass, function); - if (LP_DEBUG & DEBUG_JIT) { + if (gallivm_debug & GALLIVM_DEBUG_IR) { /* Print the LLVM IR to stderr */ - LLVMDumpValue(function); + lp_debug_dump_value(function); debug_printf("\n"); } @@ -865,12 +875,84 @@ generate_fragment(struct llvmpipe_context *lp, variant->jit_function[do_tri_test] = cast_voidptr_to_lp_jit_frag_func(f); - if (LP_DEBUG & DEBUG_ASM) + if (gallivm_debug & GALLIVM_DEBUG_ASM) { lp_disassemble(f); + } } } +static void +dump_fs_variant_key(const struct lp_fragment_shader_variant_key *key) +{ + unsigned i; + + debug_printf("fs variant %p:\n", (void *) key); + + if (key->depth.enabled) { + debug_printf("depth.format = %s\n", util_format_name(key->zsbuf_format)); + debug_printf("depth.func = %s\n", util_dump_func(key->depth.func, TRUE)); + debug_printf("depth.writemask = %u\n", key->depth.writemask); + } + + for (i = 0; i < 2; ++i) { + if (key->stencil[i].enabled) { + debug_printf("stencil[%u].func = %s\n", i, util_dump_func(key->stencil[i].func, TRUE)); + debug_printf("stencil[%u].fail_op = %s\n", i, util_dump_stencil_op(key->stencil[i].fail_op, TRUE)); + debug_printf("stencil[%u].zpass_op = %s\n", i, util_dump_stencil_op(key->stencil[i].zpass_op, TRUE)); + debug_printf("stencil[%u].zfail_op = %s\n", i, util_dump_stencil_op(key->stencil[i].zfail_op, TRUE)); + debug_printf("stencil[%u].valuemask = 0x%x\n", i, key->stencil[i].valuemask); + debug_printf("stencil[%u].writemask = 0x%x\n", i, key->stencil[i].writemask); + } + } + + if (key->alpha.enabled) { + debug_printf("alpha.func = %s\n", util_dump_func(key->alpha.func, TRUE)); + debug_printf("alpha.ref_value = %f\n", key->alpha.ref_value); + } + + if (key->blend.logicop_enable) { + debug_printf("blend.logicop_func = %s\n", util_dump_logicop(key->blend.logicop_func, TRUE)); + } + else if (key->blend.rt[0].blend_enable) { + debug_printf("blend.rgb_func = %s\n", util_dump_blend_func (key->blend.rt[0].rgb_func, TRUE)); + debug_printf("blend.rgb_src_factor = %s\n", util_dump_blend_factor(key->blend.rt[0].rgb_src_factor, TRUE)); + debug_printf("blend.rgb_dst_factor = %s\n", util_dump_blend_factor(key->blend.rt[0].rgb_dst_factor, TRUE)); + debug_printf("blend.alpha_func = %s\n", util_dump_blend_func (key->blend.rt[0].alpha_func, TRUE)); + debug_printf("blend.alpha_src_factor = %s\n", util_dump_blend_factor(key->blend.rt[0].alpha_src_factor, TRUE)); + debug_printf("blend.alpha_dst_factor = %s\n", util_dump_blend_factor(key->blend.rt[0].alpha_dst_factor, TRUE)); + } + debug_printf("blend.colormask = 0x%x\n", key->blend.rt[0].colormask); + for (i = 0; i < PIPE_MAX_SAMPLERS; ++i) { + if (key->sampler[i].format) { + debug_printf("sampler[%u] = \n", i); + debug_printf(" .format = %s\n", + util_format_name(key->sampler[i].format)); + debug_printf(" .target = %s\n", + util_dump_tex_target(key->sampler[i].target, TRUE)); + debug_printf(" .pot = %u %u %u\n", + key->sampler[i].pot_width, + key->sampler[i].pot_height, + key->sampler[i].pot_depth); + debug_printf(" .wrap = %s %s %s\n", + util_dump_tex_wrap(key->sampler[i].wrap_s, TRUE), + util_dump_tex_wrap(key->sampler[i].wrap_t, TRUE), + util_dump_tex_wrap(key->sampler[i].wrap_r, TRUE)); + debug_printf(" .min_img_filter = %s\n", + util_dump_tex_filter(key->sampler[i].min_img_filter, TRUE)); + debug_printf(" .min_mip_filter = %s\n", + util_dump_tex_mipfilter(key->sampler[i].min_mip_filter, TRUE)); + debug_printf(" .mag_img_filter = %s\n", + util_dump_tex_filter(key->sampler[i].mag_img_filter, TRUE)); + if (key->sampler[i].compare_mode != PIPE_TEX_COMPARE_NONE) + debug_printf(" .compare_func = %s\n", util_dump_func(key->sampler[i].compare_func, TRUE)); + debug_printf(" .normalized_coords = %u\n", key->sampler[i].normalized_coords); + } + } +} + + + static struct lp_fragment_shader_variant * generate_variant(struct llvmpipe_context *lp, struct lp_fragment_shader *shader, @@ -878,57 +960,9 @@ generate_variant(struct llvmpipe_context *lp, { struct lp_fragment_shader_variant *variant; - if (LP_DEBUG & DEBUG_JIT) { - unsigned i; - + if (gallivm_debug & GALLIVM_DEBUG_IR) { tgsi_dump(shader->base.tokens, 0); - if(key->depth.enabled) { - debug_printf("depth.format = %s\n", util_format_name(key->zsbuf_format)); - debug_printf("depth.func = %s\n", util_dump_func(key->depth.func, TRUE)); - debug_printf("depth.writemask = %u\n", key->depth.writemask); - } - if(key->alpha.enabled) { - debug_printf("alpha.func = %s\n", util_dump_func(key->alpha.func, TRUE)); - debug_printf("alpha.ref_value = %f\n", key->alpha.ref_value); - } - if(key->blend.logicop_enable) { - debug_printf("blend.logicop_func = %u\n", key->blend.logicop_func); - } - else if(key->blend.rt[0].blend_enable) { - debug_printf("blend.rgb_func = %s\n", util_dump_blend_func (key->blend.rt[0].rgb_func, TRUE)); - debug_printf("rgb_src_factor = %s\n", util_dump_blend_factor(key->blend.rt[0].rgb_src_factor, TRUE)); - debug_printf("rgb_dst_factor = %s\n", util_dump_blend_factor(key->blend.rt[0].rgb_dst_factor, TRUE)); - debug_printf("alpha_func = %s\n", util_dump_blend_func (key->blend.rt[0].alpha_func, TRUE)); - debug_printf("alpha_src_factor = %s\n", util_dump_blend_factor(key->blend.rt[0].alpha_src_factor, TRUE)); - debug_printf("alpha_dst_factor = %s\n", util_dump_blend_factor(key->blend.rt[0].alpha_dst_factor, TRUE)); - } - debug_printf("blend.colormask = 0x%x\n", key->blend.rt[0].colormask); - for(i = 0; i < PIPE_MAX_SAMPLERS; ++i) { - if(key->sampler[i].format) { - debug_printf("sampler[%u] = \n", i); - debug_printf(" .format = %s\n", - util_format_name(key->sampler[i].format)); - debug_printf(" .target = %s\n", - util_dump_tex_target(key->sampler[i].target, TRUE)); - debug_printf(" .pot = %u %u %u\n", - key->sampler[i].pot_width, - key->sampler[i].pot_height, - key->sampler[i].pot_depth); - debug_printf(" .wrap = %s %s %s\n", - util_dump_tex_wrap(key->sampler[i].wrap_s, TRUE), - util_dump_tex_wrap(key->sampler[i].wrap_t, TRUE), - util_dump_tex_wrap(key->sampler[i].wrap_r, TRUE)); - debug_printf(" .min_img_filter = %s\n", - util_dump_tex_filter(key->sampler[i].min_img_filter, TRUE)); - debug_printf(" .min_mip_filter = %s\n", - util_dump_tex_mipfilter(key->sampler[i].min_mip_filter, TRUE)); - debug_printf(" .mag_img_filter = %s\n", - util_dump_tex_filter(key->sampler[i].mag_img_filter, TRUE)); - if(key->sampler[i].compare_mode != PIPE_TEX_COMPARE_NONE) - debug_printf(" .compare_func = %s\n", util_dump_func(key->sampler[i].compare_func, TRUE)); - debug_printf(" .normalized_coords = %u\n", key->sampler[i].normalized_coords); - } - } + dump_fs_variant_key(key); } variant = CALLOC_STRUCT(lp_fragment_shader_variant); @@ -937,8 +971,20 @@ generate_variant(struct llvmpipe_context *lp, memcpy(&variant->key, key, sizeof *key); - generate_fragment(lp, shader, variant, 0); - generate_fragment(lp, shader, variant, 1); + generate_fragment(lp, shader, variant, RAST_WHOLE); + generate_fragment(lp, shader, variant, RAST_EDGE_TEST); + + /* TODO: most of these can be relaxed, in particular the colormask */ + variant->opaque = + !key->blend.logicop_enable && + !key->blend.rt[0].blend_enable && + key->blend.rt[0].colormask == 0xf && + !key->stencil[0].enabled && + !key->alpha.enabled && + !key->depth.enabled && + !key->scissor && + !shader->info.uses_kill + ? TRUE : FALSE; /* insert new variant into linked list */ variant->next = shader->variants; @@ -964,7 +1010,7 @@ llvmpipe_create_fs_state(struct pipe_context *pipe, /* we need to keep a local copy of the tokens */ shader->base.tokens = tgsi_dup_tokens(templ->tokens); - if (LP_DEBUG & DEBUG_TGSI) { + if (gallivm_debug & GALLIVM_DEBUG_TGSI) { debug_printf("llvmpipe: Create fragment shader %p:\n", (void *) shader); tgsi_dump(templ->tokens, 0); } @@ -1123,6 +1169,9 @@ make_variant_key(struct llvmpipe_context *lp, key->flatshade = lp->rasterizer->flatshade; key->scissor = lp->rasterizer->scissor; + if (lp->active_query_count) { + key->occlusion_count = TRUE; + } if (lp->framebuffer.nr_cbufs) { memcpy(&key->blend, lp->blend, sizeof key->blend); @@ -1187,7 +1236,6 @@ llvmpipe_update_fs(struct llvmpipe_context *lp) struct lp_fragment_shader *shader = lp->fs; struct lp_fragment_shader_variant_key key; struct lp_fragment_shader_variant *variant; - boolean opaque; make_variant_key(lp, shader, &key); @@ -1212,22 +1260,10 @@ llvmpipe_update_fs(struct llvmpipe_context *lp) LP_COUNT_ADD(nr_llvm_compiles, 2); /* emit vs. omit in/out test */ } - /* TODO: put this in the variant */ - /* TODO: most of these can be relaxed, in particular the colormask */ - opaque = !key.blend.logicop_enable && - !key.blend.rt[0].blend_enable && - key.blend.rt[0].colormask == 0xf && - !key.stencil[0].enabled && - !key.alpha.enabled && - !key.depth.enabled && - !key.scissor && - !shader->info.uses_kill - ? TRUE : FALSE; - lp_setup_set_fs_functions(lp->setup, variant->jit_function[RAST_WHOLE], variant->jit_function[RAST_EDGE_TEST], - opaque); + variant->opaque); } diff --git a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c index 622eb47ff45..afd3e0b21c9 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c +++ b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c @@ -67,8 +67,8 @@ llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, void *handle) */ if (llvmpipe->rasterizer) { lp_setup_set_triangle_state( llvmpipe->setup, - llvmpipe->rasterizer->cull_mode, - llvmpipe->rasterizer->front_winding == PIPE_WINDING_CCW, + llvmpipe->rasterizer->cull_face, + llvmpipe->rasterizer->front_ccw, llvmpipe->rasterizer->scissor, llvmpipe->rasterizer->gl_rasterization_rules); lp_setup_set_flatshade_first( llvmpipe->setup, diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c index fae7bf3fcf2..072d699666b 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c @@ -52,6 +52,19 @@ enum vector_mode typedef void (*blend_test_ptr_t)(const void *src, const void *dst, const void *con, void *res); +/** cast wrapper */ +static blend_test_ptr_t +voidptr_to_blend_test_ptr_t(void *p) +{ + union { + void *v; + blend_test_ptr_t f; + } u; + u.v = p; + return u.f; +} + + void write_tsv_header(FILE *fp) @@ -163,6 +176,7 @@ add_blend_test(LLVMModuleRef module, LLVMValueRef res_ptr; LLVMBasicBlockRef block; LLVMBuilderRef builder; + const unsigned rt = 0; vec_type = lp_build_vec_type(type); @@ -188,7 +202,7 @@ add_blend_test(LLVMModuleRef module, dst = LLVMBuildLoad(builder, dst_ptr, "dst"); con = LLVMBuildLoad(builder, const_ptr, "const"); - res = lp_build_blend_aos(builder, blend, type, src, dst, con, 3); + res = lp_build_blend_aos(builder, blend, type, rt, src, dst, con, 3); lp_build_name(res, "res"); @@ -212,7 +226,7 @@ add_blend_test(LLVMModuleRef module, lp_build_name(dst[i], "dst.%c", "rgba"[i]); } - lp_build_blend_soa(builder, blend, type, src, dst, con, res); + lp_build_blend_soa(builder, blend, type, rt, src, dst, con, res); for(i = 0; i < 4; ++i) { LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0); @@ -481,6 +495,7 @@ test_one(unsigned verbose, int64_t cycles[LP_TEST_NUM_SAMPLES]; double cycles_avg = 0.0; unsigned i, j; + void *code; if(verbose >= 1) dump_blend_type(stdout, blend, mode, type); @@ -522,10 +537,11 @@ test_one(unsigned verbose, if(verbose >= 2) LLVMDumpModule(module); - blend_test_ptr = (blend_test_ptr_t)LLVMGetPointerToGlobal(engine, func); + code = LLVMGetPointerToGlobal(engine, func); + blend_test_ptr = voidptr_to_blend_test_ptr_t(code); if(verbose >= 2) - lp_disassemble(blend_test_ptr); + lp_disassemble(code); success = TRUE; for(i = 0; i < n && success; ++i) { diff --git a/src/gallium/drivers/llvmpipe/lp_test_conv.c b/src/gallium/drivers/llvmpipe/lp_test_conv.c index 958cc40538e..254f0daea3b 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_conv.c +++ b/src/gallium/drivers/llvmpipe/lp_test_conv.c @@ -43,6 +43,17 @@ typedef void (*conv_test_ptr_t)(const void *src, const void *dst); +/** cast wrapper */ +static conv_test_ptr_t +voidptr_to_conv_test_ptr_t(void *p) +{ + union { + void *v; + conv_test_ptr_t f; + } u; + u.v = p; + return u.f; +} void write_tsv_header(FILE *fp) @@ -164,6 +175,7 @@ test_one(unsigned verbose, unsigned num_dsts; double eps; unsigned i, j; + void *code; if(verbose >= 1) dump_conv_types(stdout, src_type, dst_type); @@ -221,10 +233,11 @@ test_one(unsigned verbose, if(verbose >= 2) LLVMDumpModule(module); - conv_test_ptr = (conv_test_ptr_t)LLVMGetPointerToGlobal(engine, func); + code = LLVMGetPointerToGlobal(engine, func); + conv_test_ptr = voidptr_to_conv_test_ptr_t(code); if(verbose >= 2) - lp_disassemble(conv_test_ptr); + lp_disassemble(code); success = TRUE; for(i = 0; i < n && success; ++i) { @@ -384,7 +397,7 @@ test_all(unsigned verbose, FILE *fp) { const struct lp_type *src_type; const struct lp_type *dst_type; - bool success = TRUE; + boolean success = TRUE; for(src_type = conv_types; src_type < &conv_types[num_types]; ++src_type) { for(dst_type = conv_types; dst_type < &conv_types[num_types]; ++dst_type) { @@ -411,7 +424,7 @@ test_some(unsigned verbose, FILE *fp, unsigned long n) const struct lp_type *src_type; const struct lp_type *dst_type; unsigned long i; - bool success = TRUE; + boolean success = TRUE; for(i = 0; i < n; ++i) { src_type = &conv_types[rand() % num_types]; diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c index fbac815d107..267f1487bb8 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_format.c +++ b/src/gallium/drivers/llvmpipe/lp_test_format.c @@ -73,6 +73,19 @@ typedef void (*fetch_ptr_t)(float *, const void *packed, unsigned i, unsigned j); +/** cast wrapper to avoid warnings */ +static fetch_ptr_t +void_to_fetch_ptr_t(void *p) +{ + union { + void *v; + fetch_ptr_t f; + } u; + u.v = p; + return u.f; +} + + static LLVMValueRef add_fetch_rgba_test(LLVMModuleRef lp_build_module, @@ -125,7 +138,7 @@ test_format(unsigned verbose, FILE *fp, fetch_ptr_t fetch_ptr; float unpacked[4]; boolean success; - unsigned i; + unsigned i, j, k; fetch = add_fetch_rgba_test(lp_build_module, desc); @@ -149,31 +162,39 @@ test_format(unsigned verbose, FILE *fp, (void)pass; #endif - fetch_ptr = (fetch_ptr_t) LLVMGetPointerToGlobal(lp_build_engine, fetch); + fetch_ptr = void_to_fetch_ptr_t(LLVMGetPointerToGlobal(lp_build_engine, fetch)); - memset(unpacked, 0, sizeof unpacked); + for (i = 0; i < desc->block.height; ++i) { + for (j = 0; j < desc->block.width; ++j) { - fetch_ptr(unpacked, test->packed, 0, 0); + memset(unpacked, 0, sizeof unpacked); - success = TRUE; - for(i = 0; i < 4; ++i) - if (fabs((float)test->unpacked[0][0][i] - unpacked[i]) > FLT_EPSILON) - success = FALSE; + fetch_ptr(unpacked, test->packed, j, i); - if (!success) { - printf("FAILED\n"); - printf(" Packed: %02x %02x %02x %02x\n", - test->packed[0], test->packed[1], test->packed[2], test->packed[3]); - printf(" Unpacked: %f %f %f %f obtained\n", - unpacked[0], unpacked[1], unpacked[2], unpacked[3]); - printf(" %f %f %f %f expected\n", - test->unpacked[0][0][0], - test->unpacked[0][0][1], - test->unpacked[0][0][2], - test->unpacked[0][0][3]); - LLVMDumpValue(fetch); + success = TRUE; + for(k = 0; k < 4; ++k) + if (fabs((float)test->unpacked[i][j][k] - unpacked[k]) > FLT_EPSILON) + success = FALSE; + + if (!success) { + printf("FAILED\n"); + printf(" Packed: %02x %02x %02x %02x\n", + test->packed[0], test->packed[1], test->packed[2], test->packed[3]); + printf(" Unpacked (%u,%u): %f %f %f %f obtained\n", + j, i, + unpacked[0], unpacked[1], unpacked[2], unpacked[3]); + printf(" %f %f %f %f expected\n", + test->unpacked[i][j][0], + test->unpacked[i][j][1], + test->unpacked[i][j][2], + test->unpacked[i][j][3]); + } + } } + if (!success) + LLVMDumpValue(fetch); + LLVMFreeMachineCodeForFunction(lp_build_engine, fetch); LLVMDeleteFunction(fetch); @@ -193,20 +214,23 @@ test_one(unsigned verbose, FILE *fp, const struct util_format_description *format_desc) { unsigned i; - bool success = TRUE; - - printf("Testing %s ...\n", - format_desc->name); + boolean first = TRUE; + boolean success = TRUE; for (i = 0; i < util_format_nr_test_cases; ++i) { const struct util_format_test_case *test = &util_format_test_cases[i]; if (test->format == format_desc->format) { + if (first) { + printf("Testing %s ...\n", + format_desc->name); + first = FALSE; + } + if (!test_format(verbose, fp, format_desc, test)) { success = FALSE; } - } } @@ -218,7 +242,7 @@ boolean test_all(unsigned verbose, FILE *fp) { enum pipe_format format; - bool success = TRUE; + boolean success = TRUE; for (format = 1; format < PIPE_FORMAT_COUNT; ++format) { const struct util_format_description *format_desc; @@ -232,9 +256,7 @@ test_all(unsigned verbose, FILE *fp) * TODO: test more */ - if (format_desc->block.width != 1 || - format_desc->block.height != 1 || - format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) { + if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) { continue; } diff --git a/src/gallium/drivers/llvmpipe/lp_test_printf.c b/src/gallium/drivers/llvmpipe/lp_test_printf.c index e5e5925012a..13485c37748 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_printf.c +++ b/src/gallium/drivers/llvmpipe/lp_test_printf.c @@ -41,6 +41,7 @@ struct printf_test_case { + int foo; }; void @@ -57,6 +58,19 @@ write_tsv_header(FILE *fp) typedef void (*test_printf_t)(int i); +/** cast wrapper */ +static test_printf_t +voidptr_to_test_printf_t(void *p) +{ + union { + void *v; + test_printf_t f; + } u; + u.v = p; + return u.f; +} + + static LLVMValueRef add_printf_test(LLVMModuleRef module) { @@ -91,6 +105,7 @@ test_printf(unsigned verbose, FILE *fp, const struct printf_test_case *testcase) float unpacked[4]; unsigned packed; boolean success = TRUE; + void *code; module = LLVMModuleCreateWithName("test"); @@ -124,7 +139,8 @@ test_printf(unsigned verbose, FILE *fp, const struct printf_test_case *testcase) (void)pass; #endif - test_printf = (test_printf_t)LLVMGetPointerToGlobal(engine, test); + code = LLVMGetPointerToGlobal(engine, test); + test_printf = voidptr_to_test_printf_t(code); memset(unpacked, 0, sizeof unpacked); packed = 0; @@ -147,7 +163,7 @@ test_printf(unsigned verbose, FILE *fp, const struct printf_test_case *testcase) boolean test_all(unsigned verbose, FILE *fp) { - bool success = TRUE; + boolean success = TRUE; test_printf(verbose, fp, NULL); diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c index d3a9d39f616..65208dd5d5c 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c @@ -87,7 +87,7 @@ struct lp_llvm_sampler_soa * @sa http://llvm.org/docs/GetElementPtr.html */ static LLVMValueRef -lp_llvm_texture_member(struct lp_sampler_dynamic_state *base, +lp_llvm_texture_member(const struct lp_sampler_dynamic_state *base, LLVMBuilderRef builder, unsigned unit, unsigned member_index, @@ -135,7 +135,7 @@ lp_llvm_texture_member(struct lp_sampler_dynamic_state *base, */ #define LP_LLVM_TEXTURE_MEMBER(_name, _index, _emit_load) \ static LLVMValueRef \ - lp_llvm_texture_##_name( struct lp_sampler_dynamic_state *base, \ + lp_llvm_texture_##_name( const struct lp_sampler_dynamic_state *base, \ LLVMBuilderRef builder, \ unsigned unit) \ { \ @@ -164,7 +164,7 @@ lp_llvm_sampler_soa_destroy(struct lp_build_sampler_soa *sampler) * The 'texel' parameter returns four vectors corresponding to R, G, B, A. */ static void -lp_llvm_sampler_soa_emit_fetch_texel(struct lp_build_sampler_soa *base, +lp_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base, LLVMBuilderRef builder, struct lp_type type, unsigned unit, diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 2f41d620c8a..4eed687ac71 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -39,6 +39,7 @@ #include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" +#include "util/u_simple_list.h" #include "util/u_transfer.h" #include "lp_context.h" @@ -51,6 +52,11 @@ #include "state_tracker/sw_winsys.h" +#ifdef DEBUG +static struct llvmpipe_resource resource_list; +#endif + + static INLINE boolean resource_is_texture(const struct pipe_resource *resource) { @@ -107,32 +113,55 @@ llvmpipe_texture_layout(struct llvmpipe_screen *screen, assert(LP_MAX_TEXTURE_3D_LEVELS <= LP_MAX_TEXTURE_LEVELS); for (level = 0; level <= pt->last_level; level++) { - const unsigned width_t = align(width, TILE_SIZE) / TILE_SIZE; - const unsigned height_t = align(height, TILE_SIZE) / TILE_SIZE; - unsigned nblocksx, num_slices; - - if (lpr->base.target == PIPE_TEXTURE_CUBE) - num_slices = 6; - else if (lpr->base.target == PIPE_TEXTURE_3D) - num_slices = depth; - else - num_slices = 1; - - /* Allocate storage for whole quads. This is particularly important - * for depth surfaces, which are currently stored in a swizzled format. - */ - nblocksx = util_format_get_nblocksx(pt->format, align(width, TILE_SIZE)); - lpr->row_stride[level] = - align(nblocksx * util_format_get_blocksize(pt->format), 16); + /* Row stride and image stride (for linear layout) */ + { + unsigned alignment, nblocksx, nblocksy, block_size; + + /* For non-compressed formats we need to align the texture size + * to the tile size to facilitate render-to-texture. + */ + if (util_format_is_compressed(pt->format)) + alignment = 1; + else + alignment = TILE_SIZE; + + nblocksx = util_format_get_nblocksx(pt->format, + align(width, alignment)); + nblocksy = util_format_get_nblocksy(pt->format, + align(height, alignment)); + block_size = util_format_get_blocksize(pt->format); - lpr->img_stride[level] = lpr->row_stride[level] * align(height, TILE_SIZE); + lpr->row_stride[level] = align(nblocksx * block_size, 16); - lpr->tiles_per_row[level] = width_t; - lpr->tiles_per_image[level] = width_t * height_t; - lpr->num_slices_faces[level] = num_slices; - lpr->layout[level] = alloc_layout_array(num_slices, width, height); + lpr->img_stride[level] = lpr->row_stride[level] * nblocksy; + } + /* Size of the image in tiles (for tiled layout) */ + { + const unsigned width_t = align(width, TILE_SIZE) / TILE_SIZE; + const unsigned height_t = align(height, TILE_SIZE) / TILE_SIZE; + lpr->tiles_per_row[level] = width_t; + lpr->tiles_per_image[level] = width_t * height_t; + } + + /* Number of 3D image slices or cube faces */ + { + unsigned num_slices; + + if (lpr->base.target == PIPE_TEXTURE_CUBE) + num_slices = 6; + else if (lpr->base.target == PIPE_TEXTURE_3D) + num_slices = depth; + else + num_slices = 1; + + lpr->num_slices_faces[level] = num_slices; + + lpr->layout[level] = alloc_layout_array(num_slices, width, height); + } + + /* Compute size of next mipmap level */ width = u_minify(width, 1); height = u_minify(height, 1); depth = u_minify(depth, 1); @@ -222,6 +251,10 @@ llvmpipe_resource_create(struct pipe_screen *_screen, lpr->id = id_counter++; +#ifdef DEBUG + insert_at_tail(&resource_list, lpr); +#endif + return &lpr->base; fail: @@ -280,6 +313,11 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen, align_free(lpr->data); } +#ifdef DEBUG + if (lpr->next) + remove_from_list(lpr); +#endif + FREE(lpr); } @@ -450,7 +488,7 @@ static struct pipe_surface * llvmpipe_get_tex_surface(struct pipe_screen *screen, struct pipe_resource *pt, unsigned face, unsigned level, unsigned zslice, - enum lp_texture_usage usage) + unsigned usage) { struct pipe_surface *ps; @@ -698,11 +736,8 @@ tex_image_face_size(const struct llvmpipe_resource *lpr, unsigned level, return buffer_size; } else { - const enum pipe_format format = lpr->base.format; - const unsigned nblocksy = - util_format_get_nblocksy(format, align(height, TILE_SIZE)); - const unsigned buffer_size = nblocksy * lpr->row_stride[level]; - return buffer_size; + /* we already computed this */ + return lpr->img_stride[level]; } } @@ -1188,9 +1223,43 @@ llvmpipe_resource_size(const struct pipe_resource *resource) } +#ifdef DEBUG +void +llvmpipe_print_resources(void) +{ + struct llvmpipe_resource *lpr; + unsigned n = 0, total = 0; + + debug_printf("LLVMPIPE: current resources:\n"); + foreach(lpr, &resource_list) { + unsigned size = llvmpipe_resource_size(&lpr->base); + debug_printf("resource %u at %p, size %ux%ux%u: %u bytes, refcount %u\n", + lpr->id, (void *) lpr, + lpr->base.width0, lpr->base.height0, lpr->base.depth0, + size, lpr->base.reference.count); + total += size; + n++; + } + debug_printf("LLVMPIPE: total size of %u resources: %u\n", n, total); +} +#endif + + void llvmpipe_init_screen_resource_funcs(struct pipe_screen *screen) { +#ifdef DEBUG + /* init linked list for tracking resources */ + { + static boolean first_call = TRUE; + if (first_call) { + memset(&resource_list, 0, sizeof(resource_list)); + make_empty_list(&resource_list); + first_call = FALSE; + } + } +#endif + screen->resource_create = llvmpipe_resource_create; screen->resource_destroy = llvmpipe_resource_destroy; screen->resource_from_handle = llvmpipe_resource_from_handle; diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h index a8d08d6247f..503b6a19a8d 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.h +++ b/src/gallium/drivers/llvmpipe/lp_texture.h @@ -119,6 +119,11 @@ struct llvmpipe_resource unsigned timestamp; unsigned id; /**< temporary, for debugging */ + +#ifdef DEBUG + /** for linked list */ + struct llvmpipe_resource *prev, *next; +#endif }; @@ -220,6 +225,10 @@ llvmpipe_get_texture_tile(struct llvmpipe_resource *lpr, extern void +llvmpipe_print_resources(void); + + +extern void llvmpipe_init_screen_texture_funcs(struct pipe_screen *screen); extern void diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 89d5ffa8aa3..60bdd7276aa 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -5,6 +5,7 @@ #include "util/u_memory.h" #include "util/u_inlines.h" #include "util/u_format.h" +#include "util/u_format_s3tc.h" #include <stdio.h> #include <errno.h> @@ -246,6 +247,8 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) pscreen->fence_signalled = nouveau_screen_fence_signalled; pscreen->fence_finish = nouveau_screen_fence_finish; + util_format_s3tc_init(); + return 0; } diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 0156ff95ff9..97f938e6980 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -4208,9 +4208,12 @@ static void nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p) { struct nouveau_channel *chan = nv50->screen->base.channel; + struct nouveau_grobj *tesla = nv50->screen->tesla; struct nv50_program_exec *e; uint32_t *up, i; boolean upload = FALSE; + unsigned offset; + int width; if (!p->bo) { nouveau_bo_new(chan->device, NOUVEAU_BO_VRAM, 0x100, @@ -4267,10 +4270,22 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p) NOUVEAU_ERR("0x%08x\n", e->inst[1]); } #endif - nv50_upload_sifc(nv50, p->bo, 0, NOUVEAU_BO_VRAM, - NV50_2D_DST_FORMAT_R8_UNORM, 65536, 1, 262144, - up, NV50_2D_SIFC_FORMAT_R8_UNORM, 0, - 0, 0, p->exec_size * 4, 1, 1); + + /* SIFC_HEIGHT/SIFC_WIDTH of 65536 do not work, and are not reported + * as data error either. hw bug ? */ +#define SIFC_MAX_WIDTH (65536 - 256) + offset = 0; + width = p->exec_size * 4; + while (width > 0) { + nv50_upload_sifc(nv50, p->bo, offset, NOUVEAU_BO_VRAM, + NV50_2D_DST_FORMAT_R8_UNORM, 65536, 1, 262144, + &up[offset / 4], NV50_2D_SIFC_FORMAT_R8_UNORM, + 0, 0, 0, MIN2(SIFC_MAX_WIDTH, width), 1, 1); + width -= SIFC_MAX_WIDTH; + offset += SIFC_MAX_WIDTH; + } + BEGIN_RING(chan, tesla, NV50TCL_CODE_CB_FLUSH, 1); + OUT_RING (chan, 0); FREE(up); } diff --git a/src/gallium/drivers/nv50/nv50_push.c b/src/gallium/drivers/nv50/nv50_push.c index 244242b8434..c3ac8041462 100644 --- a/src/gallium/drivers/nv50/nv50_push.c +++ b/src/gallium/drivers/nv50/nv50_push.c @@ -108,7 +108,7 @@ emit_vertex(struct push_context *ctx, unsigned n) int i; if (ctx->edgeflag_attr < 16) { - float *edgeflag = ctx->attr[ctx->edgeflag_attr].map + + float *edgeflag = (uint8_t *)ctx->attr[ctx->edgeflag_attr].map + ctx->attr[ctx->edgeflag_attr].stride * n; if (*edgeflag != ctx->edgeflag) { @@ -120,7 +120,8 @@ emit_vertex(struct push_context *ctx, unsigned n) BEGIN_RING_NI(chan, tesla, NV50TCL_VERTEX_DATA, ctx->vtx_size); for (i = 0; i < ctx->attr_nr; i++) - ctx->attr[i].push(chan, ctx->attr[i].map + ctx->attr[i].stride * n); + ctx->attr[i].push(chan, + (uint8_t *)ctx->attr[i].map + ctx->attr[i].stride * n); } static void @@ -243,14 +244,14 @@ nv50_push_elements_instanced(struct pipe_context *pipe, assert(bo->map); return; } - ctx.attr[n].map = bo->map + vb->buffer_offset + ve->src_offset; + ctx.attr[n].map = (uint8_t *)bo->map + vb->buffer_offset + ve->src_offset; nouveau_bo_unmap(bo); ctx.attr[n].stride = vb->stride; ctx.attr[n].divisor = ve->instance_divisor; if (ctx.attr[n].divisor) { ctx.attr[n].step = i_start % ve->instance_divisor; - ctx.attr[n].map += i_start * vb->stride; + ctx.attr[n].map = (uint8_t *)ctx.attr[n].map + i_start * vb->stride; } size = util_format_get_component_bits(ve->src_format, @@ -331,7 +332,7 @@ nv50_push_elements_instanced(struct pipe_context *pipe, ctx.attr[i].divisor != ++ctx.attr[i].step) continue; ctx.attr[i].step = 0; - ctx.attr[i].map += ctx.attr[i].stride; + ctx.attr[i].map = (uint8_t *)ctx.attr[i].map + ctx.attr[i].stride; } u_split_prim_init(&s, mode, start, count); diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index a8cb1e25d81..2c0caada366 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -20,6 +20,7 @@ * SOFTWARE. */ +#include "util/u_format_s3tc.h" #include "pipe/p_screen.h" #include "nv50_context.h" @@ -64,6 +65,17 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen, break; } } else { + if (tex_usage & PIPE_BIND_SAMPLER_VIEW) { + switch (format) { + case PIPE_FORMAT_DXT1_RGB: + case PIPE_FORMAT_DXT1_RGBA: + case PIPE_FORMAT_DXT3_RGBA: + case PIPE_FORMAT_DXT5_RGBA: + return util_format_s3tc_enabled; + default: + break; + } + } switch (format) { case PIPE_FORMAT_B8G8R8A8_UNORM: case PIPE_FORMAT_B8G8R8X8_UNORM: @@ -76,10 +88,6 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen, case PIPE_FORMAT_A8_UNORM: case PIPE_FORMAT_I8_UNORM: case PIPE_FORMAT_L8A8_UNORM: - case PIPE_FORMAT_DXT1_RGB: - case PIPE_FORMAT_DXT1_RGBA: - case PIPE_FORMAT_DXT3_RGBA: - case PIPE_FORMAT_DXT5_RGBA: case PIPE_FORMAT_S8_USCALED_Z24_UNORM: case PIPE_FORMAT_Z24_UNORM_S8_USCALED: case PIPE_FORMAT_Z32_FLOAT: @@ -98,7 +106,7 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen, } static int -nv50_screen_get_param(struct pipe_screen *pscreen, int param) +nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) { switch (param) { case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: @@ -121,6 +129,8 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param) return 8; case PIPE_CAP_OCCLUSION_QUERY: return 1; + case PIPE_CAP_TIMER_QUERY: + return 0; case PIPE_CAP_TEXTURE_SHADOW_MAP: return 1; case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: @@ -146,6 +156,34 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param) case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: return 0; + case PIPE_CAP_MAX_VS_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_TEX_INDIRECTIONS: + case PIPE_CAP_MAX_FS_TEX_INDIRECTIONS: /* arbitrary limit */ + return 16384; + case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH: + case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH: /* need stack bo */ + return 4; + case PIPE_CAP_MAX_VS_INPUTS: + return 16; + case PIPE_CAP_MAX_FS_INPUTS: /* 128 / 4 with GP */ + return 64 / 4; + case PIPE_CAP_MAX_VS_CONSTS: + case PIPE_CAP_MAX_FS_CONSTS: + return 65536 / 16; + case PIPE_CAP_MAX_VS_ADDRS: + case PIPE_CAP_MAX_FS_ADDRS: /* no spilling atm */ + return 1; + case PIPE_CAP_MAX_VS_PREDS: + case PIPE_CAP_MAX_FS_PREDS: /* not yet handled */ + return 0; + case PIPE_CAP_MAX_VS_TEMPS: + case PIPE_CAP_MAX_FS_TEMPS: /* no spilling atm */ + return 128 / 4; default: NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); return 0; @@ -153,7 +191,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param) } static float -nv50_screen_get_paramf(struct pipe_screen *pscreen, int param) +nv50_screen_get_paramf(struct pipe_screen *pscreen, enum pipe_cap param) { switch (param) { case PIPE_CAP_MAX_LINE_WIDTH: diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index cf4105bcb77..f8bff764f27 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -345,7 +345,7 @@ nv50_rasterizer_state_create(struct pipe_context *pipe, CALLOC_STRUCT(nv50_rasterizer_stateobj); /*XXX: ignored - * - light_twosize + * - light_twoside * - point_smooth * - multisample * - point_sprite / sprite_coord_mode @@ -385,72 +385,44 @@ nv50_rasterizer_state_create(struct pipe_context *pipe, so_data (so, cso->point_quad_rasterization ? 1 : 0); so_method(so, tesla, NV50TCL_POLYGON_MODE_FRONT, 3); - if (cso->front_winding == PIPE_WINDING_CCW) { - so_data(so, nvgl_polygon_mode(cso->fill_ccw)); - so_data(so, nvgl_polygon_mode(cso->fill_cw)); - } else { - so_data(so, nvgl_polygon_mode(cso->fill_cw)); - so_data(so, nvgl_polygon_mode(cso->fill_ccw)); - } + so_data(so, nvgl_polygon_mode(cso->fill_front)); + so_data(so, nvgl_polygon_mode(cso->fill_back)); so_data(so, cso->poly_smooth ? 1 : 0); so_method(so, tesla, NV50TCL_CULL_FACE_ENABLE, 3); - so_data (so, cso->cull_mode != PIPE_WINDING_NONE); - if (cso->front_winding == PIPE_WINDING_CCW) { + so_data (so, cso->cull_face != PIPE_FACE_NONE); + if (cso->front_ccw) { so_data(so, NV50TCL_FRONT_FACE_CCW); - switch (cso->cull_mode) { - case PIPE_WINDING_CCW: - so_data(so, NV50TCL_CULL_FACE_FRONT); - break; - case PIPE_WINDING_CW: - so_data(so, NV50TCL_CULL_FACE_BACK); - break; - case PIPE_WINDING_BOTH: - so_data(so, NV50TCL_CULL_FACE_FRONT_AND_BACK); - break; - default: - so_data(so, NV50TCL_CULL_FACE_BACK); - break; - } - } else { + } + else { so_data(so, NV50TCL_FRONT_FACE_CW); - switch (cso->cull_mode) { - case PIPE_WINDING_CCW: - so_data(so, NV50TCL_CULL_FACE_BACK); - break; - case PIPE_WINDING_CW: - so_data(so, NV50TCL_CULL_FACE_FRONT); - break; - case PIPE_WINDING_BOTH: - so_data(so, NV50TCL_CULL_FACE_FRONT_AND_BACK); - break; - default: - so_data(so, NV50TCL_CULL_FACE_BACK); - break; - } + } + switch (cso->cull_face) { + case PIPE_FACE_FRONT: + so_data(so, NV50TCL_CULL_FACE_FRONT); + break; + case PIPE_FACE_BACK: + so_data(so, NV50TCL_CULL_FACE_BACK); + break; + case PIPE_FACE_FRONT_AND_BACK: + so_data(so, NV50TCL_CULL_FACE_FRONT_AND_BACK); + break; + default: + so_data(so, NV50TCL_CULL_FACE_BACK); + break; } so_method(so, tesla, NV50TCL_POLYGON_STIPPLE_ENABLE, 1); so_data (so, cso->poly_stipple_enable ? 1 : 0); so_method(so, tesla, NV50TCL_POLYGON_OFFSET_POINT_ENABLE, 3); - if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_POINT) || - (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_POINT)) - so_data(so, 1); - else - so_data(so, 0); - if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_LINE) || - (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_LINE)) - so_data(so, 1); - else - so_data(so, 0); - if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_FILL) || - (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_FILL)) - so_data(so, 1); - else - so_data(so, 0); + so_data(so, cso->offset_point); + so_data(so, cso->offset_line); + so_data(so, cso->offset_tri); - if (cso->offset_cw || cso->offset_ccw) { + if (cso->offset_point || + cso->offset_line || + cso->offset_tri) { so_method(so, tesla, NV50TCL_POLYGON_OFFSET_FACTOR, 1); so_data (so, fui(cso->offset_scale)); so_method(so, tesla, NV50TCL_POLYGON_OFFSET_UNITS, 1); diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c index c5581a6f9d0..f973cf24b98 100644 --- a/src/gallium/drivers/nv50/nv50_transfer.c +++ b/src/gallium/drivers/nv50/nv50_transfer.c @@ -274,7 +274,6 @@ nv50_upload_sifc(struct nv50_context *nv50, { struct nouveau_channel *chan = nv50->screen->base.channel; struct nouveau_grobj *eng2d = nv50->screen->eng2d; - struct nouveau_grobj *tesla = nv50->screen->tesla; unsigned line_dwords = (w * cpp + 3) / 4; reloc |= NOUVEAU_BO_WR; @@ -346,7 +345,4 @@ nv50_upload_sifc(struct nv50_context *nv50, src = (uint8_t *) src + src_pitch; } - - BEGIN_RING(chan, tesla, NV50TCL_CODE_CB_FLUSH, 1); - OUT_RING (chan, 0); } diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c index 1786af776aa..7e534a0c738 100644 --- a/src/gallium/drivers/nvfx/nvfx_screen.c +++ b/src/gallium/drivers/nvfx/nvfx_screen.c @@ -1,5 +1,6 @@ #include "pipe/p_screen.h" #include "pipe/p_state.h" +#include "util/u_format_s3tc.h" #include "util/u_simple_screen.h" #include "nouveau/nouveau_screen.h" @@ -29,7 +30,7 @@ struct nouveau_winsys { #define NV6X_GRCLASS4497_CHIPSETS 0x00000088 static int -nvfx_screen_get_param(struct pipe_screen *pscreen, int param) +nvfx_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) { struct nvfx_screen *screen = nvfx_screen(pscreen); @@ -51,6 +52,8 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, int param) return screen->is_nv4x ? 4 : 2; case PIPE_CAP_OCCLUSION_QUERY: return 1; + case PIPE_CAP_TIMER_QUERY: + return 0; case PIPE_CAP_TEXTURE_SHADOW_MAP: return 1; case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: @@ -83,6 +86,45 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, int param) case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: return 0; + case PIPE_CAP_MAX_FS_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_TEX_INDIRECTIONS: + return 4096; + case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH: + /* FIXME: is it the dynamic (nv30:0/nv40:24) or the static + value (nv30:0/nv40:4) ? */ + return screen->is_nv4x ? 4 : 0; + case PIPE_CAP_MAX_FS_INPUTS: + return 10; + case PIPE_CAP_MAX_FS_CONSTS: + return screen->is_nv4x ? 224 : 32; + case PIPE_CAP_MAX_FS_TEMPS: + return 32; + case PIPE_CAP_MAX_FS_ADDRS: + return screen->is_nv4x ? 1 : 0; + case PIPE_CAP_MAX_FS_PREDS: + return screen->is_nv4x ? 1 : 0; + case PIPE_CAP_MAX_VS_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS: + return screen->is_nv4x ? 512 : 256; + case PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_TEX_INDIRECTIONS: + return screen->is_nv4x ? 512 : 0; + case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH: + /* FIXME: is it the dynamic (nv30:24/nv40:24) or the static + value (nv30:1/nv40:4) ? */ + return screen->is_nv4x ? 4 : 1; + case PIPE_CAP_MAX_VS_INPUTS: + return 16; + case PIPE_CAP_MAX_VS_CONSTS: + return 256; + case PIPE_CAP_MAX_VS_TEMPS: + return screen->is_nv4x ? 32 : 13; + case PIPE_CAP_MAX_VS_ADDRS: + return 2; + case PIPE_CAP_MAX_VS_PREDS: + return screen->is_nv4x ? 1 : 0; default: NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); return 0; @@ -90,7 +132,7 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, int param) } static float -nvfx_screen_get_paramf(struct pipe_screen *pscreen, int param) +nvfx_screen_get_paramf(struct pipe_screen *pscreen, enum pipe_cap param) { struct nvfx_screen *screen = nvfx_screen(pscreen); @@ -149,6 +191,17 @@ nvfx_screen_surface_format_supported(struct pipe_screen *pscreen, } } else { switch (format) { + if (tex_usage & PIPE_BIND_SAMPLER_VIEW) { + switch (format) { + case PIPE_FORMAT_DXT1_RGB: + case PIPE_FORMAT_DXT1_RGBA: + case PIPE_FORMAT_DXT3_RGBA: + case PIPE_FORMAT_DXT5_RGBA: + return util_format_s3tc_enabled; + default: + break; + } + } case PIPE_FORMAT_B8G8R8A8_UNORM: case PIPE_FORMAT_B8G8R8X8_UNORM: case PIPE_FORMAT_B5G5R5A1_UNORM: @@ -160,10 +213,6 @@ nvfx_screen_surface_format_supported(struct pipe_screen *pscreen, case PIPE_FORMAT_L8A8_UNORM: case PIPE_FORMAT_Z16_UNORM: case PIPE_FORMAT_S8_USCALED_Z24_UNORM: - case PIPE_FORMAT_DXT1_RGB: - case PIPE_FORMAT_DXT1_RGBA: - case PIPE_FORMAT_DXT3_RGBA: - case PIPE_FORMAT_DXT5_RGBA: return TRUE; /* TODO: does nv30 support this? */ case PIPE_FORMAT_R16_SNORM: diff --git a/src/gallium/drivers/nvfx/nvfx_state.c b/src/gallium/drivers/nvfx/nvfx_state.c index 3c566808d03..30322d46d93 100644 --- a/src/gallium/drivers/nvfx/nvfx_state.c +++ b/src/gallium/drivers/nvfx/nvfx_state.c @@ -216,66 +216,39 @@ nvfx_rasterizer_state_create(struct pipe_context *pipe, sb_data(sb, fui(cso->point_size)); sb_method(sb, NV34TCL_POLYGON_MODE_FRONT, 6); - if (cso->front_winding == PIPE_WINDING_CCW) { - sb_data(sb, nvgl_polygon_mode(cso->fill_ccw)); - sb_data(sb, nvgl_polygon_mode(cso->fill_cw)); - switch (cso->cull_mode) { - case PIPE_WINDING_CCW: - sb_data(sb, NV34TCL_CULL_FACE_FRONT); - break; - case PIPE_WINDING_CW: - sb_data(sb, NV34TCL_CULL_FACE_BACK); - break; - case PIPE_WINDING_BOTH: - sb_data(sb, NV34TCL_CULL_FACE_FRONT_AND_BACK); - break; - default: - sb_data(sb, NV34TCL_CULL_FACE_BACK); - break; - } + sb_data(sb, nvgl_polygon_mode(cso->fill_front)); + sb_data(sb, nvgl_polygon_mode(cso->fill_back)); + switch (cso->cull_face) { + case PIPE_FACE_FRONT: + sb_data(sb, NV34TCL_CULL_FACE_FRONT); + break; + case PIPE_FACE_BACK: + sb_data(sb, NV34TCL_CULL_FACE_BACK); + break; + case PIPE_FACE_FRONT_AND_BACK: + sb_data(sb, NV34TCL_CULL_FACE_FRONT_AND_BACK); + break; + default: + sb_data(sb, NV34TCL_CULL_FACE_BACK); + break; + } + if (cso->front_ccw) { sb_data(sb, NV34TCL_FRONT_FACE_CCW); } else { - sb_data(sb, nvgl_polygon_mode(cso->fill_cw)); - sb_data(sb, nvgl_polygon_mode(cso->fill_ccw)); - switch (cso->cull_mode) { - case PIPE_WINDING_CCW: - sb_data(sb, NV34TCL_CULL_FACE_BACK); - break; - case PIPE_WINDING_CW: - sb_data(sb, NV34TCL_CULL_FACE_FRONT); - break; - case PIPE_WINDING_BOTH: - sb_data(sb, NV34TCL_CULL_FACE_FRONT_AND_BACK); - break; - default: - sb_data(sb, NV34TCL_CULL_FACE_BACK); - break; - } sb_data(sb, NV34TCL_FRONT_FACE_CW); } sb_data(sb, cso->poly_smooth ? 1 : 0); - sb_data(sb, (cso->cull_mode != PIPE_WINDING_NONE) ? 1 : 0); + sb_data(sb, (cso->cull_face != PIPE_FACE_NONE) ? 1 : 0); sb_method(sb, NV34TCL_POLYGON_STIPPLE_ENABLE, 1); sb_data(sb, cso->poly_stipple_enable ? 1 : 0); sb_method(sb, NV34TCL_POLYGON_OFFSET_POINT_ENABLE, 3); - if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_POINT) || - (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_POINT)) - sb_data(sb, 1); - else - sb_data(sb, 0); - if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_LINE) || - (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_LINE)) - sb_data(sb, 1); - else - sb_data(sb, 0); - if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_FILL) || - (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_FILL)) - sb_data(sb, 1); - else - sb_data(sb, 0); - if (cso->offset_cw || cso->offset_ccw) { + sb_data(sb, cso->offset_point); + sb_data(sb, cso->offset_line); + sb_data(sb, cso->offset_tri); + + if (cso->offset_point || cso->offset_line || cso->offset_tri) { sb_method(sb, NV34TCL_POLYGON_OFFSET_FACTOR, 2); sb_data(sb, fui(cso->offset_scale)); sb_data(sb, fui(cso->offset_units * 2)); diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index b3ef97fa52b..f771e10c64e 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -80,6 +80,9 @@ static void r300_destroy_context(struct pipe_context* context) FREE(r300->ztop_state.state); FREE(r300->fs_constants.state); FREE(r300->vs_constants.state); + if (!r300->screen->caps.has_tcl) { + FREE(r300->vertex_stream_state.state); + } FREE(r300); } @@ -151,6 +154,16 @@ static void r300_setup_atoms(struct r300_context* r300) r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state); r300->fs_constants.state = CALLOC_STRUCT(r300_constant_buffer); r300->vs_constants.state = CALLOC_STRUCT(r300_constant_buffer); + if (!r300->screen->caps.has_tcl) { + r300->vertex_stream_state.state = CALLOC_STRUCT(r300_vertex_stream_state); + } + + /* Some non-CSO atoms don't use the state pointer. */ + r300->invariant_state.allow_null_state = TRUE; + r300->fs_rc_constant_state.allow_null_state = TRUE; + r300->pvs_flush.allow_null_state = TRUE; + r300->query_start.allow_null_state = TRUE; + r300->texture_cache_inval.allow_null_state = TRUE; } struct pipe_context* r300_create_context(struct pipe_screen* screen, @@ -201,9 +214,9 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, draw_set_rasterize_stage(r300->draw, r300_draw_stage(r300)); /* Enable Draw's clipping. */ draw_set_driver_clipping(r300->draw, FALSE); - /* Force Draw to never do viewport transform, since we can do - * transform in hardware, always. */ - draw_set_viewport_state(r300->draw, &r300_viewport_identity); + /* Disable converting points/lines to triangles. */ + draw_wide_line_threshold(r300->draw, 10000000.f); + draw_wide_point_threshold(r300->draw, 10000000.f); } r300_setup_atoms(r300); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index e9c8fcdc157..e44906d0099 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -55,6 +55,8 @@ struct r300_atom { unsigned size; /* Whether this atom should be emitted. */ boolean dirty; + /* Whether this atom may be emitted with state == NULL. */ + boolean allow_null_state; }; struct r300_blend_state { @@ -88,12 +90,15 @@ struct r300_dsa_state { }; struct r300_rs_state { - /* Draw-specific rasterizer state */ + /* Original rasterizer state. */ struct pipe_rasterizer_state rs; + /* Draw-specific rasterizer state. */ + struct pipe_rasterizer_state rs_draw; uint32_t vap_control_status; /* R300_VAP_CNTL_STATUS: 0x2140 */ uint32_t antialiasing_config; /* R300_GB_AA_CONFIG: 0x4020 */ uint32_t point_size; /* R300_GA_POINT_SIZE: 0x421c */ + uint32_t point_minmax; /* R300_GA_POINT_MINMAX: 0x4230 */ uint32_t line_control; /* R300_GA_LINE_CNTL: 0x4234 */ float depth_scale; /* R300_SU_POLY_OFFSET_FRONT_SCALE: 0x42a4 */ /* R300_SU_POLY_OFFSET_BACK_SCALE: 0x42ac */ @@ -151,6 +156,10 @@ struct r300_texture_format_state { struct r300_sampler_view { struct pipe_sampler_view base; + /* Swizzles in the UTIL_FORMAT_SWIZZLE_* representation, + * derived from base. */ + unsigned char swizzle[4]; + /* Copy of r300_texture::texture_format_state with format-specific bits * added. */ struct r300_texture_format_state format; @@ -166,6 +175,13 @@ struct r300_texture_fb_state { uint32_t zb_format; /* R300_ZB_FORMAT */ }; +struct r300_texture_sampler_state { + struct r300_texture_format_state format; + uint32_t filter0; /* R300_TX_FILTER0: 0x4400 */ + uint32_t filter1; /* R300_TX_FILTER1: 0x4440 */ + uint32_t border_color; /* R300_TX_BORDER_COLOR: 0x45c0 */ +}; + struct r300_textures_state { /* Textures. */ struct r300_sampler_view *sampler_views[16]; @@ -177,12 +193,7 @@ struct r300_textures_state { /* This is the merge of the texture and sampler states. */ unsigned count; uint32_t tx_enable; /* R300_TX_ENABLE: 0x4101 */ - struct r300_texture_sampler_state { - struct r300_texture_format_state format; - uint32_t filter0; /* R300_TX_FILTER0: 0x4400 */ - uint32_t filter1; /* R300_TX_FILTER1: 0x4440 */ - uint32_t border_color; /* R300_TX_BORDER_COLOR: 0x45c0 */ - } regs[16]; + struct r300_texture_sampler_state regs[16]; }; struct r300_vertex_stream_state { @@ -228,10 +239,6 @@ struct r300_constant_buffer { struct r300_query { /* The kind of query. Currently only OQ is supported. */ unsigned type; - /* Whether this query is currently active. Only active queries will - * get emitted into the command stream, and only active queries get - * tallied. */ - boolean active; /* The current count of this query. Required to be at least 32 bits. */ unsigned int count; /* The offset of this query into the query buffer, in bytes. */ @@ -297,16 +304,6 @@ struct r300_texture { enum r300_buffer_tiling microtile, macrotile; }; -struct r300_vertex_info { - /* Parent class */ - struct vertex_info vinfo; - - /* R300_VAP_PROG_STREAK_CNTL_[0-7] */ - uint32_t vap_prog_stream_cntl[8]; - /* R300_VAP_PROG_STREAK_CNTL_EXT_[0-7] */ - uint32_t vap_prog_stream_cntl_ext[8]; -}; - struct r300_vertex_element_state { unsigned count; struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS]; @@ -314,8 +311,6 @@ struct r300_vertex_element_state { struct r300_vertex_stream_state vertex_stream; }; -extern struct pipe_viewport_state r300_viewport_identity; - struct r300_context { /* Parent class */ struct pipe_context context; @@ -331,8 +326,7 @@ struct r300_context { void (*emit_draw_elements)( struct r300_context *r300, struct pipe_resource* indexBuffer, - unsigned indexSize, int indexBias, - unsigned minIndex, unsigned maxIndex, + unsigned indexSize, unsigned minIndex, unsigned maxIndex, unsigned mode, unsigned start, unsigned count); @@ -436,6 +430,8 @@ struct r300_context { boolean stencil_ref_bf_fallback; /* Point sprites texcoord index, 1 bit per texcoord */ int sprite_coord_enable; + /* Whether two-sided color selection is enabled (AKA light_twoside). */ + boolean two_sided_color; /* upload managers */ struct u_upload_mgr *upload_vb; diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index 8eb321fa08a..85a1aa7b06e 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -40,6 +40,7 @@ static struct debug_option debug_options[] = { { "texalloc", DBG_TEXALLOC, "Texture allocation (for debugging)" }, { "fall", DBG_FALL, "Fallbacks (for debugging)" }, { "rs", DBG_RS, "Rasterizer (for debugging)" }, + { "fb", DBG_FB, "Framebuffer (for debugging)" }, { "anisohq", DBG_ANISOHQ, "High quality anisotropic filtering (for benchmarking)" }, { "notiling", DBG_NO_TILING, "Disable tiling (for benchmarking)" }, { "noimmd", DBG_NO_IMMD, "Disable immediate mode (for benchmarking)" }, @@ -97,3 +98,84 @@ void r300_init_debug(struct r300_screen * screen) } } } + +void r500_dump_rs_block(struct r300_rs_block *rs) +{ + unsigned count, ip, it_count, ic_count, i, j; + unsigned tex_ptr; + unsigned col_ptr, col_fmt; + + count = rs->inst_count & 0xf; + count++; + + it_count = rs->count & 0x7f; + ic_count = (rs->count >> 7) & 0xf; + + fprintf(stderr, "RS Block: %d texcoords (linear), %d colors (perspective)\n", + it_count, ic_count); + fprintf(stderr, "%d instructions\n", count); + + for (i = 0; i < count; i++) { + if (rs->inst[i] & 0x10) { + ip = rs->inst[i] & 0xf; + fprintf(stderr, "texture: ip %d to psf %d\n", + ip, (rs->inst[i] >> 5) & 0x7f); + + tex_ptr = rs->ip[ip] & 0xffffff; + fprintf(stderr, " : "); + + j = 3; + do { + if (tex_ptr & 0x3f == 63) { + fprintf(stderr, "1.0"); + } else if (tex_ptr & 0x3f == 62) { + fprintf(stderr, "0.0"); + } else { + fprintf(stderr, "[%d]", tex_ptr & 0x3f); + } + } while (j-- && fprintf(stderr, "/")); + fprintf(stderr, "\n"); + } + + if (rs->inst[i] & 0x10000) { + ip = (rs->inst[i] >> 12) & 0xf; + fprintf(stderr, "color: ip %d to psf %d\n", + ip, (rs->inst[i] >> 18) & 0x7f); + + col_ptr = (rs->ip[ip] >> 24) & 0x7; + col_fmt = (rs->ip[ip] >> 27) & 0xf; + fprintf(stderr, " : offset %d ", col_ptr); + + switch (col_fmt) { + case 0: + fprintf(stderr, "(R/G/B/A)"); + break; + case 1: + fprintf(stderr, "(R/G/B/0)"); + break; + case 2: + fprintf(stderr, "(R/G/B/1)"); + break; + case 4: + fprintf(stderr, "(0/0/0/A)"); + break; + case 5: + fprintf(stderr, "(0/0/0/0)"); + break; + case 6: + fprintf(stderr, "(0/0/0/1)"); + break; + case 8: + fprintf(stderr, "(1/1/1/A)"); + break; + case 9: + fprintf(stderr, "(1/1/1/0)"); + break; + case 10: + fprintf(stderr, "(1/1/1/1)"); + break; + } + fprintf(stderr, "\n"); + } + } +} diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 23bbc6a99c8..7f7f2929cc3 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -525,8 +525,6 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state) OUT_CS(((fb->width + 1440-1) << R300_SCISSORS_X_SHIFT) | ((fb->height + 1440-1) << R300_SCISSORS_Y_SHIFT)); } - OUT_CS_REG(R300_GA_POINT_MINMAX, - (MAX2(fb->width, fb->height) * 6) << R300_GA_POINT_MINMAX_MAX_SHIFT); END_CS; } @@ -550,8 +548,8 @@ void r300_emit_query_start(struct r300_context *r300, unsigned size, void*state) } -static void r300_emit_query_finish(struct r300_context *r300, - struct r300_query *query) +static void r300_emit_query_end_frag_pipes(struct r300_context *r300, + struct r300_query *query) { struct r300_capabilities* caps = &r300->screen->caps; CS_LOCALS(r300); @@ -606,8 +604,8 @@ static void r300_emit_query_finish(struct r300_context *r300, END_CS; } -static void rv530_emit_query_single(struct r300_context *r300, - struct r300_query *query) +static void rv530_emit_query_end_single_z(struct r300_context *r300, + struct r300_query *query) { CS_LOCALS(r300); @@ -619,8 +617,8 @@ static void rv530_emit_query_single(struct r300_context *r300, END_CS; } -static void rv530_emit_query_double(struct r300_context *r300, - struct r300_query *query) +static void rv530_emit_query_end_double_z(struct r300_context *r300, + struct r300_query *query) { CS_LOCALS(r300); @@ -648,11 +646,13 @@ void r300_emit_query_end(struct r300_context* r300) if (caps->family == CHIP_FAMILY_RV530) { if (caps->num_z_pipes == 2) - rv530_emit_query_double(r300, query); + rv530_emit_query_end_double_z(r300, query); else - rv530_emit_query_single(r300, query); + rv530_emit_query_end_single_z(r300, query); } else - r300_emit_query_finish(r300, query); + r300_emit_query_end_frag_pipes(r300, query); + + query->begin_emitted = FALSE; } void r300_emit_rs_state(struct r300_context* r300, unsigned size, void* state) @@ -667,7 +667,9 @@ void r300_emit_rs_state(struct r300_context* r300, unsigned size, void* state) OUT_CS_REG(R300_GB_AA_CONFIG, rs->antialiasing_config); OUT_CS_REG(R300_GA_POINT_SIZE, rs->point_size); - OUT_CS_REG(R300_GA_LINE_CNTL, rs->line_control); + OUT_CS_REG_SEQ(R300_GA_POINT_MINMAX, 2); + OUT_CS(rs->point_minmax); + OUT_CS(rs->line_control); if (rs->polygon_offset_enable) { scale = rs->depth_scale * 12; @@ -714,6 +716,10 @@ void r300_emit_rs_block_state(struct r300_context* r300, unsigned count = (rs->inst_count & R300_RS_INST_COUNT_MASK) + 1; CS_LOCALS(r300); + if (SCREEN_DBG_ON(r300->screen, DBG_DRAW)) { + r500_dump_rs_block(rs); + } + DBG(r300, DBG_DRAW, "r300: RS emit:\n"); BEGIN_CS(size); @@ -1003,16 +1009,16 @@ void r300_emit_viewport_state(struct r300_context* r300, struct r300_viewport_state* viewport = (struct r300_viewport_state*)state; CS_LOCALS(r300); - BEGIN_CS(size); - OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6); - OUT_CS_32F(viewport->xscale); - OUT_CS_32F(viewport->xoffset); - OUT_CS_32F(viewport->yscale); - OUT_CS_32F(viewport->yoffset); - OUT_CS_32F(viewport->zscale); - OUT_CS_32F(viewport->zoffset); - OUT_CS_REG(R300_VAP_VTE_CNTL, viewport->vte_control); - END_CS; + BEGIN_CS(size); + OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6); + OUT_CS_32F(viewport->xscale); + OUT_CS_32F(viewport->xoffset); + OUT_CS_32F(viewport->yscale); + OUT_CS_32F(viewport->yoffset); + OUT_CS_32F(viewport->zscale); + OUT_CS_32F(viewport->zoffset); + OUT_CS_REG(R300_VAP_VTE_CNTL, viewport->vte_control); + END_CS; } void r300_emit_ztop_state(struct r300_context* r300, @@ -1094,7 +1100,8 @@ validate: } } /* ...occlusion query buffer... */ - if (r300->query_start.dirty) { + if (r300->query_start.dirty || + (r300->query_current && r300->query_current->begin_emitted)) { if (!r300_add_buffer(r300->rws, r300->oqbo, 0, RADEON_GEM_DOMAIN_GTT)) { r300->context.flush(&r300->context, 0, NULL); @@ -1152,8 +1159,6 @@ unsigned r300_get_num_dirty_dwords(struct r300_context *r300) } } - /* emit_query_end is not atomized. */ - dwords += 26; /* let's reserve some more, just in case */ dwords += 32; diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index e78c6a3624f..d6876c1903f 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -1,5 +1,6 @@ /* * Copyright 2008 Corbin Simpson <[email protected]> + * Copyright 2010 Marek Olšák <[email protected]> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -37,6 +38,8 @@ static void r300_flush(struct pipe_context* pipe, struct r300_context *r300 = r300_context(pipe); struct r300_query *query; struct r300_atom *atom; + struct pipe_framebuffer_state *fb; + unsigned i; CS_LOCALS(r300); (void) cs_count; @@ -48,15 +51,15 @@ static void r300_flush(struct pipe_context* pipe, draw_flush(r300->draw); } - r300_emit_query_end(r300); - if (r300->dirty_hw) { + r300_emit_query_end(r300); + FLUSH_CS; r300->dirty_hw = 0; /* New kitchen sink, baby. */ foreach(atom, &r300->atom_list) { - if (atom->state) { + if (atom->state || atom->allow_null_state) { atom->dirty = TRUE; } } @@ -72,6 +75,39 @@ static void r300_flush(struct pipe_context* pipe, foreach(query, &r300->query_list) { query->flushed = TRUE; } + + /* XXX + * + * This is a preliminary implementation of glFinish. Note that st/mesa + * uses a non-null fence when glFinish is called and then waits for + * the fence. Instead of returning the actual fence, we do the sync + * directly. + * + * The ideal implementation should use something like EmitIrqLocked and + * WaitIrq, or better, real fences. + * + * This feature degrades performance to the level of r300c for games that + * use glFinish a lot, even openarena does. Ideally we wouldn't need + * glFinish at all if we had proper throttling in swapbuffers so that + * the CPU wouldn't outrun the GPU by several frames, so this is basically + * a temporary fix for the input lag. Once swap&sync works with DRI2, + * I'll be happy to remove this code. + * + * - M. */ + if (fence && r300->fb_state.state) { + fb = r300->fb_state.state; + + for (i = 0; i < fb->nr_cbufs; i++) { + if (fb->cbufs[i]->texture) { + r300->rws->buffer_wait(r300->rws, + r300_texture(fb->cbufs[i]->texture)->buffer); + } + if (fb->zsbuf) { + r300->rws->buffer_wait(r300->rws, + r300_texture(fb->zsbuf->texture)->buffer); + } + } + } } void r300_init_flush_functions(struct r300_context* r300) diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c index 88303f074cd..30aa0651399 100644 --- a/src/gallium/drivers/r300/r300_fs.c +++ b/src/gallium/drivers/r300/r300_fs.c @@ -137,6 +137,7 @@ static void get_external_state( { struct r300_textures_state *texstate = r300->textures_state.state; unsigned i; + unsigned char *swizzle; for (i = 0; i < texstate->sampler_state_count; i++) { struct r300_sampler_state* s = texstate->sampler_states[i]; @@ -146,9 +147,18 @@ static void get_external_state( } if (s->state.compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) { - /* XXX Gallium doesn't provide us with any information regarding - * this mode, so we are screwed. I'm setting 0 = LUMINANCE. */ - state->unit[i].depth_texture_mode = 0; + state->unit[i].compare_mode_enabled = 1; + + /* Pass depth texture swizzling to the compiler. */ + if (texstate->sampler_views[i]) { + swizzle = texstate->sampler_views[i]->swizzle; + + state->unit[i].depth_texture_swizzle = + RC_MAKE_SWIZZLE(swizzle[0], swizzle[1], + swizzle[2], swizzle[3]); + } else { + state->unit[i].depth_texture_swizzle = RC_SWIZZLE_XYZW; + } /* Fortunately, no need to translate this. */ state->unit[i].texture_compare_func = s->state.compare_func; diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c index 5c27796e894..6acbac22196 100644 --- a/src/gallium/drivers/r300/r300_query.c +++ b/src/gallium/drivers/r300/r300_query.c @@ -43,8 +43,6 @@ static struct pipe_query *r300_create_query(struct pipe_context *pipe, q->type = query_type; assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER); - q->active = FALSE; - if (r300screen->caps.family == CHIP_FAMILY_RV530) query_size = r300screen->caps.num_z_pipes * sizeof(uint32_t); else @@ -59,6 +57,7 @@ static struct pipe_query *r300_create_query(struct pipe_context *pipe, /* XXX */ if (q->offset >= 4096) { q->offset = 0; + fprintf(stderr, "r300: Rewinding OQBO...\n"); } return (struct pipe_query*)q; @@ -80,7 +79,12 @@ static void r300_begin_query(struct pipe_context* pipe, struct r300_context* r300 = r300_context(pipe); struct r300_query* q = (struct r300_query*)query; - assert(r300->query_current == NULL); + if (r300->query_current != NULL) { + fprintf(stderr, "r300: begin_query: " + "Some other query has already been started.\n"); + assert(0); + return; + } pipe_buffer_write(pipe, r300->oqbo, @@ -97,10 +101,14 @@ static void r300_end_query(struct pipe_context* pipe, struct pipe_query* query) { struct r300_context* r300 = r300_context(pipe); - struct r300_query* q = (struct r300_query*)query; + + if ((struct r300_query*)query != r300->query_current) { + fprintf(stderr, "r300: end_query: Got invalid query.\n"); + assert(0); + return; + } r300_emit_query_end(r300); - q->begin_emitted = false; r300->query_current = NULL; } diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 7c3a7902a49..e1f61982be2 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -114,16 +114,79 @@ static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300, return color_control; } +static void r500_emit_index_offset(struct r300_context *r300, int index_bias) +{ + CS_LOCALS(r300); + + if (r300->screen->caps.is_r500 && + r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0)) { + BEGIN_CS(2); + OUT_CS_REG(R500_VAP_INDEX_OFFSET, + (index_bias & 0xFFFFFF) | (index_bias < 0 ? 1<<24 : 0)); + END_CS; + } else { + if (index_bias) { + fprintf(stderr, "r300: Non-zero index bias is unsupported " + "on this hardware.\n"); + assert(0); + } + } +} + +enum r300_prepare_flags { + PREP_FIRST_DRAW = (1 << 0), + PREP_VALIDATE_VBOS = (1 << 1), + PREP_EMIT_AOS = (1 << 2), + PREP_INDEXED = (1 << 3) +}; + /* Check if the requested number of dwords is available in the CS and - * if not, flush. Return TRUE if the flush occured. */ -static boolean r300_reserve_cs_space(struct r300_context *r300, - unsigned dwords) + * if not, flush. Then validate buffers and emit dirty state. + * Return TRUE if flush occured. */ +static void r300_prepare_for_rendering(struct r300_context *r300, + enum r300_prepare_flags flags, + struct pipe_resource *index_buffer, + unsigned cs_dwords, + unsigned aos_offset, + int index_bias) { - if (!r300->rws->check_cs(r300->rws, dwords)) { + boolean flushed = FALSE; + boolean first_draw = flags & PREP_FIRST_DRAW; + boolean emit_aos = flags & PREP_EMIT_AOS; + + /* Stencil ref fallback. */ + if (r300->stencil_ref_bf_fallback) { + cs_dwords = cs_dwords * 2 + 10; + } + + /* Add dirty state, index offset, and AOS. */ + if (first_draw) { + cs_dwords += r300_get_num_dirty_dwords(r300); + + if (r300->screen->caps.is_r500) + cs_dwords += 2; /* emit_index_offset */ + + if (emit_aos) + cs_dwords += 55; /* emit_aos */ + } + + /* Emitted in flush. */ + cs_dwords += 26; /* emit_query_end */ + + /* Reserve requested CS space. */ + if (!r300->rws->check_cs(r300->rws, cs_dwords)) { r300->context.flush(&r300->context, 0, NULL); - return TRUE; + flushed = TRUE; + } + + /* Validate buffers and emit dirty state if needed. */ + if (first_draw || flushed) { + r300_emit_buffer_validate(r300, flags & PREP_VALIDATE_VBOS, index_buffer); + r300_emit_dirty_state(r300); + r500_emit_index_offset(r300, index_bias); + if (emit_aos) + r300_emit_aos(r300, aos_offset, flags & PREP_INDEXED); } - return FALSE; } static boolean immd_is_good_idea(struct r300_context *r300, @@ -135,7 +198,15 @@ static boolean immd_is_good_idea(struct r300_context *r300, unsigned vertex_element_count = r300->velems->count; unsigned i, vbi; - if (count > 10 || DBG_ON(r300, DBG_NO_IMMD)) { + if (DBG_ON(r300, DBG_NO_IMMD)) { + return FALSE; + } + + if (r300->draw) { + return FALSE; + } + + if (count > 10) { return FALSE; } @@ -166,24 +237,6 @@ static boolean immd_is_good_idea(struct r300_context *r300, * after resolving fallback issues (e.g. stencil ref two-sided). * ****************************************************************************/ -static boolean r500_emit_index_offset(struct r300_context *r300, int indexBias) -{ - CS_LOCALS(r300); - - if (r300->screen->caps.is_r500 && - r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0)) { - BEGIN_CS(2); - OUT_CS_REG(R500_VAP_INDEX_OFFSET, - (indexBias & 0xFFFFFF) | (indexBias < 0 ? 1<<24 : 0)); - END_CS; - } else { - if (indexBias) - return FALSE; /* Can't do anything :( */ - } - - return TRUE; -} - void r500_emit_draw_arrays_immediate(struct r300_context *r300, unsigned mode, unsigned start, @@ -235,11 +288,7 @@ void r500_emit_draw_arrays_immediate(struct r300_context *r300, dwords = 9 + count * vertex_size; - r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 2 + dwords); - r300_emit_buffer_validate(r300, FALSE, NULL); - r300_emit_dirty_state(r300); - - r500_emit_index_offset(r300, 0); + r300_prepare_for_rendering(r300, PREP_FIRST_DRAW, NULL, dwords, 0, 0); BEGIN_CS(dwords); OUT_CS_REG(R300_GA_COLOR_CONTROL, @@ -291,8 +340,6 @@ void r500_emit_draw_arrays(struct r300_context *r300, return; } - r500_emit_index_offset(r300, 0); - BEGIN_CS(7 + (alt_num_verts ? 2 : 0)); if (alt_num_verts) { OUT_CS_REG(R500_VAP_ALT_NUM_VERTICES, count); @@ -312,7 +359,6 @@ void r500_emit_draw_arrays(struct r300_context *r300, void r500_emit_draw_elements(struct r300_context *r300, struct pipe_resource* indexBuffer, unsigned indexSize, - int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -335,12 +381,6 @@ void r500_emit_draw_elements(struct r300_context *r300, DBG(r300, DBG_DRAW, "r300: Indexbuf of %u indices, min %u max %u\n", count, minIndex, maxIndex); - if (!r500_emit_index_offset(r300, indexBias)) { - fprintf(stderr, "r300: Got a non-zero index bias, " - "refusing to render.\n"); - return; - } - BEGIN_CS(13 + (alt_num_verts ? 2 : 0)); if (alt_num_verts) { OUT_CS_REG(R500_VAP_ALT_NUM_VERTICES, count); @@ -457,7 +497,6 @@ void r300_emit_draw_arrays(struct r300_context *r300, void r300_emit_draw_elements(struct r300_context *r300, struct pipe_resource* indexBuffer, unsigned indexSize, - int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -465,14 +504,14 @@ void r300_emit_draw_elements(struct r300_context *r300, unsigned count) { if (!r300->stencil_ref_bf_fallback) { - r500_emit_draw_elements(r300, indexBuffer, indexSize, indexBias, + r500_emit_draw_elements(r300, indexBuffer, indexSize, minIndex, maxIndex, mode, start, count); } else { r300_begin_stencil_ref_fallback(r300); - r500_emit_draw_elements(r300, indexBuffer, indexSize, indexBias, + r500_emit_draw_elements(r300, indexBuffer, indexSize, minIndex, maxIndex, mode, start, count); r300_switch_stencil_ref_side(r300); - r500_emit_draw_elements(r300, indexBuffer, indexSize, indexBias, + r500_emit_draw_elements(r300, indexBuffer, indexSize, minIndex, maxIndex, mode, start, count); r300_end_stencil_ref_fallback(r300); } @@ -576,36 +615,33 @@ void r300_draw_range_elements(struct pipe_context* pipe, } r300_update_derived_state(r300); - r300_upload_index_buffer(r300, &indexBuffer, indexSize, start, count); - /* 128 dwords for emit_aos and emit_draw_elements */ - r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 128); - r300_emit_buffer_validate(r300, TRUE, indexBuffer); - r300_emit_dirty_state(r300); - r300_emit_aos(r300, 0, TRUE); + /* 15 dwords for emit_draw_elements */ + r300_prepare_for_rendering(r300, + PREP_FIRST_DRAW | PREP_VALIDATE_VBOS | PREP_EMIT_AOS | PREP_INDEXED, + indexBuffer, 15, 0, indexBias); u_upload_flush(r300->upload_vb); u_upload_flush(r300->upload_ib); if (alt_num_verts || count <= 65535) { - r300->emit_draw_elements(r300, indexBuffer, indexSize, indexBias, + r300->emit_draw_elements(r300, indexBuffer, indexSize, minIndex, maxIndex, mode, start, count); } else { do { short_count = MIN2(count, 65534); - r300->emit_draw_elements(r300, indexBuffer, indexSize, indexBias, + r300->emit_draw_elements(r300, indexBuffer, indexSize, minIndex, maxIndex, mode, start, short_count); start += short_count; count -= short_count; - /* 16 spare dwords are enough for emit_draw_elements. - * Also reserve some space for emit_query_end. */ - if (count && r300_reserve_cs_space(r300, 74)) { - r300_emit_buffer_validate(r300, TRUE, indexBuffer); - r300_emit_dirty_state(r300); - r300_emit_aos(r300, 0, TRUE); + /* 15 dwords for emit_draw_elements */ + if (count) { + r300_prepare_for_rendering(r300, + PREP_VALIDATE_VBOS | PREP_EMIT_AOS | PREP_INDEXED, + indexBuffer, 15, 0, indexBias); } } while (count); } @@ -650,30 +686,25 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, if (immd_is_good_idea(r300, count)) { r300->emit_draw_arrays_immediate(r300, mode, start, count); } else { - /* Make sure there are at least 128 spare dwords in the command buffer. - * (most of it being consumed by emit_aos) */ - r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 128); - r300_emit_buffer_validate(r300, TRUE, NULL); - r300_emit_dirty_state(r300); + /* 9 spare dwords for emit_draw_arrays. */ + r300_prepare_for_rendering(r300, PREP_FIRST_DRAW | PREP_VALIDATE_VBOS | PREP_EMIT_AOS, + NULL, 9, start, 0); if (alt_num_verts || count <= 65535) { - r300_emit_aos(r300, start, FALSE); r300->emit_draw_arrays(r300, mode, count); } else { do { short_count = MIN2(count, 65535); - r300_emit_aos(r300, start, FALSE); r300->emit_draw_arrays(r300, mode, short_count); start += short_count; count -= short_count; - /* Again, we emit both AOS and draw_arrays so there should be - * at least 128 spare dwords. - * Also reserve some space for emit_query_end. */ - if (count && r300_reserve_cs_space(r300, 186)) { - r300_emit_buffer_validate(r300, TRUE, NULL); - r300_emit_dirty_state(r300); + /* 9 spare dwords for emit_draw_arrays. */ + if (count) { + r300_prepare_for_rendering(r300, + PREP_VALIDATE_VBOS | PREP_EMIT_AOS, NULL, 9, + start, 0); } } while (count); } @@ -704,6 +735,8 @@ void r300_swtcl_draw_arrays(struct pipe_context* pipe, return; } + r300_update_derived_state(r300); + for (i = 0; i < r300->vertex_buffer_count; i++) { void* buf = pipe_buffer_map(pipe, r300->vertex_buffer[i].buffer, @@ -716,6 +749,10 @@ void r300_swtcl_draw_arrays(struct pipe_context* pipe, draw_arrays(r300->draw, mode, start, count); + /* XXX Not sure whether this is the best fix. + * It prevents CS from being rejected and weird assertion failures. */ + draw_flush(r300->draw); + for (i = 0; i < r300->vertex_buffer_count; i++) { pipe_buffer_unmap(pipe, r300->vertex_buffer[i].buffer, vb_transfer[i]); @@ -748,6 +785,8 @@ void r300_swtcl_draw_range_elements(struct pipe_context* pipe, return; } + r300_update_derived_state(r300); + for (i = 0; i < r300->vertex_buffer_count; i++) { void* buf = pipe_buffer_map(pipe, r300->vertex_buffer[i].buffer, @@ -763,6 +802,10 @@ void r300_swtcl_draw_range_elements(struct pipe_context* pipe, draw_arrays(r300->draw, mode, start, count); + /* XXX Not sure whether this is the best fix. + * It prevents CS from being rejected and weird assertion failures. */ + draw_flush(r300->draw); + for (i = 0; i < r300->vertex_buffer_count; i++) { pipe_buffer_unmap(pipe, r300->vertex_buffer[i].buffer, vb_transfer[i]); @@ -796,7 +839,7 @@ struct r300_render { size_t vbo_max_used; void * vbo_ptr; - struct pipe_transfer *vbo_transfer; + struct pipe_transfer *vbo_transfer; }; static INLINE struct r300_render* @@ -811,8 +854,6 @@ r300_render_get_vertex_info(struct vbuf_render* render) struct r300_render* r300render = r300_render(render); struct r300_context* r300 = r300render->r300; - r300_update_derived_state(r300); - return &r300->vertex_info; } @@ -860,10 +901,6 @@ static void r300_render_unmap_vertices(struct vbuf_render* render, { struct r300_render* r300render = r300_render(render); struct pipe_context* context = &r300render->r300->context; - CS_LOCALS(r300render->r300); - BEGIN_CS(2); - OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, max); - END_CS; r300render->vbo_max_used = MAX2(r300render->vbo_max_used, r300render->vertex_size * (max + 1)); @@ -895,42 +932,64 @@ static void r500_render_draw_arrays(struct vbuf_render* render, { struct r300_render* r300render = r300_render(render); struct r300_context* r300 = r300render->r300; + uint8_t* ptr; + unsigned i; + unsigned dwords = 6; CS_LOCALS(r300); - r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 2); - r300_emit_buffer_validate(r300, FALSE, NULL); - r300_emit_dirty_state(r300); + (void) i; (void) ptr; + + r300_prepare_for_rendering(r300, PREP_FIRST_DRAW, NULL, dwords, 0, 0); DBG(r300, DBG_DRAW, "r300: Doing vbuf render, count %d\n", count); - r500_emit_index_offset(r300, 0); + /* Uncomment to dump all VBOs rendered through this interface. + * Slow and noisy! + ptr = pipe_buffer_map(&r300render->r300->context, + r300render->vbo, PIPE_TRANSFER_READ, + &r300render->vbo_transfer); - BEGIN_CS(2); + for (i = 0; i < count; i++) { + printf("r300: Vertex %d\n", i); + draw_dump_emitted_vertex(&r300->vertex_info, ptr); + ptr += r300->vertex_info.size * 4; + printf("\n"); + } + + pipe_buffer_unmap(&r300render->r300->context, r300render->vbo, + r300render->vbo_transfer); + */ + + BEGIN_CS(dwords); + OUT_CS_REG(R300_GA_COLOR_CONTROL, + r300_provoking_vertex_fixes(r300, r300render->prim)); + OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, count - 1); OUT_CS_PKT3(R300_PACKET3_3D_DRAW_VBUF_2, 0); OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (count << 16) | r300render->hwprim); END_CS; } -static void r500_render_draw(struct vbuf_render* render, - const ushort* indices, - uint count) +static void r500_render_draw_elements(struct vbuf_render* render, + const ushort* indices, + uint count) { struct r300_render* r300render = r300_render(render); struct r300_context* r300 = r300render->r300; int i; - unsigned dwords = 2 + (count+1)/2; + unsigned dwords = 6 + (count+1)/2; + unsigned max_index = (r300render->vbo_size - r300render->vbo_offset) / + (r300render->r300->vertex_info.size * 4) - 1; CS_LOCALS(r300); - r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + dwords); - r300_emit_buffer_validate(r300, FALSE, NULL); - r300_emit_dirty_state(r300); - - r500_emit_index_offset(r300, 0); + r300_prepare_for_rendering(r300, PREP_FIRST_DRAW, NULL, dwords, 0, 0); BEGIN_CS(dwords); + OUT_CS_REG(R300_GA_COLOR_CONTROL, + r300_provoking_vertex_fixes(r300, r300render->prim)); + OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, max_index); OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, (count+1)/2); OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) | r300render->hwprim); @@ -960,19 +1019,19 @@ static void r300_render_draw_arrays(struct vbuf_render* render, } } -static void r300_render_draw(struct vbuf_render* render, - const ushort* indices, - uint count) +static void r300_render_draw_elements(struct vbuf_render* render, + const ushort* indices, + uint count) { struct r300_context* r300 = r300_render(render)->r300; if (!r300->stencil_ref_bf_fallback) { - r500_render_draw(render, indices, count); + r500_render_draw_elements(render, indices, count); } else { r300_begin_stencil_ref_fallback(r300); - r500_render_draw(render, indices, count); + r500_render_draw_elements(render, indices, count); r300_switch_stencil_ref_side(r300); - r500_render_draw(render, indices, count); + r500_render_draw_elements(render, indices, count); r300_end_stencil_ref_fallback(r300); } } @@ -998,10 +1057,10 @@ static struct vbuf_render* r300_render_create(struct r300_context* r300) r300render->base.unmap_vertices = r300_render_unmap_vertices; r300render->base.set_primitive = r300_render_set_primitive; if (r300->screen->caps.is_r500) { - r300render->base.draw = r500_render_draw; + r300render->base.draw_elements = r500_render_draw_elements; r300render->base.draw_arrays = r500_render_draw_arrays; } else { - r300render->base.draw = r300_render_draw; + r300render->base.draw_elements = r300_render_draw_elements; r300render->base.draw_arrays = r300_render_draw_arrays; } r300render->base.release_vertices = r300_render_release_vertices; diff --git a/src/gallium/drivers/r300/r300_render.h b/src/gallium/drivers/r300/r300_render.h index 4e78914c1ba..71dea218be6 100644 --- a/src/gallium/drivers/r300/r300_render.h +++ b/src/gallium/drivers/r300/r300_render.h @@ -35,7 +35,6 @@ void r500_emit_draw_arrays(struct r300_context *r300, void r500_emit_draw_elements(struct r300_context *r300, struct pipe_resource* indexBuffer, unsigned indexSize, - int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -54,7 +53,6 @@ void r300_emit_draw_arrays(struct r300_context *r300, void r300_emit_draw_elements(struct r300_context *r300, struct pipe_resource* indexBuffer, unsigned indexSize, - int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index b7f1c617f03..ef0255066b7 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -76,20 +76,19 @@ static const char* r300_get_name(struct pipe_screen* pscreen) return chip_families[r300screen->caps.family]; } -static int r300_get_param(struct pipe_screen* pscreen, int param) +static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param) { struct r300_screen* r300screen = r300_screen(pscreen); + boolean is_r400 = r300screen->caps.is_r400; + boolean is_r500 = r300screen->caps.is_r500; + + /* XXX extended shader capabilities of r400 unimplemented */ + is_r400 = FALSE; switch (param) { - case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: - case PIPE_CAP_MAX_COMBINED_SAMPLERS: - return r300screen->caps.num_tex_units; + /* Supported features (boolean caps). */ case PIPE_CAP_NPOT_TEXTURES: - /* XXX enable now to get GL2.1 API, - * figure out later how to emulate this */ - return 1; case PIPE_CAP_TWO_SIDED_STENCIL: - return 1; case PIPE_CAP_GLSL: /* I'll be frank. This is a lie. * @@ -106,59 +105,103 @@ static int r300_get_param(struct pipe_screen* pscreen, int param) * * ~ C. */ - return 1; - case PIPE_CAP_DUAL_SOURCE_BLEND: - return 0; case PIPE_CAP_ANISOTROPIC_FILTER: - return 1; case PIPE_CAP_POINT_SPRITE: - return 1; - case PIPE_CAP_MAX_RENDER_TARGETS: - return 4; case PIPE_CAP_OCCLUSION_QUERY: - return 1; case PIPE_CAP_TEXTURE_SHADOW_MAP: - return 1; - case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: - case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: - case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: - if (r300screen->caps.is_r500) { - /* 13 == 4096 */ - return 13; - } else { - /* 12 == 2048 */ - return 12; - } case PIPE_CAP_TEXTURE_MIRROR_CLAMP: - return 1; case PIPE_CAP_TEXTURE_MIRROR_REPEAT: + case PIPE_CAP_BLEND_EQUATION_SEPARATE: return 1; - case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS: - return 0; + + /* Unsupported features (boolean caps). */ + case PIPE_CAP_TIMER_QUERY: + case PIPE_CAP_DUAL_SOURCE_BLEND: case PIPE_CAP_TGSI_CONT_SUPPORTED: + case PIPE_CAP_INDEP_BLEND_ENABLE: + case PIPE_CAP_INDEP_BLEND_FUNC: return 0; - case PIPE_CAP_BLEND_EQUATION_SEPARATE: - return 1; + + /* Texturing. */ + case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: + case PIPE_CAP_MAX_COMBINED_SAMPLERS: + return r300screen->caps.num_tex_units; + case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS: + return 0; + case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: + case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: + case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: + /* 13 == 4096, 12 == 2048 */ + return is_r500 ? 13 : 12; + + /* Render targets. */ + case PIPE_CAP_MAX_RENDER_TARGETS: + return 4; + + /* General shader limits and features. */ case PIPE_CAP_SM3: - if (r300screen->caps.is_r500) { - return 1; - } else { - return 0; - } + return is_r500 ? 1 : 0; case PIPE_CAP_MAX_CONST_BUFFERS: return 1; case PIPE_CAP_MAX_CONST_BUFFER_SIZE: return 256; - case PIPE_CAP_INDEP_BLEND_ENABLE: - return 0; - case PIPE_CAP_INDEP_BLEND_FUNC: - return 0; + + /* Fragment coordinate conventions. */ case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: return 1; case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: return 0; + + /* Fragment shader limits. */ + case PIPE_CAP_MAX_FS_INSTRUCTIONS: + return is_r500 || is_r400 ? 512 : 96; + case PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS: + return is_r500 || is_r400 ? 512 : 64; + case PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS: + return is_r500 || is_r400 ? 512 : 32; + case PIPE_CAP_MAX_FS_TEX_INDIRECTIONS: + return is_r500 ? 511 : 4; + case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH: + return is_r500 ? 64 : 0; /* Actually unlimited on r500. */ + case PIPE_CAP_MAX_FS_INPUTS: + /* 2 colors + 8 texcoords are always supported + * (minus fog and wpos). + * + * R500 has the ability to turn 3rd and 4th color into + * additional texcoords but there is no two-sided color + * selection then. However the facing bit can be used instead. */ + return 10; + case PIPE_CAP_MAX_FS_CONSTS: + return is_r500 ? 256 : 32; + case PIPE_CAP_MAX_FS_TEMPS: + return is_r500 ? 128 : is_r400 ? 64 : 32; + case PIPE_CAP_MAX_FS_ADDRS: + return 0; + case PIPE_CAP_MAX_FS_PREDS: + return is_r500 ? 1 : 0; + + /* Vertex shader limits. */ + case PIPE_CAP_MAX_VS_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS: + return is_r500 ? 1024 : 256; + case PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_TEX_INDIRECTIONS: + return 0; + case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH: + return is_r500 ? 4 : 0; /* For loops; not sure about conditionals. */ + case PIPE_CAP_MAX_VS_INPUTS: + return 16; + case PIPE_CAP_MAX_VS_CONSTS: + return 256; + case PIPE_CAP_MAX_VS_TEMPS: + return 32; + case PIPE_CAP_MAX_VS_ADDRS: + return 1; /* XXX guessed */ + case PIPE_CAP_MAX_VS_PREDS: + return is_r500 ? 4 : 0; /* XXX guessed. */ + default: fprintf(stderr, "r300: Implementation error: Bad param %d\n", param); @@ -166,7 +209,7 @@ static int r300_get_param(struct pipe_screen* pscreen, int param) } } -static float r300_get_paramf(struct pipe_screen* pscreen, int param) +static float r300_get_paramf(struct pipe_screen* pscreen, enum pipe_cap param) { struct r300_screen* r300screen = r300_screen(pscreen); diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h index d58aa138a70..29492024fe3 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -61,19 +61,23 @@ static INLINE struct r300_screen* r300_screen(struct pipe_screen* screen) { * those changes. */ /*@{*/ -#define DBG_HELP 0x0000001 -#define DBG_FP 0x0000002 -#define DBG_VP 0x0000004 -#define DBG_CS 0x0000008 -#define DBG_DRAW 0x0000010 -#define DBG_TEX 0x0000020 -#define DBG_FALL 0x0000040 -#define DBG_ANISOHQ 0x0000080 -#define DBG_NO_TILING 0x0000100 -#define DBG_NO_IMMD 0x0000200 -#define DBG_STATS 0x0000400 -#define DBG_RS 0x0000800 -#define DBG_TEXALLOC 0x0001000 +#define DBG_HELP (1 << 0) +/* Logging. */ +#define DBG_FP (1 << 1) +#define DBG_VP (1 << 2) +#define DBG_CS (1 << 3) +#define DBG_DRAW (1 << 4) +#define DBG_TEX (1 << 5) +#define DBG_TEXALLOC (1 << 6) +#define DBG_RS (1 << 7) +#define DBG_FALL (1 << 8) +#define DBG_FB (1 << 9) +/* Features. */ +#define DBG_ANISOHQ (1 << 16) +#define DBG_NO_TILING (1 << 17) +#define DBG_NO_IMMD (1 << 18) +/* Statistics. */ +#define DBG_STATS (1 << 24) /*@}*/ static INLINE boolean SCREEN_DBG_ON(struct r300_screen * screen, unsigned flags) diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 4f41530c16a..67e09362d8e 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -395,13 +395,13 @@ static void r300_set_clip_state(struct pipe_context* pipe, if (r300->screen->caps.has_tcl) { memcpy(r300->clip_state.state, state, sizeof(struct pipe_clip_state)); r300->clip_state.size = 29; + + r300->clip_state.dirty = TRUE; } else { draw_flush(r300->draw); draw_set_clip_state(r300->draw, state); r300->clip_state.size = 2; } - - r300->clip_state.dirty = TRUE; } static void @@ -573,13 +573,35 @@ static void r300_fb_set_tiling_flags(struct r300_context *r300, } } +static void r300_print_fb_surf_info(struct pipe_surface *surf, unsigned index, + const char *binding) +{ + struct pipe_resource *tex = surf->texture; + struct r300_texture *rtex = r300_texture(tex); + + fprintf(stderr, + "r300: %s[%i] Dim: %ix%i, Offset: %i, ZSlice: %i, " + "Face: %i, Level: %i, Format: %s\n" + + "r300: TEX: Macro: %s, Micro: %s, Pitch: %i, " + "Dim: %ix%ix%i, LastLevel: %i, Format: %s\n", + + binding, index, surf->width, surf->height, surf->offset, + surf->zslice, surf->face, surf->level, + util_format_short_name(surf->format), + + rtex->macrotile ? "YES" : " NO", rtex->microtile ? "YES" : " NO", + rtex->hwpitch[0], tex->width0, tex->height0, tex->depth0, + tex->last_level, util_format_short_name(tex->format)); +} + static void r300_set_framebuffer_state(struct pipe_context* pipe, const struct pipe_framebuffer_state* state) { struct r300_context* r300 = r300_context(pipe); struct pipe_framebuffer_state *old_state = r300->fb_state.state; - unsigned max_width, max_height; + unsigned max_width, max_height, i; uint32_t zbuffer_bpp = 0; if (state->nr_cbufs > 4) { @@ -623,7 +645,7 @@ static void memcpy(r300->fb_state.state, state, sizeof(struct pipe_framebuffer_state)); r300->fb_state.size = (10 * state->nr_cbufs) + (2 * (4 - state->nr_cbufs)) + - (state->zsbuf ? 10 : 0) + 11; + (state->zsbuf ? 10 : 0) + 9; /* Polygon offset depends on the zbuffer bit depth. */ if (state->zsbuf && r300->polygon_offset_enabled) { @@ -641,6 +663,16 @@ static void r300->rs_state.dirty = TRUE; } } + + if (DBG_ON(r300, DBG_FB)) { + fprintf(stderr, "r300: set_framebuffer_state:\n"); + for (i = 0; i < state->nr_cbufs; i++) { + r300_print_fb_surf_info(state->cbufs[i], i, "CB"); + } + if (state->zsbuf) { + r300_print_fb_surf_info(state->zsbuf, 0, "ZB"); + } + } } /* Create fragment shader state. */ @@ -729,9 +761,14 @@ static void* r300_create_rs_state(struct pipe_context* pipe, { struct r300_rs_state* rs = CALLOC_STRUCT(r300_rs_state); int i; + float psiz; - /* Copy rasterizer state for Draw. */ + /* Copy rasterizer state. */ rs->rs = *state; + rs->rs_draw = *state; + + /* Override some states for Draw. */ + rs->rs_draw.sprite_coord_enable = 0; /* We can do this in HW. */ #ifdef PIPE_ARCH_LITTLE_ENDIAN rs->vap_control_status = R300_VC_NO_SWAP; @@ -744,60 +781,64 @@ static void* r300_create_rs_state(struct pipe_context* pipe, rs->vap_control_status |= R300_VAP_TCL_BYPASS; } - rs->point_size = pack_float_16_6x(state->point_size) | + /* Point size width and height. */ + rs->point_size = + pack_float_16_6x(state->point_size) | (pack_float_16_6x(state->point_size) << R300_POINTSIZE_X_SHIFT); + /* Point size clamping. */ + if (state->point_size_per_vertex) { + /* Per-vertex point size. + * Clamp to [0, max FB size] */ + psiz = pipe->screen->get_paramf(pipe->screen, + PIPE_CAP_MAX_POINT_WIDTH); + rs->point_minmax = + pack_float_16_6x(psiz) << R300_GA_POINT_MINMAX_MAX_SHIFT; + } else { + /* We cannot disable the point-size vertex output, + * so clamp it. */ + psiz = state->point_size; + rs->point_minmax = + (pack_float_16_6x(psiz) << R300_GA_POINT_MINMAX_MIN_SHIFT) | + (pack_float_16_6x(psiz) << R300_GA_POINT_MINMAX_MAX_SHIFT); + } + + /* Line control. */ rs->line_control = pack_float_16_6x(state->line_width) | R300_GA_LINE_CNTL_END_TYPE_COMP; /* Enable polygon mode */ - if (state->fill_cw != PIPE_POLYGON_MODE_FILL || - state->fill_ccw != PIPE_POLYGON_MODE_FILL) { + if (state->fill_front != PIPE_POLYGON_MODE_FILL || + state->fill_back != PIPE_POLYGON_MODE_FILL) { rs->polygon_mode = R300_GA_POLY_MODE_DUAL; } - /* Radeons don't think in "CW/CCW", they think in "front/back". */ - if (state->front_winding == PIPE_WINDING_CW) { - rs->cull_mode = R300_FRONT_FACE_CW; - - /* Polygon offset */ - if (state->offset_cw) { - rs->polygon_offset_enable |= R300_FRONT_ENABLE; - } - if (state->offset_ccw) { - rs->polygon_offset_enable |= R300_BACK_ENABLE; - } - - /* Polygon mode */ - if (rs->polygon_mode) { - rs->polygon_mode |= - r300_translate_polygon_mode_front(state->fill_cw); - rs->polygon_mode |= - r300_translate_polygon_mode_back(state->fill_ccw); - } - } else { + /* Front face */ + if (state->front_ccw) rs->cull_mode = R300_FRONT_FACE_CCW; + else + rs->cull_mode = R300_FRONT_FACE_CW; - /* Polygon offset */ - if (state->offset_ccw) { - rs->polygon_offset_enable |= R300_FRONT_ENABLE; - } - if (state->offset_cw) { - rs->polygon_offset_enable |= R300_BACK_ENABLE; - } + /* Polygon offset */ + if (util_get_offset(state, state->fill_front)) { + rs->polygon_offset_enable |= R300_FRONT_ENABLE; + } + if (util_get_offset(state, state->fill_back)) { + rs->polygon_offset_enable |= R300_BACK_ENABLE; + } - /* Polygon mode */ - if (rs->polygon_mode) { - rs->polygon_mode |= - r300_translate_polygon_mode_front(state->fill_ccw); - rs->polygon_mode |= - r300_translate_polygon_mode_back(state->fill_cw); - } + /* Polygon mode */ + if (rs->polygon_mode) { + rs->polygon_mode |= + r300_translate_polygon_mode_front(state->fill_front); + rs->polygon_mode |= + r300_translate_polygon_mode_back(state->fill_back); } - if (state->front_winding & state->cull_mode) { + + if (state->cull_face & PIPE_FACE_FRONT) { rs->cull_mode |= R300_CULL_FRONT; } - if (~(state->front_winding) & state->cull_mode) { + if (state->cull_face & PIPE_FACE_BACK) { rs->cull_mode |= R300_CULL_BACK; } @@ -856,24 +897,30 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) struct r300_context* r300 = r300_context(pipe); struct r300_rs_state* rs = (struct r300_rs_state*)state; int last_sprite_coord_enable = r300->sprite_coord_enable; + boolean last_two_sided_color = r300->two_sided_color; - if (r300->draw) { + if (r300->draw && rs) { draw_flush(r300->draw); - draw_set_rasterizer_state(r300->draw, &rs->rs, state); + draw_set_rasterizer_state(r300->draw, &rs->rs_draw, state); } if (rs) { - r300->polygon_offset_enabled = rs->rs.offset_cw || rs->rs.offset_ccw; + r300->polygon_offset_enabled = (rs->rs.offset_point || + rs->rs.offset_line || + rs->rs.offset_tri); r300->sprite_coord_enable = rs->rs.sprite_coord_enable; + r300->two_sided_color = rs->rs.light_twoside; } else { r300->polygon_offset_enabled = FALSE; r300->sprite_coord_enable = 0; + r300->two_sided_color = FALSE; } UPDATE_STATE(state, r300->rs_state); - r300->rs_state.size = 26 + (r300->polygon_offset_enabled ? 5 : 0); + r300->rs_state.size = 27 + (r300->polygon_offset_enabled ? 5 : 0); - if (last_sprite_coord_enable != r300->sprite_coord_enable) { + if (last_sprite_coord_enable != r300->sprite_coord_enable || + last_two_sided_color != r300->two_sided_color) { r300->rs_block_state.dirty = TRUE; } } @@ -913,7 +960,7 @@ static void* sampler->min_lod = MAX2((unsigned)state->min_lod, 0); sampler->max_lod = MAX2((unsigned)ceilf(state->max_lod), 0); - lod_bias = CLAMP((int)(state->lod_bias * 32), -(1 << 9), (1 << 9) - 1); + lod_bias = CLAMP((int)(state->lod_bias * 32 + 1), -(1 << 9), (1 << 9) - 1); sampler->filter1 |= lod_bias << R300_LOD_BIAS_SHIFT; @@ -1028,7 +1075,6 @@ r300_create_sampler_view(struct pipe_context *pipe, { struct r300_sampler_view *view = CALLOC_STRUCT(r300_sampler_view); struct r300_texture *tex = r300_texture(texture); - unsigned char swizzle[4]; if (view) { view->base = *templ; @@ -1037,14 +1083,14 @@ r300_create_sampler_view(struct pipe_context *pipe, view->base.texture = NULL; pipe_resource_reference(&view->base.texture, texture); - swizzle[0] = templ->swizzle_r; - swizzle[1] = templ->swizzle_g; - swizzle[2] = templ->swizzle_b; - swizzle[3] = templ->swizzle_a; + view->swizzle[0] = templ->swizzle_r; + view->swizzle[1] = templ->swizzle_g; + view->swizzle[2] = templ->swizzle_b; + view->swizzle[3] = templ->swizzle_a; view->format = tex->tx_format; view->format.format1 |= r300_translate_texformat(templ->format, - swizzle); + view->swizzle); if (r300_screen(pipe->screen)->caps.is_r500) { view->format.format2 |= r500_tx_format_msb_bit(templ->format); } @@ -1081,6 +1127,13 @@ static void r300_set_viewport_state(struct pipe_context* pipe, r300->viewport = *state; + if (r300->draw) { + draw_flush(r300->draw); + draw_set_viewport_state(r300->draw, state); + viewport->vte_control = R300_VTX_XY_FMT | R300_VTX_Z_FMT; + return; + } + /* Do the transform in HW. */ viewport->vte_control = R300_VTX_W0_FMT; @@ -1190,7 +1243,7 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, } } -/* Update the PSC tables. */ +/* Initialize the PSC tables. */ static void r300_vertex_psc(struct r300_vertex_element_state *velems) { struct r300_vertex_stream_state *vstream = &velems->vertex_stream; @@ -1329,7 +1382,6 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe, abort(); } } - } } return velems; @@ -1350,6 +1402,7 @@ static void r300_bind_vertex_elements_state(struct pipe_context *pipe, if (r300->draw) { draw_flush(r300->draw); draw_set_vertex_elements(r300->draw, velems->count, velems->velem); + return; } UPDATE_STATE(&velems->vertex_stream, r300->vertex_stream_state); @@ -1372,8 +1425,10 @@ static void* r300_create_vs_state(struct pipe_context* pipe, vs->state = *shader; vs->state.tokens = tgsi_dup_tokens(shader->tokens); + r300_init_vs_outputs(vs); + if (r300->screen->caps.has_tcl) { - r300_translate_vertex_shader(r300, vs, vs->state.tokens); + r300_translate_vertex_shader(r300, vs); } else { vs->draw_vs = draw_create_vertex_shader(r300->draw, shader); } @@ -1443,7 +1498,7 @@ static void r300_set_constant_buffer(struct pipe_context *pipe, struct r300_constant_buffer *cbuf; struct pipe_transfer *tr; void *mapped; - int max_size = 0; + int max_size = 0, max_size_bytes = 0, clamped_size = 0; switch (shader) { case PIPE_SHADER_VERTEX: @@ -1462,6 +1517,7 @@ static void r300_set_constant_buffer(struct pipe_context *pipe, assert(0); return; } + max_size_bytes = max_size * 4 * sizeof(float); if (buf == NULL || buf->width0 == 0 || (mapped = pipe_buffer_map(pipe, buf, PIPE_TRANSFER_READ, &tr)) == NULL) @@ -1470,19 +1526,21 @@ static void r300_set_constant_buffer(struct pipe_context *pipe, return; } - assert((buf->width0 % 4 * sizeof(float)) == 0); + if (shader == PIPE_SHADER_FRAGMENT || + (shader == PIPE_SHADER_VERTEX && r300->screen->caps.has_tcl)) { + assert((buf->width0 % (4 * sizeof(float))) == 0); - /* Check the size of the constant buffer. */ - /* XXX Subtract immediates and RC_STATE_* variables. */ - if (buf->width0 > (sizeof(float) * 4 * max_size)) { - fprintf(stderr, "r300: Max size of the constant buffer is " - "%i*4 floats.\n", max_size); - abort(); - } + /* Check the size of the constant buffer. */ + /* XXX Subtract immediates and RC_STATE_* variables. */ + if (buf->width0 > max_size_bytes) { + fprintf(stderr, "r300: Max size of the constant buffer is " + "%i*4 floats.\n", max_size); + } + clamped_size = MIN2(buf->width0, max_size_bytes); - memcpy(cbuf->constants, mapped, buf->width0); - cbuf->count = buf->width0 / (4 * sizeof(float)); - pipe_buffer_unmap(pipe, buf, tr); + memcpy(cbuf->constants, mapped, clamped_size); + cbuf->count = clamped_size / (4 * sizeof(float)); + } if (shader == PIPE_SHADER_VERTEX) { if (r300->screen->caps.has_tcl) { @@ -1492,12 +1550,13 @@ static void r300_set_constant_buffer(struct pipe_context *pipe, r300->pvs_flush.dirty = TRUE; } else if (r300->draw) { draw_set_mapped_constant_buffer(r300->draw, PIPE_SHADER_VERTEX, - 0, cbuf->constants, - buf->width0); + 0, mapped, buf->width0); } } else if (shader == PIPE_SHADER_FRAGMENT) { r300->fs_constants.dirty = TRUE; } + + pipe_buffer_unmap(pipe, buf, tr); } void r300_init_state_functions(struct r300_context* r300) diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index e3adace0faa..7583862a1a4 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -34,6 +34,7 @@ #include "r300_state.h" #include "r300_state_derived.h" #include "r300_state_inlines.h" +#include "r300_texture.h" #include "r300_vs.h" /* r300_state_derived: Various bits of state which are dependent upon @@ -115,13 +116,12 @@ static void r300_draw_emit_all_attribs(struct r300_context* r300) static void r300_swtcl_vertex_psc(struct r300_context *r300) { struct r300_vertex_stream_state *vstream = r300->vertex_stream_state.state; - struct vertex_info* vinfo = &r300->vertex_info; + struct vertex_info *vinfo = &r300->vertex_info; uint16_t type, swizzle; enum pipe_format format; unsigned i, attrib_count; int* vs_output_tab = r300->stream_loc_notcl; - /* XXX hax */ memset(vstream, 0, sizeof(struct r300_vertex_stream_state)); /* For each Draw attribute, route it to the fragment shader according @@ -354,10 +354,26 @@ static void r300_update_rs_block(struct r300_context *r300) /* Set up back-face colors. The rasterizer will do the color selection * automatically. */ if (any_bcolor_used) { - for (i = 0; i < ATTR_COLOR_COUNT; i++) { - rs.vap_vsm_vtx_assm |= R300_INPUT_CNTL_COLOR; - rs.vap_out_vtx_fmt[0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << (2+i); - stream_loc_notcl[loc++] = 4 + i; + if (r300->two_sided_color) { + /* Rasterize as back-face colors. */ + for (i = 0; i < ATTR_COLOR_COUNT; i++) { + rs.vap_vsm_vtx_assm |= R300_INPUT_CNTL_COLOR; + rs.vap_out_vtx_fmt[0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << (2+i); + stream_loc_notcl[loc++] = 4 + i; + } + } else { + /* Rasterize two fake texcoords to prevent from the two-sided color + * selection. */ + /* XXX Consider recompiling the vertex shader to save 2 RS units. */ + for (i = 0; i < 2; i++) { + rs.vap_vsm_vtx_assm |= (R300_INPUT_CNTL_TC0 << tex_count); + rs.vap_out_vtx_fmt[1] |= (4 << (3 * tex_count)); + stream_loc_notcl[loc++] = 6 + tex_count; + + /* Rasterize it. */ + rX00_rs_tex(&rs, tex_count, tex_count, SWIZ_XYZW); + tex_count++; + } } } @@ -493,6 +509,12 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) unsigned min_level, max_level, i, size; unsigned count = MIN2(state->sampler_view_count, state->sampler_state_count); + unsigned char depth_swizzle[4] = { + UTIL_FORMAT_SWIZZLE_X, + UTIL_FORMAT_SWIZZLE_X, + UTIL_FORMAT_SWIZZLE_X, + UTIL_FORMAT_SWIZZLE_X + }; state->tx_enable = 0; state->count = 0; @@ -512,6 +534,20 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) texstate->filter1 = sampler->filter1; texstate->border_color = sampler->border_color; + /* If compare mode is disabled, the sampler view swizzles + * are stored in the format. + * Otherwise, swizzles must be applied after the compare mode + * in the fragment shader. */ + if (util_format_is_depth_or_stencil(tex->b.b.format)) { + if (sampler->state.compare_mode == PIPE_TEX_COMPARE_NONE) { + texstate->format.format1 |= + r300_get_swizzle_combined(depth_swizzle, view->swizzle); + } else { + texstate->format.format1 |= + r300_get_swizzle_combined(depth_swizzle, 0); + } + } + /* to emulate 1D textures through 2D ones correctly */ if (tex->b.b.target == PIPE_TEXTURE_1D) { texstate->filter0 &= ~R300_TX_WRAP_T_MASK; @@ -578,13 +614,13 @@ void r300_update_derived_state(struct r300_context* r300) if (r300->rs_block_state.dirty) { r300_update_rs_block(r300); - } - if (r300->draw) { - memset(&r300->vertex_info, 0, sizeof(struct vertex_info)); - r300_draw_emit_all_attribs(r300); - draw_compute_vertex_size(&r300->vertex_info); - r300_swtcl_vertex_psc(r300); + if (r300->draw) { + memset(&r300->vertex_info, 0, sizeof(struct vertex_info)); + r300_draw_emit_all_attribs(r300); + draw_compute_vertex_size(&r300->vertex_info); + r300_swtcl_vertex_psc(r300); + } } r300_update_hyperz_state(r300); diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index cd9443fa260..34d3a169d57 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -27,11 +27,6 @@ #include "r300_screen.h" #include "r300_state_invariant.h" -struct pipe_viewport_state r300_viewport_identity = { - .scale = {1.0, 1.0, 1.0, 1.0}, - .translate = {0.0, 0.0, 0.0, 0.0}, -}; - /* Calculate and emit invariant state. This is data that the 3D engine * will probably want at the beginning of every CS, but it's not currently * handled by any CSO setup, and in addition it doesn't really change much. diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index d6f629cf9c6..4a5c932b7e8 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -24,6 +24,7 @@ #include "pipe/p_screen.h" #include "util/u_format.h" +#include "util/u_format_s3tc.h" #include "util/u_math.h" #include "util/u_memory.h" @@ -46,6 +47,60 @@ static const unsigned microblock_table[5][3][2] = { {{ 2, 1}, {0, 0}, {0, 0}} /* 128 bits per pixel */ }; +unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format, + const unsigned char *swizzle_view) +{ + unsigned i; + unsigned char swizzle[4]; + unsigned result = 0; + const uint32_t swizzle_shift[4] = { + R300_TX_FORMAT_R_SHIFT, + R300_TX_FORMAT_G_SHIFT, + R300_TX_FORMAT_B_SHIFT, + R300_TX_FORMAT_A_SHIFT + }; + const uint32_t swizzle_bit[4] = { + R300_TX_FORMAT_X, + R300_TX_FORMAT_Y, + R300_TX_FORMAT_Z, + R300_TX_FORMAT_W + }; + + if (swizzle_view) { + /* Combine two sets of swizzles. */ + for (i = 0; i < 4; i++) { + swizzle[i] = swizzle_view[i] <= UTIL_FORMAT_SWIZZLE_W ? + swizzle_format[swizzle_view[i]] : swizzle_view[i]; + } + } else { + memcpy(swizzle, swizzle_format, 4); + } + + /* Get swizzle. */ + for (i = 0; i < 4; i++) { + switch (swizzle[i]) { + case UTIL_FORMAT_SWIZZLE_Y: + result |= swizzle_bit[1] << swizzle_shift[i]; + break; + case UTIL_FORMAT_SWIZZLE_Z: + result |= swizzle_bit[2] << swizzle_shift[i]; + break; + case UTIL_FORMAT_SWIZZLE_W: + result |= swizzle_bit[3] << swizzle_shift[i]; + break; + case UTIL_FORMAT_SWIZZLE_0: + result |= R300_TX_FORMAT_ZERO << swizzle_shift[i]; + break; + case UTIL_FORMAT_SWIZZLE_1: + result |= R300_TX_FORMAT_ONE << swizzle_shift[i]; + break; + default: /* UTIL_FORMAT_SWIZZLE_X */ + result |= swizzle_bit[0] << swizzle_shift[i]; + } + } + return result; +} + /* Translate a pipe_format into a useful texture format for sampling. * * Some special formats are translated directly using R300_EASY_TX_FORMAT, @@ -65,38 +120,26 @@ uint32_t r300_translate_texformat(enum pipe_format format, const struct util_format_description *desc; unsigned i; boolean uniform = TRUE; - const uint32_t swizzle_shift[4] = { - R300_TX_FORMAT_R_SHIFT, - R300_TX_FORMAT_G_SHIFT, - R300_TX_FORMAT_B_SHIFT, - R300_TX_FORMAT_A_SHIFT - }; - const uint32_t swizzle_bit[4] = { - R300_TX_FORMAT_X, - R300_TX_FORMAT_Y, - R300_TX_FORMAT_Z, - R300_TX_FORMAT_W - }; const uint32_t sign_bit[4] = { R300_TX_FORMAT_SIGNED_X, R300_TX_FORMAT_SIGNED_Y, R300_TX_FORMAT_SIGNED_Z, R300_TX_FORMAT_SIGNED_W, }; - unsigned char swizzle[4]; desc = util_format_description(format); /* Colorspace (return non-RGB formats directly). */ switch (desc->colorspace) { - /* Depth stencil formats. */ + /* Depth stencil formats. + * Swizzles are added in r300_merge_textures_and_samplers. */ case UTIL_FORMAT_COLORSPACE_ZS: switch (format) { case PIPE_FORMAT_Z16_UNORM: - return R300_EASY_TX_FORMAT(X, X, X, X, X16); + return R300_TX_FORMAT_X16; case PIPE_FORMAT_X8Z24_UNORM: case PIPE_FORMAT_S8_USCALED_Z24_UNORM: - return R300_EASY_TX_FORMAT(X, X, X, X, W24_FP); + return R300_TX_FORMAT_W24_FP; default: return ~0; /* Unsupported. */ } @@ -130,46 +173,14 @@ uint32_t r300_translate_texformat(enum pipe_format format, } } - /* Get swizzle. */ - if (swizzle_view) { - /* Compose two sets of swizzles. */ - for (i = 0; i < 4; i++) { - swizzle[i] = swizzle_view[i] <= UTIL_FORMAT_SWIZZLE_W ? - desc->swizzle[swizzle_view[i]] : swizzle_view[i]; - } - } else { - memcpy(swizzle, desc->swizzle, sizeof(swizzle)); - } - - /* Add swizzle. */ - for (i = 0; i < 4; i++) { - switch (swizzle[i]) { - case UTIL_FORMAT_SWIZZLE_X: - case UTIL_FORMAT_SWIZZLE_NONE: - result |= swizzle_bit[0] << swizzle_shift[i]; - break; - case UTIL_FORMAT_SWIZZLE_Y: - result |= swizzle_bit[1] << swizzle_shift[i]; - break; - case UTIL_FORMAT_SWIZZLE_Z: - result |= swizzle_bit[2] << swizzle_shift[i]; - break; - case UTIL_FORMAT_SWIZZLE_W: - result |= swizzle_bit[3] << swizzle_shift[i]; - break; - case UTIL_FORMAT_SWIZZLE_0: - result |= R300_TX_FORMAT_ZERO << swizzle_shift[i]; - break; - case UTIL_FORMAT_SWIZZLE_1: - result |= R300_TX_FORMAT_ONE << swizzle_shift[i]; - break; - default: - return ~0; /* Unsupported. */ - } - } + result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view); /* S3TC formats. */ if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) { + if (!util_format_s3tc_enabled) { + return ~0; /* Unsupported. */ + } + switch (format) { case PIPE_FORMAT_DXT1_RGB: case PIPE_FORMAT_DXT1_RGBA: @@ -920,6 +931,7 @@ struct pipe_resource* r300_texture_create(struct pipe_screen* screen, fprintf(stderr, "r300: texture_create: " "Got invalid texture dimensions: %ix%ix%i\n", base->width0, base->height0, base->depth0); + FREE(tex); return NULL; } @@ -948,7 +960,7 @@ struct pipe_resource* r300_texture_create(struct pipe_screen* screen, util_format_short_name(base->format)); tex->buffer = rws->buffer_create(rws, 2048, - PIPE_BIND_SAMPLER_VIEW, /* XXX */ + base->bind, tex->size); rws->buffer_set_tiling(rws, tex->buffer, tex->pitch[0], diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h index ba79ec068a1..2d8f0e14393 100644 --- a/src/gallium/drivers/r300/r300_texture.h +++ b/src/gallium/drivers/r300/r300_texture.h @@ -27,6 +27,9 @@ struct r300_texture; +unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format, + const unsigned char *swizzle_view); + uint32_t r300_translate_texformat(enum pipe_format format, const unsigned char *swizzle_view); diff --git a/src/gallium/drivers/r300/r300_transfer.c b/src/gallium/drivers/r300/r300_transfer.c index f0f87c5e2bc..beb321cb238 100644 --- a/src/gallium/drivers/r300/r300_transfer.c +++ b/src/gallium/drivers/r300/r300_transfer.c @@ -108,6 +108,12 @@ r300_texture_get_transfer(struct pipe_context *ctx, struct r300_transfer *trans; struct pipe_resource base; + /* XXX Why aren't flushes taken care of by winsys automatically? + * Winsys seems to sometimes return a cached buffer instead of + * a mapped hardware buffer if this flush is commented out. */ + if (ctx->is_resource_referenced(ctx, texture, sr.face, sr.level)) + ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL); + trans = CALLOC_STRUCT(r300_transfer); if (trans) { /* Initialize the transfer object. */ diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c index f3186431e1d..59f89b3482a 100644 --- a/src/gallium/drivers/r300/r300_vs.c +++ b/src/gallium/drivers/r300/r300_vs.c @@ -181,21 +181,23 @@ static void r300_dummy_vertex_shader( state.tokens = ureg_finalize(ureg); shader->dummy = TRUE; - r300_translate_vertex_shader(r300, shader, state.tokens); + r300_translate_vertex_shader(r300, shader); ureg_destroy(ureg); } -void r300_translate_vertex_shader(struct r300_context* r300, - struct r300_vertex_shader* vs, - const struct tgsi_token *tokens) +void r300_init_vs_outputs(struct r300_vertex_shader *vs) +{ + tgsi_scan_shader(vs->state.tokens, &vs->info); + r300_shader_read_vs_outputs(&vs->info, &vs->outputs); +} + +void r300_translate_vertex_shader(struct r300_context *r300, + struct r300_vertex_shader *vs) { struct r300_vertex_program_compiler compiler; struct tgsi_to_rc ttr; - tgsi_scan_shader(tokens, &vs->info); - r300_shader_read_vs_outputs(&vs->info, &vs->outputs); - /* Setup the compiler */ rc_init(&compiler.Base); @@ -205,7 +207,7 @@ void r300_translate_vertex_shader(struct r300_context* r300, if (compiler.Base.Debug) { debug_printf("r300: Initial vertex program\n"); - tgsi_dump(tokens, 0); + tgsi_dump(vs->state.tokens, 0); } /* Translate TGSI to our internal representation */ @@ -213,7 +215,7 @@ void r300_translate_vertex_shader(struct r300_context* r300, ttr.info = &vs->info; ttr.use_half_swizzles = FALSE; - r300_tgsi_to_rc(&ttr, tokens); + r300_tgsi_to_rc(&ttr, vs->state.tokens); compiler.RequiredOutputs = ~(~0 << (vs->info.num_outputs + 1)); compiler.SetHwInputOutput = &set_vertex_inputs_outputs; diff --git a/src/gallium/drivers/r300/r300_vs.h b/src/gallium/drivers/r300/r300_vs.h index 57b3fbca0bb..31890d78caf 100644 --- a/src/gallium/drivers/r300/r300_vs.h +++ b/src/gallium/drivers/r300/r300_vs.h @@ -56,8 +56,8 @@ struct r300_vertex_shader { void *draw_vs; }; -void r300_translate_vertex_shader(struct r300_context* r300, - struct r300_vertex_shader* vs, - const struct tgsi_token *tokens); +void r300_init_vs_outputs(struct r300_vertex_shader *vs); +void r300_translate_vertex_shader(struct r300_context *r300, + struct r300_vertex_shader *vs); #endif /* R300_VS_H */ diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index 1642981eaa8..3d0413f90af 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -87,13 +87,8 @@ struct r300_winsys_screen { struct r300_winsys_buffer **pdst, struct r300_winsys_buffer *src); - boolean (*buffer_references)(struct r300_winsys_buffer *a, - struct r300_winsys_buffer *b); - - void (*buffer_flush_range)(struct r300_winsys_screen *rws, - struct r300_winsys_buffer *buf, - unsigned offset, - unsigned length); + void (*buffer_wait)(struct r300_winsys_screen *rws, + struct r300_winsys_buffer *buf); /* Add a pipe_resource to the list of buffer objects to validate. */ boolean (*add_buffer)(struct r300_winsys_screen *winsys, diff --git a/src/gallium/drivers/rbug/Makefile b/src/gallium/drivers/rbug/Makefile new file mode 100644 index 00000000000..64e172fe5c1 --- /dev/null +++ b/src/gallium/drivers/rbug/Makefile @@ -0,0 +1,12 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +LIBNAME = rbug + +C_SOURCES = \ + rbug_core.c \ + rbug_context.c \ + rbug_objects.c \ + rbug_screen.c + +include ../../Makefile.template diff --git a/src/gallium/drivers/rbug/README b/src/gallium/drivers/rbug/README new file mode 100644 index 00000000000..b6d3a5cf351 --- /dev/null +++ b/src/gallium/drivers/rbug/README @@ -0,0 +1,58 @@ + RBUG PIPE DRIVER + + += About = + +This directory contains a Gallium3D remote debugger pipe driver. +It provides remote debugging functionality. + + += Build Instructions = + +To build, invoke scons on the top dir as + + scons dri=no statetrackers=mesa winsys=xlib + + += Usage = + +To use do + + export LD_LIBRARY_PATH=$PWD/build/linux-x86-debug/lib + +ensure the right libGL.so is being picked by doing + + ldd progs/trivial/tri + + export XMESA_TRACE=y + GALLIUM_RBUG=true progs/trivial/tri + +which should open gallium remote debugging session. While the program is running +you can launch the small remote debugging application from progs/rbug. More +information is in that directory. Also for a gui see: + + http://cgit.freedesktop.org/mesa/rbug-gui + + += Integrating = + +You can integrate the rbug pipe driver either inside the state tracker or the +target. The procedure on both cases is the same. Let's assume you have a +pipe_screen obtained by the usual means (variable and function names are just +for illustration purposes): + + real_screen = real_screen_create(...); + +The rbug screen is then created by doing + + rbug_screen = rbug_screen_create(real_screen); + +You can then simply use rbug_screen instead of real_screen. + +You can create as many contexts you wish from rbug_screen::context_create they +are automatically wrapped by rbug_screen. + + +-- +Jose Fonseca <[email protected]> +Jakob Bornecrantz <[email protected]> diff --git a/src/gallium/drivers/rbug/SConscript b/src/gallium/drivers/rbug/SConscript new file mode 100644 index 00000000000..3da6ac104a4 --- /dev/null +++ b/src/gallium/drivers/rbug/SConscript @@ -0,0 +1,14 @@ +Import('*') + +env = env.Clone() + +rbug = env.ConvenienceLibrary( + target = 'rbug', + source = [ + 'rbug_context.c', + 'rbug_core.c', + 'rbug_objects.c', + 'rbug_screen.c', + ]) + +Export('rbug') diff --git a/src/gallium/drivers/rbug/rbug_context.c b/src/gallium/drivers/rbug/rbug_context.c new file mode 100644 index 00000000000..59f005ec16c --- /dev/null +++ b/src/gallium/drivers/rbug/rbug_context.c @@ -0,0 +1,1072 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include "pipe/p_context.h" +#include "util/u_memory.h" +#include "util/u_inlines.h" +#include "util/u_simple_list.h" + +#include "rbug/rbug_context.h" + +#include "rbug_context.h" +#include "rbug_objects.h" + + +static void +rbug_destroy(struct pipe_context *_pipe) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->destroy(pipe); + + FREE(rb_pipe); +} + +static void +rbug_draw_block_locked(struct rbug_context *rb_pipe, int flag) +{ + + if (rb_pipe->draw_blocker & flag) { + rb_pipe->draw_blocked |= flag; + } else if ((rb_pipe->draw_rule.blocker & flag) && + (rb_pipe->draw_blocker & RBUG_BLOCK_RULE)) { + int k; + boolean block = FALSE; + debug_printf("%s (%p %p) (%p %p) (%p %u) (%p %u)\n", __FUNCTION__, + (void *) rb_pipe->draw_rule.fs, (void *) rb_pipe->curr.fs, + (void *) rb_pipe->draw_rule.vs, (void *) rb_pipe->curr.vs, + (void *) rb_pipe->draw_rule.surf, 0, + (void *) rb_pipe->draw_rule.texture, 0); + if (rb_pipe->draw_rule.fs && + rb_pipe->draw_rule.fs == rb_pipe->curr.fs) + block = TRUE; + if (rb_pipe->draw_rule.vs && + rb_pipe->draw_rule.vs == rb_pipe->curr.vs) + block = TRUE; + if (rb_pipe->draw_rule.surf && + rb_pipe->draw_rule.surf == rb_pipe->curr.zsbuf) + block = TRUE; + if (rb_pipe->draw_rule.surf) + for (k = 0; k < rb_pipe->curr.nr_cbufs; k++) + if (rb_pipe->draw_rule.surf == rb_pipe->curr.cbufs[k]) + block = TRUE; + if (rb_pipe->draw_rule.texture) { + for (k = 0; k < rb_pipe->curr.num_fs_views; k++) + if (rb_pipe->draw_rule.texture == rb_pipe->curr.fs_texs[k]) + block = TRUE; + for (k = 0; k < rb_pipe->curr.num_vs_views; k++) { + if (rb_pipe->draw_rule.texture == rb_pipe->curr.vs_texs[k]) { + block = TRUE; + } + } + } + + if (block) + rb_pipe->draw_blocked |= (flag | RBUG_BLOCK_RULE); + } + + if (rb_pipe->draw_blocked) + rbug_notify_draw_blocked(rb_pipe); + + /* wait for rbug to clear the blocked flag */ + while (rb_pipe->draw_blocked & flag) { + rb_pipe->draw_blocked |= flag; +#ifdef PIPE_THREAD_HAVE_CONDVAR + pipe_condvar_wait(rb_pipe->draw_cond, rb_pipe->draw_mutex); +#else + pipe_mutex_unlock(rb_pipe->draw_mutex); +#ifdef PIPE_SUBSYSTEM_WINDOWS_USER + Sleep(1); +#endif + pipe_mutex_lock(rb_pipe->draw_mutex); +#endif + } + +} + +static void +rbug_draw_arrays(struct pipe_context *_pipe, + unsigned prim, + unsigned start, + unsigned count) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe_mutex_lock(rb_pipe->draw_mutex); + rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_BEFORE); + + pipe->draw_arrays(pipe, + prim, + start, + count); + + rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_AFTER); + pipe_mutex_unlock(rb_pipe->draw_mutex); +} + +static void +rbug_draw_elements(struct pipe_context *_pipe, + struct pipe_resource *_indexResource, + unsigned indexSize, + int indexBias, + unsigned prim, + unsigned start, + unsigned count) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct rbug_resource *rb_resource = rbug_resource(_indexResource); + struct pipe_context *pipe = rb_pipe->pipe; + struct pipe_resource *indexResource = rb_resource->resource; + + pipe_mutex_lock(rb_pipe->draw_mutex); + rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_BEFORE); + + pipe->draw_elements(pipe, + indexResource, + indexSize, + indexBias, + prim, + start, + count); + + rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_AFTER); + pipe_mutex_unlock(rb_pipe->draw_mutex); +} + +static void +rbug_draw_range_elements(struct pipe_context *_pipe, + struct pipe_resource *_indexResource, + unsigned indexSize, + int indexBias, + unsigned minIndex, + unsigned maxIndex, + unsigned mode, + unsigned start, + unsigned count) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct rbug_resource *rb_resource = rbug_resource(_indexResource); + struct pipe_context *pipe = rb_pipe->pipe; + struct pipe_resource *indexResource = rb_resource->resource; + + pipe_mutex_lock(rb_pipe->draw_mutex); + rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_BEFORE); + + pipe->draw_range_elements(pipe, + indexResource, + indexSize, + indexBias, + minIndex, + maxIndex, + mode, + start, + count); + + rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_AFTER); + pipe_mutex_unlock(rb_pipe->draw_mutex); +} + +static struct pipe_query * +rbug_create_query(struct pipe_context *_pipe, + unsigned query_type) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + return pipe->create_query(pipe, + query_type); +} + +static void +rbug_destroy_query(struct pipe_context *_pipe, + struct pipe_query *query) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->destroy_query(pipe, + query); +} + +static void +rbug_begin_query(struct pipe_context *_pipe, + struct pipe_query *query) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->begin_query(pipe, + query); +} + +static void +rbug_end_query(struct pipe_context *_pipe, + struct pipe_query *query) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->end_query(pipe, + query); +} + +static boolean +rbug_get_query_result(struct pipe_context *_pipe, + struct pipe_query *query, + boolean wait, + uint64_t *result) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + return pipe->get_query_result(pipe, + query, + wait, + result); +} + +static void * +rbug_create_blend_state(struct pipe_context *_pipe, + const struct pipe_blend_state *blend) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + return pipe->create_blend_state(pipe, + blend); +} + +static void +rbug_bind_blend_state(struct pipe_context *_pipe, + void *blend) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->bind_blend_state(pipe, + blend); +} + +static void +rbug_delete_blend_state(struct pipe_context *_pipe, + void *blend) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->delete_blend_state(pipe, + blend); +} + +static void * +rbug_create_sampler_state(struct pipe_context *_pipe, + const struct pipe_sampler_state *sampler) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + return pipe->create_sampler_state(pipe, + sampler); +} + +static void +rbug_bind_fragment_sampler_states(struct pipe_context *_pipe, + unsigned num_samplers, + void **samplers) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->bind_fragment_sampler_states(pipe, + num_samplers, + samplers); +} + +static void +rbug_bind_vertex_sampler_states(struct pipe_context *_pipe, + unsigned num_samplers, + void **samplers) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->bind_vertex_sampler_states(pipe, + num_samplers, + samplers); +} + +static void +rbug_delete_sampler_state(struct pipe_context *_pipe, + void *sampler) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->delete_sampler_state(pipe, + sampler); +} + +static void * +rbug_create_rasterizer_state(struct pipe_context *_pipe, + const struct pipe_rasterizer_state *rasterizer) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + return pipe->create_rasterizer_state(pipe, + rasterizer); +} + +static void +rbug_bind_rasterizer_state(struct pipe_context *_pipe, + void *rasterizer) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->bind_rasterizer_state(pipe, + rasterizer); +} + +static void +rbug_delete_rasterizer_state(struct pipe_context *_pipe, + void *rasterizer) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->delete_rasterizer_state(pipe, + rasterizer); +} + +static void * +rbug_create_depth_stencil_alpha_state(struct pipe_context *_pipe, + const struct pipe_depth_stencil_alpha_state *depth_stencil_alpha) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + return pipe->create_depth_stencil_alpha_state(pipe, + depth_stencil_alpha); +} + +static void +rbug_bind_depth_stencil_alpha_state(struct pipe_context *_pipe, + void *depth_stencil_alpha) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->bind_depth_stencil_alpha_state(pipe, + depth_stencil_alpha); +} + +static void +rbug_delete_depth_stencil_alpha_state(struct pipe_context *_pipe, + void *depth_stencil_alpha) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->delete_depth_stencil_alpha_state(pipe, + depth_stencil_alpha); +} + +static void * +rbug_create_fs_state(struct pipe_context *_pipe, + const struct pipe_shader_state *state) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + void *result; + + result = pipe->create_fs_state(pipe, state); + if (!result) + return NULL; + + return rbug_shader_create(rb_pipe, state, result, RBUG_SHADER_FRAGMENT); +} + +static void +rbug_bind_fs_state(struct pipe_context *_pipe, + void *_fs) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + void *fs; + + fs = rbug_shader_unwrap(_fs); + rb_pipe->curr.fs = rbug_shader(_fs); + pipe->bind_fs_state(pipe, + fs); +} + +static void +rbug_delete_fs_state(struct pipe_context *_pipe, + void *_fs) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct rbug_shader *rb_shader = rbug_shader(_fs); + + rbug_shader_destroy(rb_pipe, rb_shader); +} + +static void * +rbug_create_vs_state(struct pipe_context *_pipe, + const struct pipe_shader_state *state) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + void *result; + + result = pipe->create_vs_state(pipe, state); + if (!result) + return NULL; + + return rbug_shader_create(rb_pipe, state, result, RBUG_SHADER_VERTEX); +} + +static void +rbug_bind_vs_state(struct pipe_context *_pipe, + void *_vs) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + void *vs; + + vs = rbug_shader_unwrap(_vs); + rb_pipe->curr.vs = rbug_shader(_vs); + pipe->bind_vs_state(pipe, + vs); +} + +static void +rbug_delete_vs_state(struct pipe_context *_pipe, + void *_vs) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct rbug_shader *rb_shader = rbug_shader(_vs); + + rbug_shader_destroy(rb_pipe, rb_shader); +} + +static void * +rbug_create_gs_state(struct pipe_context *_pipe, + const struct pipe_shader_state *state) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + void *result; + + result = pipe->create_gs_state(pipe, state); + if (!result) + return NULL; + + return rbug_shader_create(rb_pipe, state, result, RBUG_SHADER_GEOM); +} + +static void +rbug_bind_gs_state(struct pipe_context *_pipe, + void *_gs) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + void *gs; + + gs = rbug_shader_unwrap(_gs); + rb_pipe->curr.gs = rbug_shader(_gs); + pipe->bind_gs_state(pipe, + gs); +} + +static void +rbug_delete_gs_state(struct pipe_context *_pipe, + void *_gs) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct rbug_shader *rb_shader = rbug_shader(_gs); + + rbug_shader_destroy(rb_pipe, rb_shader); +} + +static void * +rbug_create_vertex_elements_state(struct pipe_context *_pipe, + unsigned num_elements, + const struct pipe_vertex_element *vertex_elements) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + return pipe->create_vertex_elements_state(pipe, + num_elements, + vertex_elements); +} + +static void +rbug_bind_vertex_elements_state(struct pipe_context *_pipe, + void *velems) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->bind_vertex_elements_state(pipe, + velems); +} + +static void +rbug_delete_vertex_elements_state(struct pipe_context *_pipe, + void *velems) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->delete_vertex_elements_state(pipe, + velems); +} + +static void +rbug_set_blend_color(struct pipe_context *_pipe, + const struct pipe_blend_color *blend_color) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->set_blend_color(pipe, + blend_color); +} + +static void +rbug_set_stencil_ref(struct pipe_context *_pipe, + const struct pipe_stencil_ref *stencil_ref) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->set_stencil_ref(pipe, + stencil_ref); +} + +static void +rbug_set_clip_state(struct pipe_context *_pipe, + const struct pipe_clip_state *clip) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->set_clip_state(pipe, + clip); +} + +static void +rbug_set_constant_buffer(struct pipe_context *_pipe, + uint shader, + uint index, + struct pipe_resource *_resource) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + struct pipe_resource *unwrapped_resource; + struct pipe_resource *resource = NULL; + + /* XXX hmm? unwrap the input state */ + if (_resource) { + unwrapped_resource = rbug_resource_unwrap(_resource); + resource = unwrapped_resource; + } + + pipe->set_constant_buffer(pipe, + shader, + index, + resource); +} + +static void +rbug_set_framebuffer_state(struct pipe_context *_pipe, + const struct pipe_framebuffer_state *_state) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + struct pipe_framebuffer_state unwrapped_state; + struct pipe_framebuffer_state *state = NULL; + unsigned i; + + rb_pipe->curr.nr_cbufs = 0; + memset(rb_pipe->curr.cbufs, 0, sizeof(rb_pipe->curr.cbufs)); + + /* unwrap the input state */ + if (_state) { + memcpy(&unwrapped_state, _state, sizeof(unwrapped_state)); + + rb_pipe->curr.nr_cbufs = _state->nr_cbufs; + for(i = 0; i < _state->nr_cbufs; i++) { + unwrapped_state.cbufs[i] = rbug_surface_unwrap(_state->cbufs[i]); + if (_state->cbufs[i]) + rb_pipe->curr.cbufs[i] = rbug_resource(_state->cbufs[i]->texture); + } + unwrapped_state.zsbuf = rbug_surface_unwrap(_state->zsbuf); + state = &unwrapped_state; + } + + pipe->set_framebuffer_state(pipe, + state); +} + +static void +rbug_set_polygon_stipple(struct pipe_context *_pipe, + const struct pipe_poly_stipple *poly_stipple) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->set_polygon_stipple(pipe, + poly_stipple); +} + +static void +rbug_set_scissor_state(struct pipe_context *_pipe, + const struct pipe_scissor_state *scissor) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->set_scissor_state(pipe, + scissor); +} + +static void +rbug_set_viewport_state(struct pipe_context *_pipe, + const struct pipe_viewport_state *viewport) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->set_viewport_state(pipe, + viewport); +} + +static void +rbug_set_fragment_sampler_views(struct pipe_context *_pipe, + unsigned num, + struct pipe_sampler_view **_views) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view **views = NULL; + unsigned i; + + rb_pipe->curr.num_fs_views = 0; + memset(rb_pipe->curr.fs_views, 0, sizeof(rb_pipe->curr.fs_views)); + memset(rb_pipe->curr.fs_texs, 0, sizeof(rb_pipe->curr.fs_texs)); + memset(unwrapped_views, 0, sizeof(unwrapped_views)); + + if (_views) { + rb_pipe->curr.num_fs_views = num; + for (i = 0; i < num; i++) { + rb_pipe->curr.fs_views[i] = rbug_sampler_view(_views[i]); + rb_pipe->curr.fs_texs[i] = rbug_resource(_views[i] ? _views[i]->texture : NULL); + unwrapped_views[i] = rbug_sampler_view_unwrap(_views[i]); + } + views = unwrapped_views; + } + + pipe->set_fragment_sampler_views(pipe, num, views); +} + +static void +rbug_set_vertex_sampler_views(struct pipe_context *_pipe, + unsigned num, + struct pipe_sampler_view **_views) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + struct pipe_sampler_view *unwrapped_views[PIPE_MAX_VERTEX_SAMPLERS]; + struct pipe_sampler_view **views = NULL; + unsigned i; + + rb_pipe->curr.num_vs_views = 0; + memset(rb_pipe->curr.vs_views, 0, sizeof(rb_pipe->curr.vs_views)); + memset(rb_pipe->curr.vs_texs, 0, sizeof(rb_pipe->curr.vs_texs)); + memset(unwrapped_views, 0, sizeof(unwrapped_views)); + + if (_views) { + rb_pipe->curr.num_vs_views = num; + for (i = 0; i < num; i++) { + rb_pipe->curr.vs_views[i] = rbug_sampler_view(_views[i]); + rb_pipe->curr.vs_texs[i] = rbug_resource(_views[i]->texture); + unwrapped_views[i] = rbug_sampler_view_unwrap(_views[i]); + } + views = unwrapped_views; + } + + pipe->set_vertex_sampler_views(pipe, num, views); +} + +static void +rbug_set_vertex_buffers(struct pipe_context *_pipe, + unsigned num_buffers, + const struct pipe_vertex_buffer *_buffers) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + struct pipe_vertex_buffer unwrapped_buffers[PIPE_MAX_SHADER_INPUTS]; + struct pipe_vertex_buffer *buffers = NULL; + unsigned i; + + if (num_buffers) { + memcpy(unwrapped_buffers, _buffers, num_buffers * sizeof(*_buffers)); + for (i = 0; i < num_buffers; i++) + unwrapped_buffers[i].buffer = rbug_resource_unwrap(_buffers[i].buffer); + buffers = unwrapped_buffers; + } + + pipe->set_vertex_buffers(pipe, + num_buffers, + buffers); +} +static void +rbug_surface_copy(struct pipe_context *_pipe, + struct pipe_surface *_dst, + unsigned dstx, + unsigned dsty, + struct pipe_surface *_src, + unsigned srcx, + unsigned srcy, + unsigned width, + unsigned height) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct rbug_surface *rb_surface_dst = rbug_surface(_dst); + struct rbug_surface *rb_surface_src = rbug_surface(_src); + struct pipe_context *pipe = rb_pipe->pipe; + struct pipe_surface *dst = rb_surface_dst->surface; + struct pipe_surface *src = rb_surface_src->surface; + + pipe->surface_copy(pipe, + dst, + dstx, + dsty, + src, + srcx, + srcy, + width, + height); +} + +static void +rbug_surface_fill(struct pipe_context *_pipe, + struct pipe_surface *_dst, + unsigned dstx, + unsigned dsty, + unsigned width, + unsigned height, + unsigned value) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct rbug_surface *rb_surface_dst = rbug_surface(_dst); + struct pipe_context *pipe = rb_pipe->pipe; + struct pipe_surface *dst = rb_surface_dst->surface; + + pipe->surface_fill(pipe, + dst, + dstx, + dsty, + width, + height, + value); +} + +static void +rbug_clear(struct pipe_context *_pipe, + unsigned buffers, + const float *rgba, + double depth, + unsigned stencil) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->clear(pipe, + buffers, + rgba, + depth, + stencil); +} + +static void +rbug_flush(struct pipe_context *_pipe, + unsigned flags, + struct pipe_fence_handle **fence) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct pipe_context *pipe = rb_pipe->pipe; + + pipe->flush(pipe, + flags, + fence); +} + +static unsigned int +rbug_is_resource_referenced(struct pipe_context *_pipe, + struct pipe_resource *_resource, + unsigned face, + unsigned level) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct rbug_resource *rb_resource = rbug_resource(_resource); + struct pipe_context *pipe = rb_pipe->pipe; + struct pipe_resource *resource = rb_resource->resource; + + return pipe->is_resource_referenced(pipe, + resource, + face, + level); +} + +static struct pipe_sampler_view * +rbug_context_create_sampler_view(struct pipe_context *_pipe, + struct pipe_resource *_resource, + const struct pipe_sampler_view *templ) +{ + struct rbug_context *rb_pipe = rbug_context(_pipe); + struct rbug_resource *rb_resource = rbug_resource(_resource); + struct pipe_context *pipe = rb_pipe->pipe; + struct pipe_resource *resource = rb_resource->resource; + struct pipe_sampler_view *result; + + result = pipe->create_sampler_view(pipe, + resource, + templ); + + if (result) + return rbug_sampler_view_create(rb_pipe, rb_resource, result); + return NULL; +} + +static void +rbug_context_sampler_view_destroy(struct pipe_context *_pipe, + struct pipe_sampler_view *_view) +{ + rbug_sampler_view_destroy(rbug_context(_pipe), + rbug_sampler_view(_view)); +} + +static struct pipe_transfer * +rbug_context_get_transfer(struct pipe_context *_context, + struct pipe_resource *_resource, + struct pipe_subresource sr, + unsigned usage, + const struct pipe_box *box) +{ + struct rbug_context *rb_pipe = rbug_context(_context); + struct rbug_resource *rb_resource = rbug_resource(_resource); + struct pipe_context *context = rb_pipe->pipe; + struct pipe_resource *resource = rb_resource->resource; + struct pipe_transfer *result; + + result = context->get_transfer(context, + resource, + sr, + usage, + box); + + if (result) + return rbug_transfer_create(rb_pipe, rb_resource, result); + return NULL; +} + +static void +rbug_context_transfer_destroy(struct pipe_context *_pipe, + struct pipe_transfer *_transfer) +{ + rbug_transfer_destroy(rbug_context(_pipe), + rbug_transfer(_transfer)); +} + +static void * +rbug_context_transfer_map(struct pipe_context *_context, + struct pipe_transfer *_transfer) +{ + struct rbug_context *rb_pipe = rbug_context(_context); + struct rbug_transfer *rb_transfer = rbug_transfer(_transfer); + struct pipe_context *context = rb_pipe->pipe; + struct pipe_transfer *transfer = rb_transfer->transfer; + + return context->transfer_map(context, + transfer); +} + + + +static void +rbug_context_transfer_flush_region(struct pipe_context *_context, + struct pipe_transfer *_transfer, + const struct pipe_box *box) +{ + struct rbug_context *rb_pipe = rbug_context(_context); + struct rbug_transfer *rb_transfer = rbug_transfer(_transfer); + struct pipe_context *context = rb_pipe->pipe; + struct pipe_transfer *transfer = rb_transfer->transfer; + + context->transfer_flush_region(context, + transfer, + box); +} + + +static void +rbug_context_transfer_unmap(struct pipe_context *_context, + struct pipe_transfer *_transfer) +{ + struct rbug_context *rb_pipe = rbug_context(_context); + struct rbug_transfer *rb_transfer = rbug_transfer(_transfer); + struct pipe_context *context = rb_pipe->pipe; + struct pipe_transfer *transfer = rb_transfer->transfer; + + context->transfer_unmap(context, + transfer); +} + + +static void +rbug_context_transfer_inline_write(struct pipe_context *_context, + struct pipe_resource *_resource, + struct pipe_subresource sr, + unsigned usage, + const struct pipe_box *box, + const void *data, + unsigned stride, + unsigned slice_stride) +{ + struct rbug_context *rb_pipe = rbug_context(_context); + struct rbug_resource *rb_resource = rbug_resource(_resource); + struct pipe_context *context = rb_pipe->pipe; + struct pipe_resource *resource = rb_resource->resource; + + context->transfer_inline_write(context, + resource, + sr, + usage, + box, + data, + stride, + slice_stride); +} + + +struct pipe_context * +rbug_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) +{ + struct rbug_context *rb_pipe; + struct rbug_screen *rb_screen = rbug_screen(_screen); + + if (!rb_screen) + return NULL; + + rb_pipe = CALLOC_STRUCT(rbug_context); + if (!rb_pipe) + return NULL; + + pipe_mutex_init(rb_pipe->draw_mutex); + pipe_condvar_init(rb_pipe->draw_cond); + pipe_mutex_init(rb_pipe->call_mutex); + pipe_mutex_init(rb_pipe->list_mutex); + make_empty_list(&rb_pipe->shaders); + + rb_pipe->base.winsys = NULL; + rb_pipe->base.screen = _screen; + rb_pipe->base.priv = pipe->priv; /* expose wrapped data */ + rb_pipe->base.draw = NULL; + + rb_pipe->base.destroy = rbug_destroy; + rb_pipe->base.draw_arrays = rbug_draw_arrays; + rb_pipe->base.draw_elements = rbug_draw_elements; + rb_pipe->base.draw_range_elements = rbug_draw_range_elements; + rb_pipe->base.create_query = rbug_create_query; + rb_pipe->base.destroy_query = rbug_destroy_query; + rb_pipe->base.begin_query = rbug_begin_query; + rb_pipe->base.end_query = rbug_end_query; + rb_pipe->base.get_query_result = rbug_get_query_result; + rb_pipe->base.create_blend_state = rbug_create_blend_state; + rb_pipe->base.bind_blend_state = rbug_bind_blend_state; + rb_pipe->base.delete_blend_state = rbug_delete_blend_state; + rb_pipe->base.create_sampler_state = rbug_create_sampler_state; + rb_pipe->base.bind_fragment_sampler_states = rbug_bind_fragment_sampler_states; + rb_pipe->base.bind_vertex_sampler_states = rbug_bind_vertex_sampler_states; + rb_pipe->base.delete_sampler_state = rbug_delete_sampler_state; + rb_pipe->base.create_rasterizer_state = rbug_create_rasterizer_state; + rb_pipe->base.bind_rasterizer_state = rbug_bind_rasterizer_state; + rb_pipe->base.delete_rasterizer_state = rbug_delete_rasterizer_state; + rb_pipe->base.create_depth_stencil_alpha_state = rbug_create_depth_stencil_alpha_state; + rb_pipe->base.bind_depth_stencil_alpha_state = rbug_bind_depth_stencil_alpha_state; + rb_pipe->base.delete_depth_stencil_alpha_state = rbug_delete_depth_stencil_alpha_state; + rb_pipe->base.create_fs_state = rbug_create_fs_state; + rb_pipe->base.bind_fs_state = rbug_bind_fs_state; + rb_pipe->base.delete_fs_state = rbug_delete_fs_state; + rb_pipe->base.create_vs_state = rbug_create_vs_state; + rb_pipe->base.bind_vs_state = rbug_bind_vs_state; + rb_pipe->base.delete_vs_state = rbug_delete_vs_state; + rb_pipe->base.create_gs_state = rbug_create_gs_state; + rb_pipe->base.bind_gs_state = rbug_bind_gs_state; + rb_pipe->base.delete_gs_state = rbug_delete_gs_state; + rb_pipe->base.create_vertex_elements_state = rbug_create_vertex_elements_state; + rb_pipe->base.bind_vertex_elements_state = rbug_bind_vertex_elements_state; + rb_pipe->base.delete_vertex_elements_state = rbug_delete_vertex_elements_state; + rb_pipe->base.set_blend_color = rbug_set_blend_color; + rb_pipe->base.set_stencil_ref = rbug_set_stencil_ref; + rb_pipe->base.set_clip_state = rbug_set_clip_state; + rb_pipe->base.set_constant_buffer = rbug_set_constant_buffer; + rb_pipe->base.set_framebuffer_state = rbug_set_framebuffer_state; + rb_pipe->base.set_polygon_stipple = rbug_set_polygon_stipple; + rb_pipe->base.set_scissor_state = rbug_set_scissor_state; + rb_pipe->base.set_viewport_state = rbug_set_viewport_state; + rb_pipe->base.set_fragment_sampler_views = rbug_set_fragment_sampler_views; + rb_pipe->base.set_vertex_sampler_views = rbug_set_vertex_sampler_views; + rb_pipe->base.set_vertex_buffers = rbug_set_vertex_buffers; + rb_pipe->base.surface_copy = rbug_surface_copy; + rb_pipe->base.surface_fill = rbug_surface_fill; + rb_pipe->base.clear = rbug_clear; + rb_pipe->base.flush = rbug_flush; + rb_pipe->base.is_resource_referenced = rbug_is_resource_referenced; + rb_pipe->base.create_sampler_view = rbug_context_create_sampler_view; + rb_pipe->base.sampler_view_destroy = rbug_context_sampler_view_destroy; + rb_pipe->base.get_transfer = rbug_context_get_transfer; + rb_pipe->base.transfer_destroy = rbug_context_transfer_destroy; + rb_pipe->base.transfer_map = rbug_context_transfer_map; + rb_pipe->base.transfer_unmap = rbug_context_transfer_unmap; + rb_pipe->base.transfer_flush_region = rbug_context_transfer_flush_region; + rb_pipe->base.transfer_inline_write = rbug_context_transfer_inline_write; + + rb_pipe->pipe = pipe; + + rbug_screen_add_to_list(rb_screen, contexts, rb_pipe); + + return &rb_pipe->base; +} diff --git a/src/gallium/drivers/rbug/rbug_context.h b/src/gallium/drivers/rbug/rbug_context.h new file mode 100644 index 00000000000..80c803da83f --- /dev/null +++ b/src/gallium/drivers/rbug/rbug_context.h @@ -0,0 +1,111 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef RBUG_CONTEXT_H +#define RBUG_CONTEXT_H + +#include "pipe/p_state.h" +#include "pipe/p_context.h" + +#include "rbug_screen.h" + + +struct rbug_context { + struct pipe_context base; /**< base class */ + + struct pipe_context *pipe; + + struct rbug_list list; + + /* call locking */ + pipe_mutex call_mutex; + + /* current state */ + struct { + struct rbug_shader *fs; + struct rbug_shader *vs; + struct rbug_shader *gs; + + struct rbug_sampler_view *fs_views[PIPE_MAX_SAMPLERS]; + struct rbug_resource *fs_texs[PIPE_MAX_SAMPLERS]; + unsigned num_fs_views; + + struct rbug_sampler_view *vs_views[PIPE_MAX_VERTEX_SAMPLERS]; + struct rbug_resource *vs_texs[PIPE_MAX_VERTEX_SAMPLERS]; + unsigned num_vs_views; + + unsigned nr_cbufs; + struct rbug_resource *cbufs[PIPE_MAX_COLOR_BUFS]; + struct rbug_resource *zsbuf; + } curr; + + /* draw locking */ + pipe_mutex draw_mutex; + pipe_condvar draw_cond; + unsigned draw_num_rules; + int draw_blocker; + int draw_blocked; + + struct { + struct rbug_shader *fs; + struct rbug_shader *vs; + + struct rbug_resource *texture; + struct rbug_resource *surf; + + int blocker; + } draw_rule; + + /* list of state objects */ + pipe_mutex list_mutex; + unsigned num_shaders; + struct rbug_list shaders; +}; + +static INLINE struct rbug_context * +rbug_context(struct pipe_context *pipe) +{ + return (struct rbug_context *)pipe; +} + + +/********************************************************** + * rbug_context.c + */ + +struct pipe_context * +rbug_context_create(struct pipe_screen *screen, struct pipe_context *pipe); + + +/********************************************************** + * rbug_core.c + */ + +void rbug_notify_draw_blocked(struct rbug_context *rb_context); + + +#endif /* RBUG_CONTEXT_H */ diff --git a/src/gallium/drivers/rbug/rbug_core.c b/src/gallium/drivers/rbug/rbug_core.c new file mode 100644 index 00000000000..f1aab3869b5 --- /dev/null +++ b/src/gallium/drivers/rbug/rbug_core.c @@ -0,0 +1,890 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include "os/os_thread.h" +#include "util/u_format.h" +#include "util/u_string.h" +#include "util/u_inlines.h" +#include "util/u_memory.h" +#include "util/u_simple_list.h" +#include "util/u_network.h" +#include "os/os_time.h" + +#include "tgsi/tgsi_parse.h" + +#include "rbug_context.h" +#include "rbug_objects.h" + +#include "rbug/rbug.h" + +#include <errno.h> + +#define U642VOID(x) ((void *)(unsigned long)(x)) +#define VOID2U64(x) ((uint64_t)(unsigned long)(x)) + +#define container_of(ptr, type, field) \ + (type*)((char*)ptr - offsetof(type, field)) + +struct rbug_rbug +{ + struct rbug_screen *rb_screen; + struct rbug_connection *con; + pipe_thread thread; + boolean running; +}; + +PIPE_THREAD_ROUTINE(rbug_thread, void_rbug); + + +/********************************************************** + * Helper functions + */ + + +static struct rbug_context * +rbug_get_context_locked(struct rbug_screen *rb_screen, rbug_context_t ctx) +{ + struct rbug_context *rb_context = NULL; + struct rbug_list *ptr; + + foreach(ptr, &rb_screen->contexts) { + rb_context = container_of(ptr, struct rbug_context, list); + if (ctx == VOID2U64(rb_context)) + break; + rb_context = NULL; + } + + return rb_context; +} + +static struct rbug_shader * +rbug_get_shader_locked(struct rbug_context *rb_context, rbug_shader_t shdr) +{ + struct rbug_shader *tr_shdr = NULL; + struct rbug_list *ptr; + + foreach(ptr, &rb_context->shaders) { + tr_shdr = container_of(ptr, struct rbug_shader, list); + if (shdr == VOID2U64(tr_shdr)) + break; + tr_shdr = NULL; + } + + return tr_shdr; +} + +static void * +rbug_shader_create_locked(struct pipe_context *pipe, + struct rbug_shader *rb_shader, + struct tgsi_token *tokens) +{ + void *state = NULL; + struct pipe_shader_state pss = { 0 }; + pss.tokens = tokens; + + switch(rb_shader->type) { + case RBUG_SHADER_FRAGMENT: + state = pipe->create_fs_state(pipe, &pss); + break; + case RBUG_SHADER_VERTEX: + state = pipe->create_vs_state(pipe, &pss); + break; + case RBUG_SHADER_GEOM: + state = pipe->create_gs_state(pipe, &pss); + break; + default: + assert(0); + break; + } + + return state; +} + +static void +rbug_shader_bind_locked(struct pipe_context *pipe, + struct rbug_shader *rb_shader, + void *state) +{ + switch(rb_shader->type) { + case RBUG_SHADER_FRAGMENT: + pipe->bind_fs_state(pipe, state); + break; + case RBUG_SHADER_VERTEX: + pipe->bind_vs_state(pipe, state); + break; + case RBUG_SHADER_GEOM: + pipe->bind_gs_state(pipe, state); + break; + default: + assert(0); + break; + } +} + +static void +rbug_shader_delete_locked(struct pipe_context *pipe, + struct rbug_shader *rb_shader, + void *state) +{ + switch(rb_shader->type) { + case RBUG_SHADER_FRAGMENT: + pipe->delete_fs_state(pipe, state); + break; + case RBUG_SHADER_VERTEX: + pipe->delete_vs_state(pipe, state); + break; + case RBUG_SHADER_GEOM: + pipe->delete_gs_state(pipe, state); + break; + default: + assert(0); + break; + } +} + +/************************************************ + * Request handler functions + */ + + +static int +rbug_texture_list(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_screen *rb_screen = tr_rbug->rb_screen; + struct rbug_resource *tr_tex = NULL; + struct rbug_list *ptr; + rbug_texture_t *texs; + int i = 0; + + pipe_mutex_lock(rb_screen->list_mutex); + texs = MALLOC(rb_screen->num_resources * sizeof(rbug_texture_t)); + foreach(ptr, &rb_screen->resources) { + tr_tex = container_of(ptr, struct rbug_resource, list); + texs[i++] = VOID2U64(tr_tex); + } + pipe_mutex_unlock(rb_screen->list_mutex); + + rbug_send_texture_list_reply(tr_rbug->con, serial, texs, i, NULL); + FREE(texs); + + return 0; +} + +static int +rbug_texture_info(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_screen *rb_screen = tr_rbug->rb_screen; + struct rbug_resource *tr_tex = NULL; + struct rbug_proto_texture_info *gpti = (struct rbug_proto_texture_info *)header; + struct rbug_list *ptr; + struct pipe_resource *t; + + pipe_mutex_lock(rb_screen->list_mutex); + foreach(ptr, &rb_screen->resources) { + tr_tex = container_of(ptr, struct rbug_resource, list); + if (gpti->texture == VOID2U64(tr_tex)) + break; + tr_tex = NULL; + } + + if (!tr_tex) { + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + t = tr_tex->resource; + rbug_send_texture_info_reply(tr_rbug->con, serial, + t->target, t->format, + &t->width0, 1, + &t->height0, 1, + &t->depth0, 1, + util_format_get_blockwidth(t->format), + util_format_get_blockheight(t->format), + util_format_get_blocksize(t->format), + t->last_level, + t->nr_samples, + t->bind, + NULL); + + pipe_mutex_unlock(rb_screen->list_mutex); + + return 0; +} + +static int +rbug_texture_read(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_texture_read *gptr = (struct rbug_proto_texture_read *)header; + + struct rbug_screen *rb_screen = tr_rbug->rb_screen; + struct rbug_resource *tr_tex = NULL; + struct rbug_list *ptr; + + struct pipe_context *context = rb_screen->private_context; + struct pipe_resource *tex; + struct pipe_transfer *t; + + void *map; + + pipe_mutex_lock(rb_screen->list_mutex); + foreach(ptr, &rb_screen->resources) { + tr_tex = container_of(ptr, struct rbug_resource, list); + if (gptr->texture == VOID2U64(tr_tex)) + break; + tr_tex = NULL; + } + + if (!tr_tex) { + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + tex = tr_tex->resource; + t = pipe_get_transfer(context, tex, + gptr->face, gptr->level, gptr->zslice, + PIPE_TRANSFER_READ, + gptr->x, gptr->y, gptr->w, gptr->h); + + map = context->transfer_map(context, t); + + rbug_send_texture_read_reply(tr_rbug->con, serial, + t->resource->format, + util_format_get_blockwidth(t->resource->format), + util_format_get_blockheight(t->resource->format), + util_format_get_blocksize(t->resource->format), + (uint8_t*)map, + t->stride * util_format_get_nblocksy(t->resource->format, + t->box.height), + t->stride, + NULL); + + context->transfer_unmap(context, t); + context->transfer_destroy(context, t); + + pipe_mutex_unlock(rb_screen->list_mutex); + + return 0; +} + +static int +rbug_context_list(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_screen *rb_screen = tr_rbug->rb_screen; + struct rbug_list *ptr; + struct rbug_context *rb_context = NULL; + rbug_context_t *ctxs; + int i = 0; + + pipe_mutex_lock(rb_screen->list_mutex); + ctxs = MALLOC(rb_screen->num_contexts * sizeof(rbug_context_t)); + foreach(ptr, &rb_screen->contexts) { + rb_context = container_of(ptr, struct rbug_context, list); + ctxs[i++] = VOID2U64(rb_context); + } + pipe_mutex_unlock(rb_screen->list_mutex); + + rbug_send_context_list_reply(tr_rbug->con, serial, ctxs, i, NULL); + FREE(ctxs); + + return 0; +} + +static int +rbug_context_info(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_context_info *info = (struct rbug_proto_context_info *)header; + + struct rbug_screen *rb_screen = tr_rbug->rb_screen; + struct rbug_context *rb_context = NULL; + rbug_texture_t cbufs[PIPE_MAX_COLOR_BUFS]; + rbug_texture_t texs[PIPE_MAX_SAMPLERS]; + int i; + + pipe_mutex_lock(rb_screen->list_mutex); + rb_context = rbug_get_context_locked(rb_screen, info->context); + + if (!rb_context) { + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + /* protect the pipe context */ + pipe_mutex_lock(rb_context->draw_mutex); + pipe_mutex_lock(rb_context->call_mutex); + + for (i = 0; i < rb_context->curr.nr_cbufs; i++) + cbufs[i] = VOID2U64(rb_context->curr.cbufs[i]); + + for (i = 0; i < rb_context->curr.num_fs_views; i++) + texs[i] = VOID2U64(rb_context->curr.fs_texs[i]); + + rbug_send_context_info_reply(tr_rbug->con, serial, + VOID2U64(rb_context->curr.vs), VOID2U64(rb_context->curr.fs), + texs, rb_context->curr.num_fs_views, + cbufs, rb_context->curr.nr_cbufs, + VOID2U64(rb_context->curr.zsbuf), + rb_context->draw_blocker, rb_context->draw_blocked, NULL); + + pipe_mutex_unlock(rb_context->call_mutex); + pipe_mutex_unlock(rb_context->draw_mutex); + pipe_mutex_unlock(rb_screen->list_mutex); + + return 0; +} + +static int +rbug_context_draw_block(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_context_draw_block *block = (struct rbug_proto_context_draw_block *)header; + + struct rbug_screen *rb_screen = tr_rbug->rb_screen; + struct rbug_context *rb_context = NULL; + + pipe_mutex_lock(rb_screen->list_mutex); + rb_context = rbug_get_context_locked(rb_screen, block->context); + + if (!rb_context) { + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(rb_context->draw_mutex); + rb_context->draw_blocker |= block->block; + pipe_mutex_unlock(rb_context->draw_mutex); + + pipe_mutex_unlock(rb_screen->list_mutex); + + return 0; +} + +static int +rbug_context_draw_step(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_context_draw_step *step = (struct rbug_proto_context_draw_step *)header; + + struct rbug_screen *rb_screen = tr_rbug->rb_screen; + struct rbug_context *rb_context = NULL; + + pipe_mutex_lock(rb_screen->list_mutex); + rb_context = rbug_get_context_locked(rb_screen, step->context); + + if (!rb_context) { + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(rb_context->draw_mutex); + if (rb_context->draw_blocked & RBUG_BLOCK_RULE) { + if (step->step & RBUG_BLOCK_RULE) + rb_context->draw_blocked &= ~RBUG_BLOCK_MASK; + } else { + rb_context->draw_blocked &= ~step->step; + } + pipe_mutex_unlock(rb_context->draw_mutex); + +#ifdef PIPE_THREAD_HAVE_CONDVAR + pipe_condvar_broadcast(rb_context->draw_cond); +#endif + + pipe_mutex_unlock(rb_screen->list_mutex); + + return 0; +} + +static int +rbug_context_draw_unblock(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_context_draw_unblock *unblock = (struct rbug_proto_context_draw_unblock *)header; + + struct rbug_screen *rb_screen = tr_rbug->rb_screen; + struct rbug_context *rb_context = NULL; + + pipe_mutex_lock(rb_screen->list_mutex); + rb_context = rbug_get_context_locked(rb_screen, unblock->context); + + if (!rb_context) { + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(rb_context->draw_mutex); + if (rb_context->draw_blocked & RBUG_BLOCK_RULE) { + if (unblock->unblock & RBUG_BLOCK_RULE) + rb_context->draw_blocked &= ~RBUG_BLOCK_MASK; + } else { + rb_context->draw_blocked &= ~unblock->unblock; + } + rb_context->draw_blocker &= ~unblock->unblock; + pipe_mutex_unlock(rb_context->draw_mutex); + +#ifdef PIPE_THREAD_HAVE_CONDVAR + pipe_condvar_broadcast(rb_context->draw_cond); +#endif + + pipe_mutex_unlock(rb_screen->list_mutex); + + return 0; +} + +static int +rbug_context_draw_rule(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_context_draw_rule *rule = (struct rbug_proto_context_draw_rule *)header; + + struct rbug_screen *rb_screen = tr_rbug->rb_screen; + struct rbug_context *rb_context = NULL; + + pipe_mutex_lock(rb_screen->list_mutex); + rb_context = rbug_get_context_locked(rb_screen, rule->context); + + if (!rb_context) { + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(rb_context->draw_mutex); + rb_context->draw_rule.vs = U642VOID(rule->vertex); + rb_context->draw_rule.fs = U642VOID(rule->fragment); + rb_context->draw_rule.texture = U642VOID(rule->texture); + rb_context->draw_rule.surf = U642VOID(rule->surface); + rb_context->draw_rule.blocker = rule->block; + rb_context->draw_blocker |= RBUG_BLOCK_RULE; + pipe_mutex_unlock(rb_context->draw_mutex); + +#ifdef PIPE_THREAD_HAVE_CONDVAR + pipe_condvar_broadcast(rb_context->draw_cond); +#endif + + pipe_mutex_unlock(rb_screen->list_mutex); + + return 0; +} + +static int +rbug_context_flush(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_context_flush *flush = (struct rbug_proto_context_flush *)header; + + struct rbug_screen *rb_screen = tr_rbug->rb_screen; + struct rbug_context *rb_context = NULL; + + pipe_mutex_lock(rb_screen->list_mutex); + rb_context = rbug_get_context_locked(rb_screen, flush->context); + + if (!rb_context) { + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + /* protect the pipe context */ + pipe_mutex_lock(rb_context->call_mutex); + + rb_context->pipe->flush(rb_context->pipe, flush->flags, NULL); + + pipe_mutex_unlock(rb_context->call_mutex); + pipe_mutex_unlock(rb_screen->list_mutex); + + return 0; +} + +static int +rbug_shader_list(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_shader_list *list = (struct rbug_proto_shader_list *)header; + + struct rbug_screen *rb_screen = tr_rbug->rb_screen; + struct rbug_context *rb_context = NULL; + struct rbug_shader *tr_shdr = NULL; + struct rbug_list *ptr; + rbug_shader_t *shdrs; + int i = 0; + + pipe_mutex_lock(rb_screen->list_mutex); + rb_context = rbug_get_context_locked(rb_screen, list->context); + + if (!rb_context) { + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(rb_context->list_mutex); + shdrs = MALLOC(rb_context->num_shaders * sizeof(rbug_shader_t)); + foreach(ptr, &rb_context->shaders) { + tr_shdr = container_of(ptr, struct rbug_shader, list); + shdrs[i++] = VOID2U64(tr_shdr); + } + + pipe_mutex_unlock(rb_context->list_mutex); + pipe_mutex_unlock(rb_screen->list_mutex); + + rbug_send_shader_list_reply(tr_rbug->con, serial, shdrs, i, NULL); + FREE(shdrs); + + return 0; +} + +static int +rbug_shader_info(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + struct rbug_proto_shader_info *info = (struct rbug_proto_shader_info *)header; + + struct rbug_screen *rb_screen = tr_rbug->rb_screen; + struct rbug_context *rb_context = NULL; + struct rbug_shader *tr_shdr = NULL; + unsigned original_len; + unsigned replaced_len; + + pipe_mutex_lock(rb_screen->list_mutex); + rb_context = rbug_get_context_locked(rb_screen, info->context); + + if (!rb_context) { + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(rb_context->list_mutex); + + tr_shdr = rbug_get_shader_locked(rb_context, info->shader); + + if (!tr_shdr) { + pipe_mutex_unlock(rb_context->list_mutex); + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + /* just in case */ + assert(sizeof(struct tgsi_token) == 4); + + original_len = tgsi_num_tokens(tr_shdr->tokens); + if (tr_shdr->replaced_tokens) + replaced_len = tgsi_num_tokens(tr_shdr->replaced_tokens); + else + replaced_len = 0; + + rbug_send_shader_info_reply(tr_rbug->con, serial, + (uint32_t*)tr_shdr->tokens, original_len, + (uint32_t*)tr_shdr->replaced_tokens, replaced_len, + tr_shdr->disabled, + NULL); + + pipe_mutex_unlock(rb_context->list_mutex); + pipe_mutex_unlock(rb_screen->list_mutex); + + return 0; +} + +static int +rbug_shader_disable(struct rbug_rbug *tr_rbug, struct rbug_header *header) +{ + struct rbug_proto_shader_disable *dis = (struct rbug_proto_shader_disable *)header; + + struct rbug_screen *rb_screen = tr_rbug->rb_screen; + struct rbug_context *rb_context = NULL; + struct rbug_shader *tr_shdr = NULL; + + pipe_mutex_lock(rb_screen->list_mutex); + rb_context = rbug_get_context_locked(rb_screen, dis->context); + + if (!rb_context) { + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(rb_context->list_mutex); + + tr_shdr = rbug_get_shader_locked(rb_context, dis->shader); + + if (!tr_shdr) { + pipe_mutex_unlock(rb_context->list_mutex); + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + tr_shdr->disabled = dis->disable; + + pipe_mutex_unlock(rb_context->list_mutex); + pipe_mutex_unlock(rb_screen->list_mutex); + + return 0; +} + +static int +rbug_shader_replace(struct rbug_rbug *tr_rbug, struct rbug_header *header) +{ + struct rbug_proto_shader_replace *rep = (struct rbug_proto_shader_replace *)header; + + struct rbug_screen *rb_screen = tr_rbug->rb_screen; + struct rbug_context *rb_context = NULL; + struct rbug_shader *tr_shdr = NULL; + struct pipe_context *pipe = NULL; + void *state; + + pipe_mutex_lock(rb_screen->list_mutex); + rb_context = rbug_get_context_locked(rb_screen, rep->context); + + if (!rb_context) { + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + pipe_mutex_lock(rb_context->list_mutex); + + tr_shdr = rbug_get_shader_locked(rb_context, rep->shader); + + if (!tr_shdr) { + pipe_mutex_unlock(rb_context->list_mutex); + pipe_mutex_unlock(rb_screen->list_mutex); + return -ESRCH; + } + + /* protect the pipe context */ + pipe_mutex_lock(rb_context->call_mutex); + + pipe = rb_context->pipe; + + /* remove old replaced shader */ + if (tr_shdr->replaced_shader) { + /* if this shader is bound rebind the original shader */ + if (rb_context->curr.fs == tr_shdr || rb_context->curr.vs == tr_shdr) + rbug_shader_bind_locked(pipe, tr_shdr, tr_shdr->shader); + + FREE(tr_shdr->replaced_tokens); + rbug_shader_delete_locked(pipe, tr_shdr, tr_shdr->replaced_shader); + tr_shdr->replaced_shader = NULL; + tr_shdr->replaced_tokens = NULL; + } + + /* empty inputs means restore old which we did above */ + if (rep->tokens_len == 0) + goto out; + + tr_shdr->replaced_tokens = tgsi_dup_tokens((struct tgsi_token *)rep->tokens); + if (!tr_shdr->replaced_tokens) + goto err; + + state = rbug_shader_create_locked(pipe, tr_shdr, tr_shdr->replaced_tokens); + if (!state) + goto err; + + /* bind new shader if the shader is currently a bound */ + if (rb_context->curr.fs == tr_shdr || rb_context->curr.vs == tr_shdr) + rbug_shader_bind_locked(pipe, tr_shdr, state); + + /* save state */ + tr_shdr->replaced_shader = state; + +out: + pipe_mutex_unlock(rb_context->call_mutex); + pipe_mutex_unlock(rb_context->list_mutex); + pipe_mutex_unlock(rb_screen->list_mutex); + + return 0; + +err: + FREE(tr_shdr->replaced_tokens); + tr_shdr->replaced_shader = NULL; + tr_shdr->replaced_tokens = NULL; + + pipe_mutex_unlock(rb_context->call_mutex); + pipe_mutex_unlock(rb_context->list_mutex); + pipe_mutex_unlock(rb_screen->list_mutex); + return -EINVAL; +} + +static boolean +rbug_header(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) +{ + int ret = 0; + + switch(header->opcode) { + case RBUG_OP_PING: + rbug_send_ping_reply(tr_rbug->con, serial, NULL); + break; + case RBUG_OP_TEXTURE_LIST: + ret = rbug_texture_list(tr_rbug, header, serial); + break; + case RBUG_OP_TEXTURE_INFO: + ret = rbug_texture_info(tr_rbug, header, serial); + break; + case RBUG_OP_TEXTURE_READ: + ret = rbug_texture_read(tr_rbug, header, serial); + break; + case RBUG_OP_CONTEXT_LIST: + ret = rbug_context_list(tr_rbug, header, serial); + break; + case RBUG_OP_CONTEXT_INFO: + ret = rbug_context_info(tr_rbug, header, serial); + break; + case RBUG_OP_CONTEXT_DRAW_BLOCK: + ret = rbug_context_draw_block(tr_rbug, header, serial); + break; + case RBUG_OP_CONTEXT_DRAW_STEP: + ret = rbug_context_draw_step(tr_rbug, header, serial); + break; + case RBUG_OP_CONTEXT_DRAW_UNBLOCK: + ret = rbug_context_draw_unblock(tr_rbug, header, serial); + break; + case RBUG_OP_CONTEXT_DRAW_RULE: + ret = rbug_context_draw_rule(tr_rbug, header, serial); + break; + case RBUG_OP_CONTEXT_FLUSH: + ret = rbug_context_flush(tr_rbug, header, serial); + break; + case RBUG_OP_SHADER_LIST: + ret = rbug_shader_list(tr_rbug, header, serial); + break; + case RBUG_OP_SHADER_INFO: + ret = rbug_shader_info(tr_rbug, header, serial); + break; + case RBUG_OP_SHADER_DISABLE: + ret = rbug_shader_disable(tr_rbug, header); + break; + case RBUG_OP_SHADER_REPLACE: + ret = rbug_shader_replace(tr_rbug, header); + break; + default: + debug_printf("%s - unsupported opcode %u\n", __FUNCTION__, header->opcode); + ret = -ENOSYS; + break; + } + rbug_free_header(header); + + if (ret) + rbug_send_error_reply(tr_rbug->con, serial, ret, NULL); + + return TRUE; +} + +static void +rbug_con(struct rbug_rbug *tr_rbug) +{ + struct rbug_header *header; + uint32_t serial; + + debug_printf("%s - connection received\n", __FUNCTION__); + + while(tr_rbug->running) { + header = rbug_get_message(tr_rbug->con, &serial); + if (!header) + break; + + if (!rbug_header(tr_rbug, header, serial)) + break; + } + + debug_printf("%s - connection closed\n", __FUNCTION__); + + rbug_disconnect(tr_rbug->con); + tr_rbug->con = NULL; +} + +PIPE_THREAD_ROUTINE(rbug_thread, void_tr_rbug) +{ + struct rbug_rbug *tr_rbug = void_tr_rbug; + uint16_t port = 13370; + int s = -1; + int c; + + u_socket_init(); + + for (;port <= 13379 && s < 0; port++) + s = u_socket_listen_on_port(port); + + if (s < 0) { + debug_printf("rbug_rbug - failed to listen\n"); + return NULL; + } + + u_socket_block(s, false); + + debug_printf("rbug_rbug - remote debugging listening on port %u\n", --port); + + while(tr_rbug->running) { + os_time_sleep(1); + + c = u_socket_accept(s); + if (c < 0) + continue; + + u_socket_block(c, true); + tr_rbug->con = rbug_from_socket(c); + + rbug_con(tr_rbug); + + u_socket_close(c); + } + + u_socket_close(s); + + u_socket_stop(); + + return NULL; +} + +/********************************************************** + * + */ + +struct rbug_rbug * +rbug_start(struct rbug_screen *rb_screen) +{ + struct rbug_rbug *tr_rbug = CALLOC_STRUCT(rbug_rbug); + if (!tr_rbug) + return NULL; + + tr_rbug->rb_screen = rb_screen; + tr_rbug->running = TRUE; + tr_rbug->thread = pipe_thread_create(rbug_thread, tr_rbug); + + return tr_rbug; +} + +void +rbug_stop(struct rbug_rbug *tr_rbug) +{ + if (!tr_rbug) + return; + + tr_rbug->running = false; + pipe_thread_wait(tr_rbug->thread); + + FREE(tr_rbug); + + return; +} + +void +rbug_notify_draw_blocked(struct rbug_context *rb_context) +{ + struct rbug_screen *rb_screen = rbug_screen(rb_context->base.screen); + struct rbug_rbug *tr_rbug = rb_screen->rbug; + + if (tr_rbug && tr_rbug->con) + rbug_send_context_draw_blocked(tr_rbug->con, + VOID2U64(rb_context), rb_context->draw_blocked, NULL); +} diff --git a/src/gallium/drivers/rbug/rbug_objects.c b/src/gallium/drivers/rbug/rbug_objects.c new file mode 100644 index 00000000000..0979fcff957 --- /dev/null +++ b/src/gallium/drivers/rbug/rbug_objects.c @@ -0,0 +1,247 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "util/u_inlines.h" +#include "util/u_memory.h" +#include "util/u_simple_list.h" + +#include "tgsi/tgsi_parse.h" + +#include "rbug_screen.h" +#include "rbug_objects.h" +#include "rbug_context.h" + + + +struct pipe_resource * +rbug_resource_create(struct rbug_screen *rb_screen, + struct pipe_resource *resource) +{ + struct rbug_resource *rb_resource; + + if(!resource) + goto error; + + assert(resource->screen == rb_screen->screen); + + rb_resource = CALLOC_STRUCT(rbug_resource); + if(!rb_resource) + goto error; + + memcpy(&rb_resource->base, resource, sizeof(struct pipe_resource)); + + pipe_reference_init(&rb_resource->base.reference, 1); + rb_resource->base.screen = &rb_screen->base; + rb_resource->resource = resource; + + rbug_screen_add_to_list(rb_screen, resources, rb_resource); + + return &rb_resource->base; + +error: + pipe_resource_reference(&resource, NULL); + return NULL; +} + +void +rbug_resource_destroy(struct rbug_resource *rb_resource) +{ + struct rbug_screen *rb_screen = rbug_screen(rb_resource->base.screen); + rbug_screen_remove_from_list(rb_screen, resources, rb_resource); + + pipe_resource_reference(&rb_resource->resource, NULL); + FREE(rb_resource); +} + + +struct pipe_surface * +rbug_surface_create(struct rbug_resource *rb_resource, + struct pipe_surface *surface) +{ + struct rbug_surface *rb_surface; + + if(!surface) + goto error; + + assert(surface->texture == rb_resource->resource); + + rb_surface = CALLOC_STRUCT(rbug_surface); + if(!rb_surface) + goto error; + + memcpy(&rb_surface->base, surface, sizeof(struct pipe_surface)); + + pipe_reference_init(&rb_surface->base.reference, 1); + rb_surface->base.texture = NULL; + pipe_resource_reference(&rb_surface->base.texture, &rb_resource->base); + rb_surface->surface = surface; + + return &rb_surface->base; + +error: + pipe_surface_reference(&surface, NULL); + return NULL; +} + +void +rbug_surface_destroy(struct rbug_surface *rb_surface) +{ + pipe_resource_reference(&rb_surface->base.texture, NULL); + pipe_surface_reference(&rb_surface->surface, NULL); + FREE(rb_surface); +} + + +struct pipe_sampler_view * +rbug_sampler_view_create(struct rbug_context *rb_context, + struct rbug_resource *rb_resource, + struct pipe_sampler_view *view) +{ + struct rbug_sampler_view *rb_view; + + if (!view) + goto error; + + assert(view->texture == rb_resource->resource); + + rb_view = MALLOC(sizeof(struct rbug_sampler_view)); + + rb_view->base = *view; + rb_view->base.reference.count = 1; + rb_view->base.texture = NULL; + pipe_resource_reference(&rb_view->base.texture, &rb_resource->base); + rb_view->base.context = rb_context->pipe; + rb_view->sampler_view = view; + + return &rb_view->base; +error: + return NULL; +} + +void +rbug_sampler_view_destroy(struct rbug_context *rb_context, + struct rbug_sampler_view *rb_view) +{ + pipe_resource_reference(&rb_view->base.texture, NULL); + rb_context->pipe->sampler_view_destroy(rb_context->pipe, + rb_view->sampler_view); + FREE(rb_view); +} + + +struct pipe_transfer * +rbug_transfer_create(struct rbug_context *rb_context, + struct rbug_resource *rb_resource, + struct pipe_transfer *transfer) +{ + struct rbug_transfer *rb_transfer; + + if(!transfer) + goto error; + + assert(transfer->resource == rb_resource->resource); + + rb_transfer = CALLOC_STRUCT(rbug_transfer); + if(!rb_transfer) + goto error; + + memcpy(&rb_transfer->base, transfer, sizeof(struct pipe_transfer)); + + rb_transfer->base.resource = NULL; + rb_transfer->transfer = transfer; + rb_transfer->pipe = rb_context->pipe; + + pipe_resource_reference(&rb_transfer->base.resource, &rb_resource->base); + assert(rb_transfer->base.resource == &rb_resource->base); + + return &rb_transfer->base; + +error: + rb_context->pipe->transfer_destroy(rb_context->pipe, transfer); + return NULL; +} + +void +rbug_transfer_destroy(struct rbug_context *rb_context, + struct rbug_transfer *rb_transfer) +{ + pipe_resource_reference(&rb_transfer->base.resource, NULL); + rb_transfer->pipe->transfer_destroy(rb_context->pipe, + rb_transfer->transfer); + FREE(rb_transfer); +} + +void * +rbug_shader_create(struct rbug_context *rb_context, + const struct pipe_shader_state *state, + void *result, enum rbug_shader_type type) +{ + struct rbug_shader *rb_shader = CALLOC_STRUCT(rbug_shader); + + rb_shader->type = type; + rb_shader->shader = result; + rb_shader->tokens = tgsi_dup_tokens(state->tokens); + + /* works on context as well since its just a macro */ + rbug_screen_add_to_list(rb_context, shaders, rb_shader); + + return rb_shader; +} + +void +rbug_shader_destroy(struct rbug_context *rb_context, + struct rbug_shader *rb_shader) +{ + struct pipe_context *pipe = rb_context->pipe; + + /* works on context as well since its just a macro */ + rbug_screen_remove_from_list(rb_context, shaders, rb_shader); + + switch(rb_shader->type) { + case RBUG_SHADER_FRAGMENT: + if (rb_shader->replaced_shader) + pipe->delete_fs_state(pipe, rb_shader->replaced_shader); + pipe->delete_fs_state(pipe, rb_shader->shader); + break; + case RBUG_SHADER_VERTEX: + if (rb_shader->replaced_shader) + pipe->delete_vs_state(pipe, rb_shader->replaced_shader); + pipe->delete_vs_state(pipe, rb_shader->shader); + break; + case RBUG_SHADER_GEOM: + if (rb_shader->replaced_shader) + pipe->delete_gs_state(pipe, rb_shader->replaced_shader); + pipe->delete_gs_state(pipe, rb_shader->shader); + break; + default: + assert(0); + } + + FREE(rb_shader->replaced_tokens); + FREE(rb_shader->tokens); + FREE(rb_shader); +} diff --git a/src/gallium/drivers/rbug/rbug_objects.h b/src/gallium/drivers/rbug/rbug_objects.h new file mode 100644 index 00000000000..49c128d3d1a --- /dev/null +++ b/src/gallium/drivers/rbug/rbug_objects.h @@ -0,0 +1,226 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef RBUG_OBJECTS_H +#define RBUG_OBJECTS_H + + +#include "pipe/p_compiler.h" +#include "pipe/p_state.h" + +#include "rbug_screen.h" + +struct rbug_context; + + +struct rbug_resource +{ + struct pipe_resource base; + + struct pipe_resource *resource; + + struct rbug_list list; +}; + + +enum rbug_shader_type +{ + RBUG_SHADER_GEOM, + RBUG_SHADER_VERTEX, + RBUG_SHADER_FRAGMENT, +}; + +struct rbug_shader +{ + struct rbug_list list; + + void *shader; + void *tokens; + void *replaced_shader; + void *replaced_tokens; + + enum rbug_shader_type type; + boolean disabled; +}; + + +struct rbug_sampler_view +{ + struct pipe_sampler_view base; + + struct pipe_sampler_view *sampler_view; +}; + + +struct rbug_surface +{ + struct pipe_surface base; + + struct pipe_surface *surface; +}; + + +struct rbug_transfer +{ + struct pipe_transfer base; + + struct pipe_context *pipe; + struct pipe_transfer *transfer; +}; + + +static INLINE struct rbug_resource * +rbug_resource(struct pipe_resource *_resource) +{ + if (!_resource) + return NULL; + (void)rbug_screen(_resource->screen); + return (struct rbug_resource *)_resource; +} + +static INLINE struct rbug_sampler_view * +rbug_sampler_view(struct pipe_sampler_view *_sampler_view) +{ + if (!_sampler_view) + return NULL; + (void)rbug_resource(_sampler_view->texture); + return (struct rbug_sampler_view *)_sampler_view; +} + +static INLINE struct rbug_surface * +rbug_surface(struct pipe_surface *_surface) +{ + if (!_surface) + return NULL; + (void)rbug_resource(_surface->texture); + return (struct rbug_surface *)_surface; +} + +static INLINE struct rbug_transfer * +rbug_transfer(struct pipe_transfer *_transfer) +{ + if (!_transfer) + return NULL; + (void)rbug_resource(_transfer->resource); + return (struct rbug_transfer *)_transfer; +} + +static INLINE struct rbug_shader * +rbug_shader(void *_state) +{ + if (!_state) + return NULL; + return (struct rbug_shader *)_state; +} + +static INLINE struct pipe_resource * +rbug_resource_unwrap(struct pipe_resource *_resource) +{ + if (!_resource) + return NULL; + return rbug_resource(_resource)->resource; +} + +static INLINE struct pipe_sampler_view * +rbug_sampler_view_unwrap(struct pipe_sampler_view *_sampler_view) +{ + if (!_sampler_view) + return NULL; + return rbug_sampler_view(_sampler_view)->sampler_view; +} + +static INLINE struct pipe_surface * +rbug_surface_unwrap(struct pipe_surface *_surface) +{ + if (!_surface) + return NULL; + return rbug_surface(_surface)->surface; +} + +static INLINE struct pipe_transfer * +rbug_transfer_unwrap(struct pipe_transfer *_transfer) +{ + if (!_transfer) + return NULL; + return rbug_transfer(_transfer)->transfer; +} + +static INLINE void * +rbug_shader_unwrap(void *_state) +{ + struct rbug_shader *shader; + if (!_state) + return NULL; + + shader = rbug_shader(_state); + return shader->replaced_shader ? shader->replaced_shader : shader->shader; +} + + +struct pipe_resource * +rbug_resource_create(struct rbug_screen *rb_screen, + struct pipe_resource *resource); + +void +rbug_resource_destroy(struct rbug_resource *rb_resource); + +struct pipe_surface * +rbug_surface_create(struct rbug_resource *rb_resource, + struct pipe_surface *surface); + +void +rbug_surface_destroy(struct rbug_surface *rb_surface); + +struct pipe_sampler_view * +rbug_sampler_view_create(struct rbug_context *rb_context, + struct rbug_resource *rb_resource, + struct pipe_sampler_view *view); + +void +rbug_sampler_view_destroy(struct rbug_context *rb_context, + struct rbug_sampler_view *rb_sampler_view); + +struct pipe_transfer * +rbug_transfer_create(struct rbug_context *rb_context, + struct rbug_resource *rb_resource, + struct pipe_transfer *transfer); + +void +rbug_transfer_destroy(struct rbug_context *rb_context, + struct rbug_transfer *rb_transfer); + +void * +rbug_shader_create(struct rbug_context *rb_context, + const struct pipe_shader_state *state, + void *result, enum rbug_shader_type type); + +void +rbug_shader_destroy(struct rbug_context *rb_context, + struct rbug_shader *rb_shader); + + +#endif /* RBUG_OBJECTS_H */ diff --git a/src/gallium/drivers/rbug/rbug_public.h b/src/gallium/drivers/rbug/rbug_public.h new file mode 100644 index 00000000000..b66740b49cd --- /dev/null +++ b/src/gallium/drivers/rbug/rbug_public.h @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef RBUG_PUBLIC_H +#define RBUG_PUBLIC_H + +struct pipe_screen; +struct pipe_context; + +struct pipe_screen * +rbug_screen_create(struct pipe_screen *screen); + +boolean +rbug_enabled(void); + +#endif /* RBUG_PUBLIC_H */ diff --git a/src/gallium/drivers/rbug/rbug_screen.c b/src/gallium/drivers/rbug/rbug_screen.c new file mode 100644 index 00000000000..2b60af2302a --- /dev/null +++ b/src/gallium/drivers/rbug/rbug_screen.c @@ -0,0 +1,351 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include "pipe/p_screen.h" +#include "pipe/p_state.h" +#include "util/u_memory.h" +#include "util/u_debug.h" +#include "util/u_simple_list.h" + +#include "rbug_public.h" +#include "rbug_screen.h" +#include "rbug_context.h" +#include "rbug_objects.h" + +DEBUG_GET_ONCE_BOOL_OPTION(rbug, "GALLIUM_RBUG", FALSE) + +static void +rbug_screen_destroy(struct pipe_screen *_screen) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct pipe_screen *screen = rb_screen->screen; + + screen->destroy(screen); + + FREE(rb_screen); +} + +static const char * +rbug_screen_get_name(struct pipe_screen *_screen) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct pipe_screen *screen = rb_screen->screen; + + return screen->get_name(screen); +} + +static const char * +rbug_screen_get_vendor(struct pipe_screen *_screen) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct pipe_screen *screen = rb_screen->screen; + + return screen->get_vendor(screen); +} + +static int +rbug_screen_get_param(struct pipe_screen *_screen, + enum pipe_cap param) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct pipe_screen *screen = rb_screen->screen; + + return screen->get_param(screen, + param); +} + +static float +rbug_screen_get_paramf(struct pipe_screen *_screen, + enum pipe_cap param) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct pipe_screen *screen = rb_screen->screen; + + return screen->get_paramf(screen, + param); +} + +static boolean +rbug_screen_is_format_supported(struct pipe_screen *_screen, + enum pipe_format format, + enum pipe_texture_target target, + unsigned tex_usage, + unsigned geom_flags) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct pipe_screen *screen = rb_screen->screen; + + return screen->is_format_supported(screen, + format, + target, + tex_usage, + geom_flags); +} + +static struct pipe_context * +rbug_screen_context_create(struct pipe_screen *_screen, + void *priv) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct pipe_screen *screen = rb_screen->screen; + struct pipe_context *result; + + result = screen->context_create(screen, priv); + if (result) + return rbug_context_create(_screen, result); + return NULL; +} + +static struct pipe_resource * +rbug_screen_resource_create(struct pipe_screen *_screen, + const struct pipe_resource *templat) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct pipe_screen *screen = rb_screen->screen; + struct pipe_resource *result; + + result = screen->resource_create(screen, + templat); + + if (result) + return rbug_resource_create(rb_screen, result); + return NULL; +} + +static struct pipe_resource * +rbug_screen_resource_from_handle(struct pipe_screen *_screen, + const struct pipe_resource *templ, + struct winsys_handle *handle) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct pipe_screen *screen = rb_screen->screen; + struct pipe_resource *result; + + result = screen->resource_from_handle(screen, templ, handle); + + result = rbug_resource_create(rbug_screen(_screen), result); + + return result; +} + +static boolean +rbug_screen_resource_get_handle(struct pipe_screen *_screen, + struct pipe_resource *_resource, + struct winsys_handle *handle) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct rbug_resource *rb_resource = rbug_resource(_resource); + struct pipe_screen *screen = rb_screen->screen; + struct pipe_resource *resource = rb_resource->resource; + + return screen->resource_get_handle(screen, resource, handle); +} + + + +static void +rbug_screen_resource_destroy(struct pipe_screen *screen, + struct pipe_resource *_resource) +{ + rbug_resource_destroy(rbug_resource(_resource)); +} + +static struct pipe_surface * +rbug_screen_get_tex_surface(struct pipe_screen *_screen, + struct pipe_resource *_resource, + unsigned face, + unsigned level, + unsigned zslice, + unsigned usage) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct rbug_resource *rb_resource = rbug_resource(_resource); + struct pipe_screen *screen = rb_screen->screen; + struct pipe_resource *resource = rb_resource->resource; + struct pipe_surface *result; + + result = screen->get_tex_surface(screen, + resource, + face, + level, + zslice, + usage); + + if (result) + return rbug_surface_create(rb_resource, result); + return NULL; +} + +static void +rbug_screen_tex_surface_destroy(struct pipe_surface *_surface) +{ + rbug_surface_destroy(rbug_surface(_surface)); +} + + + +static struct pipe_resource * +rbug_screen_user_buffer_create(struct pipe_screen *_screen, + void *ptr, + unsigned bytes, + unsigned usage) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct pipe_screen *screen = rb_screen->screen; + struct pipe_resource *result; + + result = screen->user_buffer_create(screen, + ptr, + bytes, + usage); + + if (result) + return rbug_resource_create(rb_screen, result); + return NULL; +} + + + +static void +rbug_screen_flush_frontbuffer(struct pipe_screen *_screen, + struct pipe_surface *_surface, + void *context_private) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct rbug_surface *rb_surface = rbug_surface(_surface); + struct pipe_screen *screen = rb_screen->screen; + struct pipe_surface *surface = rb_surface->surface; + + screen->flush_frontbuffer(screen, + surface, + context_private); +} + +static void +rbug_screen_fence_reference(struct pipe_screen *_screen, + struct pipe_fence_handle **ptr, + struct pipe_fence_handle *fence) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct pipe_screen *screen = rb_screen->screen; + + screen->fence_reference(screen, + ptr, + fence); +} + +static int +rbug_screen_fence_signalled(struct pipe_screen *_screen, + struct pipe_fence_handle *fence, + unsigned flags) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct pipe_screen *screen = rb_screen->screen; + + return screen->fence_signalled(screen, + fence, + flags); +} + +static int +rbug_screen_fence_finish(struct pipe_screen *_screen, + struct pipe_fence_handle *fence, + unsigned flags) +{ + struct rbug_screen *rb_screen = rbug_screen(_screen); + struct pipe_screen *screen = rb_screen->screen; + + return screen->fence_finish(screen, + fence, + flags); +} + +boolean +rbug_enabled() +{ + return debug_get_option_rbug(); +} + +struct pipe_screen * +rbug_screen_create(struct pipe_screen *screen) +{ + struct rbug_screen *rb_screen; + + if (!debug_get_option_rbug()) + return screen; + + rb_screen = CALLOC_STRUCT(rbug_screen); + if (!rb_screen) + return screen; + + pipe_mutex_init(rb_screen->list_mutex); + make_empty_list(&rb_screen->contexts); + make_empty_list(&rb_screen->resources); + make_empty_list(&rb_screen->surfaces); + make_empty_list(&rb_screen->transfers); + + rb_screen->base.winsys = NULL; + + rb_screen->base.destroy = rbug_screen_destroy; + rb_screen->base.get_name = rbug_screen_get_name; + rb_screen->base.get_vendor = rbug_screen_get_vendor; + rb_screen->base.get_param = rbug_screen_get_param; + rb_screen->base.get_paramf = rbug_screen_get_paramf; + rb_screen->base.is_format_supported = rbug_screen_is_format_supported; + rb_screen->base.context_create = rbug_screen_context_create; + rb_screen->base.resource_create = rbug_screen_resource_create; + rb_screen->base.resource_from_handle = rbug_screen_resource_from_handle; + rb_screen->base.resource_get_handle = rbug_screen_resource_get_handle; + rb_screen->base.resource_destroy = rbug_screen_resource_destroy; + rb_screen->base.get_tex_surface = rbug_screen_get_tex_surface; + rb_screen->base.tex_surface_destroy = rbug_screen_tex_surface_destroy; + rb_screen->base.user_buffer_create = rbug_screen_user_buffer_create; + rb_screen->base.flush_frontbuffer = rbug_screen_flush_frontbuffer; + rb_screen->base.fence_reference = rbug_screen_fence_reference; + rb_screen->base.fence_signalled = rbug_screen_fence_signalled; + rb_screen->base.fence_finish = rbug_screen_fence_finish; + + rb_screen->screen = screen; + + rb_screen->private_context = screen->context_create(screen, NULL); + if (!rb_screen->private_context) + goto err_free; + + rb_screen->rbug = rbug_start(rb_screen); + + if (!rb_screen->rbug) + goto err_context; + + return &rb_screen->base; + +err_context: + rb_screen->private_context->destroy(rb_screen->private_context); +err_free: + FREE(rb_screen); + return screen; +} diff --git a/src/gallium/drivers/rbug/rbug_screen.h b/src/gallium/drivers/rbug/rbug_screen.h new file mode 100644 index 00000000000..a53afac05e9 --- /dev/null +++ b/src/gallium/drivers/rbug/rbug_screen.h @@ -0,0 +1,100 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef RBUG_SCREEN_H +#define RBUG_SCREEN_H + +#include "pipe/p_screen.h" +#include "pipe/p_defines.h" + +#include "os/os_thread.h" + +struct rbug_list { + struct rbug_list *next; + struct rbug_list *prev; +}; + + +struct rbug_screen +{ + struct pipe_screen base; + + struct pipe_screen *screen; + struct pipe_context *private_context; + + /* remote debugger */ + struct rbug_rbug *rbug; + + pipe_mutex list_mutex; + int num_contexts; + int num_resources; + int num_surfaces; + int num_transfers; + struct rbug_list contexts; + struct rbug_list resources; + struct rbug_list surfaces; + struct rbug_list transfers; +}; + +static INLINE struct rbug_screen * +rbug_screen(struct pipe_screen *screen) +{ + return (struct rbug_screen *)screen; +} + +#define rbug_screen_add_to_list(scr, name, obj) \ + do { \ + pipe_mutex_lock(scr->list_mutex); \ + insert_at_head(&scr->name, &obj->list); \ + scr->num_##name++; \ + pipe_mutex_unlock(scr->list_mutex); \ + } while (0) + +#define rbug_screen_remove_from_list(scr, name, obj) \ + do { \ + pipe_mutex_lock(scr->list_mutex); \ + remove_from_list(&obj->list); \ + scr->num_##name--; \ + pipe_mutex_unlock(scr->list_mutex); \ + } while (0) + + + +/********************************************************** + * rbug_core.c + */ + +struct rbug_rbug; + +struct rbug_rbug * +rbug_start(struct rbug_screen *rb_screen); + +void +rbug_stop(struct rbug_rbug *rbug); + + +#endif /* RBUG_SCREEN_H */ diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index 0f1bcc21bd6..2f10b46e989 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -36,6 +36,7 @@ #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_inlines.h" +#include "tgsi/tgsi_exec.h" #include "sp_clear.h" #include "sp_context.h" #include "sp_flush.h" @@ -123,6 +124,8 @@ softpipe_destroy( struct pipe_context *pipe ) } } + tgsi_exec_machine_destroy(softpipe->fs_machine); + FREE( softpipe ); } @@ -294,6 +297,8 @@ softpipe_create_context( struct pipe_screen *screen, softpipe->vertex_tex_cache[i] = sp_create_tex_tile_cache( &softpipe->pipe ); } + softpipe->fs_machine = tgsi_exec_machine_create(); + /* setup quad rendering stages */ softpipe->quad.shade = sp_quad_shade_stage(softpipe); softpipe->quad.depth_test = sp_quad_depth_test_stage(softpipe); diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index 92607874b60..b3d3fe620fd 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -109,6 +109,9 @@ struct softpipe_context { /** The reduced version of the primitive supplied by the state tracker */ unsigned reduced_api_prim; + /** Derived information about which winding orders to cull */ + unsigned cull_mode; + /** * The reduced primitive after unfilled triangles, wide-line decomposition, * etc, are taken into account. This is the primitive type that's actually @@ -140,6 +143,8 @@ struct softpipe_context { struct sp_sampler_varient *frag_samplers_list[PIPE_MAX_SAMPLERS]; } tgsi; + struct tgsi_exec_machine *fs_machine; + /** The primitive drawing context */ struct draw_context *draw; diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c index a58bc107c0a..db0d1755103 100644 --- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c +++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c @@ -158,26 +158,27 @@ static INLINE cptrf4 get_vert( const void *vertex_buffer, * draw elements / indexed primitives */ static void -sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) +sp_vbuf_draw_elements(struct vbuf_render *vbr, const ushort *indices, uint nr) { struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr); struct softpipe_context *softpipe = cvbr->softpipe; const unsigned stride = softpipe->vertex_info_vbuf.size * sizeof(float); const void *vertex_buffer = cvbr->vertex_buffer; - struct setup_context *setup_ctx = cvbr->setup; + struct setup_context *setup = cvbr->setup; + const boolean flatshade_first = softpipe->rasterizer->flatshade_first; unsigned i; switch (cvbr->prim) { case PIPE_PRIM_POINTS: for (i = 0; i < nr; i++) { - sp_setup_point( setup_ctx, + sp_setup_point( setup, get_vert(vertex_buffer, indices[i-0], stride) ); } break; case PIPE_PRIM_LINES: for (i = 1; i < nr; i += 2) { - sp_setup_line( setup_ctx, + sp_setup_line( setup, get_vert(vertex_buffer, indices[i-1], stride), get_vert(vertex_buffer, indices[i-0], stride) ); } @@ -185,7 +186,7 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) case PIPE_PRIM_LINE_STRIP: for (i = 1; i < nr; i ++) { - sp_setup_line( setup_ctx, + sp_setup_line( setup, get_vert(vertex_buffer, indices[i-1], stride), get_vert(vertex_buffer, indices[i-0], stride) ); } @@ -193,48 +194,41 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) case PIPE_PRIM_LINE_LOOP: for (i = 1; i < nr; i ++) { - sp_setup_line( setup_ctx, + sp_setup_line( setup, get_vert(vertex_buffer, indices[i-1], stride), get_vert(vertex_buffer, indices[i-0], stride) ); } if (nr) { - sp_setup_line( setup_ctx, + sp_setup_line( setup, get_vert(vertex_buffer, indices[nr-1], stride), get_vert(vertex_buffer, indices[0], stride) ); } break; case PIPE_PRIM_TRIANGLES: - if (softpipe->rasterizer->flatshade_first) { - for (i = 2; i < nr; i += 3) { - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-0], stride), - get_vert(vertex_buffer, indices[i-2], stride) ); - } - } - else { - for (i = 2; i < nr; i += 3) { - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, indices[i-2], stride), - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-0], stride) ); - } + for (i = 2; i < nr; i += 3) { + sp_setup_tri( setup, + get_vert(vertex_buffer, indices[i-2], stride), + get_vert(vertex_buffer, indices[i-1], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); } break; case PIPE_PRIM_TRIANGLE_STRIP: - if (softpipe->rasterizer->flatshade_first) { + if (flatshade_first) { for (i = 2; i < nr; i += 1) { - sp_setup_tri( setup_ctx, + /* emit first triangle vertex as first triangle vertex */ + sp_setup_tri( setup, + get_vert(vertex_buffer, indices[i-2], stride), get_vert(vertex_buffer, indices[i+(i&1)-1], stride), - get_vert(vertex_buffer, indices[i-(i&1)], stride), - get_vert(vertex_buffer, indices[i-2], stride) ); + get_vert(vertex_buffer, indices[i-(i&1)], stride) ); + } } else { for (i = 2; i < nr; i += 1) { - sp_setup_tri( setup_ctx, + /* emit last triangle vertex as last triangle vertex */ + sp_setup_tri( setup, get_vert(vertex_buffer, indices[i+(i&1)-2], stride), get_vert(vertex_buffer, indices[i-(i&1)-1], stride), get_vert(vertex_buffer, indices[i-0], stride) ); @@ -243,17 +237,19 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) break; case PIPE_PRIM_TRIANGLE_FAN: - if (softpipe->rasterizer->flatshade_first) { + if (flatshade_first) { for (i = 2; i < nr; i += 1) { - sp_setup_tri( setup_ctx, + /* emit first non-spoke vertex as first vertex */ + sp_setup_tri( setup, + get_vert(vertex_buffer, indices[i-1], stride), get_vert(vertex_buffer, indices[i-0], stride), - get_vert(vertex_buffer, indices[0], stride), - get_vert(vertex_buffer, indices[i-1], stride) ); + get_vert(vertex_buffer, indices[0], stride) ); } } else { for (i = 2; i < nr; i += 1) { - sp_setup_tri( setup_ctx, + /* emit last non-spoke vertex as last vertex */ + sp_setup_tri( setup, get_vert(vertex_buffer, indices[0], stride), get_vert(vertex_buffer, indices[i-1], stride), get_vert(vertex_buffer, indices[i-0], stride) ); @@ -262,43 +258,88 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) break; case PIPE_PRIM_QUADS: - for (i = 3; i < nr; i += 4) { - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, indices[i-3], stride), - get_vert(vertex_buffer, indices[i-2], stride), - get_vert(vertex_buffer, indices[i-0], stride) ); + /* GL quads don't follow provoking vertex convention */ + if (flatshade_first) { + /* emit last quad vertex as first triangle vertex */ + for (i = 3; i < nr; i += 4) { + sp_setup_tri( setup, + get_vert(vertex_buffer, indices[i-0], stride), + get_vert(vertex_buffer, indices[i-3], stride), + get_vert(vertex_buffer, indices[i-2], stride) ); - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, indices[i-2], stride), - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-0], stride) ); + sp_setup_tri( setup, + get_vert(vertex_buffer, indices[i-0], stride), + get_vert(vertex_buffer, indices[i-2], stride), + get_vert(vertex_buffer, indices[i-1], stride) ); + } + } + else { + /* emit last quad vertex as last triangle vertex */ + for (i = 3; i < nr; i += 4) { + sp_setup_tri( setup, + get_vert(vertex_buffer, indices[i-3], stride), + get_vert(vertex_buffer, indices[i-2], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); + + sp_setup_tri( setup, + get_vert(vertex_buffer, indices[i-2], stride), + get_vert(vertex_buffer, indices[i-1], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); + } } break; case PIPE_PRIM_QUAD_STRIP: - for (i = 3; i < nr; i += 2) { - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, indices[i-3], stride), - get_vert(vertex_buffer, indices[i-2], stride), - get_vert(vertex_buffer, indices[i-0], stride) ); - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-3], stride), - get_vert(vertex_buffer, indices[i-0], stride) ); + /* GL quad strips don't follow provoking vertex convention */ + if (flatshade_first) { + /* emit last quad vertex as first triangle vertex */ + for (i = 3; i < nr; i += 2) { + sp_setup_tri( setup, + get_vert(vertex_buffer, indices[i-0], stride), + get_vert(vertex_buffer, indices[i-3], stride), + get_vert(vertex_buffer, indices[i-2], stride) ); + sp_setup_tri( setup, + get_vert(vertex_buffer, indices[i-0], stride), + get_vert(vertex_buffer, indices[i-1], stride), + get_vert(vertex_buffer, indices[i-3], stride) ); + } + } + else { + /* emit last quad vertex as last triangle vertex */ + for (i = 3; i < nr; i += 2) { + sp_setup_tri( setup, + get_vert(vertex_buffer, indices[i-3], stride), + get_vert(vertex_buffer, indices[i-2], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); + sp_setup_tri( setup, + get_vert(vertex_buffer, indices[i-1], stride), + get_vert(vertex_buffer, indices[i-3], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); + } } break; case PIPE_PRIM_POLYGON: /* Almost same as tri fan but the _first_ vertex specifies the flat - * shading color. Note that the first polygon vertex is passed as - * the last triangle vertex here. - * flatshade_first state makes no difference. + * shading color. */ - for (i = 2; i < nr; i += 1) { - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, indices[i-0], stride), - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[0], stride) ); + if (flatshade_first) { + /* emit first polygon vertex as first triangle vertex */ + for (i = 2; i < nr; i += 1) { + sp_setup_tri( setup, + get_vert(vertex_buffer, indices[0], stride), + get_vert(vertex_buffer, indices[i-1], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); + } + } + else { + /* emit first polygon vertex as last triangle vertex */ + for (i = 2; i < nr; i += 1) { + sp_setup_tri( setup, + get_vert(vertex_buffer, indices[i-1], stride), + get_vert(vertex_buffer, indices[i-0], stride), + get_vert(vertex_buffer, indices[0], stride) ); + } } break; @@ -317,23 +358,24 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) { struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr); struct softpipe_context *softpipe = cvbr->softpipe; - struct setup_context *setup_ctx = cvbr->setup; + struct setup_context *setup = cvbr->setup; const unsigned stride = softpipe->vertex_info_vbuf.size * sizeof(float); const void *vertex_buffer = (void *) get_vert(cvbr->vertex_buffer, start, stride); + const boolean flatshade_first = softpipe->rasterizer->flatshade_first; unsigned i; switch (cvbr->prim) { case PIPE_PRIM_POINTS: for (i = 0; i < nr; i++) { - sp_setup_point( setup_ctx, + sp_setup_point( setup, get_vert(vertex_buffer, i-0, stride) ); } break; case PIPE_PRIM_LINES: for (i = 1; i < nr; i += 2) { - sp_setup_line( setup_ctx, + sp_setup_line( setup, get_vert(vertex_buffer, i-1, stride), get_vert(vertex_buffer, i-0, stride) ); } @@ -341,7 +383,7 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) case PIPE_PRIM_LINE_STRIP: for (i = 1; i < nr; i ++) { - sp_setup_line( setup_ctx, + sp_setup_line( setup, get_vert(vertex_buffer, i-1, stride), get_vert(vertex_buffer, i-0, stride) ); } @@ -349,48 +391,40 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) case PIPE_PRIM_LINE_LOOP: for (i = 1; i < nr; i ++) { - sp_setup_line( setup_ctx, + sp_setup_line( setup, get_vert(vertex_buffer, i-1, stride), get_vert(vertex_buffer, i-0, stride) ); } if (nr) { - sp_setup_line( setup_ctx, + sp_setup_line( setup, get_vert(vertex_buffer, nr-1, stride), get_vert(vertex_buffer, 0, stride) ); } break; case PIPE_PRIM_TRIANGLES: - if (softpipe->rasterizer->flatshade_first) { - for (i = 2; i < nr; i += 3) { - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-0, stride), - get_vert(vertex_buffer, i-2, stride) ); - } - } - else { - for (i = 2; i < nr; i += 3) { - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-0, stride) ); - } + for (i = 2; i < nr; i += 3) { + sp_setup_tri( setup, + get_vert(vertex_buffer, i-2, stride), + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-0, stride) ); } break; case PIPE_PRIM_TRIANGLE_STRIP: - if (softpipe->rasterizer->flatshade_first) { + if (flatshade_first) { for (i = 2; i < nr; i++) { - sp_setup_tri( setup_ctx, + /* emit first triangle vertex as first triangle vertex */ + sp_setup_tri( setup, + get_vert(vertex_buffer, i-2, stride), get_vert(vertex_buffer, i+(i&1)-1, stride), - get_vert(vertex_buffer, i-(i&1), stride), - get_vert(vertex_buffer, i-2, stride) ); + get_vert(vertex_buffer, i-(i&1), stride) ); } } else { for (i = 2; i < nr; i++) { - sp_setup_tri( setup_ctx, + /* emit last triangle vertex as last triangle vertex */ + sp_setup_tri( setup, get_vert(vertex_buffer, i+(i&1)-2, stride), get_vert(vertex_buffer, i-(i&1)-1, stride), get_vert(vertex_buffer, i-0, stride) ); @@ -399,17 +433,19 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) break; case PIPE_PRIM_TRIANGLE_FAN: - if (softpipe->rasterizer->flatshade_first) { + if (flatshade_first) { for (i = 2; i < nr; i += 1) { - sp_setup_tri( setup_ctx, + /* emit first non-spoke vertex as first vertex */ + sp_setup_tri( setup, + get_vert(vertex_buffer, i-1, stride), get_vert(vertex_buffer, i-0, stride), - get_vert(vertex_buffer, 0, stride), - get_vert(vertex_buffer, i-1, stride) ); + get_vert(vertex_buffer, 0, stride) ); } } else { for (i = 2; i < nr; i += 1) { - sp_setup_tri( setup_ctx, + /* emit last non-spoke vertex as last vertex */ + sp_setup_tri( setup, get_vert(vertex_buffer, 0, stride), get_vert(vertex_buffer, i-1, stride), get_vert(vertex_buffer, i-0, stride) ); @@ -418,42 +454,86 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) break; case PIPE_PRIM_QUADS: - for (i = 3; i < nr; i += 4) { - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, i-3, stride), - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-0, stride) ); - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-0, stride) ); + /* GL quads don't follow provoking vertex convention */ + if (flatshade_first) { + /* emit last quad vertex as first triangle vertex */ + for (i = 3; i < nr; i += 4) { + sp_setup_tri( setup, + get_vert(vertex_buffer, i-0, stride), + get_vert(vertex_buffer, i-3, stride), + get_vert(vertex_buffer, i-2, stride) ); + sp_setup_tri( setup, + get_vert(vertex_buffer, i-0, stride), + get_vert(vertex_buffer, i-2, stride), + get_vert(vertex_buffer, i-1, stride) ); + } + } + else { + /* emit last quad vertex as last triangle vertex */ + for (i = 3; i < nr; i += 4) { + sp_setup_tri( setup, + get_vert(vertex_buffer, i-3, stride), + get_vert(vertex_buffer, i-2, stride), + get_vert(vertex_buffer, i-0, stride) ); + sp_setup_tri( setup, + get_vert(vertex_buffer, i-2, stride), + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-0, stride) ); + } } break; case PIPE_PRIM_QUAD_STRIP: - for (i = 3; i < nr; i += 2) { - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, i-3, stride), - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-0, stride) ); - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-3, stride), - get_vert(vertex_buffer, i-0, stride) ); + /* GL quad strips don't follow provoking vertex convention */ + if (flatshade_first) { + /* emit last quad vertex as first triangle vertex */ + for (i = 3; i < nr; i += 2) { + sp_setup_tri( setup, + get_vert(vertex_buffer, i-0, stride), + get_vert(vertex_buffer, i-3, stride), + get_vert(vertex_buffer, i-2, stride) ); + sp_setup_tri( setup, + get_vert(vertex_buffer, i-0, stride), + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-3, stride) ); + } + } + else { + /* emit last quad vertex as last triangle vertex */ + for (i = 3; i < nr; i += 2) { + sp_setup_tri( setup, + get_vert(vertex_buffer, i-3, stride), + get_vert(vertex_buffer, i-2, stride), + get_vert(vertex_buffer, i-0, stride) ); + sp_setup_tri( setup, + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-3, stride), + get_vert(vertex_buffer, i-0, stride) ); + } } break; case PIPE_PRIM_POLYGON: /* Almost same as tri fan but the _first_ vertex specifies the flat - * shading color. Note that the first polygon vertex is passed as - * the last triangle vertex here. - * flatshade_first state makes no difference. + * shading color. */ - for (i = 2; i < nr; i += 1) { - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-0, stride), - get_vert(vertex_buffer, 0, stride) ); + if (flatshade_first) { + /* emit first polygon vertex as first triangle vertex */ + for (i = 2; i < nr; i += 1) { + sp_setup_tri( setup, + get_vert(vertex_buffer, 0, stride), + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-0, stride) ); + } + } + else { + /* emit first polygon vertex as last triangle vertex */ + for (i = 2; i < nr; i += 1) { + sp_setup_tri( setup, + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-0, stride), + get_vert(vertex_buffer, 0, stride) ); + } } break; @@ -492,7 +572,7 @@ sp_create_vbuf_backend(struct softpipe_context *sp) cvbr->base.map_vertices = sp_vbuf_map_vertices; cvbr->base.unmap_vertices = sp_vbuf_unmap_vertices; cvbr->base.set_primitive = sp_vbuf_set_primitive; - cvbr->base.draw = sp_vbuf_draw; + cvbr->base.draw_elements = sp_vbuf_draw_elements; cvbr->base.draw_arrays = sp_vbuf_draw_arrays; cvbr->base.release_vertices = sp_vbuf_release_vertices; cvbr->base.destroy = sp_vbuf_destroy; diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c index 8ae5a7f028b..907e94b59b9 100644 --- a/src/gallium/drivers/softpipe/sp_quad_fs.c +++ b/src/gallium/drivers/softpipe/sp_quad_fs.c @@ -50,8 +50,8 @@ struct quad_shade_stage { struct quad_stage stage; /**< base class */ - struct tgsi_exec_machine *machine; - struct tgsi_exec_vector *inputs, *outputs; + + /* no other fields at this time */ }; @@ -70,9 +70,8 @@ quad_shade_stage(struct quad_stage *qs) static INLINE boolean shade_quad(struct quad_stage *qs, struct quad_header *quad) { - struct quad_shade_stage *qss = quad_shade_stage( qs ); struct softpipe_context *softpipe = qs->softpipe; - struct tgsi_exec_machine *machine = qss->machine; + struct tgsi_exec_machine *machine = softpipe->fs_machine; /* run shader */ return softpipe->fs->run( softpipe->fs, machine, quad ); @@ -108,9 +107,8 @@ shade_quads(struct quad_stage *qs, struct quad_header *quads[], unsigned nr) { - struct quad_shade_stage *qss = quad_shade_stage( qs ); struct softpipe_context *softpipe = qs->softpipe; - struct tgsi_exec_machine *machine = qss->machine; + struct tgsi_exec_machine *machine = softpipe->fs_machine; unsigned i, pass = 0; for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { @@ -139,11 +137,10 @@ shade_quads(struct quad_stage *qs, static void shade_begin(struct quad_stage *qs) { - struct quad_shade_stage *qss = quad_shade_stage(qs); struct softpipe_context *softpipe = qs->softpipe; softpipe->fs->prepare( softpipe->fs, - qss->machine, + softpipe->fs_machine, (struct tgsi_sampler **) softpipe->tgsi.frag_samplers_list ); @@ -154,10 +151,6 @@ shade_begin(struct quad_stage *qs) static void shade_destroy(struct quad_stage *qs) { - struct quad_shade_stage *qss = (struct quad_shade_stage *) qs; - - tgsi_exec_machine_destroy(qss->machine); - FREE( qs ); } @@ -174,16 +167,9 @@ sp_quad_shade_stage( struct softpipe_context *softpipe ) qss->stage.run = shade_quads; qss->stage.destroy = shade_destroy; - qss->machine = tgsi_exec_machine_create(); - if (!qss->machine) - goto fail; - return &qss->stage; fail: - if (qss && qss->machine) - tgsi_exec_machine_destroy(qss->machine); - FREE(qss); return NULL; } diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c index 4ef5d9f7b1d..b959af63aff 100644 --- a/src/gallium/drivers/softpipe/sp_query.c +++ b/src/gallium/drivers/softpipe/sp_query.c @@ -30,6 +30,7 @@ */ #include "draw/draw_context.h" +#include "os/os_time.h" #include "pipe/p_defines.h" #include "util/u_memory.h" #include "sp_context.h" @@ -37,6 +38,7 @@ #include "sp_state.h" struct softpipe_query { + unsigned type; uint64_t start; uint64_t end; }; @@ -51,8 +53,13 @@ static struct pipe_query * softpipe_create_query(struct pipe_context *pipe, unsigned type) { - assert(type == PIPE_QUERY_OCCLUSION_COUNTER); - return (struct pipe_query *)CALLOC_STRUCT( softpipe_query ); + struct softpipe_query* sq; + + assert(type == PIPE_QUERY_OCCLUSION_COUNTER || type == PIPE_QUERY_TIME_ELAPSED); + sq = CALLOC_STRUCT( softpipe_query ); + sq->type = type; + + return (struct pipe_query *)sq; } @@ -69,7 +76,17 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q) struct softpipe_context *softpipe = softpipe_context( pipe ); struct softpipe_query *sq = softpipe_query(q); - sq->start = softpipe->occlusion_count; + switch (sq->type) { + case PIPE_QUERY_OCCLUSION_COUNTER: + sq->start = softpipe->occlusion_count; + break; + case PIPE_QUERY_TIME_ELAPSED: + sq->start = 1000*os_time_get(); + break; + default: + assert(0); + break; + } softpipe->active_query_count++; softpipe->dirty |= SP_NEW_QUERY; } @@ -82,7 +99,17 @@ softpipe_end_query(struct pipe_context *pipe, struct pipe_query *q) struct softpipe_query *sq = softpipe_query(q); softpipe->active_query_count--; - sq->end = softpipe->occlusion_count; + switch (sq->type) { + case PIPE_QUERY_OCCLUSION_COUNTER: + sq->end = softpipe->occlusion_count; + break; + case PIPE_QUERY_TIME_ELAPSED: + sq->end = 1000*os_time_get(); + break; + default: + assert(0); + break; + } softpipe->dirty |= SP_NEW_QUERY; } diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index ad59ee90936..73987c913e5 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -33,6 +33,7 @@ #include "pipe/p_screen.h" #include "state_tracker/sw_winsys.h" +#include "tgsi/tgsi_exec.h" #include "sp_texture.h" #include "sp_screen.h" @@ -56,7 +57,7 @@ softpipe_get_name(struct pipe_screen *screen) static int -softpipe_get_param(struct pipe_screen *screen, int param) +softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) { switch (param) { case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: @@ -81,6 +82,8 @@ softpipe_get_param(struct pipe_screen *screen, int param) return PIPE_MAX_COLOR_BUFS; case PIPE_CAP_OCCLUSION_QUERY: return 1; + case PIPE_CAP_TIMER_QUERY: + return 1; case PIPE_CAP_TEXTURE_MIRROR_CLAMP: return 1; case PIPE_CAP_TEXTURE_MIRROR_REPEAT: @@ -110,6 +113,36 @@ softpipe_get_param(struct pipe_screen *screen, int param) case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: return 1; + + case PIPE_CAP_MAX_VS_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_TEX_INDIRECTIONS: + case PIPE_CAP_MAX_FS_TEX_INDIRECTIONS: + /* There is no limit in number of instructions beyond available memory */ + return 32768; + case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH: + case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH: + return TGSI_EXEC_MAX_NESTING; + case PIPE_CAP_MAX_VS_INPUTS: + case PIPE_CAP_MAX_FS_INPUTS: + return TGSI_EXEC_MAX_INPUT_ATTRIBS; + case PIPE_CAP_MAX_FS_CONSTS: + case PIPE_CAP_MAX_VS_CONSTS: + return TGSI_EXEC_MAX_CONST_BUFFER; + case PIPE_CAP_MAX_VS_TEMPS: + case PIPE_CAP_MAX_FS_TEMPS: + return TGSI_EXEC_NUM_TEMPS; + case PIPE_CAP_MAX_VS_ADDRS: + case PIPE_CAP_MAX_FS_ADDRS: + return TGSI_EXEC_NUM_ADDRS; + case PIPE_CAP_MAX_VS_PREDS: + case PIPE_CAP_MAX_FS_PREDS: + return TGSI_EXEC_NUM_PREDS; + default: return 0; } @@ -117,7 +150,7 @@ softpipe_get_param(struct pipe_screen *screen, int param) static float -softpipe_get_paramf(struct pipe_screen *screen, int param) +softpipe_get_paramf(struct pipe_screen *screen, enum pipe_cap param) { switch (param) { case PIPE_CAP_MAX_LINE_WIDTH: diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index 86354664e4b..5d727dc00df 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -111,34 +111,13 @@ struct setup_context { uint numFragsWritten; /**< per primitive */ #endif - unsigned winding; /* which winding to cull */ + unsigned cull_face; /* which faces cull */ unsigned nr_vertex_attrs; }; -/** - * Do triangle cull test using tri determinant (sign indicates orientation) - * \return true if triangle is to be culled. - */ -static INLINE boolean -cull_tri(const struct setup_context *setup, float det) -{ - if (det != 0) { - /* if (det < 0 then Z points toward camera and triangle is - * counter-clockwise winding. - */ - unsigned winding = (det < 0) ? PIPE_WINDING_CCW : PIPE_WINDING_CW; - - if ((winding & setup->winding) == 0) - return FALSE; - } - - /* Culled: - */ - return TRUE; -} @@ -304,7 +283,10 @@ setup_sort_vertices(struct setup_context *setup, const float (*v1)[4], const float (*v2)[4]) { - setup->vprovoke = v2; + if (setup->softpipe->rasterizer->flatshade_first) + setup->vprovoke = v0; + else + setup->vprovoke = v2; /* determine bottom to top order of vertices */ { @@ -390,8 +372,16 @@ setup_sort_vertices(struct setup_context *setup, * 0 = front-facing, 1 = back-facing */ setup->facing = - ((det > 0.0) ^ - (setup->softpipe->rasterizer->front_winding == PIPE_WINDING_CW)); + ((det < 0.0) ^ + (setup->softpipe->rasterizer->front_ccw)); + + { + unsigned face = setup->facing == 0 ? PIPE_FACE_FRONT : PIPE_FACE_BACK; + + if (face & setup->cull_face) + return FALSE; + } + /* Prepare pixel offset for rasterisation: * - pixel center (0.5, 0.5) for GL, or @@ -829,11 +819,9 @@ sp_setup_tri(struct setup_context *setup, setup->numFragsWritten = 0; #endif - if (cull_tri( setup, det )) - return; - if (!setup_sort_vertices( setup, det, v0, v1, v2 )) return; + setup_tri_coefficients( setup ); setup_tri_edges( setup ); @@ -1417,14 +1405,14 @@ sp_setup_prepare(struct setup_context *setup) sp->quad.first->begin( sp->quad.first ); if (sp->reduced_api_prim == PIPE_PRIM_TRIANGLES && - sp->rasterizer->fill_cw == PIPE_POLYGON_MODE_FILL && - sp->rasterizer->fill_ccw == PIPE_POLYGON_MODE_FILL) { + sp->rasterizer->fill_front == PIPE_POLYGON_MODE_FILL && + sp->rasterizer->fill_back == PIPE_POLYGON_MODE_FILL) { /* we'll do culling */ - setup->winding = sp->rasterizer->cull_mode; + setup->cull_face = sp->rasterizer->cull_face; } else { /* 'draw' will do culling */ - setup->winding = PIPE_WINDING_NONE; + setup->cull_face = PIPE_FACE_NONE; } } diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c index 7f072f5a269..816e0c18bd2 100644 --- a/src/gallium/drivers/softpipe/sp_state_fs.c +++ b/src/gallium/drivers/softpipe/sp_state_fs.c @@ -36,6 +36,7 @@ #include "draw/draw_context.h" #include "draw/draw_vs.h" #include "tgsi/tgsi_dump.h" +#include "tgsi/tgsi_exec.h" #include "tgsi/tgsi_scan.h" #include "tgsi/tgsi_parse.h" @@ -95,10 +96,18 @@ softpipe_bind_fs_state(struct pipe_context *pipe, void *fs) void softpipe_delete_fs_state(struct pipe_context *pipe, void *fs) { + struct softpipe_context *softpipe = softpipe_context(pipe); struct sp_fragment_shader *state = fs; assert(fs != softpipe_context(pipe)->fs); - + + if (softpipe->fs_machine->Tokens == state->shader.tokens) { + /* unbind the shader from the tgsi executor if we're + * deleting it. + */ + tgsi_exec_machine_bind_shader(softpipe->fs_machine, NULL, 0, NULL); + } + state->delete( state ); } diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 7aa85559b23..4e6123fbd07 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -343,11 +343,15 @@ softpipe_get_transfer(struct pipe_context *pipe, if (spt) { struct pipe_transfer *pt = &spt->base; enum pipe_format format = resource->format; + const unsigned hgt = u_minify(spr->base.height0, sr.level); + const unsigned nblocksy = util_format_get_nblocksy(format, hgt); + pipe_resource_reference(&pt->resource, resource); pt->sr = sr; pt->usage = usage; pt->box = *box; pt->stride = spr->stride[sr.level]; + pt->slice_stride = pt->stride * nblocksy; spt->offset = sp_get_tex_image_offset(spr, sr.level, sr.face, box->z); diff --git a/src/gallium/drivers/svga/svga_pipe_rasterizer.c b/src/gallium/drivers/svga/svga_pipe_rasterizer.c index 5253c45cb20..660eb0757a6 100644 --- a/src/gallium/drivers/svga/svga_pipe_rasterizer.c +++ b/src/gallium/drivers/svga/svga_pipe_rasterizer.c @@ -36,16 +36,17 @@ /* Hardware frontwinding is always set up as SVGA3D_FRONTWINDING_CW. */ static SVGA3dFace svga_translate_cullmode( unsigned mode, - unsigned front_winding ) + unsigned front_ccw ) { + const int hw_front_ccw = 0; /* hardware is always CW */ switch (mode) { - case PIPE_WINDING_NONE: + case PIPE_FACE_NONE: return SVGA3D_FACE_NONE; - case PIPE_WINDING_CCW: - return SVGA3D_FACE_BACK; - case PIPE_WINDING_CW: - return SVGA3D_FACE_FRONT; - case PIPE_WINDING_BOTH: + case PIPE_FACE_FRONT: + return front_ccw == hw_front_ccw ? SVGA3D_FACE_FRONT : SVGA3D_FACE_BACK; + case PIPE_FACE_BACK: + return front_ccw == hw_front_ccw ? SVGA3D_FACE_BACK : SVGA3D_FACE_FRONT; + case PIPE_FACE_FRONT_AND_BACK: return SVGA3D_FACE_FRONT_BACK; default: assert(0); @@ -81,8 +82,8 @@ svga_create_rasterizer_state(struct pipe_context *pipe, /* fill_cw, fill_ccw - draw module or index translation */ rast->shademode = svga_translate_flatshade( templ->flatshade ); - rast->cullmode = svga_translate_cullmode( templ->cull_mode, - templ->front_winding ); + rast->cullmode = svga_translate_cullmode( templ->cull_face, + templ->front_ccw ); rast->scissortestenable = templ->scissor; rast->multisampleantialias = templ->multisample; rast->antialiasedlineenable = templ->line_smooth; @@ -117,31 +118,31 @@ svga_create_rasterizer_state(struct pipe_context *pipe, rast->need_pipeline |= SVGA_PIPELINE_FLAG_POINTS; { - boolean offset_cw = templ->offset_cw; - boolean offset_ccw = templ->offset_ccw; - boolean offset = 0; - int fill_cw = templ->fill_cw; - int fill_ccw = templ->fill_ccw; + int fill_front = templ->fill_front; + int fill_back = templ->fill_back; int fill = PIPE_POLYGON_MODE_FILL; + boolean offset_front = util_get_offset(templ, fill_front); + boolean offset_back = util_get_offset(templ, fill_back); + boolean offset = 0; - switch (templ->cull_mode) { - case PIPE_WINDING_BOTH: + switch (templ->cull_face) { + case PIPE_FACE_FRONT_AND_BACK: offset = 0; fill = PIPE_POLYGON_MODE_FILL; break; - case PIPE_WINDING_CW: - offset = offset_ccw; - fill = fill_ccw; + case PIPE_FACE_FRONT: + offset = offset_front; + fill = fill_front; break; - case PIPE_WINDING_CCW: - offset = offset_cw; - fill = fill_cw; + case PIPE_FACE_BACK: + offset = offset_back; + fill = fill_back; break; - case PIPE_WINDING_NONE: - if (fill_cw != fill_ccw || offset_cw != offset_ccw) + case PIPE_FACE_NONE: + if (fill_front != fill_back || offset_front != offset_back) { /* Always need the draw module to work out different * front/back fill modes: @@ -149,8 +150,8 @@ svga_create_rasterizer_state(struct pipe_context *pipe, rast->need_pipeline |= SVGA_PIPELINE_FLAG_TRIS; } else { - offset = offset_ccw; - fill = fill_ccw; + offset = offset_front; + fill = fill_front; } break; @@ -167,7 +168,7 @@ svga_create_rasterizer_state(struct pipe_context *pipe, (templ->flatshade || templ->light_twoside || offset || - templ->cull_mode != PIPE_WINDING_NONE)) + templ->cull_face != PIPE_FACE_NONE)) { fill = PIPE_POLYGON_MODE_FILL; rast->need_pipeline |= SVGA_PIPELINE_FLAG_TRIS; diff --git a/src/gallium/drivers/svga/svga_resource.c b/src/gallium/drivers/svga/svga_resource.c index ba630582e59..ef2a0c40f03 100644 --- a/src/gallium/drivers/svga/svga_resource.c +++ b/src/gallium/drivers/svga/svga_resource.c @@ -33,6 +33,7 @@ svga_resource_from_handle(struct pipe_screen * screen, void svga_init_resource_functions(struct svga_context *svga) { + svga->pipe.is_resource_referenced = u_is_resource_referenced_vtbl; svga->pipe.get_transfer = u_get_transfer_vtbl; svga->pipe.transfer_map = u_transfer_map_vtbl; svga->pipe.transfer_flush_region = u_transfer_flush_region_vtbl; diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index b24af329218..99b419178b0 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -84,7 +84,7 @@ svga_get_name( struct pipe_screen *pscreen ) static float -svga_get_paramf(struct pipe_screen *screen, int param) +svga_get_paramf(struct pipe_screen *screen, enum pipe_cap param) { struct svga_screen *svgascreen = svga_screen(screen); struct svga_winsys_screen *sws = svgascreen->sws; @@ -134,6 +134,8 @@ svga_get_paramf(struct pipe_screen *screen, int param) return MIN2(result.u, PIPE_MAX_COLOR_BUFS); case PIPE_CAP_OCCLUSION_QUERY: return 1; + case PIPE_CAP_TIMER_QUERY: + return 0; case PIPE_CAP_TEXTURE_SHADOW_MAP: return 1; @@ -177,6 +179,57 @@ svga_get_paramf(struct pipe_screen *screen, int param) case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: return 0; + /* + * Fragment shader limits + */ + + case PIPE_CAP_MAX_FS_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS: + case PIPE_CAP_MAX_FS_TEX_INDIRECTIONS: + return svgascreen->use_ps30 ? 512 : 96; + case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH: + return SVGA3D_MAX_NESTING_LEVEL; + case PIPE_CAP_MAX_FS_INPUTS: + return 10; + case PIPE_CAP_MAX_FS_CONSTS: + return svgascreen->use_vs30 ? 224 : 16; + case PIPE_CAP_MAX_FS_TEMPS: + if (!sws->get_cap(sws, SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_TEMPS, &result)) + return svgascreen->use_ps30 ? 32 : 12; + return result.u; + case PIPE_CAP_MAX_FS_ADDRS: + return svgascreen->use_ps30 ? 1 : 0; + case PIPE_CAP_MAX_FS_PREDS: + return svgascreen->use_ps30 ? 1 : 0; + + /* + * Vertex shader limits + */ + case PIPE_CAP_MAX_VS_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS: + if (!sws->get_cap(sws, SVGA3D_DEVCAP_MAX_VERTEX_SHADER_INSTRUCTIONS, &result)) + return svgascreen->use_vs30 ? 512 : 256; + return result.u; + case PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS: + case PIPE_CAP_MAX_VS_TEX_INDIRECTIONS: + /* XXX: until we have vertex texture support */ + return 0; + case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH: + return SVGA3D_MAX_NESTING_LEVEL; + case PIPE_CAP_MAX_VS_INPUTS: + return 16; + case PIPE_CAP_MAX_VS_CONSTS: + return 256; + case PIPE_CAP_MAX_VS_TEMPS: + if (!sws->get_cap(sws, SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEMPS, &result)) + return svgascreen->use_vs30 ? 32 : 12; + return result.u; + case PIPE_CAP_MAX_VS_ADDRS: + return svgascreen->use_vs30 ? 1 : 0; + case PIPE_CAP_MAX_VS_PREDS: + return svgascreen->use_vs30 ? 1 : 0; + default: return 0; } @@ -186,7 +239,7 @@ svga_get_paramf(struct pipe_screen *screen, int param) /* This is a fairly pointless interface */ static int -svga_get_param(struct pipe_screen *screen, int param) +svga_get_param(struct pipe_screen *screen, enum pipe_cap param) { return (int) svga_get_paramf( screen, param ); } diff --git a/src/gallium/drivers/svga/svga_state_fs.c b/src/gallium/drivers/svga/svga_state_fs.c index 1310fd9825f..ad6f2947137 100644 --- a/src/gallium/drivers/svga/svga_state_fs.c +++ b/src/gallium/drivers/svga/svga_state_fs.c @@ -131,8 +131,7 @@ static int make_fs_key( const struct svga_context *svga, /* SVGA_NEW_RAST */ key->light_twoside = svga->curr.rast->templ.light_twoside; - key->front_cw = (svga->curr.rast->templ.front_winding == - PIPE_WINDING_CW); + key->front_ccw = svga->curr.rast->templ.front_ccw; } /* The blend workaround for simulating logicop xor behaviour diff --git a/src/gallium/drivers/svga/svga_state_rss.c b/src/gallium/drivers/svga/svga_state_rss.c index b7195d246bc..ab13f3fdf19 100644 --- a/src/gallium/drivers/svga/svga_state_rss.c +++ b/src/gallium/drivers/svga/svga_state_rss.c @@ -146,13 +146,13 @@ static int emit_rss( struct svga_context *svga, * then our definition of front face agrees with hardware. * Otherwise need to flip. */ - if (rast->templ.front_winding == PIPE_WINDING_CW) { - cw = 0; - ccw = 1; + if (rast->templ.front_ccw) { + ccw = 0; + cw = 1; } else { - cw = 1; - ccw = 0; + ccw = 1; + cw = 0; } /* Twoside stencil diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c index bd2cc380048..b21dc5fd9af 100644 --- a/src/gallium/drivers/svga/svga_surface.c +++ b/src/gallium/drivers/svga/svga_surface.c @@ -37,7 +37,6 @@ #include "svga_context.h" #include "svga_resource_texture.h" #include "svga_surface.h" -#include "svga_winsys.h" #include "svga_debug.h" diff --git a/src/gallium/drivers/svga/svga_swtnl.h b/src/gallium/drivers/svga/svga_swtnl.h index 8724690f7e1..65c675f99c9 100644 --- a/src/gallium/drivers/svga/svga_swtnl.h +++ b/src/gallium/drivers/svga/svga_swtnl.h @@ -30,7 +30,6 @@ struct svga_context; struct pipe_context; -struct pipe_buffer; struct vbuf_render; diff --git a/src/gallium/drivers/svga/svga_swtnl_backend.c b/src/gallium/drivers/svga/svga_swtnl_backend.c index b0cbead8a5c..ff3da842729 100644 --- a/src/gallium/drivers/svga/svga_swtnl_backend.c +++ b/src/gallium/drivers/svga/svga_swtnl_backend.c @@ -240,9 +240,9 @@ svga_vbuf_render_draw_arrays( struct vbuf_render *render, static void -svga_vbuf_render_draw( struct vbuf_render *render, - const ushort *indices, - uint nr_indices) +svga_vbuf_render_draw_elements( struct vbuf_render *render, + const ushort *indices, + uint nr_indices) { struct svga_vbuf_render *svga_render = svga_vbuf_render(render); struct svga_context *svga = svga_render->svga; @@ -341,7 +341,7 @@ svga_vbuf_render_create( struct svga_context *svga ) svga_render->base.map_vertices = svga_vbuf_render_map_vertices; svga_render->base.unmap_vertices = svga_vbuf_render_unmap_vertices; svga_render->base.set_primitive = svga_vbuf_render_set_primitive; - svga_render->base.draw = svga_vbuf_render_draw; + svga_render->base.draw_elements = svga_vbuf_render_draw_elements; svga_render->base.draw_arrays = svga_vbuf_render_draw_arrays; svga_render->base.release_vertices = svga_vbuf_render_release_vertices; svga_render->base.destroy = svga_vbuf_render_destroy; diff --git a/src/gallium/drivers/svga/svga_tgsi.h b/src/gallium/drivers/svga/svga_tgsi.h index 063c9cf4221..7ea909c37bf 100644 --- a/src/gallium/drivers/svga/svga_tgsi.h +++ b/src/gallium/drivers/svga/svga_tgsi.h @@ -48,7 +48,7 @@ struct svga_vs_compile_key struct svga_fs_compile_key { unsigned light_twoside:1; - unsigned front_cw:1; + unsigned front_ccw:1; unsigned white_fragments:1; unsigned num_textures:8; unsigned num_unnormalized_coords:8; diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c b/src/gallium/drivers/svga/svga_tgsi_insn.c index 7d7024c4a7d..67e1f22a701 100644 --- a/src/gallium/drivers/svga/svga_tgsi_insn.c +++ b/src/gallium/drivers/svga/svga_tgsi_insn.c @@ -2588,10 +2588,10 @@ static boolean emit_light_twoside( struct svga_shader_emitter *emit ) if_token = inst_token( SVGA3DOP_IFC ); - if (emit->key.fkey.front_cw) - if_token.control = SVGA3DOPCOMP_GT; - else + if (emit->key.fkey.front_ccw) if_token.control = SVGA3DOPCOMP_LT; + else + if_token.control = SVGA3DOPCOMP_GT; zero = scalar(zero, TGSI_SWIZZLE_X); @@ -2639,12 +2639,12 @@ static boolean emit_frontface( struct svga_shader_emitter *emit ) temp = dst_register( SVGA3DREG_TEMP, emit->nr_hw_temp++ ); - if (emit->key.fkey.front_cw) { - pass = scalar( zero, TGSI_SWIZZLE_W ); - fail = scalar( zero, TGSI_SWIZZLE_X ); - } else { + if (emit->key.fkey.front_ccw) { pass = scalar( zero, TGSI_SWIZZLE_X ); fail = scalar( zero, TGSI_SWIZZLE_W ); + } else { + pass = scalar( zero, TGSI_SWIZZLE_W ); + fail = scalar( zero, TGSI_SWIZZLE_X ); } if (!emit_conditional(emit, PIPE_FUNC_GREATER, diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile index 78f6347dc72..1b0c087a2a4 100644 --- a/src/gallium/drivers/trace/Makefile +++ b/src/gallium/drivers/trace/Makefile @@ -8,8 +8,6 @@ C_SOURCES = \ tr_dump.c \ tr_dump_state.c \ tr_screen.c \ - tr_state.c \ - tr_rbug.c \ tr_drm.c \ tr_texture.c diff --git a/src/gallium/drivers/trace/README b/src/gallium/drivers/trace/README index 203c3851bc3..cdcd8d2b4be 100644 --- a/src/gallium/drivers/trace/README +++ b/src/gallium/drivers/trace/README @@ -3,15 +3,15 @@ = About = -This directory contains a Gallium3D debugger pipe driver. -It can traces all incoming calls and/or provide remote debugging functionality. +This directory contains a Gallium3D trace debugger pipe driver. +It can traces all incoming calls. = Build Instructions = To build, invoke scons on the top dir as - scons dri=no statetrackers=mesa drivers=softpipe,i965simple,trace winsys=xlib + scons dri=no statetrackers=mesa winsys=xlib = Usage = @@ -36,40 +36,27 @@ Firefox or Internet Explorer. == Remote debugging == -For remote debugging +For remote debugging see: - export XMESA_TRACE=y - GALLIUM_RBUG=true progs/trivial/tri - -which should open gallium remote debugging session. While the program is running -you can launch the small remote debugging application from progs/rbug. More -information is in that directory. + src/gallium/drivers/rbug/README = Integrating = You can integrate the trace pipe driver either inside the state tracker or the -winsys. The procedure on both cases is the same. Let's assume you have a -pipe_screen and a pipe_context pair obtained by the usual means (variable and -function names are just for illustration purposes): +target. The procedure on both cases is the same. Let's assume you have a +pipe_screen obtained by the usual means (variable and function names are just +for illustration purposes): real_screen = real_screen_create(...); - real_context = real_context_create(...); - -The trace screen and pipe_context is then created by doing +The trace screen is then created by doing trace_screen = trace_screen_create(real_screen); - - trace_context = trace_context_create(trace_screen, real_context); - -You can then simply use trace_screen and trace_context instead of real_screen -and real_context. -Do not call trace_winsys_create. Simply pass trace_screen->winsys or -trace_context->winsys in places you would pass winsys. +You can then simply use trace_screen instead of real_screen. -You can create as many contexts you wish. Just ensure that you don't mistake -trace_screen with real_screen when creating them. +You can create as many contexts you wish from trace_screen::context_create they +are automatically wrapped by trace_screen. -- diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript index 5f1fb17966a..0dc43a9ec41 100644 --- a/src/gallium/drivers/trace/SConscript +++ b/src/gallium/drivers/trace/SConscript @@ -10,8 +10,6 @@ trace = env.ConvenienceLibrary( 'tr_dump.c', 'tr_dump_state.c', 'tr_screen.c', - 'tr_state.c', - 'tr_rbug.c', 'tr_texture.c', ]) diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 64a4316984b..5cc244d4b77 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -28,16 +28,16 @@ #include "util/u_inlines.h" #include "util/u_memory.h" #include "util/u_simple_list.h" -#include "util/u_format.h" #include "pipe/p_format.h" #include "pipe/p_screen.h" #include "tr_dump.h" #include "tr_dump_state.h" -#include "tr_state.h" +#include "tr_public.h" #include "tr_screen.h" #include "tr_texture.h" +#include "tr_context.h" @@ -83,82 +83,12 @@ trace_surface_unwrap(struct trace_context *tr_ctx, static INLINE void -trace_context_draw_block(struct trace_context *tr_ctx, int flag) -{ - int k; - - pipe_mutex_lock(tr_ctx->draw_mutex); - - if (tr_ctx->draw_blocker & flag) { - tr_ctx->draw_blocked |= flag; - } else if ((tr_ctx->draw_rule.blocker & flag) && - (tr_ctx->draw_blocker & 4)) { - boolean block = FALSE; - debug_printf("%s (%p %p) (%p %p) (%p %u) (%p %u)\n", __FUNCTION__, - (void *) tr_ctx->draw_rule.fs, (void *) tr_ctx->curr.fs, - (void *) tr_ctx->draw_rule.vs, (void *) tr_ctx->curr.vs, - (void *) tr_ctx->draw_rule.surf, 0, - (void *) tr_ctx->draw_rule.sampler_view, 0); - if (tr_ctx->draw_rule.fs && - tr_ctx->draw_rule.fs == tr_ctx->curr.fs) - block = TRUE; - if (tr_ctx->draw_rule.vs && - tr_ctx->draw_rule.vs == tr_ctx->curr.vs) - block = TRUE; - if (tr_ctx->draw_rule.surf && - tr_ctx->draw_rule.surf == tr_ctx->curr.zsbuf) - block = TRUE; - if (tr_ctx->draw_rule.surf) - for (k = 0; k < tr_ctx->curr.nr_cbufs; k++) - if (tr_ctx->draw_rule.surf == tr_ctx->curr.cbufs[k]) - block = TRUE; - if (tr_ctx->draw_rule.sampler_view) { - for (k = 0; k < tr_ctx->curr.num_sampler_views; k++) - if (tr_ctx->draw_rule.sampler_view == tr_ctx->curr.sampler_views[k]) - block = TRUE; - for (k = 0; k < tr_ctx->curr.num_vert_sampler_views; k++) { - if (tr_ctx->draw_rule.sampler_view == tr_ctx->curr.vert_sampler_views[k]) { - block = TRUE; - } - } - } - - if (block) - tr_ctx->draw_blocked |= (flag | 4); - } - - if (tr_ctx->draw_blocked) - trace_rbug_notify_draw_blocked(tr_ctx); - - /* wait for rbug to clear the blocked flag */ - while (tr_ctx->draw_blocked & flag) { - tr_ctx->draw_blocked |= flag; -#ifdef PIPE_THREAD_HAVE_CONDVAR - pipe_condvar_wait(tr_ctx->draw_cond, tr_ctx->draw_mutex); -#else - pipe_mutex_unlock(tr_ctx->draw_mutex); -#ifdef PIPE_SUBSYSTEM_WINDOWS_USER - Sleep(1); -#endif - pipe_mutex_lock(tr_ctx->draw_mutex); -#endif - } - - pipe_mutex_unlock(tr_ctx->draw_mutex); -} - -static INLINE void trace_context_draw_arrays(struct pipe_context *_pipe, unsigned mode, unsigned start, unsigned count) { struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; - if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled) - return; - - trace_context_draw_block(tr_ctx, 1); - trace_dump_call_begin("pipe_context", "draw_arrays"); trace_dump_arg(ptr, pipe); @@ -169,8 +99,6 @@ trace_context_draw_arrays(struct pipe_context *_pipe, pipe->draw_arrays(pipe, mode, start, count); trace_dump_call_end(); - - trace_context_draw_block(tr_ctx, 2); } @@ -185,11 +113,6 @@ trace_context_draw_elements(struct pipe_context *_pipe, struct pipe_context *pipe = tr_ctx->pipe; struct pipe_resource *indexBuffer = tr_buf->resource; - if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled) - return; - - trace_context_draw_block(tr_ctx, 1); - trace_dump_call_begin("pipe_context", "draw_elements"); trace_dump_arg(ptr, pipe); @@ -204,8 +127,6 @@ trace_context_draw_elements(struct pipe_context *_pipe, mode, start, count); trace_dump_call_end(); - - trace_context_draw_block(tr_ctx, 2); } @@ -225,11 +146,6 @@ trace_context_draw_range_elements(struct pipe_context *_pipe, struct pipe_context *pipe = tr_ctx->pipe; struct pipe_resource *indexBuffer = tr_buf->resource; - if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled) - return; - - trace_context_draw_block(tr_ctx, 1); - trace_dump_call_begin("pipe_context", "draw_range_elements"); trace_dump_arg(ptr, pipe); @@ -248,8 +164,6 @@ trace_context_draw_range_elements(struct pipe_context *_pipe, mode, start, count); trace_dump_call_end(); - - trace_context_draw_block(tr_ctx, 2); } @@ -634,31 +548,22 @@ trace_context_create_fs_state(struct pipe_context *_pipe, trace_dump_call_end(); - result = trace_shader_create(tr_ctx, state, result, TRACE_SHADER_FRAGMENT); - return result; } static INLINE void trace_context_bind_fs_state(struct pipe_context *_pipe, - void *_state) + void *state) { struct trace_context *tr_ctx = trace_context(_pipe); - struct trace_shader *tr_shdr = trace_shader(_state); struct pipe_context *pipe = tr_ctx->pipe; - void *state = tr_shdr ? tr_shdr->state : NULL; trace_dump_call_begin("pipe_context", "bind_fs_state"); trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, state); - tr_ctx->curr.fs = tr_shdr; - - if (tr_shdr && tr_shdr->replaced) - state = tr_shdr->replaced; - pipe->bind_fs_state(pipe, state); trace_dump_call_end(); @@ -667,12 +572,10 @@ trace_context_bind_fs_state(struct pipe_context *_pipe, static INLINE void trace_context_delete_fs_state(struct pipe_context *_pipe, - void *_state) + void *state) { struct trace_context *tr_ctx = trace_context(_pipe); - struct trace_shader *tr_shdr = trace_shader(_state); struct pipe_context *pipe = tr_ctx->pipe; - void *state = tr_shdr->state; trace_dump_call_begin("pipe_context", "delete_fs_state"); @@ -682,8 +585,6 @@ trace_context_delete_fs_state(struct pipe_context *_pipe, pipe->delete_fs_state(pipe, state); trace_dump_call_end(); - - trace_shader_destroy(tr_ctx, tr_shdr); } @@ -706,31 +607,22 @@ trace_context_create_vs_state(struct pipe_context *_pipe, trace_dump_call_end(); - result = trace_shader_create(tr_ctx, state, result, TRACE_SHADER_VERTEX); - return result; } static INLINE void trace_context_bind_vs_state(struct pipe_context *_pipe, - void *_state) + void *state) { struct trace_context *tr_ctx = trace_context(_pipe); - struct trace_shader *tr_shdr = trace_shader(_state); struct pipe_context *pipe = tr_ctx->pipe; - void *state = tr_shdr ? tr_shdr->state : NULL; trace_dump_call_begin("pipe_context", "bind_vs_state"); trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, state); - tr_ctx->curr.vs = tr_shdr; - - if (tr_shdr && tr_shdr->replaced) - state = tr_shdr->replaced; - pipe->bind_vs_state(pipe, state); trace_dump_call_end(); @@ -739,12 +631,10 @@ trace_context_bind_vs_state(struct pipe_context *_pipe, static INLINE void trace_context_delete_vs_state(struct pipe_context *_pipe, - void *_state) + void *state) { struct trace_context *tr_ctx = trace_context(_pipe); - struct trace_shader *tr_shdr = trace_shader(_state); struct pipe_context *pipe = tr_ctx->pipe; - void *state = tr_shdr->state; trace_dump_call_begin("pipe_context", "delete_vs_state"); @@ -754,8 +644,6 @@ trace_context_delete_vs_state(struct pipe_context *_pipe, pipe->delete_vs_state(pipe, state); trace_dump_call_end(); - - trace_shader_destroy(tr_ctx, tr_shdr); } @@ -927,18 +815,6 @@ trace_context_set_framebuffer_state(struct pipe_context *_pipe, struct pipe_framebuffer_state unwrapped_state; unsigned i; - { - tr_ctx->curr.nr_cbufs = state->nr_cbufs; - for (i = 0; i < state->nr_cbufs; i++) - if (state->cbufs[i]) - tr_ctx->curr.cbufs[i] = trace_resource(state->cbufs[i]->texture); - else - tr_ctx->curr.cbufs[i] = NULL; - if (state->zsbuf) - tr_ctx->curr.zsbuf = trace_resource(state->zsbuf->texture); - else - tr_ctx->curr.zsbuf = NULL; - } /* Unwrap the input state */ memcpy(&unwrapped_state, state, sizeof(unwrapped_state)); @@ -1088,10 +964,8 @@ trace_context_set_fragment_sampler_views(struct pipe_context *_pipe, struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS]; unsigned i; - tr_ctx->curr.num_sampler_views = num; for(i = 0; i < num; ++i) { tr_view = trace_sampler_view(views[i]); - tr_ctx->curr.sampler_views[i] = tr_view; unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL; } views = unwrapped_views; @@ -1119,10 +993,8 @@ trace_context_set_vertex_sampler_views(struct pipe_context *_pipe, struct pipe_sampler_view *unwrapped_views[PIPE_MAX_VERTEX_SAMPLERS]; unsigned i; - tr_ctx->curr.num_vert_sampler_views = num; for(i = 0; i < num; ++i) { tr_view = trace_sampler_view(views[i]); - tr_ctx->curr.vert_sampler_views[i] = tr_view; unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL; } views = unwrapped_views; @@ -1293,7 +1165,6 @@ trace_context_flush(struct pipe_context *_pipe, static INLINE void trace_context_destroy(struct pipe_context *_pipe) { - struct trace_screen *tr_scr = trace_screen(_pipe->screen); struct trace_context *tr_ctx = trace_context(_pipe); struct pipe_context *pipe = tr_ctx->pipe; @@ -1301,8 +1172,6 @@ trace_context_destroy(struct pipe_context *_pipe) trace_dump_arg(ptr, pipe); trace_dump_call_end(); - trace_screen_remove_from_list(tr_scr, contexts, tr_ctx); - pipe->destroy(pipe); FREE(tr_ctx); @@ -1535,13 +1404,6 @@ trace_context_create(struct trace_screen *tr_scr, tr_ctx->base.winsys = NULL; tr_ctx->base.priv = pipe->priv; /* expose wrapped priv data */ tr_ctx->base.screen = &tr_scr->base; - tr_ctx->draw_blocker = debug_get_flags_option("RBUG_BLOCK", - rbug_blocker_flags, - 0); - pipe_mutex_init(tr_ctx->draw_mutex); - pipe_condvar_init(tr_ctx->draw_cond); - pipe_mutex_init(tr_ctx->list_mutex); - make_empty_list(&tr_ctx->shaders); tr_ctx->base.destroy = trace_context_destroy; tr_ctx->base.draw_arrays = trace_context_draw_arrays; @@ -1603,8 +1465,6 @@ trace_context_create(struct trace_screen *tr_scr, tr_ctx->pipe = pipe; - trace_screen_add_to_list(tr_scr, contexts, tr_ctx); - return &tr_ctx->base; error1: diff --git a/src/gallium/drivers/trace/tr_context.h b/src/gallium/drivers/trace/tr_context.h index 1b4121d80a9..dadbe561180 100644 --- a/src/gallium/drivers/trace/tr_context.h +++ b/src/gallium/drivers/trace/tr_context.h @@ -47,45 +47,6 @@ struct trace_context struct pipe_context base; struct pipe_context *pipe; - - /* current state */ - struct { - struct trace_shader *fs; - struct trace_shader *vs; - - struct trace_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; - unsigned num_sampler_views; - - struct trace_sampler_view *vert_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; - unsigned num_vert_sampler_views; - - unsigned nr_cbufs; - struct trace_resource *cbufs[PIPE_MAX_COLOR_BUFS]; - struct trace_resource *zsbuf; - } curr; - - struct { - struct trace_shader *fs; - struct trace_shader *vs; - - struct trace_sampler_view *sampler_view; - struct trace_resource *surf; - - int blocker; - } draw_rule; - unsigned draw_num_rules; - pipe_condvar draw_cond; - pipe_mutex draw_mutex; - int draw_blocker; - int draw_blocked; - - /* for list on screen */ - struct tr_list list; - - /* list of state objects */ - pipe_mutex list_mutex; - unsigned num_shaders; - struct tr_list shaders; }; @@ -101,9 +62,6 @@ struct pipe_context * trace_context_create(struct trace_screen *tr_scr, struct pipe_context *pipe); -void -trace_rbug_notify_draw_blocked(struct trace_context *tr_ctx); - #ifdef __cplusplus } diff --git a/src/gallium/drivers/trace/tr_drm.c b/src/gallium/drivers/trace/tr_drm.c index 0dc8cca2648..9c7d39201a9 100644 --- a/src/gallium/drivers/trace/tr_drm.c +++ b/src/gallium/drivers/trace/tr_drm.c @@ -28,6 +28,7 @@ #include "state_tracker/drm_api.h" #include "util/u_memory.h" +#include "rbug/rbug_public.h" #include "tr_drm.h" #include "tr_screen.h" #include "tr_public.h" @@ -61,7 +62,7 @@ trace_drm_create_screen(struct drm_api *_api, int fd, screen = api->create_screen(api, fd, arg); - return trace_screen_create(screen); + return trace_screen_create(rbug_screen_create(screen)); } static void @@ -84,7 +85,7 @@ trace_drm_create(struct drm_api *api) if (!api) goto error; - if (!trace_enabled()) + if (!trace_enabled() && !rbug_enabled()) goto error; tr_api = CALLOC_STRUCT(trace_drm_api); diff --git a/src/gallium/drivers/trace/tr_dump.h b/src/gallium/drivers/trace/tr_dump.h index f21f72b0c79..74c5e83e9e1 100644 --- a/src/gallium/drivers/trace/tr_dump.h +++ b/src/gallium/drivers/trace/tr_dump.h @@ -37,7 +37,6 @@ #include "pipe/p_compiler.h" #include "pipe/p_format.h" -struct pipe_buffer; struct pipe_resource; struct pipe_surface; struct pipe_transfer; diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c index f148a859ff3..1727c2a0206 100644 --- a/src/gallium/drivers/trace/tr_dump_state.c +++ b/src/gallium/drivers/trace/tr_dump_state.c @@ -136,12 +136,13 @@ void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state) trace_dump_member(bool, state, flatshade); trace_dump_member(bool, state, light_twoside); - trace_dump_member(uint, state, front_winding); - trace_dump_member(uint, state, cull_mode); - trace_dump_member(uint, state, fill_cw); - trace_dump_member(uint, state, fill_ccw); - trace_dump_member(bool, state, offset_cw); - trace_dump_member(bool, state, offset_ccw); + trace_dump_member(uint, state, front_ccw); + trace_dump_member(uint, state, cull_face); + trace_dump_member(uint, state, fill_front); + trace_dump_member(uint, state, fill_back); + trace_dump_member(bool, state, offset_point); + trace_dump_member(bool, state, offset_line); + trace_dump_member(bool, state, offset_tri); trace_dump_member(bool, state, scissor); trace_dump_member(bool, state, poly_smooth); trace_dump_member(bool, state, poly_stipple_enable); diff --git a/src/gallium/drivers/trace/tr_public.h b/src/gallium/drivers/trace/tr_public.h index 62e217097d0..aee4937dd4f 100644 --- a/src/gallium/drivers/trace/tr_public.h +++ b/src/gallium/drivers/trace/tr_public.h @@ -38,6 +38,9 @@ struct pipe_context; struct pipe_screen * trace_screen_create(struct pipe_screen *screen); +boolean +trace_enabled(void); + #ifdef __cplusplus } #endif diff --git a/src/gallium/drivers/trace/tr_rbug.c b/src/gallium/drivers/trace/tr_rbug.c deleted file mode 100644 index 3ce1b85854b..00000000000 --- a/src/gallium/drivers/trace/tr_rbug.c +++ /dev/null @@ -1,864 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -#include "os/os_thread.h" -#include "util/u_format.h" -#include "util/u_string.h" -#include "util/u_inlines.h" -#include "util/u_memory.h" -#include "util/u_simple_list.h" -#include "util/u_network.h" -#include "os/os_time.h" - -#include "tgsi/tgsi_parse.h" - -#include "tr_dump.h" -#include "tr_state.h" -#include "tr_texture.h" - -#include "rbug/rbug.h" - -#include <errno.h> - -#define U642VOID(x) ((void *)(unsigned long)(x)) -#define VOID2U64(x) ((uint64_t)(unsigned long)(x)) - -struct trace_rbug -{ - struct trace_screen *tr_scr; - struct rbug_connection *con; - pipe_thread thread; - boolean running; -}; - -PIPE_THREAD_ROUTINE(trace_rbug_thread, void_tr_rbug); - - -/********************************************************** - * Helper functions - */ - - -static struct trace_context * -trace_rbug_get_context_locked(struct trace_screen *tr_scr, rbug_context_t ctx) -{ - struct trace_context *tr_ctx = NULL; - struct tr_list *ptr; - - foreach(ptr, &tr_scr->contexts) { - tr_ctx = (struct trace_context *)((char*)ptr - offsetof(struct trace_context, list)); - if (ctx == VOID2U64(tr_ctx)) - break; - tr_ctx = NULL; - } - - return tr_ctx; -} - -static struct trace_shader * -trace_rbug_get_shader_locked(struct trace_context *tr_ctx, rbug_shader_t shdr) -{ - struct trace_shader *tr_shdr = NULL; - struct tr_list *ptr; - - foreach(ptr, &tr_ctx->shaders) { - tr_shdr = (struct trace_shader *)((char*)ptr - offsetof(struct trace_shader, list)); - if (shdr == VOID2U64(tr_shdr)) - break; - tr_shdr = NULL; - } - - return tr_shdr; -} - -static void * -trace_shader_create_locked(struct pipe_context *pipe, - struct trace_shader *tr_shdr, - struct tgsi_token *tokens) -{ - void *state = NULL; - struct pipe_shader_state pss = { 0 }; - pss.tokens = tokens; - - if (tr_shdr->type == TRACE_SHADER_FRAGMENT) { - state = pipe->create_fs_state(pipe, &pss); - } else if (tr_shdr->type == TRACE_SHADER_VERTEX) { - state = pipe->create_vs_state(pipe, &pss); - } else - assert(0); - - return state; -} - -static void -trace_shader_bind_locked(struct pipe_context *pipe, - struct trace_shader *tr_shdr, - void *state) -{ - if (tr_shdr->type == TRACE_SHADER_FRAGMENT) { - pipe->bind_fs_state(pipe, state); - } else if (tr_shdr->type == TRACE_SHADER_VERTEX) { - pipe->bind_vs_state(pipe, state); - } else - assert(0); -} - -static void -trace_shader_delete_locked(struct pipe_context *pipe, - struct trace_shader *tr_shdr, - void *state) -{ - if (tr_shdr->type == TRACE_SHADER_FRAGMENT) { - pipe->delete_fs_state(pipe, state); - } else if (tr_shdr->type == TRACE_SHADER_VERTEX) { - pipe->delete_vs_state(pipe, state); - } else - assert(0); -} - -/************************************************ - * Request handler functions - */ - - -static int -trace_rbug_texture_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_resource *tr_tex = NULL; - struct tr_list *ptr; - rbug_texture_t *texs; - int i = 0; - - pipe_mutex_lock(tr_scr->list_mutex); - texs = MALLOC(tr_scr->num_textures * sizeof(rbug_texture_t)); - foreach(ptr, &tr_scr->textures) { - tr_tex = (struct trace_resource *)((char*)ptr - offsetof(struct trace_resource, list)); - texs[i++] = VOID2U64(tr_tex); - } - pipe_mutex_unlock(tr_scr->list_mutex); - - rbug_send_texture_list_reply(tr_rbug->con, serial, texs, i, NULL); - FREE(texs); - - return 0; -} - -static int -trace_rbug_texture_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_resource *tr_tex = NULL; - struct rbug_proto_texture_info *gpti = (struct rbug_proto_texture_info *)header; - struct tr_list *ptr; - struct pipe_resource *t; - - pipe_mutex_lock(tr_scr->list_mutex); - foreach(ptr, &tr_scr->textures) { - tr_tex = (struct trace_resource *)((char*)ptr - offsetof(struct trace_resource, list)); - if (gpti->texture == VOID2U64(tr_tex)) - break; - tr_tex = NULL; - } - - if (!tr_tex) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - t = tr_tex->resource; - rbug_send_texture_info_reply(tr_rbug->con, serial, - t->target, t->format, - &t->width0, 1, - &t->height0, 1, - &t->depth0, 1, - util_format_get_blockwidth(t->format), - util_format_get_blockheight(t->format), - util_format_get_blocksize(t->format), - t->last_level, - t->nr_samples, - t->bind, - NULL); - - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_texture_read *gptr = (struct rbug_proto_texture_read *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_resource *tr_tex = NULL; - struct tr_list *ptr; - - struct pipe_context *context = tr_scr->private_context; - struct pipe_resource *tex; - struct pipe_transfer *t; - - void *map; - - pipe_mutex_lock(tr_scr->list_mutex); - foreach(ptr, &tr_scr->textures) { - tr_tex = (struct trace_resource *)((char*)ptr - offsetof(struct trace_resource, list)); - if (gptr->texture == VOID2U64(tr_tex)) - break; - tr_tex = NULL; - } - - if (!tr_tex) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - tex = tr_tex->resource; - t = pipe_get_transfer(context, tex, - gptr->face, gptr->level, gptr->zslice, - PIPE_TRANSFER_READ, - gptr->x, gptr->y, gptr->w, gptr->h); - - map = context->transfer_map(context, t); - - rbug_send_texture_read_reply(tr_rbug->con, serial, - t->resource->format, - util_format_get_blockwidth(t->resource->format), - util_format_get_blockheight(t->resource->format), - util_format_get_blocksize(t->resource->format), - (uint8_t*)map, - t->stride * util_format_get_nblocksy(t->resource->format, - t->box.height), - t->stride, - NULL); - - context->transfer_unmap(context, t); - context->transfer_destroy(context, t); - - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_context_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct tr_list *ptr; - struct trace_context *tr_ctx = NULL; - rbug_context_t *ctxs; - int i = 0; - - pipe_mutex_lock(tr_scr->list_mutex); - ctxs = MALLOC(tr_scr->num_contexts * sizeof(rbug_context_t)); - foreach(ptr, &tr_scr->contexts) { - tr_ctx = (struct trace_context *)((char*)ptr - offsetof(struct trace_context, list)); - ctxs[i++] = VOID2U64(tr_ctx); - } - pipe_mutex_unlock(tr_scr->list_mutex); - - rbug_send_context_list_reply(tr_rbug->con, serial, ctxs, i, NULL); - FREE(ctxs); - - return 0; -} - -static int -trace_rbug_context_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_context_info *info = (struct rbug_proto_context_info *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - rbug_texture_t cbufs[PIPE_MAX_COLOR_BUFS]; - rbug_texture_t texs[PIPE_MAX_SAMPLERS]; - int i; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, info->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - /* protect the pipe context */ - pipe_mutex_lock(tr_ctx->draw_mutex); - trace_dump_call_lock(); - - for (i = 0; i < tr_ctx->curr.nr_cbufs; i++) - cbufs[i] = VOID2U64(tr_ctx->curr.cbufs[i]); - - for (i = 0; i < tr_ctx->curr.num_sampler_views; i++) - texs[i] = VOID2U64(tr_ctx->curr.sampler_views[i]); - - rbug_send_context_info_reply(tr_rbug->con, serial, - VOID2U64(tr_ctx->curr.vs), VOID2U64(tr_ctx->curr.fs), - texs, tr_ctx->curr.num_sampler_views, - cbufs, tr_ctx->curr.nr_cbufs, - VOID2U64(tr_ctx->curr.zsbuf), - tr_ctx->draw_blocker, tr_ctx->draw_blocked, NULL); - - trace_dump_call_unlock(); - pipe_mutex_unlock(tr_ctx->draw_mutex); - - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_context_draw_block(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_context_draw_block *block = (struct rbug_proto_context_draw_block *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, block->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->draw_mutex); - tr_ctx->draw_blocker |= block->block; - pipe_mutex_unlock(tr_ctx->draw_mutex); - - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_context_draw_step(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_context_draw_step *step = (struct rbug_proto_context_draw_step *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, step->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->draw_mutex); - if (tr_ctx->draw_blocked & RBUG_BLOCK_RULE) { - if (step->step & RBUG_BLOCK_RULE) - tr_ctx->draw_blocked &= ~RBUG_BLOCK_MASK; - } else { - tr_ctx->draw_blocked &= ~step->step; - } - pipe_mutex_unlock(tr_ctx->draw_mutex); - -#ifdef PIPE_THREAD_HAVE_CONDVAR - pipe_condvar_broadcast(tr_ctx->draw_cond); -#endif - - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_context_draw_unblock(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_context_draw_unblock *unblock = (struct rbug_proto_context_draw_unblock *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, unblock->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->draw_mutex); - if (tr_ctx->draw_blocked & RBUG_BLOCK_RULE) { - if (unblock->unblock & RBUG_BLOCK_RULE) - tr_ctx->draw_blocked &= ~RBUG_BLOCK_MASK; - } else { - tr_ctx->draw_blocked &= ~unblock->unblock; - } - tr_ctx->draw_blocker &= ~unblock->unblock; - pipe_mutex_unlock(tr_ctx->draw_mutex); - -#ifdef PIPE_THREAD_HAVE_CONDVAR - pipe_condvar_broadcast(tr_ctx->draw_cond); -#endif - - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_context_draw_rule(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_context_draw_rule *rule = (struct rbug_proto_context_draw_rule *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, rule->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->draw_mutex); - tr_ctx->draw_rule.vs = U642VOID(rule->vertex); - tr_ctx->draw_rule.fs = U642VOID(rule->fragment); - tr_ctx->draw_rule.sampler_view = U642VOID(rule->texture); - tr_ctx->draw_rule.surf = U642VOID(rule->surface); - tr_ctx->draw_rule.blocker = rule->block; - tr_ctx->draw_blocker |= RBUG_BLOCK_RULE; - pipe_mutex_unlock(tr_ctx->draw_mutex); - -#ifdef PIPE_THREAD_HAVE_CONDVAR - pipe_condvar_broadcast(tr_ctx->draw_cond); -#endif - - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_context_flush(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_context_flush *flush = (struct rbug_proto_context_flush *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, flush->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - /* protect the pipe context */ - trace_dump_call_lock(); - - tr_ctx->pipe->flush(tr_ctx->pipe, flush->flags, NULL); - - trace_dump_call_unlock(); - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_shader_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_shader_list *list = (struct rbug_proto_shader_list *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - struct trace_shader *tr_shdr = NULL; - struct tr_list *ptr; - rbug_shader_t *shdrs; - int i = 0; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, list->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->list_mutex); - shdrs = MALLOC(tr_ctx->num_shaders * sizeof(rbug_shader_t)); - foreach(ptr, &tr_ctx->shaders) { - tr_shdr = (struct trace_shader *)((char*)ptr - offsetof(struct trace_shader, list)); - shdrs[i++] = VOID2U64(tr_shdr); - } - - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - - rbug_send_shader_list_reply(tr_rbug->con, serial, shdrs, i, NULL); - FREE(shdrs); - - return 0; -} - -static int -trace_rbug_shader_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - struct rbug_proto_shader_info *info = (struct rbug_proto_shader_info *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - struct trace_shader *tr_shdr = NULL; - unsigned original_len; - unsigned replaced_len; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, info->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->list_mutex); - - tr_shdr = trace_rbug_get_shader_locked(tr_ctx, info->shader); - - if (!tr_shdr) { - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - /* just in case */ - assert(sizeof(struct tgsi_token) == 4); - - original_len = tgsi_num_tokens(tr_shdr->tokens); - if (tr_shdr->replaced_tokens) - replaced_len = tgsi_num_tokens(tr_shdr->replaced_tokens); - else - replaced_len = 0; - - rbug_send_shader_info_reply(tr_rbug->con, serial, - (uint32_t*)tr_shdr->tokens, original_len, - (uint32_t*)tr_shdr->replaced_tokens, replaced_len, - tr_shdr->disabled, - NULL); - - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_shader_disable(struct trace_rbug *tr_rbug, struct rbug_header *header) -{ - struct rbug_proto_shader_disable *dis = (struct rbug_proto_shader_disable *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - struct trace_shader *tr_shdr = NULL; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, dis->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->list_mutex); - - tr_shdr = trace_rbug_get_shader_locked(tr_ctx, dis->shader); - - if (!tr_shdr) { - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - tr_shdr->disabled = dis->disable; - - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; -} - -static int -trace_rbug_shader_replace(struct trace_rbug *tr_rbug, struct rbug_header *header) -{ - struct rbug_proto_shader_replace *rep = (struct rbug_proto_shader_replace *)header; - - struct trace_screen *tr_scr = tr_rbug->tr_scr; - struct trace_context *tr_ctx = NULL; - struct trace_shader *tr_shdr = NULL; - struct pipe_context *pipe = NULL; - void *state; - - pipe_mutex_lock(tr_scr->list_mutex); - tr_ctx = trace_rbug_get_context_locked(tr_scr, rep->context); - - if (!tr_ctx) { - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - pipe_mutex_lock(tr_ctx->list_mutex); - - tr_shdr = trace_rbug_get_shader_locked(tr_ctx, rep->shader); - - if (!tr_shdr) { - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - return -ESRCH; - } - - /* protect the pipe context */ - trace_dump_call_lock(); - - pipe = tr_ctx->pipe; - - /* remove old replaced shader */ - if (tr_shdr->replaced) { - if (tr_ctx->curr.fs == tr_shdr || tr_ctx->curr.vs == tr_shdr) - trace_shader_bind_locked(pipe, tr_shdr, tr_shdr->state); - - FREE(tr_shdr->replaced_tokens); - trace_shader_delete_locked(pipe, tr_shdr, tr_shdr->replaced); - tr_shdr->replaced = NULL; - tr_shdr->replaced_tokens = NULL; - } - - /* empty inputs means restore old which we did above */ - if (rep->tokens_len == 0) - goto out; - - tr_shdr->replaced_tokens = tgsi_dup_tokens((struct tgsi_token *)rep->tokens); - if (!tr_shdr->replaced_tokens) - goto err; - - state = trace_shader_create_locked(pipe, tr_shdr, tr_shdr->replaced_tokens); - if (!state) - goto err; - - /* bind new shader if the shader is currently a bound */ - if (tr_ctx->curr.fs == tr_shdr || tr_ctx->curr.vs == tr_shdr) - trace_shader_bind_locked(pipe, tr_shdr, state); - - /* save state */ - tr_shdr->replaced = state; - -out: - trace_dump_call_unlock(); - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - - return 0; - -err: - FREE(tr_shdr->replaced_tokens); - tr_shdr->replaced = NULL; - tr_shdr->replaced_tokens = NULL; - - trace_dump_call_unlock(); - pipe_mutex_unlock(tr_ctx->list_mutex); - pipe_mutex_unlock(tr_scr->list_mutex); - return -EINVAL; -} - -static boolean -trace_rbug_header(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial) -{ - int ret = 0; - - switch(header->opcode) { - case RBUG_OP_PING: - rbug_send_ping_reply(tr_rbug->con, serial, NULL); - break; - case RBUG_OP_TEXTURE_LIST: - ret = trace_rbug_texture_list(tr_rbug, header, serial); - break; - case RBUG_OP_TEXTURE_INFO: - ret = trace_rbug_texture_info(tr_rbug, header, serial); - break; - case RBUG_OP_TEXTURE_READ: - ret = trace_rbug_texture_read(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_LIST: - ret = trace_rbug_context_list(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_INFO: - ret = trace_rbug_context_info(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_DRAW_BLOCK: - ret = trace_rbug_context_draw_block(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_DRAW_STEP: - ret = trace_rbug_context_draw_step(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_DRAW_UNBLOCK: - ret = trace_rbug_context_draw_unblock(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_DRAW_RULE: - ret = trace_rbug_context_draw_rule(tr_rbug, header, serial); - break; - case RBUG_OP_CONTEXT_FLUSH: - ret = trace_rbug_context_flush(tr_rbug, header, serial); - break; - case RBUG_OP_SHADER_LIST: - ret = trace_rbug_shader_list(tr_rbug, header, serial); - break; - case RBUG_OP_SHADER_INFO: - ret = trace_rbug_shader_info(tr_rbug, header, serial); - break; - case RBUG_OP_SHADER_DISABLE: - ret = trace_rbug_shader_disable(tr_rbug, header); - break; - case RBUG_OP_SHADER_REPLACE: - ret = trace_rbug_shader_replace(tr_rbug, header); - break; - default: - debug_printf("%s - unsupported opcode %u\n", __FUNCTION__, header->opcode); - ret = -ENOSYS; - break; - } - rbug_free_header(header); - - if (ret) - rbug_send_error_reply(tr_rbug->con, serial, ret, NULL); - - return TRUE; -} - -static void -trace_rbug_con(struct trace_rbug *tr_rbug) -{ - struct rbug_header *header; - uint32_t serial; - - debug_printf("%s - connection received\n", __FUNCTION__); - - while(tr_rbug->running) { - header = rbug_get_message(tr_rbug->con, &serial); - if (!header) - break; - - if (!trace_rbug_header(tr_rbug, header, serial)) - break; - } - - debug_printf("%s - connection closed\n", __FUNCTION__); - - rbug_disconnect(tr_rbug->con); - tr_rbug->con = NULL; -} - -PIPE_THREAD_ROUTINE(trace_rbug_thread, void_tr_rbug) -{ - struct trace_rbug *tr_rbug = void_tr_rbug; - uint16_t port = 13370; - int s = -1; - int c; - - u_socket_init(); - - for (;port <= 13379 && s < 0; port++) - s = u_socket_listen_on_port(port); - - if (s < 0) { - debug_printf("trace_rbug - failed to listen\n"); - return NULL; - } - - u_socket_block(s, false); - - debug_printf("trace_rbug - remote debugging listening on port %u\n", --port); - - while(tr_rbug->running) { - os_time_sleep(1); - - c = u_socket_accept(s); - if (c < 0) - continue; - - u_socket_block(c, true); - tr_rbug->con = rbug_from_socket(c); - - trace_rbug_con(tr_rbug); - - u_socket_close(c); - } - - u_socket_close(s); - - u_socket_stop(); - - return NULL; -} - -/********************************************************** - * - */ - -struct trace_rbug * -trace_rbug_start(struct trace_screen *tr_scr) -{ - struct trace_rbug *tr_rbug = CALLOC_STRUCT(trace_rbug); - if (!tr_rbug) - return NULL; - - tr_rbug->tr_scr = tr_scr; - tr_rbug->running = TRUE; - tr_rbug->thread = pipe_thread_create(trace_rbug_thread, tr_rbug); - - return tr_rbug; -} - -void -trace_rbug_stop(struct trace_rbug *tr_rbug) -{ - if (!tr_rbug) - return; - - tr_rbug->running = false; - pipe_thread_wait(tr_rbug->thread); - - FREE(tr_rbug); - - return; -} - -void -trace_rbug_notify_draw_blocked(struct trace_context *tr_ctx) -{ - struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen); - struct trace_rbug *tr_rbug = tr_scr->rbug; - - if (tr_rbug && tr_rbug->con) - rbug_send_context_draw_blocked(tr_rbug->con, - VOID2U64(tr_ctx), tr_ctx->draw_blocked, NULL); -} diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index ffae6e94d11..32e519a68a0 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -40,7 +40,6 @@ static boolean trace = FALSE; -static boolean rbug = FALSE; static const char * trace_screen_get_name(struct pipe_screen *_screen) @@ -86,7 +85,7 @@ trace_screen_get_vendor(struct pipe_screen *_screen) static int trace_screen_get_param(struct pipe_screen *_screen, - int param) + enum pipe_cap param) { struct trace_screen *tr_scr = trace_screen(_screen); struct pipe_screen *screen = tr_scr->screen; @@ -109,7 +108,7 @@ trace_screen_get_param(struct pipe_screen *_screen, static float trace_screen_get_paramf(struct pipe_screen *_screen, - int param) + enum pipe_cap param) { struct trace_screen *tr_scr = trace_screen(_screen); struct pipe_screen *screen = tr_scr->screen; @@ -494,9 +493,6 @@ trace_screen_destroy(struct pipe_screen *_screen) trace_dump_call_end(); trace_dump_trace_end(); - if (tr_scr->rbug) - trace_rbug_stop(tr_scr->rbug); - screen->destroy(screen); FREE(tr_scr); @@ -518,11 +514,6 @@ trace_enabled(void) trace = TRUE; } - if (debug_get_bool_option("GALLIUM_RBUG", FALSE)) { - trace = TRUE; - rbug = TRUE; - } - return trace; } @@ -551,13 +542,6 @@ trace_screen_create(struct pipe_screen *screen) #else winsys = screen->winsys; #endif - pipe_mutex_init(tr_scr->list_mutex); - make_empty_list(&tr_scr->buffers); - make_empty_list(&tr_scr->contexts); - make_empty_list(&tr_scr->textures); - make_empty_list(&tr_scr->surfaces); - make_empty_list(&tr_scr->transfers); - tr_scr->base.winsys = winsys; tr_scr->base.destroy = trace_screen_destroy; tr_scr->base.get_name = trace_screen_get_name; @@ -580,20 +564,12 @@ trace_screen_create(struct pipe_screen *screen) tr_scr->base.flush_frontbuffer = trace_screen_flush_frontbuffer; tr_scr->screen = screen; - tr_scr->private_context = screen->context_create(screen, NULL); - if (tr_scr->private_context == NULL) - goto error3; trace_dump_ret(ptr, screen); trace_dump_call_end(); - if (rbug) - tr_scr->rbug = trace_rbug_start(tr_scr); - return &tr_scr->base; -error3: - FREE(tr_scr); error2: trace_dump_ret(ptr, screen); trace_dump_call_end(); diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h index 05ff9ef61f1..3598ceaa20f 100644 --- a/src/gallium/drivers/trace/tr_screen.h +++ b/src/gallium/drivers/trace/tr_screen.h @@ -56,67 +56,17 @@ struct trace_screen struct pipe_screen base; struct pipe_screen *screen; - struct pipe_context *private_context; - - /* remote debugger */ - struct trace_rbug *rbug; - - pipe_mutex list_mutex; - int num_buffers; - int num_contexts; - int num_textures; - int num_surfaces; - int num_transfers; - struct tr_list buffers; - struct tr_list contexts; - struct tr_list textures; - struct tr_list surfaces; - struct tr_list transfers; }; /* - * tr_rbug.c - */ - - -struct trace_rbug; - -struct trace_rbug * -trace_rbug_start(struct trace_screen *tr_scr); - -void -trace_rbug_stop(struct trace_rbug *tr_rbug); - - -/* * tr_screen.c */ -boolean -trace_enabled(void); - struct trace_screen * trace_screen(struct pipe_screen *screen); -#define trace_screen_add_to_list(tr_scr, name, obj) \ - do { \ - pipe_mutex_lock(tr_scr->list_mutex); \ - insert_at_head(&tr_scr->name, &obj->list); \ - tr_scr->num_##name++; \ - pipe_mutex_unlock(tr_scr->list_mutex); \ - } while (0) - -#define trace_screen_remove_from_list(tr_scr, name, obj) \ - do { \ - pipe_mutex_lock(tr_scr->list_mutex); \ - remove_from_list(&obj->list); \ - tr_scr->num_##name--; \ - pipe_mutex_unlock(tr_scr->list_mutex); \ - } while (0) - - #ifdef __cplusplus } #endif diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c deleted file mode 100644 index d8c11640bf3..00000000000 --- a/src/gallium/drivers/trace/tr_state.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * 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 - * VMWARE 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 "tr_state.h" - -#include "util/u_memory.h" -#include "util/u_simple_list.h" - -#include "tgsi/tgsi_parse.h" - -struct trace_shader * trace_shader_create(struct trace_context *tr_ctx, - const struct pipe_shader_state *state, - void *result, - enum trace_shader_type type) -{ - struct trace_shader *tr_shdr = CALLOC_STRUCT(trace_shader); - - tr_shdr->state = result; - tr_shdr->type = type; - tr_shdr->tokens = tgsi_dup_tokens(state->tokens); - - /* works on context as well */ - trace_screen_add_to_list(tr_ctx, shaders, tr_shdr); - - return tr_shdr; -} - -void trace_shader_destroy(struct trace_context *tr_ctx, - struct trace_shader *tr_shdr) -{ - trace_screen_remove_from_list(tr_ctx, shaders, tr_shdr); - - if (tr_shdr->replaced) { - if (tr_shdr->type == TRACE_SHADER_FRAGMENT) - tr_ctx->pipe->delete_fs_state(tr_ctx->pipe, tr_shdr->replaced); - else if (tr_shdr->type == TRACE_SHADER_VERTEX) - tr_ctx->pipe->delete_vs_state(tr_ctx->pipe, tr_shdr->replaced); - else - assert(0); - } - - FREE(tr_shdr->replaced_tokens); - FREE(tr_shdr->tokens); - FREE(tr_shdr); -} diff --git a/src/gallium/drivers/trace/tr_state.h b/src/gallium/drivers/trace/tr_state.h deleted file mode 100644 index e2f981d0513..00000000000 --- a/src/gallium/drivers/trace/tr_state.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * 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 - * VMWARE 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 TR_STATE_H_ -#define TR_STATE_H_ - -#include "tr_context.h" - -struct tgsi_token; - -enum trace_shader_type { - TRACE_SHADER_FRAGMENT = 0, - TRACE_SHADER_VERTEX = 1, - TRACE_SHADER_GEOMETRY = 2 -}; - -struct trace_shader -{ - struct tr_list list; - - enum trace_shader_type type; - - void *state; - void *replaced; - - struct tgsi_token *tokens; - struct tgsi_token *replaced_tokens; - - boolean disabled; -}; - - -static INLINE struct trace_shader * -trace_shader(void *state) -{ - return (struct trace_shader *)state; -} - -struct trace_shader * trace_shader_create(struct trace_context *tr_ctx, - const struct pipe_shader_state *state, - void *result, - enum trace_shader_type type); - -void trace_shader_destroy(struct trace_context *tr_ctx, - struct trace_shader *tr_shdr); - -#endif diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c index 1132dc92724..9914b98b39c 100644 --- a/src/gallium/drivers/trace/tr_texture.c +++ b/src/gallium/drivers/trace/tr_texture.c @@ -56,8 +56,6 @@ trace_resource_create(struct trace_screen *tr_scr, tr_tex->base.screen = &tr_scr->base; tr_tex->resource = texture; - trace_screen_add_to_list(tr_scr, textures, tr_tex); - return &tr_tex->base; error: @@ -70,8 +68,6 @@ void trace_resource_destroy(struct trace_screen *tr_scr, struct trace_resource *tr_tex) { - trace_screen_remove_from_list(tr_scr, textures, tr_tex); - pipe_resource_reference(&tr_tex->resource, NULL); FREE(tr_tex); } @@ -81,7 +77,6 @@ struct pipe_surface * trace_surface_create(struct trace_resource *tr_tex, struct pipe_surface *surface) { - struct trace_screen *tr_scr = trace_screen(tr_tex->base.screen); struct trace_surface *tr_surf; if(!surface) @@ -100,8 +95,6 @@ trace_surface_create(struct trace_resource *tr_tex, pipe_resource_reference(&tr_surf->base.texture, &tr_tex->base); tr_surf->surface = surface; - trace_screen_add_to_list(tr_scr, surfaces, tr_surf); - return &tr_surf->base; error: @@ -113,10 +106,6 @@ error: void trace_surface_destroy(struct trace_surface *tr_surf) { - struct trace_screen *tr_scr = trace_screen(tr_surf->base.texture->screen); - - trace_screen_remove_from_list(tr_scr, surfaces, tr_surf); - pipe_resource_reference(&tr_surf->base.texture, NULL); pipe_surface_reference(&tr_surf->surface, NULL); FREE(tr_surf); @@ -128,7 +117,6 @@ trace_transfer_create(struct trace_context *tr_ctx, struct trace_resource *tr_tex, struct pipe_transfer *transfer) { - struct trace_screen *tr_scr = trace_screen(tr_tex->base.screen); struct trace_transfer *tr_trans; if(!transfer) @@ -148,8 +136,6 @@ trace_transfer_create(struct trace_context *tr_ctx, pipe_resource_reference(&tr_trans->base.resource, &tr_tex->base); assert(tr_trans->base.resource == &tr_tex->base); - trace_screen_add_to_list(tr_scr, transfers, tr_trans); - return &tr_trans->base; error: @@ -162,12 +148,9 @@ void trace_transfer_destroy(struct trace_context *tr_context, struct trace_transfer *tr_trans) { - struct trace_screen *tr_scr = trace_screen(tr_context->base.screen); struct pipe_context *context = tr_context->pipe; struct pipe_transfer *transfer = tr_trans->transfer; - trace_screen_remove_from_list(tr_scr, transfers, tr_trans); - pipe_resource_reference(&tr_trans->base.resource, NULL); context->transfer_destroy(context, transfer); FREE(tr_trans); diff --git a/src/gallium/include/pipe/p_config.h b/src/gallium/include/pipe/p_config.h index c5928dde471..b81702a4fac 100644 --- a/src/gallium/include/pipe/p_config.h +++ b/src/gallium/include/pipe/p_config.h @@ -165,6 +165,11 @@ #define PIPE_OS_UNIX #endif +#if defined(__CYGWIN__) +#define PIPE_OS_CYGWIN +#define PIPE_OS_UNIX +#endif + /* * Try to auto-detect the subsystem. * diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index a852ad97cab..b54a6ef8247 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -119,11 +119,11 @@ enum pipe_error { #define PIPE_POLYGON_MODE_LINE 1 #define PIPE_POLYGON_MODE_POINT 2 -/** Polygon front/back window, also for culling */ -#define PIPE_WINDING_NONE 0 -#define PIPE_WINDING_CW 1 -#define PIPE_WINDING_CCW 2 -#define PIPE_WINDING_BOTH (PIPE_WINDING_CW | PIPE_WINDING_CCW) +/** Polygon face specification, eg for culling */ +#define PIPE_FACE_NONE 0 +#define PIPE_FACE_FRONT 1 +#define PIPE_FACE_BACK 2 +#define PIPE_FACE_FRONT_AND_BACK (PIPE_FACE_FRONT | PIPE_FACE_BACK) /** Stencil ops */ #define PIPE_STENCIL_OP_KEEP 0 @@ -377,7 +377,8 @@ enum pipe_transfer_usage { #define PIPE_QUERY_OCCLUSION_COUNTER 0 #define PIPE_QUERY_PRIMITIVES_GENERATED 1 #define PIPE_QUERY_PRIMITIVES_EMITTED 2 -#define PIPE_QUERY_TYPES 3 +#define PIPE_QUERY_TIME_ELAPSED 3 +#define PIPE_QUERY_TYPES 4 /** @@ -411,46 +412,76 @@ enum pipe_transfer_usage { * Implementation capabilities/limits which are queried through * pipe_screen::get_param() and pipe_screen::get_paramf(). */ -#define PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS 1 -#define PIPE_CAP_NPOT_TEXTURES 2 -#define PIPE_CAP_TWO_SIDED_STENCIL 3 -#define PIPE_CAP_GLSL 4 /* XXX need something better */ -#define PIPE_CAP_DUAL_SOURCE_BLEND 5 -#define PIPE_CAP_ANISOTROPIC_FILTER 6 -#define PIPE_CAP_POINT_SPRITE 7 -#define PIPE_CAP_MAX_RENDER_TARGETS 8 -#define PIPE_CAP_OCCLUSION_QUERY 9 -#define PIPE_CAP_TEXTURE_SHADOW_MAP 10 -#define PIPE_CAP_MAX_TEXTURE_2D_LEVELS 11 -#define PIPE_CAP_MAX_TEXTURE_3D_LEVELS 12 -#define PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS 13 -#define PIPE_CAP_MAX_LINE_WIDTH 14 -#define PIPE_CAP_MAX_LINE_WIDTH_AA 15 -#define PIPE_CAP_MAX_POINT_WIDTH 16 -#define PIPE_CAP_MAX_POINT_WIDTH_AA 17 -#define PIPE_CAP_MAX_TEXTURE_ANISOTROPY 18 -#define PIPE_CAP_MAX_TEXTURE_LOD_BIAS 19 -#define PIPE_CAP_GUARD_BAND_LEFT 20 /*< float */ -#define PIPE_CAP_GUARD_BAND_TOP 21 /*< float */ -#define PIPE_CAP_GUARD_BAND_RIGHT 22 /*< float */ -#define PIPE_CAP_GUARD_BAND_BOTTOM 23 /*< float */ -#define PIPE_CAP_TEXTURE_MIRROR_CLAMP 24 -#define PIPE_CAP_TEXTURE_MIRROR_REPEAT 25 -#define PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS 26 -#define PIPE_CAP_TGSI_CONT_SUPPORTED 27 -#define PIPE_CAP_BLEND_EQUATION_SEPARATE 28 -#define PIPE_CAP_SM3 29 /*< Shader Model 3 supported */ -#define PIPE_CAP_MAX_PREDICATE_REGISTERS 30 -#define PIPE_CAP_MAX_COMBINED_SAMPLERS 31 /*< Maximum texture image units accessible from vertex - and fragment shaders combined */ -#define PIPE_CAP_MAX_CONST_BUFFERS 32 -#define PIPE_CAP_MAX_CONST_BUFFER_SIZE 33 /*< In bytes */ -#define PIPE_CAP_INDEP_BLEND_ENABLE 34 /*< blend enables and write masks per rendertarget */ -#define PIPE_CAP_INDEP_BLEND_FUNC 35 /*< different blend funcs per rendertarget */ -#define PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT 36 -#define PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT 37 -#define PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER 38 -#define PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER 39 +enum pipe_cap { + PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS, + PIPE_CAP_NPOT_TEXTURES, + PIPE_CAP_TWO_SIDED_STENCIL, + PIPE_CAP_GLSL, /* XXX need something better */ + PIPE_CAP_DUAL_SOURCE_BLEND, + PIPE_CAP_ANISOTROPIC_FILTER, + PIPE_CAP_POINT_SPRITE, + PIPE_CAP_MAX_RENDER_TARGETS, + PIPE_CAP_OCCLUSION_QUERY, + PIPE_CAP_TIMER_QUERY, + PIPE_CAP_TEXTURE_SHADOW_MAP, + PIPE_CAP_MAX_TEXTURE_2D_LEVELS, + PIPE_CAP_MAX_TEXTURE_3D_LEVELS, + PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS, + PIPE_CAP_MAX_LINE_WIDTH, + PIPE_CAP_MAX_LINE_WIDTH_AA, + PIPE_CAP_MAX_POINT_WIDTH, + PIPE_CAP_MAX_POINT_WIDTH_AA, + PIPE_CAP_MAX_TEXTURE_ANISOTROPY, + PIPE_CAP_MAX_TEXTURE_LOD_BIAS, + PIPE_CAP_GUARD_BAND_LEFT, /*< float */ + PIPE_CAP_GUARD_BAND_TOP, /*< float */ + PIPE_CAP_GUARD_BAND_RIGHT, /*< float */ + PIPE_CAP_GUARD_BAND_BOTTOM, /*< float */ + PIPE_CAP_TEXTURE_MIRROR_CLAMP, + PIPE_CAP_TEXTURE_MIRROR_REPEAT, + PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS, + PIPE_CAP_TGSI_CONT_SUPPORTED, + PIPE_CAP_BLEND_EQUATION_SEPARATE, + PIPE_CAP_SM3, /*< Shader Model, supported */ + PIPE_CAP_MAX_PREDICATE_REGISTERS, + /** Maximum texture image units accessible from vertex and fragment shaders + * combined */ + PIPE_CAP_MAX_COMBINED_SAMPLERS, + PIPE_CAP_MAX_CONST_BUFFERS, + PIPE_CAP_MAX_CONST_BUFFER_SIZE, /*< In bytes */ + /** blend enables and write masks per rendertarget */ + PIPE_CAP_INDEP_BLEND_ENABLE, + /** different blend funcs per rendertarget */ + PIPE_CAP_INDEP_BLEND_FUNC, + PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT, + PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT, + PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER, + PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER, + + /* + * Shader limits. + */ + PIPE_CAP_MAX_FS_INSTRUCTIONS, + PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS, + PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS, + PIPE_CAP_MAX_FS_TEX_INDIRECTIONS, + PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH, + PIPE_CAP_MAX_FS_INPUTS, + PIPE_CAP_MAX_FS_CONSTS, + PIPE_CAP_MAX_FS_TEMPS, + PIPE_CAP_MAX_FS_ADDRS, + PIPE_CAP_MAX_FS_PREDS, + PIPE_CAP_MAX_VS_INSTRUCTIONS, + PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS, + PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS, + PIPE_CAP_MAX_VS_TEX_INDIRECTIONS, + PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH, + PIPE_CAP_MAX_VS_INPUTS, + PIPE_CAP_MAX_VS_CONSTS, + PIPE_CAP_MAX_VS_TEMPS, + PIPE_CAP_MAX_VS_ADDRS, + PIPE_CAP_MAX_VS_PREDS +}; /** diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index 9cb949a4465..21f428ed4af 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -54,7 +54,6 @@ struct winsys_handle; /** Opaque type */ struct pipe_fence_handle; struct pipe_winsys; -struct pipe_texture; struct pipe_resource; struct pipe_surface; struct pipe_transfer; @@ -79,13 +78,13 @@ struct pipe_screen { * Query an integer-valued capability/parameter/limit * \param param one of PIPE_CAP_x */ - int (*get_param)( struct pipe_screen *, int param ); + int (*get_param)( struct pipe_screen *, enum pipe_cap param ); /** * Query a float-valued capability/parameter/limit * \param param one of PIPE_CAP_x */ - float (*get_paramf)( struct pipe_screen *, int param ); + float (*get_paramf)( struct pipe_screen *, enum pipe_cap param ); struct pipe_context * (*context_create)( struct pipe_screen *, void *priv ); diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index f9ad07d8f87..5255b2003f8 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -79,12 +79,13 @@ struct pipe_rasterizer_state { unsigned flatshade:1; unsigned light_twoside:1; - unsigned front_winding:2; /**< PIPE_WINDING_x */ - unsigned cull_mode:2; /**< PIPE_WINDING_x */ - unsigned fill_cw:2; /**< PIPE_POLYGON_MODE_x */ - unsigned fill_ccw:2; /**< PIPE_POLYGON_MODE_x */ - unsigned offset_cw:1; - unsigned offset_ccw:1; + unsigned front_ccw:1; + unsigned cull_face:2; /**< PIPE_FACE_x */ + unsigned fill_front:2; /**< PIPE_POLYGON_MODE_x */ + unsigned fill_back:2; /**< PIPE_POLYGON_MODE_x */ + unsigned offset_point:1; + unsigned offset_line:1; + unsigned offset_tri:1; unsigned scissor:1; unsigned poly_smooth:1; unsigned poly_stipple_enable:1; diff --git a/src/gallium/include/state_tracker/dri1_api.h b/src/gallium/include/state_tracker/dri1_api.h index a48c5de5a05..0d702d90928 100644 --- a/src/gallium/include/state_tracker/dri1_api.h +++ b/src/gallium/include/state_tracker/dri1_api.h @@ -9,7 +9,6 @@ struct pipe_screen; struct pipe_winsys; -struct pipe_buffer; struct pipe_context; struct pipe_resource; diff --git a/src/gallium/include/state_tracker/drm_api.h b/src/gallium/include/state_tracker/drm_api.h index 3d8fdd86fc7..8fd0995444d 100644 --- a/src/gallium/include/state_tracker/drm_api.h +++ b/src/gallium/include/state_tracker/drm_api.h @@ -6,7 +6,6 @@ struct pipe_screen; struct pipe_winsys; -struct pipe_buffer; struct pipe_context; struct pipe_resource; diff --git a/src/gallium/include/state_tracker/graw.h b/src/gallium/include/state_tracker/graw.h index a58e18e4739..e5b298e03d9 100644 --- a/src/gallium/include/state_tracker/graw.h +++ b/src/gallium/include/state_tracker/graw.h @@ -17,20 +17,27 @@ #include "pipe/p_format.h" struct pipe_screen; - -struct pipe_screen *graw_init( void ); +struct pipe_context; /* Returns a handle to be used with flush_frontbuffer()/present(). * * Query format support with screen::is_format_supported and usage * XXX. */ -void *graw_create_window( int x, - int y, - unsigned width, - unsigned height, - enum pipe_format format ); +PUBLIC struct pipe_screen *graw_create_window_and_screen( int x, + int y, + unsigned width, + unsigned height, + enum pipe_format format, + void **handle); + +PUBLIC void graw_set_display_func( void (*func)( void ) ); +PUBLIC void graw_main_loop( void ); + +PUBLIC void *graw_parse_vertex_shader( struct pipe_context *pipe, + const char *text ); -void graw_destroy_window( void *handle ); +PUBLIC void *graw_parse_fragment_shader( struct pipe_context *pipe, + const char *text ); #endif diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index 002d1c6b840..21f2d639b14 100644 --- a/src/gallium/include/state_tracker/st_api.h +++ b/src/gallium/include/state_tracker/st_api.h @@ -61,7 +61,7 @@ enum st_texture_type { ST_TEXTURE_1D, ST_TEXTURE_2D, ST_TEXTURE_3D, - ST_TEXTURE_RECT, + ST_TEXTURE_RECT }; /** @@ -102,7 +102,7 @@ enum st_context_resource_type { ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_POSITIVE_Z, ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_NEGATIVE_Z, ST_CONTEXT_RESOURCE_OPENGL_RENDERBUFFER, - ST_CONTEXT_RESOURCE_OPENVG_PARENT_IMAGE, + ST_CONTEXT_RESOURCE_OPENVG_PARENT_IMAGE }; /** diff --git a/src/gallium/state_trackers/dri/drm/Makefile b/src/gallium/state_trackers/dri/drm/Makefile index d9a973e3c3e..6c9d03fc5de 100644 --- a/src/gallium/state_trackers/dri/drm/Makefile +++ b/src/gallium/state_trackers/dri/drm/Makefile @@ -5,6 +5,7 @@ LIBNAME = dridrm LIBRARY_INCLUDES = \ -I$(TOP)/include \ + -I$(TOP)/src/mapi \ -I$(TOP)/src/mesa \ -I$(TOP)/src/gallium/state_trackers/dri/common \ -I$(TOP)/src/mesa/drivers/dri/common \ diff --git a/src/gallium/state_trackers/dri/drm/SConscript b/src/gallium/state_trackers/dri/drm/SConscript index 8800b655343..965dc95760f 100644 --- a/src/gallium/state_trackers/dri/drm/SConscript +++ b/src/gallium/state_trackers/dri/drm/SConscript @@ -10,6 +10,7 @@ if env['dri']: env.ParseConfig('pkg-config --cflags --libs libdrm') env.Append(CPPPATH = [ + '#/src/mapi', '#/src/mesa', '#/src/gallium/state_trackers/dri/common', '#/src/mesa/drivers/dri/common', diff --git a/src/gallium/state_trackers/dri/sw/Makefile b/src/gallium/state_trackers/dri/sw/Makefile index c0ae71451b2..a1dadeba5e6 100644 --- a/src/gallium/state_trackers/dri/sw/Makefile +++ b/src/gallium/state_trackers/dri/sw/Makefile @@ -8,6 +8,7 @@ LIBRARY_DEFINES = -D__NOT_HAVE_DRM_H LIBRARY_INCLUDES = \ -I../dri \ -I$(TOP)/include \ + -I$(TOP)/src/mapi \ -I$(TOP)/src/mesa \ -I$(TOP)/src/gallium/state_trackers/dri/common \ -I$(TOP)/src/mesa/drivers/dri/common \ diff --git a/src/gallium/state_trackers/dri/sw/SConscript b/src/gallium/state_trackers/dri/sw/SConscript index 6bb282d1a4c..0c5194d6edc 100644 --- a/src/gallium/state_trackers/dri/sw/SConscript +++ b/src/gallium/state_trackers/dri/sw/SConscript @@ -8,6 +8,7 @@ if env['dri']: env = env.Clone() env.Append(CPPPATH = [ + '#/src/mapi', '#/src/mesa', '#/src/gallium/state_trackers/dri/common', '#/src/mesa/drivers/dri/common', diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile index 1768241352f..a3c1bb43469 100644 --- a/src/gallium/state_trackers/egl/Makefile +++ b/src/gallium/state_trackers/egl/Makefile @@ -15,6 +15,7 @@ common_OBJECTS = $(common_SOURCES:.c=.o) x11_INCLUDES = \ -I$(TOP)/src/gallium/drivers \ -I$(TOP)/src/glx \ + -I$(TOP)/src/mapi \ -I$(TOP)/src/mesa \ $(X11_CFLAGS) \ $(shell pkg-config --cflags-only-I libdrm) diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index 871c33267ae..d63b81a1c59 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -50,8 +50,8 @@ egl_g3d_init_st(_EGLDriver *drv) if (gdrv->api_mask) return; + egl_g3d_init_st_apis(gdrv->stapis); for (i = 0; i < ST_API_COUNT; i++) { - gdrv->stapis[i] = egl_g3d_create_st_api(i); if (gdrv->stapis[i]) gdrv->api_mask |= egl_g3d_st_api_bit(i); } @@ -581,13 +581,8 @@ static void egl_g3d_unload(_EGLDriver *drv) { struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - EGLint i; - - for (i = 0; i < ST_API_COUNT; i++) { - if (gdrv->stapis[i]) - gdrv->stapis[i]->destroy(gdrv->stapis[i]); - } + egl_g3d_destroy_st_apis(); egl_g3d_destroy_probe(drv, NULL); FREE(gdrv); } diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.c b/src/gallium/state_trackers/egl/common/egl_g3d_st.c index 97445478684..1df57d07774 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_st.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.c @@ -27,8 +27,10 @@ */ #include "util/u_memory.h" +#include "util/u_string.h" #include "util/u_inlines.h" #include "util/u_dl.h" +#include "egldriver.h" #include "eglimage.h" #include "eglmutex.h" @@ -46,42 +48,160 @@ egl_g3d_st_manager(struct st_manager *smapi) return (struct egl_g3d_st_manager *) smapi; } -struct st_api * -egl_g3d_create_st_api(enum st_api_type api) -{ +static struct egl_g3d_st_module { + const char *filename; struct util_dl_library *lib; - const char *proc_name; - struct st_api * (*proc)(void) = NULL; - - switch (api) { - case ST_API_OPENGL: - proc_name = ST_CREATE_OPENGL_SYMBOL; - break; - case ST_API_OPENGL_ES1: - proc_name = ST_CREATE_OPENGL_ES1_SYMBOL; - break; - case ST_API_OPENGL_ES2: - proc_name = ST_CREATE_OPENGL_ES2_SYMBOL; - break; - case ST_API_OPENVG: - proc_name = ST_CREATE_OPENVG_SYMBOL; - break; - default: - assert(!"Unknown API Type\n"); - return NULL; + struct st_api *stapi; +} egl_g3d_st_modules[ST_API_COUNT]; + +static EGLBoolean +egl_g3d_search_path_callback(const char *dir, size_t len, void *callback_data) +{ + struct egl_g3d_st_module *stmod = + (struct egl_g3d_st_module *) callback_data; + char path[1024]; + int ret; + + ret = util_snprintf(path, sizeof(path), + "%.*s/%s", len, dir, stmod->filename); + if (ret > 0 && ret < sizeof(path)) + stmod->lib = util_dl_open(path); + + return !(stmod->lib); +} + +static boolean +egl_g3d_load_st_module(struct egl_g3d_st_module *stmod, + const char *filename, const char *procname) +{ + struct st_api *(*create_api)(void); + + stmod->filename = filename; + if (stmod->filename) + _eglSearchPathForEach(egl_g3d_search_path_callback, (void *) stmod); + else + stmod->lib = util_dl_open(NULL); + + if (stmod->lib) { + create_api = (struct st_api *(*)(void)) + util_dl_get_proc_address(stmod->lib, procname); + if (create_api) + stmod->stapi = create_api(); + + if (!stmod->stapi) { + util_dl_close(stmod->lib); + stmod->lib = NULL; + } } - lib = util_dl_open(NULL); - if (lib) { - proc = util_dl_get_proc_address(lib, proc_name); - debug_printf("%s: %s %p\n", __func__, proc_name, proc); - util_dl_close(lib); + if (stmod->stapi) { + return TRUE; } + else { + stmod->filename = NULL; + return FALSE; + } +} - if (!proc) - return NULL; +void +egl_g3d_init_st_apis(struct st_api *stapis[ST_API_COUNT]) +{ + const char *skip_checks[ST_API_COUNT], *symbols[ST_API_COUNT]; + const char *filenames[ST_API_COUNT][4]; + struct util_dl_library *self; + int num_needed = 0, api; + + self = util_dl_open(NULL); + + /* collect the necessary data for loading modules */ + for (api = 0; api < ST_API_COUNT; api++) { + int count = 0; + + switch (api) { + case ST_API_OPENGL: + skip_checks[api] = "glColor4d"; + symbols[api] = ST_CREATE_OPENGL_SYMBOL; + filenames[api][count++] = "api_GL.so"; + break; + case ST_API_OPENGL_ES1: + skip_checks[api] = "glColor4x"; + symbols[api] = ST_CREATE_OPENGL_ES1_SYMBOL; + filenames[api][count++] = "api_GLESv1_CM.so"; + filenames[api][count++] = "api_GL.so"; + break; + case ST_API_OPENGL_ES2: + skip_checks[api] = "glShaderBinary"; + symbols[api] = ST_CREATE_OPENGL_ES2_SYMBOL; + filenames[api][count++] = "api_GLESv2.so"; + filenames[api][count++] = "api_GL.so"; + break; + case ST_API_OPENVG: + skip_checks[api] = "vgClear"; + symbols[api] = ST_CREATE_OPENVG_SYMBOL; + filenames[api][count++]= "api_OpenVG.so"; + break; + default: + assert(!"Unknown API Type\n"); + skip_checks[api] = NULL; + symbols[api] = NULL; + break; + } + filenames[api][count++]= NULL; + assert(count < Elements(filenames[api])); + + /* heuristicically decide if the module is needed */ + if (!self || !skip_checks[api] || + util_dl_get_proc_address(self, skip_checks[api])) { + /* unset so the module is not skipped */ + skip_checks[api] = NULL; + num_needed++; + } + } + /* mark all moudles needed if we wrongly decided that none is needed */ + if (!num_needed) + memset(skip_checks, 0, sizeof(skip_checks)); + + if (self) + util_dl_close(self); + + for (api = 0; api < ST_API_COUNT; api++) { + struct egl_g3d_st_module *stmod = &egl_g3d_st_modules[api]; + const char **p; + + /* skip the module */ + if (skip_checks[api]) + continue; + + /* try all filenames, including NULL */ + for (p = filenames[api]; *p; p++) { + if (egl_g3d_load_st_module(stmod, *p, symbols[api])) + break; + } + if (!stmod->stapi) + egl_g3d_load_st_module(stmod, NULL, symbols[api]); - return proc(); + stapis[api] = stmod->stapi; + } +} + +void +egl_g3d_destroy_st_apis(void) +{ + int api; + + for (api = 0; api < ST_API_COUNT; api++) { + struct egl_g3d_st_module *stmod = &egl_g3d_st_modules[api]; + + if (stmod->stapi) { + stmod->stapi->destroy(stmod->stapi); + stmod->stapi = NULL; + } + if (stmod->lib) { + util_dl_close(stmod->lib); + stmod->lib = NULL; + } + stmod->filename = NULL; + } } static boolean diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.h b/src/gallium/state_trackers/egl/common/egl_g3d_st.h index c82681a22d8..ee53799b029 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_st.h +++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.h @@ -33,8 +33,11 @@ #include "state_tracker/st_api.h" #include "egltypedefs.h" -struct st_api * -egl_g3d_create_st_api(enum st_api_type api); +void +egl_g3d_init_st_apis(struct st_api *stapis[ST_API_COUNT]); + +void +egl_g3d_destroy_st_apis(void); struct st_manager * egl_g3d_create_st_manager(_EGLDisplay *dpy); diff --git a/src/gallium/state_trackers/es/Makefile b/src/gallium/state_trackers/es/Makefile deleted file mode 100644 index 7370634ea24..00000000000 --- a/src/gallium/state_trackers/es/Makefile +++ /dev/null @@ -1,84 +0,0 @@ -# src/gallium/state_trackers/es/Makefile - -# Build the ES 1/2 state tracker libraries -# This consists of core Mesa ES, plus GL/gallium state tracker. - -TOP = ../../../.. -include $(TOP)/configs/current - -GLES_1_VERSION_MAJOR = 1 -GLES_1_VERSION_MINOR = 1 -GLES_1_VERSION_PATCH = 0 - -GLES_2_VERSION_MAJOR = 2 -GLES_2_VERSION_MINOR = 0 -GLES_2_VERSION_PATCH = 0 - - -# Maybe move these into configs/default: -GLES_1_LIB = GLESv1_CM -GLES_1_LIB_NAME = lib$(GLES_1_LIB).so -GLES_2_LIB = GLESv2 -GLES_2_LIB_NAME = lib$(GLES_2_LIB).so - - -# These two objects indirectly reference all public functions thanks to the use -# of _glapi_get_proc_address. -ES1_OBJECTS = st_es1.o -ES2_OBJECTS = st_es2.o - - -ES1_LIBS = \ - $(TOP)/src/mesa/es/libes1gallium.a \ - $(TOP)/src/mesa/es/libes1api.a - -ES2_LIBS = \ - $(TOP)/src/mesa/es/libes2gallium.a \ - $(TOP)/src/mesa/es/libes2api.a - -SYS_LIBS = -lm -pthread - - -INCLUDE_DIRS = \ - -I$(TOP)/include \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/gallium/include - -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(DEFINES) $(CFLAGS) $< -o $@ - - -# Default: make both GL ES 1.1 and GL ES 2.0 libraries -default: $(TOP)/$(LIB_DIR)/$(GLES_1_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLES_2_LIB_NAME) - -# Make the shared libs -$(TOP)/$(LIB_DIR)/$(GLES_1_LIB_NAME): $(ES1_OBJECTS) $(ES1_LIBS) $(GALLIUM_AUXILIARIES) - $(MKLIB) -o $(GLES_1_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - -major $(GLES_1_VERSION_MAJOR) \ - -minor $(GLES_1_VERSION_MINOR) \ - -patch $(GLES_1_VERSION_PATCH) \ - -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \ - $(ES1_OBJECTS) $(ES1_LIBS) $(GALLIUM_AUXILIARIES) $(SYS_LIBS) - -$(TOP)/$(LIB_DIR)/$(GLES_2_LIB_NAME): $(ES2_OBJECTS) $(ES1_LIBS) $(GALLIUM_AUXILIARIES) - $(MKLIB) -o $(GLES_2_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - -major $(GLES_2_VERSION_MAJOR) \ - -minor $(GLES_2_VERSION_MINOR) \ - -patch $(GLES_2_VERSION_PATCH) \ - -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \ - $(ES2_OBJECTS) $(ES2_LIBS) $(GALLIUM_AUXILIARIES) $(SYS_LIBS) - -install: default - $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GLES - $(INSTALL) -m 644 $(TOP)/include/GLES/*.h $(DESTDIR)$(INSTALL_DIR)/include/GLES - $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GLES2 - $(INSTALL) -m 644 $(TOP)/include/GLES2/*.h $(DESTDIR)$(INSTALL_DIR)/include/GLES2 - $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) - $(MINSTALL) $(TOP)/$(LIB_DIR)/libGLESv1* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) - $(MINSTALL) $(TOP)/$(LIB_DIR)/libGLESv2* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) - -clean: - -rm -f *.o *~ - -rm -f $(TOP)/$(LIB_DIR)/$(GLES_1_LIB_NAME)* $(TOP)/$(LIB_DIR)/$(GLES_2_LIB_NAME)* - -depend: diff --git a/src/gallium/state_trackers/glx/xlib/Makefile b/src/gallium/state_trackers/glx/xlib/Makefile index 35509fd708b..84cb36ec367 100644 --- a/src/gallium/state_trackers/glx/xlib/Makefile +++ b/src/gallium/state_trackers/glx/xlib/Makefile @@ -5,6 +5,7 @@ LIBNAME = xlib LIBRARY_INCLUDES = \ -I$(TOP)/include \ + -I$(TOP)/src/mapi \ -I$(TOP)/src/mesa \ $(X11_CFLAGS) diff --git a/src/gallium/state_trackers/glx/xlib/SConscript b/src/gallium/state_trackers/glx/xlib/SConscript index d6c16ad2f52..9df351a2769 100644 --- a/src/gallium/state_trackers/glx/xlib/SConscript +++ b/src/gallium/state_trackers/glx/xlib/SConscript @@ -9,6 +9,7 @@ if env['platform'] == 'linux' \ env = env.Clone() env.Append(CPPPATH = [ + '#/src/mapi', '#/src/mesa', '#/src/mesa/main', ]) diff --git a/src/gallium/state_trackers/glx/xlib/glx_getproc.c b/src/gallium/state_trackers/glx/xlib/glx_getproc.c index bd4a85caa04..26fcae78ece 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_getproc.c +++ b/src/gallium/state_trackers/glx/xlib/glx_getproc.c @@ -34,7 +34,6 @@ #include <string.h> #include "GL/glx.h" #include "glapi/glapi.h" -#include "pipe/p_compiler.h" struct name_address_pair { diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c index aac28cacfde..dce24bc17d6 100644 --- a/src/gallium/state_trackers/python/st_device.c +++ b/src/gallium/state_trackers/python/st_device.c @@ -184,8 +184,7 @@ st_context_create(struct st_device *st_dev) { struct pipe_rasterizer_state rasterizer; memset(&rasterizer, 0, sizeof(rasterizer)); - rasterizer.front_winding = PIPE_WINDING_CW; - rasterizer.cull_mode = PIPE_WINDING_NONE; + rasterizer.cull_face = PIPE_FACE_NONE; cso_set_rasterizer(st_ctx->cso, &rasterizer); } diff --git a/src/gallium/state_trackers/vega/Makefile b/src/gallium/state_trackers/vega/Makefile index b871990cd9a..e0a87151c43 100644 --- a/src/gallium/state_trackers/vega/Makefile +++ b/src/gallium/state_trackers/vega/Makefile @@ -3,16 +3,14 @@ TOP = ../../../.. include $(TOP)/configs/current -VG_LIB = OpenVG -VG_LIB_NAME = lib$(VG_LIB).so +LIBNAME = vega -VG_MAJOR = 1 -VG_MINOR = 0 -VG_TINY = 0 - -### Lists of source files, included by Makefiles +LIBRARY_INCLUDES = \ + -I$(TOP)/include \ + -I$(TOP)/src/mapi -VG_SOURCES = \ +C_SOURCES = \ + api.c \ api_context.c \ api_filters.c \ api_images.c \ @@ -40,55 +38,4 @@ VG_SOURCES = \ shader.c \ shaders_cache.c -VG_OBJECTS = $(VG_SOURCES:.c=.o) - -VG_LIBS = $(GALLIUM_AUXILIARIES) -VG_LIB_DEPS = $(EXTRA_LIB_PATH) -lm - -### Include directories - -INCLUDE_DIRS = \ - -I$(TOP)/include \ - -I$(TOP)/src/gallium/include \ - -I$(TOP)/src/gallium/auxiliary - - -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ - -default: depend $(TOP)/$(LIB_DIR)/$(VG_LIB_NAME) - -# Make the OpenVG library -$(TOP)/$(LIB_DIR)/$(VG_LIB_NAME): $(VG_OBJECTS) $(VG_LIBS) - $(MKLIB) -o $(VG_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - -major $(VG_MAJOR) \ - -minor $(VG_MINOR) \ - -patch $(VG_TINY) \ - -install $(TOP)/$(LIB_DIR) \ - $(VG_OBJECTS) $(VG_LIBS) $(VG_LIB_DEPS) - -###################################################################### -# Generic stuff - -depend: $(VG_SOURCES) - @ echo "running $(MKDEP)" - @ rm -f depend # workaround oops on gutsy?!? - @ touch depend - @ $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(VG_SOURCES) \ - > /dev/null 2>/dev/null - -install: default - $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/VG - $(INSTALL) -m 644 $(TOP)/include/VG/*.h $(DESTDIR)$(INSTALL_DIR)/include/VG - $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) - $(MINSTALL) $(TOP)/$(LIB_DIR)/libOpenVG* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) - -# Emacs tags -tags: - etags `find . -name \*.[ch]` $(TOP)/include/VG/*.h - -clean: - rm -f $(VG_OBJECTS) - rm -f depend depend.bak - -sinclude depend +include ../../Makefile.template diff --git a/src/gallium/state_trackers/vega/api.c b/src/gallium/state_trackers/vega/api.c new file mode 100644 index 00000000000..bf1d37493af --- /dev/null +++ b/src/gallium/state_trackers/vega/api.c @@ -0,0 +1,88 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#include "mapi/mapi.h" + +#include "api.h" + +static const char vega_spec[] = + "1" +#define MAPI_ABI_ENTRY(ret, name, params) \ + "\0" #name "\0" +#define MAPI_ALIAS_ENTRY(alias, ret, name, params) \ + #name "\0" +#include "vgapi/vgapi_tmp.h" + "\0"; + +static const mapi_proc vega_procs[] = { +#define MAPI_ABI_ENTRY(ret, name, params) \ + (mapi_proc) vega ## name, +#include "vgapi/vgapi_tmp.h" +}; + +static void api_init(void) +{ + static boolean initialized = FALSE; + if (!initialized) { + mapi_init(vega_spec); + initialized = TRUE; + } +} + +struct mapi_table *api_create_dispatch(void) +{ + struct mapi_table *tbl; + + api_init(); + + tbl = mapi_table_create(); + if (tbl) + mapi_table_fill(tbl, vega_procs); + + return tbl; +} + +void api_destroy_dispatch(struct mapi_table *tbl) +{ + mapi_table_destroy(tbl); +} + +void api_make_dispatch_current(const struct mapi_table *tbl) +{ + mapi_table_make_current(tbl); +} + +mapi_proc api_get_proc_address(const char *proc_name) +{ + if (!proc_name || proc_name[0] != 'v' || proc_name[1] != 'g') + return NULL; + proc_name += 2; + + api_init(); + return mapi_get_proc_address(proc_name); +} diff --git a/src/gallium/state_trackers/vega/api.h b/src/gallium/state_trackers/vega/api.h new file mode 100644 index 00000000000..955508dae9a --- /dev/null +++ b/src/gallium/state_trackers/vega/api.h @@ -0,0 +1,51 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#ifndef API_H +#define API_H + +#include "VG/openvg.h" +#include "VG/vgext.h" +#include "vg_manager.h" + +/* declare the prototypes */ +#define MAPI_ABI_ENTRY(ret, name, params) \ + ret VG_API_ENTRY vega ## name params; +#include "vgapi/vgapi_tmp.h" + +struct mapi_table; + +struct mapi_table *api_create_dispatch(void); + +void api_destroy_dispatch(struct mapi_table *tbl); + +void api_make_dispatch_current(const struct mapi_table *tbl); + +st_proc_t api_get_proc_address(const char *proc_name); + +#endif /* API_H */ diff --git a/src/gallium/state_trackers/vega/api_context.c b/src/gallium/state_trackers/vega/api_context.c index eb2fbe26e7f..0d04d8e8718 100644 --- a/src/gallium/state_trackers/vega/api_context.c +++ b/src/gallium/state_trackers/vega/api_context.c @@ -28,11 +28,12 @@ #include "vg_manager.h" #include "vg_context.h" +#include "api.h" #include "pipe/p_context.h" #include "pipe/p_screen.h" -VGErrorCode vgGetError(void) +VGErrorCode vegaGetError(void) { struct vg_context *ctx = vg_current_context(); VGErrorCode error = VG_NO_CONTEXT_ERROR; @@ -46,7 +47,7 @@ VGErrorCode vgGetError(void) return error; } -void vgFlush(void) +void vegaFlush(void) { struct vg_context *ctx = vg_current_context(); struct pipe_context *pipe; @@ -60,7 +61,7 @@ void vgFlush(void) vg_manager_flush_frontbuffer(ctx); } -void vgFinish(void) +void vegaFinish(void) { struct vg_context *ctx = vg_current_context(); struct pipe_fence_handle *fence = NULL; diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c index b1c08af9382..144fb8f323d 100644 --- a/src/gallium/state_trackers/vega/api_filters.c +++ b/src/gallium/state_trackers/vega/api_filters.c @@ -28,6 +28,7 @@ #include "vg_context.h" #include "image.h" +#include "api.h" #include "renderer.h" #include "shaders_cache.h" #include "st_inlines.h" @@ -361,8 +362,8 @@ static void execute_filter(struct vg_context *ctx, pipe_surface_reference(&dst_surf, NULL); } -void vgColorMatrix(VGImage dst, VGImage src, - const VGfloat * matrix) +void vegaColorMatrix(VGImage dst, VGImage src, + const VGfloat * matrix) { struct vg_context *ctx = vg_current_context(); struct vg_image *d, *s; @@ -403,13 +404,13 @@ static VGfloat texture_offset(VGfloat width, VGint kernelSize, VGint current, VG return diff / width; } -void vgConvolve(VGImage dst, VGImage src, - VGint kernelWidth, VGint kernelHeight, - VGint shiftX, VGint shiftY, - const VGshort * kernel, - VGfloat scale, - VGfloat bias, - VGTilingMode tilingMode) +void vegaConvolve(VGImage dst, VGImage src, + VGint kernelWidth, VGint kernelHeight, + VGint shiftX, VGint shiftY, + const VGshort * kernel, + VGfloat scale, + VGfloat bias, + VGTilingMode tilingMode) { struct vg_context *ctx = vg_current_context(); VGfloat *buffer; @@ -508,15 +509,15 @@ void vgConvolve(VGImage dst, VGImage src, free(buffer); } -void vgSeparableConvolve(VGImage dst, VGImage src, - VGint kernelWidth, - VGint kernelHeight, - VGint shiftX, VGint shiftY, - const VGshort * kernelX, - const VGshort * kernelY, - VGfloat scale, - VGfloat bias, - VGTilingMode tilingMode) +void vegaSeparableConvolve(VGImage dst, VGImage src, + VGint kernelWidth, + VGint kernelHeight, + VGint shiftX, VGint shiftY, + const VGshort * kernelX, + const VGshort * kernelY, + VGfloat scale, + VGfloat bias, + VGTilingMode tilingMode) { struct vg_context *ctx = vg_current_context(); VGshort *kernel; @@ -600,10 +601,10 @@ static void compute_gaussian_kernel(VGfloat *kernel, } } -void vgGaussianBlur(VGImage dst, VGImage src, - VGfloat stdDeviationX, - VGfloat stdDeviationY, - VGTilingMode tilingMode) +void vegaGaussianBlur(VGImage dst, VGImage src, + VGfloat stdDeviationX, + VGfloat stdDeviationY, + VGTilingMode tilingMode) { struct vg_context *ctx = vg_current_context(); struct vg_image *d, *s; @@ -699,13 +700,13 @@ void vgGaussianBlur(VGImage dst, VGImage src, free(kernel); } -void vgLookup(VGImage dst, VGImage src, - const VGubyte * redLUT, - const VGubyte * greenLUT, - const VGubyte * blueLUT, - const VGubyte * alphaLUT, - VGboolean outputLinear, - VGboolean outputPremultiplied) +void vegaLookup(VGImage dst, VGImage src, + const VGubyte * redLUT, + const VGubyte * greenLUT, + const VGubyte * blueLUT, + const VGubyte * alphaLUT, + VGboolean outputLinear, + VGboolean outputPremultiplied) { struct vg_context *ctx = vg_current_context(); struct vg_image *d, *s; @@ -758,11 +759,11 @@ void vgLookup(VGImage dst, VGImage src, pipe_sampler_view_reference(&lut_texture_view, NULL); } -void vgLookupSingle(VGImage dst, VGImage src, - const VGuint * lookupTable, - VGImageChannel sourceChannel, - VGboolean outputLinear, - VGboolean outputPremultiplied) +void vegaLookupSingle(VGImage dst, VGImage src, + const VGuint * lookupTable, + VGImageChannel sourceChannel, + VGboolean outputLinear, + VGboolean outputPremultiplied) { struct vg_context *ctx = vg_current_context(); struct vg_image *d, *s; diff --git a/src/gallium/state_trackers/vega/api_images.c b/src/gallium/state_trackers/vega/api_images.c index 6c7fd3b346c..547508f815a 100644 --- a/src/gallium/state_trackers/vega/api_images.c +++ b/src/gallium/state_trackers/vega/api_images.c @@ -32,6 +32,7 @@ #include "vg_translate.h" #include "api_consts.h" #include "image.h" +#include "api.h" #include "pipe/p_context.h" #include "pipe/p_screen.h" @@ -92,9 +93,9 @@ static INLINE VGboolean supported_image_format(VGImageFormat format) return VG_FALSE; } -VGImage vgCreateImage(VGImageFormat format, - VGint width, VGint height, - VGbitfield allowedQuality) +VGImage vegaCreateImage(VGImageFormat format, + VGint width, VGint height, + VGbitfield allowedQuality) { struct vg_context *ctx = vg_current_context(); @@ -126,7 +127,7 @@ VGImage vgCreateImage(VGImageFormat format, return (VGImage)image_create(format, width, height); } -void vgDestroyImage(VGImage image) +void vegaDestroyImage(VGImage image) { struct vg_context *ctx = vg_current_context(); struct vg_image *img = (struct vg_image *)image; @@ -142,9 +143,9 @@ void vgDestroyImage(VGImage image) image_destroy(img); } -void vgClearImage(VGImage image, - VGint x, VGint y, - VGint width, VGint height) +void vegaClearImage(VGImage image, + VGint x, VGint y, + VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); struct vg_image *img; @@ -167,12 +168,12 @@ void vgClearImage(VGImage image, } -void vgImageSubData(VGImage image, - const void * data, - VGint dataStride, - VGImageFormat dataFormat, - VGint x, VGint y, - VGint width, VGint height) +void vegaImageSubData(VGImage image, + const void * data, + VGint dataStride, + VGImageFormat dataFormat, + VGint x, VGint y, + VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); struct vg_image *img; @@ -195,12 +196,12 @@ void vgImageSubData(VGImage image, x, y, width, height); } -void vgGetImageSubData(VGImage image, - void * data, - VGint dataStride, - VGImageFormat dataFormat, - VGint x, VGint y, - VGint width, VGint height) +void vegaGetImageSubData(VGImage image, + void * data, + VGint dataStride, + VGImageFormat dataFormat, + VGint x, VGint y, + VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); struct vg_image *img; @@ -222,9 +223,9 @@ void vgGetImageSubData(VGImage image, x, y, width, height); } -VGImage vgChildImage(VGImage parent, - VGint x, VGint y, - VGint width, VGint height) +VGImage vegaChildImage(VGImage parent, + VGint x, VGint y, + VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); struct vg_image *p; @@ -252,7 +253,7 @@ VGImage vgChildImage(VGImage parent, return (VGImage)image_child_image(p, x, y, width, height); } -VGImage vgGetParent(VGImage image) +VGImage vegaGetParent(VGImage image) { struct vg_context *ctx = vg_current_context(); struct vg_image *img; @@ -269,10 +270,10 @@ VGImage vgGetParent(VGImage image) return image; } -void vgCopyImage(VGImage dst, VGint dx, VGint dy, - VGImage src, VGint sx, VGint sy, - VGint width, VGint height, - VGboolean dither) +void vegaCopyImage(VGImage dst, VGint dx, VGint dy, + VGImage src, VGint sx, VGint sy, + VGint width, VGint height, + VGboolean dither) { struct vg_context *ctx = vg_current_context(); @@ -291,7 +292,7 @@ void vgCopyImage(VGImage dst, VGint dx, VGint dy, width, height, dither); } -void vgDrawImage(VGImage image) +void vegaDrawImage(VGImage image) { struct vg_context *ctx = vg_current_context(); @@ -307,9 +308,9 @@ void vgDrawImage(VGImage image) image_draw((struct vg_image*)image); } -void vgSetPixels(VGint dx, VGint dy, - VGImage src, VGint sx, VGint sy, - VGint width, VGint height) +void vegaSetPixels(VGint dx, VGint dy, + VGImage src, VGint sx, VGint sy, + VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); @@ -327,9 +328,9 @@ void vgSetPixels(VGint dx, VGint dy, height); } -void vgGetPixels(VGImage dst, VGint dx, VGint dy, - VGint sx, VGint sy, - VGint width, VGint height) +void vegaGetPixels(VGImage dst, VGint dx, VGint dy, + VGint sx, VGint sy, + VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); struct vg_image *img; @@ -349,10 +350,10 @@ void vgGetPixels(VGImage dst, VGint dx, VGint dy, sx, sy, width, height); } -void vgWritePixels(const void * data, VGint dataStride, - VGImageFormat dataFormat, - VGint dx, VGint dy, - VGint width, VGint height) +void vegaWritePixels(const void * data, VGint dataStride, + VGImageFormat dataFormat, + VGint dx, VGint dy, + VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); struct pipe_context *pipe = ctx->pipe; @@ -390,10 +391,10 @@ void vgWritePixels(const void * data, VGint dataStride, pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); } -void vgReadPixels(void * data, VGint dataStride, - VGImageFormat dataFormat, - VGint sx, VGint sy, - VGint width, VGint height) +void vegaReadPixels(void * data, VGint dataStride, + VGImageFormat dataFormat, + VGint sx, VGint sy, + VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); struct pipe_context *pipe = ctx->pipe; @@ -461,9 +462,9 @@ void vgReadPixels(void * data, VGint dataStride, } } -void vgCopyPixels(VGint dx, VGint dy, - VGint sx, VGint sy, - VGint width, VGint height) +void vegaCopyPixels(VGint dx, VGint dy, + VGint sx, VGint sy, + VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); struct pipe_framebuffer_state *fb = &ctx->state.g3d.fb; diff --git a/src/gallium/state_trackers/vega/api_masks.c b/src/gallium/state_trackers/vega/api_masks.c index 7c28ea5c872..94c1ff5375f 100644 --- a/src/gallium/state_trackers/vega/api_masks.c +++ b/src/gallium/state_trackers/vega/api_masks.c @@ -28,6 +28,7 @@ #include "mask.h" #include "renderer.h" +#include "api.h" #include "vg_context.h" #include "pipe/p_context.h" @@ -37,7 +38,6 @@ #include "util/u_draw_quad.h" #include "util/u_memory.h" - #define DISABLE_1_1_MASKING 1 /** @@ -151,9 +151,9 @@ clear_with_quad(struct vg_context *st, float x0, float y0, } -void vgMask(VGHandle mask, VGMaskOperation operation, - VGint x, VGint y, - VGint width, VGint height) +void vegaMask(VGHandle mask, VGMaskOperation operation, + VGint x, VGint y, + VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); @@ -189,8 +189,8 @@ void vgMask(VGHandle mask, VGMaskOperation operation, } } -void vgClear(VGint x, VGint y, - VGint width, VGint height) +void vegaClear(VGint x, VGint y, + VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); struct pipe_framebuffer_state *fb; @@ -225,9 +225,9 @@ void vgClear(VGint x, VGint y, #ifdef OPENVG_VERSION_1_1 -void vgRenderToMask(VGPath path, - VGbitfield paintModes, - VGMaskOperation operation) +void vegaRenderToMask(VGPath path, + VGbitfield paintModes, + VGMaskOperation operation) { struct vg_context *ctx = vg_current_context(); @@ -258,7 +258,7 @@ void vgRenderToMask(VGPath path, mask_render_to((struct path *)path, paintModes, operation); } -VGMaskLayer vgCreateMaskLayer(VGint width, VGint height) +VGMaskLayer vegaCreateMaskLayer(VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); @@ -272,7 +272,7 @@ VGMaskLayer vgCreateMaskLayer(VGint width, VGint height) return (VGMaskLayer)mask_layer_create(width, height); } -void vgDestroyMaskLayer(VGMaskLayer maskLayer) +void vegaDestroyMaskLayer(VGMaskLayer maskLayer) { struct vg_mask_layer *mask = 0; struct vg_context *ctx = vg_current_context(); @@ -290,10 +290,10 @@ void vgDestroyMaskLayer(VGMaskLayer maskLayer) mask_layer_destroy(mask); } -void vgFillMaskLayer(VGMaskLayer maskLayer, - VGint x, VGint y, - VGint width, VGint height, - VGfloat value) +void vegaFillMaskLayer(VGMaskLayer maskLayer, + VGint x, VGint y, + VGint width, VGint height, + VGfloat value) { struct vg_mask_layer *mask = 0; struct vg_context *ctx = vg_current_context(); @@ -336,10 +336,10 @@ void vgFillMaskLayer(VGMaskLayer maskLayer, mask_layer_fill(mask, x, y, width, height, value); } -void vgCopyMask(VGMaskLayer maskLayer, - VGint sx, VGint sy, - VGint dx, VGint dy, - VGint width, VGint height) +void vegaCopyMask(VGMaskLayer maskLayer, + VGint sx, VGint sy, + VGint dx, VGint dy, + VGint width, VGint height) { struct vg_context *ctx = vg_current_context(); struct vg_mask_layer *mask = 0; diff --git a/src/gallium/state_trackers/vega/api_misc.c b/src/gallium/state_trackers/vega/api_misc.c index 78ba0bc1103..e648549745b 100644 --- a/src/gallium/state_trackers/vega/api_misc.c +++ b/src/gallium/state_trackers/vega/api_misc.c @@ -27,10 +27,11 @@ #include "VG/openvg.h" #include "vg_context.h" +#include "api.h" /* Hardware Queries */ -VGHardwareQueryResult vgHardwareQuery(VGHardwareQueryType key, - VGint setting) +VGHardwareQueryResult vegaHardwareQuery(VGHardwareQueryType key, + VGint setting) { struct vg_context *ctx = vg_current_context(); @@ -58,7 +59,7 @@ VGHardwareQueryResult vgHardwareQuery(VGHardwareQueryType key, } /* Renderer and Extension Information */ -const VGubyte *vgGetString(VGStringID name) +const VGubyte *vegaGetString(VGStringID name) { struct vg_context *ctx = vg_current_context(); static const VGubyte *vendor = (VGubyte *)"Tungsten Graphics, Inc"; diff --git a/src/gallium/state_trackers/vega/api_paint.c b/src/gallium/state_trackers/vega/api_paint.c index dd3ac5bdb09..d88341b04ff 100644 --- a/src/gallium/state_trackers/vega/api_paint.c +++ b/src/gallium/state_trackers/vega/api_paint.c @@ -29,13 +29,14 @@ #include "vg_context.h" #include "paint.h" #include "image.h" +#include "api.h" -VGPaint vgCreatePaint(void) +VGPaint vegaCreatePaint(void) { return (VGPaint) paint_create(vg_current_context()); } -void vgDestroyPaint(VGPaint p) +void vegaDestroyPaint(VGPaint p) { struct vg_context *ctx = vg_current_context(); struct vg_paint *paint; @@ -49,7 +50,7 @@ void vgDestroyPaint(VGPaint p) paint_destroy(paint); } -void vgSetPaint(VGPaint paint, VGbitfield paintModes) +void vegaSetPaint(VGPaint paint, VGbitfield paintModes) { struct vg_context *ctx = vg_current_context(); @@ -74,7 +75,7 @@ void vgSetPaint(VGPaint paint, VGbitfield paintModes) } } -VGPaint vgGetPaint(VGPaintMode paintMode) +VGPaint vegaGetPaint(VGPaintMode paintMode) { struct vg_context *ctx = vg_current_context(); VGPaint paint = VG_INVALID_HANDLE; @@ -95,7 +96,7 @@ VGPaint vgGetPaint(VGPaintMode paintMode) return paint; } -void vgSetColor(VGPaint paint, VGuint rgba) +void vegaSetColor(VGPaint paint, VGuint rgba) { struct vg_context *ctx = vg_current_context(); @@ -114,7 +115,7 @@ void vgSetColor(VGPaint paint, VGuint rgba) } } -VGuint vgGetColor(VGPaint paint) +VGuint vegaGetColor(VGPaint paint) { struct vg_context *ctx = vg_current_context(); struct vg_paint *p; @@ -134,7 +135,7 @@ VGuint vgGetColor(VGPaint paint) return paint_colori(p); } -void vgPaintPattern(VGPaint paint, VGImage pattern) +void vegaPaintPattern(VGPaint paint, VGImage pattern) { struct vg_context *ctx = vg_current_context(); diff --git a/src/gallium/state_trackers/vega/api_params.c b/src/gallium/state_trackers/vega/api_params.c index db77fd9cb05..a10b009e631 100644 --- a/src/gallium/state_trackers/vega/api_params.c +++ b/src/gallium/state_trackers/vega/api_params.c @@ -32,6 +32,7 @@ #include "image.h" #include "matrix.h" #include "api_consts.h" +#include "api.h" #include "pipe/p_compiler.h" #include "util/u_pointer.h" @@ -63,7 +64,7 @@ static INLINE VGboolean count_in_bounds(VGParamType type, VGint count) } } -void vgSetf (VGParamType type, VGfloat value) +void vegaSetf (VGParamType type, VGfloat value) { struct vg_context *ctx = vg_current_context(); struct vg_state *state = current_state(); @@ -123,7 +124,7 @@ void vgSetf (VGParamType type, VGfloat value) vg_set_error(ctx, error); } -void vgSeti (VGParamType type, VGint value) +void vegaSeti (VGParamType type, VGint value) { struct vg_context *ctx = vg_current_context(); struct vg_state *state = current_state(); @@ -254,8 +255,8 @@ void vgSeti (VGParamType type, VGint value) vg_set_error(ctx, error); } -void vgSetfv(VGParamType type, VGint count, - const VGfloat * values) +void vegaSetfv(VGParamType type, VGint count, + const VGfloat * values) { struct vg_context *ctx = vg_current_context(); struct vg_state *state = current_state(); @@ -382,8 +383,8 @@ void vgSetfv(VGParamType type, VGint count, vg_set_error(ctx, error); } -void vgSetiv(VGParamType type, VGint count, - const VGint * values) +void vegaSetiv(VGParamType type, VGint count, + const VGint * values) { struct vg_context *ctx = vg_current_context(); struct vg_state *state = current_state(); @@ -506,7 +507,7 @@ void vgSetiv(VGParamType type, VGint count, } } -VGfloat vgGetf(VGParamType type) +VGfloat vegaGetf(VGParamType type) { struct vg_context *ctx = vg_current_context(); const struct vg_state *state = current_state(); @@ -568,7 +569,7 @@ VGfloat vgGetf(VGParamType type) return value; } -VGint vgGeti(VGParamType type) +VGint vegaGeti(VGParamType type) { const struct vg_state *state = current_state(); struct vg_context *ctx = vg_current_context(); @@ -683,7 +684,7 @@ VGint vgGeti(VGParamType type) return value; } -VGint vgGetVectorSize(VGParamType type) +VGint vegaGetVectorSize(VGParamType type) { struct vg_context *ctx = vg_current_context(); const struct vg_state *state = current_state(); @@ -757,8 +758,8 @@ VGint vgGetVectorSize(VGParamType type) } } -void vgGetfv(VGParamType type, VGint count, - VGfloat * values) +void vegaGetfv(VGParamType type, VGint count, + VGfloat * values) { const struct vg_state *state = current_state(); struct vg_context *ctx = vg_current_context(); @@ -858,8 +859,8 @@ void vgGetfv(VGParamType type, VGint count, } } -void vgGetiv(VGParamType type, VGint count, - VGint * values) +void vegaGetiv(VGParamType type, VGint count, + VGint * values) { const struct vg_state *state = current_state(); struct vg_context *ctx = vg_current_context(); @@ -964,9 +965,9 @@ void vgGetiv(VGParamType type, VGint count, } } -void vgSetParameterf(VGHandle object, - VGint paramType, - VGfloat value) +void vegaSetParameterf(VGHandle object, + VGint paramType, + VGfloat value) { struct vg_context *ctx = vg_current_context(); void *ptr = (void*)object; @@ -1018,9 +1019,9 @@ void vgSetParameterf(VGHandle object, } } -void vgSetParameteri(VGHandle object, - VGint paramType, - VGint value) +void vegaSetParameteri(VGHandle object, + VGint paramType, + VGint value) { struct vg_context *ctx = vg_current_context(); void *ptr = (void*)object; @@ -1093,10 +1094,10 @@ void vgSetParameteri(VGHandle object, } } -void vgSetParameterfv(VGHandle object, - VGint paramType, - VGint count, - const VGfloat * values) +void vegaSetParameterfv(VGHandle object, + VGint paramType, + VGint count, + const VGfloat * values) { struct vg_context *ctx = vg_current_context(); void *ptr = (void*)object; @@ -1206,10 +1207,10 @@ void vgSetParameterfv(VGHandle object, } } -void vgSetParameteriv(VGHandle object, - VGint paramType, - VGint count, - const VGint * values) +void vegaSetParameteriv(VGHandle object, + VGint paramType, + VGint count, + const VGint * values) { struct vg_context *ctx = vg_current_context(); void *ptr = (void*)object; @@ -1311,8 +1312,8 @@ void vgSetParameteriv(VGHandle object, } } -VGint vgGetParameterVectorSize(VGHandle object, - VGint paramType) +VGint vegaGetParameterVectorSize(VGHandle object, + VGint paramType) { struct vg_context *ctx = vg_current_context(); void *ptr = (void*)object; @@ -1367,8 +1368,8 @@ VGint vgGetParameterVectorSize(VGHandle object, } -VGfloat vgGetParameterf(VGHandle object, - VGint paramType) +VGfloat vegaGetParameterf(VGHandle object, + VGint paramType) { struct vg_context *ctx = vg_current_context(); void *ptr = (void*)object; @@ -1424,8 +1425,8 @@ VGfloat vgGetParameterf(VGHandle object, return 0; } -VGint vgGetParameteri(VGHandle object, - VGint paramType) +VGint vegaGetParameteri(VGHandle object, + VGint paramType) { struct vg_context *ctx = vg_current_context(); void *ptr = (void*)object; @@ -1511,10 +1512,10 @@ VGint vgGetParameteri(VGHandle object, return 0; } -void vgGetParameterfv(VGHandle object, - VGint paramType, - VGint count, - VGfloat * values) +void vegaGetParameterfv(VGHandle object, + VGint paramType, + VGint count, + VGfloat * values) { struct vg_context *ctx = vg_current_context(); void *ptr = (void*)object; @@ -1598,10 +1599,10 @@ void vgGetParameterfv(VGHandle object, } } -void vgGetParameteriv(VGHandle object, - VGint paramType, - VGint count, - VGint * values) +void vegaGetParameteriv(VGHandle object, + VGint paramType, + VGint count, + VGint * values) { struct vg_context *ctx = vg_current_context(); void *ptr = (void*)object; diff --git a/src/gallium/state_trackers/vega/api_path.c b/src/gallium/state_trackers/vega/api_path.c index 58ebb3b60ea..6c9a2e8d658 100644 --- a/src/gallium/state_trackers/vega/api_path.c +++ b/src/gallium/state_trackers/vega/api_path.c @@ -30,17 +30,18 @@ #include "path.h" #include "polygon.h" #include "paint.h" +#include "api.h" #include "pipe/p_context.h" #include "util/u_inlines.h" #include "util/u_draw_quad.h" -VGPath vgCreatePath(VGint pathFormat, - VGPathDatatype datatype, - VGfloat scale, VGfloat bias, - VGint segmentCapacityHint, - VGint coordCapacityHint, - VGbitfield capabilities) +VGPath vegaCreatePath(VGint pathFormat, + VGPathDatatype datatype, + VGfloat scale, VGfloat bias, + VGint segmentCapacityHint, + VGint coordCapacityHint, + VGbitfield capabilities) { struct vg_context *ctx = vg_current_context(); @@ -63,7 +64,7 @@ VGPath vgCreatePath(VGint pathFormat, capabilities); } -void vgClearPath(VGPath path, VGbitfield capabilities) +void vegaClearPath(VGPath path, VGbitfield capabilities) { struct vg_context *ctx = vg_current_context(); struct path *p = 0; @@ -77,7 +78,7 @@ void vgClearPath(VGPath path, VGbitfield capabilities) path_clear(p, capabilities); } -void vgDestroyPath(VGPath p) +void vegaDestroyPath(VGPath p) { struct path *path = 0; struct vg_context *ctx = vg_current_context(); @@ -91,8 +92,8 @@ void vgDestroyPath(VGPath p) path_destroy(path); } -void vgRemovePathCapabilities(VGPath path, - VGbitfield capabilities) +void vegaRemovePathCapabilities(VGPath path, + VGbitfield capabilities) { struct vg_context *ctx = vg_current_context(); VGbitfield current; @@ -109,7 +110,7 @@ void vgRemovePathCapabilities(VGPath path, (~(capabilities & VG_PATH_CAPABILITY_ALL)))); } -VGbitfield vgGetPathCapabilities(VGPath path) +VGbitfield vegaGetPathCapabilities(VGPath path) { struct vg_context *ctx = vg_current_context(); struct path *p = 0; @@ -122,7 +123,7 @@ VGbitfield vgGetPathCapabilities(VGPath path) return path_capabilities(p); } -void vgAppendPath(VGPath dstPath, VGPath srcPath) +void vegaAppendPath(VGPath dstPath, VGPath srcPath) { struct vg_context *ctx = vg_current_context(); struct path *src, *dst; @@ -142,10 +143,10 @@ void vgAppendPath(VGPath dstPath, VGPath srcPath) path_append_path(dst, src); } -void vgAppendPathData(VGPath dstPath, - VGint numSegments, - const VGubyte * pathSegments, - const void * pathData) +void vegaAppendPathData(VGPath dstPath, + VGint numSegments, + const VGubyte * pathSegments, + const void * pathData) { struct vg_context *ctx = vg_current_context(); struct path *p = 0; @@ -185,10 +186,10 @@ void vgAppendPathData(VGPath dstPath, path_append_data(p, numSegments, pathSegments, pathData); } -void vgModifyPathCoords(VGPath dstPath, - VGint startIndex, - VGint numSegments, - const void * pathData) +void vegaModifyPathCoords(VGPath dstPath, + VGint startIndex, + VGint numSegments, + const void * pathData) { struct vg_context *ctx = vg_current_context(); struct path *p = 0; @@ -220,7 +221,7 @@ void vgModifyPathCoords(VGPath dstPath, path_modify_coords(p, startIndex, numSegments, pathData); } -void vgTransformPath(VGPath dstPath, VGPath srcPath) +void vegaTransformPath(VGPath dstPath, VGPath srcPath) { struct vg_context *ctx = vg_current_context(); struct path *src = 0, *dst = 0; @@ -240,10 +241,10 @@ void vgTransformPath(VGPath dstPath, VGPath srcPath) path_transform(dst, src); } -VGboolean vgInterpolatePath(VGPath dstPath, - VGPath startPath, - VGPath endPath, - VGfloat amount) +VGboolean vegaInterpolatePath(VGPath dstPath, + VGPath startPath, + VGPath endPath, + VGfloat amount) { struct vg_context *ctx = vg_current_context(); struct path *start = 0, *dst = 0, *end = 0; @@ -269,9 +270,9 @@ VGboolean vgInterpolatePath(VGPath dstPath, start, end, amount); } -VGfloat vgPathLength(VGPath path, - VGint startSegment, - VGint numSegments) +VGfloat vegaPathLength(VGPath path, + VGint startSegment, + VGint numSegments) { struct vg_context *ctx = vg_current_context(); struct path *p = 0; @@ -302,13 +303,13 @@ VGfloat vgPathLength(VGPath path, return path_length(p, startSegment, numSegments); } -void vgPointAlongPath(VGPath path, - VGint startSegment, - VGint numSegments, - VGfloat distance, - VGfloat * x, VGfloat * y, - VGfloat * tangentX, - VGfloat * tangentY) +void vegaPointAlongPath(VGPath path, + VGint startSegment, + VGint numSegments, + VGfloat distance, + VGfloat * x, VGfloat * y, + VGfloat * tangentX, + VGfloat * tangentY) { struct vg_context *ctx = vg_current_context(); struct path *p = 0; @@ -362,11 +363,11 @@ void vgPointAlongPath(VGPath path, } } -void vgPathBounds(VGPath path, - VGfloat * minX, - VGfloat * minY, - VGfloat * width, - VGfloat * height) +void vegaPathBounds(VGPath path, + VGfloat * minX, + VGfloat * minY, + VGfloat * width, + VGfloat * height) { struct vg_context *ctx = vg_current_context(); struct path *p = 0; @@ -399,11 +400,11 @@ void vgPathBounds(VGPath path, path_bounding_rect(p, minX, minY, width, height); } -void vgPathTransformedBounds(VGPath path, - VGfloat * minX, - VGfloat * minY, - VGfloat * width, - VGfloat * height) +void vegaPathTransformedBounds(VGPath path, + VGfloat * minX, + VGfloat * minY, + VGfloat * width, + VGfloat * height) { struct vg_context *ctx = vg_current_context(); struct path *p = 0; @@ -466,7 +467,7 @@ void vgPathTransformedBounds(VGPath path, } -void vgDrawPath(VGPath path, VGbitfield paintModes) +void vegaDrawPath(VGPath path, VGbitfield paintModes) { struct vg_context *ctx = vg_current_context(); diff --git a/src/gallium/state_trackers/vega/api_text.c b/src/gallium/state_trackers/vega/api_text.c index d8411cf3e87..b35f3be90ab 100644 --- a/src/gallium/state_trackers/vega/api_text.c +++ b/src/gallium/state_trackers/vega/api_text.c @@ -27,6 +27,7 @@ #include "VG/openvg.h" #include "vg_context.h" +#include "api.h" #include "util/u_memory.h" @@ -39,7 +40,7 @@ struct vg_font { VGint num_glyphs; }; -VGFont vgCreateFont(VGint glyphCapacityHint) +VGFont vegaCreateFont(VGint glyphCapacityHint) { struct vg_font *font = 0; struct vg_context *ctx = vg_current_context(); @@ -55,7 +56,7 @@ VGFont vgCreateFont(VGint glyphCapacityHint) return (VGFont)font; } -void vgDestroyFont(VGFont f) +void vegaDestroyFont(VGFont f) { struct vg_font *font = (struct vg_font *)f; struct vg_context *ctx = vg_current_context(); @@ -69,12 +70,12 @@ void vgDestroyFont(VGFont f) /*free(font);*/ } -void vgSetGlyphToPath(VGFont font, - VGuint glyphIndex, - VGPath path, - VGboolean isHinted, - VGfloat glyphOrigin [2], - VGfloat escapement[2]) +void vegaSetGlyphToPath(VGFont font, + VGuint glyphIndex, + VGPath path, + VGboolean isHinted, + VGfloat glyphOrigin [2], + VGfloat escapement[2]) { struct vg_context *ctx = vg_current_context(); struct vg_object *pathObj; @@ -106,11 +107,11 @@ void vgSetGlyphToPath(VGFont font, ++f->num_glyphs; } -void vgSetGlyphToImage(VGFont font, - VGuint glyphIndex, - VGImage image, - VGfloat glyphOrigin [2], - VGfloat escapement[2]) +void vegaSetGlyphToImage(VGFont font, + VGuint glyphIndex, + VGImage image, + VGfloat glyphOrigin [2], + VGfloat escapement[2]) { struct vg_context *ctx = vg_current_context(); struct vg_object *img_obj; @@ -153,8 +154,8 @@ static INLINE VGboolean font_contains_glyph(struct vg_font *font, return VG_FALSE; } -void vgClearGlyph(VGFont font, - VGuint glyphIndex) +void vegaClearGlyph(VGFont font, + VGuint glyphIndex) { struct vg_context *ctx = vg_current_context(); struct vg_font *f; @@ -184,10 +185,10 @@ void vgClearGlyph(VGFont font, } } -void vgDrawGlyph(VGFont font, - VGuint glyphIndex, - VGbitfield paintModes, - VGboolean allowAutoHinting) +void vegaDrawGlyph(VGFont font, + VGuint glyphIndex, + VGbitfield paintModes, + VGboolean allowAutoHinting) { struct vg_context *ctx = vg_current_context(); struct vg_font *f; @@ -211,13 +212,13 @@ void vgDrawGlyph(VGFont font, } } -void vgDrawGlyphs(VGFont font, - VGint glyphCount, - VGuint *glyphIndices, - VGfloat *adjustments_x, - VGfloat *adjustments_y, - VGbitfield paintModes, - VGboolean allowAutoHinting) +void vegaDrawGlyphs(VGFont font, + VGint glyphCount, + VGuint *glyphIndices, + VGfloat *adjustments_x, + VGfloat *adjustments_y, + VGbitfield paintModes, + VGboolean allowAutoHinting) { struct vg_context *ctx = vg_current_context(); VGint i; diff --git a/src/gallium/state_trackers/vega/api_transform.c b/src/gallium/state_trackers/vega/api_transform.c index 763a5ec415c..0a40fc69b95 100644 --- a/src/gallium/state_trackers/vega/api_transform.c +++ b/src/gallium/state_trackers/vega/api_transform.c @@ -29,15 +29,16 @@ #include "vg_context.h" #include "matrix.h" +#include "api.h" -void vgLoadIdentity(void) +void vegaLoadIdentity(void) { struct vg_context *ctx = vg_current_context(); struct matrix *mat = vg_state_matrix(&ctx->state.vg); matrix_load_identity(mat); } -void vgLoadMatrix(const VGfloat * m) +void vegaLoadMatrix(const VGfloat * m) { struct vg_context *ctx = vg_current_context(); struct matrix *mat; @@ -59,7 +60,7 @@ void vgLoadMatrix(const VGfloat * m) } } -void vgGetMatrix(VGfloat * m) +void vegaGetMatrix(VGfloat * m) { struct vg_context *ctx = vg_current_context(); struct matrix *mat; @@ -76,7 +77,7 @@ void vgGetMatrix(VGfloat * m) memcpy(m, mat->m, sizeof(VGfloat)*9); } -void vgMultMatrix(const VGfloat * m) +void vegaMultMatrix(const VGfloat * m) { struct vg_context *ctx = vg_current_context(); struct matrix *dst, src; @@ -99,28 +100,28 @@ void vgMultMatrix(const VGfloat * m) } -void vgTranslate(VGfloat tx, VGfloat ty) +void vegaTranslate(VGfloat tx, VGfloat ty) { struct vg_context *ctx = vg_current_context(); struct matrix *dst = vg_state_matrix(&ctx->state.vg); matrix_translate(dst, tx, ty); } -void vgScale(VGfloat sx, VGfloat sy) +void vegaScale(VGfloat sx, VGfloat sy) { struct vg_context *ctx = vg_current_context(); struct matrix *dst = vg_state_matrix(&ctx->state.vg); matrix_scale(dst, sx, sy); } -void vgShear(VGfloat shx, VGfloat shy) +void vegaShear(VGfloat shx, VGfloat shy) { struct vg_context *ctx = vg_current_context(); struct matrix *dst = vg_state_matrix(&ctx->state.vg); matrix_shear(dst, shx, shy); } -void vgRotate(VGfloat angle) +void vegaRotate(VGfloat angle) { struct vg_context *ctx = vg_current_context(); struct matrix *dst = vg_state_matrix(&ctx->state.vg); diff --git a/src/gallium/state_trackers/vega/polygon.c b/src/gallium/state_trackers/vega/polygon.c index d2b7e489124..e9c8f031373 100644 --- a/src/gallium/state_trackers/vega/polygon.c +++ b/src/gallium/state_trackers/vega/polygon.c @@ -379,7 +379,7 @@ void polygon_fill(struct polygon *poly, struct vg_context *ctx) dsa.stencil[0].func = PIPE_FUNC_ALWAYS; dsa.stencil[0].valuemask = ~0; - raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH; + raster.cull_face = PIPE_FACE_BACK; dsa.stencil[0].fail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_INCR_WRAP; @@ -389,7 +389,7 @@ void polygon_fill(struct polygon *poly, struct vg_context *ctx) cso_set_rasterizer(ctx->cso_context, &raster); draw_polygon(ctx, poly); - raster.cull_mode = raster.front_winding; + raster.cull_face = PIPE_FACE_FRONT; dsa.stencil[0].fail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_DECR_WRAP; @@ -501,7 +501,7 @@ void polygon_array_fill(struct polygon_array *polyarray, struct vg_context *ctx) dsa.stencil[0].func = PIPE_FUNC_ALWAYS; dsa.stencil[0].valuemask = ~0; - raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH; + raster.cull_face = PIPE_FACE_BACK; dsa.stencil[0].fail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_INCR_WRAP; @@ -514,7 +514,7 @@ void polygon_array_fill(struct polygon_array *polyarray, struct vg_context *ctx) draw_polygon(ctx, poly); } - raster.cull_mode = raster.front_winding; + raster.cull_face = PIPE_FACE_FRONT; dsa.stencil[0].fail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP; dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_DECR_WRAP; diff --git a/src/gallium/state_trackers/vega/vg_api.h b/src/gallium/state_trackers/vega/vg_api.h new file mode 100644 index 00000000000..ce2a0d6bb47 --- /dev/null +++ b/src/gallium/state_trackers/vega/vg_api.h @@ -0,0 +1,37 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#ifndef VG_API_H +#define VG_API_H + +struct st_api; + +const struct st_api * +vg_api_get(void); + +#endif /* VG_API_H */ diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index b55a2b57bed..f02db8949df 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -33,6 +33,7 @@ #include "asm_util.h" #include "st_inlines.h" #include "vg_manager.h" +#include "api.h" #include "pipe/p_context.h" #include "util/u_inlines.h" @@ -67,6 +68,7 @@ static void init_clear(struct vg_context *st) void vg_set_current_context(struct vg_context *ctx) { _vg_context = ctx; + api_make_dispatch_current((ctx) ? ctx->dispatch : NULL); } struct vg_context * vg_create_context(struct pipe_context *pipe, @@ -80,6 +82,8 @@ struct vg_context * vg_create_context(struct pipe_context *pipe, ctx->pipe = pipe; + ctx->dispatch = api_create_dispatch(); + vg_init_state(&ctx->state.vg); ctx->state.dirty = ALL_DIRTY; @@ -185,6 +189,8 @@ void vg_destroy_context(struct vg_context *ctx) cso_hash_delete(ctx->owned_objects[VG_OBJECT_FONT]); cso_hash_delete(ctx->owned_objects[VG_OBJECT_PATH]); + api_destroy_dispatch(ctx->dispatch); + free(ctx); } diff --git a/src/gallium/state_trackers/vega/vg_context.h b/src/gallium/state_trackers/vega/vg_context.h index dac67192a54..7b59ad512a0 100644 --- a/src/gallium/state_trackers/vega/vg_context.h +++ b/src/gallium/state_trackers/vega/vg_context.h @@ -42,6 +42,7 @@ struct renderer; struct shaders_cache; struct shader; struct vg_shader; +struct mapi_table; struct st_renderbuffer { enum pipe_format format; @@ -90,6 +91,7 @@ enum dirty_state { struct vg_context { struct st_context_iface iface; + struct mapi_table *dispatch; struct pipe_context *pipe; diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c index 8a62a191207..3b04816df04 100644 --- a/src/gallium/state_trackers/vega/vg_manager.c +++ b/src/gallium/state_trackers/vega/vg_manager.c @@ -36,10 +36,12 @@ #include "util/u_format.h" #include "util/u_sampler.h" +#include "vg_api.h" #include "vg_manager.h" #include "vg_context.h" #include "image.h" #include "mask.h" +#include "api.h" static struct pipe_resource * create_texture(struct pipe_context *pipe, enum pipe_format format, @@ -526,17 +528,15 @@ vg_api_is_visual_supported(struct st_api *stapi, static st_proc_t vg_api_get_proc_address(struct st_api *stapi, const char *procname) { - /* TODO */ - return (st_proc_t) NULL; + return api_get_proc_address(procname); } static void vg_api_destroy(struct st_api *stapi) { - free(stapi); } -struct st_api st_vg_api = { +static const struct st_api vg_api = { vg_api_destroy, vg_api_get_proc_address, vg_api_is_visual_supported, @@ -545,8 +545,8 @@ struct st_api st_vg_api = { vg_api_get_current, }; -struct st_api * -st_api_create_OpenVG(void) +const struct st_api * +vg_api_get(void) { - return &st_vg_api; + return &vg_api; } diff --git a/src/gallium/state_trackers/wgl/SConscript b/src/gallium/state_trackers/wgl/SConscript index f59f3a9638a..0f580b859c6 100644 --- a/src/gallium/state_trackers/wgl/SConscript +++ b/src/gallium/state_trackers/wgl/SConscript @@ -7,6 +7,7 @@ if env['platform'] in ['windows']: env = env.Clone() env.Append(CPPPATH = [ + '#src/mapi', '#src/mesa', '.', ]) diff --git a/src/gallium/state_trackers/xorg/SConscript b/src/gallium/state_trackers/xorg/SConscript index 5d0b6613ac7..0b598dab6e3 100644 --- a/src/gallium/state_trackers/xorg/SConscript +++ b/src/gallium/state_trackers/xorg/SConscript @@ -11,13 +11,15 @@ if 'xorg' in env['statetrackers']: '#/src/mesa', ]) - env.ParseConfig('pkg-config --cflags --libs xorg-server') + env.ParseConfig('pkg-config --cflags --libs libdrm xorg-server') conf = env.Configure() if conf.CheckHeader('X11/extensions/dpmsconst.h'): env.Append(CPPDEFINES = [('HAVE_XEXTPROTO_71', '1')]) + conf.Finish() + st_xorg = env.ConvenienceLibrary( target = 'st_xorg', source = [ 'xorg_composite.c', diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 669bd9edcf0..f9022a9f934 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -90,11 +90,10 @@ crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn); modesettingPtr ms = modesettingPTR(crtc->scrn); xf86OutputPtr output = NULL; - drmModeConnectorPtr drm_connector; struct crtc_private *crtcp = crtc->driver_private; drmModeCrtcPtr drm_crtc = crtcp->drm_crtc; drmModeModeInfo drm_mode; - int i, ret; + int i, ret, connector_id; for (i = 0; i < config->num_output; output = NULL, i++) { output = config->output[i]; @@ -106,7 +105,7 @@ crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, if (!output) return FALSE; - drm_connector = output->driver_private; + connector_id = xorg_output_get_id(output); drm_mode.clock = mode->Clock; drm_mode.hdisplay = mode->HDisplay; @@ -127,7 +126,7 @@ crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, drm_mode.name[DRM_DISPLAY_MODE_LEN - 1] = '\0'; ret = drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y, - &drm_connector->connector_id, 1, &drm_mode); + &connector_id, 1, &drm_mode); if (ret) return FALSE; diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index 35741f86842..e719644d340 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -403,7 +403,7 @@ xorg_dri2_init(ScreenPtr pScreen) } #endif - dri2info.version = DRI2INFOREC_VERSION; + dri2info.version = min(DRI2INFOREC_VERSION, 3); dri2info.fd = ms->fd; dri2info.driverName = pScrn->driverName; diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 3687ee0db4e..44520b81b66 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -141,8 +141,6 @@ xorg_tracker_have_modesetting(ScrnInfoPtr pScrn, struct pci_device *device) static Bool drv_init_front_buffer_functions(ScrnInfoPtr pScrn); static Bool drv_close_screen(int scrnIndex, ScreenPtr pScreen); -static Bool drv_save_hw_state(ScrnInfoPtr pScrn); -static Bool drv_restore_hw_state(ScrnInfoPtr pScrn); /* @@ -336,17 +334,9 @@ static Bool drv_close_resource_management(ScrnInfoPtr pScrn) { modesettingPtr ms = modesettingPTR(pScrn); - int i; if (ms->screen) { assert(ms->ctx == NULL); - - for (i = 0; i < XORG_NR_FENCES; i++) { - if (ms->fence[i]) { - ms->screen->fence_finish(ms->screen, ms->fence[i], 0); - ms->screen->fence_reference(ms->screen, &ms->fence[i], NULL); - } - } ms->screen->destroy(ms->screen); } ms->screen = NULL; @@ -359,6 +349,22 @@ drv_close_resource_management(ScrnInfoPtr pScrn) return TRUE; } +static void +drv_cleanup_fences(ScrnInfoPtr pScrn) +{ + modesettingPtr ms = modesettingPTR(pScrn); + int i; + + assert(ms->screen); + + for (i = 0; i < XORG_NR_FENCES; i++) { + if (ms->fence[i]) { + ms->screen->fence_finish(ms->screen, ms->fence[i], 0); + ms->screen->fence_reference(ms->screen, &ms->fence[i], NULL); + } + } +} + static Bool drv_pre_init(ScrnInfoPtr pScrn, int flags) { @@ -388,7 +394,6 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags) return FALSE; ms = modesettingPTR(pScrn); - ms->SaveGeneration = -1; ms->pEnt = pEnt; ms->cust = cust; @@ -471,19 +476,14 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags) ms->SWCursor = TRUE; } - drv_save_hw_state(pScrn); - xorg_crtc_init(pScrn); xorg_output_init(pScrn); if (!xf86InitialConfiguration(pScrn, TRUE)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes.\n"); - drv_restore_hw_state(pScrn); return FALSE; } - drv_restore_hw_state(pScrn); - /* * If the driver can do gamma correction, it should call xf86SetGamma() here. */ @@ -521,22 +521,6 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags) return TRUE; } -static Bool -drv_save_hw_state(ScrnInfoPtr pScrn) -{ - /*xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);*/ - - return TRUE; -} - -static Bool -drv_restore_hw_state(ScrnInfoPtr pScrn) -{ - /*xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);*/ - - return TRUE; -} - static void drv_block_handler(int i, pointer blockData, pointer pTimeout, pointer pReadmask) { @@ -848,7 +832,9 @@ drv_leave_vt(int scrnIndex, int flags) drmModeRmFB(ms->fd, ms->fb_id); ms->fb_id = -1; - drv_restore_hw_state(pScrn); + /* idle hardware */ + if (!ms->kms) + drv_cleanup_fences(pScrn); if (drmDropMaster(ms->fd)) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, @@ -878,15 +864,6 @@ drv_enter_vt(int scrnIndex, int flags) } } - /* - * Only save state once per server generation since that's what most - * drivers do. Could change this to save state at each VT enter. - */ - if (ms->SaveGeneration != serverGeneration) { - ms->SaveGeneration = serverGeneration; - drv_save_hw_state(pScrn); - } - if (!ms->create_front_buffer(pScrn)) return FALSE; @@ -917,10 +894,6 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen) modesettingPtr ms = modesettingPTR(pScrn); CustomizerPtr cust = ms->cust; - if (pScrn->vtSema) { - drv_leave_vt(scrnIndex, 0); - } - if (ms->cursor) { FreeCursor(ms->cursor, None); ms->cursor = NULL; @@ -952,6 +925,11 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen) xorg_exa_close(pScrn); ms->exa = NULL; + /* calls drop master make sure we don't talk to 3D HW after that */ + if (pScrn->vtSema) { + drv_leave_vt(scrnIndex, 0); + } + drv_close_resource_management(pScrn); drv_close_drm(pScrn); diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 6657f7391b2..ee40bc8ccbd 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -968,6 +968,8 @@ xorg_exa_close(ScrnInfoPtr pScrn) renderer_destroy(exa->renderer); + xorg_exa_finish(exa); + if (exa->pipe) exa->pipe->destroy(exa->pipe); exa->pipe = NULL; diff --git a/src/gallium/state_trackers/xorg/xorg_output.c b/src/gallium/state_trackers/xorg/xorg_output.c index 13c3fb97e3b..056098f76b4 100644 --- a/src/gallium/state_trackers/xorg/xorg_output.c +++ b/src/gallium/state_trackers/xorg/xorg_output.c @@ -51,6 +51,13 @@ #include "xorg_tracker.h" +struct output_private +{ + drmModeConnectorPtr drm_connector; + + int c; +}; + static char *output_enum_list[] = { "Unknown", "VGA", @@ -82,22 +89,38 @@ output_dpms(xf86OutputPtr output, int mode) static xf86OutputStatus output_detect(xf86OutputPtr output) { - drmModeConnectorPtr drm_connector = output->driver_private; + modesettingPtr ms = modesettingPTR(output->scrn); + struct output_private *priv = output->driver_private; + drmModeConnectorPtr drm_connector; + xf86OutputStatus status; + + drm_connector = drmModeGetConnector(ms->fd, priv->drm_connector->connector_id); + if (drm_connector) { + drmModeFreeConnector(priv->drm_connector); + priv->drm_connector = drm_connector; + } else { + drm_connector = priv->drm_connector; + } switch (drm_connector->connection) { case DRM_MODE_CONNECTED: - return XF86OutputStatusConnected; + status = XF86OutputStatusConnected; + break; case DRM_MODE_DISCONNECTED: - return XF86OutputStatusDisconnected; + status = XF86OutputStatusDisconnected; + break; default: - return XF86OutputStatusUnknown; + status = XF86OutputStatusUnknown; } + + return status; } static DisplayModePtr output_get_modes(xf86OutputPtr output) { - drmModeConnectorPtr drm_connector = output->driver_private; + struct output_private *priv = output->driver_private; + drmModeConnectorPtr drm_connector = priv->drm_connector; drmModeModeInfoPtr drm_mode = NULL; DisplayModePtr modes = NULL, mode = NULL; int i; @@ -161,7 +184,10 @@ output_get_property(xf86OutputPtr output, Atom property) static void output_destroy(xf86OutputPtr output) { - drmModeFreeConnector(output->driver_private); + struct output_private *priv = output->driver_private; + drmModeFreeConnector(priv->drm_connector); + xfree(priv); + output->driver_private = NULL; } static const xf86OutputFuncsRec output_funcs = { @@ -188,6 +214,7 @@ xorg_output_init(ScrnInfoPtr pScrn) drmModeResPtr res; drmModeConnectorPtr drm_connector = NULL; drmModeEncoderPtr drm_encoder = NULL; + struct output_private *priv; char name[32]; int c, v, p; @@ -226,9 +253,16 @@ xorg_output_init(ScrnInfoPtr pScrn) drm_connector->connector_type_id); + priv = xcalloc(sizeof(*priv), 1); + if (!priv) { + continue; + } + output = xf86OutputCreate(pScrn, &output_funcs, name); - if (!output) + if (!output) { + xfree(priv); continue; + } drm_encoder = drmModeGetEncoder(ms->fd, drm_connector->encoders[0]); if (drm_encoder) { @@ -238,7 +272,9 @@ xorg_output_init(ScrnInfoPtr pScrn) output->possible_crtcs = 0; output->possible_clones = 0; } - output->driver_private = drm_connector; + priv->c = c; + priv->drm_connector = drm_connector; + output->driver_private = priv; output->subpixel_order = SubPixelHorizontalRGB; output->interlaceAllowed = FALSE; output->doubleScanAllowed = FALSE; @@ -248,4 +284,11 @@ xorg_output_init(ScrnInfoPtr pScrn) drmModeFreeResources(res); } +unsigned +xorg_output_get_id(xf86OutputPtr output) +{ + struct output_private *priv = output->driver_private; + return priv->drm_connector->connector_id; +} + /* vim: set sw=4 ts=8 sts=4: */ diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c index 1576e5ea01b..e5def3e2edd 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.c +++ b/src/gallium/state_trackers/xorg/xorg_renderer.c @@ -7,7 +7,6 @@ #include "util/u_draw_quad.h" #include "util/u_math.h" #include "util/u_memory.h" -#include "util/u_rect.h" #include "util/u_sampler.h" #include "util/u_surface.h" diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h index cb6773424a8..65fbc3234ba 100644 --- a/src/gallium/state_trackers/xorg/xorg_tracker.h +++ b/src/gallium/state_trackers/xorg/xorg_tracker.h @@ -96,8 +96,6 @@ typedef struct _modesettingRec /* Broken-out options. */ OptionInfoPtr Options; - unsigned int SaveGeneration; - void (*blockHandler)(int, pointer, pointer, pointer); struct pipe_fence_handle *fence[XORG_NR_FENCES]; @@ -192,6 +190,9 @@ xorg_crtc_cursor_destroy(xf86CrtcPtr crtc); void xorg_output_init(ScrnInfoPtr pScrn); +unsigned +xorg_output_get_id(xf86OutputPtr output); + /*********************************************************************** * xorg_xv.c diff --git a/src/gallium/targets/Makefile.dri b/src/gallium/targets/Makefile.dri index 3cbaf615e2f..3eff07538fe 100644 --- a/src/gallium/targets/Makefile.dri +++ b/src/gallium/targets/Makefile.dri @@ -1,7 +1,6 @@ # -*-makefile-*- ifeq ($(MESA_LLVM),1) -DRIVER_DEFINES += -DGALLIUM_LLVMPIPE PIPE_DRIVERS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a LDFLAGS += $(LLVM_LDFLAGS) LD = g++ @@ -42,13 +41,13 @@ SHARED_INCLUDES = \ -Iserver \ -I$(TOP)/include \ -I$(TOP)/include/GL/internal \ + -I$(TOP)/src/mapi \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/auxiliary \ -I$(TOP)/src/gallium/drivers \ -I$(TOP)/src/gallium/winsys \ -I$(TOP)/src/mesa \ -I$(TOP)/src/mesa/main \ - -I$(TOP)/src/mesa/glapi \ -I$(TOP)/src/mesa/math \ -I$(TOP)/src/mesa/transform \ -I$(TOP)/src/mesa/shader \ diff --git a/src/gallium/targets/Makefile.egl b/src/gallium/targets/Makefile.egl index 9265e2eb7bc..4f8641e0561 100644 --- a/src/gallium/targets/Makefile.egl +++ b/src/gallium/targets/Makefile.egl @@ -19,10 +19,17 @@ x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a \ $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/identity/libidentity.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes +ifeq ($(MESA_LLVM),1) +x11_ST += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a +x11_LIBS += $(LLVM_LIBS) +LDFLAGS += $(LLVM_LDFLAGS) +endif + kms_ST = $(TOP)/src/gallium/state_trackers/egl/libeglkms.a kms_LIBS = $(common_LIBS) @@ -36,19 +43,20 @@ kms_LIBS = $(common_LIBS) EGL_DISPLAY_DRIVERS = $(foreach dpy, $(EGL_DISPLAYS), egl_$(dpy)_$(EGL_DRIVER_NAME).so) -EGL_DISPLAY_LIBS = $(foreach drv, $(EGL_DISPLAY_DRIVERS), $(TOP)/$(LIB_DIR)/$(drv)) +EGL_DISPLAY_LIBS = $(foreach drv, $(EGL_DISPLAY_DRIVERS), $(TOP)/$(LIB_DIR)/egl/$(drv)) default: $(EGL_DISPLAY_LIBS) -$(EGL_DISPLAY_LIBS): $(TOP)/$(LIB_DIR)/%.so: %.so - $(INSTALL) $< $(TOP)/$(LIB_DIR) +$(EGL_DISPLAY_LIBS): $(TOP)/$(LIB_DIR)/egl/%.so: %.so + @$(INSTALL) -d $(TOP)/$(LIB_DIR)/egl + $(INSTALL) $< $(TOP)/$(LIB_DIR)/egl define mklib-egl $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) \ -Wl,--start-group $($(1)_ST) $(EGL_DRIVER_PIPES) \ $(GALLIUM_AUXILIARIES) -Wl,--end-group \ - $($(1)_LIBS) $(EGL_DRIVER_LIBS) + $($(1)_LIBS) $(EGL_DRIVER_LIBS) -L$(TOP)/$(LIB_DIR) -l$(EGL_LIB) endef egl_x11_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(x11_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile diff --git a/src/gallium/targets/SConscript b/src/gallium/targets/SConscript index 1292d4f6193..9077cbf6a45 100644 --- a/src/gallium/targets/SConscript +++ b/src/gallium/targets/SConscript @@ -1,5 +1,8 @@ +import os Import('*') +# Compatibility with old build scripts: +# if 'xlib' in env['winsys']: SConscript([ 'libgl-xlib/SConscript', @@ -10,10 +13,10 @@ if 'gdi' in env['winsys']: 'libgl-gdi/SConscript', ]) -if 'graw-xlib' in env['winsys']: - SConscript([ - 'graw-xlib/SConscript', - ]) +if not 'graw-xlib' in env['targets'] and not env['msvc']: + # XXX: disable until MSVC can link correctly + SConscript('graw-null/SConscript') + if env['dri']: SConscript([ @@ -25,3 +28,13 @@ if 'xorg' in env['statetrackers']: SConscript([ 'xorg-vmwgfx/SConscript', ]) + +# Ideally all non-target directories would produce convenience +# libraries, and the actual shared libraries and other installables +# would be finally assembled in the targets subtree: +# +for target in env['targets']: + SConscript(os.path.join(target, 'SConscript')) + + + diff --git a/src/gallium/targets/SConscript.dri b/src/gallium/targets/SConscript.dri index 28fbe02ab8d..4bbb16c2272 100644 --- a/src/gallium/targets/SConscript.dri +++ b/src/gallium/targets/SConscript.dri @@ -9,6 +9,7 @@ drienv.Replace(CPPPATH = [ '#src/mesa/drivers/dri/common', '#include', '#include/GL/internal', + '#src/mapi', '#src/gallium/include', '#src/gallium/auxiliary', '#src/gallium/drivers', diff --git a/src/gallium/targets/dri-i915/Makefile b/src/gallium/targets/dri-i915/Makefile index 50a8e11e17c..fdcfd08c227 100644 --- a/src/gallium/targets/dri-i915/Makefile +++ b/src/gallium/targets/dri-i915/Makefile @@ -7,6 +7,7 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \ $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/identity/libidentity.a \ $(TOP)/src/gallium/drivers/i915/libi915.a diff --git a/src/gallium/targets/dri-i915/SConscript b/src/gallium/targets/dri-i915/SConscript index 2fcc8028f12..65c42398875 100644 --- a/src/gallium/targets/dri-i915/SConscript +++ b/src/gallium/targets/dri-i915/SConscript @@ -13,6 +13,7 @@ env.Prepend(LIBS = [ i915drm, i915, trace, + rbug, mesa, glsl, gallium, diff --git a/src/gallium/targets/dri-i965/Makefile b/src/gallium/targets/dri-i965/Makefile index e267ba3a023..13987c643e2 100644 --- a/src/gallium/targets/dri-i965/Makefile +++ b/src/gallium/targets/dri-i965/Makefile @@ -7,6 +7,7 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \ $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a \ $(TOP)/src/gallium/winsys/sw/drm/libswdrm.a \ $(TOP)/src/gallium/winsys/sw/wrapper/libwsw.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ diff --git a/src/gallium/targets/dri-i965/SConscript b/src/gallium/targets/dri-i965/SConscript index eb9e6cd172a..13ac5a2d8ea 100644 --- a/src/gallium/targets/dri-i965/SConscript +++ b/src/gallium/targets/dri-i965/SConscript @@ -11,8 +11,11 @@ env.ParseConfig('pkg-config --cflags --libs libdrm_intel') env.Prepend(LIBS = [ st_dri, i965drm, + ws_drm, + ws_wrapper, i965, trace, + rbug, mesa, glsl, gallium, diff --git a/src/gallium/targets/dri-radeong/Makefile b/src/gallium/targets/dri-radeong/Makefile index 66dd392b68b..8ef24c08215 100644 --- a/src/gallium/targets/dri-radeong/Makefile +++ b/src/gallium/targets/dri-radeong/Makefile @@ -8,6 +8,7 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a \ $(TOP)/src/gallium/drivers/r300/libr300.a C_SOURCES = \ diff --git a/src/gallium/targets/dri-radeong/SConscript b/src/gallium/targets/dri-radeong/SConscript index d926c272889..4c6cfb84eba 100644 --- a/src/gallium/targets/dri-radeong/SConscript +++ b/src/gallium/targets/dri-radeong/SConscript @@ -13,6 +13,7 @@ env.Prepend(LIBS = [ radeonwinsys, r300, trace, + rbug, mesa, glsl, gallium, diff --git a/src/gallium/targets/dri-swrast/Makefile b/src/gallium/targets/dri-swrast/Makefile index 3db9781c209..0a53eb56c45 100644 --- a/src/gallium/targets/dri-swrast/Makefile +++ b/src/gallium/targets/dri-swrast/Makefile @@ -9,7 +9,8 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/sw/libdrisw.a \ $(TOP)/src/gallium/winsys/sw/dri/libswdri.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a SWRAST_COMMON_GALLIUM_SOURCES = \ $(TOP)/src/mesa/drivers/dri/common/utils.c \ diff --git a/src/gallium/targets/dri-swrast/SConscript b/src/gallium/targets/dri-swrast/SConscript index 77f44384d06..679afab41c7 100644 --- a/src/gallium/targets/dri-swrast/SConscript +++ b/src/gallium/targets/dri-swrast/SConscript @@ -10,6 +10,7 @@ env.Prepend(LIBS = [ st_drisw, ws_dri, trace, + rbug, mesa, glsl, gallium, diff --git a/src/gallium/targets/dri-vmwgfx/Makefile b/src/gallium/targets/dri-vmwgfx/Makefile index 4b002e828fa..b5b679f3c7c 100644 --- a/src/gallium/targets/dri-vmwgfx/Makefile +++ b/src/gallium/targets/dri-vmwgfx/Makefile @@ -7,6 +7,7 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \ $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a \ $(TOP)/src/gallium/drivers/svga/libsvga.a C_SOURCES = \ diff --git a/src/gallium/targets/dri-vmwgfx/SConscript b/src/gallium/targets/dri-vmwgfx/SConscript index 6a1f8827bc3..09a0c254c30 100644 --- a/src/gallium/targets/dri-vmwgfx/SConscript +++ b/src/gallium/targets/dri-vmwgfx/SConscript @@ -11,6 +11,7 @@ env.Prepend(LIBS = [ svgadrm, svga, trace, + rbug, mesa, glsl, gallium, diff --git a/src/gallium/targets/egl-apis/Makefile b/src/gallium/targets/egl-apis/Makefile new file mode 100644 index 00000000000..88915bfc5ec --- /dev/null +++ b/src/gallium/targets/egl-apis/Makefile @@ -0,0 +1,77 @@ +# src/gallium/targets/egl-apis + +TOP = ../../../.. +include $(TOP)/configs/current + +OUTPUT_PREFIX := api_ +OUTPUT_PATH := $(TOP)/$(LIB_DIR)/egl + +OUTPUTS := $(addsuffix .so, $(EGL_CLIENT_APIS)) +OUTPUTS := $(addprefix $(OUTPUT_PATH)/$(OUTPUT_PREFIX), $(OUTPUTS)) + +# include dirs +GL_INCLUDES := -I$(TOP)/src/mesa -I$(TOP)/src/gallium/include +GLESv1_CM_INCLUDES := $(GL_INCLUDES) +GLESv2_INCLUDES := $(GL_INCLUDES) +OpenVG_INCLUDES := -I$(TOP)/src/gallium/state_trackers/vega -I$(TOP)/src/gallium/include + +# system libs +GL_SYS := -lpthread -lm -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) +GLESv1_CM_SYS := -lpthread -lm -L$(TOP)/$(LIB_DIR) -l$(GLESv1_CM_LIB) +GLESv2_SYS := -lpthread -lm -L$(TOP)/$(LIB_DIR) -l$(GLESv2_LIB) +OpenVG_SYS := -lm -L$(TOP)/$(LIB_DIR) -l$(VG_LIB) + +# $(LLVM_LIBS) will be discarded except for OpenGL, which creates a private +# draw context for selection/feedback mode. +ifeq ($(MESA_LLVM),1) +GL_SYS += $(LLVM_LIBS) +GLESv1_CM_SYS += $(LLVM_LIBS) +GLESv2_SYS += $(LLVM_LIBS) +OpenVG_SYS += $(LLVM_LIBS) +LDFLAGS += $(LLVM_LDFLAGS) +endif + +# project libs +GL_LIBS := $(TOP)/src/mesa/libmesagallium.a +GLESv1_CM_LIBS := $(TOP)/src/mesa/libes1gallium.a +GLESv2_LIBS := $(TOP)/src/mesa/libes2gallium.a +OpenVG_LIBS := $(TOP)/src/gallium/state_trackers/vega/libvega.a + +# objects +GL_OBJECTS := api_GL.o +GLESv1_CM_OBJECTS := api_GLESv1_CM.o +GLESv2_OBJECTS := api_GLESv2.o +OpenVG_OBJECTS := api_OpenVG.o + +default: $(OUTPUTS) + +api_%.o: api_%.c + $(CC) -c -o $@ $< $($*_INCLUDES) $(DEFINES) $(CFLAGS) + +define mklib +$(MKLIB) -o $(notdir $@) -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + -install $(OUTPUT_PATH) $(MKLIB_OPTIONS) \ + $($(1)_OBJECTS) $($(1)_LIBS) $(GALLIUM_AUXILIARIES) $($(1)_SYS) +endef + +$(OUTPUT_PATH)/$(OUTPUT_PREFIX)$(GL_LIB).so: $(GL_OBJECTS) $(GL_LIBS) + $(call mklib,GL) + +$(OUTPUT_PATH)/$(OUTPUT_PREFIX)$(GLESv1_CM_LIB).so: $(GLESv1_CM_OBJECTS) $(GLESv1_CM_LIBS) + $(call mklib,GLESv1_CM) + +$(OUTPUT_PATH)/$(OUTPUT_PREFIX)$(GLESv2_LIB).so: $(GLESv2_OBJECTS) $(GLESv2_LIBS) + $(call mklib,GLESv2) + +$(OUTPUT_PATH)/$(OUTPUT_PREFIX)$(VG_LIB).so: $(OpenVG_OBJECTS) $(OpenVG_LIBS) + $(call mklib,OpenVG) + +install: $(OUTPUTS) + $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR) + for out in $(OUTPUTS); do \ + $(MINSTALL) -m 755 "$$out" $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR); \ + done + +clean: + -rm -f $(OUTPUTS) + -rm -f *.o diff --git a/src/gallium/targets/egl-apis/api_GL.c b/src/gallium/targets/egl-apis/api_GL.c new file mode 100644 index 00000000000..6d172745c01 --- /dev/null +++ b/src/gallium/targets/egl-apis/api_GL.c @@ -0,0 +1,7 @@ +#include "state_tracker/st_gl_api.h" + +PUBLIC struct st_api * +st_api_create_OpenGL() +{ + return st_gl_api_create(); +} diff --git a/src/gallium/state_trackers/es/st_es1.c b/src/gallium/targets/egl-apis/api_GLESv1_CM.c index 825fdac2150..825fdac2150 100644 --- a/src/gallium/state_trackers/es/st_es1.c +++ b/src/gallium/targets/egl-apis/api_GLESv1_CM.c diff --git a/src/gallium/state_trackers/es/st_es2.c b/src/gallium/targets/egl-apis/api_GLESv2.c index 5c773aaf93b..5c773aaf93b 100644 --- a/src/gallium/state_trackers/es/st_es2.c +++ b/src/gallium/targets/egl-apis/api_GLESv2.c diff --git a/src/gallium/targets/egl-apis/api_OpenVG.c b/src/gallium/targets/egl-apis/api_OpenVG.c new file mode 100644 index 00000000000..f85ebea8a1c --- /dev/null +++ b/src/gallium/targets/egl-apis/api_OpenVG.c @@ -0,0 +1,8 @@ +#include "state_tracker/st_api.h" +#include "vg_api.h" + +PUBLIC struct st_api * +st_api_create_OpenVG() +{ + return (struct st_api *) vg_api_get(); +} diff --git a/src/gallium/targets/egl-i915/Makefile b/src/gallium/targets/egl-i915/Makefile index 02258fb69a4..a4b41842ff7 100644 --- a/src/gallium/targets/egl-i915/Makefile +++ b/src/gallium/targets/egl-i915/Makefile @@ -8,6 +8,7 @@ EGL_DRIVER_LIBS = -ldrm_intel EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a \ $(TOP)/src/gallium/drivers/i915/libi915.a include ../Makefile.egl diff --git a/src/gallium/targets/egl-i965/Makefile b/src/gallium/targets/egl-i965/Makefile index fad56ef5554..d4730824a5b 100644 --- a/src/gallium/targets/egl-i965/Makefile +++ b/src/gallium/targets/egl-i965/Makefile @@ -8,6 +8,7 @@ EGL_DRIVER_LIBS = -ldrm_intel EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a \ $(TOP)/src/gallium/drivers/i965/libi965.a \ $(TOP)/src/gallium/winsys/sw/drm/libswdrm.a \ $(TOP)/src/gallium/winsys/sw/wrapper/libwsw.a \ diff --git a/src/gallium/targets/egl-radeon/Makefile b/src/gallium/targets/egl-radeon/Makefile index 8daadb59791..8fcca268265 100644 --- a/src/gallium/targets/egl-radeon/Makefile +++ b/src/gallium/targets/egl-radeon/Makefile @@ -8,6 +8,7 @@ EGL_DRIVER_LIBS = -ldrm_radeon EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a \ $(TOP)/src/gallium/drivers/r300/libr300.a include ../Makefile.egl diff --git a/src/gallium/targets/egl-vmwgfx/Makefile b/src/gallium/targets/egl-vmwgfx/Makefile index 5f9385f42b0..a9f6874b981 100644 --- a/src/gallium/targets/egl-vmwgfx/Makefile +++ b/src/gallium/targets/egl-vmwgfx/Makefile @@ -8,6 +8,7 @@ EGL_DRIVER_LIBS = EGL_DRIVER_PIPES = \ $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a \ $(TOP)/src/gallium/drivers/svga/libsvga.a include ../Makefile.egl diff --git a/src/gallium/targets/graw-null/SConscript b/src/gallium/targets/graw-null/SConscript new file mode 100644 index 00000000000..106dcd9a835 --- /dev/null +++ b/src/gallium/targets/graw-null/SConscript @@ -0,0 +1,57 @@ +####################################################################### +# SConscript for xlib winsys + +Import('*') + +env = env.Clone() + +env.Prepend(LIBS = [ + ws_null, + trace, + rbug, + identity, +# gallium, +]) + +env.Append(CPPPATH = [ + '#src/gallium/drivers', +]) + +if env['platform'] == 'windows': + # For trace + env.Append(LIBS = [ + 'ws2_32', + ]) + +sources = [ + 'graw_null.c', +] + +if True: + env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE') + env.Prepend(LIBS = [softpipe]) + +if env['llvm']: + env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') + env.Tool('udis86') + env.Prepend(LIBS = [llvmpipe]) + +# Need this for trace, identity drivers referenced by +# gallium_wrap_screen(). +# +env.Prepend(LIBS = [gallium]) + +# TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions +graw = env.SharedLibrary( + target ='graw', + source = sources, +) + +env.InstallSharedLibrary(graw, version=(1, 0)) + +if env['platform'] == 'windows': + graw = env.FindIxes(graw, 'LIBPREFIX', 'LIBSUFFIX') +else: + graw = env.FindIxes(graw, 'SHLIBPREFIX', 'SHLIBSUFFIX') + +Export('graw') diff --git a/src/gallium/targets/graw-null/graw_null.c b/src/gallium/targets/graw-null/graw_null.c new file mode 100644 index 00000000000..6965f5873e4 --- /dev/null +++ b/src/gallium/targets/graw-null/graw_null.c @@ -0,0 +1,81 @@ +#include "pipe/p_compiler.h" +#include "util/u_debug.h" +#include "util/u_memory.h" +#include "target-helpers/wrap_screen.h" +#include "sw/null/null_sw_winsys.h" + +#ifdef GALLIUM_SOFTPIPE +#include "softpipe/sp_public.h" +#endif + +#ifdef GALLIUM_LLVMPIPE +#include "llvmpipe/lp_public.h" +#endif + +/* Haven't figured out a decent way to build the helper code yet - + * #include it here temporarily. + */ +#include "sw/sw_public.h" +#include "sw/sw.c" + +#include <stdio.h> + + +struct pipe_screen * +graw_init( void ) +{ + const char *default_driver; + const char *driver; + struct pipe_screen *screen = NULL; + struct sw_winsys *winsys = NULL; + + /* Create the underlying winsys, which performs presents to Xlib + * drawables: + */ + winsys = null_sw_create(); + if (winsys == NULL) + return NULL; + +#if defined(GALLIUM_LLVMPIPE) + default_driver = "llvmpipe"; +#elif defined(GALLIUM_SOFTPIPE) + default_driver = "softpipe"; +#else + default_driver = ""; +#endif + + driver = debug_get_option("GALLIUM_DRIVER", default_driver); + +#if defined(GALLIUM_LLVMPIPE) + if (screen == NULL && strcmp(driver, "llvmpipe") == 0) + screen = llvmpipe_create_screen( winsys ); +#endif + +#if defined(GALLIUM_SOFTPIPE) + if (screen == NULL) + screen = softpipe_create_screen( winsys ); +#endif + + /* Inject any wrapping layers we want to here: + */ + return gallium_wrap_screen( screen ); +} + + +void * +graw_create_window( int x, + int y, + unsigned width, + unsigned height, + enum pipe_format format ) +{ + static int dummy; + return &dummy; +} + + +void +graw_destroy_window( void *window ) +{ +} + diff --git a/src/gallium/targets/graw-xlib/SConscript b/src/gallium/targets/graw-xlib/SConscript index 979252b22d7..40332fa4e14 100644 --- a/src/gallium/targets/graw-xlib/SConscript +++ b/src/gallium/targets/graw-xlib/SConscript @@ -8,9 +8,12 @@ if env['platform'] != 'linux': env = env.Clone() +env.Tool('x11') + env.Prepend(LIBS = [ ws_xlib, trace, + rbug, identity, # gallium, ]) @@ -22,6 +25,7 @@ env.Append(CPPPATH = [ sources = [ 'graw_xlib.c', + 'graw_util.c', ] if True: diff --git a/src/gallium/targets/graw-xlib/graw.h b/src/gallium/targets/graw-xlib/graw.h deleted file mode 100644 index a58e18e4739..00000000000 --- a/src/gallium/targets/graw-xlib/graw.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef GALLIUM_RAW_H -#define GALLIUM_RAW_H - -/* This is an API for exercising gallium functionality in a - * platform-neutral fashion. Whatever platform integration is - * necessary to implement this interface is orchestrated by the - * individual target building this entity. - * - * For instance, the graw-xlib target includes code to implent these - * interfaces on top of the X window system. - * - * Programs using this interface may additionally benefit from some of - * the utilities currently in the libgallium.a library, especially - * those for parsing text representations of TGSI shaders. - */ - -#include "pipe/p_format.h" - -struct pipe_screen; - -struct pipe_screen *graw_init( void ); - -/* Returns a handle to be used with flush_frontbuffer()/present(). - * - * Query format support with screen::is_format_supported and usage - * XXX. - */ -void *graw_create_window( int x, - int y, - unsigned width, - unsigned height, - enum pipe_format format ); - -void graw_destroy_window( void *handle ); - -#endif diff --git a/src/gallium/targets/graw-xlib/graw_util.c b/src/gallium/targets/graw-xlib/graw_util.c new file mode 100644 index 00000000000..147532cdee1 --- /dev/null +++ b/src/gallium/targets/graw-xlib/graw_util.c @@ -0,0 +1,36 @@ + +#include "pipe/p_compiler.h" +#include "pipe/p_context.h" +#include "tgsi/tgsi_text.h" +#include "util/u_memory.h" +#include "state_tracker/graw.h" + + +/* Helper functions. These are the same for all graw implementations. + */ +void *graw_parse_vertex_shader(struct pipe_context *pipe, + const char *text) +{ + struct tgsi_token tokens[1024]; + struct pipe_shader_state state; + + if (!tgsi_text_translate(text, tokens, Elements(tokens))) + return NULL; + + state.tokens = tokens; + return pipe->create_vs_state(pipe, &state); +} + +void *graw_parse_fragment_shader(struct pipe_context *pipe, + const char *text) +{ + struct tgsi_token tokens[1024]; + struct pipe_shader_state state; + + if (!tgsi_text_translate(text, tokens, Elements(tokens))) + return NULL; + + state.tokens = tokens; + return pipe->create_fs_state(pipe, &state); +} + diff --git a/src/gallium/targets/graw-xlib/graw_xlib.c b/src/gallium/targets/graw-xlib/graw_xlib.c index fb8ef9d78b6..41120ba3c70 100644 --- a/src/gallium/targets/graw-xlib/graw_xlib.c +++ b/src/gallium/targets/graw-xlib/graw_xlib.c @@ -1,4 +1,5 @@ #include "pipe/p_compiler.h" +#include "pipe/p_context.h" #include "util/u_debug.h" #include "util/u_memory.h" #include "target-helpers/wrap_screen.h" @@ -18,7 +19,7 @@ #include "sw/sw_public.h" #include "sw/sw.c" -#include "graw.h" +#include "state_tracker/graw.h" #include <X11/Xlib.h> #include <X11/Xlibint.h> @@ -27,21 +28,18 @@ static struct { Display *display; + void (*draw)(void); } graw; -struct pipe_screen * -graw_init( void ) +static struct pipe_screen * +graw_create_screen( void ) { const char *default_driver; const char *driver; struct pipe_screen *screen = NULL; struct sw_winsys *winsys = NULL; - graw.display = XOpenDisplay(NULL); - if (graw.display == NULL) - return NULL; - /* Create the underlying winsys, which performs presents to Xlib * drawables: */ @@ -78,14 +76,16 @@ graw_init( void ) -void * -graw_create_window( int x, - int y, - unsigned width, - unsigned height, - enum pipe_format format ) +struct pipe_screen * +graw_create_window_and_screen( int x, + int y, + unsigned width, + unsigned height, + enum pipe_format format, + void **handle) { - struct xlib_drawable *handle = NULL; + struct pipe_screen *screen = NULL; + struct xlib_drawable *xlib_handle = NULL; XSetWindowAttributes attr; Window root; Window win = 0; @@ -94,6 +94,9 @@ graw_create_window( int x, int n; int scrnum; + graw.display = XOpenDisplay(NULL); + if (graw.display == NULL) + return NULL; scrnum = DefaultScreen( graw.display ); root = RootWindow( graw.display, scrnum ); @@ -105,8 +108,8 @@ graw_create_window( int x, if (graw.display == NULL) goto fail; - handle = CALLOC_STRUCT(xlib_drawable); - if (handle == NULL) + xlib_handle = CALLOC_STRUCT(xlib_drawable); + if (xlib_handle == NULL) goto fail; @@ -148,7 +151,6 @@ graw_create_window( int x, None, (char **)NULL, 0, &sizehints); } - XFree(visinfo); XMapWindow(graw.display, win); while (1) { XEvent e; @@ -158,14 +160,27 @@ graw_create_window( int x, } } - handle->visual = visinfo->visual; - handle->drawable = (Drawable)win; - handle->depth = visinfo->depth; - return (void *)handle; + xlib_handle->visual = visinfo->visual; + xlib_handle->drawable = (Drawable)win; + xlib_handle->depth = visinfo->depth; + *handle = (void *)xlib_handle; + + screen = graw_create_screen(); + if (screen == NULL) + goto fail; -fail: - FREE(handle); XFree(visinfo); + return screen; + +fail: + if (screen) + screen->destroy(screen); + + if (xlib_handle) + FREE(xlib_handle); + + if (visinfo) + XFree(visinfo); if (win) XDestroyWindow(graw.display, win); @@ -174,8 +189,19 @@ fail: } +void +graw_set_display_func( void (*draw)( void ) ) +{ + graw.draw = draw; +} + void -graw_destroy_window( void *xlib_drawable ) +graw_main_loop( void ) { + int i; + for (i = 0; i < 10; i++) { + graw.draw(); + sleep(1); + } } diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript index 2a55c7a5776..144084f74f8 100644 --- a/src/gallium/targets/libgl-gdi/SConscript +++ b/src/gallium/targets/libgl-gdi/SConscript @@ -35,7 +35,7 @@ if env['platform'] == 'windows': else: sources += ['#src/gallium/state_trackers/wgl/opengl32.def'] - drivers += [trace] + drivers += [trace, rbug] env['no_import_lib'] = 1 diff --git a/src/gallium/targets/libgl-xlib/Makefile b/src/gallium/targets/libgl-xlib/Makefile index add3a273945..b173ceb994a 100644 --- a/src/gallium/targets/libgl-xlib/Makefile +++ b/src/gallium/targets/libgl-xlib/Makefile @@ -15,6 +15,7 @@ GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY) INCLUDE_DIRS = \ -I$(TOP)/include \ + -I$(TOP)/src/mapi \ -I$(TOP)/src/mesa \ -I$(TOP)/src/mesa/main \ -I$(TOP)/src/gallium/include \ @@ -41,8 +42,9 @@ LIBS = \ $(TOP)/src/gallium/state_trackers/glx/xlib/libxlib.a \ $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a \ $(TOP)/src/gallium/drivers/identity/libidentity.a \ - $(TOP)/src/mesa/libglapi.a \ + $(TOP)/src/mapi/glapi/libglapi.a \ $(TOP)/src/mesa/libmesagallium.a \ $(GALLIUM_AUXILIARIES) \ $(CELL_SPU_LIB) \ diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index 63e4531263a..78703fd096d 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -17,6 +17,7 @@ if env['dri']: env = env.Clone() env.Append(CPPPATH = [ + '#/src/mapi', '#/src/mesa', '#/src/mesa/main', '#src/gallium/state_trackers/glx/xlib', @@ -28,6 +29,7 @@ env.Prepend(LIBS = [ st_xlib, ws_xlib, trace, + rbug, identity, glapi, mesa, diff --git a/src/gallium/targets/xorg-i915/Makefile b/src/gallium/targets/xorg-i915/Makefile index 52a9e97b409..2f2439c6d42 100644 --- a/src/gallium/targets/xorg-i915/Makefile +++ b/src/gallium/targets/xorg-i915/Makefile @@ -20,6 +20,7 @@ LIBS = \ $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \ $(TOP)/src/gallium/drivers/i915/libi915.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(GALLIUM_AUXILIARIES) diff --git a/src/gallium/targets/xorg-i965/Makefile b/src/gallium/targets/xorg-i965/Makefile index 104a1434a84..0aab30ff3c6 100644 --- a/src/gallium/targets/xorg-i965/Makefile +++ b/src/gallium/targets/xorg-i965/Makefile @@ -20,6 +20,7 @@ LIBS = \ $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \ $(TOP)/src/gallium/drivers/i965/libi965.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(GALLIUM_AUXILIARIES) diff --git a/src/gallium/targets/xorg-radeon/Makefile b/src/gallium/targets/xorg-radeon/Makefile index cd32914c0d3..85aa711a4f3 100644 --- a/src/gallium/targets/xorg-radeon/Makefile +++ b/src/gallium/targets/xorg-radeon/Makefile @@ -20,6 +20,7 @@ LIBS = \ $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \ $(TOP)/src/gallium/drivers/r300/libr300.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a \ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ $(GALLIUM_AUXILIARIES) diff --git a/src/gallium/targets/xorg-vmwgfx/Makefile b/src/gallium/targets/xorg-vmwgfx/Makefile index 12bc307ef9b..e334d889957 100644 --- a/src/gallium/targets/xorg-vmwgfx/Makefile +++ b/src/gallium/targets/xorg-vmwgfx/Makefile @@ -22,6 +22,7 @@ LIBS = \ $(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \ $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/rbug/librbug.a \ $(TOP)/src/gallium/drivers/svga/libsvga.a \ $(GALLIUM_AUXILIARIES) diff --git a/src/gallium/targets/xorg-vmwgfx/SConscript b/src/gallium/targets/xorg-vmwgfx/SConscript index b63ab99e050..d5edbebae87 100644 --- a/src/gallium/targets/xorg-vmwgfx/SConscript +++ b/src/gallium/targets/xorg-vmwgfx/SConscript @@ -39,6 +39,7 @@ if env['platform'] == 'linux': env.Prepend(LIBS = [ trace, + rbug, st_xorg, svgadrm, svga, diff --git a/src/gallium/tests/graw/SConscript b/src/gallium/tests/graw/SConscript new file mode 100644 index 00000000000..7eab973db31 --- /dev/null +++ b/src/gallium/tests/graw/SConscript @@ -0,0 +1,25 @@ +Import('*') + +try: + graw +except NameError: + print 'warning: graw library not avaiable: skipping build of graw test' + Return() + +env = env.Clone() + +env.Prepend(LIBPATH = [graw.dir]) +env.Prepend(LIBS = ['graw']) + +progs = [ + 'clear', + 'tri', + 'quad-tex', +] + +for prog in progs: + env.Program( + target = prog, + source = prog + '.c', + ) + diff --git a/src/gallium/tests/raw/clear.c b/src/gallium/tests/graw/clear.c index 706e3be3728..28c986eee64 100644 --- a/src/gallium/tests/raw/clear.c +++ b/src/gallium/tests/graw/clear.c @@ -7,9 +7,9 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" #include "pipe/p_defines.h" -#include <unistd.h> /* for sleep() */ #include "util/u_debug.h" /* debug_dump_surface_bmp() */ +#include "os/os_time.h" /* os_time_sleep() */ enum pipe_format formats[] = { PIPE_FORMAT_R8G8B8A8_UNORM, @@ -20,33 +20,58 @@ enum pipe_format formats[] = { static const int WIDTH = 300; static const int HEIGHT = 300; -int main( int argc, char *argv[] ) +struct pipe_screen *screen; +struct pipe_context *ctx; +struct pipe_surface *surf; +static void *window = NULL; + +static void draw( void ) { - struct pipe_screen *screen; - struct pipe_context *pipe; - struct pipe_surface *surf; - struct pipe_framebuffer_state fb; - struct pipe_texture *tex, templat; - void *window = NULL; float clear_color[4] = {1,0,1,1}; - int i; - screen = graw_init(); - if (screen == NULL) - exit(1); + ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0); + ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL); + +#if 0 + /* At the moment, libgraw leaks out/makes available some of the + * symbols from gallium/auxiliary, including these debug helpers. + * Will eventually want to bless some of these paths, and lock the + * others down so they aren't accessible from test programs. + * + * This currently just happens to work on debug builds - a release + * build will probably fail to link here: + */ + debug_dump_surface_bmp(ctx, "result.bmp", surf); +#endif + + screen->flush_frontbuffer(screen, surf, window); +} +static void init( void ) +{ + struct pipe_framebuffer_state fb; + struct pipe_resource *tex, templat; + int i; + + /* It's hard to say whether window or screen should be created + * first. Different environments would prefer one or the other. + * + * Also, no easy way of querying supported formats if the screen + * cannot be created first. + */ for (i = 0; window == NULL && formats[i] != PIPE_FORMAT_NONE; i++) { - window = graw_create_window(0,0,300,300, formats[i]); + screen = graw_create_window_and_screen(0,0,300,300, + formats[i], + &window); } - if (window == NULL) exit(2); - pipe = screen->context_create(screen, NULL); - if (pipe == NULL) + ctx = screen->context_create(screen, NULL); + if (ctx == NULL) exit(3); templat.target = PIPE_TEXTURE_2D; @@ -57,10 +82,10 @@ int main( int argc, char *argv[] ) templat.last_level = 0; templat.nr_samples = 1; templat.bind = (PIPE_BIND_RENDER_TARGET | - PIPE_BIND_DISPLAY_TARGET); + PIPE_BIND_DISPLAY_TARGET); tex = screen->resource_create(screen, - &templat); + &templat); if (tex == NULL) exit(4); @@ -76,20 +101,16 @@ int main( int argc, char *argv[] ) fb.height = HEIGHT; fb.cbufs[0] = surf; - pipe->set_framebuffer_state(pipe, &fb); - pipe->clear(pipe, PIPE_CLEAR_COLOR, clear_color, 0, 0); - pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); + ctx->set_framebuffer_state(ctx, &fb); +} - /* At the moment, libgraw includes/makes available all the symbols - * from gallium/auxiliary, including these debug helpers. Will - * eventually want to bless some of these paths, and lock the - * others down so they aren't accessible from test programs. - */ - if (0) - debug_dump_surface_bmp(pipe, "result.bmp", surf); - screen->flush_frontbuffer(screen, surf, window); - sleep(100); +int main( int argc, char *argv[] ) +{ + init(); + + graw_set_display_func( draw ); + graw_main_loop(); return 0; } diff --git a/src/gallium/tests/graw/quad-tex.c b/src/gallium/tests/graw/quad-tex.c new file mode 100644 index 00000000000..225cbfc8e88 --- /dev/null +++ b/src/gallium/tests/graw/quad-tex.c @@ -0,0 +1,403 @@ +/* Display a cleared blue window. This demo has no dependencies on + * any utility code, just the graw interface and gallium. + */ + +#include "state_tracker/graw.h" +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "pipe/p_shader_tokens.h" +#include "pipe/p_state.h" +#include "pipe/p_defines.h" +#include <unistd.h> /* for sleep() */ + +#include "util/u_debug.h" /* debug_dump_surface_bmp() */ +#include "util/u_inlines.h" +#include "util/u_memory.h" /* Offset() */ +#include "util/u_box.h" + +enum pipe_format formats[] = { + PIPE_FORMAT_R8G8B8A8_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_NONE +}; + +static const int WIDTH = 300; +static const int HEIGHT = 300; + +static struct pipe_screen *screen = NULL; +static struct pipe_context *ctx = NULL; +static struct pipe_resource *rttex = NULL; +static struct pipe_resource *samptex = NULL; +static struct pipe_surface *surf = NULL; +static struct pipe_sampler_view *sv = NULL; +static void *sampler = NULL; +static void *window = NULL; + +struct vertex { + float position[4]; + float color[4]; +}; + +static struct vertex vertices[] = +{ + { { 0.9, -0.9, 0.0, 1.0 }, + { 1, 0, 0, 1 } }, + + { { 0.9, 0.9, 0.0, 1.0 }, + { 1, 1, 0, 1 } }, + + { {-0.9, 0.9, 0.0, 1.0 }, + { 0, 1, 0, 1 } }, + + { {-0.9, -0.9, 0.0, 1.0 }, + { 0, 0, 0, 1 } }, +}; + + + + +static void set_viewport( float x, float y, + float width, float height, + float near, float far) +{ + float z = far; + float half_width = (float)width / 2.0f; + float half_height = (float)height / 2.0f; + float half_depth = ((float)far - (float)near) / 2.0f; + struct pipe_viewport_state vp; + + vp.scale[0] = half_width; + vp.scale[1] = half_height; + vp.scale[2] = half_depth; + vp.scale[3] = 1.0f; + + vp.translate[0] = half_width + x; + vp.translate[1] = half_height + y; + vp.translate[2] = half_depth + z; + vp.translate[3] = 0.0f; + + ctx->set_viewport_state( ctx, &vp ); +} + +static void set_vertices( void ) +{ + struct pipe_vertex_element ve[2]; + struct pipe_vertex_buffer vbuf; + void *handle; + + memset(ve, 0, sizeof ve); + + ve[0].src_offset = Offset(struct vertex, position); + ve[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + ve[1].src_offset = Offset(struct vertex, color); + ve[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + + handle = ctx->create_vertex_elements_state(ctx, 2, ve); + ctx->bind_vertex_elements_state(ctx, handle); + + + vbuf.stride = sizeof( struct vertex ); + vbuf.max_index = sizeof(vertices) / vbuf.stride; + vbuf.buffer_offset = 0; + vbuf.buffer = screen->user_buffer_create(screen, + vertices, + sizeof(vertices), + PIPE_BIND_VERTEX_BUFFER); + + ctx->set_vertex_buffers(ctx, 1, &vbuf); +} + +static void set_vertex_shader( void ) +{ + void *handle; + const char *text = + "VERT\n" + "DCL IN[0]\n" + "DCL IN[1]\n" + "DCL OUT[0], POSITION\n" + "DCL OUT[1], GENERIC[0]\n" + " 0: MOV OUT[1], IN[1]\n" + " 1: MOV OUT[0], IN[0]\n" + " 2: END\n"; + + handle = graw_parse_vertex_shader(ctx, text); + ctx->bind_vs_state(ctx, handle); +} + +static void set_fragment_shader( void ) +{ + void *handle; + const char *text = + "FRAG\n" + "DCL IN[0], GENERIC[0], PERSPECTIVE\n" + "DCL OUT[0], COLOR\n" + "DCL TEMP[0]\n" + "DCL SAMP[0]\n" + " 0: TXP TEMP[0], IN[0], SAMP[0], 2D\n" + " 1: MOV OUT[0], TEMP[0]\n" + " 2: END\n"; + + handle = graw_parse_fragment_shader(ctx, text); + ctx->bind_fs_state(ctx, handle); +} + + +static void draw( void ) +{ + float clear_color[4] = {.5,.5,.5,1}; + + ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0); + ctx->draw_arrays(ctx, PIPE_PRIM_QUADS, 0, 4); + ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL); + +#if 0 + /* At the moment, libgraw leaks out/makes available some of the + * symbols from gallium/auxiliary, including these debug helpers. + * Will eventually want to bless some of these paths, and lock the + * others down so they aren't accessible from test programs. + * + * This currently just happens to work on debug builds - a release + * build will probably fail to link here: + */ + debug_dump_surface_bmp(ctx, "result.bmp", surf); +#endif + + screen->flush_frontbuffer(screen, surf, window); +} + +#define SIZE 16 + +static void init_tex( void ) +{ + struct pipe_sampler_view sv_template; + struct pipe_sampler_state sampler_desc; + struct pipe_resource templat; + struct pipe_box box; + ubyte tex2d[SIZE][SIZE][4]; + int s, t; + +#if (SIZE != 2) + for (s = 0; s < SIZE; s++) { + for (t = 0; t < SIZE; t++) { + if (0) { + int x = (s ^ t) & 1; + tex2d[t][s][0] = (x) ? 0 : 63; + tex2d[t][s][1] = (x) ? 0 : 128; + tex2d[t][s][2] = 0; + tex2d[t][s][3] = 0xff; + } + else { + int x = ((s ^ t) >> 2) & 1; + tex2d[t][s][0] = s*255/(SIZE-1); + tex2d[t][s][1] = t*255/(SIZE-1); + tex2d[t][s][2] = (x) ? 0 : 128; + tex2d[t][s][3] = 0xff; + } + } + } +#else + tex2d[0][0][0] = 0; + tex2d[0][0][1] = 255; + tex2d[0][0][2] = 255; + tex2d[0][0][3] = 0; + + tex2d[0][1][0] = 0; + tex2d[0][1][1] = 0; + tex2d[0][1][2] = 255; + tex2d[0][1][3] = 255; + + tex2d[1][0][0] = 255; + tex2d[1][0][1] = 255; + tex2d[1][0][2] = 0; + tex2d[1][0][3] = 255; + + tex2d[1][1][0] = 255; + tex2d[1][1][1] = 0; + tex2d[1][1][2] = 0; + tex2d[1][1][3] = 255; +#endif + + templat.target = PIPE_TEXTURE_2D; + templat.format = PIPE_FORMAT_B8G8R8A8_UNORM; + templat.width0 = SIZE; + templat.height0 = SIZE; + templat.depth0 = 1; + templat.last_level = 0; + templat.nr_samples = 1; + templat.bind = PIPE_BIND_SAMPLER_VIEW; + + + samptex = screen->resource_create(screen, + &templat); + if (samptex == NULL) + exit(4); + + u_box_2d(0,0,SIZE,SIZE, &box); + + ctx->transfer_inline_write(ctx, + samptex, + u_subresource(0,0), + PIPE_TRANSFER_WRITE, + &box, + tex2d, + sizeof tex2d[0], + sizeof tex2d); + + /* Possibly read back & compare against original data: + */ + if (0) + { + struct pipe_transfer *t; + uint32_t *ptr; + t = pipe_get_transfer(ctx, samptex, + 0, 0, 0, /* face, level, zslice */ + PIPE_TRANSFER_READ, + 0, 0, SIZE, SIZE); /* x, y, width, height */ + + ptr = ctx->transfer_map(ctx, t); + + if (memcmp(ptr, tex2d, sizeof tex2d) != 0) { + assert(0); + exit(9); + } + + ctx->transfer_unmap(ctx, t); + + ctx->transfer_destroy(ctx, t); + } + + memset(&sv_template, 0, sizeof sv_template); + sv_template.format = samptex->format; + sv_template.texture = samptex; + sv_template.first_level = 0; + sv_template.last_level = 0; + sv_template.swizzle_r = 0; + sv_template.swizzle_g = 1; + sv_template.swizzle_b = 2; + sv_template.swizzle_a = 3; + sv = ctx->create_sampler_view(ctx, samptex, &sv_template); + if (sv == NULL) + exit(5); + + ctx->set_fragment_sampler_views(ctx, 1, &sv); + + + memset(&sampler_desc, 0, sizeof sampler_desc); + sampler_desc.wrap_s = PIPE_TEX_WRAP_REPEAT; + sampler_desc.wrap_t = PIPE_TEX_WRAP_REPEAT; + sampler_desc.wrap_r = PIPE_TEX_WRAP_REPEAT; + sampler_desc.min_img_filter = PIPE_TEX_FILTER_NEAREST; + sampler_desc.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; + sampler_desc.mag_img_filter = PIPE_TEX_FILTER_NEAREST; + sampler_desc.compare_mode = PIPE_TEX_COMPARE_NONE; + sampler_desc.compare_func = 0; + sampler_desc.normalized_coords = 1; + sampler_desc.max_anisotropy = 0; + + sampler = ctx->create_sampler_state(ctx, &sampler_desc); + if (sampler == NULL) + exit(6); + + ctx->bind_fragment_sampler_states(ctx, 1, &sampler); + +} + +static void init( void ) +{ + struct pipe_framebuffer_state fb; + struct pipe_resource templat; + int i; + + /* It's hard to say whether window or screen should be created + * first. Different environments would prefer one or the other. + * + * Also, no easy way of querying supported formats if the screen + * cannot be created first. + */ + for (i = 0; + window == NULL && formats[i] != PIPE_FORMAT_NONE; + i++) { + + screen = graw_create_window_and_screen(0,0,300,300, + formats[i], + &window); + } + + ctx = screen->context_create(screen, NULL); + if (ctx == NULL) + exit(3); + + templat.target = PIPE_TEXTURE_2D; + templat.format = formats[i]; + templat.width0 = WIDTH; + templat.height0 = HEIGHT; + templat.depth0 = 1; + templat.last_level = 0; + templat.nr_samples = 1; + templat.bind = (PIPE_BIND_RENDER_TARGET | + PIPE_BIND_DISPLAY_TARGET); + + rttex = screen->resource_create(screen, + &templat); + if (rttex == NULL) + exit(4); + + surf = screen->get_tex_surface(screen, rttex, 0, 0, 0, + PIPE_BIND_RENDER_TARGET | + PIPE_BIND_DISPLAY_TARGET); + if (surf == NULL) + exit(5); + + memset(&fb, 0, sizeof fb); + fb.nr_cbufs = 1; + fb.width = WIDTH; + fb.height = HEIGHT; + fb.cbufs[0] = surf; + + ctx->set_framebuffer_state(ctx, &fb); + + { + struct pipe_blend_state blend; + void *handle; + memset(&blend, 0, sizeof blend); + blend.rt[0].colormask = PIPE_MASK_RGBA; + handle = ctx->create_blend_state(ctx, &blend); + ctx->bind_blend_state(ctx, handle); + } + + { + struct pipe_depth_stencil_alpha_state depthstencil; + void *handle; + memset(&depthstencil, 0, sizeof depthstencil); + handle = ctx->create_depth_stencil_alpha_state(ctx, &depthstencil); + ctx->bind_depth_stencil_alpha_state(ctx, handle); + } + + { + struct pipe_rasterizer_state rasterizer; + void *handle; + memset(&rasterizer, 0, sizeof rasterizer); + rasterizer.cull_face = PIPE_FACE_NONE; + rasterizer.gl_rasterization_rules = 1; + handle = ctx->create_rasterizer_state(ctx, &rasterizer); + ctx->bind_rasterizer_state(ctx, handle); + } + + set_viewport(0, 0, WIDTH, HEIGHT, 30, 1000); + + init_tex(); + + set_vertices(); + set_vertex_shader(); + set_fragment_shader(); +} + + +int main( int argc, char *argv[] ) +{ + init(); + + graw_set_display_func( draw ); + graw_main_loop(); + return 0; +} diff --git a/src/gallium/tests/raw/SConscript b/src/gallium/tests/raw/SConscript deleted file mode 100644 index 073b97951e7..00000000000 --- a/src/gallium/tests/raw/SConscript +++ /dev/null @@ -1,17 +0,0 @@ -Import('*') - -env = env.Clone() - -env.Prepend(LIBPATH = [graw.dir]) -env.Prepend(LIBS = [graw.name]) - -progs = [ - 'clear' -] - -for prog in progs: - env.Program( - target = prog, - source = prog + '.c', - ) - diff --git a/src/gallium/tests/trivial/quad-tex.c b/src/gallium/tests/trivial/quad-tex.c index 522ff3cb42d..93f24876cbb 100644 --- a/src/gallium/tests/trivial/quad-tex.c +++ b/src/gallium/tests/trivial/quad-tex.c @@ -201,8 +201,7 @@ static void init_prog(struct program *p) /* rasterizer */ memset(&p->rasterizer, 0, sizeof(p->rasterizer)); - p->rasterizer.front_winding = PIPE_WINDING_CW; - p->rasterizer.cull_mode = PIPE_WINDING_NONE; + p->rasterizer.cull_face = PIPE_FACE_NONE; p->rasterizer.gl_rasterization_rules = 1; /* sampler */ diff --git a/src/gallium/tests/trivial/tri.c b/src/gallium/tests/trivial/tri.c index 48305240a4b..7823c27727d 100644 --- a/src/gallium/tests/trivial/tri.c +++ b/src/gallium/tests/trivial/tri.c @@ -151,8 +151,7 @@ static void init_prog(struct program *p) /* rasterizer */ memset(&p->rasterizer, 0, sizeof(p->rasterizer)); - p->rasterizer.front_winding = PIPE_WINDING_CW; - p->rasterizer.cull_mode = PIPE_WINDING_NONE; + p->rasterizer.cull_face = PIPE_FACE_NONE; p->rasterizer.gl_rasterization_rules = 1; /* drawing destination */ diff --git a/src/gallium/winsys/SConscript b/src/gallium/winsys/SConscript index 2013ee97c1c..330b1ab834c 100644 --- a/src/gallium/winsys/SConscript +++ b/src/gallium/winsys/SConscript @@ -1,5 +1,10 @@ Import('*') + +SConscript([ + 'sw/wrapper/SConscript', +]) + if 'xlib' in env['winsys']: SConscript([ 'sw/xlib/SConscript', @@ -12,6 +17,7 @@ if 'gdi' in env['winsys']: if env['dri']: SConscript([ + 'sw/drm/SConscript', 'sw/dri/SConscript', ]) diff --git a/src/gallium/winsys/i965/drm/i965_drm_buffer.c b/src/gallium/winsys/i965/drm/i965_drm_buffer.c index 33a17496b2b..fb5e50ce810 100644 --- a/src/gallium/winsys/i965/drm/i965_drm_buffer.c +++ b/src/gallium/winsys/i965/drm/i965_drm_buffer.c @@ -463,7 +463,7 @@ i965_libdrm_bo_flush_range(struct brw_winsys_buffer *buffer, brw_dump_data( idws->id, buf->data_type, buf->bo->offset + offset, - buf->bo->virtual + offset, + (char*)buf->bo->virtual + offset, length ); } diff --git a/src/gallium/winsys/i965/xlib/Makefile b/src/gallium/winsys/i965/xlib/Makefile index 3730db6997e..cc8249395c5 100644 --- a/src/gallium/winsys/i965/xlib/Makefile +++ b/src/gallium/winsys/i965/xlib/Makefile @@ -38,7 +38,7 @@ LIBS = \ $(TOP)/src/gallium/drivers/i965/libi965.a \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/state_trackers/glx/xlib/libxlib.a \ - $(TOP)/src/mesa/libglapi.a \ + $(TOP)/src/mapi/glapi/libglapi.a \ $(TOP)/src/mesa/libmesagallium.a \ $(GALLIUM_AUXILIARIES) diff --git a/src/gallium/winsys/radeon/drm/radeon_buffer.h b/src/gallium/winsys/radeon/drm/radeon_buffer.h index b48b6358e01..b9ecf9ded07 100644 --- a/src/gallium/winsys/radeon/drm/radeon_buffer.h +++ b/src/gallium/winsys/radeon/drm/radeon_buffer.h @@ -88,4 +88,7 @@ boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf, boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf, enum r300_reference_domain domain); + +void radeon_drm_bufmgr_wait(struct pb_buffer *_buf); + #endif diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c b/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c index b8366498922..a05205da886 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c @@ -419,3 +419,10 @@ void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr) make_empty_list(&mgr->buffer_map_list); } + +void radeon_drm_bufmgr_wait(struct pb_buffer *_buf) +{ + struct radeon_drm_buffer *buf = get_drm_buffer(_buf); + + radeon_bo_wait(buf->bo); +} diff --git a/src/gallium/winsys/radeon/drm/radeon_r300.c b/src/gallium/winsys/radeon/drm/radeon_r300.c index fb779e4033b..e188f7e7ccd 100644 --- a/src/gallium/winsys/radeon/drm/radeon_r300.c +++ b/src/gallium/winsys/radeon/drm/radeon_r300.c @@ -86,7 +86,7 @@ static void *radeon_r300_winsys_buffer_map(struct r300_winsys_screen *ws, unsigned usage) { struct pb_buffer *_buf = radeon_pb_buffer(buf); - + return pb_map(_buf, usage); } @@ -98,6 +98,13 @@ static void radeon_r300_winsys_buffer_unmap(struct r300_winsys_screen *ws, pb_unmap(_buf); } +static void radeon_r300_winsys_buffer_wait(struct r300_winsys_screen *ws, + struct r300_winsys_buffer *buf) +{ + struct pb_buffer *_buf = radeon_pb_buffer(buf); + radeon_drm_bufmgr_wait(_buf); +} + static void radeon_r300_winsys_buffer_reference(struct r300_winsys_screen *rws, struct r300_winsys_buffer **pdst, struct r300_winsys_buffer *src) @@ -343,6 +350,7 @@ radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* ws) ws->base.buffer_get_tiling = radeon_r300_winsys_buffer_get_tiling; ws->base.buffer_map = radeon_r300_winsys_buffer_map; ws->base.buffer_unmap = radeon_r300_winsys_buffer_unmap; + ws->base.buffer_wait = radeon_r300_winsys_buffer_wait; ws->base.buffer_reference = radeon_r300_winsys_buffer_reference; ws->base.buffer_from_handle = radeon_r300_winsys_buffer_from_handle; ws->base.buffer_get_handle = radeon_r300_winsys_buffer_get_handle; diff --git a/src/gallium/winsys/svga/drm/SConscript b/src/gallium/winsys/svga/drm/SConscript index edaf9458bee..3ad4c725727 100644 --- a/src/gallium/winsys/svga/drm/SConscript +++ b/src/gallium/winsys/svga/drm/SConscript @@ -2,6 +2,8 @@ Import('*') env = env.Clone() +env.ParseConfig('pkg-config --cflags libdrm') + if env['gcc']: env.Append(CCFLAGS = ['-fvisibility=hidden']) env.Append(CPPDEFINES = [ diff --git a/src/gallium/winsys/sw/drm/SConscript b/src/gallium/winsys/sw/drm/SConscript new file mode 100644 index 00000000000..15a2e05d5af --- /dev/null +++ b/src/gallium/winsys/sw/drm/SConscript @@ -0,0 +1,21 @@ +####################################################################### +# SConscript for xlib winsys + + +Import('*') + +env = env.Clone() + +env.Append(CPPPATH = [ + '#/src/gallium/include', + '#/src/gallium/auxiliary', + '#/src/gallium/drivers', +]) + +ws_drm = env.ConvenienceLibrary( + target = 'ws_drm', + source = [ + 'sw_drm_api.c', + ] +) +Export('ws_drm') diff --git a/src/gallium/winsys/sw/wrapper/SConscript b/src/gallium/winsys/sw/wrapper/SConscript new file mode 100644 index 00000000000..4c60488df0b --- /dev/null +++ b/src/gallium/winsys/sw/wrapper/SConscript @@ -0,0 +1,21 @@ +####################################################################### +# SConscript for xlib winsys + + +Import('*') + +env = env.Clone() + +env.Append(CPPPATH = [ + '#/src/gallium/include', + '#/src/gallium/auxiliary', + '#/src/gallium/drivers', +]) + +ws_wrapper = env.ConvenienceLibrary( + target = 'ws_wrapper', + source = [ + 'wrapper_sw_winsys.c', + ] +) +Export('ws_wrapper') diff --git a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c index d4d4270eb86..b997abda9b0 100644 --- a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c +++ b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c @@ -145,6 +145,7 @@ wsw_dt_create(struct sw_winsys *ws, * XXX Why don't we just get the template. */ memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; templ.width0 = width; templ.height0 = height; templ.format = format; @@ -175,6 +176,18 @@ wsw_dt_from_handle(struct sw_winsys *ws, return wsw_dt_wrap_texture(wsw, tex, stride); } +static boolean +wsw_dt_get_handle(struct sw_winsys *ws, + struct sw_displaytarget *dt, + struct winsys_handle *whandle) +{ + struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws); + struct wrapper_sw_displaytarget *wdt = wrapper_sw_displaytarget(dt); + struct pipe_resource *tex = wdt->tex; + + return wsw->screen->resource_get_handle(wsw->screen, tex, whandle); +} + static void * wsw_dt_map(struct sw_winsys *ws, struct sw_displaytarget *dt, @@ -267,6 +280,7 @@ wrapper_sw_winsys_warp_pipe_screen(struct pipe_screen *screen) wsw->base.displaytarget_create = wsw_dt_create; wsw->base.displaytarget_from_handle = wsw_dt_from_handle; + wsw->base.displaytarget_get_handle = wsw_dt_get_handle; wsw->base.displaytarget_map = wsw_dt_map; wsw->base.displaytarget_unmap = wsw_dt_unmap; wsw->base.displaytarget_destroy = wsw_dt_destroy; diff --git a/src/gles/Makefile b/src/gles/Makefile deleted file mode 100644 index d023c14049f..00000000000 --- a/src/gles/Makefile +++ /dev/null @@ -1,70 +0,0 @@ -TOP = ../.. -MESA = $(TOP)/src/mesa -include $(TOP)/configs/current -include $(MESA)/sources.mak - -GLESv1_CM_ASM := $(addprefix $(MESA)/es/glapi/glapi-es1/,$(GLAPI_ASM_SOURCES)) -GLESv2_ASM := $(addprefix $(MESA)/es/glapi/glapi-es2/,$(GLAPI_ASM_SOURCES)) -API_SOURCES := $(addprefix $(MESA)/,$(GLAPI_SOURCES)) - -$(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_NAME) : PREFIX = es1 -$(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_NAME) : NAME = GLESv1_CM - -$(TOP)/$(LIB_DIR)/$(GLESv2_LIB_NAME) : PREFIX = es2 -$(TOP)/$(LIB_DIR)/$(GLESv2_LIB_NAME) : NAME = GLESv2 - -INCLUDES = -I$(TOP)/include -I$(MESA)/es/glapi/glapi-$(PREFIX) -I$(MESA) - -OBJECTS = \ - $(notdir $(GLAPI_ASM_SOURCES:%.S=%.o)) \ - $(notdir $(GLAPI_SOURCES:%.c=%.o)) - -GLESv1_CM_OBJECTS = $(addprefix es1-,$(OBJECTS)) -GLESv2_OBJECTS = $(addprefix es2-,$(OBJECTS)) - -es1-%.o: $(dir $(GLESv1_CM_ASM))%.S - $(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $< -es1-%.o: $(MESA)/glapi/%.c - $(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $< - -es2-%.o: $(dir $(GLESv2_ASM))%.S - $(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $< -es2-%.o: $(MESA)/glapi/%.c - $(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $< - -default: depend \ - $(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_NAME) \ - $(TOP)/$(LIB_DIR)/$(GLESv2_LIB_NAME) - -$(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_NAME) : $(GLESv1_CM_OBJECTS) -$(TOP)/$(LIB_DIR)/$(GLESv2_LIB_NAME) : $(GLESv2_OBJECTS) - -$(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_NAME) \ -$(TOP)/$(LIB_DIR)/$(GLESv2_LIB_NAME) : Makefile - $(MKLIB) -o $($(NAME)_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - -major 1 -minor 2 $(MKLIB_OPTIONS) \ - -install $(TOP)/$(LIB_DIR) -id \ - $(INSTALL_LIB_DIR)/lib$($(NAME)_LIB).1.dylib \ - $($(NAME)_LIB_DEPS) $($(NAME)_OBJECTS) - -depend: Makefile - rm -f depend - touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(API_SOURCES) \ - $(ES1_API_ASM) $(ES2_API_ASM) - -# Emacs tags -tags: - etags `find . -name \*.[ch]` `find $(TOP)/include` - -install: $(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLESv2_LIB_NAME) - $(MAKE) -C $(TOP)/src/mesa install-es2 install-es1 - -# Remove .o and backup files -clean: - -rm -f $(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_GLOB) - -rm -f $(TOP)/$(LIB_DIR)/$(GLESv2_LIB_GLOB) - -rm -f *.o *~ - -rm -f depend depend.bak - --include depend diff --git a/src/glew/glew.c b/src/glew/glew.c index 624222f9fb1..987236b7d30 100644 --- a/src/glew/glew.c +++ b/src/glew/glew.c @@ -525,6 +525,12 @@ PFNGLFRAMEBUFFERTEXTUREPROC __glewFramebufferTexture = NULL; PFNGLGETBUFFERPARAMETERI64VPROC __glewGetBufferParameteri64v = NULL; PFNGLGETINTEGER64I_VPROC __glewGetInteger64i_v = NULL; +PFNGLBLENDEQUATIONSEPARATEIPROC __glewBlendEquationSeparatei = NULL; +PFNGLBLENDEQUATIONIPROC __glewBlendEquationi = NULL; +PFNGLBLENDFUNCSEPARATEIPROC __glewBlendFuncSeparatei = NULL; +PFNGLBLENDFUNCIPROC __glewBlendFunci = NULL; +PFNGLMINSAMPLESHADINGPROC __glewMinSampleShading = NULL; + PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX = NULL; PFNGLBLENDEQUATIONINDEXEDAMDPROC __glewBlendEquationIndexedAMD = NULL; @@ -589,6 +595,9 @@ PFNGLMAPVERTEXATTRIB1FAPPLEPROC __glewMapVertexAttrib1fAPPLE = NULL; PFNGLMAPVERTEXATTRIB2DAPPLEPROC __glewMapVertexAttrib2dAPPLE = NULL; PFNGLMAPVERTEXATTRIB2FAPPLEPROC __glewMapVertexAttrib2fAPPLE = NULL; +PFNGLBINDFRAGDATALOCATIONINDEXEDPROC __glewBindFragDataLocationIndexed = NULL; +PFNGLGETFRAGDATAINDEXPROC __glewGetFragDataIndex = NULL; + PFNGLCLAMPCOLORARBPROC __glewClampColorARB = NULL; PFNGLCOPYBUFFERSUBDATAPROC __glewCopyBufferSubData = NULL; @@ -605,6 +614,9 @@ PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC __glewDrawElementsInstancedBaseVertex = PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC __glewDrawRangeElementsBaseVertex = NULL; PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC __glewMultiDrawElementsBaseVertex = NULL; +PFNGLDRAWARRAYSINDIRECTPROC __glewDrawArraysIndirect = NULL; +PFNGLDRAWELEMENTSINDIRECTPROC __glewDrawElementsIndirect = NULL; + PFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB = NULL; PFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB = NULL; @@ -731,6 +743,21 @@ PFNGLPROVOKINGVERTEXPROC __glewProvokingVertex = NULL; PFNGLMINSAMPLESHADINGARBPROC __glewMinSampleShadingARB = NULL; +PFNGLBINDSAMPLERPROC __glewBindSampler = NULL; +PFNGLDELETESAMPLERSPROC __glewDeleteSamplers = NULL; +PFNGLGENSAMPLERSPROC __glewGenSamplers = NULL; +PFNGLGETSAMPLERPARAMETERIIVPROC __glewGetSamplerParameterIiv = NULL; +PFNGLGETSAMPLERPARAMETERIUIVPROC __glewGetSamplerParameterIuiv = NULL; +PFNGLGETSAMPLERPARAMETERFVPROC __glewGetSamplerParameterfv = NULL; +PFNGLGETSAMPLERPARAMETERIVPROC __glewGetSamplerParameteriv = NULL; +PFNGLISSAMPLERPROC __glewIsSampler = NULL; +PFNGLSAMPLERPARAMETERIIVPROC __glewSamplerParameterIiv = NULL; +PFNGLSAMPLERPARAMETERIUIVPROC __glewSamplerParameterIuiv = NULL; +PFNGLSAMPLERPARAMETERFPROC __glewSamplerParameterf = NULL; +PFNGLSAMPLERPARAMETERFVPROC __glewSamplerParameterfv = NULL; +PFNGLSAMPLERPARAMETERIPROC __glewSamplerParameteri = NULL; +PFNGLSAMPLERPARAMETERIVPROC __glewSamplerParameteriv = NULL; + PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB = NULL; PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB = NULL; PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB = NULL; @@ -771,6 +798,22 @@ PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB = NULL; PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB = NULL; PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB = NULL; +PFNGLGETACTIVESUBROUTINENAMEPROC __glewGetActiveSubroutineName = NULL; +PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC __glewGetActiveSubroutineUniformName = NULL; +PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC __glewGetActiveSubroutineUniformiv = NULL; +PFNGLGETPROGRAMSTAGEIVPROC __glewGetProgramStageiv = NULL; +PFNGLGETSUBROUTINEINDEXPROC __glewGetSubroutineIndex = NULL; +PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC __glewGetSubroutineUniformLocation = NULL; +PFNGLGETUNIFORMSUBROUTINEUIVPROC __glewGetUniformSubroutineuiv = NULL; +PFNGLUNIFORMSUBROUTINESUIVPROC __glewUniformSubroutinesuiv = NULL; + +PFNGLCOMPILESHADERINCLUDEARBPROC __glewCompileShaderIncludeARB = NULL; +PFNGLDELETENAMEDSTRINGARBPROC __glewDeleteNamedStringARB = NULL; +PFNGLGETNAMEDSTRINGARBPROC __glewGetNamedStringARB = NULL; +PFNGLGETNAMEDSTRINGIVARBPROC __glewGetNamedStringivARB = NULL; +PFNGLISNAMEDSTRINGARBPROC __glewIsNamedStringARB = NULL; +PFNGLNAMEDSTRINGARBPROC __glewNamedStringARB = NULL; + PFNGLCLIENTWAITSYNCPROC __glewClientWaitSync = NULL; PFNGLDELETESYNCPROC __glewDeleteSync = NULL; PFNGLFENCESYNCPROC __glewFenceSync = NULL; @@ -779,6 +822,9 @@ PFNGLGETSYNCIVPROC __glewGetSynciv = NULL; PFNGLISSYNCPROC __glewIsSync = NULL; PFNGLWAITSYNCPROC __glewWaitSync = NULL; +PFNGLPATCHPARAMETERFVPROC __glewPatchParameterfv = NULL; +PFNGLPATCHPARAMETERIPROC __glewPatchParameteri = NULL; + PFNGLTEXBUFFERARBPROC __glewTexBufferARB = NULL; PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB = NULL; @@ -794,6 +840,23 @@ PFNGLSAMPLEMASKIPROC __glewSampleMaski = NULL; PFNGLTEXIMAGE2DMULTISAMPLEPROC __glewTexImage2DMultisample = NULL; PFNGLTEXIMAGE3DMULTISAMPLEPROC __glewTexImage3DMultisample = NULL; +PFNGLGETQUERYOBJECTI64VPROC __glewGetQueryObjecti64v = NULL; +PFNGLGETQUERYOBJECTUI64VPROC __glewGetQueryObjectui64v = NULL; +PFNGLQUERYCOUNTERPROC __glewQueryCounter = NULL; + +PFNGLBINDTRANSFORMFEEDBACKPROC __glewBindTransformFeedback = NULL; +PFNGLDELETETRANSFORMFEEDBACKSPROC __glewDeleteTransformFeedbacks = NULL; +PFNGLDRAWTRANSFORMFEEDBACKPROC __glewDrawTransformFeedback = NULL; +PFNGLGENTRANSFORMFEEDBACKSPROC __glewGenTransformFeedbacks = NULL; +PFNGLISTRANSFORMFEEDBACKPROC __glewIsTransformFeedback = NULL; +PFNGLPAUSETRANSFORMFEEDBACKPROC __glewPauseTransformFeedback = NULL; +PFNGLRESUMETRANSFORMFEEDBACKPROC __glewResumeTransformFeedback = NULL; + +PFNGLBEGINQUERYINDEXEDPROC __glewBeginQueryIndexed = NULL; +PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC __glewDrawTransformFeedbackStream = NULL; +PFNGLENDQUERYINDEXEDPROC __glewEndQueryIndexed = NULL; +PFNGLGETQUERYINDEXEDIVPROC __glewGetQueryIndexediv = NULL; + PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB = NULL; PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB = NULL; PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB = NULL; @@ -905,6 +968,45 @@ PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB = NULL; PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB = NULL; PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB = NULL; +PFNGLCOLORP3UIPROC __glewColorP3ui = NULL; +PFNGLCOLORP3UIVPROC __glewColorP3uiv = NULL; +PFNGLCOLORP4UIPROC __glewColorP4ui = NULL; +PFNGLCOLORP4UIVPROC __glewColorP4uiv = NULL; +PFNGLMULTITEXCOORDP1UIPROC __glewMultiTexCoordP1ui = NULL; +PFNGLMULTITEXCOORDP1UIVPROC __glewMultiTexCoordP1uiv = NULL; +PFNGLMULTITEXCOORDP2UIPROC __glewMultiTexCoordP2ui = NULL; +PFNGLMULTITEXCOORDP2UIVPROC __glewMultiTexCoordP2uiv = NULL; +PFNGLMULTITEXCOORDP3UIPROC __glewMultiTexCoordP3ui = NULL; +PFNGLMULTITEXCOORDP3UIVPROC __glewMultiTexCoordP3uiv = NULL; +PFNGLMULTITEXCOORDP4UIPROC __glewMultiTexCoordP4ui = NULL; +PFNGLMULTITEXCOORDP4UIVPROC __glewMultiTexCoordP4uiv = NULL; +PFNGLNORMALP3UIPROC __glewNormalP3ui = NULL; +PFNGLNORMALP3UIVPROC __glewNormalP3uiv = NULL; +PFNGLSECONDARYCOLORP3UIPROC __glewSecondaryColorP3ui = NULL; +PFNGLSECONDARYCOLORP3UIVPROC __glewSecondaryColorP3uiv = NULL; +PFNGLTEXCOORDP1UIPROC __glewTexCoordP1ui = NULL; +PFNGLTEXCOORDP1UIVPROC __glewTexCoordP1uiv = NULL; +PFNGLTEXCOORDP2UIPROC __glewTexCoordP2ui = NULL; +PFNGLTEXCOORDP2UIVPROC __glewTexCoordP2uiv = NULL; +PFNGLTEXCOORDP3UIPROC __glewTexCoordP3ui = NULL; +PFNGLTEXCOORDP3UIVPROC __glewTexCoordP3uiv = NULL; +PFNGLTEXCOORDP4UIPROC __glewTexCoordP4ui = NULL; +PFNGLTEXCOORDP4UIVPROC __glewTexCoordP4uiv = NULL; +PFNGLVERTEXATTRIBP1UIPROC __glewVertexAttribP1ui = NULL; +PFNGLVERTEXATTRIBP1UIVPROC __glewVertexAttribP1uiv = NULL; +PFNGLVERTEXATTRIBP2UIPROC __glewVertexAttribP2ui = NULL; +PFNGLVERTEXATTRIBP2UIVPROC __glewVertexAttribP2uiv = NULL; +PFNGLVERTEXATTRIBP3UIPROC __glewVertexAttribP3ui = NULL; +PFNGLVERTEXATTRIBP3UIVPROC __glewVertexAttribP3uiv = NULL; +PFNGLVERTEXATTRIBP4UIPROC __glewVertexAttribP4ui = NULL; +PFNGLVERTEXATTRIBP4UIVPROC __glewVertexAttribP4uiv = NULL; +PFNGLVERTEXP2UIPROC __glewVertexP2ui = NULL; +PFNGLVERTEXP2UIVPROC __glewVertexP2uiv = NULL; +PFNGLVERTEXP3UIPROC __glewVertexP3ui = NULL; +PFNGLVERTEXP3UIVPROC __glewVertexP3uiv = NULL; +PFNGLVERTEXP4UIPROC __glewVertexP4ui = NULL; +PFNGLVERTEXP4UIVPROC __glewVertexP4uiv = NULL; + PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB = NULL; PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB = NULL; PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB = NULL; @@ -1443,6 +1545,9 @@ PFNGLACTIVEPROGRAMEXTPROC __glewActiveProgramEXT = NULL; PFNGLCREATESHADERPROGRAMEXTPROC __glewCreateShaderProgramEXT = NULL; PFNGLUSESHADERPROGRAMEXTPROC __glewUseShaderProgramEXT = NULL; +PFNGLBINDIMAGETEXTUREEXTPROC __glewBindImageTextureEXT = NULL; +PFNGLMEMORYBARRIEREXTPROC __glewMemoryBarrierEXT = NULL; + PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT = NULL; PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT = NULL; @@ -1490,6 +1595,18 @@ PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT = NULL; PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT = NULL; PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT = NULL; +PFNGLGETVERTEXATTRIBLDVEXTPROC __glewGetVertexAttribLdvEXT = NULL; +PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC __glewVertexArrayVertexAttribLOffsetEXT = NULL; +PFNGLVERTEXATTRIBL1DEXTPROC __glewVertexAttribL1dEXT = NULL; +PFNGLVERTEXATTRIBL1DVEXTPROC __glewVertexAttribL1dvEXT = NULL; +PFNGLVERTEXATTRIBL2DEXTPROC __glewVertexAttribL2dEXT = NULL; +PFNGLVERTEXATTRIBL2DVEXTPROC __glewVertexAttribL2dvEXT = NULL; +PFNGLVERTEXATTRIBL3DEXTPROC __glewVertexAttribL3dEXT = NULL; +PFNGLVERTEXATTRIBL3DVEXTPROC __glewVertexAttribL3dvEXT = NULL; +PFNGLVERTEXATTRIBL4DEXTPROC __glewVertexAttribL4dEXT = NULL; +PFNGLVERTEXATTRIBL4DVEXTPROC __glewVertexAttribL4dvEXT = NULL; +PFNGLVERTEXATTRIBLPOINTEREXTPROC __glewVertexAttribLPointerEXT = NULL; + PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT = NULL; PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT = NULL; PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT = NULL; @@ -1656,6 +1773,41 @@ PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV = NULL; PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV = NULL; PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV = NULL; +PFNGLGETUNIFORMI64VNVPROC __glewGetUniformi64vNV = NULL; +PFNGLGETUNIFORMUI64VNVPROC __glewGetUniformui64vNV = NULL; +PFNGLPROGRAMUNIFORM1I64NVPROC __glewProgramUniform1i64NV = NULL; +PFNGLPROGRAMUNIFORM1I64VNVPROC __glewProgramUniform1i64vNV = NULL; +PFNGLPROGRAMUNIFORM1UI64NVPROC __glewProgramUniform1ui64NV = NULL; +PFNGLPROGRAMUNIFORM1UI64VNVPROC __glewProgramUniform1ui64vNV = NULL; +PFNGLPROGRAMUNIFORM2I64NVPROC __glewProgramUniform2i64NV = NULL; +PFNGLPROGRAMUNIFORM2I64VNVPROC __glewProgramUniform2i64vNV = NULL; +PFNGLPROGRAMUNIFORM2UI64NVPROC __glewProgramUniform2ui64NV = NULL; +PFNGLPROGRAMUNIFORM2UI64VNVPROC __glewProgramUniform2ui64vNV = NULL; +PFNGLPROGRAMUNIFORM3I64NVPROC __glewProgramUniform3i64NV = NULL; +PFNGLPROGRAMUNIFORM3I64VNVPROC __glewProgramUniform3i64vNV = NULL; +PFNGLPROGRAMUNIFORM3UI64NVPROC __glewProgramUniform3ui64NV = NULL; +PFNGLPROGRAMUNIFORM3UI64VNVPROC __glewProgramUniform3ui64vNV = NULL; +PFNGLPROGRAMUNIFORM4I64NVPROC __glewProgramUniform4i64NV = NULL; +PFNGLPROGRAMUNIFORM4I64VNVPROC __glewProgramUniform4i64vNV = NULL; +PFNGLPROGRAMUNIFORM4UI64NVPROC __glewProgramUniform4ui64NV = NULL; +PFNGLPROGRAMUNIFORM4UI64VNVPROC __glewProgramUniform4ui64vNV = NULL; +PFNGLUNIFORM1I64NVPROC __glewUniform1i64NV = NULL; +PFNGLUNIFORM1I64VNVPROC __glewUniform1i64vNV = NULL; +PFNGLUNIFORM1UI64NVPROC __glewUniform1ui64NV = NULL; +PFNGLUNIFORM1UI64VNVPROC __glewUniform1ui64vNV = NULL; +PFNGLUNIFORM2I64NVPROC __glewUniform2i64NV = NULL; +PFNGLUNIFORM2I64VNVPROC __glewUniform2i64vNV = NULL; +PFNGLUNIFORM2UI64NVPROC __glewUniform2ui64NV = NULL; +PFNGLUNIFORM2UI64VNVPROC __glewUniform2ui64vNV = NULL; +PFNGLUNIFORM3I64NVPROC __glewUniform3i64NV = NULL; +PFNGLUNIFORM3I64VNVPROC __glewUniform3i64vNV = NULL; +PFNGLUNIFORM3UI64NVPROC __glewUniform3ui64NV = NULL; +PFNGLUNIFORM3UI64VNVPROC __glewUniform3ui64vNV = NULL; +PFNGLUNIFORM4I64NVPROC __glewUniform4i64NV = NULL; +PFNGLUNIFORM4I64VNVPROC __glewUniform4i64vNV = NULL; +PFNGLUNIFORM4UI64NVPROC __glewUniform4ui64NV = NULL; +PFNGLUNIFORM4UI64VNVPROC __glewUniform4ui64vNV = NULL; + PFNGLCOLOR3HNVPROC __glewColor3hNV = NULL; PFNGLCOLOR3HVNVPROC __glewColor3hvNV = NULL; PFNGLCOLOR4HNVPROC __glewColor4hNV = NULL; @@ -1751,7 +1903,6 @@ PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV = NUL PFNGLGETBUFFERPARAMETERUI64VNVPROC __glewGetBufferParameterui64vNV = NULL; PFNGLGETINTEGERUI64VNVPROC __glewGetIntegerui64vNV = NULL; PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC __glewGetNamedBufferParameterui64vNV = NULL; -PFNGLGETUNIFORMUI64VNVPROC __glewGetUniformui64vNV = NULL; PFNGLISBUFFERRESIDENTNVPROC __glewIsBufferResidentNV = NULL; PFNGLISNAMEDBUFFERRESIDENTNVPROC __glewIsNamedBufferResidentNV = NULL; PFNGLMAKEBUFFERNONRESIDENTNVPROC __glewMakeBufferNonResidentNV = NULL; @@ -1788,6 +1939,26 @@ PFNGLRESUMETRANSFORMFEEDBACKNVPROC __glewResumeTransformFeedbackNV = NULL; PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV = NULL; PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV = NULL; +PFNGLGETVERTEXATTRIBLI64VNVPROC __glewGetVertexAttribLi64vNV = NULL; +PFNGLGETVERTEXATTRIBLUI64VNVPROC __glewGetVertexAttribLui64vNV = NULL; +PFNGLVERTEXATTRIBL1I64NVPROC __glewVertexAttribL1i64NV = NULL; +PFNGLVERTEXATTRIBL1I64VNVPROC __glewVertexAttribL1i64vNV = NULL; +PFNGLVERTEXATTRIBL1UI64NVPROC __glewVertexAttribL1ui64NV = NULL; +PFNGLVERTEXATTRIBL1UI64VNVPROC __glewVertexAttribL1ui64vNV = NULL; +PFNGLVERTEXATTRIBL2I64NVPROC __glewVertexAttribL2i64NV = NULL; +PFNGLVERTEXATTRIBL2I64VNVPROC __glewVertexAttribL2i64vNV = NULL; +PFNGLVERTEXATTRIBL2UI64NVPROC __glewVertexAttribL2ui64NV = NULL; +PFNGLVERTEXATTRIBL2UI64VNVPROC __glewVertexAttribL2ui64vNV = NULL; +PFNGLVERTEXATTRIBL3I64NVPROC __glewVertexAttribL3i64NV = NULL; +PFNGLVERTEXATTRIBL3I64VNVPROC __glewVertexAttribL3i64vNV = NULL; +PFNGLVERTEXATTRIBL3UI64NVPROC __glewVertexAttribL3ui64NV = NULL; +PFNGLVERTEXATTRIBL3UI64VNVPROC __glewVertexAttribL3ui64vNV = NULL; +PFNGLVERTEXATTRIBL4I64NVPROC __glewVertexAttribL4i64NV = NULL; +PFNGLVERTEXATTRIBL4I64VNVPROC __glewVertexAttribL4i64vNV = NULL; +PFNGLVERTEXATTRIBL4UI64NVPROC __glewVertexAttribL4ui64NV = NULL; +PFNGLVERTEXATTRIBL4UI64VNVPROC __glewVertexAttribL4ui64vNV = NULL; +PFNGLVERTEXATTRIBLFORMATNVPROC __glewVertexAttribLFormatNV = NULL; + PFNGLBUFFERADDRESSRANGENVPROC __glewBufferAddressRangeNV = NULL; PFNGLCOLORFORMATNVPROC __glewColorFormatNV = NULL; PFNGLEDGEFLAGFORMATNVPROC __glewEdgeFlagFormatNV = NULL; @@ -2019,11 +2190,16 @@ GLboolean __GLEW_VERSION_2_1 = GL_FALSE; GLboolean __GLEW_VERSION_3_0 = GL_FALSE; GLboolean __GLEW_VERSION_3_1 = GL_FALSE; GLboolean __GLEW_VERSION_3_2 = GL_FALSE; +GLboolean __GLEW_VERSION_3_3 = GL_FALSE; +GLboolean __GLEW_VERSION_4_0 = GL_FALSE; GLboolean __GLEW_3DFX_multisample = GL_FALSE; GLboolean __GLEW_3DFX_tbuffer = GL_FALSE; GLboolean __GLEW_3DFX_texture_compression_FXT1 = GL_FALSE; +GLboolean __GLEW_AMD_conservative_depth = GL_FALSE; GLboolean __GLEW_AMD_draw_buffers_blend = GL_FALSE; GLboolean __GLEW_AMD_performance_monitor = GL_FALSE; +GLboolean __GLEW_AMD_seamless_cubemap_per_texture = GL_FALSE; +GLboolean __GLEW_AMD_shader_stencil_export = GL_FALSE; GLboolean __GLEW_AMD_texture_texture4 = GL_FALSE; GLboolean __GLEW_AMD_vertex_shader_tessellator = GL_FALSE; GLboolean __GLEW_APPLE_aux_depth_stencil = GL_FALSE; @@ -2043,6 +2219,7 @@ GLboolean __GLEW_APPLE_vertex_array_object = GL_FALSE; GLboolean __GLEW_APPLE_vertex_array_range = GL_FALSE; GLboolean __GLEW_APPLE_vertex_program_evaluators = GL_FALSE; GLboolean __GLEW_APPLE_ycbcr_422 = GL_FALSE; +GLboolean __GLEW_ARB_blend_func_extended = GL_FALSE; GLboolean __GLEW_ARB_color_buffer_float = GL_FALSE; GLboolean __GLEW_ARB_compatibility = GL_FALSE; GLboolean __GLEW_ARB_copy_buffer = GL_FALSE; @@ -2052,7 +2229,9 @@ GLboolean __GLEW_ARB_depth_texture = GL_FALSE; GLboolean __GLEW_ARB_draw_buffers = GL_FALSE; GLboolean __GLEW_ARB_draw_buffers_blend = GL_FALSE; GLboolean __GLEW_ARB_draw_elements_base_vertex = GL_FALSE; +GLboolean __GLEW_ARB_draw_indirect = GL_FALSE; GLboolean __GLEW_ARB_draw_instanced = GL_FALSE; +GLboolean __GLEW_ARB_explicit_attrib_location = GL_FALSE; GLboolean __GLEW_ARB_fragment_coord_conventions = GL_FALSE; GLboolean __GLEW_ARB_fragment_program = GL_FALSE; GLboolean __GLEW_ARB_fragment_program_shadow = GL_FALSE; @@ -2060,6 +2239,8 @@ GLboolean __GLEW_ARB_fragment_shader = GL_FALSE; GLboolean __GLEW_ARB_framebuffer_object = GL_FALSE; GLboolean __GLEW_ARB_framebuffer_sRGB = GL_FALSE; GLboolean __GLEW_ARB_geometry_shader4 = GL_FALSE; +GLboolean __GLEW_ARB_gpu_shader5 = GL_FALSE; +GLboolean __GLEW_ARB_gpu_shader_fp64 = GL_FALSE; GLboolean __GLEW_ARB_half_float_pixel = GL_FALSE; GLboolean __GLEW_ARB_half_float_vertex = GL_FALSE; GLboolean __GLEW_ARB_imaging = GL_FALSE; @@ -2069,21 +2250,29 @@ GLboolean __GLEW_ARB_matrix_palette = GL_FALSE; GLboolean __GLEW_ARB_multisample = GL_FALSE; GLboolean __GLEW_ARB_multitexture = GL_FALSE; GLboolean __GLEW_ARB_occlusion_query = GL_FALSE; +GLboolean __GLEW_ARB_occlusion_query2 = GL_FALSE; GLboolean __GLEW_ARB_pixel_buffer_object = GL_FALSE; GLboolean __GLEW_ARB_point_parameters = GL_FALSE; GLboolean __GLEW_ARB_point_sprite = GL_FALSE; GLboolean __GLEW_ARB_provoking_vertex = GL_FALSE; GLboolean __GLEW_ARB_sample_shading = GL_FALSE; +GLboolean __GLEW_ARB_sampler_objects = GL_FALSE; GLboolean __GLEW_ARB_seamless_cube_map = GL_FALSE; +GLboolean __GLEW_ARB_shader_bit_encoding = GL_FALSE; GLboolean __GLEW_ARB_shader_objects = GL_FALSE; +GLboolean __GLEW_ARB_shader_subroutine = GL_FALSE; GLboolean __GLEW_ARB_shader_texture_lod = GL_FALSE; GLboolean __GLEW_ARB_shading_language_100 = GL_FALSE; +GLboolean __GLEW_ARB_shading_language_include = GL_FALSE; GLboolean __GLEW_ARB_shadow = GL_FALSE; GLboolean __GLEW_ARB_shadow_ambient = GL_FALSE; GLboolean __GLEW_ARB_sync = GL_FALSE; +GLboolean __GLEW_ARB_tessellation_shader = GL_FALSE; GLboolean __GLEW_ARB_texture_border_clamp = GL_FALSE; GLboolean __GLEW_ARB_texture_buffer_object = GL_FALSE; +GLboolean __GLEW_ARB_texture_buffer_object_rgb32 = GL_FALSE; GLboolean __GLEW_ARB_texture_compression = GL_FALSE; +GLboolean __GLEW_ARB_texture_compression_bptc = GL_FALSE; GLboolean __GLEW_ARB_texture_compression_rgtc = GL_FALSE; GLboolean __GLEW_ARB_texture_cube_map = GL_FALSE; GLboolean __GLEW_ARB_texture_cube_map_array = GL_FALSE; @@ -2099,6 +2288,11 @@ GLboolean __GLEW_ARB_texture_non_power_of_two = GL_FALSE; GLboolean __GLEW_ARB_texture_query_lod = GL_FALSE; GLboolean __GLEW_ARB_texture_rectangle = GL_FALSE; GLboolean __GLEW_ARB_texture_rg = GL_FALSE; +GLboolean __GLEW_ARB_texture_rgb10_a2ui = GL_FALSE; +GLboolean __GLEW_ARB_texture_swizzle = GL_FALSE; +GLboolean __GLEW_ARB_timer_query = GL_FALSE; +GLboolean __GLEW_ARB_transform_feedback2 = GL_FALSE; +GLboolean __GLEW_ARB_transform_feedback3 = GL_FALSE; GLboolean __GLEW_ARB_transpose_matrix = GL_FALSE; GLboolean __GLEW_ARB_uniform_buffer_object = GL_FALSE; GLboolean __GLEW_ARB_vertex_array_bgra = GL_FALSE; @@ -2107,6 +2301,7 @@ GLboolean __GLEW_ARB_vertex_blend = GL_FALSE; GLboolean __GLEW_ARB_vertex_buffer_object = GL_FALSE; GLboolean __GLEW_ARB_vertex_program = GL_FALSE; GLboolean __GLEW_ARB_vertex_shader = GL_FALSE; +GLboolean __GLEW_ARB_vertex_type_2_10_10_10_rev = GL_FALSE; GLboolean __GLEW_ARB_window_pos = GL_FALSE; GLboolean __GLEW_ATIX_point_sprites = GL_FALSE; GLboolean __GLEW_ATIX_texture_env_combine3 = GL_FALSE; @@ -2186,6 +2381,7 @@ GLboolean __GLEW_EXT_scene_marker = GL_FALSE; GLboolean __GLEW_EXT_secondary_color = GL_FALSE; GLboolean __GLEW_EXT_separate_shader_objects = GL_FALSE; GLboolean __GLEW_EXT_separate_specular_color = GL_FALSE; +GLboolean __GLEW_EXT_shader_image_load_store = GL_FALSE; GLboolean __GLEW_EXT_shadow_funcs = GL_FALSE; GLboolean __GLEW_EXT_shared_texture_palette = GL_FALSE; GLboolean __GLEW_EXT_stencil_clear_tag = GL_FALSE; @@ -2221,6 +2417,7 @@ GLboolean __GLEW_EXT_timer_query = GL_FALSE; GLboolean __GLEW_EXT_transform_feedback = GL_FALSE; GLboolean __GLEW_EXT_vertex_array = GL_FALSE; GLboolean __GLEW_EXT_vertex_array_bgra = GL_FALSE; +GLboolean __GLEW_EXT_vertex_attrib_64bit = GL_FALSE; GLboolean __GLEW_EXT_vertex_shader = GL_FALSE; GLboolean __GLEW_EXT_vertex_weighting = GL_FALSE; GLboolean __GLEW_GREMEDY_frame_terminator = GL_FALSE; @@ -2265,6 +2462,9 @@ GLboolean __GLEW_NV_framebuffer_multisample_coverage = GL_FALSE; GLboolean __GLEW_NV_geometry_program4 = GL_FALSE; GLboolean __GLEW_NV_geometry_shader4 = GL_FALSE; GLboolean __GLEW_NV_gpu_program4 = GL_FALSE; +GLboolean __GLEW_NV_gpu_program5 = GL_FALSE; +GLboolean __GLEW_NV_gpu_program_fp64 = GL_FALSE; +GLboolean __GLEW_NV_gpu_shader5 = GL_FALSE; GLboolean __GLEW_NV_half_float = GL_FALSE; GLboolean __GLEW_NV_light_max_exponent = GL_FALSE; GLboolean __GLEW_NV_multisample_filter_hint = GL_FALSE; @@ -2279,6 +2479,7 @@ GLboolean __GLEW_NV_primitive_restart = GL_FALSE; GLboolean __GLEW_NV_register_combiners = GL_FALSE; GLboolean __GLEW_NV_register_combiners2 = GL_FALSE; GLboolean __GLEW_NV_shader_buffer_load = GL_FALSE; +GLboolean __GLEW_NV_tessellation_program5 = GL_FALSE; GLboolean __GLEW_NV_texgen_emboss = GL_FALSE; GLboolean __GLEW_NV_texgen_reflection = GL_FALSE; GLboolean __GLEW_NV_texture_barrier = GL_FALSE; @@ -2293,6 +2494,7 @@ GLboolean __GLEW_NV_transform_feedback = GL_FALSE; GLboolean __GLEW_NV_transform_feedback2 = GL_FALSE; GLboolean __GLEW_NV_vertex_array_range = GL_FALSE; GLboolean __GLEW_NV_vertex_array_range2 = GL_FALSE; +GLboolean __GLEW_NV_vertex_attrib_integer_64bit = GL_FALSE; GLboolean __GLEW_NV_vertex_buffer_unified_memory = GL_FALSE; GLboolean __GLEW_NV_vertex_program = GL_FALSE; GLboolean __GLEW_NV_vertex_program1_1 = GL_FALSE; @@ -2759,6 +2961,27 @@ static GLboolean _glewInit_GL_VERSION_3_2 (GLEW_CONTEXT_ARG_DEF_INIT) #endif /* GL_VERSION_3_2 */ +#ifdef GL_VERSION_3_3 + +#endif /* GL_VERSION_3_3 */ + +#ifdef GL_VERSION_4_0 + +static GLboolean _glewInit_GL_VERSION_4_0 (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glBlendEquationSeparatei = (PFNGLBLENDEQUATIONSEPARATEIPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationSeparatei")) == NULL) || r; + r = ((glBlendEquationi = (PFNGLBLENDEQUATIONIPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationi")) == NULL) || r; + r = ((glBlendFuncSeparatei = (PFNGLBLENDFUNCSEPARATEIPROC)glewGetProcAddress((const GLubyte*)"glBlendFuncSeparatei")) == NULL) || r; + r = ((glBlendFunci = (PFNGLBLENDFUNCIPROC)glewGetProcAddress((const GLubyte*)"glBlendFunci")) == NULL) || r; + r = ((glMinSampleShading = (PFNGLMINSAMPLESHADINGPROC)glewGetProcAddress((const GLubyte*)"glMinSampleShading")) == NULL) || r; + + return r; +} + +#endif /* GL_VERSION_4_0 */ + #ifdef GL_3DFX_multisample #endif /* GL_3DFX_multisample */ @@ -2780,6 +3003,10 @@ static GLboolean _glewInit_GL_3DFX_tbuffer (GLEW_CONTEXT_ARG_DEF_INIT) #endif /* GL_3DFX_texture_compression_FXT1 */ +#ifdef GL_AMD_conservative_depth + +#endif /* GL_AMD_conservative_depth */ + #ifdef GL_AMD_draw_buffers_blend static GLboolean _glewInit_GL_AMD_draw_buffers_blend (GLEW_CONTEXT_ARG_DEF_INIT) @@ -2819,6 +3046,14 @@ static GLboolean _glewInit_GL_AMD_performance_monitor (GLEW_CONTEXT_ARG_DEF_INIT #endif /* GL_AMD_performance_monitor */ +#ifdef GL_AMD_seamless_cubemap_per_texture + +#endif /* GL_AMD_seamless_cubemap_per_texture */ + +#ifdef GL_AMD_shader_stencil_export + +#endif /* GL_AMD_shader_stencil_export */ + #ifdef GL_AMD_texture_texture4 #endif /* GL_AMD_texture_texture4 */ @@ -3003,6 +3238,20 @@ static GLboolean _glewInit_GL_APPLE_vertex_program_evaluators (GLEW_CONTEXT_ARG_ #endif /* GL_APPLE_ycbcr_422 */ +#ifdef GL_ARB_blend_func_extended + +static GLboolean _glewInit_GL_ARB_blend_func_extended (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)glewGetProcAddress((const GLubyte*)"glBindFragDataLocationIndexed")) == NULL) || r; + r = ((glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC)glewGetProcAddress((const GLubyte*)"glGetFragDataIndex")) == NULL) || r; + + return r; +} + +#endif /* GL_ARB_blend_func_extended */ + #ifdef GL_ARB_color_buffer_float static GLboolean _glewInit_GL_ARB_color_buffer_float (GLEW_CONTEXT_ARG_DEF_INIT) @@ -3090,6 +3339,20 @@ static GLboolean _glewInit_GL_ARB_draw_elements_base_vertex (GLEW_CONTEXT_ARG_DE #endif /* GL_ARB_draw_elements_base_vertex */ +#ifdef GL_ARB_draw_indirect + +static GLboolean _glewInit_GL_ARB_draw_indirect (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glDrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysIndirect")) == NULL) || r; + r = ((glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsIndirect")) == NULL) || r; + + return r; +} + +#endif /* GL_ARB_draw_indirect */ + #ifdef GL_ARB_draw_instanced static GLboolean _glewInit_GL_ARB_draw_instanced (GLEW_CONTEXT_ARG_DEF_INIT) @@ -3104,6 +3367,10 @@ static GLboolean _glewInit_GL_ARB_draw_instanced (GLEW_CONTEXT_ARG_DEF_INIT) #endif /* GL_ARB_draw_instanced */ +#ifdef GL_ARB_explicit_attrib_location + +#endif /* GL_ARB_explicit_attrib_location */ + #ifdef GL_ARB_fragment_coord_conventions #endif /* GL_ARB_fragment_coord_conventions */ @@ -3172,6 +3439,14 @@ static GLboolean _glewInit_GL_ARB_geometry_shader4 (GLEW_CONTEXT_ARG_DEF_INIT) #endif /* GL_ARB_geometry_shader4 */ +#ifdef GL_ARB_gpu_shader5 + +#endif /* GL_ARB_gpu_shader5 */ + +#ifdef GL_ARB_gpu_shader_fp64 + +#endif /* GL_ARB_gpu_shader_fp64 */ + #ifdef GL_ARB_half_float_pixel #endif /* GL_ARB_half_float_pixel */ @@ -3348,6 +3623,10 @@ static GLboolean _glewInit_GL_ARB_occlusion_query (GLEW_CONTEXT_ARG_DEF_INIT) #endif /* GL_ARB_occlusion_query */ +#ifdef GL_ARB_occlusion_query2 + +#endif /* GL_ARB_occlusion_query2 */ + #ifdef GL_ARB_pixel_buffer_object #endif /* GL_ARB_pixel_buffer_object */ @@ -3396,10 +3675,40 @@ static GLboolean _glewInit_GL_ARB_sample_shading (GLEW_CONTEXT_ARG_DEF_INIT) #endif /* GL_ARB_sample_shading */ +#ifdef GL_ARB_sampler_objects + +static GLboolean _glewInit_GL_ARB_sampler_objects (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glBindSampler = (PFNGLBINDSAMPLERPROC)glewGetProcAddress((const GLubyte*)"glBindSampler")) == NULL) || r; + r = ((glDeleteSamplers = (PFNGLDELETESAMPLERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteSamplers")) == NULL) || r; + r = ((glGenSamplers = (PFNGLGENSAMPLERSPROC)glewGetProcAddress((const GLubyte*)"glGenSamplers")) == NULL) || r; + r = ((glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)"glGetSamplerParameterIiv")) == NULL) || r; + r = ((glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)"glGetSamplerParameterIuiv")) == NULL) || r; + r = ((glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetSamplerParameterfv")) == NULL) || r; + r = ((glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetSamplerParameteriv")) == NULL) || r; + r = ((glIsSampler = (PFNGLISSAMPLERPROC)glewGetProcAddress((const GLubyte*)"glIsSampler")) == NULL) || r; + r = ((glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)"glSamplerParameterIiv")) == NULL) || r; + r = ((glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)"glSamplerParameterIuiv")) == NULL) || r; + r = ((glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC)glewGetProcAddress((const GLubyte*)"glSamplerParameterf")) == NULL) || r; + r = ((glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glSamplerParameterfv")) == NULL) || r; + r = ((glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC)glewGetProcAddress((const GLubyte*)"glSamplerParameteri")) == NULL) || r; + r = ((glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glSamplerParameteriv")) == NULL) || r; + + return r; +} + +#endif /* GL_ARB_sampler_objects */ + #ifdef GL_ARB_seamless_cube_map #endif /* GL_ARB_seamless_cube_map */ +#ifdef GL_ARB_shader_bit_encoding + +#endif /* GL_ARB_shader_bit_encoding */ + #ifdef GL_ARB_shader_objects static GLboolean _glewInit_GL_ARB_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT) @@ -3451,6 +3760,26 @@ static GLboolean _glewInit_GL_ARB_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT) #endif /* GL_ARB_shader_objects */ +#ifdef GL_ARB_shader_subroutine + +static GLboolean _glewInit_GL_ARB_shader_subroutine (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glGetActiveSubroutineName = (PFNGLGETACTIVESUBROUTINENAMEPROC)glewGetProcAddress((const GLubyte*)"glGetActiveSubroutineName")) == NULL) || r; + r = ((glGetActiveSubroutineUniformName = (PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)glewGetProcAddress((const GLubyte*)"glGetActiveSubroutineUniformName")) == NULL) || r; + r = ((glGetActiveSubroutineUniformiv = (PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC)glewGetProcAddress((const GLubyte*)"glGetActiveSubroutineUniformiv")) == NULL) || r; + r = ((glGetProgramStageiv = (PFNGLGETPROGRAMSTAGEIVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramStageiv")) == NULL) || r; + r = ((glGetSubroutineIndex = (PFNGLGETSUBROUTINEINDEXPROC)glewGetProcAddress((const GLubyte*)"glGetSubroutineIndex")) == NULL) || r; + r = ((glGetSubroutineUniformLocation = (PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC)glewGetProcAddress((const GLubyte*)"glGetSubroutineUniformLocation")) == NULL) || r; + r = ((glGetUniformSubroutineuiv = (PFNGLGETUNIFORMSUBROUTINEUIVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformSubroutineuiv")) == NULL) || r; + r = ((glUniformSubroutinesuiv = (PFNGLUNIFORMSUBROUTINESUIVPROC)glewGetProcAddress((const GLubyte*)"glUniformSubroutinesuiv")) == NULL) || r; + + return r; +} + +#endif /* GL_ARB_shader_subroutine */ + #ifdef GL_ARB_shader_texture_lod #endif /* GL_ARB_shader_texture_lod */ @@ -3459,6 +3788,24 @@ static GLboolean _glewInit_GL_ARB_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT) #endif /* GL_ARB_shading_language_100 */ +#ifdef GL_ARB_shading_language_include + +static GLboolean _glewInit_GL_ARB_shading_language_include (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glCompileShaderIncludeARB = (PFNGLCOMPILESHADERINCLUDEARBPROC)glewGetProcAddress((const GLubyte*)"glCompileShaderIncludeARB")) == NULL) || r; + r = ((glDeleteNamedStringARB = (PFNGLDELETENAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"glDeleteNamedStringARB")) == NULL) || r; + r = ((glGetNamedStringARB = (PFNGLGETNAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"glGetNamedStringARB")) == NULL) || r; + r = ((glGetNamedStringivARB = (PFNGLGETNAMEDSTRINGIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetNamedStringivARB")) == NULL) || r; + r = ((glIsNamedStringARB = (PFNGLISNAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"glIsNamedStringARB")) == NULL) || r; + r = ((glNamedStringARB = (PFNGLNAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"glNamedStringARB")) == NULL) || r; + + return r; +} + +#endif /* GL_ARB_shading_language_include */ + #ifdef GL_ARB_shadow #endif /* GL_ARB_shadow */ @@ -3486,6 +3833,20 @@ static GLboolean _glewInit_GL_ARB_sync (GLEW_CONTEXT_ARG_DEF_INIT) #endif /* GL_ARB_sync */ +#ifdef GL_ARB_tessellation_shader + +static GLboolean _glewInit_GL_ARB_tessellation_shader (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glPatchParameterfv = (PFNGLPATCHPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glPatchParameterfv")) == NULL) || r; + r = ((glPatchParameteri = (PFNGLPATCHPARAMETERIPROC)glewGetProcAddress((const GLubyte*)"glPatchParameteri")) == NULL) || r; + + return r; +} + +#endif /* GL_ARB_tessellation_shader */ + #ifdef GL_ARB_texture_border_clamp #endif /* GL_ARB_texture_border_clamp */ @@ -3503,6 +3864,10 @@ static GLboolean _glewInit_GL_ARB_texture_buffer_object (GLEW_CONTEXT_ARG_DEF_IN #endif /* GL_ARB_texture_buffer_object */ +#ifdef GL_ARB_texture_buffer_object_rgb32 + +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + #ifdef GL_ARB_texture_compression static GLboolean _glewInit_GL_ARB_texture_compression (GLEW_CONTEXT_ARG_DEF_INIT) @@ -3522,6 +3887,10 @@ static GLboolean _glewInit_GL_ARB_texture_compression (GLEW_CONTEXT_ARG_DEF_INIT #endif /* GL_ARB_texture_compression */ +#ifdef GL_ARB_texture_compression_bptc + +#endif /* GL_ARB_texture_compression_bptc */ + #ifdef GL_ARB_texture_compression_rgtc #endif /* GL_ARB_texture_compression_rgtc */ @@ -3594,6 +3963,64 @@ static GLboolean _glewInit_GL_ARB_texture_multisample (GLEW_CONTEXT_ARG_DEF_INIT #endif /* GL_ARB_texture_rg */ +#ifdef GL_ARB_texture_rgb10_a2ui + +#endif /* GL_ARB_texture_rgb10_a2ui */ + +#ifdef GL_ARB_texture_swizzle + +#endif /* GL_ARB_texture_swizzle */ + +#ifdef GL_ARB_timer_query + +static GLboolean _glewInit_GL_ARB_timer_query (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjecti64v")) == NULL) || r; + r = ((glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectui64v")) == NULL) || r; + r = ((glQueryCounter = (PFNGLQUERYCOUNTERPROC)glewGetProcAddress((const GLubyte*)"glQueryCounter")) == NULL) || r; + + return r; +} + +#endif /* GL_ARB_timer_query */ + +#ifdef GL_ARB_transform_feedback2 + +static GLboolean _glewInit_GL_ARB_transform_feedback2 (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glBindTransformFeedback")) == NULL) || r; + r = ((glDeleteTransformFeedbacks = (PFNGLDELETETRANSFORMFEEDBACKSPROC)glewGetProcAddress((const GLubyte*)"glDeleteTransformFeedbacks")) == NULL) || r; + r = ((glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glDrawTransformFeedback")) == NULL) || r; + r = ((glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC)glewGetProcAddress((const GLubyte*)"glGenTransformFeedbacks")) == NULL) || r; + r = ((glIsTransformFeedback = (PFNGLISTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glIsTransformFeedback")) == NULL) || r; + r = ((glPauseTransformFeedback = (PFNGLPAUSETRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glPauseTransformFeedback")) == NULL) || r; + r = ((glResumeTransformFeedback = (PFNGLRESUMETRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glResumeTransformFeedback")) == NULL) || r; + + return r; +} + +#endif /* GL_ARB_transform_feedback2 */ + +#ifdef GL_ARB_transform_feedback3 + +static GLboolean _glewInit_GL_ARB_transform_feedback3 (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glBeginQueryIndexed = (PFNGLBEGINQUERYINDEXEDPROC)glewGetProcAddress((const GLubyte*)"glBeginQueryIndexed")) == NULL) || r; + r = ((glDrawTransformFeedbackStream = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC)glewGetProcAddress((const GLubyte*)"glDrawTransformFeedbackStream")) == NULL) || r; + r = ((glEndQueryIndexed = (PFNGLENDQUERYINDEXEDPROC)glewGetProcAddress((const GLubyte*)"glEndQueryIndexed")) == NULL) || r; + r = ((glGetQueryIndexediv = (PFNGLGETQUERYINDEXEDIVPROC)glewGetProcAddress((const GLubyte*)"glGetQueryIndexediv")) == NULL) || r; + + return r; +} + +#endif /* GL_ARB_transform_feedback3 */ + #ifdef GL_ARB_transpose_matrix static GLboolean _glewInit_GL_ARB_transpose_matrix (GLEW_CONTEXT_ARG_DEF_INIT) @@ -3786,6 +4213,56 @@ static GLboolean _glewInit_GL_ARB_vertex_shader (GLEW_CONTEXT_ARG_DEF_INIT) #endif /* GL_ARB_vertex_shader */ +#ifdef GL_ARB_vertex_type_2_10_10_10_rev + +static GLboolean _glewInit_GL_ARB_vertex_type_2_10_10_10_rev (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glColorP3ui = (PFNGLCOLORP3UIPROC)glewGetProcAddress((const GLubyte*)"glColorP3ui")) == NULL) || r; + r = ((glColorP3uiv = (PFNGLCOLORP3UIVPROC)glewGetProcAddress((const GLubyte*)"glColorP3uiv")) == NULL) || r; + r = ((glColorP4ui = (PFNGLCOLORP4UIPROC)glewGetProcAddress((const GLubyte*)"glColorP4ui")) == NULL) || r; + r = ((glColorP4uiv = (PFNGLCOLORP4UIVPROC)glewGetProcAddress((const GLubyte*)"glColorP4uiv")) == NULL) || r; + r = ((glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP1ui")) == NULL) || r; + r = ((glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP1uiv")) == NULL) || r; + r = ((glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP2ui")) == NULL) || r; + r = ((glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP2uiv")) == NULL) || r; + r = ((glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP3ui")) == NULL) || r; + r = ((glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP3uiv")) == NULL) || r; + r = ((glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP4ui")) == NULL) || r; + r = ((glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordP4uiv")) == NULL) || r; + r = ((glNormalP3ui = (PFNGLNORMALP3UIPROC)glewGetProcAddress((const GLubyte*)"glNormalP3ui")) == NULL) || r; + r = ((glNormalP3uiv = (PFNGLNORMALP3UIVPROC)glewGetProcAddress((const GLubyte*)"glNormalP3uiv")) == NULL) || r; + r = ((glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorP3ui")) == NULL) || r; + r = ((glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorP3uiv")) == NULL) || r; + r = ((glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP1ui")) == NULL) || r; + r = ((glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP1uiv")) == NULL) || r; + r = ((glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP2ui")) == NULL) || r; + r = ((glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP2uiv")) == NULL) || r; + r = ((glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP3ui")) == NULL) || r; + r = ((glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP3uiv")) == NULL) || r; + r = ((glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP4ui")) == NULL) || r; + r = ((glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC)glewGetProcAddress((const GLubyte*)"glTexCoordP4uiv")) == NULL) || r; + r = ((glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP1ui")) == NULL) || r; + r = ((glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP1uiv")) == NULL) || r; + r = ((glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP2ui")) == NULL) || r; + r = ((glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP2uiv")) == NULL) || r; + r = ((glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP3ui")) == NULL) || r; + r = ((glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP3uiv")) == NULL) || r; + r = ((glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP4ui")) == NULL) || r; + r = ((glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribP4uiv")) == NULL) || r; + r = ((glVertexP2ui = (PFNGLVERTEXP2UIPROC)glewGetProcAddress((const GLubyte*)"glVertexP2ui")) == NULL) || r; + r = ((glVertexP2uiv = (PFNGLVERTEXP2UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexP2uiv")) == NULL) || r; + r = ((glVertexP3ui = (PFNGLVERTEXP3UIPROC)glewGetProcAddress((const GLubyte*)"glVertexP3ui")) == NULL) || r; + r = ((glVertexP3uiv = (PFNGLVERTEXP3UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexP3uiv")) == NULL) || r; + r = ((glVertexP4ui = (PFNGLVERTEXP4UIPROC)glewGetProcAddress((const GLubyte*)"glVertexP4ui")) == NULL) || r; + r = ((glVertexP4uiv = (PFNGLVERTEXP4UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexP4uiv")) == NULL) || r; + + return r; +} + +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ + #ifdef GL_ARB_window_pos static GLboolean _glewInit_GL_ARB_window_pos (GLEW_CONTEXT_ARG_DEF_INIT) @@ -4983,6 +5460,20 @@ static GLboolean _glewInit_GL_EXT_separate_shader_objects (GLEW_CONTEXT_ARG_DEF_ #endif /* GL_EXT_separate_specular_color */ +#ifdef GL_EXT_shader_image_load_store + +static GLboolean _glewInit_GL_EXT_shader_image_load_store (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glBindImageTextureEXT = (PFNGLBINDIMAGETEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glBindImageTextureEXT")) == NULL) || r; + r = ((glMemoryBarrierEXT = (PFNGLMEMORYBARRIEREXTPROC)glewGetProcAddress((const GLubyte*)"glMemoryBarrierEXT")) == NULL) || r; + + return r; +} + +#endif /* GL_EXT_shader_image_load_store */ + #ifdef GL_EXT_shadow_funcs #endif /* GL_EXT_shadow_funcs */ @@ -5240,6 +5731,29 @@ static GLboolean _glewInit_GL_EXT_vertex_array (GLEW_CONTEXT_ARG_DEF_INIT) #endif /* GL_EXT_vertex_array_bgra */ +#ifdef GL_EXT_vertex_attrib_64bit + +static GLboolean _glewInit_GL_EXT_vertex_attrib_64bit (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glGetVertexAttribLdvEXT = (PFNGLGETVERTEXATTRIBLDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribLdvEXT")) == NULL) || r; + r = ((glVertexArrayVertexAttribLOffsetEXT = (PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayVertexAttribLOffsetEXT")) == NULL) || r; + r = ((glVertexAttribL1dEXT = (PFNGLVERTEXATTRIBL1DEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1dEXT")) == NULL) || r; + r = ((glVertexAttribL1dvEXT = (PFNGLVERTEXATTRIBL1DVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1dvEXT")) == NULL) || r; + r = ((glVertexAttribL2dEXT = (PFNGLVERTEXATTRIBL2DEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL2dEXT")) == NULL) || r; + r = ((glVertexAttribL2dvEXT = (PFNGLVERTEXATTRIBL2DVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL2dvEXT")) == NULL) || r; + r = ((glVertexAttribL3dEXT = (PFNGLVERTEXATTRIBL3DEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL3dEXT")) == NULL) || r; + r = ((glVertexAttribL3dvEXT = (PFNGLVERTEXATTRIBL3DVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL3dvEXT")) == NULL) || r; + r = ((glVertexAttribL4dEXT = (PFNGLVERTEXATTRIBL4DEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL4dEXT")) == NULL) || r; + r = ((glVertexAttribL4dvEXT = (PFNGLVERTEXATTRIBL4DVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL4dvEXT")) == NULL) || r; + r = ((glVertexAttribLPointerEXT = (PFNGLVERTEXATTRIBLPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribLPointerEXT")) == NULL) || r; + + return r; +} + +#endif /* GL_EXT_vertex_attrib_64bit */ + #ifdef GL_EXT_vertex_shader static GLboolean _glewInit_GL_EXT_vertex_shader (GLEW_CONTEXT_ARG_DEF_INIT) @@ -5736,6 +6250,60 @@ static GLboolean _glewInit_GL_NV_gpu_program4 (GLEW_CONTEXT_ARG_DEF_INIT) #endif /* GL_NV_gpu_program4 */ +#ifdef GL_NV_gpu_program5 + +#endif /* GL_NV_gpu_program5 */ + +#ifdef GL_NV_gpu_program_fp64 + +#endif /* GL_NV_gpu_program_fp64 */ + +#ifdef GL_NV_gpu_shader5 + +static GLboolean _glewInit_GL_NV_gpu_shader5 (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glGetUniformi64vNV = (PFNGLGETUNIFORMI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformi64vNV")) == NULL) || r; + r = ((glGetUniformui64vNV = (PFNGLGETUNIFORMUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformui64vNV")) == NULL) || r; + r = ((glProgramUniform1i64NV = (PFNGLPROGRAMUNIFORM1I64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1i64NV")) == NULL) || r; + r = ((glProgramUniform1i64vNV = (PFNGLPROGRAMUNIFORM1I64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1i64vNV")) == NULL) || r; + r = ((glProgramUniform1ui64NV = (PFNGLPROGRAMUNIFORM1UI64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1ui64NV")) == NULL) || r; + r = ((glProgramUniform1ui64vNV = (PFNGLPROGRAMUNIFORM1UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1ui64vNV")) == NULL) || r; + r = ((glProgramUniform2i64NV = (PFNGLPROGRAMUNIFORM2I64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2i64NV")) == NULL) || r; + r = ((glProgramUniform2i64vNV = (PFNGLPROGRAMUNIFORM2I64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2i64vNV")) == NULL) || r; + r = ((glProgramUniform2ui64NV = (PFNGLPROGRAMUNIFORM2UI64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2ui64NV")) == NULL) || r; + r = ((glProgramUniform2ui64vNV = (PFNGLPROGRAMUNIFORM2UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2ui64vNV")) == NULL) || r; + r = ((glProgramUniform3i64NV = (PFNGLPROGRAMUNIFORM3I64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3i64NV")) == NULL) || r; + r = ((glProgramUniform3i64vNV = (PFNGLPROGRAMUNIFORM3I64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3i64vNV")) == NULL) || r; + r = ((glProgramUniform3ui64NV = (PFNGLPROGRAMUNIFORM3UI64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3ui64NV")) == NULL) || r; + r = ((glProgramUniform3ui64vNV = (PFNGLPROGRAMUNIFORM3UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3ui64vNV")) == NULL) || r; + r = ((glProgramUniform4i64NV = (PFNGLPROGRAMUNIFORM4I64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4i64NV")) == NULL) || r; + r = ((glProgramUniform4i64vNV = (PFNGLPROGRAMUNIFORM4I64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4i64vNV")) == NULL) || r; + r = ((glProgramUniform4ui64NV = (PFNGLPROGRAMUNIFORM4UI64NVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4ui64NV")) == NULL) || r; + r = ((glProgramUniform4ui64vNV = (PFNGLPROGRAMUNIFORM4UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4ui64vNV")) == NULL) || r; + r = ((glUniform1i64NV = (PFNGLUNIFORM1I64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform1i64NV")) == NULL) || r; + r = ((glUniform1i64vNV = (PFNGLUNIFORM1I64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform1i64vNV")) == NULL) || r; + r = ((glUniform1ui64NV = (PFNGLUNIFORM1UI64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform1ui64NV")) == NULL) || r; + r = ((glUniform1ui64vNV = (PFNGLUNIFORM1UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform1ui64vNV")) == NULL) || r; + r = ((glUniform2i64NV = (PFNGLUNIFORM2I64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform2i64NV")) == NULL) || r; + r = ((glUniform2i64vNV = (PFNGLUNIFORM2I64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform2i64vNV")) == NULL) || r; + r = ((glUniform2ui64NV = (PFNGLUNIFORM2UI64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform2ui64NV")) == NULL) || r; + r = ((glUniform2ui64vNV = (PFNGLUNIFORM2UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform2ui64vNV")) == NULL) || r; + r = ((glUniform3i64NV = (PFNGLUNIFORM3I64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform3i64NV")) == NULL) || r; + r = ((glUniform3i64vNV = (PFNGLUNIFORM3I64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform3i64vNV")) == NULL) || r; + r = ((glUniform3ui64NV = (PFNGLUNIFORM3UI64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform3ui64NV")) == NULL) || r; + r = ((glUniform3ui64vNV = (PFNGLUNIFORM3UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform3ui64vNV")) == NULL) || r; + r = ((glUniform4i64NV = (PFNGLUNIFORM4I64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform4i64NV")) == NULL) || r; + r = ((glUniform4i64vNV = (PFNGLUNIFORM4I64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform4i64vNV")) == NULL) || r; + r = ((glUniform4ui64NV = (PFNGLUNIFORM4UI64NVPROC)glewGetProcAddress((const GLubyte*)"glUniform4ui64NV")) == NULL) || r; + r = ((glUniform4ui64vNV = (PFNGLUNIFORM4UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glUniform4ui64vNV")) == NULL) || r; + + return r; +} + +#endif /* GL_NV_gpu_shader5 */ + #ifdef GL_NV_half_float static GLboolean _glewInit_GL_NV_half_float (GLEW_CONTEXT_ARG_DEF_INIT) @@ -5952,7 +6520,6 @@ static GLboolean _glewInit_GL_NV_shader_buffer_load (GLEW_CONTEXT_ARG_DEF_INIT) r = ((glGetBufferParameterui64vNV = (PFNGLGETBUFFERPARAMETERUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetBufferParameterui64vNV")) == NULL) || r; r = ((glGetIntegerui64vNV = (PFNGLGETINTEGERUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetIntegerui64vNV")) == NULL) || r; r = ((glGetNamedBufferParameterui64vNV = (PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferParameterui64vNV")) == NULL) || r; - r = ((glGetUniformui64vNV = (PFNGLGETUNIFORMUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformui64vNV")) == NULL) || r; r = ((glIsBufferResidentNV = (PFNGLISBUFFERRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glIsBufferResidentNV")) == NULL) || r; r = ((glIsNamedBufferResidentNV = (PFNGLISNAMEDBUFFERRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glIsNamedBufferResidentNV")) == NULL) || r; r = ((glMakeBufferNonResidentNV = (PFNGLMAKEBUFFERNONRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glMakeBufferNonResidentNV")) == NULL) || r; @@ -5969,6 +6536,10 @@ static GLboolean _glewInit_GL_NV_shader_buffer_load (GLEW_CONTEXT_ARG_DEF_INIT) #endif /* GL_NV_shader_buffer_load */ +#ifdef GL_NV_tessellation_program5 + +#endif /* GL_NV_tessellation_program5 */ + #ifdef GL_NV_texgen_emboss #endif /* GL_NV_texgen_emboss */ @@ -6078,6 +6649,37 @@ static GLboolean _glewInit_GL_NV_vertex_array_range (GLEW_CONTEXT_ARG_DEF_INIT) #endif /* GL_NV_vertex_array_range2 */ +#ifdef GL_NV_vertex_attrib_integer_64bit + +static GLboolean _glewInit_GL_NV_vertex_attrib_integer_64bit (GLEW_CONTEXT_ARG_DEF_INIT) +{ + GLboolean r = GL_FALSE; + + r = ((glGetVertexAttribLi64vNV = (PFNGLGETVERTEXATTRIBLI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribLi64vNV")) == NULL) || r; + r = ((glGetVertexAttribLui64vNV = (PFNGLGETVERTEXATTRIBLUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribLui64vNV")) == NULL) || r; + r = ((glVertexAttribL1i64NV = (PFNGLVERTEXATTRIBL1I64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1i64NV")) == NULL) || r; + r = ((glVertexAttribL1i64vNV = (PFNGLVERTEXATTRIBL1I64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1i64vNV")) == NULL) || r; + r = ((glVertexAttribL1ui64NV = (PFNGLVERTEXATTRIBL1UI64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1ui64NV")) == NULL) || r; + r = ((glVertexAttribL1ui64vNV = (PFNGLVERTEXATTRIBL1UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL1ui64vNV")) == NULL) || r; + r = ((glVertexAttribL2i64NV = (PFNGLVERTEXATTRIBL2I64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL2i64NV")) == NULL) || r; + r = ((glVertexAttribL2i64vNV = (PFNGLVERTEXATTRIBL2I64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL2i64vNV")) == NULL) || r; + r = ((glVertexAttribL2ui64NV = (PFNGLVERTEXATTRIBL2UI64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL2ui64NV")) == NULL) || r; + r = ((glVertexAttribL2ui64vNV = (PFNGLVERTEXATTRIBL2UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL2ui64vNV")) == NULL) || r; + r = ((glVertexAttribL3i64NV = (PFNGLVERTEXATTRIBL3I64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL3i64NV")) == NULL) || r; + r = ((glVertexAttribL3i64vNV = (PFNGLVERTEXATTRIBL3I64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL3i64vNV")) == NULL) || r; + r = ((glVertexAttribL3ui64NV = (PFNGLVERTEXATTRIBL3UI64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL3ui64NV")) == NULL) || r; + r = ((glVertexAttribL3ui64vNV = (PFNGLVERTEXATTRIBL3UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL3ui64vNV")) == NULL) || r; + r = ((glVertexAttribL4i64NV = (PFNGLVERTEXATTRIBL4I64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL4i64NV")) == NULL) || r; + r = ((glVertexAttribL4i64vNV = (PFNGLVERTEXATTRIBL4I64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL4i64vNV")) == NULL) || r; + r = ((glVertexAttribL4ui64NV = (PFNGLVERTEXATTRIBL4UI64NVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL4ui64NV")) == NULL) || r; + r = ((glVertexAttribL4ui64vNV = (PFNGLVERTEXATTRIBL4UI64VNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribL4ui64vNV")) == NULL) || r; + r = ((glVertexAttribLFormatNV = (PFNGLVERTEXATTRIBLFORMATNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribLFormatNV")) == NULL) || r; + + return r; +} + +#endif /* GL_NV_vertex_attrib_integer_64bit */ + #ifdef GL_NV_vertex_buffer_unified_memory static GLboolean _glewInit_GL_NV_vertex_buffer_unified_memory (GLEW_CONTEXT_ARG_DEF_INIT) @@ -6838,7 +7440,11 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) } else { - CONST_CAST(GLEW_VERSION_3_0) = ( major >= 3 ) ? GL_TRUE : GL_FALSE; + CONST_CAST(GLEW_VERSION_4_0) = ( major > 4 ) || ( major == 4 ) ? GL_TRUE : GL_FALSE; + CONST_CAST(GLEW_VERSION_3_3) = GLEW_VERSION_4_0 == GL_TRUE || ( major == 3 && minor >= 3 ) ? GL_TRUE : GL_FALSE; + CONST_CAST(GLEW_VERSION_3_2) = GLEW_VERSION_3_3 == GL_TRUE || ( major == 3 && minor >= 2 ) ? GL_TRUE : GL_FALSE; + CONST_CAST(GLEW_VERSION_3_1) = GLEW_VERSION_3_2 == GL_TRUE || ( major == 3 && minor >= 1 ) ? GL_TRUE : GL_FALSE; + CONST_CAST(GLEW_VERSION_3_0) = GLEW_VERSION_3_1 == GL_TRUE || ( major == 3 ) ? GL_TRUE : GL_FALSE; CONST_CAST(GLEW_VERSION_2_1) = GLEW_VERSION_3_0 == GL_TRUE || ( major == 2 && minor >= 1 ) ? GL_TRUE : GL_FALSE; CONST_CAST(GLEW_VERSION_2_0) = GLEW_VERSION_2_1 == GL_TRUE || ( major == 2 ) ? GL_TRUE : GL_FALSE; CONST_CAST(GLEW_VERSION_1_5) = GLEW_VERSION_2_0 == GL_TRUE || ( major == 1 && minor >= 5 ) ? GL_TRUE : GL_FALSE; @@ -6875,6 +7481,11 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) #ifdef GL_VERSION_3_2 if (glewExperimental || GLEW_VERSION_3_2) CONST_CAST(GLEW_VERSION_3_2) = !_glewInit_GL_VERSION_3_2(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_VERSION_3_2 */ +#ifdef GL_VERSION_3_3 +#endif /* GL_VERSION_3_3 */ +#ifdef GL_VERSION_4_0 + if (glewExperimental || GLEW_VERSION_4_0) CONST_CAST(GLEW_VERSION_4_0) = !_glewInit_GL_VERSION_4_0(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_VERSION_4_0 */ #ifdef GL_3DFX_multisample CONST_CAST(GLEW_3DFX_multisample) = glewGetExtension("GL_3DFX_multisample"); #endif /* GL_3DFX_multisample */ @@ -6885,6 +7496,9 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) #ifdef GL_3DFX_texture_compression_FXT1 CONST_CAST(GLEW_3DFX_texture_compression_FXT1) = glewGetExtension("GL_3DFX_texture_compression_FXT1"); #endif /* GL_3DFX_texture_compression_FXT1 */ +#ifdef GL_AMD_conservative_depth + CONST_CAST(GLEW_AMD_conservative_depth) = glewGetExtension("GL_AMD_conservative_depth"); +#endif /* GL_AMD_conservative_depth */ #ifdef GL_AMD_draw_buffers_blend CONST_CAST(GLEW_AMD_draw_buffers_blend) = glewGetExtension("GL_AMD_draw_buffers_blend"); if (glewExperimental || GLEW_AMD_draw_buffers_blend) CONST_CAST(GLEW_AMD_draw_buffers_blend) = !_glewInit_GL_AMD_draw_buffers_blend(GLEW_CONTEXT_ARG_VAR_INIT); @@ -6893,6 +7507,12 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) CONST_CAST(GLEW_AMD_performance_monitor) = glewGetExtension("GL_AMD_performance_monitor"); if (glewExperimental || GLEW_AMD_performance_monitor) CONST_CAST(GLEW_AMD_performance_monitor) = !_glewInit_GL_AMD_performance_monitor(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_AMD_performance_monitor */ +#ifdef GL_AMD_seamless_cubemap_per_texture + CONST_CAST(GLEW_AMD_seamless_cubemap_per_texture) = glewGetExtension("GL_AMD_seamless_cubemap_per_texture"); +#endif /* GL_AMD_seamless_cubemap_per_texture */ +#ifdef GL_AMD_shader_stencil_export + CONST_CAST(GLEW_AMD_shader_stencil_export) = glewGetExtension("GL_AMD_shader_stencil_export"); +#endif /* GL_AMD_shader_stencil_export */ #ifdef GL_AMD_texture_texture4 CONST_CAST(GLEW_AMD_texture_texture4) = glewGetExtension("GL_AMD_texture_texture4"); #endif /* GL_AMD_texture_texture4 */ @@ -6959,6 +7579,10 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) #ifdef GL_APPLE_ycbcr_422 CONST_CAST(GLEW_APPLE_ycbcr_422) = glewGetExtension("GL_APPLE_ycbcr_422"); #endif /* GL_APPLE_ycbcr_422 */ +#ifdef GL_ARB_blend_func_extended + CONST_CAST(GLEW_ARB_blend_func_extended) = glewGetExtension("GL_ARB_blend_func_extended"); + if (glewExperimental || GLEW_ARB_blend_func_extended) CONST_CAST(GLEW_ARB_blend_func_extended) = !_glewInit_GL_ARB_blend_func_extended(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_ARB_blend_func_extended */ #ifdef GL_ARB_color_buffer_float CONST_CAST(GLEW_ARB_color_buffer_float) = glewGetExtension("GL_ARB_color_buffer_float"); if (glewExperimental || GLEW_ARB_color_buffer_float) CONST_CAST(GLEW_ARB_color_buffer_float) = !_glewInit_GL_ARB_color_buffer_float(GLEW_CONTEXT_ARG_VAR_INIT); @@ -6991,10 +7615,17 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) CONST_CAST(GLEW_ARB_draw_elements_base_vertex) = glewGetExtension("GL_ARB_draw_elements_base_vertex"); if (glewExperimental || GLEW_ARB_draw_elements_base_vertex) CONST_CAST(GLEW_ARB_draw_elements_base_vertex) = !_glewInit_GL_ARB_draw_elements_base_vertex(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_draw_elements_base_vertex */ +#ifdef GL_ARB_draw_indirect + CONST_CAST(GLEW_ARB_draw_indirect) = glewGetExtension("GL_ARB_draw_indirect"); + if (glewExperimental || GLEW_ARB_draw_indirect) CONST_CAST(GLEW_ARB_draw_indirect) = !_glewInit_GL_ARB_draw_indirect(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_ARB_draw_indirect */ #ifdef GL_ARB_draw_instanced CONST_CAST(GLEW_ARB_draw_instanced) = glewGetExtension("GL_ARB_draw_instanced"); if (glewExperimental || GLEW_ARB_draw_instanced) CONST_CAST(GLEW_ARB_draw_instanced) = !_glewInit_GL_ARB_draw_instanced(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_draw_instanced */ +#ifdef GL_ARB_explicit_attrib_location + CONST_CAST(GLEW_ARB_explicit_attrib_location) = glewGetExtension("GL_ARB_explicit_attrib_location"); +#endif /* GL_ARB_explicit_attrib_location */ #ifdef GL_ARB_fragment_coord_conventions CONST_CAST(GLEW_ARB_fragment_coord_conventions) = glewGetExtension("GL_ARB_fragment_coord_conventions"); #endif /* GL_ARB_fragment_coord_conventions */ @@ -7018,6 +7649,12 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) CONST_CAST(GLEW_ARB_geometry_shader4) = glewGetExtension("GL_ARB_geometry_shader4"); if (glewExperimental || GLEW_ARB_geometry_shader4) CONST_CAST(GLEW_ARB_geometry_shader4) = !_glewInit_GL_ARB_geometry_shader4(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_geometry_shader4 */ +#ifdef GL_ARB_gpu_shader5 + CONST_CAST(GLEW_ARB_gpu_shader5) = glewGetExtension("GL_ARB_gpu_shader5"); +#endif /* GL_ARB_gpu_shader5 */ +#ifdef GL_ARB_gpu_shader_fp64 + CONST_CAST(GLEW_ARB_gpu_shader_fp64) = glewGetExtension("GL_ARB_gpu_shader_fp64"); +#endif /* GL_ARB_gpu_shader_fp64 */ #ifdef GL_ARB_half_float_pixel CONST_CAST(GLEW_ARB_half_float_pixel) = glewGetExtension("GL_ARB_half_float_pixel"); #endif /* GL_ARB_half_float_pixel */ @@ -7052,6 +7689,9 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) CONST_CAST(GLEW_ARB_occlusion_query) = glewGetExtension("GL_ARB_occlusion_query"); if (glewExperimental || GLEW_ARB_occlusion_query) CONST_CAST(GLEW_ARB_occlusion_query) = !_glewInit_GL_ARB_occlusion_query(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_occlusion_query */ +#ifdef GL_ARB_occlusion_query2 + CONST_CAST(GLEW_ARB_occlusion_query2) = glewGetExtension("GL_ARB_occlusion_query2"); +#endif /* GL_ARB_occlusion_query2 */ #ifdef GL_ARB_pixel_buffer_object CONST_CAST(GLEW_ARB_pixel_buffer_object) = glewGetExtension("GL_ARB_pixel_buffer_object"); #endif /* GL_ARB_pixel_buffer_object */ @@ -7070,19 +7710,34 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) CONST_CAST(GLEW_ARB_sample_shading) = glewGetExtension("GL_ARB_sample_shading"); if (glewExperimental || GLEW_ARB_sample_shading) CONST_CAST(GLEW_ARB_sample_shading) = !_glewInit_GL_ARB_sample_shading(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_sample_shading */ +#ifdef GL_ARB_sampler_objects + CONST_CAST(GLEW_ARB_sampler_objects) = glewGetExtension("GL_ARB_sampler_objects"); + if (glewExperimental || GLEW_ARB_sampler_objects) CONST_CAST(GLEW_ARB_sampler_objects) = !_glewInit_GL_ARB_sampler_objects(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_ARB_sampler_objects */ #ifdef GL_ARB_seamless_cube_map CONST_CAST(GLEW_ARB_seamless_cube_map) = glewGetExtension("GL_ARB_seamless_cube_map"); #endif /* GL_ARB_seamless_cube_map */ +#ifdef GL_ARB_shader_bit_encoding + CONST_CAST(GLEW_ARB_shader_bit_encoding) = glewGetExtension("GL_ARB_shader_bit_encoding"); +#endif /* GL_ARB_shader_bit_encoding */ #ifdef GL_ARB_shader_objects CONST_CAST(GLEW_ARB_shader_objects) = glewGetExtension("GL_ARB_shader_objects"); if (glewExperimental || GLEW_ARB_shader_objects) CONST_CAST(GLEW_ARB_shader_objects) = !_glewInit_GL_ARB_shader_objects(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_shader_objects */ +#ifdef GL_ARB_shader_subroutine + CONST_CAST(GLEW_ARB_shader_subroutine) = glewGetExtension("GL_ARB_shader_subroutine"); + if (glewExperimental || GLEW_ARB_shader_subroutine) CONST_CAST(GLEW_ARB_shader_subroutine) = !_glewInit_GL_ARB_shader_subroutine(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_ARB_shader_subroutine */ #ifdef GL_ARB_shader_texture_lod CONST_CAST(GLEW_ARB_shader_texture_lod) = glewGetExtension("GL_ARB_shader_texture_lod"); #endif /* GL_ARB_shader_texture_lod */ #ifdef GL_ARB_shading_language_100 CONST_CAST(GLEW_ARB_shading_language_100) = glewGetExtension("GL_ARB_shading_language_100"); #endif /* GL_ARB_shading_language_100 */ +#ifdef GL_ARB_shading_language_include + CONST_CAST(GLEW_ARB_shading_language_include) = glewGetExtension("GL_ARB_shading_language_include"); + if (glewExperimental || GLEW_ARB_shading_language_include) CONST_CAST(GLEW_ARB_shading_language_include) = !_glewInit_GL_ARB_shading_language_include(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_ARB_shading_language_include */ #ifdef GL_ARB_shadow CONST_CAST(GLEW_ARB_shadow) = glewGetExtension("GL_ARB_shadow"); #endif /* GL_ARB_shadow */ @@ -7093,6 +7748,10 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) CONST_CAST(GLEW_ARB_sync) = glewGetExtension("GL_ARB_sync"); if (glewExperimental || GLEW_ARB_sync) CONST_CAST(GLEW_ARB_sync) = !_glewInit_GL_ARB_sync(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_sync */ +#ifdef GL_ARB_tessellation_shader + CONST_CAST(GLEW_ARB_tessellation_shader) = glewGetExtension("GL_ARB_tessellation_shader"); + if (glewExperimental || GLEW_ARB_tessellation_shader) CONST_CAST(GLEW_ARB_tessellation_shader) = !_glewInit_GL_ARB_tessellation_shader(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_ARB_tessellation_shader */ #ifdef GL_ARB_texture_border_clamp CONST_CAST(GLEW_ARB_texture_border_clamp) = glewGetExtension("GL_ARB_texture_border_clamp"); #endif /* GL_ARB_texture_border_clamp */ @@ -7100,10 +7759,16 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) CONST_CAST(GLEW_ARB_texture_buffer_object) = glewGetExtension("GL_ARB_texture_buffer_object"); if (glewExperimental || GLEW_ARB_texture_buffer_object) CONST_CAST(GLEW_ARB_texture_buffer_object) = !_glewInit_GL_ARB_texture_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_texture_buffer_object */ +#ifdef GL_ARB_texture_buffer_object_rgb32 + CONST_CAST(GLEW_ARB_texture_buffer_object_rgb32) = glewGetExtension("GL_ARB_texture_buffer_object_rgb32"); +#endif /* GL_ARB_texture_buffer_object_rgb32 */ #ifdef GL_ARB_texture_compression CONST_CAST(GLEW_ARB_texture_compression) = glewGetExtension("GL_ARB_texture_compression"); if (glewExperimental || GLEW_ARB_texture_compression) CONST_CAST(GLEW_ARB_texture_compression) = !_glewInit_GL_ARB_texture_compression(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_texture_compression */ +#ifdef GL_ARB_texture_compression_bptc + CONST_CAST(GLEW_ARB_texture_compression_bptc) = glewGetExtension("GL_ARB_texture_compression_bptc"); +#endif /* GL_ARB_texture_compression_bptc */ #ifdef GL_ARB_texture_compression_rgtc CONST_CAST(GLEW_ARB_texture_compression_rgtc) = glewGetExtension("GL_ARB_texture_compression_rgtc"); #endif /* GL_ARB_texture_compression_rgtc */ @@ -7150,6 +7815,24 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) #ifdef GL_ARB_texture_rg CONST_CAST(GLEW_ARB_texture_rg) = glewGetExtension("GL_ARB_texture_rg"); #endif /* GL_ARB_texture_rg */ +#ifdef GL_ARB_texture_rgb10_a2ui + CONST_CAST(GLEW_ARB_texture_rgb10_a2ui) = glewGetExtension("GL_ARB_texture_rgb10_a2ui"); +#endif /* GL_ARB_texture_rgb10_a2ui */ +#ifdef GL_ARB_texture_swizzle + CONST_CAST(GLEW_ARB_texture_swizzle) = glewGetExtension("GL_ARB_texture_swizzle"); +#endif /* GL_ARB_texture_swizzle */ +#ifdef GL_ARB_timer_query + CONST_CAST(GLEW_ARB_timer_query) = glewGetExtension("GL_ARB_timer_query"); + if (glewExperimental || GLEW_ARB_timer_query) CONST_CAST(GLEW_ARB_timer_query) = !_glewInit_GL_ARB_timer_query(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_ARB_timer_query */ +#ifdef GL_ARB_transform_feedback2 + CONST_CAST(GLEW_ARB_transform_feedback2) = glewGetExtension("GL_ARB_transform_feedback2"); + if (glewExperimental || GLEW_ARB_transform_feedback2) CONST_CAST(GLEW_ARB_transform_feedback2) = !_glewInit_GL_ARB_transform_feedback2(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_ARB_transform_feedback2 */ +#ifdef GL_ARB_transform_feedback3 + CONST_CAST(GLEW_ARB_transform_feedback3) = glewGetExtension("GL_ARB_transform_feedback3"); + if (glewExperimental || GLEW_ARB_transform_feedback3) CONST_CAST(GLEW_ARB_transform_feedback3) = !_glewInit_GL_ARB_transform_feedback3(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_ARB_transform_feedback3 */ #ifdef GL_ARB_transpose_matrix CONST_CAST(GLEW_ARB_transpose_matrix) = glewGetExtension("GL_ARB_transpose_matrix"); if (glewExperimental || GLEW_ARB_transpose_matrix) CONST_CAST(GLEW_ARB_transpose_matrix) = !_glewInit_GL_ARB_transpose_matrix(GLEW_CONTEXT_ARG_VAR_INIT); @@ -7181,6 +7864,10 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) CONST_CAST(GLEW_ARB_vertex_shader) = glewGetExtension("GL_ARB_vertex_shader"); if (glewExperimental || GLEW_ARB_vertex_shader) CONST_CAST(GLEW_ARB_vertex_shader) = !_glewInit_GL_ARB_vertex_shader(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_ARB_vertex_shader */ +#ifdef GL_ARB_vertex_type_2_10_10_10_rev + CONST_CAST(GLEW_ARB_vertex_type_2_10_10_10_rev) = glewGetExtension("GL_ARB_vertex_type_2_10_10_10_rev"); + if (glewExperimental || GLEW_ARB_vertex_type_2_10_10_10_rev) CONST_CAST(GLEW_ARB_vertex_type_2_10_10_10_rev) = !_glewInit_GL_ARB_vertex_type_2_10_10_10_rev(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ #ifdef GL_ARB_window_pos CONST_CAST(GLEW_ARB_window_pos) = glewGetExtension("GL_ARB_window_pos"); if (glewExperimental || GLEW_ARB_window_pos) CONST_CAST(GLEW_ARB_window_pos) = !_glewInit_GL_ARB_window_pos(GLEW_CONTEXT_ARG_VAR_INIT); @@ -7467,6 +8154,10 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) #ifdef GL_EXT_separate_specular_color CONST_CAST(GLEW_EXT_separate_specular_color) = glewGetExtension("GL_EXT_separate_specular_color"); #endif /* GL_EXT_separate_specular_color */ +#ifdef GL_EXT_shader_image_load_store + CONST_CAST(GLEW_EXT_shader_image_load_store) = glewGetExtension("GL_EXT_shader_image_load_store"); + if (glewExperimental || GLEW_EXT_shader_image_load_store) CONST_CAST(GLEW_EXT_shader_image_load_store) = !_glewInit_GL_EXT_shader_image_load_store(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_EXT_shader_image_load_store */ #ifdef GL_EXT_shadow_funcs CONST_CAST(GLEW_EXT_shadow_funcs) = glewGetExtension("GL_EXT_shadow_funcs"); #endif /* GL_EXT_shadow_funcs */ @@ -7582,6 +8273,10 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) #ifdef GL_EXT_vertex_array_bgra CONST_CAST(GLEW_EXT_vertex_array_bgra) = glewGetExtension("GL_EXT_vertex_array_bgra"); #endif /* GL_EXT_vertex_array_bgra */ +#ifdef GL_EXT_vertex_attrib_64bit + CONST_CAST(GLEW_EXT_vertex_attrib_64bit) = glewGetExtension("GL_EXT_vertex_attrib_64bit"); + if (glewExperimental || GLEW_EXT_vertex_attrib_64bit) CONST_CAST(GLEW_EXT_vertex_attrib_64bit) = !_glewInit_GL_EXT_vertex_attrib_64bit(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_EXT_vertex_attrib_64bit */ #ifdef GL_EXT_vertex_shader CONST_CAST(GLEW_EXT_vertex_shader) = glewGetExtension("GL_EXT_vertex_shader"); if (glewExperimental || GLEW_EXT_vertex_shader) CONST_CAST(GLEW_EXT_vertex_shader) = !_glewInit_GL_EXT_vertex_shader(GLEW_CONTEXT_ARG_VAR_INIT); @@ -7716,7 +8411,7 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) CONST_CAST(GLEW_NV_fragment_program2) = glewGetExtension("GL_NV_fragment_program2"); #endif /* GL_NV_fragment_program2 */ #ifdef GL_NV_fragment_program4 - CONST_CAST(GLEW_NV_fragment_program4) = glewGetExtension("GL_NV_fragment_program4"); + CONST_CAST(GLEW_NV_fragment_program4) = glewGetExtension("GL_NV_gpu_program4"); #endif /* GL_NV_fragment_program4 */ #ifdef GL_NV_fragment_program_option CONST_CAST(GLEW_NV_fragment_program_option) = glewGetExtension("GL_NV_fragment_program_option"); @@ -7726,7 +8421,7 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) if (glewExperimental || GLEW_NV_framebuffer_multisample_coverage) CONST_CAST(GLEW_NV_framebuffer_multisample_coverage) = !_glewInit_GL_NV_framebuffer_multisample_coverage(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_framebuffer_multisample_coverage */ #ifdef GL_NV_geometry_program4 - CONST_CAST(GLEW_NV_geometry_program4) = glewGetExtension("GL_NV_geometry_program4"); + CONST_CAST(GLEW_NV_geometry_program4) = glewGetExtension("GL_NV_gpu_program4"); if (glewExperimental || GLEW_NV_geometry_program4) CONST_CAST(GLEW_NV_geometry_program4) = !_glewInit_GL_NV_geometry_program4(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_geometry_program4 */ #ifdef GL_NV_geometry_shader4 @@ -7736,6 +8431,16 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) CONST_CAST(GLEW_NV_gpu_program4) = glewGetExtension("GL_NV_gpu_program4"); if (glewExperimental || GLEW_NV_gpu_program4) CONST_CAST(GLEW_NV_gpu_program4) = !_glewInit_GL_NV_gpu_program4(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_gpu_program4 */ +#ifdef GL_NV_gpu_program5 + CONST_CAST(GLEW_NV_gpu_program5) = glewGetExtension("GL_NV_gpu_program5"); +#endif /* GL_NV_gpu_program5 */ +#ifdef GL_NV_gpu_program_fp64 + CONST_CAST(GLEW_NV_gpu_program_fp64) = glewGetExtension("GL_NV_gpu_program_fp64"); +#endif /* GL_NV_gpu_program_fp64 */ +#ifdef GL_NV_gpu_shader5 + CONST_CAST(GLEW_NV_gpu_shader5) = glewGetExtension("GL_NV_gpu_shader5"); + if (glewExperimental || GLEW_NV_gpu_shader5) CONST_CAST(GLEW_NV_gpu_shader5) = !_glewInit_GL_NV_gpu_shader5(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_NV_gpu_shader5 */ #ifdef GL_NV_half_float CONST_CAST(GLEW_NV_half_float) = glewGetExtension("GL_NV_half_float"); if (glewExperimental || GLEW_NV_half_float) CONST_CAST(GLEW_NV_half_float) = !_glewInit_GL_NV_half_float(GLEW_CONTEXT_ARG_VAR_INIT); @@ -7788,6 +8493,9 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) CONST_CAST(GLEW_NV_shader_buffer_load) = glewGetExtension("GL_NV_shader_buffer_load"); if (glewExperimental || GLEW_NV_shader_buffer_load) CONST_CAST(GLEW_NV_shader_buffer_load) = !_glewInit_GL_NV_shader_buffer_load(GLEW_CONTEXT_ARG_VAR_INIT); #endif /* GL_NV_shader_buffer_load */ +#ifdef GL_NV_tessellation_program5 + CONST_CAST(GLEW_NV_tessellation_program5) = glewGetExtension("GL_NV_gpu_program5"); +#endif /* GL_NV_tessellation_program5 */ #ifdef GL_NV_texgen_emboss CONST_CAST(GLEW_NV_texgen_emboss) = glewGetExtension("GL_NV_texgen_emboss"); #endif /* GL_NV_texgen_emboss */ @@ -7834,6 +8542,10 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) #ifdef GL_NV_vertex_array_range2 CONST_CAST(GLEW_NV_vertex_array_range2) = glewGetExtension("GL_NV_vertex_array_range2"); #endif /* GL_NV_vertex_array_range2 */ +#ifdef GL_NV_vertex_attrib_integer_64bit + CONST_CAST(GLEW_NV_vertex_attrib_integer_64bit) = glewGetExtension("GL_NV_vertex_attrib_integer_64bit"); + if (glewExperimental || GLEW_NV_vertex_attrib_integer_64bit) CONST_CAST(GLEW_NV_vertex_attrib_integer_64bit) = !_glewInit_GL_NV_vertex_attrib_integer_64bit(GLEW_CONTEXT_ARG_VAR_INIT); +#endif /* GL_NV_vertex_attrib_integer_64bit */ #ifdef GL_NV_vertex_buffer_unified_memory CONST_CAST(GLEW_NV_vertex_buffer_unified_memory) = glewGetExtension("GL_NV_vertex_buffer_unified_memory"); if (glewExperimental || GLEW_NV_vertex_buffer_unified_memory) CONST_CAST(GLEW_NV_vertex_buffer_unified_memory) = !_glewInit_GL_NV_vertex_buffer_unified_memory(GLEW_CONTEXT_ARG_VAR_INIT); @@ -7855,7 +8567,7 @@ GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) CONST_CAST(GLEW_NV_vertex_program3) = glewGetExtension("GL_NV_vertex_program3"); #endif /* GL_NV_vertex_program3 */ #ifdef GL_NV_vertex_program4 - CONST_CAST(GLEW_NV_vertex_program4) = glewGetExtension("GL_NV_vertex_program4"); + CONST_CAST(GLEW_NV_vertex_program4) = glewGetExtension("GL_NV_gpu_program4"); #endif /* GL_NV_vertex_program4 */ #ifdef GL_OES_byte_coordinates CONST_CAST(GLEW_OES_byte_coordinates) = glewGetExtension("GL_OES_byte_coordinates"); @@ -9110,6 +9822,7 @@ GLboolean __GLXEW_ARB_fbconfig_float = GL_FALSE; GLboolean __GLXEW_ARB_framebuffer_sRGB = GL_FALSE; GLboolean __GLXEW_ARB_get_proc_address = GL_FALSE; GLboolean __GLXEW_ARB_multisample = GL_FALSE; +GLboolean __GLXEW_ARB_vertex_buffer_object = GL_FALSE; GLboolean __GLXEW_ATI_pixel_format_float = GL_FALSE; GLboolean __GLXEW_ATI_render_texture = GL_FALSE; GLboolean __GLXEW_EXT_fbconfig_packed_float = GL_FALSE; @@ -9120,6 +9833,7 @@ GLboolean __GLXEW_EXT_swap_control = GL_FALSE; GLboolean __GLXEW_EXT_texture_from_pixmap = GL_FALSE; GLboolean __GLXEW_EXT_visual_info = GL_FALSE; GLboolean __GLXEW_EXT_visual_rating = GL_FALSE; +GLboolean __GLXEW_INTEL_swap_event = GL_FALSE; GLboolean __GLXEW_MESA_agp_offset = GL_FALSE; GLboolean __GLXEW_MESA_copy_sub_buffer = GL_FALSE; GLboolean __GLXEW_MESA_pixmap_colormap = GL_FALSE; @@ -9238,6 +9952,10 @@ static GLboolean _glewInit_GLX_ARB_create_context (GLXEW_CONTEXT_ARG_DEF_INIT) #endif /* GLX_ARB_multisample */ +#ifdef GLX_ARB_vertex_buffer_object + +#endif /* GLX_ARB_vertex_buffer_object */ + #ifdef GLX_ATI_pixel_format_float #endif /* GLX_ATI_pixel_format_float */ @@ -9320,6 +10038,10 @@ static GLboolean _glewInit_GLX_EXT_texture_from_pixmap (GLXEW_CONTEXT_ARG_DEF_IN #endif /* GLX_EXT_visual_rating */ +#ifdef GLX_INTEL_swap_event + +#endif /* GLX_INTEL_swap_event */ + #ifdef GLX_MESA_agp_offset static GLboolean _glewInit_GLX_MESA_agp_offset (GLXEW_CONTEXT_ARG_DEF_INIT) @@ -9765,6 +10487,9 @@ GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST) #ifdef GLX_ARB_multisample CONST_CAST(GLXEW_ARB_multisample) = glxewGetExtension("GLX_ARB_multisample"); #endif /* GLX_ARB_multisample */ +#ifdef GLX_ARB_vertex_buffer_object + CONST_CAST(GLXEW_ARB_vertex_buffer_object) = glxewGetExtension("GLX_ARB_vertex_buffer_object"); +#endif /* GLX_ARB_vertex_buffer_object */ #ifdef GLX_ATI_pixel_format_float CONST_CAST(GLXEW_ATI_pixel_format_float) = glxewGetExtension("GLX_ATI_pixel_format_float"); #endif /* GLX_ATI_pixel_format_float */ @@ -9799,6 +10524,9 @@ GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST) #ifdef GLX_EXT_visual_rating CONST_CAST(GLXEW_EXT_visual_rating) = glxewGetExtension("GLX_EXT_visual_rating"); #endif /* GLX_EXT_visual_rating */ +#ifdef GLX_INTEL_swap_event + CONST_CAST(GLXEW_INTEL_swap_event) = glxewGetExtension("GLX_INTEL_swap_event"); +#endif /* GLX_INTEL_swap_event */ #ifdef GLX_MESA_agp_offset CONST_CAST(GLXEW_MESA_agp_offset) = glxewGetExtension("GLX_MESA_agp_offset"); if (glewExperimental || GLXEW_MESA_agp_offset) CONST_CAST(GLXEW_MESA_agp_offset) = !_glewInit_GLX_MESA_agp_offset(GLEW_CONTEXT_ARG_VAR_INIT); @@ -9940,10 +10668,10 @@ const GLubyte* glewGetString (GLenum name) static const GLubyte* _glewString[] = { (const GLubyte*)NULL, - (const GLubyte*)"1.5.2", + (const GLubyte*)"1.5.4", (const GLubyte*)"1", (const GLubyte*)"5", - (const GLubyte*)"2" + (const GLubyte*)"4" }; const int max_string = sizeof(_glewString)/sizeof(*_glewString) - 1; return _glewString[(int)name > max_string ? 0 : (int)name]; @@ -10053,6 +10781,20 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_VERSION_3_3 + if (_glewStrSame3(&pos, &len, (const GLubyte*)"3_3", 3)) + { + ret = GLEW_VERSION_3_3; + continue; + } +#endif +#ifdef GL_VERSION_4_0 + if (_glewStrSame3(&pos, &len, (const GLubyte*)"4_0", 3)) + { + ret = GLEW_VERSION_4_0; + continue; + } +#endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"3DFX_", 5)) { @@ -10080,6 +10822,13 @@ GLboolean glewIsSupported (const char* name) } if (_glewStrSame2(&pos, &len, (const GLubyte*)"AMD_", 4)) { +#ifdef GL_AMD_conservative_depth + if (_glewStrSame3(&pos, &len, (const GLubyte*)"conservative_depth", 18)) + { + ret = GLEW_AMD_conservative_depth; + continue; + } +#endif #ifdef GL_AMD_draw_buffers_blend if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_buffers_blend", 18)) { @@ -10094,6 +10843,20 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_AMD_seamless_cubemap_per_texture + if (_glewStrSame3(&pos, &len, (const GLubyte*)"seamless_cubemap_per_texture", 28)) + { + ret = GLEW_AMD_seamless_cubemap_per_texture; + continue; + } +#endif +#ifdef GL_AMD_shader_stencil_export + if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_stencil_export", 21)) + { + ret = GLEW_AMD_shader_stencil_export; + continue; + } +#endif #ifdef GL_AMD_texture_texture4 if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_texture4", 16)) { @@ -10233,6 +10996,13 @@ GLboolean glewIsSupported (const char* name) } if (_glewStrSame2(&pos, &len, (const GLubyte*)"ARB_", 4)) { +#ifdef GL_ARB_blend_func_extended + if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_func_extended", 19)) + { + ret = GLEW_ARB_blend_func_extended; + continue; + } +#endif #ifdef GL_ARB_color_buffer_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_buffer_float", 18)) { @@ -10296,6 +11066,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_ARB_draw_indirect + if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_indirect", 13)) + { + ret = GLEW_ARB_draw_indirect; + continue; + } +#endif #ifdef GL_ARB_draw_instanced if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_instanced", 14)) { @@ -10303,6 +11080,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_ARB_explicit_attrib_location + if (_glewStrSame3(&pos, &len, (const GLubyte*)"explicit_attrib_location", 24)) + { + ret = GLEW_ARB_explicit_attrib_location; + continue; + } +#endif #ifdef GL_ARB_fragment_coord_conventions if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_coord_conventions", 26)) { @@ -10352,6 +11136,20 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_ARB_gpu_shader5 + if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_shader5", 11)) + { + ret = GLEW_ARB_gpu_shader5; + continue; + } +#endif +#ifdef GL_ARB_gpu_shader_fp64 + if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_shader_fp64", 15)) + { + ret = GLEW_ARB_gpu_shader_fp64; + continue; + } +#endif #ifdef GL_ARB_half_float_pixel if (_glewStrSame3(&pos, &len, (const GLubyte*)"half_float_pixel", 16)) { @@ -10415,6 +11213,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_ARB_occlusion_query2 + if (_glewStrSame3(&pos, &len, (const GLubyte*)"occlusion_query2", 16)) + { + ret = GLEW_ARB_occlusion_query2; + continue; + } +#endif #ifdef GL_ARB_pixel_buffer_object if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_buffer_object", 19)) { @@ -10450,6 +11255,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_ARB_sampler_objects + if (_glewStrSame3(&pos, &len, (const GLubyte*)"sampler_objects", 15)) + { + ret = GLEW_ARB_sampler_objects; + continue; + } +#endif #ifdef GL_ARB_seamless_cube_map if (_glewStrSame3(&pos, &len, (const GLubyte*)"seamless_cube_map", 17)) { @@ -10457,6 +11269,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_ARB_shader_bit_encoding + if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_bit_encoding", 19)) + { + ret = GLEW_ARB_shader_bit_encoding; + continue; + } +#endif #ifdef GL_ARB_shader_objects if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_objects", 14)) { @@ -10464,6 +11283,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_ARB_shader_subroutine + if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_subroutine", 17)) + { + ret = GLEW_ARB_shader_subroutine; + continue; + } +#endif #ifdef GL_ARB_shader_texture_lod if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_texture_lod", 18)) { @@ -10478,6 +11304,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_ARB_shading_language_include + if (_glewStrSame3(&pos, &len, (const GLubyte*)"shading_language_include", 24)) + { + ret = GLEW_ARB_shading_language_include; + continue; + } +#endif #ifdef GL_ARB_shadow if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow", 6)) { @@ -10499,6 +11332,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_ARB_tessellation_shader + if (_glewStrSame3(&pos, &len, (const GLubyte*)"tessellation_shader", 19)) + { + ret = GLEW_ARB_tessellation_shader; + continue; + } +#endif #ifdef GL_ARB_texture_border_clamp if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_border_clamp", 20)) { @@ -10513,6 +11353,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_ARB_texture_buffer_object_rgb32 + if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_buffer_object_rgb32", 27)) + { + ret = GLEW_ARB_texture_buffer_object_rgb32; + continue; + } +#endif #ifdef GL_ARB_texture_compression if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression", 19)) { @@ -10520,6 +11367,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_ARB_texture_compression_bptc + if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_bptc", 24)) + { + ret = GLEW_ARB_texture_compression_bptc; + continue; + } +#endif #ifdef GL_ARB_texture_compression_rgtc if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_rgtc", 24)) { @@ -10625,6 +11479,41 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_ARB_texture_rgb10_a2ui + if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rgb10_a2ui", 18)) + { + ret = GLEW_ARB_texture_rgb10_a2ui; + continue; + } +#endif +#ifdef GL_ARB_texture_swizzle + if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_swizzle", 15)) + { + ret = GLEW_ARB_texture_swizzle; + continue; + } +#endif +#ifdef GL_ARB_timer_query + if (_glewStrSame3(&pos, &len, (const GLubyte*)"timer_query", 11)) + { + ret = GLEW_ARB_timer_query; + continue; + } +#endif +#ifdef GL_ARB_transform_feedback2 + if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback2", 19)) + { + ret = GLEW_ARB_transform_feedback2; + continue; + } +#endif +#ifdef GL_ARB_transform_feedback3 + if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback3", 19)) + { + ret = GLEW_ARB_transform_feedback3; + continue; + } +#endif #ifdef GL_ARB_transpose_matrix if (_glewStrSame3(&pos, &len, (const GLubyte*)"transpose_matrix", 16)) { @@ -10681,6 +11570,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_ARB_vertex_type_2_10_10_10_rev + if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_type_2_10_10_10_rev", 26)) + { + ret = GLEW_ARB_vertex_type_2_10_10_10_rev; + continue; + } +#endif #ifdef GL_ARB_window_pos if (_glewStrSame3(&pos, &len, (const GLubyte*)"window_pos", 10)) { @@ -11243,6 +12139,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_EXT_shader_image_load_store + if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_image_load_store", 23)) + { + ret = GLEW_EXT_shader_image_load_store; + continue; + } +#endif #ifdef GL_EXT_shadow_funcs if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow_funcs", 12)) { @@ -11488,6 +12391,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_EXT_vertex_attrib_64bit + if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_attrib_64bit", 19)) + { + ret = GLEW_EXT_vertex_attrib_64bit; + continue; + } +#endif #ifdef GL_EXT_vertex_shader if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_shader", 13)) { @@ -11823,6 +12733,27 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_NV_gpu_program5 + if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_program5", 12)) + { + ret = GLEW_NV_gpu_program5; + continue; + } +#endif +#ifdef GL_NV_gpu_program_fp64 + if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_program_fp64", 16)) + { + ret = GLEW_NV_gpu_program_fp64; + continue; + } +#endif +#ifdef GL_NV_gpu_shader5 + if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_shader5", 11)) + { + ret = GLEW_NV_gpu_shader5; + continue; + } +#endif #ifdef GL_NV_half_float if (_glewStrSame3(&pos, &len, (const GLubyte*)"half_float", 10)) { @@ -11921,6 +12852,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_NV_tessellation_program5 + if (_glewStrSame3(&pos, &len, (const GLubyte*)"tessellation_program5", 21)) + { + ret = GLEW_NV_tessellation_program5; + continue; + } +#endif #ifdef GL_NV_texgen_emboss if (_glewStrSame3(&pos, &len, (const GLubyte*)"texgen_emboss", 13)) { @@ -12019,6 +12957,13 @@ GLboolean glewIsSupported (const char* name) continue; } #endif +#ifdef GL_NV_vertex_attrib_integer_64bit + if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_attrib_integer_64bit", 27)) + { + ret = GLEW_NV_vertex_attrib_integer_64bit; + continue; + } +#endif #ifdef GL_NV_vertex_buffer_unified_memory if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_buffer_unified_memory", 28)) { @@ -13040,6 +13985,13 @@ GLboolean glxewIsSupported (const char* name) continue; } #endif +#ifdef GLX_ARB_vertex_buffer_object + if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_buffer_object", 20)) + { + ret = GLXEW_ARB_vertex_buffer_object; + continue; + } +#endif } if (_glewStrSame2(&pos, &len, (const GLubyte*)"ATI_", 4)) { @@ -13117,6 +14069,16 @@ GLboolean glxewIsSupported (const char* name) } #endif } + if (_glewStrSame2(&pos, &len, (const GLubyte*)"INTEL_", 6)) + { +#ifdef GLX_INTEL_swap_event + if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_event", 10)) + { + ret = GLXEW_INTEL_swap_event; + continue; + } +#endif + } if (_glewStrSame2(&pos, &len, (const GLubyte*)"MESA_", 5)) { #ifdef GLX_MESA_agp_offset diff --git a/src/glew/glewinfo.c b/src/glew/glewinfo.c index 6847cbb8652..abfe1fa2999 100644 --- a/src/glew/glewinfo.c +++ b/src/glew/glewinfo.c @@ -473,6 +473,30 @@ static void _glewInfo_GL_VERSION_3_2 (void) #endif /* GL_VERSION_3_2 */ +#ifdef GL_VERSION_3_3 + +static void _glewInfo_GL_VERSION_3_3 (void) +{ + glewPrintExt("GL_VERSION_3_3", GLEW_VERSION_3_3, GLEW_VERSION_3_3, GLEW_VERSION_3_3); +} + +#endif /* GL_VERSION_3_3 */ + +#ifdef GL_VERSION_4_0 + +static void _glewInfo_GL_VERSION_4_0 (void) +{ + glewPrintExt("GL_VERSION_4_0", GLEW_VERSION_4_0, GLEW_VERSION_4_0, GLEW_VERSION_4_0); + + glewInfoFunc("glBlendEquationSeparatei", glBlendEquationSeparatei == NULL); + glewInfoFunc("glBlendEquationi", glBlendEquationi == NULL); + glewInfoFunc("glBlendFuncSeparatei", glBlendFuncSeparatei == NULL); + glewInfoFunc("glBlendFunci", glBlendFunci == NULL); + glewInfoFunc("glMinSampleShading", glMinSampleShading == NULL); +} + +#endif /* GL_VERSION_4_0 */ + #ifdef GL_3DFX_multisample static void _glewInfo_GL_3DFX_multisample (void) @@ -502,6 +526,15 @@ static void _glewInfo_GL_3DFX_texture_compression_FXT1 (void) #endif /* GL_3DFX_texture_compression_FXT1 */ +#ifdef GL_AMD_conservative_depth + +static void _glewInfo_GL_AMD_conservative_depth (void) +{ + glewPrintExt("GL_AMD_conservative_depth", GLEW_AMD_conservative_depth, glewIsSupported("GL_AMD_conservative_depth"), glewGetExtension("GL_AMD_conservative_depth")); +} + +#endif /* GL_AMD_conservative_depth */ + #ifdef GL_AMD_draw_buffers_blend static void _glewInfo_GL_AMD_draw_buffers_blend (void) @@ -537,6 +570,24 @@ static void _glewInfo_GL_AMD_performance_monitor (void) #endif /* GL_AMD_performance_monitor */ +#ifdef GL_AMD_seamless_cubemap_per_texture + +static void _glewInfo_GL_AMD_seamless_cubemap_per_texture (void) +{ + glewPrintExt("GL_AMD_seamless_cubemap_per_texture", GLEW_AMD_seamless_cubemap_per_texture, glewIsSupported("GL_AMD_seamless_cubemap_per_texture"), glewGetExtension("GL_AMD_seamless_cubemap_per_texture")); +} + +#endif /* GL_AMD_seamless_cubemap_per_texture */ + +#ifdef GL_AMD_shader_stencil_export + +static void _glewInfo_GL_AMD_shader_stencil_export (void) +{ + glewPrintExt("GL_AMD_shader_stencil_export", GLEW_AMD_shader_stencil_export, glewIsSupported("GL_AMD_shader_stencil_export"), glewGetExtension("GL_AMD_shader_stencil_export")); +} + +#endif /* GL_AMD_shader_stencil_export */ + #ifdef GL_AMD_texture_texture4 static void _glewInfo_GL_AMD_texture_texture4 (void) @@ -753,6 +804,18 @@ static void _glewInfo_GL_APPLE_ycbcr_422 (void) #endif /* GL_APPLE_ycbcr_422 */ +#ifdef GL_ARB_blend_func_extended + +static void _glewInfo_GL_ARB_blend_func_extended (void) +{ + glewPrintExt("GL_ARB_blend_func_extended", GLEW_ARB_blend_func_extended, glewIsSupported("GL_ARB_blend_func_extended"), glewGetExtension("GL_ARB_blend_func_extended")); + + glewInfoFunc("glBindFragDataLocationIndexed", glBindFragDataLocationIndexed == NULL); + glewInfoFunc("glGetFragDataIndex", glGetFragDataIndex == NULL); +} + +#endif /* GL_ARB_blend_func_extended */ + #ifdef GL_ARB_color_buffer_float static void _glewInfo_GL_ARB_color_buffer_float (void) @@ -850,6 +913,18 @@ static void _glewInfo_GL_ARB_draw_elements_base_vertex (void) #endif /* GL_ARB_draw_elements_base_vertex */ +#ifdef GL_ARB_draw_indirect + +static void _glewInfo_GL_ARB_draw_indirect (void) +{ + glewPrintExt("GL_ARB_draw_indirect", GLEW_ARB_draw_indirect, glewIsSupported("GL_ARB_draw_indirect"), glewGetExtension("GL_ARB_draw_indirect")); + + glewInfoFunc("glDrawArraysIndirect", glDrawArraysIndirect == NULL); + glewInfoFunc("glDrawElementsIndirect", glDrawElementsIndirect == NULL); +} + +#endif /* GL_ARB_draw_indirect */ + #ifdef GL_ARB_draw_instanced static void _glewInfo_GL_ARB_draw_instanced (void) @@ -862,6 +937,15 @@ static void _glewInfo_GL_ARB_draw_instanced (void) #endif /* GL_ARB_draw_instanced */ +#ifdef GL_ARB_explicit_attrib_location + +static void _glewInfo_GL_ARB_explicit_attrib_location (void) +{ + glewPrintExt("GL_ARB_explicit_attrib_location", GLEW_ARB_explicit_attrib_location, glewIsSupported("GL_ARB_explicit_attrib_location"), glewGetExtension("GL_ARB_explicit_attrib_location")); +} + +#endif /* GL_ARB_explicit_attrib_location */ + #ifdef GL_ARB_fragment_coord_conventions static void _glewInfo_GL_ARB_fragment_coord_conventions (void) @@ -951,6 +1035,24 @@ static void _glewInfo_GL_ARB_geometry_shader4 (void) #endif /* GL_ARB_geometry_shader4 */ +#ifdef GL_ARB_gpu_shader5 + +static void _glewInfo_GL_ARB_gpu_shader5 (void) +{ + glewPrintExt("GL_ARB_gpu_shader5", GLEW_ARB_gpu_shader5, glewIsSupported("GL_ARB_gpu_shader5"), glewGetExtension("GL_ARB_gpu_shader5")); +} + +#endif /* GL_ARB_gpu_shader5 */ + +#ifdef GL_ARB_gpu_shader_fp64 + +static void _glewInfo_GL_ARB_gpu_shader_fp64 (void) +{ + glewPrintExt("GL_ARB_gpu_shader_fp64", GLEW_ARB_gpu_shader_fp64, glewIsSupported("GL_ARB_gpu_shader_fp64"), glewGetExtension("GL_ARB_gpu_shader_fp64")); +} + +#endif /* GL_ARB_gpu_shader_fp64 */ + #ifdef GL_ARB_half_float_pixel static void _glewInfo_GL_ARB_half_float_pixel (void) @@ -1123,6 +1225,15 @@ static void _glewInfo_GL_ARB_occlusion_query (void) #endif /* GL_ARB_occlusion_query */ +#ifdef GL_ARB_occlusion_query2 + +static void _glewInfo_GL_ARB_occlusion_query2 (void) +{ + glewPrintExt("GL_ARB_occlusion_query2", GLEW_ARB_occlusion_query2, glewIsSupported("GL_ARB_occlusion_query2"), glewGetExtension("GL_ARB_occlusion_query2")); +} + +#endif /* GL_ARB_occlusion_query2 */ + #ifdef GL_ARB_pixel_buffer_object static void _glewInfo_GL_ARB_pixel_buffer_object (void) @@ -1175,6 +1286,30 @@ static void _glewInfo_GL_ARB_sample_shading (void) #endif /* GL_ARB_sample_shading */ +#ifdef GL_ARB_sampler_objects + +static void _glewInfo_GL_ARB_sampler_objects (void) +{ + glewPrintExt("GL_ARB_sampler_objects", GLEW_ARB_sampler_objects, glewIsSupported("GL_ARB_sampler_objects"), glewGetExtension("GL_ARB_sampler_objects")); + + glewInfoFunc("glBindSampler", glBindSampler == NULL); + glewInfoFunc("glDeleteSamplers", glDeleteSamplers == NULL); + glewInfoFunc("glGenSamplers", glGenSamplers == NULL); + glewInfoFunc("glGetSamplerParameterIiv", glGetSamplerParameterIiv == NULL); + glewInfoFunc("glGetSamplerParameterIuiv", glGetSamplerParameterIuiv == NULL); + glewInfoFunc("glGetSamplerParameterfv", glGetSamplerParameterfv == NULL); + glewInfoFunc("glGetSamplerParameteriv", glGetSamplerParameteriv == NULL); + glewInfoFunc("glIsSampler", glIsSampler == NULL); + glewInfoFunc("glSamplerParameterIiv", glSamplerParameterIiv == NULL); + glewInfoFunc("glSamplerParameterIuiv", glSamplerParameterIuiv == NULL); + glewInfoFunc("glSamplerParameterf", glSamplerParameterf == NULL); + glewInfoFunc("glSamplerParameterfv", glSamplerParameterfv == NULL); + glewInfoFunc("glSamplerParameteri", glSamplerParameteri == NULL); + glewInfoFunc("glSamplerParameteriv", glSamplerParameteriv == NULL); +} + +#endif /* GL_ARB_sampler_objects */ + #ifdef GL_ARB_seamless_cube_map static void _glewInfo_GL_ARB_seamless_cube_map (void) @@ -1184,6 +1319,15 @@ static void _glewInfo_GL_ARB_seamless_cube_map (void) #endif /* GL_ARB_seamless_cube_map */ +#ifdef GL_ARB_shader_bit_encoding + +static void _glewInfo_GL_ARB_shader_bit_encoding (void) +{ + glewPrintExt("GL_ARB_shader_bit_encoding", GLEW_ARB_shader_bit_encoding, glewIsSupported("GL_ARB_shader_bit_encoding"), glewGetExtension("GL_ARB_shader_bit_encoding")); +} + +#endif /* GL_ARB_shader_bit_encoding */ + #ifdef GL_ARB_shader_objects static void _glewInfo_GL_ARB_shader_objects (void) @@ -1233,6 +1377,24 @@ static void _glewInfo_GL_ARB_shader_objects (void) #endif /* GL_ARB_shader_objects */ +#ifdef GL_ARB_shader_subroutine + +static void _glewInfo_GL_ARB_shader_subroutine (void) +{ + glewPrintExt("GL_ARB_shader_subroutine", GLEW_ARB_shader_subroutine, glewIsSupported("GL_ARB_shader_subroutine"), glewGetExtension("GL_ARB_shader_subroutine")); + + glewInfoFunc("glGetActiveSubroutineName", glGetActiveSubroutineName == NULL); + glewInfoFunc("glGetActiveSubroutineUniformName", glGetActiveSubroutineUniformName == NULL); + glewInfoFunc("glGetActiveSubroutineUniformiv", glGetActiveSubroutineUniformiv == NULL); + glewInfoFunc("glGetProgramStageiv", glGetProgramStageiv == NULL); + glewInfoFunc("glGetSubroutineIndex", glGetSubroutineIndex == NULL); + glewInfoFunc("glGetSubroutineUniformLocation", glGetSubroutineUniformLocation == NULL); + glewInfoFunc("glGetUniformSubroutineuiv", glGetUniformSubroutineuiv == NULL); + glewInfoFunc("glUniformSubroutinesuiv", glUniformSubroutinesuiv == NULL); +} + +#endif /* GL_ARB_shader_subroutine */ + #ifdef GL_ARB_shader_texture_lod static void _glewInfo_GL_ARB_shader_texture_lod (void) @@ -1251,6 +1413,22 @@ static void _glewInfo_GL_ARB_shading_language_100 (void) #endif /* GL_ARB_shading_language_100 */ +#ifdef GL_ARB_shading_language_include + +static void _glewInfo_GL_ARB_shading_language_include (void) +{ + glewPrintExt("GL_ARB_shading_language_include", GLEW_ARB_shading_language_include, glewIsSupported("GL_ARB_shading_language_include"), glewGetExtension("GL_ARB_shading_language_include")); + + glewInfoFunc("glCompileShaderIncludeARB", glCompileShaderIncludeARB == NULL); + glewInfoFunc("glDeleteNamedStringARB", glDeleteNamedStringARB == NULL); + glewInfoFunc("glGetNamedStringARB", glGetNamedStringARB == NULL); + glewInfoFunc("glGetNamedStringivARB", glGetNamedStringivARB == NULL); + glewInfoFunc("glIsNamedStringARB", glIsNamedStringARB == NULL); + glewInfoFunc("glNamedStringARB", glNamedStringARB == NULL); +} + +#endif /* GL_ARB_shading_language_include */ + #ifdef GL_ARB_shadow static void _glewInfo_GL_ARB_shadow (void) @@ -1286,6 +1464,18 @@ static void _glewInfo_GL_ARB_sync (void) #endif /* GL_ARB_sync */ +#ifdef GL_ARB_tessellation_shader + +static void _glewInfo_GL_ARB_tessellation_shader (void) +{ + glewPrintExt("GL_ARB_tessellation_shader", GLEW_ARB_tessellation_shader, glewIsSupported("GL_ARB_tessellation_shader"), glewGetExtension("GL_ARB_tessellation_shader")); + + glewInfoFunc("glPatchParameterfv", glPatchParameterfv == NULL); + glewInfoFunc("glPatchParameteri", glPatchParameteri == NULL); +} + +#endif /* GL_ARB_tessellation_shader */ + #ifdef GL_ARB_texture_border_clamp static void _glewInfo_GL_ARB_texture_border_clamp (void) @@ -1306,6 +1496,15 @@ static void _glewInfo_GL_ARB_texture_buffer_object (void) #endif /* GL_ARB_texture_buffer_object */ +#ifdef GL_ARB_texture_buffer_object_rgb32 + +static void _glewInfo_GL_ARB_texture_buffer_object_rgb32 (void) +{ + glewPrintExt("GL_ARB_texture_buffer_object_rgb32", GLEW_ARB_texture_buffer_object_rgb32, glewIsSupported("GL_ARB_texture_buffer_object_rgb32"), glewGetExtension("GL_ARB_texture_buffer_object_rgb32")); +} + +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + #ifdef GL_ARB_texture_compression static void _glewInfo_GL_ARB_texture_compression (void) @@ -1323,6 +1522,15 @@ static void _glewInfo_GL_ARB_texture_compression (void) #endif /* GL_ARB_texture_compression */ +#ifdef GL_ARB_texture_compression_bptc + +static void _glewInfo_GL_ARB_texture_compression_bptc (void) +{ + glewPrintExt("GL_ARB_texture_compression_bptc", GLEW_ARB_texture_compression_bptc, glewIsSupported("GL_ARB_texture_compression_bptc"), glewGetExtension("GL_ARB_texture_compression_bptc")); +} + +#endif /* GL_ARB_texture_compression_bptc */ + #ifdef GL_ARB_texture_compression_rgtc static void _glewInfo_GL_ARB_texture_compression_rgtc (void) @@ -1463,6 +1671,68 @@ static void _glewInfo_GL_ARB_texture_rg (void) #endif /* GL_ARB_texture_rg */ +#ifdef GL_ARB_texture_rgb10_a2ui + +static void _glewInfo_GL_ARB_texture_rgb10_a2ui (void) +{ + glewPrintExt("GL_ARB_texture_rgb10_a2ui", GLEW_ARB_texture_rgb10_a2ui, glewIsSupported("GL_ARB_texture_rgb10_a2ui"), glewGetExtension("GL_ARB_texture_rgb10_a2ui")); +} + +#endif /* GL_ARB_texture_rgb10_a2ui */ + +#ifdef GL_ARB_texture_swizzle + +static void _glewInfo_GL_ARB_texture_swizzle (void) +{ + glewPrintExt("GL_ARB_texture_swizzle", GLEW_ARB_texture_swizzle, glewIsSupported("GL_ARB_texture_swizzle"), glewGetExtension("GL_ARB_texture_swizzle")); +} + +#endif /* GL_ARB_texture_swizzle */ + +#ifdef GL_ARB_timer_query + +static void _glewInfo_GL_ARB_timer_query (void) +{ + glewPrintExt("GL_ARB_timer_query", GLEW_ARB_timer_query, glewIsSupported("GL_ARB_timer_query"), glewGetExtension("GL_ARB_timer_query")); + + glewInfoFunc("glGetQueryObjecti64v", glGetQueryObjecti64v == NULL); + glewInfoFunc("glGetQueryObjectui64v", glGetQueryObjectui64v == NULL); + glewInfoFunc("glQueryCounter", glQueryCounter == NULL); +} + +#endif /* GL_ARB_timer_query */ + +#ifdef GL_ARB_transform_feedback2 + +static void _glewInfo_GL_ARB_transform_feedback2 (void) +{ + glewPrintExt("GL_ARB_transform_feedback2", GLEW_ARB_transform_feedback2, glewIsSupported("GL_ARB_transform_feedback2"), glewGetExtension("GL_ARB_transform_feedback2")); + + glewInfoFunc("glBindTransformFeedback", glBindTransformFeedback == NULL); + glewInfoFunc("glDeleteTransformFeedbacks", glDeleteTransformFeedbacks == NULL); + glewInfoFunc("glDrawTransformFeedback", glDrawTransformFeedback == NULL); + glewInfoFunc("glGenTransformFeedbacks", glGenTransformFeedbacks == NULL); + glewInfoFunc("glIsTransformFeedback", glIsTransformFeedback == NULL); + glewInfoFunc("glPauseTransformFeedback", glPauseTransformFeedback == NULL); + glewInfoFunc("glResumeTransformFeedback", glResumeTransformFeedback == NULL); +} + +#endif /* GL_ARB_transform_feedback2 */ + +#ifdef GL_ARB_transform_feedback3 + +static void _glewInfo_GL_ARB_transform_feedback3 (void) +{ + glewPrintExt("GL_ARB_transform_feedback3", GLEW_ARB_transform_feedback3, glewIsSupported("GL_ARB_transform_feedback3"), glewGetExtension("GL_ARB_transform_feedback3")); + + glewInfoFunc("glBeginQueryIndexed", glBeginQueryIndexed == NULL); + glewInfoFunc("glDrawTransformFeedbackStream", glDrawTransformFeedbackStream == NULL); + glewInfoFunc("glEndQueryIndexed", glEndQueryIndexed == NULL); + glewInfoFunc("glGetQueryIndexediv", glGetQueryIndexediv == NULL); +} + +#endif /* GL_ARB_transform_feedback3 */ + #ifdef GL_ARB_transpose_matrix static void _glewInfo_GL_ARB_transpose_matrix (void) @@ -1646,6 +1916,54 @@ static void _glewInfo_GL_ARB_vertex_shader (void) #endif /* GL_ARB_vertex_shader */ +#ifdef GL_ARB_vertex_type_2_10_10_10_rev + +static void _glewInfo_GL_ARB_vertex_type_2_10_10_10_rev (void) +{ + glewPrintExt("GL_ARB_vertex_type_2_10_10_10_rev", GLEW_ARB_vertex_type_2_10_10_10_rev, glewIsSupported("GL_ARB_vertex_type_2_10_10_10_rev"), glewGetExtension("GL_ARB_vertex_type_2_10_10_10_rev")); + + glewInfoFunc("glColorP3ui", glColorP3ui == NULL); + glewInfoFunc("glColorP3uiv", glColorP3uiv == NULL); + glewInfoFunc("glColorP4ui", glColorP4ui == NULL); + glewInfoFunc("glColorP4uiv", glColorP4uiv == NULL); + glewInfoFunc("glMultiTexCoordP1ui", glMultiTexCoordP1ui == NULL); + glewInfoFunc("glMultiTexCoordP1uiv", glMultiTexCoordP1uiv == NULL); + glewInfoFunc("glMultiTexCoordP2ui", glMultiTexCoordP2ui == NULL); + glewInfoFunc("glMultiTexCoordP2uiv", glMultiTexCoordP2uiv == NULL); + glewInfoFunc("glMultiTexCoordP3ui", glMultiTexCoordP3ui == NULL); + glewInfoFunc("glMultiTexCoordP3uiv", glMultiTexCoordP3uiv == NULL); + glewInfoFunc("glMultiTexCoordP4ui", glMultiTexCoordP4ui == NULL); + glewInfoFunc("glMultiTexCoordP4uiv", glMultiTexCoordP4uiv == NULL); + glewInfoFunc("glNormalP3ui", glNormalP3ui == NULL); + glewInfoFunc("glNormalP3uiv", glNormalP3uiv == NULL); + glewInfoFunc("glSecondaryColorP3ui", glSecondaryColorP3ui == NULL); + glewInfoFunc("glSecondaryColorP3uiv", glSecondaryColorP3uiv == NULL); + glewInfoFunc("glTexCoordP1ui", glTexCoordP1ui == NULL); + glewInfoFunc("glTexCoordP1uiv", glTexCoordP1uiv == NULL); + glewInfoFunc("glTexCoordP2ui", glTexCoordP2ui == NULL); + glewInfoFunc("glTexCoordP2uiv", glTexCoordP2uiv == NULL); + glewInfoFunc("glTexCoordP3ui", glTexCoordP3ui == NULL); + glewInfoFunc("glTexCoordP3uiv", glTexCoordP3uiv == NULL); + glewInfoFunc("glTexCoordP4ui", glTexCoordP4ui == NULL); + glewInfoFunc("glTexCoordP4uiv", glTexCoordP4uiv == NULL); + glewInfoFunc("glVertexAttribP1ui", glVertexAttribP1ui == NULL); + glewInfoFunc("glVertexAttribP1uiv", glVertexAttribP1uiv == NULL); + glewInfoFunc("glVertexAttribP2ui", glVertexAttribP2ui == NULL); + glewInfoFunc("glVertexAttribP2uiv", glVertexAttribP2uiv == NULL); + glewInfoFunc("glVertexAttribP3ui", glVertexAttribP3ui == NULL); + glewInfoFunc("glVertexAttribP3uiv", glVertexAttribP3uiv == NULL); + glewInfoFunc("glVertexAttribP4ui", glVertexAttribP4ui == NULL); + glewInfoFunc("glVertexAttribP4uiv", glVertexAttribP4uiv == NULL); + glewInfoFunc("glVertexP2ui", glVertexP2ui == NULL); + glewInfoFunc("glVertexP2uiv", glVertexP2uiv == NULL); + glewInfoFunc("glVertexP3ui", glVertexP3ui == NULL); + glewInfoFunc("glVertexP3uiv", glVertexP3uiv == NULL); + glewInfoFunc("glVertexP4ui", glVertexP4ui == NULL); + glewInfoFunc("glVertexP4uiv", glVertexP4uiv == NULL); +} + +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ + #ifdef GL_ARB_window_pos static void _glewInfo_GL_ARB_window_pos (void) @@ -2895,6 +3213,18 @@ static void _glewInfo_GL_EXT_separate_specular_color (void) #endif /* GL_EXT_separate_specular_color */ +#ifdef GL_EXT_shader_image_load_store + +static void _glewInfo_GL_EXT_shader_image_load_store (void) +{ + glewPrintExt("GL_EXT_shader_image_load_store", GLEW_EXT_shader_image_load_store, glewIsSupported("GL_EXT_shader_image_load_store"), glewGetExtension("GL_EXT_shader_image_load_store")); + + glewInfoFunc("glBindImageTextureEXT", glBindImageTextureEXT == NULL); + glewInfoFunc("glMemoryBarrierEXT", glMemoryBarrierEXT == NULL); +} + +#endif /* GL_EXT_shader_image_load_store */ + #ifdef GL_EXT_shadow_funcs static void _glewInfo_GL_EXT_shadow_funcs (void) @@ -3257,6 +3587,27 @@ static void _glewInfo_GL_EXT_vertex_array_bgra (void) #endif /* GL_EXT_vertex_array_bgra */ +#ifdef GL_EXT_vertex_attrib_64bit + +static void _glewInfo_GL_EXT_vertex_attrib_64bit (void) +{ + glewPrintExt("GL_EXT_vertex_attrib_64bit", GLEW_EXT_vertex_attrib_64bit, glewIsSupported("GL_EXT_vertex_attrib_64bit"), glewGetExtension("GL_EXT_vertex_attrib_64bit")); + + glewInfoFunc("glGetVertexAttribLdvEXT", glGetVertexAttribLdvEXT == NULL); + glewInfoFunc("glVertexArrayVertexAttribLOffsetEXT", glVertexArrayVertexAttribLOffsetEXT == NULL); + glewInfoFunc("glVertexAttribL1dEXT", glVertexAttribL1dEXT == NULL); + glewInfoFunc("glVertexAttribL1dvEXT", glVertexAttribL1dvEXT == NULL); + glewInfoFunc("glVertexAttribL2dEXT", glVertexAttribL2dEXT == NULL); + glewInfoFunc("glVertexAttribL2dvEXT", glVertexAttribL2dvEXT == NULL); + glewInfoFunc("glVertexAttribL3dEXT", glVertexAttribL3dEXT == NULL); + glewInfoFunc("glVertexAttribL3dvEXT", glVertexAttribL3dvEXT == NULL); + glewInfoFunc("glVertexAttribL4dEXT", glVertexAttribL4dEXT == NULL); + glewInfoFunc("glVertexAttribL4dvEXT", glVertexAttribL4dvEXT == NULL); + glewInfoFunc("glVertexAttribLPointerEXT", glVertexAttribLPointerEXT == NULL); +} + +#endif /* GL_EXT_vertex_attrib_64bit */ + #ifdef GL_EXT_vertex_shader static void _glewInfo_GL_EXT_vertex_shader (void) @@ -3752,7 +4103,7 @@ static void _glewInfo_GL_NV_fragment_program2 (void) static void _glewInfo_GL_NV_fragment_program4 (void) { - glewPrintExt("GL_NV_fragment_program4", GLEW_NV_fragment_program4, glewIsSupported("GL_NV_fragment_program4"), glewGetExtension("GL_NV_fragment_program4")); + glewPrintExt("GL_NV_fragment_program4", GLEW_NV_fragment_program4, glewIsSupported("GL_NV_fragment_program4"), glewGetExtension("GL_NV_gpu_program4")); } #endif /* GL_NV_fragment_program4 */ @@ -3781,7 +4132,7 @@ static void _glewInfo_GL_NV_framebuffer_multisample_coverage (void) static void _glewInfo_GL_NV_geometry_program4 (void) { - glewPrintExt("GL_NV_geometry_program4", GLEW_NV_geometry_program4, glewIsSupported("GL_NV_geometry_program4"), glewGetExtension("GL_NV_geometry_program4")); + glewPrintExt("GL_NV_geometry_program4", GLEW_NV_geometry_program4, glewIsSupported("GL_NV_geometry_program4"), glewGetExtension("GL_NV_gpu_program4")); glewInfoFunc("glProgramVertexLimitNV", glProgramVertexLimitNV == NULL); } @@ -3819,6 +4170,68 @@ static void _glewInfo_GL_NV_gpu_program4 (void) #endif /* GL_NV_gpu_program4 */ +#ifdef GL_NV_gpu_program5 + +static void _glewInfo_GL_NV_gpu_program5 (void) +{ + glewPrintExt("GL_NV_gpu_program5", GLEW_NV_gpu_program5, glewIsSupported("GL_NV_gpu_program5"), glewGetExtension("GL_NV_gpu_program5")); +} + +#endif /* GL_NV_gpu_program5 */ + +#ifdef GL_NV_gpu_program_fp64 + +static void _glewInfo_GL_NV_gpu_program_fp64 (void) +{ + glewPrintExt("GL_NV_gpu_program_fp64", GLEW_NV_gpu_program_fp64, glewIsSupported("GL_NV_gpu_program_fp64"), glewGetExtension("GL_NV_gpu_program_fp64")); +} + +#endif /* GL_NV_gpu_program_fp64 */ + +#ifdef GL_NV_gpu_shader5 + +static void _glewInfo_GL_NV_gpu_shader5 (void) +{ + glewPrintExt("GL_NV_gpu_shader5", GLEW_NV_gpu_shader5, glewIsSupported("GL_NV_gpu_shader5"), glewGetExtension("GL_NV_gpu_shader5")); + + glewInfoFunc("glGetUniformi64vNV", glGetUniformi64vNV == NULL); + glewInfoFunc("glGetUniformui64vNV", glGetUniformui64vNV == NULL); + glewInfoFunc("glProgramUniform1i64NV", glProgramUniform1i64NV == NULL); + glewInfoFunc("glProgramUniform1i64vNV", glProgramUniform1i64vNV == NULL); + glewInfoFunc("glProgramUniform1ui64NV", glProgramUniform1ui64NV == NULL); + glewInfoFunc("glProgramUniform1ui64vNV", glProgramUniform1ui64vNV == NULL); + glewInfoFunc("glProgramUniform2i64NV", glProgramUniform2i64NV == NULL); + glewInfoFunc("glProgramUniform2i64vNV", glProgramUniform2i64vNV == NULL); + glewInfoFunc("glProgramUniform2ui64NV", glProgramUniform2ui64NV == NULL); + glewInfoFunc("glProgramUniform2ui64vNV", glProgramUniform2ui64vNV == NULL); + glewInfoFunc("glProgramUniform3i64NV", glProgramUniform3i64NV == NULL); + glewInfoFunc("glProgramUniform3i64vNV", glProgramUniform3i64vNV == NULL); + glewInfoFunc("glProgramUniform3ui64NV", glProgramUniform3ui64NV == NULL); + glewInfoFunc("glProgramUniform3ui64vNV", glProgramUniform3ui64vNV == NULL); + glewInfoFunc("glProgramUniform4i64NV", glProgramUniform4i64NV == NULL); + glewInfoFunc("glProgramUniform4i64vNV", glProgramUniform4i64vNV == NULL); + glewInfoFunc("glProgramUniform4ui64NV", glProgramUniform4ui64NV == NULL); + glewInfoFunc("glProgramUniform4ui64vNV", glProgramUniform4ui64vNV == NULL); + glewInfoFunc("glUniform1i64NV", glUniform1i64NV == NULL); + glewInfoFunc("glUniform1i64vNV", glUniform1i64vNV == NULL); + glewInfoFunc("glUniform1ui64NV", glUniform1ui64NV == NULL); + glewInfoFunc("glUniform1ui64vNV", glUniform1ui64vNV == NULL); + glewInfoFunc("glUniform2i64NV", glUniform2i64NV == NULL); + glewInfoFunc("glUniform2i64vNV", glUniform2i64vNV == NULL); + glewInfoFunc("glUniform2ui64NV", glUniform2ui64NV == NULL); + glewInfoFunc("glUniform2ui64vNV", glUniform2ui64vNV == NULL); + glewInfoFunc("glUniform3i64NV", glUniform3i64NV == NULL); + glewInfoFunc("glUniform3i64vNV", glUniform3i64vNV == NULL); + glewInfoFunc("glUniform3ui64NV", glUniform3ui64NV == NULL); + glewInfoFunc("glUniform3ui64vNV", glUniform3ui64vNV == NULL); + glewInfoFunc("glUniform4i64NV", glUniform4i64NV == NULL); + glewInfoFunc("glUniform4i64vNV", glUniform4i64vNV == NULL); + glewInfoFunc("glUniform4ui64NV", glUniform4ui64NV == NULL); + glewInfoFunc("glUniform4ui64vNV", glUniform4ui64vNV == NULL); +} + +#endif /* GL_NV_gpu_shader5 */ + #ifdef GL_NV_half_float static void _glewInfo_GL_NV_half_float (void) @@ -4037,7 +4450,6 @@ static void _glewInfo_GL_NV_shader_buffer_load (void) glewInfoFunc("glGetBufferParameterui64vNV", glGetBufferParameterui64vNV == NULL); glewInfoFunc("glGetIntegerui64vNV", glGetIntegerui64vNV == NULL); glewInfoFunc("glGetNamedBufferParameterui64vNV", glGetNamedBufferParameterui64vNV == NULL); - glewInfoFunc("glGetUniformui64vNV", glGetUniformui64vNV == NULL); glewInfoFunc("glIsBufferResidentNV", glIsBufferResidentNV == NULL); glewInfoFunc("glIsNamedBufferResidentNV", glIsNamedBufferResidentNV == NULL); glewInfoFunc("glMakeBufferNonResidentNV", glMakeBufferNonResidentNV == NULL); @@ -4052,6 +4464,15 @@ static void _glewInfo_GL_NV_shader_buffer_load (void) #endif /* GL_NV_shader_buffer_load */ +#ifdef GL_NV_tessellation_program5 + +static void _glewInfo_GL_NV_tessellation_program5 (void) +{ + glewPrintExt("GL_NV_tessellation_program5", GLEW_NV_tessellation_program5, glewIsSupported("GL_NV_tessellation_program5"), glewGetExtension("GL_NV_gpu_program5")); +} + +#endif /* GL_NV_tessellation_program5 */ + #ifdef GL_NV_texgen_emboss static void _glewInfo_GL_NV_texgen_emboss (void) @@ -4203,6 +4624,35 @@ static void _glewInfo_GL_NV_vertex_array_range2 (void) #endif /* GL_NV_vertex_array_range2 */ +#ifdef GL_NV_vertex_attrib_integer_64bit + +static void _glewInfo_GL_NV_vertex_attrib_integer_64bit (void) +{ + glewPrintExt("GL_NV_vertex_attrib_integer_64bit", GLEW_NV_vertex_attrib_integer_64bit, glewIsSupported("GL_NV_vertex_attrib_integer_64bit"), glewGetExtension("GL_NV_vertex_attrib_integer_64bit")); + + glewInfoFunc("glGetVertexAttribLi64vNV", glGetVertexAttribLi64vNV == NULL); + glewInfoFunc("glGetVertexAttribLui64vNV", glGetVertexAttribLui64vNV == NULL); + glewInfoFunc("glVertexAttribL1i64NV", glVertexAttribL1i64NV == NULL); + glewInfoFunc("glVertexAttribL1i64vNV", glVertexAttribL1i64vNV == NULL); + glewInfoFunc("glVertexAttribL1ui64NV", glVertexAttribL1ui64NV == NULL); + glewInfoFunc("glVertexAttribL1ui64vNV", glVertexAttribL1ui64vNV == NULL); + glewInfoFunc("glVertexAttribL2i64NV", glVertexAttribL2i64NV == NULL); + glewInfoFunc("glVertexAttribL2i64vNV", glVertexAttribL2i64vNV == NULL); + glewInfoFunc("glVertexAttribL2ui64NV", glVertexAttribL2ui64NV == NULL); + glewInfoFunc("glVertexAttribL2ui64vNV", glVertexAttribL2ui64vNV == NULL); + glewInfoFunc("glVertexAttribL3i64NV", glVertexAttribL3i64NV == NULL); + glewInfoFunc("glVertexAttribL3i64vNV", glVertexAttribL3i64vNV == NULL); + glewInfoFunc("glVertexAttribL3ui64NV", glVertexAttribL3ui64NV == NULL); + glewInfoFunc("glVertexAttribL3ui64vNV", glVertexAttribL3ui64vNV == NULL); + glewInfoFunc("glVertexAttribL4i64NV", glVertexAttribL4i64NV == NULL); + glewInfoFunc("glVertexAttribL4i64vNV", glVertexAttribL4i64vNV == NULL); + glewInfoFunc("glVertexAttribL4ui64NV", glVertexAttribL4ui64NV == NULL); + glewInfoFunc("glVertexAttribL4ui64vNV", glVertexAttribL4ui64vNV == NULL); + glewInfoFunc("glVertexAttribLFormatNV", glVertexAttribLFormatNV == NULL); +} + +#endif /* GL_NV_vertex_attrib_integer_64bit */ + #ifdef GL_NV_vertex_buffer_unified_memory static void _glewInfo_GL_NV_vertex_buffer_unified_memory (void) @@ -4339,7 +4789,7 @@ static void _glewInfo_GL_NV_vertex_program3 (void) static void _glewInfo_GL_NV_vertex_program4 (void) { - glewPrintExt("GL_NV_vertex_program4", GLEW_NV_vertex_program4, glewIsSupported("GL_NV_vertex_program4"), glewGetExtension("GL_NV_vertex_program4")); + glewPrintExt("GL_NV_vertex_program4", GLEW_NV_vertex_program4, glewIsSupported("GL_NV_vertex_program4"), glewGetExtension("GL_NV_gpu_program4")); } #endif /* GL_NV_vertex_program4 */ @@ -5749,6 +6199,15 @@ static void _glewInfo_GLX_ARB_multisample (void) #endif /* GLX_ARB_multisample */ +#ifdef GLX_ARB_vertex_buffer_object + +static void _glewInfo_GLX_ARB_vertex_buffer_object (void) +{ + glewPrintExt("GLX_ARB_vertex_buffer_object", GLXEW_ARB_vertex_buffer_object, glxewIsSupported("GLX_ARB_vertex_buffer_object"), glxewGetExtension("GLX_ARB_vertex_buffer_object")); +} + +#endif /* GLX_ARB_vertex_buffer_object */ + #ifdef GLX_ATI_pixel_format_float static void _glewInfo_GLX_ATI_pixel_format_float (void) @@ -5853,6 +6312,15 @@ static void _glewInfo_GLX_EXT_visual_rating (void) #endif /* GLX_EXT_visual_rating */ +#ifdef GLX_INTEL_swap_event + +static void _glewInfo_GLX_INTEL_swap_event (void) +{ + glewPrintExt("GLX_INTEL_swap_event", GLXEW_INTEL_swap_event, glxewIsSupported("GLX_INTEL_swap_event"), glxewGetExtension("GLX_INTEL_swap_event")); +} + +#endif /* GLX_INTEL_swap_event */ + #ifdef GLX_MESA_agp_offset static void _glewInfo_GLX_MESA_agp_offset (void) @@ -6246,6 +6714,12 @@ static void glewInfo (void) #ifdef GL_VERSION_3_2 _glewInfo_GL_VERSION_3_2(); #endif /* GL_VERSION_3_2 */ +#ifdef GL_VERSION_3_3 + _glewInfo_GL_VERSION_3_3(); +#endif /* GL_VERSION_3_3 */ +#ifdef GL_VERSION_4_0 + _glewInfo_GL_VERSION_4_0(); +#endif /* GL_VERSION_4_0 */ #ifdef GL_3DFX_multisample _glewInfo_GL_3DFX_multisample(); #endif /* GL_3DFX_multisample */ @@ -6255,12 +6729,21 @@ static void glewInfo (void) #ifdef GL_3DFX_texture_compression_FXT1 _glewInfo_GL_3DFX_texture_compression_FXT1(); #endif /* GL_3DFX_texture_compression_FXT1 */ +#ifdef GL_AMD_conservative_depth + _glewInfo_GL_AMD_conservative_depth(); +#endif /* GL_AMD_conservative_depth */ #ifdef GL_AMD_draw_buffers_blend _glewInfo_GL_AMD_draw_buffers_blend(); #endif /* GL_AMD_draw_buffers_blend */ #ifdef GL_AMD_performance_monitor _glewInfo_GL_AMD_performance_monitor(); #endif /* GL_AMD_performance_monitor */ +#ifdef GL_AMD_seamless_cubemap_per_texture + _glewInfo_GL_AMD_seamless_cubemap_per_texture(); +#endif /* GL_AMD_seamless_cubemap_per_texture */ +#ifdef GL_AMD_shader_stencil_export + _glewInfo_GL_AMD_shader_stencil_export(); +#endif /* GL_AMD_shader_stencil_export */ #ifdef GL_AMD_texture_texture4 _glewInfo_GL_AMD_texture_texture4(); #endif /* GL_AMD_texture_texture4 */ @@ -6318,6 +6801,9 @@ static void glewInfo (void) #ifdef GL_APPLE_ycbcr_422 _glewInfo_GL_APPLE_ycbcr_422(); #endif /* GL_APPLE_ycbcr_422 */ +#ifdef GL_ARB_blend_func_extended + _glewInfo_GL_ARB_blend_func_extended(); +#endif /* GL_ARB_blend_func_extended */ #ifdef GL_ARB_color_buffer_float _glewInfo_GL_ARB_color_buffer_float(); #endif /* GL_ARB_color_buffer_float */ @@ -6345,9 +6831,15 @@ static void glewInfo (void) #ifdef GL_ARB_draw_elements_base_vertex _glewInfo_GL_ARB_draw_elements_base_vertex(); #endif /* GL_ARB_draw_elements_base_vertex */ +#ifdef GL_ARB_draw_indirect + _glewInfo_GL_ARB_draw_indirect(); +#endif /* GL_ARB_draw_indirect */ #ifdef GL_ARB_draw_instanced _glewInfo_GL_ARB_draw_instanced(); #endif /* GL_ARB_draw_instanced */ +#ifdef GL_ARB_explicit_attrib_location + _glewInfo_GL_ARB_explicit_attrib_location(); +#endif /* GL_ARB_explicit_attrib_location */ #ifdef GL_ARB_fragment_coord_conventions _glewInfo_GL_ARB_fragment_coord_conventions(); #endif /* GL_ARB_fragment_coord_conventions */ @@ -6369,6 +6861,12 @@ static void glewInfo (void) #ifdef GL_ARB_geometry_shader4 _glewInfo_GL_ARB_geometry_shader4(); #endif /* GL_ARB_geometry_shader4 */ +#ifdef GL_ARB_gpu_shader5 + _glewInfo_GL_ARB_gpu_shader5(); +#endif /* GL_ARB_gpu_shader5 */ +#ifdef GL_ARB_gpu_shader_fp64 + _glewInfo_GL_ARB_gpu_shader_fp64(); +#endif /* GL_ARB_gpu_shader_fp64 */ #ifdef GL_ARB_half_float_pixel _glewInfo_GL_ARB_half_float_pixel(); #endif /* GL_ARB_half_float_pixel */ @@ -6396,6 +6894,9 @@ static void glewInfo (void) #ifdef GL_ARB_occlusion_query _glewInfo_GL_ARB_occlusion_query(); #endif /* GL_ARB_occlusion_query */ +#ifdef GL_ARB_occlusion_query2 + _glewInfo_GL_ARB_occlusion_query2(); +#endif /* GL_ARB_occlusion_query2 */ #ifdef GL_ARB_pixel_buffer_object _glewInfo_GL_ARB_pixel_buffer_object(); #endif /* GL_ARB_pixel_buffer_object */ @@ -6411,18 +6912,30 @@ static void glewInfo (void) #ifdef GL_ARB_sample_shading _glewInfo_GL_ARB_sample_shading(); #endif /* GL_ARB_sample_shading */ +#ifdef GL_ARB_sampler_objects + _glewInfo_GL_ARB_sampler_objects(); +#endif /* GL_ARB_sampler_objects */ #ifdef GL_ARB_seamless_cube_map _glewInfo_GL_ARB_seamless_cube_map(); #endif /* GL_ARB_seamless_cube_map */ +#ifdef GL_ARB_shader_bit_encoding + _glewInfo_GL_ARB_shader_bit_encoding(); +#endif /* GL_ARB_shader_bit_encoding */ #ifdef GL_ARB_shader_objects _glewInfo_GL_ARB_shader_objects(); #endif /* GL_ARB_shader_objects */ +#ifdef GL_ARB_shader_subroutine + _glewInfo_GL_ARB_shader_subroutine(); +#endif /* GL_ARB_shader_subroutine */ #ifdef GL_ARB_shader_texture_lod _glewInfo_GL_ARB_shader_texture_lod(); #endif /* GL_ARB_shader_texture_lod */ #ifdef GL_ARB_shading_language_100 _glewInfo_GL_ARB_shading_language_100(); #endif /* GL_ARB_shading_language_100 */ +#ifdef GL_ARB_shading_language_include + _glewInfo_GL_ARB_shading_language_include(); +#endif /* GL_ARB_shading_language_include */ #ifdef GL_ARB_shadow _glewInfo_GL_ARB_shadow(); #endif /* GL_ARB_shadow */ @@ -6432,15 +6945,24 @@ static void glewInfo (void) #ifdef GL_ARB_sync _glewInfo_GL_ARB_sync(); #endif /* GL_ARB_sync */ +#ifdef GL_ARB_tessellation_shader + _glewInfo_GL_ARB_tessellation_shader(); +#endif /* GL_ARB_tessellation_shader */ #ifdef GL_ARB_texture_border_clamp _glewInfo_GL_ARB_texture_border_clamp(); #endif /* GL_ARB_texture_border_clamp */ #ifdef GL_ARB_texture_buffer_object _glewInfo_GL_ARB_texture_buffer_object(); #endif /* GL_ARB_texture_buffer_object */ +#ifdef GL_ARB_texture_buffer_object_rgb32 + _glewInfo_GL_ARB_texture_buffer_object_rgb32(); +#endif /* GL_ARB_texture_buffer_object_rgb32 */ #ifdef GL_ARB_texture_compression _glewInfo_GL_ARB_texture_compression(); #endif /* GL_ARB_texture_compression */ +#ifdef GL_ARB_texture_compression_bptc + _glewInfo_GL_ARB_texture_compression_bptc(); +#endif /* GL_ARB_texture_compression_bptc */ #ifdef GL_ARB_texture_compression_rgtc _glewInfo_GL_ARB_texture_compression_rgtc(); #endif /* GL_ARB_texture_compression_rgtc */ @@ -6486,6 +7008,21 @@ static void glewInfo (void) #ifdef GL_ARB_texture_rg _glewInfo_GL_ARB_texture_rg(); #endif /* GL_ARB_texture_rg */ +#ifdef GL_ARB_texture_rgb10_a2ui + _glewInfo_GL_ARB_texture_rgb10_a2ui(); +#endif /* GL_ARB_texture_rgb10_a2ui */ +#ifdef GL_ARB_texture_swizzle + _glewInfo_GL_ARB_texture_swizzle(); +#endif /* GL_ARB_texture_swizzle */ +#ifdef GL_ARB_timer_query + _glewInfo_GL_ARB_timer_query(); +#endif /* GL_ARB_timer_query */ +#ifdef GL_ARB_transform_feedback2 + _glewInfo_GL_ARB_transform_feedback2(); +#endif /* GL_ARB_transform_feedback2 */ +#ifdef GL_ARB_transform_feedback3 + _glewInfo_GL_ARB_transform_feedback3(); +#endif /* GL_ARB_transform_feedback3 */ #ifdef GL_ARB_transpose_matrix _glewInfo_GL_ARB_transpose_matrix(); #endif /* GL_ARB_transpose_matrix */ @@ -6510,6 +7047,9 @@ static void glewInfo (void) #ifdef GL_ARB_vertex_shader _glewInfo_GL_ARB_vertex_shader(); #endif /* GL_ARB_vertex_shader */ +#ifdef GL_ARB_vertex_type_2_10_10_10_rev + _glewInfo_GL_ARB_vertex_type_2_10_10_10_rev(); +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ #ifdef GL_ARB_window_pos _glewInfo_GL_ARB_window_pos(); #endif /* GL_ARB_window_pos */ @@ -6747,6 +7287,9 @@ static void glewInfo (void) #ifdef GL_EXT_separate_specular_color _glewInfo_GL_EXT_separate_specular_color(); #endif /* GL_EXT_separate_specular_color */ +#ifdef GL_EXT_shader_image_load_store + _glewInfo_GL_EXT_shader_image_load_store(); +#endif /* GL_EXT_shader_image_load_store */ #ifdef GL_EXT_shadow_funcs _glewInfo_GL_EXT_shadow_funcs(); #endif /* GL_EXT_shadow_funcs */ @@ -6852,6 +7395,9 @@ static void glewInfo (void) #ifdef GL_EXT_vertex_array_bgra _glewInfo_GL_EXT_vertex_array_bgra(); #endif /* GL_EXT_vertex_array_bgra */ +#ifdef GL_EXT_vertex_attrib_64bit + _glewInfo_GL_EXT_vertex_attrib_64bit(); +#endif /* GL_EXT_vertex_attrib_64bit */ #ifdef GL_EXT_vertex_shader _glewInfo_GL_EXT_vertex_shader(); #endif /* GL_EXT_vertex_shader */ @@ -6984,6 +7530,15 @@ static void glewInfo (void) #ifdef GL_NV_gpu_program4 _glewInfo_GL_NV_gpu_program4(); #endif /* GL_NV_gpu_program4 */ +#ifdef GL_NV_gpu_program5 + _glewInfo_GL_NV_gpu_program5(); +#endif /* GL_NV_gpu_program5 */ +#ifdef GL_NV_gpu_program_fp64 + _glewInfo_GL_NV_gpu_program_fp64(); +#endif /* GL_NV_gpu_program_fp64 */ +#ifdef GL_NV_gpu_shader5 + _glewInfo_GL_NV_gpu_shader5(); +#endif /* GL_NV_gpu_shader5 */ #ifdef GL_NV_half_float _glewInfo_GL_NV_half_float(); #endif /* GL_NV_half_float */ @@ -7026,6 +7581,9 @@ static void glewInfo (void) #ifdef GL_NV_shader_buffer_load _glewInfo_GL_NV_shader_buffer_load(); #endif /* GL_NV_shader_buffer_load */ +#ifdef GL_NV_tessellation_program5 + _glewInfo_GL_NV_tessellation_program5(); +#endif /* GL_NV_tessellation_program5 */ #ifdef GL_NV_texgen_emboss _glewInfo_GL_NV_texgen_emboss(); #endif /* GL_NV_texgen_emboss */ @@ -7068,6 +7626,9 @@ static void glewInfo (void) #ifdef GL_NV_vertex_array_range2 _glewInfo_GL_NV_vertex_array_range2(); #endif /* GL_NV_vertex_array_range2 */ +#ifdef GL_NV_vertex_attrib_integer_64bit + _glewInfo_GL_NV_vertex_attrib_integer_64bit(); +#endif /* GL_NV_vertex_attrib_integer_64bit */ #ifdef GL_NV_vertex_buffer_unified_memory _glewInfo_GL_NV_vertex_buffer_unified_memory(); #endif /* GL_NV_vertex_buffer_unified_memory */ @@ -7472,6 +8033,9 @@ static void glxewInfo () #ifdef GLX_ARB_multisample _glewInfo_GLX_ARB_multisample(); #endif /* GLX_ARB_multisample */ +#ifdef GLX_ARB_vertex_buffer_object + _glewInfo_GLX_ARB_vertex_buffer_object(); +#endif /* GLX_ARB_vertex_buffer_object */ #ifdef GLX_ATI_pixel_format_float _glewInfo_GLX_ATI_pixel_format_float(); #endif /* GLX_ATI_pixel_format_float */ @@ -7502,6 +8066,9 @@ static void glxewInfo () #ifdef GLX_EXT_visual_rating _glewInfo_GLX_EXT_visual_rating(); #endif /* GLX_EXT_visual_rating */ +#ifdef GLX_INTEL_swap_event + _glewInfo_GLX_INTEL_swap_event(); +#endif /* GLX_INTEL_swap_event */ #ifdef GLX_MESA_agp_offset _glewInfo_GLX_MESA_agp_offset(); #endif /* GLX_MESA_agp_offset */ diff --git a/src/glx/Makefile b/src/glx/Makefile index c6ebc49828b..48d901fb894 100644 --- a/src/glx/Makefile +++ b/src/glx/Makefile @@ -39,7 +39,7 @@ SOURCES = \ dri2_glx.c \ dri2.c -GLAPI_LIB = $(TOP)/src/mesa/libglapi.a +GLAPI_LIB = $(TOP)/src/mapi/glapi/libglapi.a OBJECTS = $(SOURCES:.c=.o) @@ -47,7 +47,8 @@ INCLUDES = -I. \ -I$(TOP)/include \ -I$(TOP)/include/GL/internal \ -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/glapi \ + -I$(TOP)/src/mapi \ + -I$(TOP)/src/mapi/glapi \ $(LIBDRM_CFLAGS) \ $(DRI2PROTO_CFLAGS) \ $(X11_INCLUDES) @@ -73,7 +74,7 @@ $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) $(GLAPI_LIB) Makefile $(GL_LIB_DEPS) $(OBJECTS) $(GLAPI_LIB) $(GLAPI_LIB): - @$(MAKE) -C $(TOP)/src/mesa libglapi.a + @$(MAKE) -C $(TOP)/src/mapi/glapi depend: $(SOURCES) Makefile rm -f depend diff --git a/src/glx/apple/Makefile b/src/glx/apple/Makefile index 279f7aded9d..fd47b3d39c2 100644 --- a/src/glx/apple/Makefile +++ b/src/glx/apple/Makefile @@ -65,7 +65,8 @@ INCLUDES = -I. -Iinclude -I..\ -I$(TOP)/include \ -I$(TOP)/include/GL/internal \ -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/glapi \ + -I$(TOP)/src/mapi \ + -I$(TOP)/src/mapi/glapi \ $(LIBDRM_CFLAGS) \ $(DRI2PROTO_CFLAGS) \ $(X11_INCLUDES) diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 6058c721da7..45959915b4b 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -73,6 +73,8 @@ struct __GLXDRIdisplayPrivateRec int driPatch; int swapAvailable; int invalidateAvailable; + + const __DRIextension *loader_extensions[4]; }; struct __GLXDRIcontextPrivateRec @@ -544,17 +546,11 @@ static const __DRIdri2LoaderExtension dri2LoaderExtension_old = { NULL, }; -static const __DRIextension *loader_extensions[] = { - &dri2LoaderExtension.base, - &systemTimeExtension.base, - NULL -}; - -static const __DRIextension *loader_extensions_old[] = { - &dri2LoaderExtension_old.base, - &systemTimeExtension.base, - NULL +#ifdef __DRI_USE_INVALIDATE +static const __DRIuseInvalidateExtension dri2UseInvalidate = { + { __DRI_USE_INVALIDATE, __DRI_USE_INVALIDATE_VERSION } }; +#endif _X_HIDDEN void dri2InvalidateBuffers(Display *dpy, XID drawable) @@ -630,13 +626,14 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen, 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, ((pdp->driMinor < 1) - ? loader_extensions_old - : loader_extensions), + psc->dri2->createNewScreen(screen, psc->fd, + (const __DRIextension **) + &pdp->loader_extensions[0], &driver_configs, psc); if (psc->__driScreen == NULL) { @@ -718,7 +715,7 @@ _X_HIDDEN __GLXDRIdisplay * dri2CreateDisplay(Display * dpy) { __GLXDRIdisplayPrivate *pdp; - int eventBase, errorBase; + int eventBase, errorBase, i; if (!DRI2QueryExtension(dpy, &eventBase, &errorBase)) return NULL; @@ -739,6 +736,19 @@ dri2CreateDisplay(Display * dpy) 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; + +#ifdef __DRI_USE_INVALIDATE + pdp->loader_extensions[i++] = &dri2UseInvalidate.base; +#endif + pdp->loader_extensions[i++] = NULL; + return &pdp->base; } diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index 926be1014a8..34fbecf9563 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -887,9 +887,6 @@ glXCopyContext(Display * dpy, GLXContext source, static Bool __glXIsDirect(Display * dpy, GLXContextID contextID) { -#ifdef GLX_USE_APPLEGL /* TODO: apple indirect */ - return GC_IS_DIRECT(gc); -#else #if !defined(USE_XCB) xGLXIsDirectReq *req; xGLXIsDirectReply reply; @@ -925,7 +922,6 @@ __glXIsDirect(Display * dpy, GLXContextID contextID) return reply.isDirect; #endif /* USE_XCB */ -#endif /* GLX_USE_APPLEGL */ } /** @@ -943,7 +939,11 @@ glXIsDirect(Display * dpy, GLXContext gc) else if (GC_IS_DIRECT(gc)) { return GL_TRUE; } +#ifdef GLX_USE_APPLEGL /* TODO: indirect on darwin */ + return GL_FALSE; +#else return __glXIsDirect(dpy, gc->xid); +#endif } PUBLIC GLXPixmap @@ -1766,6 +1766,15 @@ static int __glXQueryContextInfo(Display * dpy, GLXContext ctx) unsigned i; _XRead(dpy, (char *) propList, nPropListBytes); + + /* Look up screen first so we can look up visuals/fbconfigs later */ + pProp = propList; + for (i = 0; i < numValues; i++, pProp += 2) + if (pProp[0] == GLX_SCREEN) { + ctx->screen = pProp[1]; + ctx->psc = GetGLXScreenConfigs(dpy, ctx->screen); + } + pProp = propList; for (i = 0; i < numValues; i++) { switch (*pProp++) { @@ -1776,9 +1785,6 @@ static int __glXQueryContextInfo(Display * dpy, GLXContext ctx) ctx->mode = _gl_context_modes_find_visual(ctx->psc->visuals, *pProp++); break; - case GLX_SCREEN: - ctx->screen = *pProp++; - break; case GLX_FBCONFIG_ID: ctx->mode = _gl_context_modes_find_fbconfig(ctx->psc->configs, @@ -1787,6 +1793,7 @@ static int __glXQueryContextInfo(Display * dpy, GLXContext ctx) case GLX_RENDER_TYPE: ctx->renderType = *pProp++; break; + case GLX_SCREEN: default: pProp++; continue; diff --git a/src/mapi/es1api/Makefile b/src/mapi/es1api/Makefile new file mode 100644 index 00000000000..576ac5afdc3 --- /dev/null +++ b/src/mapi/es1api/Makefile @@ -0,0 +1,144 @@ +# src/mapi/es1api/Makefile + +TOP := ../../.. +include $(TOP)/configs/current + +# this Makefile can build both OpenGL ES 1.1 and 2.0 +ifeq ($(ES),) +ES := es1 + +GLES_HEADER := GLES +GLES_PC := glesv1_cm.pc + +GLES_LIB := $(GLESv1_CM_LIB) +GLES_LIB_NAME := $(GLESv1_CM_LIB_NAME) +GLES_LIB_GLOB := $(GLESv1_CM_LIB_GLOB) +GLES_LIB_DEPS := $(GLESv1_CM_LIB_DEPS) +GLES_LIB_MAJOR := 1 +GLES_LIB_MINOR := 1 +GLES_LIB_PATCH := 0 +else +GLES_HEADER := GLES2 +GLES_PC := glesv2.pc + +GLES_LIB := $(GLESv2_LIB) +GLES_LIB_NAME := $(GLESv2_LIB_NAME) +GLES_LIB_GLOB := $(GLESv2_LIB_GLOB) +GLES_LIB_DEPS := $(GLESv2_LIB_DEPS) +GLES_LIB_MAJOR := 2 +GLES_LIB_MINOR := 0 +GLES_LIB_PATCH := 0 +endif + +ESAPI = $(ES)api + +GLAPI := $(TOP)/src/mapi/glapi +MAPI := $(TOP)/src/mapi/mapi +# directory for generated sources/headers +GEN := glapi + +include $(GLAPI)/sources.mak +GLAPI_OBJECTS := $(GLAPI_SOURCES:.c=.o) +GLAPI_SOURCES := $(addprefix $(GLAPI)/, $(GLAPI_SOURCES)) +GLAPI_ASM_OBJECTS := $(GLAPI_ASM_SOURCES:.S=.o) +GLAPI_ASM_SOURCES := $(addprefix $(GEN)/, $(GLAPI_ASM_SOURCES)) + +include $(MAPI)/sources.mak +MAPI_GLAPI_OBJECTS := $(MAPI_GLAPI_SOURCES:.c=.o) +MAPI_GLAPI_SOURCES := $(addprefix $(MAPI)/, $(MAPI_GLAPI_SOURCES)) + +ESAPI_OBJECTS = $(GLAPI_OBJECTS) $(GLAPI_ASM_OBJECTS) $(MAPI_GLAPI_OBJECTS) + +INCLUDE_DIRS = \ + -I$(TOP)/include \ + -I$(TOP)/src/mapi/$(ESAPI) \ + -I$(TOP)/src/mapi \ + -I$(TOP)/src/mesa + +.PHONY: default +default: depend $(TOP)/$(LIB_DIR)/$(GLES_LIB_NAME) + +$(TOP)/$(LIB_DIR)/$(GLES_LIB_NAME): $(ESAPI_OBJECTS) + $(MKLIB) -o $(GLES_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + -major $(GLES_LIB_MAJOR) \ + -minor $(GLES_LIB_MINOR) \ + -patch $(GLES_LIB_PATCH) \ + -id $(INSTALL_LIB_DIR)/lib$(GLES_LIB).$(GLES_LIB_MAJOR).dylib \ + $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \ + $(ESAPI_OBJECTS) $(GLES_LIB_DEPS) + +# not used, but kept for completeness +lib$(ESAPI).a: $(ESAPI_OBJECTS) + @$(MKLIB) -o $(ESAPI) -static $(ESAPI_OBJECTS) + +$(GLAPI_OBJECTS): %.o: $(GLAPI)/%.c + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ + +$(GLAPI_ASM_OBJECTS): %.o: $(GEN)/%.S + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ + +$(MAPI_GLAPI_OBJECTS): %.o: $(MAPI)/%.c + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) -DMAPI_GLAPI_CURRENT $< -o $@ + +$(GLAPI_SOURCES) $(GLAPI_ASM_SOURCES): | glapi-stamp + +glapi-stamp: + @# generate sources/headers + @$(MAKE) -C $(GLAPI)/gen-es $(ES) + @touch $@ + +.PHONY: clean +clean: + -rm -f $(GLES_PC) + -rm -f $(TOP)/$(LIB_DIR)/$(GLES_LIB_NAME) + -rm -f lib$(ESAPI).a + -rm -f $(ESAPI_OBJECTS) + -rm -f depend depend.bak + -rm -f glapi-stamp + @# clean generated sources/headers + @$(MAKE) -C $(GLAPI)/gen-es clean-$(ES) + +pcedit = \ + -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \ + -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \ + -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \ + -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' \ + +pcedit-es1 = \ + $(pcedit) \ + -e 's,@GLESv1_CM_PC_REQ_PRIV@,$(GLESv1_CM_PC_REQ_PRIV),' \ + -e 's,@GLESv1_CM_PC_LIB_PRIV@,$(GLESv1_CM_PC_LIB_PRIV),' \ + -e 's,@GLESv1_CM_PC_CFLAGS@,$(GLESv1_CM_PC_CFLAGS),' \ + -e 's,@GLESv1_CM_LIB@,$(GLESv1_CM_LIB),' + +pcedit-es2 = \ + $(pcedit) \ + -e 's,@GLESv2_PC_REQ_PRIV@,$(GLESv2_PC_REQ_PRIV),' \ + -e 's,@GLESv2_PC_LIB_PRIV@,$(GLESv2_PC_LIB_PRIV),' \ + -e 's,@GLESv2_PC_CFLAGS@,$(GLESv2_PC_CFLAGS),' \ + -e 's,@GLESv2_LIB@,$(GLESv2_LIB),' + +$(GLES_PC): $(GLES_PC).in + @sed $(pcedit-$(ES)) $< > $@ + +install-headers: + $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/$(GLES_HEADER) + $(INSTALL) -m 644 $(TOP)/include/$(GLES_HEADER)/*.h \ + $(DESTDIR)$(INSTALL_INC_DIR)/$(GLES_HEADER) + +install-pc: $(GLES_PC) + $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig + $(INSTALL) -m 644 $(GLES_PC) $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig + +install: default install-headers install-pc + $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GLES_LIB_GLOB) \ + $(DESTDIR)$(INSTALL_LIB_DIR) + +depend: $(GLAPI_SOURCES) $(MAPI_GLAPI_SOURCES) + @echo "running $(MKDEP)" + @touch depend + @$(MKDEP) $(MKDEP_OPTIONS) -f- $(DEFINES) $(INCLUDE_DIRS) \ + -DMAPI_GLAPI_CURRENT $(GLAPI_SOURCES) $(MAPI_GLAPI_SOURCES) \ + 2>/dev/null | sed -e 's,^$(GLAPI)/,,' -e 's,^$(MAPI)/,,' \ + > depend diff --git a/src/mesa/glesv1_cm.pc.in b/src/mapi/es1api/glesv1_cm.pc.in index e9c22222041..291f5abf3f9 100644 --- a/src/mesa/glesv1_cm.pc.in +++ b/src/mapi/es1api/glesv1_cm.pc.in @@ -4,8 +4,8 @@ libdir=@INSTALL_LIB_DIR@ includedir=@INSTALL_INC_DIR@ Name: glesv1_cm -Description: Mesa OpenGL ES 1.0 CM library -Requires.private: @GLESv1_CM_REQ_PRIV@ +Description: Mesa OpenGL ES 1.1 CM library +Requires.private: @GLESv1_CM_PC_REQ_PRIV@ Version: @VERSION@ Libs: -L${libdir} -l@GLESv1_CM_LIB@ Libs.private: @GLESv1_CM_PC_LIB_PRIV@ diff --git a/src/mapi/es2api/Makefile b/src/mapi/es2api/Makefile new file mode 100644 index 00000000000..21816a694af --- /dev/null +++ b/src/mapi/es2api/Makefile @@ -0,0 +1,3 @@ +# src/mapi/es2api/Makefile +ES := es2 +include ../es1api/Makefile diff --git a/src/mesa/glesv2.pc.in b/src/mapi/es2api/glesv2.pc.in index 3b747cbee77..3b747cbee77 100644 --- a/src/mesa/glesv2.pc.in +++ b/src/mapi/es2api/glesv2.pc.in diff --git a/src/mesa/glapi/.gitignore b/src/mapi/glapi/.gitignore index e706bc23cab..e706bc23cab 100644 --- a/src/mesa/glapi/.gitignore +++ b/src/mapi/glapi/.gitignore diff --git a/src/mapi/glapi/Makefile b/src/mapi/glapi/Makefile new file mode 100644 index 00000000000..ca9381d4253 --- /dev/null +++ b/src/mapi/glapi/Makefile @@ -0,0 +1,53 @@ +# src/mapi/glapi/Makefile + +TOP = ../../.. +include $(TOP)/configs/current + +TARGET = glapi + +MAPI = $(TOP)/src/mapi/mapi + +include sources.mak +GLAPI_OBJECTS = $(GLAPI_SOURCES:.c=.o) +GLAPI_ASM_OBJECTS = $(GLAPI_ASM_SOURCES:.S=.o) + +include $(MAPI)/sources.mak +MAPI_GLAPI_OBJECTS := $(MAPI_GLAPI_SOURCES:.c=.o) +MAPI_GLAPI_SOURCES := $(addprefix $(MAPI)/, $(MAPI_GLAPI_SOURCES)) + +TARGET_OBJECTS = $(GLAPI_OBJECTS) $(GLAPI_ASM_OBJECTS) $(MAPI_GLAPI_OBJECTS) + +INCLUDE_DIRS = \ + -I$(TOP)/include \ + -I$(TOP)/src/mapi \ + -I$(TOP)/src/mesa + +default: depend lib$(TARGET).a + +lib$(TARGET).a: $(TARGET_OBJECTS) + @$(MKLIB) -o $(TARGET) -static $(TARGET_OBJECTS) + +$(GLAPI_OBJECTS): %.o: %.c + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ + +$(GLAPI_ASM_OBJECTS): %.o: %.S + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ + +$(MAPI_GLAPI_OBJECTS): %.o: $(MAPI)/%.c + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) -DMAPI_GLAPI_CURRENT $< -o $@ + +install: + +clean: + -rm -f $(TARGET_OBJECTS) + -rm -f lib$(TARGET).a + -rm -f depend depend.bak + +depend: $(GLAPI_SOURCES) $(MAPI_GLAPI_SOURCES) + @ echo "running $(MKDEP)" + @ touch depend + @$(MKDEP) $(MKDEP_OPTIONS) -f- $(DEFINES) $(INCLUDE_DIRS) \ + -DMAPI_GLAPI_CURRENT $(GLAPI_SOURCES) $(MAPI_GLAPI_SOURCES) \ + 2>/dev/null | sed -e 's,^$(MAPI)/,,' > depend + +-include depend diff --git a/src/mapi/glapi/SConscript b/src/mapi/glapi/SConscript new file mode 100644 index 00000000000..15c08255c39 --- /dev/null +++ b/src/mapi/glapi/SConscript @@ -0,0 +1,72 @@ +####################################################################### +# SConscript for Mesa + + +Import('*') + +if env['platform'] != 'winddk': + + env = env.Clone() + + env.Append(CPPDEFINES = [ + 'MAPI_GLAPI_CURRENT', + ]) + + env.Append(CPPPATH = [ + '#/src/mapi', + '#/src/mesa', + ]) + + glapi_sources = [ + 'glapi_dispatch.c', + 'glapi_entrypoint.c', + 'glapi_getproc.c', + 'glapi_nop.c', + 'glthread.c', + ] + + glapi_sources += [ + '../mapi/u_current.c', + '../mapi/u_execmem.c', + '../mapi/u_thread.c', + ] + + # + # Assembly sources + # + if gcc and env['machine'] == 'x86': + env.Append(CPPDEFINES = [ + 'USE_X86_ASM', + 'USE_MMX_ASM', + 'USE_3DNOW_ASM', + 'USE_SSE_ASM', + ]) + glapi_sources += [ + 'glapi_x86.S', + ] + elif gcc and env['machine'] == 'x86_64': + env.Append(CPPDEFINES = [ + 'USE_X86_64_ASM', + ]) + glapi_sources += [ + 'glapi_x86-64.S' + ] + elif gcc and env['machine'] == 'ppc': + env.Append(CPPDEFINES = [ + 'USE_PPC_ASM', + 'USE_VMX_ASM', + ]) + glapi_sources += [ + ] + elif gcc and env['machine'] == 'sparc': + glapi_sources += [ + 'glapi_sparc.S' + ] + else: + pass + + glapi = env.ConvenienceLibrary( + target = 'glapi', + source = glapi_sources, + ) + Export('glapi') diff --git a/src/mesa/es/glapi/Makefile b/src/mapi/glapi/gen-es/Makefile index fea55594fda..bda8e9ef729 100644 --- a/src/mesa/es/glapi/Makefile +++ b/src/mapi/glapi/gen-es/Makefile @@ -1,5 +1,5 @@ TOP = ../../../.. -GLAPI = ../../glapi/gen +GLAPI = ../gen include $(TOP)/configs/current OUTPUTS := \ @@ -8,9 +8,9 @@ OUTPUTS := \ glapi/glapitable.h \ glapi/glapitemp.h \ glapi/glprocs.h \ - sparc/glapi_sparc.S \ - x86-64/glapi_x86-64.S \ - x86/glapi_x86.S \ + glapi/glapi_sparc.S \ + glapi/glapi_x86-64.S \ + glapi/glapi_x86.S \ main/remap_helper.h COMMON = gl_XML.py glX_XML.py license.py typeexpr.py @@ -18,8 +18,8 @@ COMMON := $(addprefix $(GLAPI)/, $(COMMON)) ES1_APIXML := es1_API.xml ES2_APIXML := es2_API.xml -ES1_OUTPUT_DIR := glapi-es1 -ES2_OUTPUT_DIR := glapi-es2 +ES1_OUTPUT_DIR := $(TOP)/src/mapi/es1api +ES2_OUTPUT_DIR := $(TOP)/src/mapi/es2api ES1_DEPS = $(ES1_APIXML) base1_API.xml es1_EXT.xml es_EXT.xml \ es1_COMPAT.xml es_COMPAT.xml @@ -59,13 +59,13 @@ endef %/glprocs.h: $(GLAPI)/gl_procs.py $(COMMON) $(call gen-glapi,-c) -%/sparc/glapi_sparc.S: $(GLAPI)/gl_SPARC_asm.py $(COMMON) +%/glapi_sparc.S: $(GLAPI)/gl_SPARC_asm.py $(COMMON) $(call gen-glapi) -%/x86-64/glapi_x86-64.S: $(GLAPI)/gl_x86-64_asm.py $(COMMON) +%/glapi_x86-64.S: $(GLAPI)/gl_x86-64_asm.py $(COMMON) $(call gen-glapi) -%/x86/glapi_x86.S: $(GLAPI)/gl_x86_asm.py $(COMMON) +%/glapi_x86.S: $(GLAPI)/gl_x86_asm.py $(COMMON) $(call gen-glapi) %/main/remap_helper.h: $(GLAPI)/remap_helper.py $(COMMON) @@ -84,6 +84,13 @@ verify_xml: @$(PYTHON2) $(PYTHON_FLAGS) gl_compare.py difference tmp.xml es2_API.xml @rm -f tmp.xml -clean: - -rm -rf $(ES1_OUTPUT_DIR) $(ES2_OUTPUT_DIR) +clean-es1: + -rm -rf $(ES1_OUTPUT_DIR)/glapi + -rm -rf $(ES1_OUTPUT_DIR)/main + +clean-es2: + -rm -rf $(ES2_OUTPUT_DIR)/glapi + -rm -rf $(ES2_OUTPUT_DIR)/main + +clean: clean-es1 clean-es2 -rm -f *~ *.pyc *.pyo diff --git a/src/mesa/es/glapi/base1_API.xml b/src/mapi/glapi/gen-es/base1_API.xml index 72e41282726..720be257ca2 100644 --- a/src/mesa/es/glapi/base1_API.xml +++ b/src/mapi/glapi/gen-es/base1_API.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE OpenGLAPI SYSTEM "../../glapi/gen/gl_API.dtd"> +<!DOCTYPE OpenGLAPI SYSTEM "../gen/gl_API.dtd"> <!-- OpenGL and OpenGL ES 1.x APIs This file defines the base categories that can be shared by all APIs. diff --git a/src/mesa/es/glapi/base2_API.xml b/src/mapi/glapi/gen-es/base2_API.xml index 5657b8e775e..b59ef62de64 100644 --- a/src/mesa/es/glapi/base2_API.xml +++ b/src/mapi/glapi/gen-es/base2_API.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE OpenGLAPI SYSTEM "../../glapi/gen/gl_API.dtd"> +<!DOCTYPE OpenGLAPI SYSTEM "../gen/gl_API.dtd"> <!-- OpenGL and OpenGL ES 2.x APIs --> diff --git a/src/mesa/es/glapi/es1_API.xml b/src/mapi/glapi/gen-es/es1_API.xml index 1ac14674583..3428ae5616a 100644 --- a/src/mesa/es/glapi/es1_API.xml +++ b/src/mapi/glapi/gen-es/es1_API.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE OpenGLAPI SYSTEM "../../glapi/gen/gl_API.dtd"> +<!DOCTYPE OpenGLAPI SYSTEM "../gen/gl_API.dtd"> <!-- OpenGL ES 1.x API --> diff --git a/src/mesa/es/glapi/es1_COMPAT.xml b/src/mapi/glapi/gen-es/es1_COMPAT.xml index 1f45a8c0b64..096cea88d6f 100644 --- a/src/mesa/es/glapi/es1_COMPAT.xml +++ b/src/mapi/glapi/gen-es/es1_COMPAT.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE OpenGLAPI SYSTEM "../../glapi/gen/gl_API.dtd"> +<!DOCTYPE OpenGLAPI SYSTEM "../gen/gl_API.dtd"> <OpenGLAPI> diff --git a/src/mesa/es/glapi/es1_EXT.xml b/src/mapi/glapi/gen-es/es1_EXT.xml index d4abd81046b..c1e86373d8b 100644 --- a/src/mesa/es/glapi/es1_EXT.xml +++ b/src/mapi/glapi/gen-es/es1_EXT.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE OpenGLAPI SYSTEM "../../glapi/gen/gl_API.dtd"> +<!DOCTYPE OpenGLAPI SYSTEM "../gen/gl_API.dtd"> <!-- OpenGL ES 1.x extensions --> diff --git a/src/mesa/es/glapi/es2_API.xml b/src/mapi/glapi/gen-es/es2_API.xml index b476dbe00f2..f8af63b94fe 100644 --- a/src/mesa/es/glapi/es2_API.xml +++ b/src/mapi/glapi/gen-es/es2_API.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE OpenGLAPI SYSTEM "../../glapi/gen/gl_API.dtd"> +<!DOCTYPE OpenGLAPI SYSTEM "../gen/gl_API.dtd"> <!-- OpenGL ES 2.x API --> diff --git a/src/mesa/es/glapi/es2_COMPAT.xml b/src/mapi/glapi/gen-es/es2_COMPAT.xml index 5ecd4a1ba6e..1bd3569635b 100644 --- a/src/mesa/es/glapi/es2_COMPAT.xml +++ b/src/mapi/glapi/gen-es/es2_COMPAT.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE OpenGLAPI SYSTEM "../../glapi/gen/gl_API.dtd"> +<!DOCTYPE OpenGLAPI SYSTEM "../gen/gl_API.dtd"> <OpenGLAPI> diff --git a/src/mesa/es/glapi/es2_EXT.xml b/src/mapi/glapi/gen-es/es2_EXT.xml index dcf9858569f..4a67952e5c3 100644 --- a/src/mesa/es/glapi/es2_EXT.xml +++ b/src/mapi/glapi/gen-es/es2_EXT.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE OpenGLAPI SYSTEM "../../glapi/gen/gl_API.dtd"> +<!DOCTYPE OpenGLAPI SYSTEM "../gen/gl_API.dtd"> <!-- OpenGL ES 2.x extensions --> diff --git a/src/mesa/es/glapi/es_COMPAT.xml b/src/mapi/glapi/gen-es/es_COMPAT.xml index 1bd66dad306..7c729261105 100644 --- a/src/mesa/es/glapi/es_COMPAT.xml +++ b/src/mapi/glapi/gen-es/es_COMPAT.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE OpenGLAPI SYSTEM "../../glapi/gen/gl_API.dtd"> +<!DOCTYPE OpenGLAPI SYSTEM "../gen/gl_API.dtd"> <OpenGLAPI> @@ -2641,6 +2641,6 @@ </function> </category> -<xi:include href="../../glapi/gen/APPLE_vertex_array_object.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> +<xi:include href="../gen/APPLE_vertex_array_object.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> </OpenGLAPI> diff --git a/src/mesa/es/glapi/es_EXT.xml b/src/mapi/glapi/gen-es/es_EXT.xml index 291a53b4b27..113d8d74ddd 100644 --- a/src/mesa/es/glapi/es_EXT.xml +++ b/src/mapi/glapi/gen-es/es_EXT.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE OpenGLAPI SYSTEM "../../glapi/gen/gl_API.dtd"> +<!DOCTYPE OpenGLAPI SYSTEM "../gen/gl_API.dtd"> <!-- OpenGL ES extensions --> @@ -19,7 +19,7 @@ </category> <!-- 23. GL_OES_EGL_image --> -<xi:include href="../../glapi/gen/OES_EGL_image.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> +<xi:include href="../gen/OES_EGL_image.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <category name="GL_OES_depth24" number="24"> <enum name="DEPTH_COMPONENT24_OES" value="0x81A6"/> diff --git a/src/mesa/es/glapi/gl_compare.py b/src/mapi/glapi/gen-es/gl_compare.py index 6b5e43bb98b..6b5e43bb98b 100644 --- a/src/mesa/es/glapi/gl_compare.py +++ b/src/mapi/glapi/gen-es/gl_compare.py diff --git a/src/mesa/es/glapi/gl_parse_header.py b/src/mapi/glapi/gen-es/gl_parse_header.py index 5382eba35c3..5382eba35c3 100644 --- a/src/mesa/es/glapi/gl_parse_header.py +++ b/src/mapi/glapi/gen-es/gl_parse_header.py diff --git a/src/mesa/glapi/gen/APPLE_object_purgeable.xml b/src/mapi/glapi/gen/APPLE_object_purgeable.xml index 62fa64ad212..62fa64ad212 100644 --- a/src/mesa/glapi/gen/APPLE_object_purgeable.xml +++ b/src/mapi/glapi/gen/APPLE_object_purgeable.xml diff --git a/src/mesa/glapi/gen/APPLE_vertex_array_object.xml b/src/mapi/glapi/gen/APPLE_vertex_array_object.xml index bd8427eaf62..bd8427eaf62 100644 --- a/src/mesa/glapi/gen/APPLE_vertex_array_object.xml +++ b/src/mapi/glapi/gen/APPLE_vertex_array_object.xml diff --git a/src/mesa/glapi/gen/ARB_copy_buffer.xml b/src/mapi/glapi/gen/ARB_copy_buffer.xml index 719816d817e..719816d817e 100644 --- a/src/mesa/glapi/gen/ARB_copy_buffer.xml +++ b/src/mapi/glapi/gen/ARB_copy_buffer.xml diff --git a/src/mesa/glapi/gen/ARB_depth_clamp.xml b/src/mapi/glapi/gen/ARB_depth_clamp.xml index 157c9a86b12..157c9a86b12 100644 --- a/src/mesa/glapi/gen/ARB_depth_clamp.xml +++ b/src/mapi/glapi/gen/ARB_depth_clamp.xml diff --git a/src/mesa/glapi/gen/ARB_draw_elements_base_vertex.xml b/src/mapi/glapi/gen/ARB_draw_elements_base_vertex.xml index f4067f4c8dd..f4067f4c8dd 100644 --- a/src/mesa/glapi/gen/ARB_draw_elements_base_vertex.xml +++ b/src/mapi/glapi/gen/ARB_draw_elements_base_vertex.xml diff --git a/src/mesa/glapi/gen/ARB_draw_instanced.xml b/src/mapi/glapi/gen/ARB_draw_instanced.xml index 5741a588c9f..5741a588c9f 100644 --- a/src/mesa/glapi/gen/ARB_draw_instanced.xml +++ b/src/mapi/glapi/gen/ARB_draw_instanced.xml diff --git a/src/mesa/glapi/gen/ARB_framebuffer_object.xml b/src/mapi/glapi/gen/ARB_framebuffer_object.xml index e6bdcd6e509..e6bdcd6e509 100644 --- a/src/mesa/glapi/gen/ARB_framebuffer_object.xml +++ b/src/mapi/glapi/gen/ARB_framebuffer_object.xml diff --git a/src/mesa/glapi/gen/ARB_map_buffer_range.xml b/src/mapi/glapi/gen/ARB_map_buffer_range.xml index afcb9b6ba6d..afcb9b6ba6d 100644 --- a/src/mesa/glapi/gen/ARB_map_buffer_range.xml +++ b/src/mapi/glapi/gen/ARB_map_buffer_range.xml diff --git a/src/mesa/glapi/gen/ARB_seamless_cube_map.xml b/src/mapi/glapi/gen/ARB_seamless_cube_map.xml index 8dc827c5a89..8dc827c5a89 100644 --- a/src/mesa/glapi/gen/ARB_seamless_cube_map.xml +++ b/src/mapi/glapi/gen/ARB_seamless_cube_map.xml diff --git a/src/mesa/glapi/gen/ARB_sync.xml b/src/mapi/glapi/gen/ARB_sync.xml index 4e4eebac32a..4e4eebac32a 100644 --- a/src/mesa/glapi/gen/ARB_sync.xml +++ b/src/mapi/glapi/gen/ARB_sync.xml diff --git a/src/mesa/glapi/gen/ARB_vertex_array_object.xml b/src/mapi/glapi/gen/ARB_vertex_array_object.xml index 3b4ab64f557..3b4ab64f557 100644 --- a/src/mesa/glapi/gen/ARB_vertex_array_object.xml +++ b/src/mapi/glapi/gen/ARB_vertex_array_object.xml diff --git a/src/mesa/glapi/gen/EXT_draw_buffers2.xml b/src/mapi/glapi/gen/EXT_draw_buffers2.xml index efbe61f74ed..efbe61f74ed 100644 --- a/src/mesa/glapi/gen/EXT_draw_buffers2.xml +++ b/src/mapi/glapi/gen/EXT_draw_buffers2.xml diff --git a/src/mesa/glapi/gen/EXT_framebuffer_object.xml b/src/mapi/glapi/gen/EXT_framebuffer_object.xml index 4f418f7b64c..4f418f7b64c 100644 --- a/src/mesa/glapi/gen/EXT_framebuffer_object.xml +++ b/src/mapi/glapi/gen/EXT_framebuffer_object.xml diff --git a/src/mesa/glapi/gen/EXT_packed_depth_stencil.xml b/src/mapi/glapi/gen/EXT_packed_depth_stencil.xml index 5be810302f3..5be810302f3 100644 --- a/src/mesa/glapi/gen/EXT_packed_depth_stencil.xml +++ b/src/mapi/glapi/gen/EXT_packed_depth_stencil.xml diff --git a/src/mesa/glapi/gen/EXT_provoking_vertex.xml b/src/mapi/glapi/gen/EXT_provoking_vertex.xml index 71d2c729091..71d2c729091 100644 --- a/src/mesa/glapi/gen/EXT_provoking_vertex.xml +++ b/src/mapi/glapi/gen/EXT_provoking_vertex.xml diff --git a/src/mesa/glapi/gen/EXT_texture_array.xml b/src/mapi/glapi/gen/EXT_texture_array.xml index b5b8bd406f7..b5b8bd406f7 100644 --- a/src/mesa/glapi/gen/EXT_texture_array.xml +++ b/src/mapi/glapi/gen/EXT_texture_array.xml diff --git a/src/mesa/glapi/gen/EXT_transform_feedback.xml b/src/mapi/glapi/gen/EXT_transform_feedback.xml index abbed9b25b3..06deafce4ea 100644 --- a/src/mesa/glapi/gen/EXT_transform_feedback.xml +++ b/src/mapi/glapi/gen/EXT_transform_feedback.xml @@ -120,4 +120,44 @@ </category> +<category name="GL_ARB_transform_feedback2" number="93"> + + <enum name="TRANSFORM_FEEDBACK" value="0x8E22"/> + <enum name="TRANSFORM_FEEDBACK_BUFFER_PAUSED" value="0x8E23"/> + <enum name="TRANSFORM_FEEDBACK_BUFFER_ACTIVE" value="0x8E24"/> + <enum name="TRANSFORM_FEEDBACK_BINDING" value="0x8E25"/> + + <function name="BindTransformFeedback" offset="assign"> + <param name="target" type="GLenum"/> + <param name="id" type="GLuint"/> + </function> + + <function name="DeleteTransformFeedbacks" offset="assign"> + <param name="n" type="GLsizei"/> + <param name="ids" type="const GLuint *"/> + </function> + + <function name="GenTransformFeedbacks" offset="assign"> + <param name="n" type="GLsizei"/> + <param name="ids" type="GLuint *"/> + </function> + + <function name="IsTransformFeedback" offset="assign"> + <param name="id" type="GLuint"/> + <return type="GLboolean"/> + </function> + + <function name="PauseTransformFeedback" offset="assign"> + </function> + + <function name="ResumeTransformFeedback" offset="assign"> + </function> + + <function name="DrawTransformFeedback" offset="assign"> + <param name="mode" type="GLenum"/> + <param name="id" type="GLuint"/> + </function> + +</category> + </OpenGLAPI> diff --git a/src/mesa/glapi/gen/GL3.xml b/src/mapi/glapi/gen/GL3.xml index 0d8d935f0ae..0d8d935f0ae 100644 --- a/src/mesa/glapi/gen/GL3.xml +++ b/src/mapi/glapi/gen/GL3.xml diff --git a/src/mesa/glapi/gen/Makefile b/src/mapi/glapi/gen/Makefile index 10998b2ce23..daa0a48ddae 100644 --- a/src/mesa/glapi/gen/Makefile +++ b/src/mapi/glapi/gen/Makefile @@ -8,7 +8,7 @@ TOP = ../../../.. include $(TOP)/configs/current MESA_DIR = $(TOP)/src/mesa -MESA_GLAPI_DIR = $(TOP)/src/mesa/glapi +MESA_GLAPI_DIR = $(TOP)/src/mapi/glapi MESA_GLX_DIR = $(TOP)/src/glx MESA_GLAPI_OUTPUTS = \ @@ -19,9 +19,9 @@ MESA_GLAPI_OUTPUTS = \ $(MESA_GLAPI_DIR)/glapidispatch.h MESA_GLAPI_ASM_OUTPUTS = \ - $(MESA_DIR)/x86/glapi_x86.S \ - $(MESA_DIR)/x86-64/glapi_x86-64.S \ - $(MESA_DIR)/sparc/glapi_sparc.S + $(MESA_GLAPI_DIR)/glapi_x86.S \ + $(MESA_GLAPI_DIR)/glapi_x86-64.S \ + $(MESA_GLAPI_DIR)/glapi_sparc.S MESA_OUTPUTS = \ $(MESA_GLAPI_OUTPUTS) \ @@ -140,21 +140,21 @@ $(MESA_GLAPI_DIR)/glapidispatch.h: gl_table.py $(COMMON) ###################################################################### -$(MESA_DIR)/x86/glapi_x86.S: gl_x86_asm.py $(COMMON) +$(MESA_GLAPI_DIR)/glapi_x86.S: gl_x86_asm.py $(COMMON) $(PYTHON2) $(PYTHON_FLAGS) $< > $@ -$(MESA_DIR)/x86-64/glapi_x86-64.S: gl_x86-64_asm.py $(COMMON) +$(MESA_GLAPI_DIR)/glapi_x86-64.S: gl_x86-64_asm.py $(COMMON) $(PYTHON2) $(PYTHON_FLAGS) $< > $@ -$(MESA_DIR)/sparc/glapi_sparc.S: gl_SPARC_asm.py $(COMMON) +$(MESA_GLAPI_DIR)/glapi_sparc.S: gl_SPARC_asm.py $(COMMON) $(PYTHON2) $(PYTHON_FLAGS) $< > $@ ###################################################################### $(MESA_DIR)/main/enums.c: gl_enums.py $(COMMON) $(ES_API) $(PYTHON2) $(PYTHON_FLAGS) $< -f gl_API.xml \ - -f $(MESA_DIR)/es/glapi/es1_API.xml \ - -f $(MESA_DIR)/es/glapi/es2_API.xml > $@ + -f $(MESA_GLAPI_DIR)/gen-es/es1_API.xml \ + -f $(MESA_GLAPI_DIR)/gen-es/es2_API.xml > $@ $(MESA_DIR)/main/remap_helper.h: remap_helper.py $(COMMON) $(PYTHON2) $(PYTHON_FLAGS) $< > $@ diff --git a/src/mesa/glapi/gen/NV_conditional_render.xml b/src/mapi/glapi/gen/NV_conditional_render.xml index 8bb31dd1fc9..8bb31dd1fc9 100644 --- a/src/mesa/glapi/gen/NV_conditional_render.xml +++ b/src/mapi/glapi/gen/NV_conditional_render.xml diff --git a/src/mesa/glapi/gen/OES_EGL_image.xml b/src/mapi/glapi/gen/OES_EGL_image.xml index 1cb43d49a41..1cb43d49a41 100644 --- a/src/mesa/glapi/gen/OES_EGL_image.xml +++ b/src/mapi/glapi/gen/OES_EGL_image.xml diff --git a/src/mesa/glapi/gen/extension_helper.py b/src/mapi/glapi/gen/extension_helper.py index 2c83b4e0d10..2c83b4e0d10 100644 --- a/src/mesa/glapi/gen/extension_helper.py +++ b/src/mapi/glapi/gen/extension_helper.py diff --git a/src/mesa/glapi/gen/glX_API.xml b/src/mapi/glapi/gen/glX_API.xml index 9e02aa498ee..9e02aa498ee 100644 --- a/src/mesa/glapi/gen/glX_API.xml +++ b/src/mapi/glapi/gen/glX_API.xml diff --git a/src/mesa/glapi/gen/glX_XML.py b/src/mapi/glapi/gen/glX_XML.py index 4c2e0f95bf4..4c2e0f95bf4 100644 --- a/src/mesa/glapi/gen/glX_XML.py +++ b/src/mapi/glapi/gen/glX_XML.py diff --git a/src/mesa/glapi/gen/glX_doc.py b/src/mapi/glapi/gen/glX_doc.py index e9fbbe6f169..e9fbbe6f169 100644 --- a/src/mesa/glapi/gen/glX_doc.py +++ b/src/mapi/glapi/gen/glX_doc.py diff --git a/src/mesa/glapi/gen/glX_proto_common.py b/src/mapi/glapi/gen/glX_proto_common.py index 6f094e22b31..6f094e22b31 100644 --- a/src/mesa/glapi/gen/glX_proto_common.py +++ b/src/mapi/glapi/gen/glX_proto_common.py diff --git a/src/mesa/glapi/gen/glX_proto_recv.py b/src/mapi/glapi/gen/glX_proto_recv.py index 31745fcef77..31745fcef77 100644 --- a/src/mesa/glapi/gen/glX_proto_recv.py +++ b/src/mapi/glapi/gen/glX_proto_recv.py diff --git a/src/mesa/glapi/gen/glX_proto_send.py b/src/mapi/glapi/gen/glX_proto_send.py index c52b85bfb4f..e7322820738 100644 --- a/src/mesa/glapi/gen/glX_proto_send.py +++ b/src/mapi/glapi/gen/glX_proto_send.py @@ -373,7 +373,7 @@ const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 }; print '{' print ' __GLXcontext * const gc = __glXGetCurrentContext();' print '' - print '#ifdef GLX_DIRECT_RENDERING' + print '#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)' print ' if (gc->driContext) {' print ' %sCALL_%s(GET_DISPATCH(), (%s));' % (ret_string, func.name, func.get_called_parameter_string()) print ' } else' diff --git a/src/mesa/glapi/gen/glX_proto_size.py b/src/mapi/glapi/gen/glX_proto_size.py index 95cb5110cc3..f16ea4c3b68 100644 --- a/src/mesa/glapi/gen/glX_proto_size.py +++ b/src/mapi/glapi/gen/glX_proto_size.py @@ -329,7 +329,7 @@ class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common): self.printVisibility( "INTERNAL", "internal" ) print '' print '' - print '#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__)' + print '#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(GLX_USE_APPLEGL)' print '# undef HAVE_ALIAS' print '#endif' print '#ifdef HAVE_ALIAS' diff --git a/src/mesa/glapi/gen/glX_server_table.py b/src/mapi/glapi/gen/glX_server_table.py index f3962f875b0..f3962f875b0 100644 --- a/src/mesa/glapi/gen/glX_server_table.py +++ b/src/mapi/glapi/gen/glX_server_table.py diff --git a/src/mesa/glapi/gen/gl_API.dtd b/src/mapi/glapi/gen/gl_API.dtd index 30c646c9244..30c646c9244 100644 --- a/src/mesa/glapi/gen/gl_API.dtd +++ b/src/mapi/glapi/gen/gl_API.dtd diff --git a/src/mesa/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index 31df7a5f801..31df7a5f801 100644 --- a/src/mesa/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml diff --git a/src/mesa/glapi/gen/gl_SPARC_asm.py b/src/mapi/glapi/gen/gl_SPARC_asm.py index 33e752df38c..33e752df38c 100644 --- a/src/mesa/glapi/gen/gl_SPARC_asm.py +++ b/src/mapi/glapi/gen/gl_SPARC_asm.py diff --git a/src/mesa/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py index 660c8cfb711..660c8cfb711 100644 --- a/src/mesa/glapi/gen/gl_XML.py +++ b/src/mapi/glapi/gen/gl_XML.py diff --git a/src/mesa/glapi/gen/gl_and_glX_API.xml b/src/mapi/glapi/gen/gl_and_glX_API.xml index 34c977e9c0c..34c977e9c0c 100644 --- a/src/mesa/glapi/gen/gl_and_glX_API.xml +++ b/src/mapi/glapi/gen/gl_and_glX_API.xml diff --git a/src/mesa/glapi/gen/gl_apitemp.py b/src/mapi/glapi/gen/gl_apitemp.py index 41a40fbeb68..41a40fbeb68 100644 --- a/src/mesa/glapi/gen/gl_apitemp.py +++ b/src/mapi/glapi/gen/gl_apitemp.py diff --git a/src/mesa/glapi/gen/gl_enums.py b/src/mapi/glapi/gen/gl_enums.py index 644e0855229..644e0855229 100644 --- a/src/mesa/glapi/gen/gl_enums.py +++ b/src/mapi/glapi/gen/gl_enums.py diff --git a/src/mesa/glapi/gen/gl_offsets.py b/src/mapi/glapi/gen/gl_offsets.py index 54867b34634..54867b34634 100644 --- a/src/mesa/glapi/gen/gl_offsets.py +++ b/src/mapi/glapi/gen/gl_offsets.py diff --git a/src/mesa/glapi/gen/gl_procs.py b/src/mapi/glapi/gen/gl_procs.py index 5de61fbdfe9..5de61fbdfe9 100644 --- a/src/mesa/glapi/gen/gl_procs.py +++ b/src/mapi/glapi/gen/gl_procs.py diff --git a/src/mesa/glapi/gen/gl_table.py b/src/mapi/glapi/gen/gl_table.py index 3bd7569e92a..3bd7569e92a 100644 --- a/src/mesa/glapi/gen/gl_table.py +++ b/src/mapi/glapi/gen/gl_table.py diff --git a/src/mesa/glapi/gen/gl_x86-64_asm.py b/src/mapi/glapi/gen/gl_x86-64_asm.py index e6e78c42f3b..e6e78c42f3b 100644 --- a/src/mesa/glapi/gen/gl_x86-64_asm.py +++ b/src/mapi/glapi/gen/gl_x86-64_asm.py diff --git a/src/mesa/glapi/gen/gl_x86_asm.py b/src/mapi/glapi/gen/gl_x86_asm.py index 10dfa1ddb34..10dfa1ddb34 100644 --- a/src/mesa/glapi/gen/gl_x86_asm.py +++ b/src/mapi/glapi/gen/gl_x86_asm.py diff --git a/src/mesa/glapi/gen/license.py b/src/mapi/glapi/gen/license.py index 02181648e4b..02181648e4b 100644 --- a/src/mesa/glapi/gen/license.py +++ b/src/mapi/glapi/gen/license.py diff --git a/src/mesa/glapi/gen/mesadef.py b/src/mapi/glapi/gen/mesadef.py index 38b0246ba5b..38b0246ba5b 100644 --- a/src/mesa/glapi/gen/mesadef.py +++ b/src/mapi/glapi/gen/mesadef.py diff --git a/src/mesa/glapi/gen/next_available_offset.sh b/src/mapi/glapi/gen/next_available_offset.sh index e7d6c2f4afa..e7d6c2f4afa 100755 --- a/src/mesa/glapi/gen/next_available_offset.sh +++ b/src/mapi/glapi/gen/next_available_offset.sh diff --git a/src/mesa/glapi/gen/remap_helper.py b/src/mapi/glapi/gen/remap_helper.py index 69b8e5e9d02..69b8e5e9d02 100644 --- a/src/mesa/glapi/gen/remap_helper.py +++ b/src/mapi/glapi/gen/remap_helper.py diff --git a/src/mesa/glapi/gen/typeexpr.py b/src/mapi/glapi/gen/typeexpr.py index 8ba7de48627..8ba7de48627 100644 --- a/src/mesa/glapi/gen/typeexpr.py +++ b/src/mapi/glapi/gen/typeexpr.py diff --git a/src/mesa/glapi/glapi.h b/src/mapi/glapi/glapi.h index 7dcf2e8910b..a74884d595a 100644 --- a/src/mesa/glapi/glapi.h +++ b/src/mapi/glapi/glapi.h @@ -44,15 +44,11 @@ #ifndef _GLAPI_H #define _GLAPI_H -#include "glthread.h" - - -struct _glapi_table; - -typedef void (*_glapi_proc)(void); /* generic function pointer */ - +#ifndef MAPI_GLAPI_CURRENT +#define MAPI_GLAPI_CURRENT +#endif -#if defined(USE_MGL_NAMESPACE) +#ifdef USE_MGL_NAMESPACE #define _glapi_set_dispatch _mglapi_set_dispatch #define _glapi_get_dispatch _mglapi_get_dispatch #define _glapi_set_context _mglapi_set_context @@ -61,111 +57,31 @@ typedef void (*_glapi_proc)(void); /* generic function pointer */ #define _glapi_Context _mglapi_Context #endif +#include "mapi/u_current.h" +#include "glapi/glthread.h" -#if defined(__GNUC__) -# define likely(x) __builtin_expect(!!(x), 1) -# define unlikely(x) __builtin_expect(!!(x), 0) -#else -# define likely(x) (x) -# define unlikely(x) (x) -#endif - - -/** - ** Define the GET_DISPATCH() and GET_CURRENT_CONTEXT() macros. - ** - ** \param C local variable which will hold the current context. - **/ -#if defined (GLX_USE_TLS) - -extern const struct _glapi_table *_glapi_Dispatch; - -extern const void *_glapi_Context; - -extern __thread struct _glapi_table * _glapi_tls_Dispatch - __attribute__((tls_model("initial-exec"))); - -extern __thread void * _glapi_tls_Context - __attribute__((tls_model("initial-exec"))); - -# define GET_DISPATCH() _glapi_tls_Dispatch - -# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_tls_Context - -#else - -extern struct _glapi_table *_glapi_Dispatch; - -extern void *_glapi_Context; - -# ifdef THREADS - -# define GET_DISPATCH() \ - (likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch()) - -# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) \ - (likely(_glapi_Context) ? _glapi_Context : _glapi_get_context()) - -# else - -# define GET_DISPATCH() _glapi_Dispatch - -# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context - -# endif - -#endif /* defined (GLX_USE_TLS) */ - - -/** - ** GL API public functions - **/ - -extern void -_glapi_init_multithread(void); - - -extern void -_glapi_destroy_multithread(void); - - -extern void -_glapi_check_multithread(void); - - -extern void -_glapi_set_context(void *context); - - -extern void * -_glapi_get_context(void); - - -extern void -_glapi_set_dispatch(struct _glapi_table *dispatch); - - -extern struct _glapi_table * -_glapi_get_dispatch(void); +typedef void (*_glapi_proc)(void); +#define GET_DISPATCH() ((struct _glapi_table *) u_current_get()) +#define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) u_current_get_user() -extern unsigned int +PUBLIC unsigned int _glapi_get_dispatch_table_size(void); -extern int +PUBLIC int _glapi_add_dispatch( const char * const * function_names, const char * parameter_signature ); -extern int +PUBLIC int _glapi_get_proc_offset(const char *funcName); -extern _glapi_proc +PUBLIC _glapi_proc _glapi_get_proc_address(const char *funcName); -extern const char * +PUBLIC const char * _glapi_get_proc_name(unsigned int offset); diff --git a/src/mesa/glapi/glapi_dispatch.c b/src/mapi/glapi/glapi_dispatch.c index 32b9535e3fc..ae59140ad3a 100644 --- a/src/mesa/glapi/glapi_dispatch.c +++ b/src/mapi/glapi/glapi_dispatch.c @@ -27,8 +27,8 @@ * \file glapi_dispatch.c * * This file generates all the gl* function entrypoints. This code is not - * used if optimized assembly stubs are available (e.g., using x86/glapi_x86.S - * on IA32 or sparc/glapi_sparc.S on SPARC). + * used if optimized assembly stubs are available (e.g., using + * glapi/glapi_x86.S on IA32 or glapi/glapi_sparc.S on SPARC). * * \note * This file is also used to build the client-side libGL that loads DRI-based diff --git a/src/mesa/glapi/glapi_entrypoint.c b/src/mapi/glapi/glapi_entrypoint.c index 239780e7539..82c68c27c8b 100644 --- a/src/mesa/glapi/glapi_entrypoint.c +++ b/src/mapi/glapi/glapi_entrypoint.c @@ -39,6 +39,7 @@ #include "glapi/glapi.h" #include "glapi/glapi_priv.h" +#include "mapi/u_execmem.h" #ifdef USE_X86_ASM @@ -105,7 +106,7 @@ generate_entrypoint(unsigned int functionOffset) */ const GLubyte * const template_func = gl_dispatch_functions_start + (DISPATCH_FUNCTION_SIZE * 32); - GLubyte * const code = (GLubyte *) _glapi_exec_malloc(DISPATCH_FUNCTION_SIZE); + GLubyte * const code = (GLubyte *) u_execmem_alloc(DISPATCH_FUNCTION_SIZE); if ( code != NULL ) { @@ -288,7 +289,7 @@ generate_entrypoint(GLuint functionOffset) extern unsigned int __glapi_sparc_pthread_stub; unsigned long call_dest = (unsigned long ) &__glapi_sparc_pthread_stub; #endif - unsigned int *code = (unsigned int *) _glapi_exec_malloc(sizeof(template)); + unsigned int *code = (unsigned int *) u_execmem_alloc(sizeof(template)); if (code) { code[0] = template[0] | (functionOffset & 0x3fffff); code[1] = template[1]; diff --git a/src/mesa/glapi/glapi_getproc.c b/src/mapi/glapi/glapi_getproc.c index c73e8dd3b04..3c134f929d6 100644 --- a/src/mesa/glapi/glapi_getproc.c +++ b/src/mapi/glapi/glapi_getproc.c @@ -387,7 +387,7 @@ set_entry_info( struct _glapi_function * entry, const char * signature, unsigned * the parameter signature of a static function. */ -PUBLIC int +int _glapi_add_dispatch( const char * const * function_names, const char * parameter_signature ) { @@ -501,7 +501,7 @@ _glapi_add_dispatch( const char * const * function_names, /** * Return offset of entrypoint for named function within dispatch table. */ -PUBLIC GLint +GLint _glapi_get_proc_offset(const char *funcName) { GLint offset; @@ -522,7 +522,7 @@ _glapi_get_proc_offset(const char *funcName) * in the name of static functions, try generating a new API entrypoint on * the fly with assembly language. */ -PUBLIC _glapi_proc +_glapi_proc _glapi_get_proc_address(const char *funcName) { _glapi_proc func; @@ -598,7 +598,7 @@ _glapi_get_proc_name(GLuint offset) * Return size of dispatch table struct as number of functions (or * slots). */ -PUBLIC GLuint +GLuint _glapi_get_dispatch_table_size(void) { return DISPATCH_TABLE_SIZE; diff --git a/src/mesa/glapi/glapi_nop.c b/src/mapi/glapi/glapi_nop.c index 4257b1fbce6..4257b1fbce6 100644 --- a/src/mesa/glapi/glapi_nop.c +++ b/src/mapi/glapi/glapi_nop.c diff --git a/src/mesa/glapi/glapi_priv.h b/src/mapi/glapi/glapi_priv.h index da6fee63fe7..1c2a7042113 100644 --- a/src/mesa/glapi/glapi_priv.h +++ b/src/mapi/glapi/glapi_priv.h @@ -41,12 +41,6 @@ extern void _glapi_check_table(const struct _glapi_table *table); -/* execmem */ - -extern void * -_glapi_exec_malloc(unsigned int size); - - /* entrypoint */ extern void diff --git a/src/mesa/sparc/glapi_sparc.S b/src/mapi/glapi/glapi_sparc.S index e9f887b78f2..e9f887b78f2 100644 --- a/src/mesa/sparc/glapi_sparc.S +++ b/src/mapi/glapi/glapi_sparc.S diff --git a/src/mesa/x86-64/glapi_x86-64.S b/src/mapi/glapi/glapi_x86-64.S index 96930162175..96930162175 100644 --- a/src/mesa/x86-64/glapi_x86-64.S +++ b/src/mapi/glapi/glapi_x86-64.S diff --git a/src/mesa/x86/glapi_x86.S b/src/mapi/glapi/glapi_x86.S index 317f595454a..317f595454a 100644 --- a/src/mesa/x86/glapi_x86.S +++ b/src/mapi/glapi/glapi_x86.S diff --git a/src/mesa/glapi/glapidispatch.h b/src/mapi/glapi/glapidispatch.h index f66876fe8d2..f66876fe8d2 100644 --- a/src/mesa/glapi/glapidispatch.h +++ b/src/mapi/glapi/glapidispatch.h diff --git a/src/mesa/glapi/glapioffsets.h b/src/mapi/glapi/glapioffsets.h index a8133b40737..a8133b40737 100644 --- a/src/mesa/glapi/glapioffsets.h +++ b/src/mapi/glapi/glapioffsets.h diff --git a/src/mesa/glapi/glapitable.h b/src/mapi/glapi/glapitable.h index faf274f2704..faf274f2704 100644 --- a/src/mesa/glapi/glapitable.h +++ b/src/mapi/glapi/glapitable.h diff --git a/src/mesa/glapi/glapitemp.h b/src/mapi/glapi/glapitemp.h index 3ed337f8254..92835b9afc2 100644 --- a/src/mesa/glapi/glapitemp.h +++ b/src/mapi/glapi/glapitemp.h @@ -27,7 +27,7 @@ */ -# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) && defined(__ELF__) +# if (defined(__GNUC__) && !defined(__MINGW32__)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) && defined(__ELF__) # define HIDDEN __attribute__((visibility("hidden"))) # else # define HIDDEN diff --git a/src/mesa/glapi/glprocs.h b/src/mapi/glapi/glprocs.h index 8eb04ee6781..8eb04ee6781 100644 --- a/src/mesa/glapi/glprocs.h +++ b/src/mapi/glapi/glprocs.h diff --git a/src/mapi/glapi/glthread.c b/src/mapi/glapi/glthread.c new file mode 100644 index 00000000000..9dbc0e9a56f --- /dev/null +++ b/src/mapi/glapi/glthread.c @@ -0,0 +1,7 @@ +#include "glthread.h" + +unsigned long +_glthread_GetID(void) +{ + return u_thread_self(); +} diff --git a/src/mapi/glapi/glthread.h b/src/mapi/glapi/glthread.h new file mode 100644 index 00000000000..54292706acf --- /dev/null +++ b/src/mapi/glapi/glthread.h @@ -0,0 +1,23 @@ +#ifndef GLTHREAD_H +#define GLTHREAD_H + +#include "mapi/u_thread.h" + +#define _glthread_DECLARE_STATIC_MUTEX(name) u_mutex_declare_static(name) +#define _glthread_INIT_MUTEX(name) u_mutex_init(name) +#define _glthread_DESTROY_MUTEX(name) u_mutex_destroy(name) +#define _glthread_LOCK_MUTEX(name) u_mutex_lock(name) +#define _glthread_UNLOCK_MUTEX(name) u_mutex_unlock(name) + +#define _glthread_InitTSD(tsd) u_tsd_init(tsd); +#define _glthread_DestroyTSD(tsd) u_tsd_destroy(tsd); +#define _glthread_GetTSD(tsd) u_tsd_get(tsd); +#define _glthread_SetTSD(tsd, ptr) u_tsd_set(tsd, ptr); + +typedef struct u_tsd _glthread_TSD; +typedef u_mutex _glthread_Mutex; + +PUBLIC unsigned long +_glthread_GetID(void); + +#endif /* THREADS_H */ diff --git a/src/mapi/glapi/sources.mak b/src/mapi/glapi/sources.mak new file mode 100644 index 00000000000..cdcfa36e51f --- /dev/null +++ b/src/mapi/glapi/sources.mak @@ -0,0 +1,17 @@ +# src/mapi/glapi/sources.mak + +GLAPI_SOURCES = \ + glapi_dispatch.c \ + glapi_entrypoint.c \ + glapi_getproc.c \ + glapi_nop.c \ + glthread.c + +X86_API = \ + glapi_x86.S + +X86-64_API = \ + glapi_x86-64.S + +SPARC_API = \ + glapi_sparc.S diff --git a/src/mapi/mapi/entry.c b/src/mapi/mapi/entry.c new file mode 100644 index 00000000000..fdf2a89c52f --- /dev/null +++ b/src/mapi/mapi/entry.c @@ -0,0 +1,65 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#include "entry.h" + +#if defined(USE_X86_ASM) && defined(__GNUC__) +# ifdef GLX_USE_TLS +# include "entry_x86_tls.h" +# else +# include "entry_x86_tsd.h" +# endif +#elif defined(USE_X86_64_ASM) && defined(__GNUC__) && defined(GLX_USE_TLS) +# include "entry_x86-64_tls.h" +#else + +#include <stdlib.h> +#include "u_current.h" +#include "table.h" + +/* C version of the public entries */ +#define MAPI_TMP_PUBLIC_ENTRIES +#include "mapi_tmp.h" + +void +entry_patch_public(void) +{ +} + +mapi_func +entry_generate(int slot) +{ + return NULL; +} + +void +entry_patch(mapi_func entry, int slot) +{ +} + +#endif /* asm */ diff --git a/src/mapi/mapi/entry.h b/src/mapi/mapi/entry.h new file mode 100644 index 00000000000..48ed3f9ec4a --- /dev/null +++ b/src/mapi/mapi/entry.h @@ -0,0 +1,49 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#ifndef _ENTRY_H_ +#define _ENTRY_H_ + +#include "u_compiler.h" +#include "stub.h" + +/* declare public entries */ +#define MAPI_TMP_DEFINES +#define MAPI_TMP_PUBLIC_DECLARES +#include "mapi_tmp.h" + +void +entry_patch_public(void); + +mapi_func +entry_generate(int slot); + +void +entry_patch(mapi_func entry, int slot); + +#endif /* _ENTRY_H_ */ diff --git a/src/mapi/mapi/entry_x86-64_tls.h b/src/mapi/mapi/entry_x86-64_tls.h new file mode 100644 index 00000000000..d4c9907b895 --- /dev/null +++ b/src/mapi/mapi/entry_x86-64_tls.h @@ -0,0 +1,97 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#include <string.h> +#include "u_execmem.h" +#include "u_macros.h" + +__asm__(".text"); + +__asm__("x86_64_current_tls:\n\t" + "movq _glapi_tls_Dispatch@GOTTPOFF(%rip), %rax\n\t" + "ret"); + +#define STUB_ASM_ENTRY(func) \ + ".globl " func "\n" \ + ".type " func ", @function\n" \ + ".balign 32\n" \ + func ":" + +#define STUB_ASM_CODE(slot) \ + "movq _glapi_tls_Dispatch@GOTTPOFF(%rip), %rax\n\t" \ + "movq %fs:(%rax), %r11\n\t" \ + "jmp *(8 * " slot ")(%r11)" + +#define MAPI_TMP_STUB_ASM_GCC +#include "mapi_tmp.h" + +extern unsigned long +x86_64_current_tls(); + +void +entry_patch_public(void) +{ +} + +void +entry_patch(mapi_func entry, int slot) +{ + void *code = (void *) entry; + *((unsigned int *) (code + 12)) = slot * sizeof(mapi_func); +} + +mapi_func +entry_generate(int slot) +{ + const char code_templ[16] = { + /* movq %fs:0, %r11 */ + 0x64, 0x4c, 0x8b, 0x1c, 0x25, 0x00, 0x00, 0x00, 0x00, + /* jmp *0x1234(%r11) */ + 0x41, 0xff, 0xa3, 0x34, 0x12, 0x00, 0x00, + }; + unsigned long addr; + void *code; + mapi_func entry; + + addr = x86_64_current_tls(); + if ((addr >> 32) != 0xffffffff) + return NULL; + addr &= 0xffffffff; + + code = u_execmem_alloc(sizeof(code_templ)); + if (!code) + return NULL; + + memcpy(code, code_templ, sizeof(code_templ)); + + *((unsigned int *) (code + 5)) = addr; + entry = (mapi_func) code; + entry_patch(entry, slot); + + return entry; +} diff --git a/src/mapi/mapi/entry_x86_tls.h b/src/mapi/mapi/entry_x86_tls.h new file mode 100644 index 00000000000..de0498181de --- /dev/null +++ b/src/mapi/mapi/entry_x86_tls.h @@ -0,0 +1,120 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#include <string.h> +#include "u_execmem.h" +#include "u_macros.h" + +__asm__(".text"); + +__asm__("x86_current_tls:\n\t" + "call 1f\n" + "1:\n\t" + "popl %eax\n\t" + "addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax\n\t" + "movl _glapi_tls_Dispatch@GOTNTPOFF(%eax), %eax\n\t" + "ret"); + +#ifndef GLX_X86_READONLY_TEXT +__asm__(".section wtext, \"awx\", @progbits\n" + ".balign 16\n" + "x86_entry_start:"); +#endif /* GLX_X86_READONLY_TEXT */ + +#define STUB_ASM_ENTRY(func) \ + ".globl " func "\n" \ + ".type " func ", @function\n" \ + ".balign 16\n" \ + func ":" + +#define STUB_ASM_CODE(slot) \ + "call x86_current_tls\n\t" \ + "movl %gs:(%eax), %eax\n\t" \ + "jmp *(4 * " slot ")(%eax)" + +#define MAPI_TMP_STUB_ASM_GCC +#include "mapi_tmp.h" + +#ifndef GLX_X86_READONLY_TEXT +__asm__(".balign 16\n" + "x86_entry_end:"); +__asm__(".text"); +#endif /* GLX_X86_READONLY_TEXT */ + +extern unsigned long +x86_current_tls(); + +void +entry_patch_public(void) +{ +#ifndef GLX_X86_READONLY_TEXT + extern char x86_entry_start[]; + extern char x86_entry_end[]; + char patch[8] = { + 0x65, 0xa1, 0x00, 0x00, 0x00, 0x00, /* movl %gs:0x0, %eax */ + 0x90, 0x90 /* nop's */ + }; + char *entry; + + *((unsigned long *) (patch + 2)) = x86_current_tls(); + + for (entry = x86_entry_start; entry < x86_entry_end; entry += 16) + memcpy(entry, patch, sizeof(patch)); +#endif +} + +void +entry_patch(mapi_func entry, int slot) +{ + void *code = (void *) entry; + *((unsigned long *) (code + 8)) = slot * sizeof(mapi_func); +} + +mapi_func +entry_generate(int slot) +{ + const char code_templ[16] = { + 0x65, 0xa1, 0x00, 0x00, 0x00, 0x00, /* movl %gs:0x0, %eax */ + 0xff, 0xa0, 0x34, 0x12, 0x00, 0x00, /* jmp *0x1234(%eax) */ + 0x90, 0x90, 0x90, 0x90 /* nop's */ + }; + void *code; + mapi_func entry; + + code = u_execmem_alloc(sizeof(code_templ)); + if (!code) + return NULL; + + memcpy(code, code_templ, sizeof(code_templ)); + + *((unsigned long *) (code + 2)) = x86_current_tls(); + entry = (mapi_func) code; + entry_patch(entry, slot); + + return entry; +} diff --git a/src/mapi/mapi/entry_x86_tsd.h b/src/mapi/mapi/entry_x86_tsd.h new file mode 100644 index 00000000000..d31e0676f07 --- /dev/null +++ b/src/mapi/mapi/entry_x86_tsd.h @@ -0,0 +1,89 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#include <string.h> +#include "u_execmem.h" +#include "u_macros.h" + +#define X86_ENTRY_SIZE 32 + +__asm__(".text"); + +#define STUB_ASM_ENTRY(func) \ + ".globl " func "\n" \ + ".type " func ", @function\n" \ + ".balign 32\n" \ + func ":" + +#define STUB_ASM_CODE(slot) \ + "movl _glapi_Dispatch, %eax\n\t" \ + "testl %eax, %eax\n\t" \ + "je 1f\n\t" \ + "jmp *(4 * " slot ")(%eax)\n" \ + "1:\n\t" \ + "call _glapi_get_dispatch\n\t" \ + "jmp *(4 * " slot ")(%eax)" + +#define MAPI_TMP_STUB_ASM_GCC +#include "mapi_tmp.h" + +__asm__(".balign 32\n" + "x86_entry_end:"); + +void +entry_patch_public(void) +{ +} + +void +entry_patch(mapi_func entry, int slot) +{ + void *code = (void *) entry; + + *((unsigned long *) (code + 11)) = slot * sizeof(mapi_func); + *((unsigned long *) (code + 22)) = slot * sizeof(mapi_func); +} + +mapi_func +entry_generate(int slot) +{ + extern const char x86_entry_end[]; + const char *code_templ = x86_entry_end - X86_ENTRY_SIZE; + void *code; + mapi_func entry; + + code = u_execmem_alloc(X86_ENTRY_SIZE); + if (!code) + return NULL; + + memcpy(code, code_templ, X86_ENTRY_SIZE); + entry = (mapi_func) code; + entry_patch(entry, slot); + + return entry; +} diff --git a/src/mapi/mapi/mapi.c b/src/mapi/mapi/mapi.c new file mode 100644 index 00000000000..2f1c3fff6cc --- /dev/null +++ b/src/mapi/mapi/mapi.c @@ -0,0 +1,191 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#include <stdlib.h> +#include <string.h> + +#include "u_current.h" +#include "u_thread.h" +#include "mapi.h" +#include "stub.h" +#include "table.h" + +/* dynamic stubs will run out before this array */ +#define MAPI_MAX_STUBS (sizeof(struct mapi_table) / sizeof(mapi_func)) +static const struct mapi_stub *mapi_stub_map[MAPI_MAX_STUBS]; +static int mapi_num_stubs; + +static const struct mapi_stub * +get_stub(const char *name, const struct mapi_stub *alias) +{ + const struct mapi_stub *stub; + + stub = stub_find_public(name); + if (!stub) { + struct mapi_stub *dyn = stub_find_dynamic(name, 1); + if (dyn) { + stub_fix_dynamic(dyn, alias); + stub = dyn; + } + } + + return stub; +} + +/** + * Initialize mapi. spec consists of NULL-separated strings. The first string + * denotes the version. It is followed by variable numbers of entries. Each + * entry can have multiple names. An empty name terminates an entry. An empty + * entry terminates the spec. A spec of two entries, Foo and Bar, is as + * follows + * + * "1\0" + * "Foo\0" + * "FooEXT\0" + * "\0" + * "Bar\0" + * "\0" + */ +void +mapi_init(const char *spec) +{ + u_mutex_declare_static(mutex); + const char *p; + int ver, count; + + u_mutex_lock(mutex); + + /* already initialized */ + if (mapi_num_stubs) { + u_mutex_unlock(mutex); + return; + } + + count = 0; + p = spec; + + /* parse version string */ + ver = atoi(p); + if (ver != 1) { + u_mutex_unlock(mutex); + return; + } + p += strlen(p) + 1; + + while (*p) { + const struct mapi_stub *stub; + + stub = get_stub(p, NULL); + /* out of dynamic entries */ + if (!stub) + break; + p += strlen(p) + 1; + + while (*p) { + get_stub(p, stub); + p += strlen(p) + 1; + } + + mapi_stub_map[count++] = stub; + p++; + } + + mapi_num_stubs = count; + + u_mutex_unlock(mutex); +} + +/** + * Return the address of an entry. Optionally generate the entry if it does + * not exist. + */ +mapi_proc +mapi_get_proc_address(const char *name) +{ + const struct mapi_stub *stub; + + stub = stub_find_public(name); + if (!stub) + stub = stub_find_dynamic(name, 0); + + return (stub) ? (mapi_proc) stub->addr : NULL; +} + +/** + * Create a dispatch table. + */ +struct mapi_table * +mapi_table_create(void) +{ + const struct mapi_table *noop = table_get_noop(); + struct mapi_table *tbl; + + tbl = malloc(sizeof(*tbl)); + if (tbl) + memcpy(tbl, noop, sizeof(*tbl)); + + return tbl; +} + +/** + * Destroy a dispatch table. + */ +void +mapi_table_destroy(struct mapi_table *tbl) +{ + free(tbl); +} + +/** + * Fill a dispatch table. The order of the procs is determined when mapi_init + * is called. + */ +void +mapi_table_fill(struct mapi_table *tbl, const mapi_proc *procs) +{ + const struct mapi_table *noop = table_get_noop(); + int i; + + for (i = 0; i < mapi_num_stubs; i++) { + const struct mapi_stub *stub = mapi_stub_map[i]; + mapi_func func = (mapi_func) procs[i]; + + if (!func) + func = table_get_func(noop, stub); + table_set_func(tbl, stub, func); + } +} + +/** + * Make a dispatch table current. + */ +void +mapi_table_make_current(const struct mapi_table *tbl) +{ + u_current_set(tbl); +} diff --git a/src/mapi/mapi/mapi.h b/src/mapi/mapi/mapi.h new file mode 100644 index 00000000000..8832b3dfb6e --- /dev/null +++ b/src/mapi/mapi/mapi.h @@ -0,0 +1,56 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#ifndef _MAPI_H_ +#define _MAPI_H_ + +#include "u_compiler.h" + +typedef void (*mapi_proc)(void); + +struct mapi_table; + +PUBLIC void +mapi_init(const char *spec); + +PUBLIC mapi_proc +mapi_get_proc_address(const char *name); + +PUBLIC struct mapi_table * +mapi_table_create(void); + +PUBLIC void +mapi_table_destroy(struct mapi_table *tbl); + +PUBLIC void +mapi_table_fill(struct mapi_table *tbl, const mapi_proc *procs); + +PUBLIC void +mapi_table_make_current(const struct mapi_table *tbl); + +#endif /* _MAPI_H_ */ diff --git a/src/mapi/mapi/mapi_abi.py b/src/mapi/mapi/mapi_abi.py new file mode 100644 index 00000000000..440eb4bb9c0 --- /dev/null +++ b/src/mapi/mapi/mapi_abi.py @@ -0,0 +1,402 @@ +#!/usr/bin/env python + +# Mesa 3-D graphics library +# Version: 7.9 +# +# Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +# Authors: +# Chia-I Wu <[email protected]> + +import sys +import re +from optparse import OptionParser + +# number of dynamic entries +ABI_NUM_DYNAMIC_ENTRIES = 256 + +class ABIEntry(object): + """Represent an ABI entry.""" + + _match_c_param = re.compile( + '^(?P<type>[\w\s*]+?)(?P<name>\w+)(\[(?P<array>\d+)\])?$') + + def __init__(self, cols, attrs): + self._parse(cols) + + self.slot = attrs['slot'] + self.hidden = attrs['hidden'] + self.alias = attrs['alias'] + + def c_prototype(self): + return '%s %s(%s)' % (self.c_return(), self.name, self.c_params()) + + def c_return(self): + ret = self.ret + if not ret: + ret = 'void' + + return ret + + def c_params(self): + """Return the parameter list used in the entry prototype.""" + c_params = [] + for t, n, a in self.params: + sep = '' if t.endswith('*') else ' ' + arr = '[%d]' % a if a else '' + c_params.append(t + sep + n + arr) + if not c_params: + c_params.append('void') + + return ", ".join(c_params) + + def c_args(self): + """Return the argument list used in the entry invocation.""" + c_args = [] + for t, n, a in self.params: + c_args.append(n) + + return ", ".join(c_args) + + def _parse(self, cols): + ret = cols.pop(0) + if ret == 'void': + ret = None + + name = cols.pop(0) + + params = [] + if not cols: + raise Exception(cols) + elif len(cols) == 1 and cols[0] == 'void': + pass + else: + for val in cols: + params.append(self._parse_param(val)) + + self.ret = ret + self.name = name + self.params = params + + def _parse_param(self, c_param): + m = self._match_c_param.match(c_param) + if not m: + raise Exception('unrecognized param ' + c_param) + + c_type = m.group('type').strip() + c_name = m.group('name') + c_array = m.group('array') + c_array = int(c_array) if c_array else 0 + + return (c_type, c_name, c_array) + + def __str__(self): + return self.c_prototype() + + def __cmp__(self, other): + # compare slot, alias, and then name + res = cmp(self.slot, other.slot) + if not res: + if not self.alias: + res = -1 + elif not other.alias: + res = 1 + + if not res: + res = cmp(self.name, other.name) + + return res + +def abi_parse_line(line): + cols = [col.strip() for col in line.split(',')] + + attrs = { + 'slot': -1, + 'hidden': False, + 'alias': None, + } + + # extract attributes from the first column + vals = cols[0].split(':') + while len(vals) > 1: + val = vals.pop(0) + if val.startswith('slot='): + attrs['slot'] = int(val[5:]) + elif val == 'hidden': + attrs['hidden'] = True + elif val.startswith('alias='): + attrs['alias'] = val[6:] + elif not val: + pass + else: + raise Exception('unknown attribute %s' % val) + cols[0] = vals[0] + + return (attrs, cols) + +def abi_parse(filename): + """Parse a CSV file for ABI entries.""" + fp = open(filename) if filename != '-' else sys.stdin + lines = [line.strip() for line in fp.readlines() + if not line.startswith('#') and line.strip()] + + entry_dict = {} + next_slot = 0 + for line in lines: + attrs, cols = abi_parse_line(line) + + # post-process attributes + if attrs['alias']: + try: + ent = entry_dict[attrs['alias']] + slot = ent.slot + except KeyError: + raise Exception('failed to alias %s' % attrs['alias']) + else: + slot = next_slot + next_slot += 1 + + if attrs['slot'] < 0: + attrs['slot'] = slot + elif attrs['slot'] != slot: + raise Exception('invalid slot in %s' % (line)) + + ent = ABIEntry(cols, attrs) + if entry_dict.has_key(ent.name): + raise Exception('%s is duplicated' % (ent.name)) + entry_dict[ent.name] = ent + + entries = entry_dict.values() + entries.sort() + + # sanity check + i = 0 + for slot in xrange(next_slot): + if entries[i].slot != slot: + raise Exception('entries are not ordered by slots') + if entries[i].alias: + raise Exception('first entry of slot %d aliases %s' + % (slot, entries[i].alias)) + while i < len(entries) and entries[i].slot == slot: + i += 1 + if i < len(entries): + raise Exception('there are %d invalid entries' % (len(entries) - 1)) + + return entries + +def abi_dynamics(): + """Return the dynamic entries.""" + entries = [] + for i in xrange(ABI_NUM_DYNAMIC_ENTRIES): + cols = ['void', 'dynamic%d' % (i), 'void'] + attrs = { 'slot': -1, 'hidden': False, 'alias': None } + entries.append(ABIEntry(cols, attrs)) + return entries + +class ABIPrinter(object): + """ABIEntry Printer""" + + def __init__(self, entries, options): + self.entries = entries + self.options = options + self._undefs = [] + + def _add_undefs(self, undefs): + self._undefs.extend(undefs) + + def output_header(self): + print '/* This file is automatically generated. Do not modify. */' + print + + def output_footer(self): + print '/* clean up */' + for m in self._undefs: + print '#undef %s' % (m) + + def output_entry(self, ent): + if ent.slot < 0: + out_ent = 'MAPI_DYNAMIC_ENTRY(%s, %s, (%s))' % \ + (ent.c_return(), ent.name, ent.c_params()) + out_code = '' + else: + if ent.alias: + macro_ent = 'MAPI_ALIAS_ENTRY' + macro_code = 'MAPI_ALIAS_CODE' + else: + macro_ent = 'MAPI_ABI_ENTRY' + macro_code = 'MAPI_ABI_CODE' + + if ent.ret: + macro_code += '_RETURN' + if ent.hidden: + macro_ent += '_HIDDEN' + macro_code += '_HIDDEN' + + if ent.alias: + out_ent = '%s(%s, %s, %s, (%s))' % (macro_ent, + ent.alias, ent.c_return(), ent.name, ent.c_params()) + out_code = '%s(%s, %s, %s, (%s))' % (macro_code, + ent.alias, ent.c_return(), ent.name, ent.c_args()) + else: + out_ent = '%s(%s, %s, (%s))' % (macro_ent, + ent.c_return(), ent.name, ent.c_params()) + out_code = '%s(%s, %s, (%s))' % (macro_code, + ent.c_return(), ent.name, ent.c_args()) + + print out_ent + if out_code: + print ' ' + out_code + + def output_entries(self, pool_offsets): + defs = [ + # normal entries + ('MAPI_ABI_ENTRY', '(ret, name, params)', ''), + ('MAPI_ABI_CODE', '(ret, name, args)', ''), + ('MAPI_ABI_CODE_RETURN', '', 'MAPI_ABI_CODE'), + # alias entries + ('MAPI_ALIAS_ENTRY', '(alias, ret, name, params)', ''), + ('MAPI_ALIAS_CODE', '(alias, ret, name, args)', ''), + ('MAPI_ALIAS_CODE_RETURN', '', 'MAPI_ALIAS_CODE'), + # hidden normal entries + ('MAPI_ABI_ENTRY_HIDDEN', '', 'MAPI_ABI_ENTRY'), + ('MAPI_ABI_CODE_HIDDEN', '', 'MAPI_ABI_CODE'), + ('MAPI_ABI_CODE_RETURN_HIDDEN', '', 'MAPI_ABI_CODE_RETURN'), + # hidden alias entries + ('MAPI_ALIAS_ENTRY_HIDDEN', '', 'MAPI_ALIAS_ENTRY'), + ('MAPI_ALIAS_CODE_HIDDEN', '', 'MAPI_ALIAS_CODE'), + ('MAPI_ALIAS_CODE_RETURN_HIDDEN', '', 'MAPI_ALIAS_CODE_RETURN'), + # dynamic entries + ('MAPI_DYNAMIC_ENTRY', '(ret, name, params)', ''), + ] + undefs = [d[0] for d in defs] + + print '#if defined(MAPI_ABI_ENTRY) || defined(MAPI_ABI_ENTRY_HIDDEN)' + print + for d in defs: + print '#ifndef %s' % (d[0]) + if d[2]: + print '#define %s%s %s' % d + else: + print '#define %s%s' % d[:2] + + print '#endif' + print + + print '/* see MAPI_TMP_TABLE */' + for ent in self.entries: + print '#define MAPI_SLOT_%s %d' % (ent.name, ent.slot) + print + print '/* see MAPI_TMP_PUBLIC_STUBS */' + for ent in self.entries: + print '#define MAPI_POOL_%s %d' % (ent.name, pool_offsets[ent]) + print + + # define macros that generate code + for ent in self.entries: + self.output_entry(ent) + print + dynamics = abi_dynamics() + for ent in dynamics: + self.output_entry(ent) + print + + for ent in self.entries: + print '#undef MAPI_SLOT_%s' % (ent.name) + for ent in self.entries: + print '#undef MAPI_POOL_%s' % (ent.name) + print + print '#endif /* defined(MAPI_ABI_ENTRY) || defined(MAPI_ABI_ENTRY_HIDDEN) */' + print + + self._add_undefs(undefs) + + def _get_string_pool(self): + """Get the string pool.""" + pool = [] + offsets = {} + + count = 0 + for ent in self.entries: + offsets[ent] = count + pool.append(ent.name + '\\0') + count += len(ent.name) + 1 + + return (pool, offsets) + + def output_sorted_indices(self): + entry_index_pairs = [] + for i in xrange(len(self.entries)): + entry_index_pairs.append((self.entries[i], i)) + entry_index_pairs.sort(lambda x, y: cmp(x[0].name, y[0].name)) + + print '/* see MAPI_TMP_PUBLIC_STUBS */' + print '#ifdef MAPI_ABI_SORTED_INDICES' + print + print 'static const int MAPI_ABI_SORTED_INDICES[] = {' + for ent, idx in entry_index_pairs: + print ' %d, /* %s */' % (idx, ent.name) + print ' -1' + print '};' + print + print '#endif /* MAPI_ABI_SORTED_INDICES */' + print + + self._add_undefs(['MAPI_ABI_SORTED_INDICES']) + + def output_defines(self): + print '/* ABI defines */' + print '#ifdef MAPI_ABI_DEFINES' + print '#include "%s"' % (self.options.include) + print '#endif /* MAPI_ABI_DEFINES */' + print + + self._add_undefs(['MAPI_ABI_DEFINES']) + + def output(self): + pool, pool_offsets = self._get_string_pool() + + self.output_header() + self.output_defines() + self.output_entries(pool_offsets) + self.output_sorted_indices() + self.output_footer() + +def parse_args(): + parser = OptionParser(usage='usage: %prog [options] <filename>') + parser.add_option('-i', '--include', dest='include', + help='include the header for API defines') + + options, args = parser.parse_args() + if not args or not options.include: + parser.print_help() + sys.exit(1) + + return (args[0], options) + +def main(): + filename, options = parse_args() + + entries = abi_parse(filename) + printer = ABIPrinter(entries, options) + printer.output() + +if __name__ == '__main__': + main() diff --git a/src/mapi/mapi/mapi_tmp.h b/src/mapi/mapi/mapi_tmp.h new file mode 100644 index 00000000000..79beca47d2a --- /dev/null +++ b/src/mapi/mapi/mapi_tmp.h @@ -0,0 +1,211 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#include "u_macros.h" + +#ifndef MAPI_ABI_HEADER +#error "MAPI_ABI_HEADER must be defined" +#endif + + +/** + * Get API defines. + */ +#ifdef MAPI_TMP_DEFINES +# define MAPI_ABI_DEFINES +# include MAPI_ABI_HEADER + +#ifndef MAPI_ABI_PREFIX +#error "MAPI_ABI_PREFIX must be defined" +#endif +#ifndef MAPI_ABI_PUBLIC +#error "MAPI_ABI_PUBLIC must be defined" +#endif +#ifndef MAPI_ABI_ATTR +#error "MAPI_ABI_ATTR must be defined" +#endif + +#undef MAPI_TMP_DEFINES +#endif /* MAPI_TMP_DEFINES */ + + +/** + * Generate fields of struct mapi_table. + */ +#ifdef MAPI_TMP_TABLE +# define MAPI_ABI_ENTRY(ret, name, params) \ + ret (MAPI_ABI_ATTR *name) params; +# define MAPI_DYNAMIC_ENTRY(ret, name, params) \ + ret (MAPI_ABI_ATTR *name) params; +# include MAPI_ABI_HEADER +#undef MAPI_TMP_TABLE +#endif /* MAPI_TMP_TABLE */ + + +/** + * Declare public entries. + */ +#ifdef MAPI_TMP_PUBLIC_DECLARES +# define MAPI_ABI_ENTRY(ret, name, params) \ + MAPI_ABI_PUBLIC ret MAPI_ABI_ATTR U_CONCAT(MAPI_ABI_PREFIX, name) params; +# define MAPI_ALIAS_ENTRY(alias, ret, name, params) \ + MAPI_ABI_ENTRY(ret, name, params); +# define MAPI_ABI_ENTRY_HIDDEN(ret, name, params) \ + HIDDEN ret MAPI_ABI_ATTR U_CONCAT(MAPI_ABI_PREFIX, name) params; +# define MAPI_ALIAS_ENTRY_HIDDEN(alias, ret, name, params) \ + MAPI_ABI_ENTRY_HIDDEN(ret, name, params) +# include MAPI_ABI_HEADER +#undef MAPI_TMP_PUBLIC_DECLARES +#endif /* MAPI_TMP_PUBLIC_DECLARES */ + + +/** + * Generate string pool and public stubs. + */ +#ifdef MAPI_TMP_PUBLIC_STUBS +/* define the string pool */ +static const char public_string_pool[] = +# define MAPI_ABI_ENTRY(ret, name, params) \ + U_STRINGIFY(name) "\0" +# define MAPI_ALIAS_ENTRY(alias, ret, name, params) \ + MAPI_ABI_ENTRY(ret, name, params) +# include MAPI_ABI_HEADER + ; +/* define public_sorted_indices */ +# define MAPI_ABI_SORTED_INDICES public_sorted_indices +# include MAPI_ABI_HEADER + +/* define public_stubs */ +static const struct mapi_stub public_stubs[] = { +# define MAPI_ABI_ENTRY(ret, name, params) \ + { (mapi_func) U_CONCAT(MAPI_ABI_PREFIX, name), \ + MAPI_SLOT_ ## name, (void *) MAPI_POOL_ ## name }, +# define MAPI_ALIAS_ENTRY(alias, ret, name, params) \ + MAPI_ABI_ENTRY(ret, name, params) +# include MAPI_ABI_HEADER + { NULL, -1, (void *) -1 } +}; + +#undef MAPI_TMP_PUBLIC_STUBS +#endif /* MAPI_TMP_PUBLIC_STUBS */ + + +/** + * Generate public entries. + */ +#ifdef MAPI_TMP_PUBLIC_ENTRIES +# define MAPI_ABI_ENTRY(ret, name, params) \ + ret MAPI_ABI_ATTR U_CONCAT(MAPI_ABI_PREFIX, name) params +# define MAPI_ABI_CODE(ret, name, args) \ + { \ + const struct mapi_table *tbl = u_current_get(); \ + tbl->name args; \ + } +# define MAPI_ABI_CODE_RETURN(ret, name, args) \ + { \ + const struct mapi_table *tbl = u_current_get(); \ + return tbl->name args; \ + } +# define MAPI_ALIAS_ENTRY(alias, ret, name, params) \ + MAPI_ABI_ENTRY(ret, name, params) +# define MAPI_ALIAS_CODE(alias, ret, name, args) \ + MAPI_ABI_CODE(ret, alias, args) +# define MAPI_ALIAS_CODE_RETURN(alias, ret, name, args) \ + MAPI_ABI_CODE_RETURN(ret, alias, args) +# include MAPI_ABI_HEADER +#undef MAPI_TMP_PUBLIC_ENTRIES +#endif /* MAPI_TMP_PUBLIC_ENTRIES */ + + +/** + * Generate noop entries. + */ +#ifdef MAPI_TMP_NOOP_ARRAY +#ifdef DEBUG +# define MAPI_ABI_ENTRY(ret, name, params) \ + static ret MAPI_ABI_ATTR U_CONCAT(noop_, name) params +# define MAPI_ABI_CODE(ret, name, args) \ + { \ + noop_warn(U_CONCAT_STR(MAPI_ABI_PREFIX, name)); \ + } +# define MAPI_ABI_CODE_RETURN(ret, name, args) \ + { \ + noop_warn(U_CONCAT_STR(MAPI_ABI_PREFIX, name)); \ + return (ret) 0; \ + } +# include MAPI_ABI_HEADER + +/* define the noop function array that may be casted to mapi_table */ +const mapi_func table_noop_array[] = { +# define MAPI_ABI_ENTRY(ret, name, params) \ + (mapi_func) U_CONCAT(noop_, name), +# define MAPI_DYNAMIC_ENTRY(ret, name, params) \ + (mapi_func) noop_generic, +# include MAPI_ABI_HEADER + (mapi_func) noop_generic +}; + +#else /* DEBUG */ + +const mapi_func table_noop_array[] = { +# define MAPI_ABI_ENTRY(ret, name, params) \ + (mapi_func) noop_generic, +# define MAPI_DYNAMIC_ENTRY(ret, name, params) \ + (mapi_func) noop_generic, +# include MAPI_ABI_HEADER + (mapi_func) noop_generic +}; + +#endif /* DEBUG */ +#undef MAPI_TMP_NOOP_ARRAY +#endif /* MAPI_TMP_NOOP_ARRAY */ + + +#ifdef MAPI_TMP_STUB_ASM_GCC +# define STUB_ASM_ALIAS(func, to) \ + ".globl " func "\n" \ + ".set " func ", " to +# define STUB_ASM_HIDE(func) \ + ".hidden " func + +# define MAPI_ABI_ENTRY(ret, name, params) \ + __asm__(STUB_ASM_ENTRY(U_CONCAT_STR(MAPI_ABI_PREFIX, name))); +# define MAPI_ABI_CODE(ret, name, args) \ + __asm__(STUB_ASM_CODE(U_STRINGIFY(MAPI_SLOT_ ## name))); +# define MAPI_ALIAS_ENTRY(alias, ret, name, params) \ + __asm__(STUB_ASM_ALIAS(U_CONCAT_STR(MAPI_ABI_PREFIX, name), \ + U_CONCAT_STR(MAPI_ABI_PREFIX, alias))); +# define MAPI_ABI_ENTRY_HIDDEN(ret, name, params) \ + __asm__(STUB_ASM_HIDE(U_CONCAT_STR(MAPI_ABI_PREFIX, name))); \ + MAPI_ABI_ENTRY(ret, name, params); +# define MAPI_ALIAS_ENTRY_HIDDEN(alias, ret, name, params) \ + __asm__(STUB_ASM_HIDE(U_CONCAT_STR(MAPI_ABI_PREFIX, name))); \ + MAPI_ALIAS_ENTRY(alias, ret, name, params); +# include MAPI_ABI_HEADER +#undef MAPI_TMP_STUB_ASM_GCC +#endif /* MAPI_TMP_STUB_ASM_GCC */ diff --git a/src/mapi/mapi/sources.mak b/src/mapi/mapi/sources.mak new file mode 100644 index 00000000000..5f327f3df62 --- /dev/null +++ b/src/mapi/mapi/sources.mak @@ -0,0 +1,19 @@ +# src/mapi/mapi/sources.mak +# +# When MAPI_GLAPI_CURRENT is defined, MAPI_GLAPI_SOURCES can be built without +# MAPI_SOURCES and it is used by glapi. +# +# Otherwise, MAPI_ABI_HEADER must be defined. It should expand to the header +# generated by mapi_abi.py. + +MAPI_GLAPI_SOURCES = \ + u_current.c \ + u_execmem.c \ + u_thread.c + +MAPI_SOURCES = \ + entry.c \ + mapi.c \ + stub.c \ + table.c \ + $(MAPI_GLAPI_SOURCES) diff --git a/src/mapi/mapi/stub.c b/src/mapi/mapi/stub.c new file mode 100644 index 00000000000..8ceaec3132b --- /dev/null +++ b/src/mapi/mapi/stub.c @@ -0,0 +1,180 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#include <stdlib.h> +#include <stddef.h> /* for offsetof */ +#include <string.h> +#include <assert.h> + +#include "u_current.h" +#include "u_thread.h" +#include "entry.h" +#include "stub.h" +#include "table.h" + +#define MAPI_TABLE_FIRST_DYNAMIC \ + (offsetof(struct mapi_table, dynamic0) / sizeof(mapi_func)) +#define MAPI_TABLE_NUM_DYNAMIC \ + ((offsetof(struct mapi_table, last) - \ + offsetof(struct mapi_table, dynamic0)) / sizeof(mapi_func)) +#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) + +/* + * This will define public_string_pool, public_sorted_indices, and + * public_stubs. + */ +#define MAPI_TMP_PUBLIC_STUBS +#include "mapi_tmp.h" + +static struct mapi_stub dynamic_stubs[MAPI_TABLE_NUM_DYNAMIC]; +static int num_dynamic_stubs; +static int next_dynamic_slot = MAPI_TABLE_FIRST_DYNAMIC; + +void +stub_init_once(void) +{ +#ifdef PTHREADS + static pthread_once_t once = PTHREAD_ONCE_INIT; + pthread_once(&once, entry_patch_public); +#else + static int first = 1; + if (first) { + first = 0; + entry_patch_public(); + } +#endif +} + +static int +stub_compare(const void *key, const void *elem) +{ + const char *name = (const char *) key; + const int *index = (const int *) elem; + const struct mapi_stub *stub; + const char *stub_name; + + stub = &public_stubs[*index]; + stub_name = &public_string_pool[(unsigned long) stub->name]; + + return strcmp(name, stub_name); +} + +/** + * Return the public stub with the given name. + */ +const struct mapi_stub * +stub_find_public(const char *name) +{ + const int *index; + + index = (const int *) bsearch(name, public_sorted_indices, + ARRAY_SIZE(public_sorted_indices) - 1, + sizeof(public_sorted_indices[0]), stub_compare); + + return (index) ? &public_stubs[*index] : NULL; +} + +/** + * Add a dynamic stub. + */ +static struct mapi_stub * +stub_add_dynamic(const char *name) +{ + struct mapi_stub *stub; + int idx; + + idx = num_dynamic_stubs; + if (idx >= MAPI_TABLE_NUM_DYNAMIC) + return NULL; + + stub = &dynamic_stubs[idx]; + + /* dispatch to mapi_table->last, which is always no-op */ + stub->addr = + entry_generate(MAPI_TABLE_FIRST_DYNAMIC + MAPI_TABLE_NUM_DYNAMIC); + if (!stub->addr) + return NULL; + + stub->name = (const void *) name; + /* to be fixed later */ + stub->slot = -1; + + num_dynamic_stubs = idx + 1; + + return stub; +} + +/** + * Return the dynamic stub with the given name. If no such stub exists and + * generate is true, a new stub is generated. + */ +struct mapi_stub * +stub_find_dynamic(const char *name, int generate) +{ + u_mutex_declare_static(dynamic_mutex); + struct mapi_stub *stub = NULL; + int count, i; + + u_mutex_lock(dynamic_mutex); + + if (generate) + assert(!stub_find_public(name)); + + count = num_dynamic_stubs; + for (i = 0; i < count; i++) { + if (strcmp(name, (const char *) dynamic_stubs[i].name) == 0) { + stub = &dynamic_stubs[i]; + break; + } + } + + /* generate a dynamic stub */ + if (generate && !stub) + stub = stub_add_dynamic(name); + + u_mutex_unlock(dynamic_mutex); + + return stub; +} + +void +stub_fix_dynamic(struct mapi_stub *stub, const struct mapi_stub *alias) +{ + int slot; + + if (stub->slot >= 0) + return; + + if (alias) + slot = alias->slot; + else + slot = next_dynamic_slot++; + + entry_patch(stub->addr, slot); + stub->slot = slot; +} diff --git a/src/mapi/mapi/stub.h b/src/mapi/mapi/stub.h new file mode 100644 index 00000000000..c7e194cf4fc --- /dev/null +++ b/src/mapi/mapi/stub.h @@ -0,0 +1,52 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#ifndef _STUB_H_ +#define _STUB_H_ + +typedef void (*mapi_func)(void); + +struct mapi_stub { + mapi_func addr; + int slot; + const void *name; +}; + +void +stub_init_once(void); + +const struct mapi_stub * +stub_find_public(const char *name); + +struct mapi_stub * +stub_find_dynamic(const char *name, int generate); + +void +stub_fix_dynamic(struct mapi_stub *stub, const struct mapi_stub *alias); + +#endif /* _STUB_H_ */ diff --git a/src/mapi/mapi/table.c b/src/mapi/mapi/table.c new file mode 100644 index 00000000000..8f4f700b920 --- /dev/null +++ b/src/mapi/mapi/table.c @@ -0,0 +1,56 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "stub.h" +#include "table.h" + +static void +noop_warn(const char *name) +{ + static int debug = -1; + + if (debug < 0) + debug = (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")); + + if (debug) + fprintf(stderr, "%s is no-op", name); +} + +static int +noop_generic(void) +{ + noop_warn("function"); + return 0; +} + +/* define noop_array */ +#define MAPI_TMP_NOOP_ARRAY +#include "mapi_tmp.h" diff --git a/src/mapi/mapi/table.h b/src/mapi/mapi/table.h new file mode 100644 index 00000000000..48c99018aa3 --- /dev/null +++ b/src/mapi/mapi/table.h @@ -0,0 +1,76 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#ifndef _TABLE_H_ +#define _TABLE_H_ + +#include "u_compiler.h" +#include "stub.h" + +#define MAPI_TMP_DEFINES +#include "mapi_tmp.h" + +struct mapi_table { +#define MAPI_TMP_TABLE +#include "mapi_tmp.h" + mapi_func last; +}; + +extern const mapi_func table_noop_array[]; + +/** + * Get the no-op dispatch table. + */ +static INLINE const struct mapi_table * +table_get_noop(void) +{ + return (const struct mapi_table *) table_noop_array; +} + +/** + * Update the dispatch table to dispatch a stub to the given function. + */ +static INLINE void +table_set_func(struct mapi_table *tbl, + const struct mapi_stub *stub, mapi_func func) +{ + mapi_func *funcs = (mapi_func *) tbl; + funcs[stub->slot] = func; +} + +/** + * Return the dispatched function of a stub. + */ +static INLINE mapi_func +table_get_func(const struct mapi_table *tbl, const struct mapi_stub *stub) +{ + const mapi_func *funcs = (const mapi_func *) tbl; + return funcs[stub->slot]; +} + +#endif /* _TABLE_H_ */ diff --git a/src/mapi/mapi/u_compiler.h b/src/mapi/mapi/u_compiler.h new file mode 100644 index 00000000000..cc9e2cd1e81 --- /dev/null +++ b/src/mapi/mapi/u_compiler.h @@ -0,0 +1,48 @@ +#ifndef _U_COMPILER_H_ +#define _U_COMPILER_H_ + +/* Function inlining */ +#ifndef INLINE +# ifdef __cplusplus +# define INLINE inline +# elif defined(__GNUC__) +# define INLINE __inline__ +# elif defined(_MSC_VER) +# define INLINE __inline +# elif defined(__ICL) +# define INLINE __inline +# elif defined(__INTEL_COMPILER) +# define INLINE inline +# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) +# define INLINE __inline +# elif defined(__SUNPRO_C) && defined(__C99FEATURES__) +# define INLINE inline +# elif (__STDC_VERSION__ >= 199901L) /* C99 */ +# define INLINE inline +# else +# define INLINE +# endif +#endif + +/* Function visibility */ +#ifndef PUBLIC +# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define PUBLIC __attribute__((visibility("default"))) +# define HIDDEN __attribute__((visibility("hidden"))) +# else +# define PUBLIC +# define HIDDEN +# endif +#endif + +#ifndef likely +# if defined(__GNUC__) +# define likely(x) __builtin_expect(!!(x), 1) +# define unlikely(x) __builtin_expect(!!(x), 0) +# else +# define likely(x) (x) +# define unlikely(x) (x) +# endif +#endif + +#endif /* _U_COMPILER_H_ */ diff --git a/src/mesa/glapi/glapi.c b/src/mapi/mapi/u_current.c index ce85cf6a87b..91547c48301 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mapi/mapi/u_current.c @@ -48,21 +48,23 @@ * drivers! No changes to the public glapi interface. */ +#include "u_current.h" +#include "u_thread.h" +#ifndef MAPI_GLAPI_CURRENT + +#include "table.h" +#include "stub.h" -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#include "glapi/mesa.h" #else -#include "main/glheader.h" -#include "main/compiler.h" -#endif -#include "glapi/glapi.h" -#include "glapi/glapi_priv.h" +extern void init_glapi_relocs_once(void); +extern void (*__glapi_noop_table[])(void); -extern _glapi_proc __glapi_noop_table[]; +#define table_noop_array __glapi_noop_table +#define stub_init_once() init_glapi_relocs_once() +#endif /** * \name Current dispatch and current context control variables @@ -97,54 +99,49 @@ extern _glapi_proc __glapi_noop_table[]; /*@{*/ #if defined(GLX_USE_TLS) -PUBLIC __thread struct _glapi_table * _glapi_tls_Dispatch +__thread struct _glapi_table *_glapi_tls_Dispatch __attribute__((tls_model("initial-exec"))) - = (struct _glapi_table *) __glapi_noop_table; + = (struct _glapi_table *) table_noop_array; -PUBLIC __thread void * _glapi_tls_Context +__thread void * _glapi_tls_Context __attribute__((tls_model("initial-exec"))); -PUBLIC const struct _glapi_table *_glapi_Dispatch = NULL; - -PUBLIC const void *_glapi_Context = NULL; +const struct _glapi_table *_glapi_Dispatch; +const void *_glapi_Context; #else -#if defined(THREADS) - -static GLboolean ThreadSafe = GL_FALSE; /**< In thread-safe mode? */ - -_glthread_TSD _gl_DispatchTSD; /**< Per-thread dispatch pointer */ +struct _glapi_table *_glapi_Dispatch = + (struct _glapi_table *) table_noop_array; +void *_glapi_Context; -static _glthread_TSD ContextTSD; /**< Per-thread context pointer */ - -#endif /* defined(THREADS) */ - -PUBLIC struct _glapi_table *_glapi_Dispatch = (struct _glapi_table *) __glapi_noop_table; - -PUBLIC void *_glapi_Context = NULL; +#ifdef THREADS +struct u_tsd _gl_DispatchTSD; +static struct u_tsd ContextTSD; +static int ThreadSafe; +#endif /* THREADS */ #endif /* defined(GLX_USE_TLS) */ /*@}*/ - -#if defined(THREADS) && !defined(GLX_USE_TLS) - void -_glapi_init_multithread(void) +_glapi_destroy_multithread(void) { - _glthread_InitTSD(&_gl_DispatchTSD); - _glthread_InitTSD(&ContextTSD); +#if defined(THREADS) && defined(WIN32_THREADS) + u_tsd_destroy(&_gl_DispatchTSD); + u_tsd_destroy(&ContextTSD); +#endif } -void -_glapi_destroy_multithread(void) + +#if defined(THREADS) && !defined(GLX_USE_TLS) + +static void +_glapi_init_multithread(void) { -#ifdef WIN32_THREADS - _glthread_DestroyTSD(&_gl_DispatchTSD); - _glthread_DestroyTSD(&ContextTSD); -#endif + u_tsd_init(&_gl_DispatchTSD); + u_tsd_init(&ContextTSD); } /** @@ -155,20 +152,20 @@ _glapi_destroy_multithread(void) #define CHECK_MULTITHREAD_LOCK() #define CHECK_MULTITHREAD_UNLOCK() #else -_glthread_DECLARE_STATIC_MUTEX(ThreadCheckMutex); -#define CHECK_MULTITHREAD_LOCK() _glthread_LOCK_MUTEX(ThreadCheckMutex) -#define CHECK_MULTITHREAD_UNLOCK() _glthread_UNLOCK_MUTEX(ThreadCheckMutex) +u_mutex_declare_static(ThreadCheckMutex); +#define CHECK_MULTITHREAD_LOCK() u_mutex_lock(ThreadCheckMutex) +#define CHECK_MULTITHREAD_UNLOCK() u_mutex_unlock(ThreadCheckMutex) #endif /** * We should call this periodically from a function such as glXMakeCurrent * in order to test if multiple threads are being used. */ -PUBLIC void +void _glapi_check_multithread(void) { static unsigned long knownID; - static GLboolean firstCall = GL_TRUE; + static int firstCall = 1; if (ThreadSafe) return; @@ -177,11 +174,11 @@ _glapi_check_multithread(void) if (firstCall) { _glapi_init_multithread(); - knownID = _glthread_GetID(); - firstCall = GL_FALSE; + knownID = u_thread_self(); + firstCall = 0; } - else if (knownID != _glthread_GetID()) { - ThreadSafe = GL_TRUE; + else if (knownID != u_thread_self()) { + ThreadSafe = 1; _glapi_set_dispatch(NULL); _glapi_set_context(NULL); } @@ -191,13 +188,9 @@ _glapi_check_multithread(void) #else void -_glapi_init_multithread(void) { } - -void -_glapi_destroy_multithread(void) { } - -PUBLIC void -_glapi_check_multithread(void) { } +_glapi_check_multithread(void) +{ +} #endif @@ -208,85 +201,73 @@ _glapi_check_multithread(void) { } * The context pointer is an opaque type which should be cast to * void from the real context pointer type. */ -PUBLIC void +void _glapi_set_context(void *context) { #if defined(GLX_USE_TLS) _glapi_tls_Context = context; #elif defined(THREADS) - _glthread_SetTSD(&ContextTSD, context); + u_tsd_set(&ContextTSD, context); _glapi_Context = (ThreadSafe) ? NULL : context; #else _glapi_Context = context; #endif } - - /** * Get the current context pointer for this thread. * The context pointer is an opaque type which should be cast from * void to the real context pointer type. */ -PUBLIC void * +void * _glapi_get_context(void) { #if defined(GLX_USE_TLS) return _glapi_tls_Context; #elif defined(THREADS) - return (ThreadSafe) ? _glthread_GetTSD(&ContextTSD) : _glapi_Context; + return (ThreadSafe) + ? u_tsd_get(&ContextTSD) + : _glapi_Context; #else return _glapi_Context; #endif } - - /** * Set the global or per-thread dispatch table pointer. * If the dispatch parameter is NULL we'll plug in the no-op dispatch * table (__glapi_noop_table). */ -PUBLIC void +void _glapi_set_dispatch(struct _glapi_table *dispatch) { - init_glapi_relocs_once(); + stub_init_once(); - if (dispatch == NULL) { - /* use the no-op functions */ - dispatch = (struct _glapi_table *) __glapi_noop_table; - } -#ifdef DEBUG - else { - _glapi_check_table_not_null(dispatch); - _glapi_check_table(dispatch); - } -#endif + if (!dispatch) + dispatch = (struct _glapi_table *) table_noop_array; #if defined(GLX_USE_TLS) _glapi_tls_Dispatch = dispatch; #elif defined(THREADS) - _glthread_SetTSD(&_gl_DispatchTSD, (void *) dispatch); + u_tsd_set(&_gl_DispatchTSD, (void *) dispatch); _glapi_Dispatch = (ThreadSafe) ? NULL : dispatch; #else _glapi_Dispatch = dispatch; #endif } - - /** * Return pointer to current dispatch table for calling thread. */ -PUBLIC struct _glapi_table * +struct _glapi_table * _glapi_get_dispatch(void) { #if defined(GLX_USE_TLS) return _glapi_tls_Dispatch; #elif defined(THREADS) return (ThreadSafe) - ? (struct _glapi_table *) _glthread_GetTSD(&_gl_DispatchTSD) - : _glapi_Dispatch; + ? (struct _glapi_table *) u_tsd_get(&_gl_DispatchTSD) + : _glapi_Dispatch; #else return _glapi_Dispatch; #endif diff --git a/src/mapi/mapi/u_current.h b/src/mapi/mapi/u_current.h new file mode 100644 index 00000000000..a6256f5b512 --- /dev/null +++ b/src/mapi/mapi/u_current.h @@ -0,0 +1,93 @@ +#ifndef _U_CURRENT_H_ +#define _U_CURRENT_H_ + +#include "u_compiler.h" + +#ifdef MAPI_GLAPI_CURRENT +#define GLAPI_EXPORT PUBLIC +#else +#define GLAPI_EXPORT +#endif + +/* + * Unlike other utility functions, we need to keep the old names (_glapi_*) for + * ABI compatibility. The desired functions are wrappers to the old ones. + */ + +struct _glapi_table; + +#ifdef GLX_USE_TLS + +GLAPI_EXPORT extern __thread struct _glapi_table *_glapi_tls_Dispatch + __attribute__((tls_model("initial-exec"))); + +GLAPI_EXPORT extern __thread void *_glapi_tls_Context + __attribute__((tls_model("initial-exec"))); + +GLAPI_EXPORT extern const struct _glapi_table *_glapi_Dispatch; +GLAPI_EXPORT extern const void *_glapi_Context; + +#else /* GLX_USE_TLS */ + +GLAPI_EXPORT extern struct _glapi_table *_glapi_Dispatch; +GLAPI_EXPORT extern void *_glapi_Context; + +#endif /* GLX_USE_TLS */ + +GLAPI_EXPORT void +_glapi_check_multithread(void); + +GLAPI_EXPORT void +_glapi_set_context(void *context); + +GLAPI_EXPORT void * +_glapi_get_context(void); + +GLAPI_EXPORT void +_glapi_set_dispatch(struct _glapi_table *dispatch); + +GLAPI_EXPORT struct _glapi_table * +_glapi_get_dispatch(void); + +void +_glapi_destroy_multithread(void); + + +struct mapi_table; + +static INLINE void +u_current_set(const struct mapi_table *tbl) +{ + _glapi_check_multithread(); + _glapi_set_dispatch((struct _glapi_table *) tbl); +} + +static INLINE const struct mapi_table * +u_current_get(void) +{ +#ifdef GLX_USE_TLS + return (const struct mapi_table *) _glapi_tls_Dispatch; +#else + return (const struct mapi_table *) (likely(_glapi_Dispatch) ? + _glapi_Dispatch : _glapi_get_dispatch()); +#endif +} + +static INLINE void +u_current_set_user(void *ptr) +{ + _glapi_check_multithread(); + _glapi_set_context(ptr); +} + +static INLINE void * +u_current_get_user(void) +{ +#ifdef GLX_USE_TLS + return _glapi_tls_Context; +#else + return likely(_glapi_Context) ? _glapi_Context : _glapi_get_context(); +#endif +} + +#endif /* GLX_USE_TLS */ diff --git a/src/mesa/glapi/glapi_execmem.c b/src/mapi/mapi/u_execmem.c index 57f00be8dcc..00df8300de3 100644 --- a/src/mesa/glapi/glapi_execmem.c +++ b/src/mapi/mapi/u_execmem.c @@ -32,15 +32,18 @@ */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#include "glapi/mesa.h" -#else -#include "main/compiler.h" -#endif +#include "u_compiler.h" +#include "u_thread.h" +#include "u_execmem.h" + + +#define EXEC_MAP_SIZE (4*1024) + +u_mutex_declare_static(exec_mutex); -#include "glapi/glthread.h" -#include "glapi/glapi_priv.h" +static unsigned int head = 0; + +static unsigned char *exec_mem = (unsigned char *)0; #if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun) @@ -58,15 +61,6 @@ #endif -#define EXEC_MAP_SIZE (4*1024) - -_glthread_DECLARE_STATIC_MUTEX(exec_mutex); - -static unsigned int head = 0; - -static unsigned char *exec_mem = NULL; - - /* * Dispatch stubs are of fixed size and never freed. Thus, we do not need to * overlay a heap, we just mmap a page and manage through an index. @@ -91,12 +85,43 @@ init_map(void) } +#elif defined(_WIN32) + +#include <windows.h> + + +/* + * Avoid Data Execution Prevention. + */ + +static int +init_map(void) +{ + exec_mem = VirtualAlloc(NULL, EXEC_MAP_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + + return (exec_mem != NULL); +} + + +#else + +static int +init_map(void) +{ + exec_mem = malloc(EXEC_MAP_SIZE); + + return (exec_mem != NULL); +} + + +#endif + void * -_glapi_exec_malloc(unsigned int size) +u_execmem_alloc(unsigned int size) { void *addr = NULL; - _glthread_LOCK_MUTEX(exec_mutex); + u_mutex_lock(exec_mutex); if (!init_map()) goto bail; @@ -110,19 +135,9 @@ _glapi_exec_malloc(unsigned int size) head += size; bail: - _glthread_UNLOCK_MUTEX(exec_mutex); + u_mutex_unlock(exec_mutex); return addr; } -#else - -void * -_glapi_exec_malloc(unsigned int size) -{ - return malloc(size); -} - - -#endif diff --git a/src/mapi/mapi/u_execmem.h b/src/mapi/mapi/u_execmem.h new file mode 100644 index 00000000000..13fff8df225 --- /dev/null +++ b/src/mapi/mapi/u_execmem.h @@ -0,0 +1,7 @@ +#ifndef _U_EXECMEM_H_ +#define _U_EXECMEM_H_ + +void * +u_execmem_alloc(unsigned int size); + +#endif /* _U_EXECMEM_H_ */ diff --git a/src/mapi/mapi/u_macros.h b/src/mapi/mapi/u_macros.h new file mode 100644 index 00000000000..72345b5f156 --- /dev/null +++ b/src/mapi/mapi/u_macros.h @@ -0,0 +1,12 @@ +#ifndef _U_MACROS_ +#define _U_MACROS_ + +#define _U_STRINGIFY(x) #x +#define _U_CONCAT(x, y) x ## y +#define _U_CONCAT_STR(x, y) #x#y + +#define U_STRINGIFY(x) _U_STRINGIFY(x) +#define U_CONCAT(x, y) _U_CONCAT(x, y) +#define U_CONCAT_STR(x, y) _U_CONCAT_STR(x, y) + +#endif /* _U_MACROS_ */ diff --git a/src/mesa/glapi/glthread.c b/src/mapi/mapi/u_thread.c index f365d17bdda..e0fa64ae034 100644 --- a/src/mesa/glapi/glthread.c +++ b/src/mapi/mapi/u_thread.c @@ -23,19 +23,10 @@ */ -/* - * XXX There's probably some work to do in order to make this file - * truly reusable outside of Mesa. First, the glheader.h include must go. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#include "glapi/mesa.h" -#else -#include "main/compiler.h" -#endif - -#include "glapi/glthread.h" +#include <stdio.h> +#include <stdlib.h> +#include "u_compiler.h" +#include "u_thread.h" /* @@ -71,15 +62,15 @@ */ #ifdef PTHREADS -PUBLIC unsigned long -_glthread_GetID(void) +unsigned long +u_thread_self(void) { return (unsigned long) pthread_self(); } void -_glthread_InitTSD(_glthread_TSD *tsd) +u_tsd_init(struct u_tsd *tsd) { if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) { perror(INIT_TSD_ERROR); @@ -90,20 +81,20 @@ _glthread_InitTSD(_glthread_TSD *tsd) void * -_glthread_GetTSD(_glthread_TSD *tsd) +u_tsd_get(struct u_tsd *tsd) { if (tsd->initMagic != (int) INIT_MAGIC) { - _glthread_InitTSD(tsd); + u_tsd_init(tsd); } return pthread_getspecific(tsd->key); } void -_glthread_SetTSD(_glthread_TSD *tsd, void *ptr) +u_tsd_set(struct u_tsd *tsd, void *ptr) { if (tsd->initMagic != (int) INIT_MAGIC) { - _glthread_InitTSD(tsd); + u_tsd_init(tsd); } if (pthread_setspecific(tsd->key, ptr) != 0) { perror(SET_TSD_ERROR); @@ -127,15 +118,15 @@ static void InsteadOf_exit(int nCode) DWORD dwErr = GetLastError(); } -PUBLIC unsigned long -_glthread_GetID(void) +unsigned long +u_thread_self(void) { return GetCurrentThreadId(); } void -_glthread_InitTSD(_glthread_TSD *tsd) +u_tsd_init(struct u_tsd *tsd) { tsd->key = TlsAlloc(); if (tsd->key == TLS_OUT_OF_INDEXES) { @@ -147,7 +138,7 @@ _glthread_InitTSD(_glthread_TSD *tsd) void -_glthread_DestroyTSD(_glthread_TSD *tsd) +u_tsd_destroy(struct u_tsd *tsd) { if (tsd->initMagic != INIT_MAGIC) { return; @@ -158,22 +149,22 @@ _glthread_DestroyTSD(_glthread_TSD *tsd) void * -_glthread_GetTSD(_glthread_TSD *tsd) +u_tsd_get(struct u_tsd *tsd) { if (tsd->initMagic != INIT_MAGIC) { - _glthread_InitTSD(tsd); + u_tsd_init(tsd); } return TlsGetValue(tsd->key); } void -_glthread_SetTSD(_glthread_TSD *tsd, void *ptr) +u_tsd_set(struct u_tsd *tsd, void *ptr) { - /* the following code assumes that the _glthread_TSD has been initialized + /* the following code assumes that the struct u_tsd has been initialized to zero at creation */ if (tsd->initMagic != INIT_MAGIC) { - _glthread_InitTSD(tsd); + u_tsd_init(tsd); } if (TlsSetValue(tsd->key, ptr) == 0) { perror(SET_TSD_ERROR); @@ -188,33 +179,33 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr) */ #ifdef BEOS_THREADS -PUBLIC unsigned long -_glthread_GetID(void) +unsigned long +u_thread_self(void) { return (unsigned long) find_thread(NULL); } void -_glthread_InitTSD(_glthread_TSD *tsd) +u_tsd_init(struct u_tsd *tsd) { tsd->key = tls_allocate(); tsd->initMagic = INIT_MAGIC; } void * -_glthread_GetTSD(_glthread_TSD *tsd) +u_tsd_get(struct u_tsd *tsd) { if (tsd->initMagic != (int) INIT_MAGIC) { - _glthread_InitTSD(tsd); + u_tsd_init(tsd); } return tls_get(tsd->key); } void -_glthread_SetTSD(_glthread_TSD *tsd, void *ptr) +u_tsd_set(struct u_tsd *tsd, void *ptr) { if (tsd->initMagic != (int) INIT_MAGIC) { - _glthread_InitTSD(tsd); + u_tsd_init(tsd); } tls_set(tsd->key, ptr); } @@ -230,7 +221,7 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr) * no-op functions */ -PUBLIC unsigned long +unsigned long _glthread_GetID(void) { return 0; @@ -238,14 +229,14 @@ _glthread_GetID(void) void -_glthread_InitTSD(_glthread_TSD *tsd) +u_tsd_init(struct u_tsd *tsd) { (void) tsd; } void * -_glthread_GetTSD(_glthread_TSD *tsd) +u_tsd_get(struct u_tsd *tsd) { (void) tsd; return NULL; @@ -253,7 +244,7 @@ _glthread_GetTSD(_glthread_TSD *tsd) void -_glthread_SetTSD(_glthread_TSD *tsd, void *ptr) +u_tsd_set(struct u_tsd *tsd, void *ptr) { (void) tsd; (void) ptr; diff --git a/src/mesa/glapi/glthread.h b/src/mapi/mapi/u_thread.h index 4fe99284a8c..b4487a3400f 100644 --- a/src/mesa/glapi/glthread.h +++ b/src/mapi/mapi/u_thread.h @@ -30,28 +30,7 @@ * and Christoph Poliwoda ([email protected]) * Revised by Keith Whitwell * Adapted for new gl dispatcher by Brian Paul - * - * - * - * DOCUMENTATION - * - * This thread module exports the following types: - * _glthread_TSD Thread-specific data area - * _glthread_Thread Thread datatype - * _glthread_Mutex Mutual exclusion lock - * - * Macros: - * _glthread_DECLARE_STATIC_MUTEX(name) Declare a non-local mutex - * _glthread_INIT_MUTEX(name) Initialize a mutex - * _glthread_LOCK_MUTEX(name) Lock a mutex - * _glthread_UNLOCK_MUTEX(name) Unlock a mutex - * - * Functions: - * _glthread_GetID(v) Get integer thread ID - * _glthread_InitTSD() Initialize thread-specific data - * _glthread_GetTSD() Get thread-specific data - * _glthread_SetTSD() Set thread-specific data - * + * Modified for use in mapi by Chia-I Wu */ /* @@ -60,9 +39,10 @@ * In general, it should only be included when needed however. */ -#ifndef GLTHREAD_H -#define GLTHREAD_H +#ifndef _U_THREAD_H_ +#define _U_THREAD_H_ +#include "u_compiler.h" #if defined(PTHREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS) #ifndef THREADS @@ -70,7 +50,6 @@ #endif #endif - /* * POSIX threads. This should be your choice in the Unix world * whenever possible. When building with POSIX threads, be sure @@ -83,29 +62,20 @@ #if defined(PTHREADS) #include <pthread.h> /* POSIX threads headers */ -typedef struct { - pthread_key_t key; +struct u_tsd { + pthread_key_t key; int initMagic; -} _glthread_TSD; +}; -typedef pthread_t _glthread_Thread; +typedef pthread_mutex_t u_mutex; -typedef pthread_mutex_t _glthread_Mutex; +#define u_mutex_declare_static(name) \ + static u_mutex name = PTHREAD_MUTEX_INITIALIZER -#define _glthread_DECLARE_STATIC_MUTEX(name) \ - static _glthread_Mutex name = PTHREAD_MUTEX_INITIALIZER - -#define _glthread_INIT_MUTEX(name) \ - pthread_mutex_init(&(name), NULL) - -#define _glthread_DESTROY_MUTEX(name) \ - pthread_mutex_destroy(&(name)) - -#define _glthread_LOCK_MUTEX(name) \ - (void) pthread_mutex_lock(&(name)) - -#define _glthread_UNLOCK_MUTEX(name) \ - (void) pthread_mutex_unlock(&(name)) +#define u_mutex_init(name) pthread_mutex_init(&(name), NULL) +#define u_mutex_destroy(name) pthread_mutex_destroy(&(name)) +#define u_mutex_lock(name) (void) pthread_mutex_lock(&(name)) +#define u_mutex_unlock(name) (void) pthread_mutex_unlock(&(name)) #endif /* PTHREADS */ @@ -118,29 +88,21 @@ typedef pthread_mutex_t _glthread_Mutex; #ifdef WIN32_THREADS #include <windows.h> -typedef struct { +struct u_tsd { DWORD key; int initMagic; -} _glthread_TSD; - -typedef HANDLE _glthread_Thread; - -typedef CRITICAL_SECTION _glthread_Mutex; - -#define _glthread_DECLARE_STATIC_MUTEX(name) \ - /* static */ _glthread_Mutex name = { 0, 0, 0, 0, 0, 0 } +}; -#define _glthread_INIT_MUTEX(name) \ - InitializeCriticalSection(&name) +typedef CRITICAL_SECTION u_mutex; -#define _glthread_DESTROY_MUTEX(name) \ - DeleteCriticalSection(&name) +/* http://locklessinc.com/articles/pthreads_on_windows/ */ +#define u_mutex_declare_static(name) \ + /* static */ u_mutex name = {(void*)-1, -1, 0, 0, 0, 0} -#define _glthread_LOCK_MUTEX(name) \ - EnterCriticalSection(&name) - -#define _glthread_UNLOCK_MUTEX(name) \ - LeaveCriticalSection(&name) +#define u_mutex_init(name) InitializeCriticalSection(&name) +#define u_mutex_destroy(name) DeleteCriticalSection(&name) +#define u_mutex_lock(name) EnterCriticalSection(&name) +#define u_mutex_unlock(name) LeaveCriticalSection(&name) #endif /* WIN32_THREADS */ @@ -165,38 +127,36 @@ typedef int32 thread_id; typedef int32 sem_id; #endif -typedef struct { +struct u_tsd { int32 key; int initMagic; -} _glthread_TSD; - -typedef thread_id _glthread_Thread; +}; /* Use Benaphore, aka speeder semaphore */ typedef struct { int32 lock; sem_id sem; } benaphore; -typedef benaphore _glthread_Mutex; +typedef benaphore u_mutex; -#define _glthread_DECLARE_STATIC_MUTEX(name) \ - static _glthread_Mutex name = { 0, 0 } +#define u_mutex_declare_static(name) \ + static u_mutex name = { 0, 0 } -#define _glthread_INIT_MUTEX(name) \ +#define u_mutex_init(name) \ name.sem = create_sem(0, #name"_benaphore"), \ name.lock = 0 -#define _glthread_DESTROY_MUTEX(name) \ +#define u_mutex_destroy(name) \ delete_sem(name.sem), \ name.lock = 0 -#define _glthread_LOCK_MUTEX(name) \ +#define u_mutex_lock(name) \ if (name.sem == 0) \ - _glthread_INIT_MUTEX(name); \ + u_mutex_init(name); \ if (atomic_add(&(name.lock), 1) >= 1) \ acquire_sem(name.sem) -#define _glthread_UNLOCK_MUTEX(name) \ +#define u_mutex_unlock(name) \ if (atomic_add(&(name.lock), -1) > 1) \ release_sem(name.sem) @@ -208,48 +168,34 @@ typedef benaphore _glthread_Mutex; */ #ifndef THREADS -typedef unsigned _glthread_TSD; - -typedef unsigned _glthread_Thread; - -typedef unsigned _glthread_Mutex; +struct u_tsd { + int initMagic; +}; -#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0 +typedef unsigned u_mutex; -#define _glthread_INIT_MUTEX(name) (void) name - -#define _glthread_DESTROY_MUTEX(name) (void) name - -#define _glthread_LOCK_MUTEX(name) (void) name - -#define _glthread_UNLOCK_MUTEX(name) (void) name +#define u_mutex_declare_static(name) static u_mutex name = 0 +#define u_mutex_init(name) (void) name +#define u_mutex_destroy(name) (void) name +#define u_mutex_lock(name) (void) name +#define u_mutex_unlock(name) (void) name #endif /* THREADS */ +unsigned long +u_thread_self(void); -/* - * Platform independent thread specific data API. - */ - -extern unsigned long -_glthread_GetID(void); - - -extern void -_glthread_InitTSD(_glthread_TSD *); - - -extern void -_glthread_DestroyTSD(_glthread_TSD *); /* WIN32 only */ - - -extern void * -_glthread_GetTSD(_glthread_TSD *); +void +u_tsd_init(struct u_tsd *tsd); +void +u_tsd_destroy(struct u_tsd *tsd); /* WIN32 only */ -extern void -_glthread_SetTSD(_glthread_TSD *, void *); +void * +u_tsd_get(struct u_tsd *tsd); +void +u_tsd_set(struct u_tsd *tsd, void *ptr); -#endif /* THREADS_H */ +#endif /* _U_THREAD_H_ */ diff --git a/src/mapi/vgapi/Makefile b/src/mapi/vgapi/Makefile new file mode 100644 index 00000000000..702db03d154 --- /dev/null +++ b/src/mapi/vgapi/Makefile @@ -0,0 +1,89 @@ +# src/mapi/vgapi/Makefile + +TOP := ../../.. +include $(TOP)/configs/current + +VG_LIB_MAJOR = 1 +VG_LIB_MINOR = 0 +VG_LIB_PATCH = 0 + +MAPI := $(TOP)/src/mapi/mapi + +include $(MAPI)/sources.mak +VGAPI_SOURCES := $(addprefix $(MAPI)/, $(MAPI_SOURCES)) +VGAPI_OBJECTS := $(MAPI_SOURCES:.c=.o) + +VGAPI_CPPFLAGS := -DMAPI_ABI_HEADER=\"vgapi/vgapi_tmp.h\" + +GENERATED_SOURCES := vgapi_tmp.h + +INCLUDE_DIRS := \ + -I$(TOP)/include \ + -I$(TOP)/src/mapi + +.PHONY: default +default: depend $(TOP)/$(LIB_DIR)/$(VG_LIB_NAME) + +$(TOP)/$(LIB_DIR)/$(VG_LIB_NAME): $(VGAPI_OBJECTS) + $(MKLIB) -o $(VG_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + -major $(VG_LIB_MAJOR) \ + -minor $(VG_LIB_MINOR) \ + -patch $(VG_LIB_PATCH) \ + -id $(INSTALL_LIB_DIR)/lib$(VG_LIB).$(VG_LIB_MAJOR).dylib \ + $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \ + $(VGAPI_OBJECTS) $(VG_LIB_DEPS) + +# not used, but kept for completeness +libvgapi.a: $(VGAPI_OBJECTS) + @$(MKLIB) -o vgapi -static $(VGAPI_OBJECTS) + +$(VGAPI_SOURCES): | $(GENERATED_SOURCES) + +$(VGAPI_OBJECTS): %.o: $(MAPI)/%.c + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(VGAPI_CPPFLAGS) $< -o $@ + +vgapi_tmp.h: vgapi.csv $(MAPI)/mapi_abi.py + $(PYTHON2) $(PYTHON_FLAGS) $(MAPI)/mapi_abi.py \ + -i vgapi/vgapi_defines.h $< > $@ + +.PHONY: clean +clean: + -rm -f vg.pc + -rm -f $(TOP)/$(LIB_DIR)/$(VG_LIB_NAME) + -rm -f libvgapi.a + -rm -f $(VGAPI_OBJECTS) + -rm -f depend depend.bak + -rm -f $(GENERATED_SOURCES) + +pcedit = \ + -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \ + -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \ + -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \ + -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' \ + -e 's,@VG_PC_REQ_PRIV@,$(VG_PC_REQ_PRIV),' \ + -e 's,@VG_PC_LIB_PRIV@,$(VG_PC_LIB_PRIV),' \ + -e 's,@VG_PC_CFLAGS@,$(VG_PC_CFLAGS),' \ + -e 's,@VG_LIB@,$(VG_LIB),' + +vg.pc: vg.pc.in + @sed $(pcedit) $< > $@ + +install-pc: vg.pc + $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig + $(INSTALL) -m 644 $< $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig + +install-headers: + $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/VG + $(INSTALL) -m 644 $(TOP)/include/VG/*.h $(DESTDIR)$(INSTALL_INC_DIR)/VG + +install: default install-headers install-pc + $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(VG_LIB_GLOB) \ + $(DESTDIR)$(INSTALL_LIB_DIR) + +depend: $(VGAPI_SOURCES) + @echo "running $(MKDEP)" + @touch depend + @$(MKDEP) $(MKDEP_OPTIONS) -f- $(DEFINES) $(INCLUDE_DIRS) \ + $(VGAPI_CPPFLAGS) $(VGAPI_SOURCES) 2>/dev/null | \ + sed -e 's,^$(MAPI)/,,' > depend diff --git a/src/mapi/vgapi/vg.pc.in b/src/mapi/vgapi/vg.pc.in new file mode 100644 index 00000000000..63e9af8355b --- /dev/null +++ b/src/mapi/vgapi/vg.pc.in @@ -0,0 +1,12 @@ +prefix=@INSTALL_DIR@ +exec_prefix=${prefix} +libdir=@INSTALL_LIB_DIR@ +includedir=@INSTALL_INC_DIR@ + +Name: vg +Description: Mesa OpenVG 1.0 library +Requires.private: @VG_PC_REQ_PRIV@ +Version: @VERSION@ +Libs: -L${libdir} -l@VG_LIB@ +Libs.private: @VG_PC_LIB_PRIV@ +Cflags: -I${includedir} @VG_PC_CFLAGS@ diff --git a/src/mapi/vgapi/vgapi.csv b/src/mapi/vgapi/vgapi.csv new file mode 100644 index 00000000000..d28ee32b28b --- /dev/null +++ b/src/mapi/vgapi/vgapi.csv @@ -0,0 +1,93 @@ +# This is the source file for the various generate structs/tables/functions +# used in st/vega. + +# OpenVG 1.0 +void, AppendPath, VGPath dstPath, VGPath srcPath +void, AppendPathData, VGPath dstPath, VGint numSegments, const VGubyte *pathSegments, const void *pathData +VGImage, ChildImage, VGImage parent, VGint x, VGint y, VGint width, VGint height +void, Clear, VGint x, VGint y, VGint width, VGint height +void, ClearImage, VGImage image, VGint x, VGint y, VGint width, VGint height +void, ClearPath, VGPath path, VGbitfield capabilities +void, ColorMatrix, VGImage dst, VGImage src, const VGfloat *matrix +void, Convolve, VGImage dst, VGImage src, VGint kernelWidth, VGint kernelHeight, VGint shiftX, VGint shiftY, const VGshort *kernel, VGfloat scale, VGfloat bias, VGTilingMode tilingMode +void, CopyImage, VGImage dst, VGint dx, VGint dy, VGImage src, VGint sx, VGint sy, VGint width, VGint height, VGboolean dither +void, CopyPixels, VGint dx, VGint dy, VGint sx, VGint sy, VGint width, VGint height +VGImage, CreateImage, VGImageFormat format, VGint width, VGint height, VGbitfield allowedQuality +VGPaint, CreatePaint, void +VGPath, CreatePath, VGint pathFormat, VGPathDatatype datatype, VGfloat scale, VGfloat bias, VGint segmentCapacityHint, VGint coordCapacityHint, VGbitfield capabilities +void, DestroyImage, VGImage image +void, DestroyPaint, VGPaint paint +void, DestroyPath, VGPath path +void, DrawImage, VGImage image +void, DrawPath, VGPath path, VGbitfield paintModes +void, Finish, void +void, Flush, void +void, GaussianBlur, VGImage dst, VGImage src, VGfloat stdDeviationX, VGfloat stdDeviationY, VGTilingMode tilingMode +VGuint, GetColor, VGPaint paint +VGErrorCode, GetError, void +void, GetImageSubData, VGImage image, void *data, VGint dataStride, VGImageFormat dataFormat, VGint x, VGint y, VGint width, VGint height +void, GetMatrix, VGfloat *m +VGPaint, GetPaint, VGPaintMode paintMode +VGint, GetParameterVectorSize, VGHandle object, VGint paramType +VGfloat, GetParameterf, VGHandle object, VGint paramType +void, GetParameterfv, VGHandle object, VGint paramType, VGint count, VGfloat *values +VGint, GetParameteri, VGHandle object, VGint paramType +void, GetParameteriv, VGHandle object, VGint paramType, VGint count, VGint *values +VGImage, GetParent, VGImage image +VGbitfield, GetPathCapabilities, VGPath path +void, GetPixels, VGImage dst, VGint dx, VGint dy, VGint sx, VGint sy, VGint width, VGint height +const VGubyte *, GetString, VGStringID name +VGint, GetVectorSize, VGParamType type +VGfloat, Getf, VGParamType type +void, Getfv, VGParamType type, VGint count, VGfloat *values +VGint, Geti, VGParamType type +void, Getiv, VGParamType type, VGint count, VGint *values +VGHardwareQueryResult, HardwareQuery, VGHardwareQueryType key, VGint setting +void, ImageSubData, VGImage image, const void *data, VGint dataStride, VGImageFormat dataFormat, VGint x, VGint y, VGint width, VGint height +VGboolean, InterpolatePath, VGPath dstPath, VGPath startPath, VGPath endPath, VGfloat amount +void, LoadIdentity, void +void, LoadMatrix, const VGfloat *m +void, Lookup, VGImage dst, VGImage src, const VGubyte *redLUT, const VGubyte *greenLUT, const VGubyte *blueLUT, const VGubyte *alphaLUT, VGboolean outputLinear, VGboolean outputPremultiplied +void, LookupSingle, VGImage dst, VGImage src, const VGuint *lookupTable, VGImageChannel sourceChannel, VGboolean outputLinear, VGboolean outputPremultiplied +void, Mask, VGHandle mask, VGMaskOperation operation, VGint x, VGint y, VGint width, VGint height +void, ModifyPathCoords, VGPath dstPath, VGint startIndex, VGint numSegments, const void *pathData +void, MultMatrix, const VGfloat *m +void, PaintPattern, VGPaint paint, VGImage pattern +void, PathBounds, VGPath path, VGfloat *minX, VGfloat *minY, VGfloat *width, VGfloat *height +VGfloat, PathLength, VGPath path, VGint startSegment, VGint numSegments +void, PathTransformedBounds, VGPath path, VGfloat *minX, VGfloat *minY, VGfloat *width, VGfloat *height +void, PointAlongPath, VGPath path, VGint startSegment, VGint numSegments, VGfloat distance, VGfloat *x, VGfloat *y, VGfloat *tangentX, VGfloat *tangentY +void, ReadPixels, void *data, VGint dataStride, VGImageFormat dataFormat, VGint sx, VGint sy, VGint width, VGint height +void, RemovePathCapabilities, VGPath path, VGbitfield capabilities +void, Rotate, VGfloat angle +void, Scale, VGfloat sx, VGfloat sy +void, SeparableConvolve, VGImage dst, VGImage src, VGint kernelWidth, VGint kernelHeight, VGint shiftX, VGint shiftY, const VGshort *kernelX, const VGshort *kernelY, VGfloat scale, VGfloat bias, VGTilingMode tilingMode +void, SetColor, VGPaint paint, VGuint rgba +void, SetPaint, VGPaint paint, VGbitfield paintModes +void, SetParameterf, VGHandle object, VGint paramType, VGfloat value +void, SetParameterfv, VGHandle object, VGint paramType, VGint count, const VGfloat *values +void, SetParameteri, VGHandle object, VGint paramType, VGint value +void, SetParameteriv, VGHandle object, VGint paramType, VGint count, const VGint *values +void, SetPixels, VGint dx, VGint dy, VGImage src, VGint sx, VGint sy, VGint width, VGint height +void, Setf, VGParamType type, VGfloat value +void, Setfv, VGParamType type, VGint count, const VGfloat *values +void, Seti, VGParamType type, VGint value +void, Setiv, VGParamType type, VGint count, const VGint *values +void, Shear, VGfloat shx, VGfloat shy +void, TransformPath, VGPath dstPath, VGPath srcPath +void, Translate, VGfloat tx, VGfloat ty +void, WritePixels, const void *data, VGint dataStride, VGImageFormat dataFormat, VGint dx, VGint dy, VGint width, VGint height + +## OpenVG 1.1 +#void, ClearGlyph, VGFont font,VGuint glyphIndex +#void, CopyMask, VGMaskLayer maskLayer, VGint dx, VGint dy, VGint sx, VGint sy, VGint width, VGint height +#VGFont, CreateFont, VGint glyphCapacityHint +#VGMaskLayer, CreateMaskLayer, VGint width, VGint height +#void, DestroyFont, VGFont font +#void, DestroyMaskLayer, VGMaskLayer maskLayer +#void, DrawGlyph, VGFont font, VGuint glyphIndex, VGbitfield paintModes, VGboolean allowAutoHinting +#void, DrawGlyphs, VGFont font, VGint glyphCount, const VGuint *glyphIndices, const VGfloat *adjustments_x, const VGfloat *adjustments_y, VGbitfield paintModes, VGboolean allowAutoHinting +#void, FillMaskLayer, VGMaskLayer maskLayer, VGint x, VGint y, VGint width, VGint height, VGfloat value +#void, RenderToMask, VGPath path, VGbitfield paintModes, VGMaskOperation operation +#void, SetGlyphToImage, VGFont font, VGuint glyphIndex, VGImage image, const VGfloat glyphOrigin[2], const VGfloat escapement[2] +#void, SetGlyphToPath, VGFont font, VGuint glyphIndex, VGPath path, VGboolean isHinted, const VGfloat glyphOrigin[2], const VGfloat escapement[2] diff --git a/src/mapi/vgapi/vgapi_defines.h b/src/mapi/vgapi/vgapi_defines.h new file mode 100644 index 00000000000..fb9f68c7adf --- /dev/null +++ b/src/mapi/vgapi/vgapi_defines.h @@ -0,0 +1,11 @@ +#ifndef VGAPI_DEFINES_H +#define VGAPI_DEFINES_H + +#include "VG/openvg.h" +#include "VG/vgext.h" + +#define MAPI_ABI_PREFIX vg +#define MAPI_ABI_PUBLIC VG_API_CALL +#define MAPI_ABI_ATTR VG_API_ENTRY + +#endif /* VGAPI_DEFINES_H */ diff --git a/src/mesa/.gitignore b/src/mesa/.gitignore index b83498b1d9d..ce83eaf47e0 100644 --- a/src/mesa/.gitignore +++ b/src/mesa/.gitignore @@ -1,2 +1,5 @@ */gen_matypes */matypes.h +depend.es* +depend.es* +objs-es* diff --git a/src/mesa/Makefile b/src/mesa/Makefile index 72f983e10a0..3bb2f39475b 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -3,33 +3,68 @@ TOP = ../.. include $(TOP)/configs/current +MESA_LIBS := libmesa.a libmesagallium.a +DEPENDS := depend + +ifeq ($(GLES_OVERLAY),1) +ES1_LIBS := libes1gallium.a +ES2_LIBS := libes2gallium.a +DEPENDS += depend.es1 depend.es2 +endif + +MESA_OBJ_DIR := . +ES1_OBJ_DIR := objs-es1 +ES2_OBJ_DIR := objs-es2 + +MESA_CPPFLAGS := $(API_DEFINES) +ES1_CPPFLAGS := -DFEATURE_ES1=1 -D__GL_EXPORTS +ES2_CPPFLAGS := -DFEATURE_ES2=1 -D__GL_EXPORTS + include sources.mak -.SUFFIXES : .cpp +# adjust object dirs +ES1_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(MESA_OBJECTS)) +ES2_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(MESA_OBJECTS)) +MESA_OBJECTS := $(addprefix $(MESA_OBJ_DIR)/, $(MESA_OBJECTS)) + +ES1_GALLIUM_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(MESA_GALLIUM_OBJECTS)) +ES2_GALLIUM_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(MESA_GALLIUM_OBJECTS)) +MESA_GALLIUM_OBJECTS := $(addprefix $(MESA_OBJ_DIR)/, $(MESA_GALLIUM_OBJECTS)) + +# adjust include dirs +MESA_INCLUDES := $(INCLUDE_DIRS) +ES1_INCLUDES := -I$(TOP)/src/mapi/es1api $(INCLUDE_DIRS) +ES2_INCLUDES := -I$(TOP)/src/mapi/es2api $(INCLUDE_DIRS) + + +define mesa-cc-c + @mkdir -p $(dir $@) + $(CC) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_INCLUDES) $(CFLAGS) +endef + +$(MESA_OBJ_DIR)/%.o: %.c + $(call mesa-cc-c,MESA) -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ +$(MESA_OBJ_DIR)/%.o: %.S + $(call mesa-cc-c,MESA) -.cpp.o: - $(CXX) -c $(INCLUDE_DIRS) $(CXXFLAGS) $< -o $@ +$(ES1_OBJ_DIR)/%.o: %.c + $(call mesa-cc-c,ES1) -.S.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ +$(ES1_OBJ_DIR)/%.o: %.S + $(call mesa-cc-c,ES1) -CFLAGS += $(API_DEFINES) +$(ES2_OBJ_DIR)/%.o: %.c + $(call mesa-cc-c,ES2) + +$(ES2_OBJ_DIR)/%.o: %.S + $(call mesa-cc-c,ES2) # Default: build dependencies, then asm_subdirs, GLSL built-in lib, # then convenience libs (.a) and finally the device drivers: -default: depend es_glapi asm_subdirs glsl_builtin libmesa.a libmesagallium.a \ - libglapi.a driver_subdirs - -es_glapi: - @for api in $(APIS) ; do \ - case "$$api" in \ - es1|es2) $(MAKE) -C es/glapi $$api;; \ - esac; \ - done +default: $(DEPENDS) asm_subdirs glsl_builtin \ + $(MESA_LIBS) $(ES1_LIBS) $(ES2_LIBS) driver_subdirs main/api_exec_es1.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.xml -V GLES1.1 > $@ @@ -37,12 +72,6 @@ main/api_exec_es1.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py m main/api_exec_es2.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.xml -V GLES2.0 > $@ -main/get_es1.c: main/get_gen_es.py - $(PYTHON2) $(PYTHON_FLAGS) $< 1 > $@ - -main/get_es2.c: main/get_gen_es.py - $(PYTHON2) $(PYTHON_FLAGS) $< 2 > $@ - ###################################################################### # Helper libraries used by many drivers: @@ -50,17 +79,25 @@ main/get_es2.c: main/get_gen_es.py libmesa.a: $(MESA_OBJECTS) $(GLSL_LIBS) @ $(MKLIB) -o mesa -static $(MESA_OBJECTS) $(GLSL_LIBS) +libes1.a: $(ES1_OBJECTS) $(GLSL_LIBS) + @$(MKLIB) -o es1 -static $(ES1_OBJECTS) $(GLSL_LIBS) + +libes2.a: $(ES2_OBJECTS) $(GLSL_LIBS) + @$(MKLIB) -o es2 -static $(ES2_OBJECTS) $(GLSL_LIBS) + # Make archive of subset of core mesa object files for gallium libmesagallium.a: $(MESA_GALLIUM_OBJECTS) $(GLSL_LIBS) @ $(MKLIB) -o mesagallium -static $(MESA_GALLIUM_OBJECTS) $(GLSL_LIBS) -# Make archive of gl* API dispatcher functions only -libglapi.a: $(GLAPI_OBJECTS) - @ $(MKLIB) -o glapi -static $(GLAPI_OBJECTS) +libes1gallium.a: $(ES1_GALLIUM_OBJECTS) $(GLSL_LIBS) + @$(MKLIB) -o es1gallium -static $(ES1_GALLIUM_OBJECTS) $(GLSL_LIBS) + +libes2gallium.a: $(ES2_GALLIUM_OBJECTS) $(GLSL_LIBS) + @$(MKLIB) -o es2gallium -static $(ES2_GALLIUM_OBJECTS) $(GLSL_LIBS) ###################################################################### # Device drivers -driver_subdirs: libmesa.a libglapi.a libmesagallium.a +driver_subdirs: $(MESA_LIBS) @ (cd drivers && $(MAKE)) @@ -88,9 +125,22 @@ glsl_builtin: depend: $(ALL_SOURCES) @ echo "running $(MKDEP)" @ touch depend - @$(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(ALL_SOURCES) \ + @$(MKDEP) $(MKDEP_OPTIONS) -p$(MESA_OBJ_DIR)/ $(DEFINES) \ + $(INCLUDE_DIRS) $(ALL_SOURCES) > /dev/null 2>/dev/null + +depend.es1: $(ALL_SOURCES) + @echo "running $(MKDEP) for ES1" + @touch $@ + @$(MKDEP) $(MKDEP_OPTIONS) -f$@ -p$(ES1_OBJ_DIR)/ $(DEFINES) \ + $(ES1_CPPFLAGS) $(ES1_INCLUDES) $(ALL_SOURCES) \ > /dev/null 2>/dev/null +depend.es2: $(ALL_SOURCES) + @echo "running $(MKDEP) for ES2" + @touch $@ + @$(MKDEP) $(MKDEP_OPTIONS) -f$@ -p$(ES2_OBJ_DIR)/ $(DEFINES) \ + $(ES2_CPPFLAGS) $(ES2_INCLUDES) $(ALL_SOURCES) \ + > /dev/null 2>/dev/null ###################################################################### # Installation rules @@ -112,12 +162,6 @@ install: default dri) $(MAKE) install-libgl install-dri || exit 1 ;; \ *) $(MAKE) install-libgl || exit 1 ;; \ esac ; \ - done; \ - for api in $(APIS) ; do \ - case "$$api" in \ - es1) $(MAKE) install-es1 || exit 1;; \ - es2) $(MAKE) install-es2 || exit 1;; \ - esac; \ done pcedit = \ @@ -137,22 +181,6 @@ gl_pcedit = sed \ gl.pc: gl.pc.in $(gl_pcedit) $< > $@ -glesv2_pcedit = sed \ - $(pcedit) \ - -e 's,@GLESv2_PC_LIB_PRIV@,$(GLESv2_PC_LIB_PRIV),' \ - -e 's,@GLESv2_LIB@,$(GLESv2_LIB),' - -glesv2.pc: glesv2.pc.in - $(glesv2_pcedit) $< > $@ - -glesv1_cm_pcedit = sed \ - $(pcedit) \ - -e 's,@GLESv1_CM_PC_LIB_PRIV@,$(GLESv1_CM_PC_LIB_PRIV),' \ - -e 's,@GLESv1_CM_LIB@,$(GLESv1_CM_LIB),' - -glesv1_cm.pc: glesv1_cm.pc.in - $(glesv1_cm_pcedit) $< > $@ - osmesa_pcedit = sed \ $(pcedit) \ -e 's,@OSMESA_LIB@,$(OSMESA_LIB),' \ @@ -174,30 +202,6 @@ install-libgl: default gl.pc install-headers $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 gl.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig -install-headers-es1: - $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GLES - $(INSTALL) -m 644 $(TOP)/include/GLES/*.h \ - $(DESTDIR)$(INSTALL_INC_DIR)/GLES - -install-es1: default glesv1_cm.pc install-headers-es1 - $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig - $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GLESv1_CM_LIB_GLOB) \ - $(DESTDIR)$(INSTALL_LIB_DIR) - $(INSTALL) -m 644 glesv1_cm.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig - -install-headers-es2: - $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GLES2 - $(INSTALL) -m 644 $(TOP)/include/GLES2/*.h \ - $(DESTDIR)$(INSTALL_INC_DIR)/GLES2 - -install-es2: default glesv2.pc install-headers-es2 - $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig - $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GLESv2_LIB_GLOB) \ - $(DESTDIR)$(INSTALL_LIB_DIR) - $(INSTALL) -m 644 glesv2.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig - install-osmesa: default osmesa.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig @@ -214,11 +218,20 @@ install-dri: default tags: etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h +clean-es1: + -rm -f $(ES1_LIBS) + -rm -rf $(ES1_OBJ_DIR) + -rm -f depend.es1 depend.es1.bak + +clean-es2: + -rm -f $(ES2_LIBS) + -rm -rf $(ES2_OBJ_DIR) + -rm -f depend.es2 depend.es2.bak -clean: +clean: clean-es1 clean-es2 -rm -f */*.o -rm -f */*/*.o - -rm -f depend depend.bak libmesa.a libglapi.a libmesagallium.a + -rm -f depend depend.bak libmesa.a libmesagallium.a -rm -f drivers/*/*.o -rm -f *.pc -rm -f shader/slang/library/*_gc.h @@ -229,4 +242,4 @@ clean: -@cd x86-64 && $(MAKE) clean --include depend +-include $(DEPENDS) diff --git a/src/mesa/SConscript b/src/mesa/SConscript index a7572af45d4..b553804fcdc 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -9,6 +9,7 @@ if env['platform'] != 'winddk': env = env.Clone() env.Append(CPPPATH = [ + '#/src/mapi', '#/src/mesa', ]) @@ -78,7 +79,6 @@ if env['platform'] != 'winddk': 'main/polygon.c', 'main/queryobj.c', 'main/rastpos.c', - 'main/rbadaptors.c', 'main/readpix.c', 'main/remap.c', 'main/renderbuffer.c', @@ -177,6 +177,7 @@ if env['platform'] != 'winddk': 'state_tracker/st_cb_readpixels.c', 'state_tracker/st_cb_strings.c', 'state_tracker/st_cb_texture.c', + 'state_tracker/st_cb_xformfb.c', 'state_tracker/st_context.c', 'state_tracker/st_debug.c', 'state_tracker/st_draw.c', @@ -249,16 +250,6 @@ if env['platform'] != 'winddk': slang_sources ) - glapi_sources = [ - 'glapi/glapi.c', - 'glapi/glapi_dispatch.c', - 'glapi/glapi_entrypoint.c', - 'glapi/glapi_execmem.c', - 'glapi/glapi_getproc.c', - 'glapi/glapi_nop.c', - 'glapi/glthread.c', - ] - # # Assembly sources # @@ -292,9 +283,6 @@ if env['platform'] != 'winddk': 'x86/sse_normal.S', 'x86/read_rgba_span_x86.S', ] - glapi_sources += [ - 'x86/glapi_x86.S', - ] elif gcc and env['machine'] == 'x86_64': env.Append(CPPDEFINES = [ 'USE_X86_64_ASM', @@ -303,9 +291,6 @@ if env['platform'] != 'winddk': 'x86-64/x86-64.c', 'x86-64/xform4.S', ] - glapi_sources += [ - 'x86-64/glapi_x86-64.S' - ] elif gcc and env['machine'] == 'ppc': env.Append(CPPDEFINES = [ 'USE_PPC_ASM', @@ -314,8 +299,6 @@ if env['platform'] != 'winddk': mesa_sources += [ 'ppc/common_ppc.c', ] - glapi_sources += [ - ] elif gcc and env['machine'] == 'sparc': mesa_sources += [ 'sparc/sparc.c', @@ -323,9 +306,6 @@ if env['platform'] != 'winddk': 'sparc/norm.S', 'sparc/xform.S', ] - glapi_sources += [ - 'sparc/glapi_sparc.S' - ] else: pass @@ -356,10 +336,3 @@ if env['platform'] != 'winddk': source = mesa_sources, ) Export('mesa') - - glapi = env.ConvenienceLibrary( - target = 'glapi', - source = glapi_sources, - ) - Export('glapi') - diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index ebfaa2f07bd..ca5eb5c7552 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -47,6 +47,9 @@ #if FEATURE_ARB_sync #include "main/syncobj.h" #endif +#if FEATURE_EXT_transform_feedback +#include "main/transformfeedback.h" +#endif #include "shader/program.h" #include "shader/shader_api.h" @@ -178,14 +181,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->TexParameter = NULL; driver->Viewport = NULL; - /* state queries */ - driver->GetBooleanv = NULL; - driver->GetDoublev = NULL; - driver->GetFloatv = NULL; - driver->GetIntegerv = NULL; - driver->GetInteger64v = NULL; - driver->GetPointerv = NULL; - /* buffer objects */ _mesa_init_buffer_object_functions(driver); @@ -213,6 +208,10 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->DeleteArrayObject = _mesa_delete_array_object; driver->BindArrayObject = NULL; +#if FEATURE_EXT_transform_feedback + _mesa_init_transform_feedback_functions(driver); +#endif + /* T&L stuff */ driver->NeedValidate = GL_FALSE; driver->ValidateTnlModule = NULL; diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index 4b9a0c1786d..8cb25439e48 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -26,6 +26,7 @@ SHARED_INCLUDES = \ -I$(TOP)/src/mesa/drivers/dri/common \ -Iserver \ -I$(TOP)/include \ + -I$(TOP)/src/mapi \ -I$(TOP)/src/mesa \ -I$(TOP)/src/egl/main \ -I$(TOP)/src/egl/drivers/dri \ diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 360c5247548..c3d1f2c4542 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -736,6 +736,8 @@ setupLoaderExtensions(__DRIscreen *psp, psp->dri2.loader = (__DRIdri2LoaderExtension *) extensions[i]; if (strcmp(extensions[i]->name, __DRI_IMAGE_LOOKUP) == 0) psp->dri2.image = (__DRIimageLookupExtension *) extensions[i]; + if (strcmp(extensions[i]->name, __DRI_USE_INVALIDATE) == 0) + psp->dri2.useInvalidate = (__DRIuseInvalidateExtension *) extensions[i]; } } diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index ab6c6e57afc..e4c590b1322 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -527,6 +527,7 @@ struct __DRIscreenRec { int enabled; __DRIdri2LoaderExtension *loader; __DRIimageLookupExtension *image; + __DRIuseInvalidateExtension *useInvalidate; } dri2; /* The lock actually in use, old sarea or DRI2 */ diff --git a/src/mesa/drivers/dri/i915/i830_state.c b/src/mesa/drivers/dri/i915/i830_state.c index 3b9b3ae329e..38e524e183c 100644 --- a/src/mesa/drivers/dri/i915/i830_state.c +++ b/src/mesa/drivers/dri/i915/i830_state.c @@ -453,8 +453,6 @@ i830Viewport(GLcontext * ctx, GLint x, GLint y, GLsizei width, GLsizei height) { intelCalcViewport(ctx); - - intel_viewport(ctx, x, y, width, height); } diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c index 91b228d52b9..26d387f383a 100644 --- a/src/mesa/drivers/dri/i915/i915_state.c +++ b/src/mesa/drivers/dri/i915/i915_state.c @@ -394,8 +394,6 @@ i915Viewport(GLcontext * ctx, GLint x, GLint y, GLsizei width, GLsizei height) { intelCalcViewport(ctx); - - intel_viewport(ctx, x, y, width, height); } diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index 9449a158dc6..7aecf68e4a8 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -1208,7 +1208,7 @@ intelFallback(struct intel_context *intel, GLbitfield bit, GLboolean mode) if (mode) { intel->Fallback |= bit; if (oldfallback == 0) { - intelFlush(ctx); + intel_flush(ctx); if (INTEL_DEBUG & DEBUG_FALLBACKS) fprintf(stderr, "ENTER FALLBACK %x: %s\n", bit, getFallbackString(bit)); diff --git a/src/mesa/drivers/dri/i965/brw_clip.c b/src/mesa/drivers/dri/i965/brw_clip.c index 029a16500b5..49ef859e456 100644 --- a/src/mesa/drivers/dri/i965/brw_clip.c +++ b/src/mesa/drivers/dri/i965/brw_clip.c @@ -42,7 +42,6 @@ #include "brw_state.h" #include "brw_clip.h" - #define FRONT_UNFILLED_BIT 0x1 #define BACK_UNFILLED_BIT 0x2 @@ -127,6 +126,14 @@ static void compile_clip_prog( struct brw_context *brw, */ program = brw_get_program(&c.func, &program_size); + if (INTEL_DEBUG & DEBUG_CLIP) { + printf("clip:\n"); + for (i = 0; i < program_size / sizeof(struct brw_instruction); i++) + brw_disasm(stdout, &((struct brw_instruction *)program)[i], + intel->gen); + printf("\n"); + } + /* Upload */ dri_bo_unreference(brw->clip.prog_bo); diff --git a/src/mesa/drivers/dri/i965/brw_clip.h b/src/mesa/drivers/dri/i965/brw_clip.h index d71bac7f617..68222c6c278 100644 --- a/src/mesa/drivers/dri/i965/brw_clip.h +++ b/src/mesa/drivers/dri/i965/brw_clip.h @@ -114,8 +114,6 @@ struct brw_clip_compile { GLboolean need_direction; - GLuint last_mrf; - GLuint header_position_offset; GLuint offset[VERT_ATTRIB_MAX]; }; diff --git a/src/mesa/drivers/dri/i965/brw_clip_tri.c b/src/mesa/drivers/dri/i965/brw_clip_tri.c index b27fe654ca9..916a99ea004 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_tri.c +++ b/src/mesa/drivers/dri/i965/brw_clip_tri.c @@ -177,7 +177,7 @@ void brw_clip_tri_init_vertices( struct brw_clip_compile *c ) void brw_clip_tri_flat_shade( struct brw_clip_compile *c ) { struct brw_compile *p = &c->func; - struct brw_instruction *is_poly; + struct brw_instruction *is_poly, *is_trifan; struct brw_reg tmp0 = c->reg.loopcount; /* handy temporary */ brw_AND(p, tmp0, get_element_ud(c->reg.R0, 2), brw_imm_ud(PRIM_MASK)); @@ -195,8 +195,22 @@ void brw_clip_tri_flat_shade( struct brw_clip_compile *c ) is_poly = brw_ELSE(p, is_poly); { if (c->key.pv_first) { - brw_clip_copy_colors(c, 1, 0); - brw_clip_copy_colors(c, 2, 0); + brw_CMP(p, + vec1(brw_null_reg()), + BRW_CONDITIONAL_EQ, + tmp0, + brw_imm_ud(_3DPRIM_TRIFAN)); + is_trifan = brw_IF(p, BRW_EXECUTE_1); + { + brw_clip_copy_colors(c, 0, 1); + brw_clip_copy_colors(c, 2, 1); + } + is_trifan = brw_ELSE(p, is_trifan); + { + brw_clip_copy_colors(c, 1, 0); + brw_clip_copy_colors(c, 2, 0); + } + brw_ENDIF(p, is_trifan); } else { brw_clip_copy_colors(c, 0, 2); diff --git a/src/mesa/drivers/dri/i965/brw_clip_util.c b/src/mesa/drivers/dri/i965/brw_clip_util.c index 34a966a47a2..2148bc8244a 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_util.c +++ b/src/mesa/drivers/dri/i965/brw_clip_util.c @@ -211,27 +211,14 @@ void brw_clip_emit_vue(struct brw_clip_compile *c, GLuint header) { struct brw_compile *p = &c->func; - GLuint start = c->last_mrf; brw_clip_ff_sync(c); assert(!(allocate && eot)); - - /* Cycle through mrf regs - probably futile as we have to wait for - * the allocation response anyway. Also, the order this function - * is invoked doesn't correspond to the order the instructions will - * be executed, so it won't have any effect in many cases. - */ -#if 0 - if (start + c->nr_regs + 1 >= MAX_MRF) - start = 0; - c->last_mrf = start + c->nr_regs + 1; -#endif - /* Copy the vertex from vertn into m1..mN+1: */ - brw_copy_from_indirect(p, brw_message_reg(start+1), vert, c->nr_regs); + brw_copy_from_indirect(p, brw_message_reg(1), vert, c->nr_regs); /* Overwrite PrimType and PrimStart in the message header, for * each vertex in turn: @@ -247,7 +234,7 @@ void brw_clip_emit_vue(struct brw_clip_compile *c, */ brw_urb_WRITE(p, allocate ? c->reg.R0 : retype(brw_null_reg(), BRW_REGISTER_TYPE_UD), - start, + 0, c->reg.R0, allocate, 1, /* used */ @@ -370,18 +357,13 @@ void brw_clip_ff_sync(struct brw_clip_compile *c) need_ff_sync = brw_IF(p, BRW_EXECUTE_1); { brw_OR(p, c->reg.ff_sync, c->reg.ff_sync, brw_imm_ud(0x1)); - brw_ff_sync(p, - c->reg.R0, - 0, - c->reg.R0, - 1, - 1, /* used */ - 1, /* msg length */ - 1, /* response length */ - 0, /* eot */ - 1, /* write compelete */ - 0, /* urb offset */ - BRW_URB_SWIZZLE_NONE); + brw_ff_sync(p, + c->reg.R0, + 0, + c->reg.R0, + 1, /* allocate */ + 1, /* response length */ + 0 /* eot */); } brw_ENDIF(p, need_ff_sync); brw_set_predicate_control(p, BRW_PREDICATE_NONE); diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 523a11aea33..dc4bd5802d4 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -64,8 +64,6 @@ static void brwInitDriverFunctions( struct dd_function_table *functions ) brwInitFragProgFuncs( functions ); brwInitProgFuncs( functions ); brw_init_queryobj_functions(functions); - - functions->Viewport = intel_viewport; } GLboolean brwCreateContext( int api, @@ -194,8 +192,6 @@ GLboolean brwCreateContext( int api, ctx->VertexProgram._MaintainTnlProgram = GL_TRUE; ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; - make_empty_list(&brw->query.active_head); - brw_draw_init( brw ); return GL_TRUE; diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 1f09651126b..a97fcb0f4db 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -418,18 +418,12 @@ struct brw_vertex_info { struct brw_query_object { struct gl_query_object Base; - /** Doubly linked list of active query objects in the context. */ - struct brw_query_object *prev, *next; - /** Last query BO associated with this query. */ dri_bo *bo; /** First index in bo with query data for this object. */ int first_index; /** Last index in bo with query data for this object. */ int last_index; - - /* Total count of pixels from previous BOs */ - unsigned int count; }; @@ -664,7 +658,7 @@ struct brw_context } cc; struct { - struct brw_query_object active_head; + struct brw_query_object *obj; dri_bo *bo; int index; GLboolean active; @@ -726,7 +720,7 @@ void brw_upload_urb_fence(struct brw_context *brw); void brw_upload_cs_urb_state(struct brw_context *brw); /* brw_disasm.c */ -int brw_disasm (FILE *file, struct brw_instruction *inst); +int brw_disasm (FILE *file, struct brw_instruction *inst, int gen); /*====================================================================== * Inline conversion functions. These are better-typed than the diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index f26a13fc3c3..2d3556b8054 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -783,7 +783,7 @@ #define CMD_BINDING_TABLE_PTRS 0x7801 # define GEN6_BINDING_TABLE_MODIFY_VS (1 << 8) # define GEN6_BINDING_TABLE_MODIFY_GS (1 << 9) -# define GEN6_BINDING_TABLE_MODIFY_PS (1 << 10) +# define GEN6_BINDING_TABLE_MODIFY_PS (1 << 12) #define CMD_3D_SAMPLER_STATE_POINTERS 0x7802 /* SNB+ */ # define PS_SAMPLER_STATE_CHANGE (1 << 12) diff --git a/src/mesa/drivers/dri/i965/brw_disasm.c b/src/mesa/drivers/dri/i965/brw_disasm.c index db3fc50a63b..ff12daf497d 100644 --- a/src/mesa/drivers/dri/i965/brw_disasm.c +++ b/src/mesa/drivers/dri/i965/brw_disasm.c @@ -323,6 +323,11 @@ char *math_precision[2] = { [1] = "partial_precision" }; +char *urb_opcode[2] = { + [0] = "urb_write", + [1] = "ff_sync", +}; + char *urb_swizzle[4] = { [BRW_URB_SWIZZLE_NONE] = "", [BRW_URB_SWIZZLE_INTERLEAVE] = "interleave", @@ -774,7 +779,7 @@ static int src1 (FILE *file, struct brw_instruction *inst) } } -int brw_disasm (FILE *file, struct brw_instruction *inst) +int brw_disasm (FILE *file, struct brw_instruction *inst, int gen) { int err = 0; int space = 0; @@ -829,12 +834,20 @@ int brw_disasm (FILE *file, struct brw_instruction *inst) } if (inst->header.opcode == BRW_OPCODE_SEND) { + int target; + + if (gen >= 5) + target = inst->bits2.send_gen5.sfid; + else + target = inst->bits3.generic.msg_target; + newline (file); pad (file, 16); space = 0; err |= control (file, "target function", target_function, - inst->bits3.generic.msg_target, &space); - switch (inst->bits3.generic.msg_target) { + target, &space); + + switch (target) { case BRW_MESSAGE_TARGET_MATH: err |= control (file, "math function", math_function, inst->bits3.math.function, &space); @@ -864,8 +877,17 @@ int brw_disasm (FILE *file, struct brw_instruction *inst) inst->bits3.dp_write.send_commit_msg); break; case BRW_MESSAGE_TARGET_URB: - format (file, " %d", inst->bits3.urb.offset); + if (gen >= 5) { + format (file, " %d", inst->bits3.urb_gen5.offset); + } else { + format (file, " %d", inst->bits3.urb.offset); + } + space = 1; + if (gen >= 5) { + err |= control (file, "urb opcode", urb_opcode, + inst->bits3.urb_gen5.opcode, &space); + } err |= control (file, "urb swizzle", urb_swizzle, inst->bits3.urb.swizzle_control, &space); err |= control (file, "urb allocate", urb_allocate, diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index e348d4686b1..fe633d3e254 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -77,32 +77,41 @@ static const GLenum reduced_prim[GL_POLYGON+1] = { * programs be immune to the active primitive (ie. cope with all * possibilities). That may not be realistic however. */ -static GLuint brw_set_prim(struct brw_context *brw, GLenum prim) +static GLuint brw_set_prim(struct brw_context *brw, + const struct _mesa_prim *prim) { GLcontext *ctx = &brw->intel.ctx; + GLenum mode = prim->mode; if (INTEL_DEBUG & DEBUG_PRIMS) - printf("PRIM: %s\n", _mesa_lookup_enum_by_nr(prim)); - + printf("PRIM: %s\n", _mesa_lookup_enum_by_nr(prim->mode)); + /* Slight optimization to avoid the GS program when not needed: */ - if (prim == GL_QUAD_STRIP && + if (mode == GL_QUAD_STRIP && ctx->Light.ShadeModel != GL_FLAT && ctx->Polygon.FrontMode == GL_FILL && ctx->Polygon.BackMode == GL_FILL) - prim = GL_TRIANGLE_STRIP; + mode = GL_TRIANGLE_STRIP; + + if (prim->mode == GL_QUADS && prim->count == 4 && + ctx->Light.ShadeModel != GL_FLAT && + ctx->Polygon.FrontMode == GL_FILL && + ctx->Polygon.BackMode == GL_FILL) { + mode = GL_TRIANGLE_FAN; + } - if (prim != brw->primitive) { - brw->primitive = prim; + if (mode != brw->primitive) { + brw->primitive = mode; brw->state.dirty.brw |= BRW_NEW_PRIMITIVE; - if (reduced_prim[prim] != brw->intel.reduced_primitive) { - brw->intel.reduced_primitive = reduced_prim[prim]; + if (reduced_prim[mode] != brw->intel.reduced_primitive) { + brw->intel.reduced_primitive = reduced_prim[mode]; brw->state.dirty.brw |= BRW_NEW_REDUCED_PRIMITIVE; } } - return prim_to_hw_prim[prim]; + return prim_to_hw_prim[mode]; } @@ -351,7 +360,7 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx, */ intel_batchbuffer_require_space(intel->batch, intel->batch->size / 4); - hw_prim = brw_set_prim(brw, prim[i].mode); + hw_prim = brw_set_prim(brw, &prim[i]); if (first_time || (brw->state.dirty.brw & BRW_NEW_PRIMITIVE)) { first_time = GL_FALSE; diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 8247faa36d8..9cbff24863d 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -59,7 +59,7 @@ static GLuint half_float_types[5] = { 0, BRW_SURFACEFORMAT_R16_FLOAT, BRW_SURFACEFORMAT_R16G16_FLOAT, - 0, /* can't seem to render this one */ + BRW_SURFACEFORMAT_R16G16B16A16_FLOAT, BRW_SURFACEFORMAT_R16G16B16A16_FLOAT }; diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h index 4f55158e8f3..3a32ad26c12 100644 --- a/src/mesa/drivers/dri/i965/brw_eu.h +++ b/src/mesa/drivers/dri/i965/brw_eu.h @@ -822,13 +822,8 @@ void brw_ff_sync(struct brw_compile *p, GLuint msg_reg_nr, struct brw_reg src0, GLboolean allocate, - GLboolean used, - GLuint msg_length, GLuint response_length, - GLboolean eot, - GLboolean writes_complete, - GLuint offset, - GLuint swizzle); + GLboolean eot); void brw_fb_WRITE(struct brw_compile *p, struct brw_reg dest, diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 785d382a009..175899b0268 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -280,28 +280,23 @@ static void brw_set_math_message( struct brw_context *brw, } -static void brw_set_ff_sync_message( struct brw_context *brw, - struct brw_instruction *insn, - GLboolean allocate, - GLboolean used, - GLuint msg_length, - GLuint response_length, - GLboolean end_of_thread, - GLboolean complete, - GLuint offset, - GLuint swizzle_control ) +static void brw_set_ff_sync_message(struct brw_context *brw, + struct brw_instruction *insn, + GLboolean allocate, + GLuint response_length, + GLboolean end_of_thread) { brw_set_src1(insn, brw_imm_d(0)); - insn->bits3.urb_gen5.opcode = 1; - insn->bits3.urb_gen5.offset = offset; - insn->bits3.urb_gen5.swizzle_control = swizzle_control; + insn->bits3.urb_gen5.opcode = 1; /* FF_SYNC */ + insn->bits3.urb_gen5.offset = 0; /* Not used by FF_SYNC */ + insn->bits3.urb_gen5.swizzle_control = 0; /* Not used by FF_SYNC */ insn->bits3.urb_gen5.allocate = allocate; - insn->bits3.urb_gen5.used = used; - insn->bits3.urb_gen5.complete = complete; + insn->bits3.urb_gen5.used = 0; /* Not used by FF_SYNC */ + insn->bits3.urb_gen5.complete = 0; /* Not used by FF_SYNC */ insn->bits3.urb_gen5.header_present = 1; - insn->bits3.urb_gen5.response_length = response_length; - insn->bits3.urb_gen5.msg_length = msg_length; + insn->bits3.urb_gen5.response_length = response_length; /* may be 1 or 0 */ + insn->bits3.urb_gen5.msg_length = 1; insn->bits3.urb_gen5.end_of_thread = end_of_thread; insn->bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_URB; insn->bits2.send_gen5.end_of_thread = end_of_thread; @@ -1451,18 +1446,11 @@ void brw_ff_sync(struct brw_compile *p, GLuint msg_reg_nr, struct brw_reg src0, GLboolean allocate, - GLboolean used, - GLuint msg_length, GLuint response_length, - GLboolean eot, - GLboolean writes_complete, - GLuint offset, - GLuint swizzle) + GLboolean eot) { struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND); - assert(msg_length < 16); - brw_set_dest(insn, dest); brw_set_src0(insn, src0); brw_set_src1(insn, brw_imm_d(0)); @@ -1470,13 +1458,8 @@ void brw_ff_sync(struct brw_compile *p, insn->header.destreg__conditionalmod = msg_reg_nr; brw_set_ff_sync_message(p->brw, - insn, - allocate, - used, - msg_length, - response_length, - eot, - writes_complete, - offset, - swizzle); + insn, + allocate, + response_length, + eot); } diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index 4b13494ecf9..94d93f3aa65 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -122,6 +122,16 @@ static void compile_gs_prog( struct brw_context *brw, */ program = brw_get_program(&c.func, &program_size); + if (INTEL_DEBUG & DEBUG_GS) { + int i; + + printf("gs:\n"); + for (i = 0; i < program_size / sizeof(struct brw_instruction); i++) + brw_disasm(stdout, &((struct brw_instruction *)program)[i], + intel->gen); + printf("\n"); + } + /* Upload */ dri_bo_unreference(brw->gs.prog_bo); @@ -163,6 +173,12 @@ static void populate_key( struct brw_context *brw, /* _NEW_LIGHT */ key->pv_first = (ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION); + if (key->primitive == GL_QUADS && ctx->Light.ShadeModel != GL_FLAT) { + /* Provide consistent primitive order with brw_set_prim's + * optimization of single quads to trifans. + */ + key->pv_first = GL_TRUE; + } key->need_gs_prog = (key->hint_gs_always || brw->primitive == GL_QUADS || diff --git a/src/mesa/drivers/dri/i965/brw_gs_emit.c b/src/mesa/drivers/dri/i965/brw_gs_emit.c index dd7b057d620..99a6f6be113 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_gs_emit.c @@ -104,18 +104,13 @@ static void brw_gs_ff_sync(struct brw_gs_compile *c, int num_prim) { struct brw_compile *p = &c->func; brw_MOV(p, get_element_ud(c->reg.R0, 1), brw_imm_ud(num_prim)); - brw_ff_sync(p, - c->reg.R0, - 0, - c->reg.R0, - 1, - 1, /* used */ - 1, /* msg length */ - 1, /* response length */ - 0, /* eot */ - 1, /* write compelete */ - 0, /* urb offset */ - BRW_URB_SWIZZLE_NONE); + brw_ff_sync(p, + c->reg.R0, + 0, + c->reg.R0, + 1, /* allocate */ + 1, /* response length */ + 0 /* eot */); } diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c index 6cce7e50890..3f47a68049f 100644 --- a/src/mesa/drivers/dri/i965/brw_queryobj.c +++ b/src/mesa/drivers/dri/i965/brw_queryobj.c @@ -38,7 +38,6 @@ * required for handling queries, so that we can be sure that we won't * have to emit a batchbuffer without getting the ending PS_DEPTH_COUNT. */ -#include "main/simple_list.h" #include "main/imports.h" #include "brw_context.h" @@ -105,7 +104,7 @@ brw_begin_query(GLcontext *ctx, struct gl_query_object *q) query->first_index = -1; query->last_index = -1; - insert_at_head(&brw->query.active_head, query); + brw->query.obj = query; intel->stats_wm++; } @@ -131,7 +130,7 @@ brw_end_query(GLcontext *ctx, struct gl_query_object *q) brw->query.bo = NULL; } - remove_from_list(query); + brw->query.obj = NULL; intel->stats_wm--; } @@ -161,7 +160,7 @@ brw_prepare_query_begin(struct brw_context *brw) struct intel_context *intel = &brw->intel; /* Skip if we're not doing any queries. */ - if (is_empty_list(&brw->query.active_head)) + if (!brw->query.obj) return; /* Get a new query BO if we're going to need it. */ @@ -182,10 +181,10 @@ void brw_emit_query_begin(struct brw_context *brw) { struct intel_context *intel = &brw->intel; - struct brw_query_object *query; + struct brw_query_object *query = brw->query.obj; /* Skip if we're not doing any queries, or we've emitted the start. */ - if (brw->query.active || is_empty_list(&brw->query.active_head)) + if (!query || brw->query.active) return; BEGIN_BATCH(4); @@ -205,16 +204,14 @@ brw_emit_query_begin(struct brw_context *brw) OUT_BATCH(0); ADVANCE_BATCH(); - foreach(query, &brw->query.active_head) { - if (query->bo != brw->query.bo) { - if (query->bo != NULL) - brw_queryobj_get_results(query); - dri_bo_reference(brw->query.bo); - query->bo = brw->query.bo; - query->first_index = brw->query.index; - } - query->last_index = brw->query.index; + if (query->bo != brw->query.bo) { + if (query->bo != NULL) + brw_queryobj_get_results(query); + dri_bo_reference(brw->query.bo); + query->bo = brw->query.bo; + query->first_index = brw->query.index; } + query->last_index = brw->query.index; brw->query.active = GL_TRUE; } diff --git a/src/mesa/drivers/dri/i965/brw_sf.c b/src/mesa/drivers/dri/i965/brw_sf.c index 57d1c29ade1..b0dd1ff3afb 100644 --- a/src/mesa/drivers/dri/i965/brw_sf.c +++ b/src/mesa/drivers/dri/i965/brw_sf.c @@ -46,6 +46,7 @@ static void compile_sf_prog( struct brw_context *brw, struct brw_sf_prog_key *key ) { + struct intel_context *intel = &brw->intel; struct brw_sf_compile c; const GLuint *program; GLuint program_size; @@ -107,6 +108,14 @@ static void compile_sf_prog( struct brw_context *brw, */ program = brw_get_program(&c.func, &program_size); + if (INTEL_DEBUG & DEBUG_SF) { + printf("sf:\n"); + for (i = 0; i < program_size / sizeof(struct brw_instruction); i++) + brw_disasm(stdout, &((struct brw_instruction *)program)[i], + intel->gen); + printf("\n"); + } + /* Upload */ dri_bo_unreference(brw->sf.prog_bo); @@ -154,6 +163,7 @@ static void upload_sf_prog(struct brw_context *brw) break; } + /* _NEW_POINT */ key.do_point_sprite = ctx->Point.PointSprite; if (key.do_point_sprite) { int i; diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index 44b085e214b..57ffb2d89e0 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -48,6 +48,7 @@ static void do_vs_prog( struct brw_context *brw, const GLuint *program; struct brw_vs_compile c; int aux_size; + int i; memset(&c, 0, sizeof(c)); memcpy(&c.key, key, sizeof(*key)); @@ -63,6 +64,17 @@ static void do_vs_prog( struct brw_context *brw, c.prog_data.inputs_read |= 1<<VERT_ATTRIB_EDGEFLAG; } + /* Put dummy slots into the VUE for the SF to put the replaced + * point sprite coords in. We shouldn't need these dummy slots, + * which take up precious URB space, but it would mean that the SF + * doesn't get nice aligned pairs of input coords into output + * coords, which would be a pain to handle. + */ + for (i = 0; i < 8; i++) { + if (c.key.point_coord_replace & (1 << i)) + c.prog_data.outputs_written |= BITFIELD64_BIT(VERT_RESULT_TEX0 + i); + } + if (0) _mesa_print_program(&c.vp->program.Base); @@ -106,6 +118,7 @@ static void brw_upload_vs_prog(struct brw_context *brw) struct brw_vs_prog_key key; struct brw_vertex_program *vp = (struct brw_vertex_program *)brw->vertex_program; + int i; memset(&key, 0, sizeof(key)); @@ -117,6 +130,14 @@ static void brw_upload_vs_prog(struct brw_context *brw) key.copy_edgeflag = (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL); + /* _NEW_POINT */ + if (ctx->Point.PointSprite) { + for (i = 0; i < 8; i++) { + if (ctx->Point.CoordReplace[i]) + key.point_coord_replace |= (1 << i); + } + } + /* Make an early check for the key. */ dri_bo_unreference(brw->vs.prog_bo); @@ -135,7 +156,7 @@ static void brw_upload_vs_prog(struct brw_context *brw) */ const struct brw_tracked_state brw_vs_prog = { .dirty = { - .mesa = _NEW_TRANSFORM | _NEW_POLYGON, + .mesa = _NEW_TRANSFORM | _NEW_POLYGON | _NEW_POINT, .brw = BRW_NEW_VERTEX_PROGRAM, .cache = 0 }, diff --git a/src/mesa/drivers/dri/i965/brw_vs.h b/src/mesa/drivers/dri/i965/brw_vs.h index 95e0501b1eb..6493744f3eb 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.h +++ b/src/mesa/drivers/dri/i965/brw_vs.h @@ -43,7 +43,7 @@ struct brw_vs_prog_key { GLuint program_string_id; GLuint nr_userclip:4; GLuint copy_edgeflag:1; - GLuint pad:26; + GLuint point_coord_replace:8; }; diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index dc6ab81c4ac..0b44deeb634 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -1882,7 +1882,7 @@ void brw_vs_emit(struct brw_vs_compile *c ) printf("vs-native:\n"); for (i = 0; i < p->nr_insn; i++) - brw_disasm(stderr, &p->store[i]); + brw_disasm(stderr, &p->store[i], intel->gen); printf("\n"); } } diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c index 375e7953912..323cfac8fa7 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_emit.c +++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c @@ -1717,7 +1717,7 @@ void brw_wm_emit( struct brw_wm_compile *c ) printf("wm-native:\n"); for (i = 0; i < p->nr_insn; i++) - brw_disasm(stderr, &p->store[i]); + brw_disasm(stderr, &p->store[i], p->brw->intel.gen); printf("\n"); } } diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index 88b885cb941..fe3c89b7212 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -2111,7 +2111,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) if (INTEL_DEBUG & DEBUG_WM) { printf("wm-native:\n"); for (i = 0; i < p->nr_insn; i++) - brw_disasm(stderr, &p->store[i]); + brw_disasm(stderr, &p->store[i], intel->gen); printf("\n"); } } diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c index 9768b0deee7..ca8e3448368 100644 --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c @@ -130,8 +130,7 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file, struct intel_context *intel = batch->intel; GLuint used = batch->ptr - batch->map; - if (!intel->using_dri2_swapbuffers && - intel->first_post_swapbuffers_batch == NULL) { + if (intel->first_post_swapbuffers_batch == NULL) { intel->first_post_swapbuffers_batch = intel->batch->buf; drm_intel_bo_reference(intel->first_post_swapbuffers_batch); } diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index 7d9f302dca6..a590c799ad3 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -353,6 +353,9 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask) OUT_BATCH(clear_val); ADVANCE_BATCH(); + if (intel->always_flush_cache) + intel_batchbuffer_emit_mi_flush(intel->batch); + if (buf == BUFFER_DEPTH || buf == BUFFER_STENCIL) mask &= ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); else diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c index 103aaf2b956..c38551bf952 100644 --- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c +++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c @@ -277,7 +277,7 @@ intel_bufferobj_map(GLcontext * ctx, /* Flush any existing batchbuffer that might reference this data. */ if (drm_intel_bo_references(intel->batch->buf, intel_obj->buffer)) - intelFlush(ctx); + intel_flush(ctx); if (intel_obj->region) intel_bufferobj_cow(intel, intel_obj); @@ -349,7 +349,7 @@ intel_bufferobj_map_range(GLcontext * ctx, */ if (!(access & GL_MAP_UNSYNCHRONIZED_BIT) && drm_intel_bo_references(intel->batch->buf, intel_obj->buffer)) - intelFlush(ctx); + intel_flush(ctx); if (intel_obj->buffer == NULL) { obj->Pointer = NULL; diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 8ee9a292a1b..05d49986546 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -177,6 +177,30 @@ intelGetString(GLcontext * ctx, GLenum name) } } +static void +intel_flush_front(GLcontext *ctx) +{ + struct intel_context *intel = intel_context(ctx); + __DRIcontext *driContext = intel->driContext; + __DRIscreen *const screen = intel->intelScreen->driScrnPriv; + + if ((ctx->DrawBuffer->Name == 0) && intel->front_buffer_dirty) { + if (screen->dri2.loader && + (screen->dri2.loader->base.version >= 2) + && (screen->dri2.loader->flushFrontBuffer != NULL) && + driContext->driDrawablePriv && + driContext->driDrawablePriv->loaderPrivate) { + (*screen->dri2.loader->flushFrontBuffer)(driContext->driDrawablePriv, + driContext->driDrawablePriv->loaderPrivate); + + /* We set the dirty bit in intel_prepare_render() if we're + * front buffer rendering once we get there. + */ + intel->front_buffer_dirty = GL_FALSE; + } + } +} + static unsigned intel_bits_per_pixel(const struct intel_renderbuffer *rb) { @@ -203,8 +227,10 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) * real front buffer contents will get copied to the new fake front * buffer. */ - if (intel->is_front_buffer_rendering) - intel_flush(&intel->ctx, GL_FALSE); + if (intel->is_front_buffer_rendering) { + intel_flush(&intel->ctx); + intel_flush_front(&intel->ctx); + } /* Set this up front, so that in case our buffers get invalidated * while we're getting new buffers, we don't clobber the stamp and @@ -362,7 +388,7 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) if (buffers[i].attachment == __DRI_BUFFER_DEPTH) depth_region = region; - intel_renderbuffer_set_region(rb, region); + intel_renderbuffer_set_region(intel, rb, region); intel_region_release(®ion); if (buffers[i].attachment == __DRI_BUFFER_DEPTH_STENCIL) { @@ -374,7 +400,7 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) continue; intel_region_reference(&stencil_region, region); - intel_renderbuffer_set_region(rb, stencil_region); + intel_renderbuffer_set_region(intel, rb, stencil_region); intel_region_release(&stencil_region); } } @@ -383,6 +409,10 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) driUpdateFramebufferSize(&intel->ctx, drawable); } +/** + * intel_prepare_render should be called anywhere that curent read/drawbuffer + * state is required. + */ void intel_prepare_render(struct intel_context *intel) { @@ -403,16 +433,47 @@ intel_prepare_render(struct intel_context *intel) intel_update_renderbuffers(driContext, drawable); driContext->dri2.read_stamp = drawable->dri2.stamp; } + + /* If we're currently rendering to the front buffer, the rendering + * that will happen next will probably dirty the front buffer. So + * mark it as dirty here. + */ + if (intel->is_front_buffer_rendering) + intel->front_buffer_dirty = GL_TRUE; + + /* Wait for the swapbuffers before the one we just emitted, so we + * don't get too many swaps outstanding for apps that are GPU-heavy + * but not CPU-heavy. + * + * We're using intelDRI2Flush (called from the loader before + * swapbuffer) and glFlush (for front buffer rendering) as the + * indicator that a frame is done and then throttle when we get + * here as we prepare to render the next frame. At this point for + * round trips for swap/copy and getting new buffers are done and + * we'll spend less time waiting on the GPU. + * + * Unfortunately, we don't have a handle to the batch containing + * the swap, and getting our hands on that doesn't seem worth it, + * so we just us the first batch we emitted after the last swap. + */ + if (intel->need_throttle && intel->first_post_swapbuffers_batch) { + drm_intel_bo_wait_rendering(intel->first_post_swapbuffers_batch); + drm_intel_bo_unreference(intel->first_post_swapbuffers_batch); + intel->first_post_swapbuffers_batch = NULL; + intel->need_throttle = GL_FALSE; + } } -void +static void intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) { struct intel_context *intel = intel_context(ctx); __DRIcontext *driContext = intel->driContext; - if (!intel->using_dri2_swapbuffers && - !intel->meta.internal_viewport_call && ctx->DrawBuffer->Name == 0) { + if (intel->saved_viewport) + intel->saved_viewport(ctx, x, y, w, h); + + if (!intel->meta.internal_viewport_call && ctx->DrawBuffer->Name == 0) { dri2InvalidateDrawable(driContext->driDrawablePriv); dri2InvalidateDrawable(driContext->driReadablePriv); } @@ -431,12 +492,12 @@ static const struct dri_debug_control debug_control[] = { { "buf", DEBUG_BUFMGR}, { "reg", DEBUG_REGION}, { "fbo", DEBUG_FBO}, - { "lock", DEBUG_LOCK}, + { "gs", DEBUG_GS}, { "sync", DEBUG_SYNC}, { "prim", DEBUG_PRIMS }, { "vert", DEBUG_VERTS }, { "dri", DEBUG_DRI }, - { "dma", DEBUG_DMA }, + { "sf", DEBUG_SF }, { "san", DEBUG_SANITY }, { "sleep", DEBUG_SLEEP }, { "stats", DEBUG_STATS }, @@ -447,6 +508,7 @@ static const struct dri_debug_control debug_control[] = { { "glsl_force", DEBUG_GLSL_FORCE }, { "urb", DEBUG_URB }, { "vs", DEBUG_VS }, + { "clip", DEBUG_CLIP }, { NULL, 0 } }; @@ -469,10 +531,9 @@ intelInvalidateState(GLcontext * ctx, GLuint new_state) } void -intel_flush(GLcontext *ctx, GLboolean needs_mi_flush) +intel_flush(GLcontext *ctx) { struct intel_context *intel = intel_context(ctx); - __DRIcontext *driContext = intel->driContext; if (intel->Fallback) _swrast_flush(ctx); @@ -482,35 +543,6 @@ intel_flush(GLcontext *ctx, GLboolean needs_mi_flush) if (intel->batch->map != intel->batch->ptr) intel_batchbuffer_flush(intel->batch); - - if ((ctx->DrawBuffer->Name == 0) && intel->front_buffer_dirty) { - __DRIscreen *const screen = intel->intelScreen->driScrnPriv; - - if (screen->dri2.loader && - (screen->dri2.loader->base.version >= 2) - && (screen->dri2.loader->flushFrontBuffer != NULL) && - driContext->driDrawablePriv && - driContext->driDrawablePriv->loaderPrivate) { - (*screen->dri2.loader->flushFrontBuffer)(driContext->driDrawablePriv, - driContext->driDrawablePriv->loaderPrivate); - - /* Only clear the dirty bit if front-buffer rendering is no longer - * enabled. This is done so that the dirty bit can only be set in - * glDrawBuffer. Otherwise the dirty bit would have to be set at - * each of N places that do rendering. This has worse performances, - * but it is much easier to get correct. - */ - if (!intel->is_front_buffer_rendering) { - intel->front_buffer_dirty = GL_FALSE; - } - } - } -} - -void -intelFlush(GLcontext * ctx) -{ - intel_flush(ctx, GL_FALSE); } static void @@ -518,26 +550,9 @@ intel_glFlush(GLcontext *ctx) { struct intel_context *intel = intel_context(ctx); - intel_flush(ctx, GL_TRUE); - - /* We're using glFlush as an indicator that a frame is done, which is - * what DRI2 does before calling SwapBuffers (and means we should catch - * people doing front-buffer rendering, as well).. - * - * Wait for the swapbuffers before the one we just emitted, so we don't - * get too many swaps outstanding for apps that are GPU-heavy but not - * CPU-heavy. - * - * Unfortunately, we don't have a handle to the batch containing the swap, - * and getting our hands on that doesn't seem worth it, so we just us the - * first batch we emitted after the last swap. - */ - if (!intel->using_dri2_swapbuffers && - intel->first_post_swapbuffers_batch != NULL) { - drm_intel_bo_wait_rendering(intel->first_post_swapbuffers_batch); - drm_intel_bo_unreference(intel->first_post_swapbuffers_batch); - intel->first_post_swapbuffers_batch = NULL; - } + intel_flush(ctx); + intel_flush_front(ctx); + intel->need_throttle = GL_TRUE; } void @@ -546,7 +561,8 @@ intelFinish(GLcontext * ctx) struct gl_framebuffer *fb = ctx->DrawBuffer; int i; - intelFlush(ctx); + intel_flush(ctx); + intel_flush_front(ctx); for (i = 0; i < fb->_NumColorDrawBuffers; i++) { struct intel_renderbuffer *irb; @@ -602,6 +618,12 @@ intelInitContext(struct intel_context *intel, if (intelScreen->bufmgr == NULL) return GL_FALSE; + /* Can't rely on invalidate events, fall back to glViewport hack */ + if (!driContextPriv->driScreenPriv->dri2.useInvalidate) { + intel->saved_viewport = functions->Viewport; + functions->Viewport = intel_viewport; + } + if (!_mesa_initialize_context_for_api(&intel->ctx, api, mesaVis, shareCtx, functions, (void *) intel)) { printf("%s: failed to init mesa context\n", __FUNCTION__); @@ -886,6 +908,12 @@ intelMakeCurrent(__DRIcontext * driContextPriv, driContextPriv->dri2.read_stamp = driReadPriv->dri2.stamp - 1; intel_prepare_render(intel); _mesa_make_current(&intel->ctx, fb, readFb); + + /* We do this in intel_prepare_render() too, but intel->ctx.DrawBuffer + * is NULL at that point. We can't call _mesa_makecurrent() + * first, since we need the buffer size for the initial + * viewport. So just call intel_draw_buffer() again here. */ + intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer); } else { _mesa_make_current(NULL, NULL, NULL); diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 02bb4d0d640..04d5fc92a25 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -150,8 +150,8 @@ struct intel_context struct intel_batchbuffer *batch; drm_intel_bo *first_post_swapbuffers_batch; + GLboolean need_throttle; GLboolean no_batch_wrap; - GLboolean using_dri2_swapbuffers; struct { @@ -243,6 +243,8 @@ struct intel_context __DRIcontext *driContext; struct intel_screen *intelScreen; + void (*saved_viewport)(GLcontext * ctx, + GLint x, GLint y, GLsizei width, GLsizei height); /** * Configuration cache @@ -324,12 +326,12 @@ extern int INTEL_DEBUG; #define DEBUG_BUFMGR 0x200 #define DEBUG_REGION 0x400 #define DEBUG_FBO 0x800 -#define DEBUG_LOCK 0x1000 +#define DEBUG_GS 0x1000 #define DEBUG_SYNC 0x2000 #define DEBUG_PRIMS 0x4000 #define DEBUG_VERTS 0x8000 #define DEBUG_DRI 0x10000 -#define DEBUG_DMA 0x20000 +#define DEBUG_SF 0x20000 #define DEBUG_SANITY 0x40000 #define DEBUG_SLEEP 0x80000 #define DEBUG_STATS 0x100000 @@ -339,6 +341,7 @@ extern int INTEL_DEBUG; #define DEBUG_URB 0x1000000 #define DEBUG_VS 0x2000000 #define DEBUG_GLSL_FORCE 0x4000000 +#define DEBUG_CLIP 0x8000000 #define DBG(...) do { \ if (INTEL_DEBUG & FILE_DEBUG_FLAG) \ @@ -371,8 +374,7 @@ extern GLboolean intelInitContext(struct intel_context *intel, struct dd_function_table *functions); extern void intelFinish(GLcontext * ctx); -extern void intelFlush(GLcontext * ctx); -extern void intel_flush(GLcontext * ctx, GLboolean needs_mi_flush); +extern void intel_flush(GLcontext * ctx); extern void intelInitDriverFunctions(struct dd_function_table *functions); @@ -447,9 +449,6 @@ extern int intel_translate_stencil_op(GLenum op); extern int intel_translate_blend_factor(GLenum factor); extern int intel_translate_logic_op(GLenum opcode); -void intel_viewport(GLcontext * ctx, GLint x, GLint y, - GLsizei width, GLsizei height); - void intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable); void intel_prepare_render(struct intel_context *intel); diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index 8278d12bb90..217be7ef6cb 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -42,7 +42,9 @@ #include "intel_fbo.h" #include "intel_mipmap_tree.h" #include "intel_regions.h" - +#ifndef I915 +#include "brw_state.h" +#endif #define FILE_DEBUG_FLAG DEBUG_FBO @@ -166,7 +168,7 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat); cpp = _mesa_get_format_bytes(rb->Format); - intelFlush(ctx); + intel_flush(ctx); /* free old region */ if (irb->region) { @@ -280,7 +282,8 @@ intel_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, void -intel_renderbuffer_set_region(struct intel_renderbuffer *rb, +intel_renderbuffer_set_region(struct intel_context *intel, + struct intel_renderbuffer *rb, struct intel_region *region) { struct intel_region *old; @@ -288,6 +291,12 @@ intel_renderbuffer_set_region(struct intel_renderbuffer *rb, old = rb->region; rb->region = NULL; intel_region_reference(&rb->region, region); +#ifndef I915 + if (old) { + brw_state_cache_bo_delete(&brw_context(&intel->ctx)->surface_cache, + old->buffer); + } +#endif intel_region_release(&old); } @@ -411,7 +420,7 @@ intel_framebuffer_renderbuffer(GLcontext * ctx, { DBG("Intel FramebufferRenderbuffer %u %u\n", fb->Name, rb ? rb->Name : 0); - intelFlush(ctx); + intel_flush(ctx); _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb); intel_draw_buffer(ctx, fb); diff --git a/src/mesa/drivers/dri/intel/intel_fbo.h b/src/mesa/drivers/dri/intel/intel_fbo.h index 72413f73694..028f657d12d 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.h +++ b/src/mesa/drivers/dri/intel/intel_fbo.h @@ -82,7 +82,8 @@ intel_get_renderbuffer(struct gl_framebuffer *fb, int attIndex) extern void -intel_renderbuffer_set_region(struct intel_renderbuffer *irb, +intel_renderbuffer_set_region(struct intel_context *intel, + struct intel_renderbuffer *irb, struct intel_region *region); diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index ef1966ea7e1..71ef7a8e39b 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -116,17 +116,16 @@ intel_miptree_create(struct intel_context *intel, GLboolean expect_accelerated_upload) { struct intel_mipmap_tree *mt; - uint32_t tiling; + uint32_t tiling = I915_TILING_NONE; if (intel->use_texture_tiling && compress_byte == 0) { if (intel->gen >= 4 && (base_format == GL_DEPTH_COMPONENT || base_format == GL_DEPTH_STENCIL_EXT)) tiling = I915_TILING_Y; - else + else if (width0 >= 64) tiling = I915_TILING_X; - } else - tiling = I915_TILING_NONE; + } mt = intel_miptree_create_internal(intel, target, internal_format, first_level, last_level, width0, diff --git a/src/mesa/drivers/dri/intel/intel_pixel_copy.c b/src/mesa/drivers/dri/intel/intel_pixel_copy.c index 56faf076c7e..2008a4c2bec 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_copy.c @@ -142,7 +142,7 @@ do_blit_copypixels(GLcontext * ctx, if (!src || !dst) return GL_FALSE; - intelFlush(&intel->ctx); + intel_flush(&intel->ctx); /* Clip to destination buffer. */ orig_dstx = dstx; diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c index bd1dd13fb7d..a40b232fff8 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c @@ -167,7 +167,7 @@ intel_stencil_drawpixels(GLcontext * ctx, irb = intel_create_renderbuffer(MESA_FORMAT_ARGB8888); irb->Base.Width = depth_irb->Base.Width; irb->Base.Height = depth_irb->Base.Height; - intel_renderbuffer_set_region(irb, depth_irb->region); + intel_renderbuffer_set_region(intel, irb, depth_irb->region); /* Create a name for our renderbuffer, which lets us use other mesa * rb functions for convenience. diff --git a/src/mesa/drivers/dri/intel/intel_pixel_read.c b/src/mesa/drivers/dri/intel/intel_pixel_read.c index 2ac3da7f42f..21d2a7a93e2 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_read.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_read.c @@ -170,11 +170,19 @@ intelReadPixels(GLcontext * ctx, GLenum format, GLenum type, const struct gl_pixelstore_attrib *pack, GLvoid * pixels) { + struct intel_context *intel = intel_context(ctx); + GLboolean dirty; + if (INTEL_DEBUG & DEBUG_PIXEL) fprintf(stderr, "%s\n", __FUNCTION__); - intelFlush(ctx); - intel_prepare_render(intel_context(ctx)); + intel_flush(ctx); + + /* glReadPixels() wont dirty the front buffer, so reset the dirty + * flag after calling intel_prepare_render(). */ + dirty = intel->front_buffer_dirty; + intel_prepare_render(intel); + intel->front_buffer_dirty = dirty; if (do_blit_readpixels (ctx, x, y, width, height, format, type, pack, pixels)) @@ -193,4 +201,7 @@ intelReadPixels(GLcontext * ctx, _mesa_update_state(ctx); _swrast_ReadPixels(ctx, x, y, width, height, format, type, pack, pixels); + + /* There's an intel_prepare_render() call in intelSpanRenderStart(). */ + intel->front_buffer_dirty = dirty; } diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index 1172de90b13..8cdeaf608c8 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -111,7 +111,7 @@ debug_backtrace(void) GLubyte * intel_region_map(struct intel_context *intel, struct intel_region *region) { - intelFlush(&intel->ctx); + intel_flush(&intel->ctx); _DBG("%s %p\n", __FUNCTION__, region); if (!region->map_refcount++) { diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 3aed253e240..15a465c6402 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -110,23 +110,16 @@ intelDRI2Flush(__DRIdrawable *drawable) if (intel->gen < 4) INTEL_FIREVERTICES(intel); + intel->need_throttle = GL_TRUE; + if (intel->batch->map != intel->batch->ptr) intel_batchbuffer_flush(intel->batch); } -static void -intelDRI2Invalidate(__DRIdrawable *drawable) -{ - struct intel_context *intel = drawable->driContextPriv->driverPrivate; - - intel->using_dri2_swapbuffers = GL_TRUE; - dri2InvalidateDrawable(drawable); -} - static const struct __DRI2flushExtensionRec intelFlushExtension = { { __DRI2_FLUSH, __DRI2_FLUSH_VERSION }, intelDRI2Flush, - intelDRI2Invalidate, + dri2InvalidateDrawable, }; static __DRIimage * diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c index c1e15d1b0f2..059f76f289a 100644 --- a/src/mesa/drivers/dri/intel/intel_span.c +++ b/src/mesa/drivers/dri/intel/intel_span.c @@ -244,7 +244,7 @@ intelSpanRenderStart(GLcontext * ctx) struct intel_context *intel = intel_context(ctx); GLuint i; - intelFlush(&intel->ctx); + intel_flush(&intel->ctx); intel_prepare_render(intel); for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { diff --git a/src/mesa/drivers/dri/intel/intel_syncobj.c b/src/mesa/drivers/dri/intel/intel_syncobj.c index d67f0cb4a68..c2d86432ff9 100644 --- a/src/mesa/drivers/dri/intel/intel_syncobj.c +++ b/src/mesa/drivers/dri/intel/intel_syncobj.c @@ -77,7 +77,7 @@ intel_fence_sync(GLcontext *ctx, struct gl_sync_object *s, sync->bo = intel->batch->buf; drm_intel_bo_reference(sync->bo); - intelFlush(ctx); + intel_flush(ctx); } /* We ignore the user-supplied timeout. This is weaselly -- we're allowed to diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c index 62e1e78f59b..549a4acc7d9 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_copy.c +++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c @@ -108,7 +108,7 @@ do_copy_texsubimage(struct intel_context *intel, return GL_FALSE; } - /* intelFlush(ctx); */ + /* intel_flush(ctx); */ intel_prepare_render(intel); { drm_intel_bo *dst_bo = intel_region_buffer(intel, diff --git a/src/mesa/drivers/dri/intel/intel_tex_format.c b/src/mesa/drivers/dri/intel/intel_tex_format.c index 7be5231eaef..610a169beb2 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_format.c +++ b/src/mesa/drivers/dri/intel/intel_tex_format.c @@ -1,7 +1,7 @@ #include "intel_context.h" #include "intel_tex.h" #include "main/enums.h" - +#include "main/formats.h" /** * Choose hardware texture format given the user's glTexImage parameters. @@ -208,22 +208,11 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat, int intel_compressed_num_bytes(GLuint mesaFormat) { - int bytes = 0; - switch(mesaFormat) { - - case MESA_FORMAT_RGB_FXT1: - case MESA_FORMAT_RGBA_FXT1: - case MESA_FORMAT_RGB_DXT1: - case MESA_FORMAT_RGBA_DXT1: - bytes = 2; - break; - - case MESA_FORMAT_RGBA_DXT3: - case MESA_FORMAT_RGBA_DXT5: - bytes = 4; - default: - break; - } - - return bytes; + GLuint bw, bh; + GLuint block_size; + + block_size = _mesa_get_format_bytes(mesaFormat); + _mesa_get_format_block_size(mesaFormat, &bw, &bh); + + return block_size / bh; } diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index 9db96acdc08..06bf2627049 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -239,8 +239,8 @@ try_pbo_upload(struct intel_context *intel, dst_stride = intelImage->mt->region->pitch; if (drm_intel_bo_references(intel->batch->buf, dst_buffer)) - intelFlush(&intel->ctx); - intel_prepare_render(intel); + intel_flush(&intel->ctx); + { dri_bo *src_buffer = intel_bufferobj_buffer(intel, pbo, INTEL_READ); @@ -473,14 +473,12 @@ intelTexImage(GLcontext * ctx, pixels, unpack, "glTexImage"); } - intel_prepare_render(intel); - if (intelImage->mt) { if (pixels != NULL) { /* Flush any queued rendering with the texture before mapping. */ if (drm_intel_bo_references(intel->batch->buf, intelImage->mt->region->buffer)) { - intelFlush(ctx); + intel_flush(ctx); } texImage->Data = intel_miptree_image_map(intel, intelImage->mt, @@ -638,7 +636,7 @@ intel_get_tex_image(GLcontext * ctx, GLenum target, GLint level, * make sure rendering is complete. * We could probably predicate this on texObj->_RenderToTexture */ - intelFlush(ctx); + intel_flush(ctx); /* Map */ if (intelImage->mt) { @@ -728,7 +726,8 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, if (!intelObj) return; - if (dPriv->lastStamp != dPriv->dri2.stamp) + if (dPriv->lastStamp != dPriv->dri2.stamp || + !pDRICtx->driScreenPriv->dri2.useInvalidate) intel_update_renderbuffers(pDRICtx, dPriv); rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT); diff --git a/src/mesa/drivers/dri/intel/intel_tex_subimage.c b/src/mesa/drivers/dri/intel/intel_tex_subimage.c index c35d2e87573..4f5c26acf27 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_subimage.c +++ b/src/mesa/drivers/dri/intel/intel_tex_subimage.c @@ -59,7 +59,7 @@ intelTexSubimage(GLcontext * ctx, _mesa_lookup_enum_by_nr(target), level, xoffset, yoffset, width, height); - intelFlush(ctx); + intel_flush(ctx); if (compressed) pixels = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, diff --git a/src/mesa/drivers/dri/r300/compiler/Makefile b/src/mesa/drivers/dri/r300/compiler/Makefile index e432afc3d41..34d22b45591 100644 --- a/src/mesa/drivers/dri/r300/compiler/Makefile +++ b/src/mesa/drivers/dri/r300/compiler/Makefile @@ -21,6 +21,7 @@ C_SOURCES = \ radeon_dataflow.c \ radeon_dataflow_deadcode.c \ radeon_dataflow_swizzles.c \ + radeon_optimize.c \ r3xx_fragprog.c \ r300_fragprog.c \ r300_fragprog_swizzle.c \ diff --git a/src/mesa/drivers/dri/r300/compiler/r300_fragprog_swizzle.c b/src/mesa/drivers/dri/r300/compiler/r300_fragprog_swizzle.c index cfa48a59e3a..5d5de2f1b2a 100644 --- a/src/mesa/drivers/dri/r300/compiler/r300_fragprog_swizzle.c +++ b/src/mesa/drivers/dri/r300/compiler/r300_fragprog_swizzle.c @@ -56,7 +56,8 @@ static const struct swizzle_data native_swizzles[] = { {MAKE_SWZ3(Z, X, Y), R300_ALU_ARGC_SRC0C_ZXY, 1}, {MAKE_SWZ3(W, Z, Y), R300_ALU_ARGC_SRC0CA_WZY, 1}, {MAKE_SWZ3(ONE, ONE, ONE), R300_ALU_ARGC_ONE, 0}, - {MAKE_SWZ3(ZERO, ZERO, ZERO), R300_ALU_ARGC_ZERO, 0} + {MAKE_SWZ3(ZERO, ZERO, ZERO), R300_ALU_ARGC_ZERO, 0}, + {MAKE_SWZ3(HALF, HALF, HALF), R300_ALU_ARGC_HALF, 0} }; static const int num_native_swizzles = sizeof(native_swizzles)/sizeof(native_swizzles[0]); @@ -221,6 +222,7 @@ unsigned int r300FPTranslateAlphaSwizzle(unsigned int src, unsigned int swizzle) case RC_SWIZZLE_W: return R300_ALU_ARGA_SRC0A + src; case RC_SWIZZLE_ONE: return R300_ALU_ARGA_ONE; case RC_SWIZZLE_ZERO: return R300_ALU_ARGA_ZERO; + case RC_SWIZZLE_HALF: return R300_ALU_ARGA_HALF; default: return R300_ALU_ARGA_ONE; } } diff --git a/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c b/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c index 25bf373b6fd..3e88ccbc46d 100644 --- a/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c +++ b/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c @@ -152,6 +152,10 @@ void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c) debug_program_log(c, "after deadcode"); + rc_optimize(&c->Base); + + debug_program_log(c, "after dataflow optimize"); + rc_dataflow_swizzles(&c->Base); if (c->Base.Error) return; diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_code.c b/src/mesa/drivers/dri/r300/compiler/radeon_code.c index 853b2becd1b..0eab18c344d 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_code.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_code.c @@ -146,7 +146,7 @@ unsigned rc_constants_add_immediate_scalar(struct rc_constant_list * c, float da unsigned comp; for(comp = 0; comp < c->Constants[index].Size; ++comp) { if (c->Constants[index].u.Immediate[comp] == data) { - *swizzle = RC_MAKE_SWIZZLE(comp, comp, comp, comp); + *swizzle = RC_MAKE_SWIZZLE_SMEAR(comp); return index; } } @@ -159,7 +159,7 @@ unsigned rc_constants_add_immediate_scalar(struct rc_constant_list * c, float da if (free_index >= 0) { unsigned comp = c->Constants[free_index].Size++; c->Constants[free_index].u.Immediate[comp] = data; - *swizzle = RC_MAKE_SWIZZLE(comp, comp, comp, comp); + *swizzle = RC_MAKE_SWIZZLE_SMEAR(comp); return free_index; } diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_code.h b/src/mesa/drivers/dri/r300/compiler/radeon_code.h index 27274f07122..1979e7e4e49 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_code.h +++ b/src/mesa/drivers/dri/r300/compiler/radeon_code.h @@ -132,7 +132,7 @@ struct r300_fragment_program_external_state { * 2 - GL_ALPHA * depending on the depth texture mode. */ - unsigned depth_texture_mode : 2; + unsigned depth_texture_swizzle:12; /** * If the sampler is used as a shadow sampler, @@ -144,6 +144,12 @@ struct r300_fragment_program_external_state { unsigned texture_compare_func : 3; /** + * No matter what the sampler type is, + * this field turns it into a shadow sampler. + */ + unsigned compare_mode_enabled : 1; + + /** * If the sampler needs to fake NPOT, this field is set. */ unsigned fake_npot : 1; diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.c b/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.c index 16e2f3a2181..0e6c62541fa 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.c @@ -30,7 +30,7 @@ #include "radeon_program.h" -static void reads_normal(struct rc_instruction * fullinst, rc_read_write_fn cb, void * userdata) +static void reads_normal(struct rc_instruction * fullinst, rc_read_write_chan_fn cb, void * userdata) { struct rc_sub_instruction * inst = &fullinst->U.I; const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->Opcode); @@ -46,18 +46,15 @@ static void reads_normal(struct rc_instruction * fullinst, rc_read_write_fn cb, refmask &= RC_MASK_XYZW; - for(unsigned int chan = 0; chan < 4; ++chan) { - if (GET_BIT(refmask, chan)) { - cb(userdata, fullinst, inst->SrcReg[src].File, inst->SrcReg[src].Index, chan); - } - } + if (refmask) + cb(userdata, fullinst, inst->SrcReg[src].File, inst->SrcReg[src].Index, refmask); if (refmask && inst->SrcReg[src].RelAddr) cb(userdata, fullinst, RC_FILE_ADDRESS, 0, RC_MASK_X); } } -static void reads_pair(struct rc_instruction * fullinst, rc_read_write_fn cb, void * userdata) +static void reads_pair(struct rc_instruction * fullinst, rc_read_write_mask_fn cb, void * userdata) { struct rc_pair_instruction * inst = &fullinst->U.P; unsigned int refmasks[3] = { 0, 0, 0 }; @@ -84,27 +81,23 @@ static void reads_pair(struct rc_instruction * fullinst, rc_read_write_fn cb, v } for(unsigned int src = 0; src < 3; ++src) { - if (inst->RGB.Src[src].Used) { - for(unsigned int chan = 0; chan < 3; ++chan) { - if (GET_BIT(refmasks[src], chan)) - cb(userdata, fullinst, inst->RGB.Src[src].File, inst->RGB.Src[src].Index, chan); - } - } + if (inst->RGB.Src[src].Used && (refmasks[src] & RC_MASK_XYZ)) + cb(userdata, fullinst, inst->RGB.Src[src].File, inst->RGB.Src[src].Index, + refmasks[src] & RC_MASK_XYZ); - if (inst->Alpha.Src[src].Used) { - if (GET_BIT(refmasks[src], 3)) - cb(userdata, fullinst, inst->Alpha.Src[src].File, inst->Alpha.Src[src].Index, 3); - } + if (inst->Alpha.Src[src].Used && (refmasks[src] & RC_MASK_W)) + cb(userdata, fullinst, inst->Alpha.Src[src].File, inst->Alpha.Src[src].Index, RC_MASK_W); } } /** - * Calls a callback function for all sourced register channels. + * Calls a callback function for all register reads. * - * This is conservative, i.e. channels may be called multiple times, - * and the writemask of the instruction is not taken into account. + * This is conservative, i.e. if the same register is referenced multiple times, + * the callback may also be called multiple times. + * Also, the writemask of the instruction is not taken into account. */ -void rc_for_all_reads(struct rc_instruction * inst, rc_read_write_fn cb, void * userdata) +void rc_for_all_reads_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata) { if (inst->Type == RC_INSTRUCTION_NORMAL) { reads_normal(inst, cb, userdata); @@ -115,44 +108,39 @@ void rc_for_all_reads(struct rc_instruction * inst, rc_read_write_fn cb, void * -static void writes_normal(struct rc_instruction * fullinst, rc_read_write_fn cb, void * userdata) +static void writes_normal(struct rc_instruction * fullinst, rc_read_write_mask_fn cb, void * userdata) { struct rc_sub_instruction * inst = &fullinst->U.I; const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->Opcode); - if (opcode->HasDstReg) { - for(unsigned int chan = 0; chan < 4; ++chan) { - if (GET_BIT(inst->DstReg.WriteMask, chan)) - cb(userdata, fullinst, inst->DstReg.File, inst->DstReg.Index, chan); - } - } + if (opcode->HasDstReg && inst->DstReg.WriteMask) + cb(userdata, fullinst, inst->DstReg.File, inst->DstReg.Index, inst->DstReg.WriteMask); if (inst->WriteALUResult) - cb(userdata, fullinst, RC_FILE_SPECIAL, RC_SPECIAL_ALU_RESULT, 0); + cb(userdata, fullinst, RC_FILE_SPECIAL, RC_SPECIAL_ALU_RESULT, RC_MASK_X); } -static void writes_pair(struct rc_instruction * fullinst, rc_read_write_fn cb, void * userdata) +static void writes_pair(struct rc_instruction * fullinst, rc_read_write_mask_fn cb, void * userdata) { struct rc_pair_instruction * inst = &fullinst->U.P; - for(unsigned int chan = 0; chan < 3; ++chan) { - if (GET_BIT(inst->RGB.WriteMask, chan)) - cb(userdata, fullinst, RC_FILE_TEMPORARY, inst->RGB.DestIndex, chan); - } + if (inst->RGB.WriteMask) + cb(userdata, fullinst, RC_FILE_TEMPORARY, inst->RGB.DestIndex, inst->RGB.WriteMask); if (inst->Alpha.WriteMask) - cb(userdata, fullinst, RC_FILE_TEMPORARY, inst->Alpha.DestIndex, 3); + cb(userdata, fullinst, RC_FILE_TEMPORARY, inst->Alpha.DestIndex, RC_MASK_W); if (inst->WriteALUResult) - cb(userdata, fullinst, RC_FILE_SPECIAL, RC_SPECIAL_ALU_RESULT, 0); + cb(userdata, fullinst, RC_FILE_SPECIAL, RC_SPECIAL_ALU_RESULT, RC_MASK_X); } /** - * Calls a callback function for all written register channels. + * Calls a callback function for all register writes in the instruction, + * reporting writemasks to the callback function. * * \warning Does not report output registers for paired instructions! */ -void rc_for_all_writes(struct rc_instruction * inst, rc_read_write_fn cb, void * userdata) +void rc_for_all_writes_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata) { if (inst->Type == RC_INSTRUCTION_NORMAL) { writes_normal(inst, cb, userdata); @@ -162,6 +150,48 @@ void rc_for_all_writes(struct rc_instruction * inst, rc_read_write_fn cb, void * } +struct mask_to_chan_data { + void * UserData; + rc_read_write_chan_fn Fn; +}; + +static void mask_to_chan_cb(void * data, struct rc_instruction * inst, + rc_register_file file, unsigned int index, unsigned int mask) +{ + struct mask_to_chan_data * d = data; + for(unsigned int chan = 0; chan < 4; ++chan) { + if (GET_BIT(mask, chan)) + d->Fn(d->UserData, inst, file, index, chan); + } +} + +/** + * Calls a callback function for all sourced register channels. + * + * This is conservative, i.e. channels may be called multiple times, + * and the writemask of the instruction is not taken into account. + */ +void rc_for_all_reads_chan(struct rc_instruction * inst, rc_read_write_chan_fn cb, void * userdata) +{ + struct mask_to_chan_data d; + d.UserData = userdata; + d.Fn = cb; + rc_for_all_reads_mask(inst, &mask_to_chan_cb, &d); +} + +/** + * Calls a callback function for all written register channels. + * + * \warning Does not report output registers for paired instructions! + */ +void rc_for_all_writes_chan(struct rc_instruction * inst, rc_read_write_chan_fn cb, void * userdata) +{ + struct mask_to_chan_data d; + d.UserData = userdata; + d.Fn = cb; + rc_for_all_writes_mask(inst, &mask_to_chan_cb, &d); +} + static void remap_normal_instruction(struct rc_instruction * fullinst, rc_remap_register_fn cb, void * userdata) { diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.h b/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.h index 62cda20eea6..60a6e192a9f 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.h +++ b/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.h @@ -39,10 +39,15 @@ struct rc_swizzle_caps; * Help analyze and modify the register accesses of instructions. */ /*@{*/ -typedef void (*rc_read_write_fn)(void * userdata, struct rc_instruction * inst, +typedef void (*rc_read_write_chan_fn)(void * userdata, struct rc_instruction * inst, rc_register_file file, unsigned int index, unsigned int chan); -void rc_for_all_reads(struct rc_instruction * inst, rc_read_write_fn cb, void * userdata); -void rc_for_all_writes(struct rc_instruction * inst, rc_read_write_fn cb, void * userdata); +void rc_for_all_reads_chan(struct rc_instruction * inst, rc_read_write_chan_fn cb, void * userdata); +void rc_for_all_writes_chan(struct rc_instruction * inst, rc_read_write_chan_fn cb, void * userdata); + +typedef void (*rc_read_write_mask_fn)(void * userdata, struct rc_instruction * inst, + rc_register_file file, unsigned int index, unsigned int mask); +void rc_for_all_reads_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata); +void rc_for_all_writes_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata); typedef void (*rc_remap_register_fn)(void * userdata, struct rc_instruction * inst, rc_register_file * pfile, unsigned int * pindex); @@ -60,4 +65,6 @@ void rc_dataflow_deadcode(struct radeon_compiler * c, rc_dataflow_mark_outputs_f void rc_dataflow_swizzles(struct radeon_compiler * c); /*@}*/ +void rc_optimize(struct radeon_compiler * c); + #endif /* RADEON_DATAFLOW_H */ diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_emulate_branches.c b/src/mesa/drivers/dri/r300/compiler/radeon_emulate_branches.c index d889612f4f4..863654cf685 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_emulate_branches.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_emulate_branches.c @@ -150,7 +150,7 @@ static void allocate_and_insert_proxies(struct emulate_branch_state * s, sap.Proxies = proxies; for(struct rc_instruction * inst = begin; inst != end; inst = inst->Next) { - rc_for_all_writes(inst, scan_write, &sap); + rc_for_all_writes_mask(inst, scan_write, &sap); rc_remap_registers(inst, remap_proxy_function, &sap); } diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c new file mode 100644 index 00000000000..21d72108886 --- /dev/null +++ b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c @@ -0,0 +1,446 @@ +/* + * Copyright (C) 2009 Nicolai Haehnle. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#include "radeon_dataflow.h" + +#include "radeon_compiler.h" +#include "radeon_swizzle.h" + + +static struct rc_src_register chain_srcregs(struct rc_src_register outer, struct rc_src_register inner) +{ + struct rc_src_register combine; + combine.File = inner.File; + combine.Index = inner.Index; + combine.RelAddr = inner.RelAddr; + if (outer.Abs) { + combine.Abs = 1; + combine.Negate = outer.Negate; + } else { + combine.Abs = inner.Abs; + combine.Negate = 0; + for(unsigned int chan = 0; chan < 4; ++chan) { + unsigned int swz = GET_SWZ(outer.Swizzle, chan); + if (swz < 4) + combine.Negate |= GET_BIT(inner.Negate, swz) << chan; + } + combine.Negate ^= outer.Negate; + } + combine.Swizzle = combine_swizzles(inner.Swizzle, outer.Swizzle); + return combine; +} + +struct peephole_state { + struct radeon_compiler * C; + struct rc_instruction * Mov; + unsigned int Conflict:1; + + /** Whether Mov's source has been clobbered */ + unsigned int SourceClobbered:1; + + /** Which components of Mov's destination register are still from that Mov? */ + unsigned int MovMask:4; + + /** Which components of Mov's destination register are clearly *not* from that Mov */ + unsigned int DefinedMask:4; + + /** Which components of Mov's source register are sourced */ + unsigned int SourcedMask:4; + + /** Branch depth beyond Mov; negative value indicates we left the Mov's block */ + int BranchDepth; +}; + +static void peephole_scan_read(void * data, struct rc_instruction * inst, + rc_register_file file, unsigned int index, unsigned int mask) +{ + struct peephole_state * s = data; + + if (file != RC_FILE_TEMPORARY || index != s->Mov->U.I.DstReg.Index) + return; + + /* These instructions cannot read from the constants file. + * see radeonTransformTEX() + */ + if(s->Mov->U.I.SrcReg[0].File != RC_FILE_TEMPORARY && + s->Mov->U.I.SrcReg[0].File != RC_FILE_INPUT && + (inst->U.I.Opcode == RC_OPCODE_TEX || + inst->U.I.Opcode == RC_OPCODE_TXB || + inst->U.I.Opcode == RC_OPCODE_TXP || + inst->U.I.Opcode == RC_OPCODE_KIL)){ + s->Conflict = 1; + return; + } + if ((mask & s->MovMask) == mask) { + if (s->SourceClobbered) { + s->Conflict = 1; + } + } else if ((mask & s->DefinedMask) == mask) { + /* read from something entirely written by other instruction: this is okay */ + } else { + /* read from component combination that is not well-defined without + * the MOV: cannot remove it */ + s->Conflict = 1; + } +} + +static void peephole_scan_write(void * data, struct rc_instruction * inst, + rc_register_file file, unsigned int index, unsigned int mask) +{ + struct peephole_state * s = data; + + if (s->BranchDepth < 0) + return; + + if (file == s->Mov->U.I.DstReg.File && index == s->Mov->U.I.DstReg.Index) { + s->MovMask &= ~mask; + if (s->BranchDepth == 0) + s->DefinedMask |= mask; + else + s->DefinedMask &= ~mask; + } + if (file == s->Mov->U.I.SrcReg[0].File && index == s->Mov->U.I.SrcReg[0].Index) { + if (mask & s->SourcedMask) + s->SourceClobbered = 1; + } else if (s->Mov->U.I.SrcReg[0].RelAddr && file == RC_FILE_ADDRESS) { + s->SourceClobbered = 1; + } +} + +static void peephole(struct radeon_compiler * c, struct rc_instruction * inst_mov) +{ + struct peephole_state s; + + if (inst_mov->U.I.DstReg.File != RC_FILE_TEMPORARY || inst_mov->U.I.WriteALUResult) + return; + + memset(&s, 0, sizeof(s)); + s.C = c; + s.Mov = inst_mov; + s.MovMask = inst_mov->U.I.DstReg.WriteMask; + s.DefinedMask = RC_MASK_XYZW & ~s.MovMask; + + for(unsigned int chan = 0; chan < 4; ++chan) { + unsigned int swz = GET_SWZ(inst_mov->U.I.SrcReg[0].Swizzle, chan); + s.SourcedMask |= (1 << swz) & RC_MASK_XYZW; + } + + /* 1st pass: Check whether all subsequent readers can be changed */ + for(struct rc_instruction * inst = inst_mov->Next; + inst != &c->Program.Instructions; + inst = inst->Next) { + rc_for_all_reads_mask(inst, peephole_scan_read, &s); + rc_for_all_writes_mask(inst, peephole_scan_write, &s); + if (s.Conflict) + return; + + if (s.BranchDepth >= 0) { + if (inst->U.I.Opcode == RC_OPCODE_IF) { + s.BranchDepth++; + } else if (inst->U.I.Opcode == RC_OPCODE_ENDIF) { + s.BranchDepth--; + if (s.BranchDepth < 0) { + s.DefinedMask &= ~s.MovMask; + s.MovMask = 0; + } + } + } + } + + if (s.Conflict) + return; + + /* 2nd pass: We can satisfy all readers, so switch them over all at once */ + s.MovMask = inst_mov->U.I.DstReg.WriteMask; + s.BranchDepth = 0; + + for(struct rc_instruction * inst = inst_mov->Next; + inst != &c->Program.Instructions; + inst = inst->Next) { + const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode); + + for(unsigned int src = 0; src < opcode->NumSrcRegs; ++src) { + if (inst->U.I.SrcReg[src].File == RC_FILE_TEMPORARY && + inst->U.I.SrcReg[src].Index == s.Mov->U.I.DstReg.Index) { + unsigned int refmask = 0; + + for(unsigned int chan = 0; chan < 4; ++chan) { + unsigned int swz = GET_SWZ(inst->U.I.SrcReg[src].Swizzle, chan); + refmask |= (1 << swz) & RC_MASK_XYZW; + } + + if ((refmask & s.MovMask) == refmask) + inst->U.I.SrcReg[src] = chain_srcregs(inst->U.I.SrcReg[src], s.Mov->U.I.SrcReg[0]); + } + } + + if (opcode->HasDstReg) { + if (inst->U.I.DstReg.File == RC_FILE_TEMPORARY && + inst->U.I.DstReg.Index == s.Mov->U.I.DstReg.Index) { + s.MovMask &= ~inst->U.I.DstReg.WriteMask; + } + } + + if (s.BranchDepth >= 0) { + if (inst->U.I.Opcode == RC_OPCODE_IF) { + s.BranchDepth++; + } else if (inst->U.I.Opcode == RC_OPCODE_ENDIF) { + s.BranchDepth--; + if (s.BranchDepth < 0) + break; /* no more readers after this point */ + } + } + } + + /* Finally, remove the original MOV instruction */ + rc_remove_instruction(inst_mov); +} + +/** + * Check if a source register is actually always the same + * swizzle constant. + */ +static int is_src_uniform_constant(struct rc_src_register src, + rc_swizzle * pswz, unsigned int * pnegate) +{ + int have_used = 0; + + if (src.File != RC_FILE_NONE) { + *pswz = 0; + return 0; + } + + for(unsigned int chan = 0; chan < 4; ++chan) { + unsigned int swz = GET_SWZ(src.Swizzle, chan); + if (swz < 4) { + *pswz = 0; + return 0; + } + if (swz == RC_SWIZZLE_UNUSED) + continue; + + if (!have_used) { + *pswz = swz; + *pnegate = GET_BIT(src.Negate, chan); + have_used = 1; + } else { + if (swz != *pswz || *pnegate != GET_BIT(src.Negate, chan)) { + *pswz = 0; + return 0; + } + } + } + + return 1; +} + + +static void constant_folding_mad(struct rc_instruction * inst) +{ + rc_swizzle swz; + unsigned int negate; + + if (is_src_uniform_constant(inst->U.I.SrcReg[2], &swz, &negate)) { + if (swz == RC_SWIZZLE_ZERO) { + inst->U.I.Opcode = RC_OPCODE_MUL; + return; + } + } + + if (is_src_uniform_constant(inst->U.I.SrcReg[1], &swz, &negate)) { + if (swz == RC_SWIZZLE_ONE) { + inst->U.I.Opcode = RC_OPCODE_ADD; + if (negate) + inst->U.I.SrcReg[0].Negate ^= RC_MASK_XYZW; + inst->U.I.SrcReg[1] = inst->U.I.SrcReg[2]; + return; + } else if (swz == RC_SWIZZLE_ZERO) { + inst->U.I.Opcode = RC_OPCODE_MOV; + inst->U.I.SrcReg[0] = inst->U.I.SrcReg[2]; + return; + } + } + + if (is_src_uniform_constant(inst->U.I.SrcReg[0], &swz, &negate)) { + if (swz == RC_SWIZZLE_ONE) { + inst->U.I.Opcode = RC_OPCODE_ADD; + if (negate) + inst->U.I.SrcReg[1].Negate ^= RC_MASK_XYZW; + inst->U.I.SrcReg[0] = inst->U.I.SrcReg[2]; + return; + } else if (swz == RC_SWIZZLE_ZERO) { + inst->U.I.Opcode = RC_OPCODE_MOV; + inst->U.I.SrcReg[0] = inst->U.I.SrcReg[2]; + return; + } + } +} + +static void constant_folding_mul(struct rc_instruction * inst) +{ + rc_swizzle swz; + unsigned int negate; + + if (is_src_uniform_constant(inst->U.I.SrcReg[0], &swz, &negate)) { + if (swz == RC_SWIZZLE_ONE) { + inst->U.I.Opcode = RC_OPCODE_MOV; + inst->U.I.SrcReg[0] = inst->U.I.SrcReg[1]; + if (negate) + inst->U.I.SrcReg[0].Negate ^= RC_MASK_XYZW; + return; + } else if (swz == RC_SWIZZLE_ZERO) { + inst->U.I.Opcode = RC_OPCODE_MOV; + inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_0000; + return; + } + } + + if (is_src_uniform_constant(inst->U.I.SrcReg[1], &swz, &negate)) { + if (swz == RC_SWIZZLE_ONE) { + inst->U.I.Opcode = RC_OPCODE_MOV; + if (negate) + inst->U.I.SrcReg[0].Negate ^= RC_MASK_XYZW; + return; + } else if (swz == RC_SWIZZLE_ZERO) { + inst->U.I.Opcode = RC_OPCODE_MOV; + inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_0000; + return; + } + } +} + +static void constant_folding_add(struct rc_instruction * inst) +{ + rc_swizzle swz; + unsigned int negate; + + if (is_src_uniform_constant(inst->U.I.SrcReg[0], &swz, &negate)) { + if (swz == RC_SWIZZLE_ZERO) { + inst->U.I.Opcode = RC_OPCODE_MOV; + inst->U.I.SrcReg[0] = inst->U.I.SrcReg[1]; + return; + } + } + + if (is_src_uniform_constant(inst->U.I.SrcReg[1], &swz, &negate)) { + if (swz == RC_SWIZZLE_ZERO) { + inst->U.I.Opcode = RC_OPCODE_MOV; + return; + } + } +} + + +/** + * Replace 0.0, 1.0 and 0.5 immediate constants by their + * respective swizzles. Simplify instructions like ADD dst, src, 0; + */ +static void constant_folding(struct radeon_compiler * c, struct rc_instruction * inst) +{ + const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode); + + /* Replace 0.0, 1.0 and 0.5 immediates by their explicit swizzles */ + for(unsigned int src = 0; src < opcode->NumSrcRegs; ++src) { + if (inst->U.I.SrcReg[src].File != RC_FILE_CONSTANT || + inst->U.I.SrcReg[src].RelAddr || + inst->U.I.SrcReg[src].Index >= c->Program.Constants.Count) + continue; + + struct rc_constant * constant = + &c->Program.Constants.Constants[inst->U.I.SrcReg[src].Index]; + + if (constant->Type != RC_CONSTANT_IMMEDIATE) + continue; + + struct rc_src_register newsrc = inst->U.I.SrcReg[src]; + int have_real_reference = 0; + for(unsigned int chan = 0; chan < 4; ++chan) { + unsigned int swz = GET_SWZ(newsrc.Swizzle, chan); + if (swz >= 4) + continue; + + unsigned int newswz; + float imm = constant->u.Immediate[swz]; + float baseimm = imm; + if (imm < 0.0) + baseimm = -baseimm; + + if (baseimm == 0.0) { + newswz = RC_SWIZZLE_ZERO; + } else if (baseimm == 1.0) { + newswz = RC_SWIZZLE_ONE; + } else if (baseimm == 0.5) { + newswz = RC_SWIZZLE_HALF; + } else { + have_real_reference = 1; + continue; + } + + SET_SWZ(newsrc.Swizzle, chan, newswz); + if (imm < 0.0 && !newsrc.Abs) + newsrc.Negate ^= 1 << chan; + } + + if (!have_real_reference) { + newsrc.File = RC_FILE_NONE; + newsrc.Index = 0; + } + + /* don't make the swizzle worse */ + if (!c->SwizzleCaps->IsNative(inst->U.I.Opcode, newsrc) && + c->SwizzleCaps->IsNative(inst->U.I.Opcode, inst->U.I.SrcReg[src])) + continue; + + inst->U.I.SrcReg[src] = newsrc; + } + + /* Simplify instructions based on constants */ + if (inst->U.I.Opcode == RC_OPCODE_MAD) + constant_folding_mad(inst); + + /* note: MAD can simplify to MUL or ADD */ + if (inst->U.I.Opcode == RC_OPCODE_MUL) + constant_folding_mul(inst); + else if (inst->U.I.Opcode == RC_OPCODE_ADD) + constant_folding_add(inst); +} + +void rc_optimize(struct radeon_compiler * c) +{ + struct rc_instruction * inst = c->Program.Instructions.Next; + while(inst != &c->Program.Instructions) { + struct rc_instruction * cur = inst; + inst = inst->Next; + + constant_folding(c, cur); + + if (cur->U.I.Opcode == RC_OPCODE_MOV) { + peephole(c, cur); + /* cur may no longer be part of the program */ + } + } +} diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_pair_regalloc.c b/src/mesa/drivers/dri/r300/compiler/radeon_pair_regalloc.c index fdfee867014..8a912da4613 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_pair_regalloc.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_pair_regalloc.c @@ -159,7 +159,7 @@ static int try_add_live_intervals(struct regalloc_state * s, } static void scan_callback(void * data, struct rc_instruction * inst, - rc_register_file file, unsigned int index, unsigned int chan) + rc_register_file file, unsigned int index, unsigned int mask) { struct regalloc_state * s = data; struct register_info * reg; @@ -191,8 +191,8 @@ static void compute_live_intervals(struct regalloc_state * s) for(struct rc_instruction * inst = s->C->Program.Instructions.Next; inst != &s->C->Program.Instructions; inst = inst->Next) { - rc_for_all_reads(inst, scan_callback, s); - rc_for_all_writes(inst, scan_callback, s); + rc_for_all_reads_mask(inst, scan_callback, s); + rc_for_all_writes_mask(inst, scan_callback, s); } } diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c b/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c index df67aafe028..a279549ff89 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c @@ -448,8 +448,8 @@ static void schedule_block(struct r300_fragment_program_compiler * c, * counter-intuitive, to account for the case where an * instruction writes to the same register as it reads * from. */ - rc_for_all_writes(inst, &scan_write, &s); - rc_for_all_reads(inst, &scan_read, &s); + rc_for_all_writes_chan(inst, &scan_write, &s); + rc_for_all_reads_chan(inst, &scan_read, &s); DBG("%i: Has %i dependencies\n", inst->IP, s.Current->NumDependencies); diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c b/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c index 05b874ba7cf..5ba2c29408c 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c @@ -556,6 +556,29 @@ static void transform_r300_vertex_CMP(struct radeon_compiler* c, rc_remove_instruction(inst); } +static void transform_r300_vertex_fix_LIT(struct radeon_compiler* c, + struct rc_instruction* inst) +{ + int tempreg = rc_find_free_temporary(c); + unsigned constant_swizzle; + int constant = rc_constants_add_immediate_scalar(&c->Program.Constants, + 0.0000000000000000001, + &constant_swizzle); + + /* MOV dst, src */ + emit1(c, inst->Prev, RC_OPCODE_MOV, 0, + dstreg(RC_FILE_TEMPORARY, tempreg), + inst->U.I.SrcReg[0]); + + /* MAX dst.z, src, 0.00...001 */ + emit2(c, inst->Prev, RC_OPCODE_MAX, 0, + dstregtmpmask(tempreg, RC_MASK_Y), + srcreg(RC_FILE_TEMPORARY, tempreg), + srcregswz(RC_FILE_CONSTANT, constant, constant_swizzle)); + + inst->U.I.SrcReg[0] = srcreg(RC_FILE_TEMPORARY, tempreg); +} + /** * For use with radeonLocalTransform, this transforms non-native ALU * instructions of the r300 up to r500 vertex engine. @@ -572,6 +595,7 @@ int r300_transform_vertex_alu( case RC_OPCODE_DP3: transform_DP3(c, inst); return 1; case RC_OPCODE_DPH: transform_DPH(c, inst); return 1; case RC_OPCODE_FLR: transform_FLR(c, inst); return 1; + case RC_OPCODE_LIT: transform_r300_vertex_fix_LIT(c, inst); return 1; case RC_OPCODE_LRP: transform_LRP(c, inst); return 1; case RC_OPCODE_SUB: transform_SUB(c, inst); return 1; case RC_OPCODE_SWZ: transform_SWZ(c, inst); return 1; @@ -789,7 +813,7 @@ int radeonTransformDeriv(struct radeon_compiler* c, if (inst->U.I.Opcode != RC_OPCODE_DDX && inst->U.I.Opcode != RC_OPCODE_DDY) return 0; - inst->U.I.SrcReg[1].Swizzle = RC_MAKE_SWIZZLE(RC_SWIZZLE_ONE, RC_SWIZZLE_ONE, RC_SWIZZLE_ONE, RC_SWIZZLE_ONE); + inst->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_1111; inst->U.I.SrcReg[1].Negate = RC_MASK_XYZW; return 1; diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_program_constants.h b/src/mesa/drivers/dri/r300/compiler/radeon_program_constants.h index 842012def02..2ddf60b6774 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_program_constants.h +++ b/src/mesa/drivers/dri/r300/compiler/radeon_program_constants.h @@ -115,6 +115,7 @@ typedef enum { #define RC_SWIZZLE_XYZW RC_MAKE_SWIZZLE(RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_W) #define RC_SWIZZLE_XYZ0 RC_MAKE_SWIZZLE(RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_ZERO) +#define RC_SWIZZLE_XYZZ RC_MAKE_SWIZZLE(RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_Z) #define RC_SWIZZLE_XXXX RC_MAKE_SWIZZLE_SMEAR(RC_SWIZZLE_X) #define RC_SWIZZLE_YYYY RC_MAKE_SWIZZLE_SMEAR(RC_SWIZZLE_Y) #define RC_SWIZZLE_ZZZZ RC_MAKE_SWIZZLE_SMEAR(RC_SWIZZLE_Z) diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c b/src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c index b4ba0b3f870..8336e58d554 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c @@ -97,7 +97,8 @@ int radeonTransformTEX( /* ARB_shadow & EXT_shadow_funcs */ if (inst->U.I.Opcode != RC_OPCODE_KIL && - c->Program.ShadowSamplers & (1 << inst->U.I.TexSrcUnit)) { + ((c->Program.ShadowSamplers & (1 << inst->U.I.TexSrcUnit)) || + (compiler->state.unit[inst->U.I.TexSrcUnit].compare_mode_enabled))) { rc_compare_func comparefunc = compiler->state.unit[inst->U.I.TexSrcUnit].texture_compare_func; if (comparefunc == RC_COMPARE_FUNC_NEVER || comparefunc == RC_COMPARE_FUNC_ALWAYS) { @@ -113,52 +114,75 @@ int radeonTransformTEX( return 1; } else { rc_compare_func comparefunc = compiler->state.unit[inst->U.I.TexSrcUnit].texture_compare_func; - unsigned int depthmode = compiler->state.unit[inst->U.I.TexSrcUnit].depth_texture_mode; - struct rc_instruction * inst_rcp = rc_insert_new_instruction(c, inst); - struct rc_instruction * inst_mad = rc_insert_new_instruction(c, inst_rcp); - struct rc_instruction * inst_cmp = rc_insert_new_instruction(c, inst_mad); - int pass, fail; - - inst_rcp->U.I.Opcode = RC_OPCODE_RCP; - inst_rcp->U.I.DstReg.File = RC_FILE_TEMPORARY; - inst_rcp->U.I.DstReg.Index = rc_find_free_temporary(c); - inst_rcp->U.I.DstReg.WriteMask = RC_MASK_W; - inst_rcp->U.I.SrcReg[0] = inst->U.I.SrcReg[0]; - inst_rcp->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_WWWW; - - inst_cmp->U.I.DstReg = inst->U.I.DstReg; + struct rc_instruction * inst_rcp = NULL; + struct rc_instruction * inst_mad; + struct rc_instruction * inst_cmp; + unsigned tmp_texsample = rc_find_free_temporary(c); + unsigned tmp_sum = rc_find_free_temporary(c); + unsigned tmp_recip_w = 0; + int pass, fail, tex; + + /* Save the output register. */ + struct rc_dst_register output_reg = inst->U.I.DstReg; + + /* Redirect TEX to a new temp. */ inst->U.I.DstReg.File = RC_FILE_TEMPORARY; - inst->U.I.DstReg.Index = rc_find_free_temporary(c); + inst->U.I.DstReg.Index = tmp_texsample; inst->U.I.DstReg.WriteMask = RC_MASK_XYZW; - inst_mad->U.I.Opcode = RC_OPCODE_MAD; + if (inst->U.I.Opcode == RC_OPCODE_TXP) { + tmp_recip_w = rc_find_free_temporary(c); + + /* Compute 1/W. */ + inst_rcp = rc_insert_new_instruction(c, inst); + inst_rcp->U.I.Opcode = RC_OPCODE_RCP; + inst_rcp->U.I.DstReg.File = RC_FILE_TEMPORARY; + inst_rcp->U.I.DstReg.Index = tmp_recip_w; + inst_rcp->U.I.DstReg.WriteMask = RC_MASK_W; + inst_rcp->U.I.SrcReg[0] = inst->U.I.SrcReg[0]; + inst_rcp->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_WWWW; + } + + /* Perspective-divide r by W (if it's TXP) and add the texture sample (see below). */ + inst_mad = rc_insert_new_instruction(c, inst_rcp ? inst_rcp : inst); inst_mad->U.I.DstReg.File = RC_FILE_TEMPORARY; - inst_mad->U.I.DstReg.Index = rc_find_free_temporary(c); + inst_mad->U.I.DstReg.Index = tmp_sum; inst_mad->U.I.SrcReg[0] = inst->U.I.SrcReg[0]; inst_mad->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_ZZZZ; - inst_mad->U.I.SrcReg[1].File = RC_FILE_TEMPORARY; - inst_mad->U.I.SrcReg[1].Index = inst_rcp->U.I.DstReg.Index; - inst_mad->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_WWWW; - inst_mad->U.I.SrcReg[2].File = RC_FILE_TEMPORARY; - inst_mad->U.I.SrcReg[2].Index = inst->U.I.DstReg.Index; - if (depthmode == 0) /* GL_LUMINANCE */ - inst_mad->U.I.SrcReg[2].Swizzle = RC_MAKE_SWIZZLE(RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_Z); - else if (depthmode == 2) /* GL_ALPHA */ - inst_mad->U.I.SrcReg[2].Swizzle = RC_SWIZZLE_WWWW; - - /* Recall that SrcReg[0] is tex, SrcReg[2] is r and: - * r < tex <=> -tex+r < 0 - * r >= tex <=> not (-tex+r < 0 */ + if (inst->U.I.Opcode == RC_OPCODE_TXP) { + inst_mad->U.I.Opcode = RC_OPCODE_MAD; + inst_mad->U.I.SrcReg[1].File = RC_FILE_TEMPORARY; + inst_mad->U.I.SrcReg[1].Index = tmp_recip_w; + inst_mad->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_WWWW; + tex = 2; + } else { + inst_mad->U.I.Opcode = RC_OPCODE_ADD; + tex = 1; + } + inst_mad->U.I.SrcReg[tex].File = RC_FILE_TEMPORARY; + inst_mad->U.I.SrcReg[tex].Index = tmp_texsample; + inst_mad->U.I.SrcReg[tex].Swizzle = compiler->state.unit[inst->U.I.TexSrcUnit].depth_texture_swizzle; + + /* Fake EQUAL/NOTEQUAL, it seems to pass some tests suprisingly. */ + if (comparefunc == RC_COMPARE_FUNC_EQUAL) { + comparefunc = RC_COMPARE_FUNC_GEQUAL; + } else if (comparefunc == RC_COMPARE_FUNC_NOTEQUAL) { + comparefunc = RC_COMPARE_FUNC_LESS; + } + + /* Recall that SrcReg[0] is r, SrcReg[tex] is tex and: + * LESS: r < tex <=> -tex+r < 0 + * GEQUAL: r >= tex <=> not (-tex+r < 0) + * GREATER: r > tex <=> tex-r < 0 + * LEQUAL: r <= tex <=> not ( tex-r < 0) + * + * This negates either r or tex: */ if (comparefunc == RC_COMPARE_FUNC_LESS || comparefunc == RC_COMPARE_FUNC_GEQUAL) - inst_mad->U.I.SrcReg[2].Negate = inst_mad->U.I.SrcReg[2].Negate ^ RC_MASK_XYZW; + inst_mad->U.I.SrcReg[tex].Negate = inst_mad->U.I.SrcReg[tex].Negate ^ RC_MASK_XYZW; else inst_mad->U.I.SrcReg[0].Negate = inst_mad->U.I.SrcReg[0].Negate ^ RC_MASK_XYZW; - inst_cmp->U.I.Opcode = RC_OPCODE_CMP; - /* DstReg has been filled out above */ - inst_cmp->U.I.SrcReg[0].File = RC_FILE_TEMPORARY; - inst_cmp->U.I.SrcReg[0].Index = inst_mad->U.I.DstReg.Index; - + /* This negates the whole expresion: */ if (comparefunc == RC_COMPARE_FUNC_LESS || comparefunc == RC_COMPARE_FUNC_GREATER) { pass = 1; fail = 2; @@ -167,6 +191,11 @@ int radeonTransformTEX( fail = 1; } + inst_cmp = rc_insert_new_instruction(c, inst_mad); + inst_cmp->U.I.Opcode = RC_OPCODE_CMP; + inst_cmp->U.I.DstReg = output_reg; + inst_cmp->U.I.SrcReg[0].File = RC_FILE_TEMPORARY; + inst_cmp->U.I.SrcReg[0].Index = tmp_sum; inst_cmp->U.I.SrcReg[pass].File = RC_FILE_NONE; inst_cmp->U.I.SrcReg[pass].Swizzle = RC_SWIZZLE_1111; inst_cmp->U.I.SrcReg[fail] = shadow_ambient(compiler, inst->U.I.TexSrcUnit); diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_common.c b/src/mesa/drivers/dri/r300/r300_fragprog_common.c index 2b7c93a9575..e678a42ca26 100644 --- a/src/mesa/drivers/dri/r300/r300_fragprog_common.c +++ b/src/mesa/drivers/dri/r300/r300_fragprog_common.c @@ -46,13 +46,13 @@ #include "radeon_mesa_to_rc.h" -static GLuint build_dtm(GLuint depthmode) +static GLuint build_dts(GLuint depthmode) { switch(depthmode) { default: - case GL_LUMINANCE: return 0; - case GL_INTENSITY: return 1; - case GL_ALPHA: return 2; + case GL_LUMINANCE: return RC_SWIZZLE_XYZZ; + case GL_INTENSITY: return RC_SWIZZLE_XYZW; + case GL_ALPHA: return RC_SWIZZLE_WWWW; } } @@ -78,7 +78,7 @@ static void build_state( if (fp->Base.ShadowSamplers & (1 << unit)) { struct gl_texture_object* tex = r300->radeon.glCtx->Texture.Unit[unit]._Current; - state->unit[unit].depth_texture_mode = build_dtm(tex->DepthMode); + state->unit[unit].depth_texture_swizzle = build_dts(tex->DepthMode); state->unit[unit].texture_compare_func = build_func(tex->CompareFunc); } } diff --git a/src/mesa/drivers/fbdev/Makefile b/src/mesa/drivers/fbdev/Makefile index ee73f29a46a..5120e1ac9e5 100644 --- a/src/mesa/drivers/fbdev/Makefile +++ b/src/mesa/drivers/fbdev/Makefile @@ -11,10 +11,11 @@ OBJECTS = $(SOURCES:.c=.o) INCLUDE_DIRS = \ -I$(TOP)/include \ + -I$(TOP)/src/mapi \ -I$(TOP)/src/mesa \ -I$(TOP)/src/mesa/main -CORE_MESA = $(TOP)/src/mesa/libmesa.a $(TOP)/src/mesa/libglapi.a +CORE_MESA = $(TOP)/src/mesa/libmesa.a $(TOP)/src/mapi/glapi/libglapi.a .c.o: diff --git a/src/mesa/drivers/glslcompiler/Makefile b/src/mesa/drivers/glslcompiler/Makefile index 7dcf9a6541a..6da9f93f59a 100644 --- a/src/mesa/drivers/glslcompiler/Makefile +++ b/src/mesa/drivers/glslcompiler/Makefile @@ -11,11 +11,12 @@ OBJECTS = \ glslcompiler.o \ ../common/driverfuncs.o \ ../../libmesa.a \ - ../../libglapi.a + $(TOP)/src/mapi/glapi/libglapi.a INCLUDES = \ -I$(TOP)/include \ -I$(TOP)/include/GL/internal \ + -I$(TOP)/src/mapi \ -I$(TOP)/src/mesa \ -I$(TOP)/src/mesa/main \ -I$(TOP)/src/mesa/glapi \ diff --git a/src/mesa/drivers/osmesa/Makefile b/src/mesa/drivers/osmesa/Makefile index 9010bbd130a..ea49a896590 100644 --- a/src/mesa/drivers/osmesa/Makefile +++ b/src/mesa/drivers/osmesa/Makefile @@ -16,6 +16,7 @@ OBJECTS = $(SOURCES:.c=.o) INCLUDE_DIRS = \ -I$(TOP)/include \ + -I$(TOP)/src/mapi \ -I$(TOP)/src/mesa \ -I$(TOP)/src/mesa/main @@ -23,7 +24,7 @@ INCLUDE_DIRS = \ ifeq ($(DRIVER_DIRS), osmesa) CORE_MESA = \ $(TOP)/src/mesa/libmesa.a \ - $(TOP)/src/mesa/libglapi.a \ + $(TOP)/src/mapi/glapi/libglapi.a \ $(TOP)/src/glsl/cl/libglslcl.a \ $(TOP)/src/glsl/pp/libglslpp.a else diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index e20507ae92f..ead40503977 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1004,7 +1004,20 @@ new_osmesa_renderbuffer(GLcontext *ctx, GLenum format, GLenum type) rb->AllocStorage = osmesa_renderbuffer_storage; rb->InternalFormat = GL_RGBA; - rb->Format = MESA_FORMAT_RGBA8888; + switch (type) { + case GL_UNSIGNED_BYTE: + rb->Format = MESA_FORMAT_RGBA8888; + break; + case GL_UNSIGNED_SHORT: + rb->Format = MESA_FORMAT_RGBA_16; + break; + case GL_FLOAT: + rb->Format = MESA_FORMAT_RGBA_FLOAT32; + break; + default: + assert(0 && "Unexpected type in new_osmesa_renderbuffer()"); + rb->Format = MESA_FORMAT_RGBA8888; + } rb->_BaseFormat = GL_RGBA; rb->DataType = type; } @@ -1048,7 +1061,6 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits, struct dd_function_table functions; GLint rind, gind, bind, aind; GLint redBits = 0, greenBits = 0, blueBits = 0, alphaBits =0; - GLenum type = CHAN_TYPE; rind = gind = bind = aind = 0; if (format==OSMESA_RGBA) { @@ -1167,11 +1179,9 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits, return NULL; } - /* create front color buffer in user-provided memory (no back buffer) */ - osmesa->rb = new_osmesa_renderbuffer(&osmesa->mesa, format, type); - _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT, osmesa->rb); - assert(osmesa->rb->RefCount == 2); - + /* Create depth/stencil/accum buffers. We'll create the color + * buffer later in OSMesaMakeCurrent(). + */ _mesa_add_soft_renderbuffers(osmesa->gl_buffer, GL_FALSE, /* color */ osmesa->gl_visual->haveDepthBuffer, @@ -1308,11 +1318,23 @@ OSMesaMakeCurrent( OSMesaContext osmesa, void *buffer, GLenum type, */ _glapi_check_multithread(); + + /* Create a front/left color buffer which wraps the user-provided buffer. + * There is no back color buffer. + * If the user tries to use a 8, 16 or 32-bit/channel buffer that + * doesn't match what Mesa was compiled for (CHAN_BITS) the + * _mesa_add_renderbuffer() function will create a "wrapper" renderbuffer + * that converts rendering from CHAN_BITS to the user-requested channel + * size. + */ + osmesa->rb = new_osmesa_renderbuffer(&osmesa->mesa, osmesa->format, type); + _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT, osmesa->rb); + assert(osmesa->rb->RefCount == 2); + /* Set renderbuffer fields. Set width/height = 0 to force * osmesa_renderbuffer_storage() being called by _mesa_resize_framebuffer() */ osmesa->rb->Data = buffer; - osmesa->rb->DataType = type; osmesa->rb->Width = osmesa->rb->Height = 0; /* Set the framebuffer's size. This causes the diff --git a/src/mesa/drivers/x11/Makefile b/src/mesa/drivers/x11/Makefile index 5e427d2d5c6..b5b0c1f11a8 100644 --- a/src/mesa/drivers/x11/Makefile +++ b/src/mesa/drivers/x11/Makefile @@ -40,11 +40,12 @@ OBJECTS = $(SOURCES:.c=.o) INCLUDE_DIRS = \ -I$(TOP)/include \ + -I$(TOP)/src/mapi \ -I$(TOP)/src/mesa \ -I$(TOP)/src/mesa/main \ $(X11_INCLUDES) -CORE_MESA = $(TOP)/src/mesa/libmesa.a $(TOP)/src/mesa/libglapi.a +CORE_MESA = $(TOP)/src/mesa/libmesa.a $(TOP)/src/mapi/glapi/libglapi.a diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index a1723fa37b1..dac1668cfe1 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -210,7 +210,7 @@ gamma_adjust( GLfloat gamma, GLint value, GLint max ) } else { double x = (double) value / (double) max; - return IROUND_POS((GLfloat) max * _mesa_pow(x, 1.0F/gamma)); + return IROUND_POS((GLfloat) max * pow(x, 1.0F/gamma)); } } @@ -846,19 +846,19 @@ setup_8bit_hpcr(XMesaVisual v) g = 1.0 / v->RedGamma; for (i=0; i<256; i++) { - GLint red = IROUND_POS(255.0 * _mesa_pow( hpcr_rgbTbl[0][i]/255.0, g )); + GLint red = IROUND_POS(255.0 * pow( hpcr_rgbTbl[0][i]/255.0, g )); v->hpcr_rgbTbl[0][i] = CLAMP( red, 16, 239 ); } g = 1.0 / v->GreenGamma; for (i=0; i<256; i++) { - GLint green = IROUND_POS(255.0 * _mesa_pow( hpcr_rgbTbl[1][i]/255.0, g )); + GLint green = IROUND_POS(255.0 * pow( hpcr_rgbTbl[1][i]/255.0, g )); v->hpcr_rgbTbl[1][i] = CLAMP( green, 16, 239 ); } g = 1.0 / v->BlueGamma; for (i=0; i<256; i++) { - GLint blue = IROUND_POS(255.0 * _mesa_pow( hpcr_rgbTbl[2][i]/255.0, g )); + GLint blue = IROUND_POS(255.0 * pow( hpcr_rgbTbl[2][i]/255.0, g )); v->hpcr_rgbTbl[2][i] = CLAMP( blue, 32, 223 ); } v->undithered_pf = PF_HPCR; /* can't really disable dithering for now */ diff --git a/src/mesa/es/.gitignore b/src/mesa/es/.gitignore deleted file mode 100644 index 7643e9f0dbe..00000000000 --- a/src/mesa/es/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -glapi/glapi-es* -glapi/glapi-stamp -main/get_es*.c -main/api_exec_es*.c -objs-es* diff --git a/src/mesa/es/Makefile b/src/mesa/es/Makefile deleted file mode 100644 index 5498b086aab..00000000000 --- a/src/mesa/es/Makefile +++ /dev/null @@ -1,122 +0,0 @@ -# src/mesa/es/Makefile -# -TOP := ../../.. -MESA := .. - -include $(TOP)/configs/current -include sources.mak - -ES1_LIBS := libes1gallium.a libes1api.a -ES2_LIBS := libes2gallium.a libes2api.a - -# Default rule: create ES1 and ES2 libs -.PHONY: default es1 es2 -default: depend es1 es2 - -es1: $(ES1_LIBS) - @rm -f subdirs-stamp-tmp - -es2: $(ES2_LIBS) - @rm -f subdirs-stamp-tmp - -ES1_CPPFLAGS := -DFEATURE_ES1=1 -D__GL_EXPORTS -ES2_CPPFLAGS := -DFEATURE_ES2=1 -D__GL_EXPORTS - -ES1_OBJ_DIR := objs-es1 -ES2_OBJ_DIR := objs-es2 - -# adjust output dirs -ES1_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(ES1_OBJECTS)) -ES1_GALLIUM_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(ES1_GALLIUM_OBJECTS)) -ES1_API_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(ES1_API_OBJECTS)) - -ES2_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(ES2_OBJECTS)) -ES2_GALLIUM_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(ES2_GALLIUM_OBJECTS)) -ES2_API_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(ES2_API_OBJECTS)) - -# compile either ES1 or ES2 sources -define es-compile - @mkdir -p $(dir $@) - $(CC) -c $(CFLAGS) $(ES$(1)_CPPFLAGS) $(ES$(1)_INCLUDES) -o $@ $< -endef - -$(ES1_OBJ_DIR)/%.o: %.c - $(call es-compile,1) - -$(ES1_OBJ_DIR)/%.o: %.S - $(call es-compile,1) - -$(ES1_OBJ_DIR)/%.o: $(MESA)/%.c - $(call es-compile,1) - -$(ES1_OBJ_DIR)/%.o: $(MESA)/%.S - $(call es-compile,1) - -$(ES2_OBJ_DIR)/%.o: %.c - $(call es-compile,2) - -$(ES2_OBJ_DIR)/%.o: %.S - $(call es-compile,2) - -$(ES2_OBJ_DIR)/%.o: $(MESA)/%.c - $(call es-compile,2) - -$(ES2_OBJ_DIR)/%.o: $(MESA)/%.S - $(call es-compile,2) - -libes1.a: $(ES1_OBJECTS) $(GLSL_LIBS) - @$(MKLIB) -o es1 -static $(ES1_OBJECTS) $(GLSL_LIBS) - -libes2.a: $(ES2_OBJECTS) $(GLSL_LIBS) - @$(MKLIB) -o es2 -static $(ES1_OBJECTS) $(GLSL_LIBS) - -libes1gallium.a: $(ES1_GALLIUM_OBJECTS) $(GLSL_LIBS) - @$(MKLIB) -o es1gallium -static $(ES1_GALLIUM_OBJECTS) $(GLSL_LIBS) - -libes2gallium.a: $(ES2_GALLIUM_OBJECTS) $(GLSL_LIBS) - @$(MKLIB) -o es2gallium -static $(ES2_GALLIUM_OBJECTS) $(GLSL_LIBS) - -libes1api.a: $(ES1_API_OBJECTS) - @$(MKLIB) -o es1api -static $(ES1_API_OBJECTS) - -libes2api.a: $(ES2_API_OBJECTS) - @$(MKLIB) -o es2api -static $(ES2_API_OBJECTS) - -.PHONY: clean -clean: - -rm -f $(ES1_LIBS) $(ES2_LIBS) - -rm -rf $(ES1_OBJ_DIR) $(ES2_OBJ_DIR) - -rm -f $(GENERATED_SOURCES) - -rm -f depend depend.bak - -rm -f subdirs-stamp-tmp - @$(MAKE) -C glapi clean - -# nothing to install -install: - -subdirs-stamp-tmp: - @$(MAKE) -C $(MESA) asm_subdirs - @$(MAKE) -C $(MESA) glsl_builtin - @$(MAKE) -C glapi - @touch subdirs-stamp-tmp - -# sort to avoid duplicates -ALL_SOURCES := $(sort $(ES1_ALL_SOURCES) $(ES2_ALL_SOURCES)) - -# need to make sure the subdirs are processed first -$(ALL_SOURCES): | subdirs-stamp-tmp - -depend: $(ALL_SOURCES) - @echo "running $(MKDEP)" - @touch depend - @# MESA is "..", but luckily, directories are longer than 2 characters - @$(MKDEP) -f- -p$(ES1_OBJ_DIR)/ $(DEFINES) $(ES1_CFLAGS) \ - $(ES1_INCLUDES) $(ES1_ALL_SOURCES) 2>/dev/null | \ - sed -e 's,^$(ES1_OBJ_DIR)/$(MESA)/,$(ES1_OBJ_DIR)/,' > depend - @$(MKDEP) -f- -p$(ES2_OBJ_DIR)/ $(DEFINES) $(ES2_CFLAGS) \ - $(ES2_INCLUDES) $(ES2_ALL_SOURCES) 2>/dev/null | \ - sed -e 's,^$(ES2_OBJ_DIR)/$(MESA)/,$(ES2_OBJ_DIR)/,' >> depend - -ifneq ($(MAKECMDGOALS),clean) --include depend -endif diff --git a/src/mesa/es/sources.mak b/src/mesa/es/sources.mak deleted file mode 100644 index 9bb7a6ff38c..00000000000 --- a/src/mesa/es/sources.mak +++ /dev/null @@ -1,125 +0,0 @@ -include $(MESA)/sources.mak - -# always use local version of GLAPI_ASM_SOURCES -LOCAL_ES1_API_ASM := $(addprefix glapi/glapi-es1/, $(GLAPI_ASM_SOURCES)) - -LOCAL_ES1_INCLUDES := \ - -I. \ - -I./glapi/glapi-es1 \ - -I$(MESA)/state_tracker - -LOCAL_ES2_API_ASM := $(subst es1,es2, $(LOCAL_ES1_API_ASM)) -LOCAL_ES2_INCLUDES := $(subst es1,es2, $(LOCAL_ES1_INCLUDES)) - -# MESA sources -# Ideally, the omit list should be replaced by features. - -MAIN_OMITTED := \ - main/api_exec.c \ - main/condrender.c \ - main/dlopen.c \ - main/get.c -MAIN_SOURCES := $(filter-out $(MAIN_OMITTED), $(MAIN_SOURCES)) - -VBO_OMITTED := \ - vbo/vbo_save.c \ - vbo/vbo_save_api.c \ - vbo/vbo_save_draw.c \ - vbo/vbo_save_loopback.c -VBO_SOURCES := $(filter-out $(VBO_OMITTED), $(VBO_SOURCES)) - -STATETRACKER_OMITTED := \ - state_tracker/st_api.c \ - state_tracker/st_cb_drawpixels.c \ - state_tracker/st_cb_feedback.c \ - state_tracker/st_cb_rasterpos.c \ - state_tracker/st_draw_feedback.c -STATETRACKER_SOURCES := $(filter-out $(STATETRACKER_OMITTED), $(STATETRACKER_SOURCES)) - -SHADER_OMITTED := \ - shader/atifragshader.c -SHADER_SOURCES := $(filter-out $(SHADER_OMITTED), $(SHADER_SOURCES)) - -MESA_ES1_SOURCES := \ - $(MAIN_SOURCES) \ - $(MATH_SOURCES) \ - $(MATH_XFORM_SOURCES) \ - $(VBO_SOURCES) \ - $(TNL_SOURCES) \ - $(SHADER_SOURCES) \ - $(SWRAST_SOURCES) \ - $(SWRAST_SETUP_SOURCES) \ - $(COMMON_DRIVER_SOURCES) \ - $(ASM_C_SOURCES) \ - $(SLANG_SOURCES) - -MESA_ES1_GALLIUM_SOURCES := \ - $(MAIN_SOURCES) \ - $(MATH_SOURCES) \ - $(VBO_SOURCES) \ - $(STATETRACKER_SOURCES) \ - $(SHADER_SOURCES) \ - ppc/common_ppc.c \ - x86/common_x86.c \ - $(SLANG_SOURCES) - -MESA_ES1_API_SOURCES := \ - $(GLAPI_SOURCES) - -MESA_ES1_INCLUDES := $(INCLUDE_DIRS) - -# right now es2 and es1 share MESA sources -MESA_ES2_SOURCES := $(MESA_ES1_SOURCES) -MESA_ES2_GALLIUM_SOURCES := $(MESA_ES1_GALLIUM_SOURCES) -MESA_ES2_API_SOURCES := $(MESA_ES1_API_SOURCES) - -MESA_ES2_INCLUDES := $(MESA_ES1_INCLUDES) - -# asm is shared by any ES version and any library -MESA_ES_ASM := $(MESA_ASM_SOURCES) - -# collect sources, adjust the pathes -ES1_SOURCES := $(addprefix $(MESA)/,$(MESA_ES1_SOURCES)) -ES1_GALLIUM_SOURCES := $(addprefix $(MESA)/,$(MESA_ES1_GALLIUM_SOURCES)) -ES1_API_SOURCES := $(addprefix $(MESA)/,$(MESA_ES1_API_SOURCES)) - -ES2_SOURCES := $(addprefix $(MESA)/,$(MESA_ES2_SOURCES)) -ES2_GALLIUM_SOURCES := $(addprefix $(MESA)/,$(MESA_ES2_GALLIUM_SOURCES)) -ES2_API_SOURCES := $(addprefix $(MESA)/,$(MESA_ES2_API_SOURCES)) - -# collect includes -ES1_INCLUDES := $(LOCAL_ES1_INCLUDES) $(MESA_ES1_INCLUDES) -ES2_INCLUDES := $(LOCAL_ES2_INCLUDES) $(MESA_ES2_INCLUDES) - -# collect objects, including asm -ES1_OBJECTS := \ - $(MESA_ES1_SOURCES:.c=.o) \ - $(MESA_ES_ASM:.S=.o) - -ES1_GALLIUM_OBJECTS := \ - $(MESA_ES1_GALLIUM_SOURCES:.c=.o) \ - $(MESA_ES_ASM:.S=.o) - -ES1_API_OBJECTS := \ - $(LOCAL_ES1_API_ASM:.S=.o) \ - $(MESA_ES1_API_SOURCES:.c=.o) - -ES2_OBJECTS := \ - $(MESA_ES2_SOURCES:.c=.o) \ - $(MESA_ES_ASM:.S=.o) - -ES2_GALLIUM_OBJECTS := \ - $(MESA_ES2_GALLIUM_SOURCES:.c=.o) \ - $(MESA_ES_ASM:.S=.o) - -ES2_API_OBJECTS := \ - $(LOCAL_ES2_API_ASM:.S=.o) \ - $(MESA_ES2_API_SOURCES:.c=.o) - -# collect sources for makedepend -ES1_ALL_SOURCES := $(ES1_SOURCES) $(ES1_GALLIUM_SOURCES) $(ES1_API_SOURCES) -ES2_ALL_SOURCES := $(ES2_SOURCES) $(ES2_GALLIUM_SOURCES) $(ES2_API_SOURCES) - -# sort to remove duplicates -ES1_ALL_SOURCES := $(sort $(ES1_ALL_SOURCES)) -ES2_ALL_SOURCES := $(sort $(ES2_ALL_SOURCES)) diff --git a/src/mesa/main/.gitignore b/src/mesa/main/.gitignore new file mode 100644 index 00000000000..391c334ab71 --- /dev/null +++ b/src/mesa/main/.gitignore @@ -0,0 +1,4 @@ +api_exec_es1.c +api_exec_es2.c +get_es1.c +get_es2.c diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml index 268bd5d3db2..b4ed18e75e8 100644 --- a/src/mesa/main/APIspec.xml +++ b/src/mesa/main/APIspec.xml @@ -3939,15 +3939,15 @@ <function name="PixelStorei" template="PixelStore" gltype="GLint"/> <function name="ReadPixels" template="ReadPixels"/> - <function name="GetBooleanv" default_prefix="_es1_" template="GetState" gltype="GLboolean"/> + <function name="GetBooleanv" template="GetState" gltype="GLboolean"/> <function name="GetClipPlanef" template="GetClipPlane" gltype="GLfloat"/> <function name="GetClipPlanex" template="GetClipPlane" gltype="GLfixed"/> <function name="GetError" template="GetError"/> - <function name="GetFloatv" default_prefix="_es1_" template="GetState" gltype="GLfloat"/> - <function name="GetFixedv" default_prefix="_es1_" template="GetState" gltype="GLfixed"/> - <function name="GetIntegerv" default_prefix="_es1_" template="GetState" gltype="GLint"/> + <function name="GetFloatv" template="GetState" gltype="GLfloat"/> + <function name="GetFixedv" template="GetState" gltype="GLfixed"/> + <function name="GetIntegerv" template="GetState" gltype="GLint"/> <function name="GetLightfv" template="GetLight" gltype="GLfloat"/> <function name="GetLightxv" template="GetLight" gltype="GLfixed"/> @@ -4173,10 +4173,10 @@ <function name="PixelStorei" template="PixelStore" gltype="GLint"/> <function name="ReadPixels" template="ReadPixels"/> - <function name="GetBooleanv" default_prefix="_es2_" template="GetState" gltype="GLboolean"/> + <function name="GetBooleanv" template="GetState" gltype="GLboolean"/> <function name="GetError" template="GetError"/> - <function name="GetFloatv" default_prefix="_es2_" template="GetState" gltype="GLfloat"/> - <function name="GetIntegerv" default_prefix="_es2_" template="GetState" gltype="GLint"/> + <function name="GetFloatv" template="GetState" gltype="GLfloat"/> + <function name="GetIntegerv" template="GetState" gltype="GLint"/> <function name="GetString" template="GetString"/> diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c index f838561aef3..7bd6e328132 100644 --- a/src/mesa/main/api_exec.c +++ b/src/mesa/main/api_exec.c @@ -36,9 +36,7 @@ #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program #include "shader/arbprogram.h" #endif -#if FEATURE_ATI_fragment_shader #include "shader/atifragshader.h" -#endif #include "attrib.h" #include "blend.h" #if FEATURE_ARB_vertex_buffer_object @@ -107,6 +105,10 @@ #endif #include "main/dispatch.h" + +#if FEATURE_GL + + #ifdef _GLAPI_USE_REMAP_TABLE #define need_MESA_remap_table @@ -523,15 +525,7 @@ _mesa_create_exec_table(void) SET_DepthBoundsEXT(exec, _mesa_DepthBoundsEXT); /* 352. GL_EXT_transform_feedback */ -#if _HAVE_FULL_GL - SET_BeginTransformFeedbackEXT(exec, _mesa_BeginTransformFeedback); - SET_EndTransformFeedbackEXT(exec, _mesa_EndTransformFeedback); - SET_BindBufferRangeEXT(exec, _mesa_BindBufferRange); - SET_BindBufferBaseEXT(exec, _mesa_BindBufferBase); - SET_BindBufferOffsetEXT(exec, _mesa_BindBufferOffsetEXT); - SET_TransformFeedbackVaryingsEXT(exec, _mesa_TransformFeedbackVaryings); - SET_GetTransformFeedbackVaryingEXT(exec, _mesa_GetTransformFeedbackVarying); -#endif + _mesa_init_transform_feedback_dispatch(exec); /* 364. GL_EXT_provoking_vertex */ SET_ProvokingVertexEXT(exec, _mesa_ProvokingVertexEXT); @@ -719,22 +713,7 @@ _mesa_create_exec_table(void) #endif /* GL_ATI_fragment_shader */ -#if FEATURE_ATI_fragment_shader - SET_GenFragmentShadersATI(exec, _mesa_GenFragmentShadersATI); - SET_BindFragmentShaderATI(exec, _mesa_BindFragmentShaderATI); - SET_DeleteFragmentShaderATI(exec, _mesa_DeleteFragmentShaderATI); - SET_BeginFragmentShaderATI(exec, _mesa_BeginFragmentShaderATI); - SET_EndFragmentShaderATI(exec, _mesa_EndFragmentShaderATI); - SET_PassTexCoordATI(exec, _mesa_PassTexCoordATI); - SET_SampleMapATI(exec, _mesa_SampleMapATI); - SET_ColorFragmentOp1ATI(exec, _mesa_ColorFragmentOp1ATI); - SET_ColorFragmentOp2ATI(exec, _mesa_ColorFragmentOp2ATI); - SET_ColorFragmentOp3ATI(exec, _mesa_ColorFragmentOp3ATI); - SET_AlphaFragmentOp1ATI(exec, _mesa_AlphaFragmentOp1ATI); - SET_AlphaFragmentOp2ATI(exec, _mesa_AlphaFragmentOp2ATI); - SET_AlphaFragmentOp3ATI(exec, _mesa_AlphaFragmentOp3ATI); - SET_SetFragmentShaderConstantATI(exec, _mesa_SetFragmentShaderConstantATI); -#endif + _mesa_init_ati_fragment_shader_dispatch(exec); /* GL_ATI_envmap_bumpmap */ SET_GetTexBumpParameterivATI(exec, _mesa_GetTexBumpParameterivATI); @@ -824,3 +803,5 @@ _mesa_create_exec_table(void) return exec; } + +#endif /* FEATURE_GL */ diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 92fb8d289d1..002448fedb8 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -46,7 +46,6 @@ #include "points.h" #include "polygon.h" #include "scissor.h" -#include "simple_list.h" #include "stencil.h" #include "texenv.h" #include "texgen.h" diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index 81704ae2c11..efd8057608c 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -200,6 +200,13 @@ extern "C" { # define __builtin_expect(x, y) x #endif +#ifdef __GNUC__ +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) +#else +#define likely(x) !!(x) +#define unlikely(x) !!(x) +#endif /** * The __FUNCTION__ gcc variable is generally only used for debugging. diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 4dd448a698d..e140a21b354 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -415,6 +415,7 @@ one_time_init( GLcontext *ctx ) } _mesa_init_sqrt_table(); + _mesa_init_get_hash(ctx); for (i = 0; i < 256; i++) { _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F; diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index c9f4d433a57..c61da62826f 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -153,6 +153,8 @@ _mesa_get_current_context(void); /*@}*/ +extern void +_mesa_init_get_hash(GLcontext *ctx); extern void _mesa_notifySwapBuffers(__GLcontext *gc); diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 897051eec07..53e44533cb3 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -706,27 +706,6 @@ struct dd_function_table { /*@}*/ - /** - * \name State-query functions - * - * Return GL_TRUE if query was completed, GL_FALSE otherwise. - */ - /*@{*/ - /** Return the value or values of a selected parameter */ - GLboolean (*GetBooleanv)(GLcontext *ctx, GLenum pname, GLboolean *result); - /** Return the value or values of a selected parameter */ - GLboolean (*GetDoublev)(GLcontext *ctx, GLenum pname, GLdouble *result); - /** Return the value or values of a selected parameter */ - GLboolean (*GetFloatv)(GLcontext *ctx, GLenum pname, GLfloat *result); - /** Return the value or values of a selected parameter */ - GLboolean (*GetIntegerv)(GLcontext *ctx, GLenum pname, GLint *result); - /** Return the value or values of a selected parameter */ - GLboolean (*GetInteger64v)(GLcontext *ctx, GLenum pname, GLint64 *result); - /** Return the value or values of a selected parameter */ - GLboolean (*GetPointerv)(GLcontext *ctx, GLenum pname, GLvoid **result); - /*@}*/ - - /** * \name Vertex/pixel buffer object functions */ @@ -1059,6 +1038,22 @@ struct dd_function_table { void *image_handle); #endif +#if FEATURE_EXT_transform_feedback + struct gl_transform_feedback_object * + (*NewTransformFeedback)(GLcontext *ctx, GLuint name); + void (*DeleteTransformFeedback)(GLcontext *ctx, + struct gl_transform_feedback_object *obj); + void (*BeginTransformFeedback)(GLcontext *ctx, GLenum mode, + struct gl_transform_feedback_object *obj); + void (*EndTransformFeedback)(GLcontext *ctx, + struct gl_transform_feedback_object *obj); + void (*PauseTransformFeedback)(GLcontext *ctx, + struct gl_transform_feedback_object *obj); + void (*ResumeTransformFeedback)(GLcontext *ctx, + struct gl_transform_feedback_object *obj); + void (*DrawTransformFeedback)(GLcontext *ctx, GLenum mode, + struct gl_transform_feedback_object *obj); +#endif }; diff --git a/src/mesa/main/dlopen.c b/src/mesa/main/dlopen.c index 658ac9e40cf..57a33292ed1 100644 --- a/src/mesa/main/dlopen.c +++ b/src/mesa/main/dlopen.c @@ -67,22 +67,27 @@ _mesa_dlopen(const char *libname, int flags) GenericFunc _mesa_dlsym(void *handle, const char *fname) { + union { + void *v; + GenericFunc f; + } u; #if defined(__blrts) - return (GenericFunc) NULL; + u.v = NULL; #elif defined(__DJGPP__) /* need '_' prefix on symbol names */ char fname2[1000]; fname2[0] = '_'; strncpy(fname2 + 1, fname, 998); fname2[999] = 0; - return (GenericFunc) dlsym(handle, fname2); + u.v = dlsym(handle, fname2); #elif defined(_GNU_SOURCE) - return (GenericFunc) dlsym(handle, fname); + u.v = dlsym(handle, fname); #elif defined(__MINGW32__) - return (GenericFunc) GetProcAddress(handle, fname); + u.v = (void *) GetProcAddress(handle, fname); #else - return (GenericFunc) NULL; + u.v = NULL; #endif + return u.f; } diff --git a/src/mesa/main/drawtex.c b/src/mesa/main/drawtex.c index 86d5b555e0f..c2ad5f23862 100644 --- a/src/mesa/main/drawtex.c +++ b/src/mesa/main/drawtex.c @@ -25,8 +25,6 @@ #include "main/state.h" #include "main/imports.h" -#include "main/dispatch.h" - #if FEATURE_OES_draw_texture diff --git a/src/mesa/main/es_generator.py b/src/mesa/main/es_generator.py index 8f08a3a6f92..a3e089ed58e 100644 --- a/src/mesa/main/es_generator.py +++ b/src/mesa/main/es_generator.py @@ -190,7 +190,10 @@ print """/* DO NOT EDIT ************************************************* print """ #include "%s" #include "%s" -""" % (versionHeader, versionExtHeader) +#include "main/mfeatures.h" + +#if FEATURE_%s +""" % (versionHeader, versionExtHeader, shortname.upper()) # Everyone needs these types. print """ @@ -211,19 +214,23 @@ extern void _mesa_error(void *ctx, GLenum error, const char *fmtString, ... ); #include "main/api_exec.h" #include "main/remap.h" +/* cannot include main/dispatch.h here */ #ifdef IN_DRI_DRIVER #define _GLAPI_USE_REMAP_TABLE #endif - -#include "es/glapi/glapi-%s/glapi/glapitable.h" -#include "es/glapi/glapi-%s/glapi/glapioffsets.h" -#include "es/glapi/glapi-%s/glapi/glapidispatch.h" +#include "%sapi/glapi/glapitable.h" +#include "%sapi/glapi/glapioffsets.h" +#include "%sapi/glapi/glapidispatch.h" #if FEATURE_remap_table +#if !FEATURE_GL +int driDispatchRemapTable[driDispatchRemapTable_size]; +#endif + #define need_MESA_remap_table -#include "es/glapi/glapi-%s/main/remap_helper.h" +#include "%sapi/main/remap_helper.h" void _mesa_init_remap_table_%s(void) @@ -728,3 +735,6 @@ for func in keys: print "" print " return exec;" print "}" + +print """ +#endif /* FEATURE_%s */""" % (shortname.upper()) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 4c8d4ccfa22..030ba607dad 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -28,7 +28,6 @@ #include "imports.h" #include "context.h" #include "extensions.h" -#include "simple_list.h" #include "mtypes.h" @@ -86,6 +85,7 @@ static const struct { { OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)}, { OFF, "GL_ARB_texture_rectangle", F(NV_texture_rectangle) }, { ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) }, + { OFF, "GL_ARB_transform_feedback2", F(ARB_transform_feedback2) }, { OFF, "GL_ARB_vertex_array_bgra", F(EXT_vertex_array_bgra) }, { OFF, "GL_ARB_vertex_array_object", F(ARB_vertex_array_object) }, { ON, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) }, diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 201a0232464..2376e7f1a54 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -887,6 +887,7 @@ _mesa_base_fbo_format(GLcontext *ctx, GLenum internalFormat) case GL_RGB10_A2: case GL_RGBA12: case GL_RGBA16: + case GL_RGBA16_SNORM: return GL_RGBA; case GL_STENCIL_INDEX: case GL_STENCIL_INDEX1_EXT: diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index b9796e4a423..3671140e859 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -721,6 +721,15 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = 16, 16, 16, 16, 0, 0, 0, 0, 0, 1, 1, 8 + }, + { + MESA_FORMAT_RGBA_16, + "MESA_FORMAT_RGBA_16", + GL_RGBA, + GL_UNSIGNED_NORMALIZED, + 16, 16, 16, 16, + 0, 0, 0, 0, 0, + 1, 1, 8 } }; @@ -1125,6 +1134,19 @@ _mesa_format_to_type_and_comps(gl_format format, *datatype = GL_BYTE; *comps = 4; return; + + case MESA_FORMAT_SIGNED_R_16: + *datatype = GL_SHORT; + *comps = 1; + return; + case MESA_FORMAT_SIGNED_RG_16: + *datatype = GL_SHORT; + *comps = 2; + return; + case MESA_FORMAT_SIGNED_RGB_16: + *datatype = GL_SHORT; + *comps = 3; + return; case MESA_FORMAT_SIGNED_RGBA_16: *datatype = GL_SHORT; *comps = 4; diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index 97e1fc5df46..c744688122f 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -142,10 +142,11 @@ typedef enum MESA_FORMAT_SIGNED_RGBX8888, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */ MESA_FORMAT_SIGNED_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ MESA_FORMAT_SIGNED_RGBA8888_REV,/*AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ - MESA_FORMAT_SIGNED_R_16, - MESA_FORMAT_SIGNED_RG_16, - MESA_FORMAT_SIGNED_RGB_16, - MESA_FORMAT_SIGNED_RGBA_16, + MESA_FORMAT_SIGNED_R_16, /* ushort[0]=R */ + MESA_FORMAT_SIGNED_RG_16, /* ushort[0]=R, ushort[1]=G */ + MESA_FORMAT_SIGNED_RGB_16, /* ushort[0]=R, ushort[1]=G, ushort[2]=B */ + MESA_FORMAT_SIGNED_RGBA_16, /* ... */ + MESA_FORMAT_RGBA_16, /* ... */ /*@}*/ MESA_FORMAT_COUNT diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index e3015cd6033..12d046b0754 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1,11 +1,31 @@ - -/*** - *** NOTE!!! DO NOT EDIT THIS FILE!!! IT IS GENERATED BY get_gen.py - ***/ +/* + * Copyright (C) 2010 Brian Paul All Rights Reserved. + * Copyright (C) 2010 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 shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Author: Kristian Høgsberg <[email protected]> + */ #include "glheader.h" #include "context.h" #include "enable.h" +#include "enums.h" #include "extensions.h" #include "get.h" #include "macros.h" @@ -14,10 +34,43 @@ #include "texcompress.h" #include "framebuffer.h" +/* This is a table driven implemetation of the glGet*v() functions. + * The basic idea is that most getters just look up an int somewhere + * in GLcontext and then convert it to a bool or float according to + * which of glGetIntegerv() glGetBooleanv() etc is being called. + * Instead of generating code to do this, we can just record the enum + * value and the offset into GLcontext in an array of structs. Then + * in glGet*(), we lookup the struct for the enum in question, and use + * the offset to get the int we need. + * + * Sometimes we need to look up a float, a boolean, a bit in a + * bitfield, a matrix or other types instead, so we need to track the + * type of the value in GLcontext. And sometimes the value isn't in + * GLcontext but in the drawbuffer, the array object, current texture + * unit, or maybe it's a computed value. So we need to also track + * where or how to find the value. Finally, we sometimes need to + * check that one of a number of extensions are enabled, the GL + * version or flush or call _mesa_update_state(). This is done by + * attaching optional extra information to the value description + * struct, it's sort of like an array of opcodes that describe extra + * checks or actions. + * + * Putting all this together we end up with struct value_desc below, + * and with a couple of macros to help, the table of struct value_desc + * is about as concise as the specification in the old python script. + */ + +#undef CONST #define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE ) +#define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \ + ((F) * 65536.0f < INT_MIN) ? INT_MIN : \ + (GLint) ((F) * 65536.0f) ) #define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) +#define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \ + ((I) < SHRT_MIN) ? INT_MIN : \ + (GLint) ((I) * 65536) ) #define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) #define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) ) @@ -25,7937 +78,2349 @@ #define BOOLEAN_TO_INT(B) ( (GLint) (B) ) #define BOOLEAN_TO_INT64(B) ( (GLint64) (B) ) #define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F ) +#define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 ) #define ENUM_TO_INT64(E) ( (GLint64) (E) ) +#define ENUM_TO_FIXED(E) (E) +enum value_type { + TYPE_INVALID, + TYPE_API_MASK, + TYPE_INT, + TYPE_INT_2, + TYPE_INT_3, + TYPE_INT_4, + TYPE_INT_N, + TYPE_INT64, + TYPE_ENUM, + TYPE_ENUM_2, + TYPE_BOOLEAN, + TYPE_BIT_0, + TYPE_BIT_1, + TYPE_BIT_2, + TYPE_BIT_3, + TYPE_BIT_4, + TYPE_BIT_5, + TYPE_FLOAT, + TYPE_FLOAT_2, + TYPE_FLOAT_3, + TYPE_FLOAT_4, + TYPE_FLOATN, + TYPE_FLOATN_2, + TYPE_FLOATN_3, + TYPE_FLOATN_4, + TYPE_DOUBLEN, + TYPE_MATRIX, + TYPE_MATRIX_T, + TYPE_CONST +}; -/* - * Check if named extension is enabled, if not generate error and return. - */ -#define CHECK_EXT1(EXT1) \ - if (!ctx->Extensions.EXT1) { \ - goto invalid_enum_error; \ +enum value_location { + LOC_BUFFER, + LOC_CONTEXT, + LOC_ARRAY, + LOC_TEXUNIT, + LOC_CUSTOM +}; + +enum value_extra { + EXTRA_END = 0x8000, + EXTRA_VERSION_30, + EXTRA_VERSION_31, + EXTRA_VERSION_32, + EXTRA_NEW_BUFFERS, + EXTRA_VALID_DRAW_BUFFER, + EXTRA_VALID_TEXTURE_UNIT, + EXTRA_FLUSH_CURRENT, +}; + +struct value_desc { + GLenum pname; + GLubyte location; /**< enum value_location */ + GLubyte type; /**< enum value_type */ + int offset; + const int *extra; +}; + +union value { + GLfloat value_float; + GLfloat value_float_4[4]; + GLmatrix *value_matrix; + GLint value_int; + GLint value_int_4[4]; + GLint64 value_int64; + GLenum value_enum; + + /* Sigh, see GL_COMPRESSED_TEXTURE_FORMATS_ARB handling */ + struct { + GLint n, ints[100]; + } value_int_n; + GLboolean value_bool; +}; + +#define BUFFER_FIELD(field, type) \ + LOC_BUFFER, type, offsetof(struct gl_framebuffer, field) +#define CONTEXT_FIELD(field, type) \ + LOC_CONTEXT, type, offsetof(GLcontext, field) +#define ARRAY_FIELD(field, type) \ + LOC_ARRAY, type, offsetof(struct gl_array_object, field) +#define CONST(value) \ + LOC_CONTEXT, TYPE_CONST, value + +#define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT) +#define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM) + +#define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT) +#define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2) +#define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64) +#define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM) +#define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2) +#define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN) +#define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0) +#define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1) +#define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2) +#define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3) +#define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4) +#define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5) +#define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT) +#define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2) +#define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3) +#define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4) +#define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX) +#define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T) + +#define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT) +#define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM) +#define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN) + +#define EXT(f) \ + offsetof(struct gl_extensions, f) + +#define EXTRA_EXT(e) \ + static const int extra_##e[] = { \ + EXT(e), EXTRA_END \ } -/* - * Check if either of two extensions is enabled. - */ -#define CHECK_EXT2(EXT1, EXT2) \ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ - goto invalid_enum_error; \ +#define EXTRA_EXT2(e1, e2) \ + static const int extra_##e1##_##e2[] = { \ + EXT(e1), EXT(e2), EXTRA_END \ } -/* - * Check if either of three extensions is enabled. - */ -#define CHECK_EXT3(EXT1, EXT2, EXT3) \ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2 && \ - !ctx->Extensions.EXT3) { \ - goto invalid_enum_error; \ +/* The 'extra' mechanism is a way to specify extra checks (such as + * extensions or specific gl versions) or actions (flush current, new + * buffers) that we need to do before looking up an enum. We need to + * declare them all up front so we can refer to them in the value_desc + * structs below. */ + +static const int extra_new_buffers[] = { + EXTRA_NEW_BUFFERS, + EXTRA_END +}; + +static const int extra_valid_draw_buffer[] = { + EXTRA_VALID_DRAW_BUFFER, + EXTRA_END +}; + +static const int extra_valid_texture_unit[] = { + EXTRA_VALID_TEXTURE_UNIT, + EXTRA_END +}; + +static const int extra_flush_current_valid_texture_unit[] = { + EXTRA_FLUSH_CURRENT, + EXTRA_VALID_TEXTURE_UNIT, + EXTRA_END +}; + +static const int extra_flush_current[] = { + EXTRA_FLUSH_CURRENT, + EXTRA_END +}; + +static const int extra_new_buffers_OES_read_format[] = { + EXTRA_NEW_BUFFERS, + EXT(OES_read_format), + EXTRA_END +}; + +static const int extra_EXT_secondary_color_flush_current[] = { + EXT(EXT_secondary_color), + EXTRA_FLUSH_CURRENT, + EXTRA_END +}; + +static const int extra_EXT_fog_coord_flush_current[] = { + EXT(EXT_fog_coord), + EXTRA_FLUSH_CURRENT, + EXTRA_END +}; + +EXTRA_EXT(ARB_multitexture); +EXTRA_EXT(ARB_texture_cube_map); +EXTRA_EXT(MESA_texture_array); +EXTRA_EXT2(EXT_secondary_color, ARB_vertex_program); +EXTRA_EXT(EXT_secondary_color); +EXTRA_EXT(EXT_fog_coord); +EXTRA_EXT(EXT_texture_lod_bias); +EXTRA_EXT(EXT_texture_filter_anisotropic); +EXTRA_EXT(IBM_rasterpos_clip); +EXTRA_EXT(NV_point_sprite); +EXTRA_EXT(SGIS_generate_mipmap); +EXTRA_EXT(NV_vertex_program); +EXTRA_EXT(NV_fragment_program); +EXTRA_EXT(NV_texture_rectangle); +EXTRA_EXT(EXT_stencil_two_side); +EXTRA_EXT(NV_light_max_exponent); +EXTRA_EXT(EXT_convolution); +EXTRA_EXT(EXT_histogram); +EXTRA_EXT(SGI_color_table); +EXTRA_EXT(SGI_texture_color_table); +EXTRA_EXT(EXT_depth_bounds_test); +EXTRA_EXT(ARB_depth_clamp); +EXTRA_EXT(ATI_fragment_shader); +EXTRA_EXT(EXT_framebuffer_blit); +EXTRA_EXT(ARB_shader_objects); +EXTRA_EXT(EXT_provoking_vertex); +EXTRA_EXT(ARB_fragment_shader); +EXTRA_EXT(ARB_fragment_program); +EXTRA_EXT(ARB_framebuffer_object); +EXTRA_EXT(EXT_framebuffer_object); +EXTRA_EXT(APPLE_vertex_array_object); +EXTRA_EXT(ARB_seamless_cube_map); +EXTRA_EXT(EXT_compiled_vertex_array); +EXTRA_EXT(ARB_sync); +EXTRA_EXT(ARB_vertex_shader); +EXTRA_EXT(EXT_transform_feedback); +EXTRA_EXT(ARB_transform_feedback2); +EXTRA_EXT(EXT_pixel_buffer_object); +EXTRA_EXT(ARB_vertex_program); +EXTRA_EXT2(NV_point_sprite, ARB_point_sprite); +EXTRA_EXT2(ARB_fragment_program, NV_fragment_program); +EXTRA_EXT2(ARB_vertex_program, NV_vertex_program); +EXTRA_EXT2(ARB_vertex_program, ARB_fragment_program); +EXTRA_EXT(ARB_vertex_buffer_object); + +static const int +extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = { + EXT(ARB_vertex_program), + EXT(ARB_fragment_program), + EXT(NV_vertex_program), + EXTRA_END +}; + +static const int +extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = { + EXT(NV_vertex_program), + EXT(ARB_vertex_program), + EXT(ARB_fragment_program), + EXT(NV_vertex_program), + EXTRA_END +}; + +static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END }; +static const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END }; +static const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END }; + +#define API_OPENGL_BIT (1 << API_OPENGL) +#define API_OPENGLES_BIT (1 << API_OPENGLES) +#define API_OPENGLES2_BIT (1 << API_OPENGLES2) + +/* This is the big table describing all the enums we accept in + * glGet*v(). The table is partitioned into six parts: enums + * understood by all GL APIs (OpenGL, GLES and GLES2), enums shared + * between OpenGL and GLES, enums exclusive to GLES, etc for the + * remaining combinations. When we add the enums to the hash table in + * _mesa_init_get_hash(), we only add the enums for the API we're + * instantiating and the different sections are guarded by #if + * FEATURE_GL etc to make sure we only compile in the enums we may + * need. */ + +static const struct value_desc values[] = { + /* Enums shared between OpenGL, GLES1 and GLES2 */ + { 0, 0, TYPE_API_MASK, + API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGLES2_BIT}, + { GL_ALPHA_BITS, BUFFER_INT(Visual.alphaBits), extra_new_buffers }, + { GL_BLEND, CONTEXT_BIT0(Color.BlendEnabled) }, + { GL_BLEND_SRC, CONTEXT_ENUM(Color.BlendSrcRGB) }, + { GL_BLUE_BITS, BUFFER_INT(Visual.blueBits), extra_new_buffers }, + { GL_COLOR_CLEAR_VALUE, CONTEXT_FIELD(Color.ClearColor[0], TYPE_FLOATN_4) }, + { GL_COLOR_WRITEMASK, LOC_CUSTOM, TYPE_INT_4, 0, }, + { GL_CULL_FACE, CONTEXT_BOOL(Polygon.CullFlag) }, + { GL_CULL_FACE_MODE, CONTEXT_ENUM(Polygon.CullFaceMode) }, + { GL_DEPTH_BITS, BUFFER_INT(Visual.depthBits) }, + { GL_DEPTH_CLEAR_VALUE, CONTEXT_FIELD(Depth.Clear, TYPE_DOUBLEN) }, + { GL_DEPTH_FUNC, CONTEXT_ENUM(Depth.Func) }, + { GL_DEPTH_RANGE, CONTEXT_FIELD(Viewport.Near, TYPE_FLOATN_2) }, + { GL_DEPTH_TEST, CONTEXT_BOOL(Depth.Test) }, + { GL_DEPTH_WRITEMASK, CONTEXT_BOOL(Depth.Mask) }, + { GL_DITHER, CONTEXT_BOOL(Color.DitherFlag) }, + { GL_FRONT_FACE, CONTEXT_ENUM(Polygon.FrontFace) }, + { GL_GREEN_BITS, BUFFER_INT(Visual.greenBits), extra_new_buffers }, + { GL_LINE_WIDTH, CONTEXT_FLOAT(Line.Width) }, + { GL_ALIASED_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidth) }, + { GL_MAX_ELEMENTS_VERTICES, CONTEXT_INT(Const.MaxArrayLockSize) }, + { GL_MAX_ELEMENTS_INDICES, CONTEXT_INT(Const.MaxArrayLockSize) }, + { GL_MAX_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT, + offsetof(GLcontext, Const.MaxTextureLevels) }, + { GL_MAX_VIEWPORT_DIMS, CONTEXT_INT2(Const.MaxViewportWidth) }, + { GL_PACK_ALIGNMENT, CONTEXT_INT(Pack.Alignment) }, + { GL_ALIASED_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSize) }, + { GL_POLYGON_OFFSET_FACTOR, CONTEXT_FLOAT(Polygon.OffsetFactor ) }, + { GL_POLYGON_OFFSET_UNITS, CONTEXT_FLOAT(Polygon.OffsetUnits ) }, + { GL_POLYGON_OFFSET_FILL, CONTEXT_BOOL(Polygon.OffsetFill) }, + { GL_RED_BITS, BUFFER_INT(Visual.redBits), extra_new_buffers }, + { GL_SCISSOR_BOX, LOC_CUSTOM, TYPE_INT_4, 0 }, + { GL_SCISSOR_TEST, CONTEXT_BOOL(Scissor.Enabled) }, + { GL_STENCIL_BITS, BUFFER_INT(Visual.stencilBits) }, + { GL_STENCIL_CLEAR_VALUE, CONTEXT_INT(Stencil.Clear) }, + { GL_STENCIL_FAIL, LOC_CUSTOM, TYPE_ENUM }, + { GL_STENCIL_FUNC, LOC_CUSTOM, TYPE_ENUM }, + { GL_STENCIL_PASS_DEPTH_FAIL, LOC_CUSTOM, TYPE_ENUM }, + { GL_STENCIL_PASS_DEPTH_PASS, LOC_CUSTOM, TYPE_ENUM }, + { GL_STENCIL_REF, LOC_CUSTOM, TYPE_INT }, + { GL_STENCIL_TEST, CONTEXT_BOOL(Stencil.Enabled) }, + { GL_STENCIL_VALUE_MASK, LOC_CUSTOM, TYPE_INT }, + { GL_STENCIL_WRITEMASK, LOC_CUSTOM, TYPE_INT }, + { GL_SUBPIXEL_BITS, CONTEXT_INT(Const.SubPixelBits) }, + { GL_TEXTURE_BINDING_2D, LOC_CUSTOM, TYPE_INT, TEXTURE_2D_INDEX }, + { GL_UNPACK_ALIGNMENT, CONTEXT_INT(Unpack.Alignment) }, + { GL_VIEWPORT, LOC_CUSTOM, TYPE_INT_4, 0 }, + + /* GL_ARB_multitexture */ + { GL_ACTIVE_TEXTURE_ARB, + LOC_CUSTOM, TYPE_INT, 0, extra_ARB_multitexture }, + + /* Note that all the OES_* extensions require that the Mesa "struct + * gl_extensions" include a member with the name of the extension. + * That structure does not yet include OES extensions (and we're + * not sure whether it will). If it does, all the OES_* + * extensions below should mark the dependency. */ + + /* GL_ARB_texture_cube_map */ + { GL_TEXTURE_BINDING_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_INT, + TEXTURE_CUBE_INDEX, extra_ARB_texture_cube_map }, + { GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(GLcontext, Const.MaxCubeTextureLevels), + extra_ARB_texture_cube_map }, /* XXX: OES_texture_cube_map */ + + /* XXX: OES_blend_subtract */ + { GL_BLEND_SRC_RGB_EXT, CONTEXT_ENUM(Color.BlendSrcRGB) }, + { GL_BLEND_DST_RGB_EXT, CONTEXT_ENUM(Color.BlendDstRGB) }, + { GL_BLEND_SRC_ALPHA_EXT, CONTEXT_ENUM(Color.BlendSrcA) }, + { GL_BLEND_DST_ALPHA_EXT, CONTEXT_ENUM(Color.BlendDstA) }, + + /* GL_BLEND_EQUATION_RGB, which is what we're really after, is + * defined identically to GL_BLEND_EQUATION. */ + { GL_BLEND_EQUATION, CONTEXT_ENUM(Color.BlendEquationRGB) }, + { GL_BLEND_EQUATION_ALPHA_EXT, CONTEXT_ENUM(Color.BlendEquationA) }, + + /* GL_ARB_texture_compression */ + { GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT, 0 }, + { GL_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT_N, 0 }, + + /* GL_ARB_multisample */ + { GL_SAMPLE_ALPHA_TO_COVERAGE_ARB, + CONTEXT_BOOL(Multisample.SampleAlphaToCoverage) }, + { GL_SAMPLE_COVERAGE_ARB, CONTEXT_BOOL(Multisample.SampleCoverage) }, + { GL_SAMPLE_COVERAGE_VALUE_ARB, + CONTEXT_FLOAT(Multisample.SampleCoverageValue) }, + { GL_SAMPLE_COVERAGE_INVERT_ARB, + CONTEXT_BOOL(Multisample.SampleCoverageInvert) }, + { GL_SAMPLE_BUFFERS_ARB, BUFFER_INT(Visual.sampleBuffers) }, + { GL_SAMPLES_ARB, BUFFER_INT(Visual.samples) }, + + /* GL_SGIS_generate_mipmap */ + { GL_GENERATE_MIPMAP_HINT_SGIS, CONTEXT_ENUM(Hint.GenerateMipmap), + extra_SGIS_generate_mipmap }, + + /* GL_ARB_vertex_buffer_object */ + { GL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0 }, + + /* GL_ARB_vertex_buffer_object */ + /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported */ + { GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0, + extra_ARB_vertex_buffer_object }, + + /* GL_OES_read_format */ + { GL_IMPLEMENTATION_COLOR_READ_TYPE_OES, LOC_CUSTOM, TYPE_INT, 0, + extra_new_buffers_OES_read_format }, + { GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES, LOC_CUSTOM, TYPE_INT, 0, + extra_new_buffers_OES_read_format }, + + /* GL_EXT_framebuffer_object */ + { GL_FRAMEBUFFER_BINDING_EXT, BUFFER_INT(Name), + extra_EXT_framebuffer_object }, + { GL_RENDERBUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, + extra_EXT_framebuffer_object }, + { GL_MAX_RENDERBUFFER_SIZE_EXT, CONTEXT_INT(Const.MaxRenderbufferSize), + extra_EXT_framebuffer_object }, + + /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's + * GLSL: */ + { GL_MAX_CLIP_PLANES, CONTEXT_INT(Const.MaxClipPlanes) }, + +#if FEATURE_GL || FEATURE_ES1 + /* Enums in OpenGL and GLES1 */ + { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES_BIT }, + { GL_LIGHT0, CONTEXT_BOOL(Light.Light[0].Enabled) }, + { GL_LIGHT1, CONTEXT_BOOL(Light.Light[1].Enabled) }, + { GL_LIGHT2, CONTEXT_BOOL(Light.Light[2].Enabled) }, + { GL_LIGHT3, CONTEXT_BOOL(Light.Light[3].Enabled) }, + { GL_LIGHT4, CONTEXT_BOOL(Light.Light[4].Enabled) }, + { GL_LIGHT5, CONTEXT_BOOL(Light.Light[5].Enabled) }, + { GL_LIGHT6, CONTEXT_BOOL(Light.Light[6].Enabled) }, + { GL_LIGHT7, CONTEXT_BOOL(Light.Light[7].Enabled) }, + { GL_LIGHTING, CONTEXT_BOOL(Light.Enabled) }, + { GL_LIGHT_MODEL_AMBIENT, + CONTEXT_FIELD(Light.Model.Ambient[0], TYPE_FLOATN_4) }, + { GL_LIGHT_MODEL_TWO_SIDE, CONTEXT_BOOL(Light.Model.TwoSide) }, + { GL_ALPHA_TEST, CONTEXT_BOOL(Color.AlphaEnabled) }, + { GL_ALPHA_TEST_FUNC, CONTEXT_ENUM(Color.AlphaFunc) }, + { GL_ALPHA_TEST_REF, CONTEXT_FIELD(Color.AlphaRef, TYPE_FLOATN) }, + { GL_BLEND_DST, CONTEXT_ENUM(Color.BlendDstRGB) }, + { GL_CLIP_PLANE0, CONTEXT_BIT0(Transform.ClipPlanesEnabled) }, + { GL_CLIP_PLANE1, CONTEXT_BIT1(Transform.ClipPlanesEnabled) }, + { GL_CLIP_PLANE2, CONTEXT_BIT2(Transform.ClipPlanesEnabled) }, + { GL_CLIP_PLANE3, CONTEXT_BIT3(Transform.ClipPlanesEnabled) }, + { GL_CLIP_PLANE4, CONTEXT_BIT4(Transform.ClipPlanesEnabled) }, + { GL_CLIP_PLANE5, CONTEXT_BIT5(Transform.ClipPlanesEnabled) }, + { GL_COLOR_MATERIAL, CONTEXT_BOOL(Light.ColorMaterialEnabled) }, + { GL_CURRENT_COLOR, + CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR0][0], TYPE_FLOATN_4), + extra_flush_current }, + { GL_CURRENT_NORMAL, + CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_NORMAL][0], TYPE_FLOATN_3), + extra_flush_current }, + { GL_CURRENT_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0, + extra_flush_current_valid_texture_unit }, + { GL_DISTANCE_ATTENUATION_EXT, CONTEXT_FLOAT3(Point.Params[0]) }, + { GL_FOG, CONTEXT_BOOL(Fog.Enabled) }, + { GL_FOG_COLOR, CONTEXT_FIELD(Fog.Color[0], TYPE_FLOATN_4) }, + { GL_FOG_DENSITY, CONTEXT_FLOAT(Fog.Density) }, + { GL_FOG_END, CONTEXT_FLOAT(Fog.End) }, + { GL_FOG_HINT, CONTEXT_ENUM(Hint.Fog) }, + { GL_FOG_MODE, CONTEXT_ENUM(Fog.Mode) }, + { GL_FOG_START, CONTEXT_FLOAT(Fog.Start) }, + { GL_LINE_SMOOTH, CONTEXT_BOOL(Line.SmoothFlag) }, + { GL_LINE_SMOOTH_HINT, CONTEXT_ENUM(Hint.LineSmooth) }, + { GL_LINE_WIDTH_RANGE, CONTEXT_FLOAT2(Const.MinLineWidthAA) }, + { GL_COLOR_LOGIC_OP, CONTEXT_BOOL(Color.ColorLogicOpEnabled) }, + { GL_LOGIC_OP_MODE, CONTEXT_ENUM(Color.LogicOp) }, + { GL_MATRIX_MODE, CONTEXT_ENUM(Transform.MatrixMode) }, + { GL_MAX_MODELVIEW_STACK_DEPTH, CONST(MAX_MODELVIEW_STACK_DEPTH) }, + { GL_MAX_PROJECTION_STACK_DEPTH, CONST(MAX_PROJECTION_STACK_DEPTH) }, + { GL_MAX_TEXTURE_STACK_DEPTH, CONST(MAX_TEXTURE_STACK_DEPTH), }, + { GL_MODELVIEW_MATRIX, CONTEXT_MATRIX(ModelviewMatrixStack.Top) }, + { GL_MODELVIEW_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, + offsetof(GLcontext, ModelviewMatrixStack.Depth) }, + { GL_NORMALIZE, CONTEXT_BOOL(Transform.Normalize) }, + { GL_PACK_SKIP_IMAGES_EXT, CONTEXT_INT(Pack.SkipImages) }, + { GL_PERSPECTIVE_CORRECTION_HINT, CONTEXT_ENUM(Hint.PerspectiveCorrection) }, + { GL_POINT_SIZE, CONTEXT_FLOAT(Point.Size) }, + { GL_POINT_SIZE_RANGE, CONTEXT_FLOAT2(Const.MinPointSizeAA) }, + { GL_POINT_SMOOTH, CONTEXT_BOOL(Point.SmoothFlag) }, + { GL_POINT_SMOOTH_HINT, CONTEXT_ENUM(Hint.PointSmooth) }, + { GL_POINT_SIZE_MIN_EXT, CONTEXT_FLOAT(Point.MinSize) }, + { GL_POINT_SIZE_MAX_EXT, CONTEXT_FLOAT(Point.MaxSize) }, + { GL_POINT_FADE_THRESHOLD_SIZE_EXT, CONTEXT_FLOAT(Point.Threshold) }, + { GL_PROJECTION_MATRIX, CONTEXT_MATRIX(ProjectionMatrixStack.Top) }, + { GL_PROJECTION_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, + offsetof(GLcontext, ProjectionMatrixStack.Depth) }, + { GL_RESCALE_NORMAL, CONTEXT_BOOL(Transform.RescaleNormals) }, + { GL_SHADE_MODEL, CONTEXT_ENUM(Light.ShadeModel) }, + { GL_TEXTURE_2D, LOC_CUSTOM, TYPE_BOOLEAN, 0 }, + { GL_TEXTURE_MATRIX, LOC_CUSTOM, TYPE_MATRIX, 0, extra_valid_texture_unit }, + { GL_TEXTURE_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, 0, + extra_valid_texture_unit }, + + { GL_VERTEX_ARRAY, ARRAY_BOOL(Vertex.Enabled) }, + { GL_VERTEX_ARRAY_SIZE, ARRAY_INT(Vertex.Size) }, + { GL_VERTEX_ARRAY_TYPE, ARRAY_ENUM(Vertex.Type) }, + { GL_VERTEX_ARRAY_STRIDE, ARRAY_INT(Vertex.Stride) }, + { GL_NORMAL_ARRAY, ARRAY_ENUM(Normal.Enabled) }, + { GL_NORMAL_ARRAY_TYPE, ARRAY_ENUM(Normal.Type) }, + { GL_NORMAL_ARRAY_STRIDE, ARRAY_INT(Normal.Stride) }, + { GL_COLOR_ARRAY, ARRAY_BOOL(Color.Enabled) }, + { GL_COLOR_ARRAY_SIZE, ARRAY_INT(Color.Size) }, + { GL_COLOR_ARRAY_TYPE, ARRAY_ENUM(Color.Type) }, + { GL_COLOR_ARRAY_STRIDE, ARRAY_INT(Color.Stride) }, + { GL_TEXTURE_COORD_ARRAY, + LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Enabled) }, + { GL_TEXTURE_COORD_ARRAY_SIZE, + LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Size) }, + { GL_TEXTURE_COORD_ARRAY_TYPE, + LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Type) }, + { GL_TEXTURE_COORD_ARRAY_STRIDE, + LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Stride) }, + + /* GL_ARB_multitexture */ + { GL_MAX_TEXTURE_UNITS_ARB, + CONTEXT_INT(Const.MaxTextureUnits), extra_ARB_multitexture }, + { GL_CLIENT_ACTIVE_TEXTURE_ARB, + LOC_CUSTOM, TYPE_INT, 0, extra_ARB_multitexture }, + + /* GL_ARB_texture_cube_map */ + { GL_TEXTURE_CUBE_MAP_ARB, LOC_CUSTOM, TYPE_BOOLEAN, 0 }, + /* S, T, and R are always set at the same time */ + { GL_TEXTURE_GEN_STR_OES, LOC_TEXUNIT, TYPE_BIT_0, + offsetof(struct gl_texture_unit, TexGenEnabled) }, + + /* GL_ARB_multisample */ + { GL_MULTISAMPLE_ARB, CONTEXT_BOOL(Multisample.Enabled) }, + { GL_SAMPLE_ALPHA_TO_ONE_ARB, CONTEXT_BOOL(Multisample.SampleAlphaToOne) }, + + /* GL_ARB_vertex_buffer_object */ + { GL_VERTEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_array_object, Vertex.BufferObj) }, + { GL_NORMAL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_array_object, Normal.BufferObj) }, + { GL_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_array_object, Color.BufferObj) }, + { GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, 0 }, + + /* GL_OES_point_sprite */ + { GL_POINT_SPRITE_NV, + CONTEXT_BOOL(Point.PointSprite), + extra_NV_point_sprite_ARB_point_sprite }, + + /* GL_ARB_fragment_shader */ + { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, + CONTEXT_INT(Const.FragmentProgram.MaxUniformComponents), + extra_ARB_fragment_shader }, + + /* GL_ARB_vertex_shader */ + { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, + CONTEXT_INT(Const.VertexProgram.MaxUniformComponents), + extra_ARB_vertex_shader }, + { GL_MAX_VARYING_FLOATS_ARB, LOC_CUSTOM, TYPE_INT, 0, + extra_ARB_vertex_shader }, + + /* GL_EXT_texture_lod_bias */ + { GL_MAX_TEXTURE_LOD_BIAS_EXT, CONTEXT_FLOAT(Const.MaxTextureLodBias), + extra_EXT_texture_lod_bias }, + + /* GL_EXT_texture_filter_anisotropic */ + { GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, + CONTEXT_FLOAT(Const.MaxTextureMaxAnisotropy), + extra_EXT_texture_filter_anisotropic }, +#endif /* FEATURE_GL || FEATURE_ES1 */ + +#if FEATURE_ES1 + { 0, 0, TYPE_API_MASK, API_OPENGLES_BIT }, + /* XXX: OES_matrix_get */ + { GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES }, + { GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES }, + { GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES }, + + /* OES_point_size_array */ + { GL_POINT_SIZE_ARRAY_OES, ARRAY_FIELD(PointSize.Enabled, TYPE_BOOLEAN) }, + { GL_POINT_SIZE_ARRAY_TYPE_OES, ARRAY_FIELD(PointSize.Type, TYPE_ENUM) }, + { GL_POINT_SIZE_ARRAY_STRIDE_OES, ARRAY_FIELD(PointSize.Stride, TYPE_INT) }, + { GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES, LOC_CUSTOM, TYPE_INT, 0 }, +#endif /* FEATURE_ES1 */ + +#if FEATURE_GL || FEATURE_ES2 + { 0, 0, TYPE_API_MASK, API_OPENGL_BIT | API_OPENGLES2_BIT }, + /* This entry isn't spec'ed for GLES 2, but is needed for Mesa's GLSL: */ + { GL_MAX_LIGHTS, CONTEXT_INT(Const.MaxLights) }, + { GL_MAX_TEXTURE_COORDS_ARB, /* == GL_MAX_TEXTURE_COORDS_NV */ + CONTEXT_INT(Const.MaxTextureCoordUnits), + extra_ARB_fragment_program_NV_fragment_program }, + + /* GL_ARB_draw_buffers */ + { GL_MAX_DRAW_BUFFERS_ARB, CONTEXT_INT(Const.MaxDrawBuffers) }, + + { GL_BLEND_COLOR_EXT, CONTEXT_FIELD(Color.BlendColor[0], TYPE_FLOATN_4) }, + /* GL_ARB_fragment_program */ + { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, /* == GL_MAX_TEXTURE_IMAGE_UNITS_NV */ + CONTEXT_INT(Const.MaxTextureImageUnits), + extra_ARB_fragment_program_NV_fragment_program }, + { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, + CONTEXT_INT(Const.MaxVertexTextureImageUnits), extra_ARB_vertex_shader }, + { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, + CONTEXT_INT(Const.MaxCombinedTextureImageUnits), + extra_ARB_vertex_shader }, + + /* GL_ARB_shader_objects + * Actually, this token isn't part of GL_ARB_shader_objects, but is + * close enough for now. */ + { GL_CURRENT_PROGRAM, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_shader_objects }, + + /* OpenGL 2.0 */ + { GL_STENCIL_BACK_FUNC, CONTEXT_ENUM(Stencil.Function[1]) }, + { GL_STENCIL_BACK_VALUE_MASK, CONTEXT_INT(Stencil.ValueMask[1]) }, + { GL_STENCIL_BACK_WRITEMASK, CONTEXT_INT(Stencil.WriteMask[1]) }, + { GL_STENCIL_BACK_REF, CONTEXT_INT(Stencil.Ref[1]) }, + { GL_STENCIL_BACK_FAIL, CONTEXT_ENUM(Stencil.FailFunc[1]) }, + { GL_STENCIL_BACK_PASS_DEPTH_FAIL, CONTEXT_ENUM(Stencil.ZFailFunc[1]) }, + { GL_STENCIL_BACK_PASS_DEPTH_PASS, CONTEXT_ENUM(Stencil.ZPassFunc[1]) }, + + { GL_MAX_VERTEX_ATTRIBS_ARB, + CONTEXT_INT(Const.VertexProgram.MaxAttribs), extra_ARB_vertex_program }, + + /* OES_texture_3D */ + { GL_TEXTURE_BINDING_3D, LOC_CUSTOM, TYPE_INT, TEXTURE_3D_INDEX }, + { GL_MAX_3D_TEXTURE_SIZE, LOC_CUSTOM, TYPE_INT, + offsetof(GLcontext, Const.Max3DTextureLevels) }, + + /* GL_ARB_fragment_shader/OES_standard_derivatives */ + { GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB, + CONTEXT_ENUM(Hint.FragmentShaderDerivative), extra_ARB_fragment_shader }, +#endif /* FEATURE_GL || FEATURE_ES2 */ + +#if FEATURE_ES2 + /* Enums unique to OpenGL ES 2.0 */ + { 0, 0, TYPE_API_MASK, API_OPENGLES2_BIT }, + { GL_MAX_FRAGMENT_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, + offsetof(GLcontext, Const.FragmentProgram.MaxUniformComponents) }, + { GL_MAX_VARYING_VECTORS, LOC_CUSTOM, TYPE_INT, + offsetof(GLcontext, Const.MaxVarying) }, + { GL_MAX_VERTEX_UNIFORM_VECTORS, LOC_CUSTOM, TYPE_INT, + offsetof(GLcontext, Const.VertexProgram.MaxUniformComponents) }, + { GL_SHADER_COMPILER, CONST(1) }, + /* OES_get_program_binary */ + { GL_NUM_SHADER_BINARY_FORMATS, CONST(0) }, + { GL_SHADER_BINARY_FORMATS, CONST(0) }, +#endif /* FEATURE_ES2 */ + +#if FEATURE_GL + /* Remaining enums are only in OpenGL */ + { 0, 0, TYPE_API_MASK, API_OPENGL_BIT }, + { GL_ACCUM_RED_BITS, BUFFER_INT(Visual.accumRedBits) }, + { GL_ACCUM_GREEN_BITS, BUFFER_INT(Visual.accumGreenBits) }, + { GL_ACCUM_BLUE_BITS, BUFFER_INT(Visual.accumBlueBits) }, + { GL_ACCUM_ALPHA_BITS, BUFFER_INT(Visual.accumAlphaBits) }, + { GL_ACCUM_CLEAR_VALUE, CONTEXT_FIELD(Accum.ClearColor[0], TYPE_FLOATN_4) }, + { GL_ALPHA_BIAS, CONTEXT_FLOAT(Pixel.AlphaBias) }, + { GL_ALPHA_SCALE, CONTEXT_FLOAT(Pixel.AlphaScale) }, + { GL_ATTRIB_STACK_DEPTH, CONTEXT_INT(AttribStackDepth) }, + { GL_AUTO_NORMAL, CONTEXT_BOOL(Eval.AutoNormal) }, + { GL_AUX_BUFFERS, BUFFER_INT(Visual.numAuxBuffers) }, + { GL_BLUE_BIAS, CONTEXT_FLOAT(Pixel.BlueBias) }, + { GL_BLUE_SCALE, CONTEXT_FLOAT(Pixel.BlueScale) }, + { GL_CLIENT_ATTRIB_STACK_DEPTH, CONTEXT_INT(ClientAttribStackDepth) }, + { GL_COLOR_MATERIAL_FACE, CONTEXT_ENUM(Light.ColorMaterialFace) }, + { GL_COLOR_MATERIAL_PARAMETER, CONTEXT_ENUM(Light.ColorMaterialMode) }, + { GL_CURRENT_INDEX, + CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]), + extra_flush_current }, + { GL_CURRENT_RASTER_COLOR, + CONTEXT_FIELD(Current.RasterColor[0], TYPE_FLOATN_4) }, + { GL_CURRENT_RASTER_DISTANCE, CONTEXT_FLOAT(Current.RasterDistance) }, + { GL_CURRENT_RASTER_INDEX, CONST(1) }, + { GL_CURRENT_RASTER_POSITION, CONTEXT_FLOAT4(Current.RasterPos[0]) }, + { GL_CURRENT_RASTER_SECONDARY_COLOR, + CONTEXT_FIELD(Current.RasterSecondaryColor[0], TYPE_FLOATN_4) }, + { GL_CURRENT_RASTER_TEXTURE_COORDS, LOC_CUSTOM, TYPE_FLOAT_4, 0, + extra_valid_texture_unit }, + { GL_CURRENT_RASTER_POSITION_VALID, CONTEXT_BOOL(Current.RasterPosValid) }, + { GL_DEPTH_BIAS, CONTEXT_FLOAT(Pixel.DepthBias) }, + { GL_DEPTH_SCALE, CONTEXT_FLOAT(Pixel.DepthScale) }, + { GL_DOUBLEBUFFER, BUFFER_INT(Visual.doubleBufferMode) }, + { GL_DRAW_BUFFER, BUFFER_ENUM(ColorDrawBuffer[0]) }, + { GL_EDGE_FLAG, LOC_CUSTOM, TYPE_BOOLEAN, 0 }, + { GL_FEEDBACK_BUFFER_SIZE, CONTEXT_INT(Feedback.BufferSize) }, + { GL_FEEDBACK_BUFFER_TYPE, CONTEXT_ENUM(Feedback.Type) }, + { GL_FOG_INDEX, CONTEXT_FLOAT(Fog.Index) }, + { GL_GREEN_BIAS, CONTEXT_FLOAT(Pixel.GreenBias) }, + { GL_GREEN_SCALE, CONTEXT_FLOAT(Pixel.GreenScale) }, + { GL_INDEX_BITS, BUFFER_INT(Visual.indexBits), extra_new_buffers }, + { GL_INDEX_CLEAR_VALUE, CONTEXT_INT(Color.ClearIndex) }, + { GL_INDEX_MODE, CONST(0) }, + { GL_INDEX_OFFSET, CONTEXT_INT(Pixel.IndexOffset) }, + { GL_INDEX_SHIFT, CONTEXT_INT(Pixel.IndexShift) }, + { GL_INDEX_WRITEMASK, CONTEXT_INT(Color.IndexMask) }, + { GL_LIGHT_MODEL_COLOR_CONTROL, CONTEXT_ENUM(Light.Model.ColorControl) }, + { GL_LIGHT_MODEL_LOCAL_VIEWER, CONTEXT_BOOL(Light.Model.LocalViewer) }, + { GL_LINE_STIPPLE, CONTEXT_BOOL(Line.StippleFlag) }, + { GL_LINE_STIPPLE_PATTERN, LOC_CUSTOM, TYPE_INT, 0 }, + { GL_LINE_STIPPLE_REPEAT, CONTEXT_INT(Line.StippleFactor) }, + { GL_LINE_WIDTH_GRANULARITY, CONTEXT_FLOAT(Const.LineWidthGranularity) }, + { GL_LIST_BASE, CONTEXT_INT(List.ListBase) }, + { GL_LIST_INDEX, LOC_CUSTOM, TYPE_INT, 0 }, + { GL_LIST_MODE, LOC_CUSTOM, TYPE_ENUM, 0 }, + { GL_INDEX_LOGIC_OP, CONTEXT_BOOL(Color.IndexLogicOpEnabled) }, + { GL_MAP1_COLOR_4, CONTEXT_BOOL(Eval.Map1Color4) }, + { GL_MAP1_GRID_DOMAIN, CONTEXT_FLOAT2(Eval.MapGrid1u1) }, + { GL_MAP1_GRID_SEGMENTS, CONTEXT_INT(Eval.MapGrid1un) }, + { GL_MAP1_INDEX, CONTEXT_BOOL(Eval.Map1Index) }, + { GL_MAP1_NORMAL, CONTEXT_BOOL(Eval.Map1Normal) }, + { GL_MAP1_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map1TextureCoord1) }, + { GL_MAP1_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map1TextureCoord2) }, + { GL_MAP1_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map1TextureCoord3) }, + { GL_MAP1_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map1TextureCoord4) }, + { GL_MAP1_VERTEX_3, CONTEXT_BOOL(Eval.Map1Vertex3) }, + { GL_MAP1_VERTEX_4, CONTEXT_BOOL(Eval.Map1Vertex4) }, + { GL_MAP2_COLOR_4, CONTEXT_BOOL(Eval.Map2Color4) }, + { GL_MAP2_GRID_DOMAIN, LOC_CUSTOM, TYPE_FLOAT_4, 0 }, + { GL_MAP2_GRID_SEGMENTS, CONTEXT_INT2(Eval.MapGrid2un) }, + { GL_MAP2_INDEX, CONTEXT_BOOL(Eval.Map2Index) }, + { GL_MAP2_NORMAL, CONTEXT_BOOL(Eval.Map2Normal) }, + { GL_MAP2_TEXTURE_COORD_1, CONTEXT_BOOL(Eval.Map2TextureCoord1) }, + { GL_MAP2_TEXTURE_COORD_2, CONTEXT_BOOL(Eval.Map2TextureCoord2) }, + { GL_MAP2_TEXTURE_COORD_3, CONTEXT_BOOL(Eval.Map2TextureCoord3) }, + { GL_MAP2_TEXTURE_COORD_4, CONTEXT_BOOL(Eval.Map2TextureCoord4) }, + { GL_MAP2_VERTEX_3, CONTEXT_BOOL(Eval.Map2Vertex3) }, + { GL_MAP2_VERTEX_4, CONTEXT_BOOL(Eval.Map2Vertex4) }, + { GL_MAP_COLOR, CONTEXT_BOOL(Pixel.MapColorFlag) }, + { GL_MAP_STENCIL, CONTEXT_BOOL(Pixel.MapStencilFlag) }, + { GL_MAX_ATTRIB_STACK_DEPTH, CONST(MAX_ATTRIB_STACK_DEPTH) }, + { GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, CONST(MAX_CLIENT_ATTRIB_STACK_DEPTH) }, + + { GL_MAX_EVAL_ORDER, CONST(MAX_EVAL_ORDER) }, + { GL_MAX_LIST_NESTING, CONST(MAX_LIST_NESTING) }, + { GL_MAX_NAME_STACK_DEPTH, CONST(MAX_NAME_STACK_DEPTH) }, + { GL_MAX_PIXEL_MAP_TABLE, CONST(MAX_PIXEL_MAP_TABLE) }, + { GL_NAME_STACK_DEPTH, CONTEXT_INT(Select.NameStackDepth) }, + { GL_PACK_LSB_FIRST, CONTEXT_BOOL(Pack.LsbFirst) }, + { GL_PACK_ROW_LENGTH, CONTEXT_INT(Pack.RowLength) }, + { GL_PACK_SKIP_PIXELS, CONTEXT_INT(Pack.SkipPixels) }, + { GL_PACK_SKIP_ROWS, CONTEXT_INT(Pack.SkipRows) }, + { GL_PACK_SWAP_BYTES, CONTEXT_BOOL(Pack.SwapBytes) }, + { GL_PACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Pack.ImageHeight) }, + { GL_PACK_INVERT_MESA, CONTEXT_BOOL(Pack.Invert) }, + { GL_PIXEL_MAP_A_TO_A_SIZE, CONTEXT_INT(PixelMaps.AtoA.Size) }, + { GL_PIXEL_MAP_B_TO_B_SIZE, CONTEXT_INT(PixelMaps.BtoB.Size) }, + { GL_PIXEL_MAP_G_TO_G_SIZE, CONTEXT_INT(PixelMaps.GtoG.Size) }, + { GL_PIXEL_MAP_I_TO_A_SIZE, CONTEXT_INT(PixelMaps.ItoA.Size) }, + { GL_PIXEL_MAP_I_TO_B_SIZE, CONTEXT_INT(PixelMaps.ItoB.Size) }, + { GL_PIXEL_MAP_I_TO_G_SIZE, CONTEXT_INT(PixelMaps.ItoG.Size) }, + { GL_PIXEL_MAP_I_TO_I_SIZE, CONTEXT_INT(PixelMaps.ItoI.Size) }, + { GL_PIXEL_MAP_I_TO_R_SIZE, CONTEXT_INT(PixelMaps.ItoR.Size) }, + { GL_PIXEL_MAP_R_TO_R_SIZE, CONTEXT_INT(PixelMaps.RtoR.Size) }, + { GL_PIXEL_MAP_S_TO_S_SIZE, CONTEXT_INT(PixelMaps.StoS.Size) }, + { GL_POINT_SIZE_GRANULARITY, CONTEXT_FLOAT(Const.PointSizeGranularity) }, + { GL_POLYGON_MODE, CONTEXT_ENUM2(Polygon.FrontMode) }, + { GL_POLYGON_OFFSET_BIAS_EXT, CONTEXT_FLOAT(Polygon.OffsetUnits) }, + { GL_POLYGON_OFFSET_POINT, CONTEXT_BOOL(Polygon.OffsetPoint) }, + { GL_POLYGON_OFFSET_LINE, CONTEXT_BOOL(Polygon.OffsetLine) }, + { GL_POLYGON_SMOOTH, CONTEXT_BOOL(Polygon.SmoothFlag) }, + { GL_POLYGON_SMOOTH_HINT, CONTEXT_ENUM(Hint.PolygonSmooth) }, + { GL_POLYGON_STIPPLE, CONTEXT_BOOL(Polygon.StippleFlag) }, + { GL_READ_BUFFER, LOC_CUSTOM, TYPE_ENUM }, + { GL_RED_BIAS, CONTEXT_FLOAT(Pixel.RedBias) }, + { GL_RED_SCALE, CONTEXT_FLOAT(Pixel.RedScale) }, + { GL_RENDER_MODE, CONTEXT_ENUM(RenderMode) }, + { GL_RGBA_MODE, CONST(1) }, + { GL_SELECTION_BUFFER_SIZE, CONTEXT_INT(Select.BufferSize) }, + { GL_SHARED_TEXTURE_PALETTE_EXT, CONTEXT_BOOL(Texture.SharedPalette) }, + + { GL_STEREO, BUFFER_INT(Visual.stereoMode) }, + + { GL_TEXTURE_1D, LOC_CUSTOM, TYPE_BOOLEAN, 0 }, + { GL_TEXTURE_3D, LOC_CUSTOM, TYPE_BOOLEAN, 0 }, + { GL_TEXTURE_1D_ARRAY_EXT, LOC_CUSTOM, TYPE_BOOLEAN, 0 }, + { GL_TEXTURE_2D_ARRAY_EXT, LOC_CUSTOM, TYPE_BOOLEAN, 0 }, + + { GL_TEXTURE_BINDING_1D, LOC_CUSTOM, TYPE_INT, TEXTURE_1D_INDEX }, + { GL_TEXTURE_BINDING_1D_ARRAY, LOC_CUSTOM, TYPE_INT, + TEXTURE_1D_ARRAY_INDEX, extra_MESA_texture_array }, + { GL_TEXTURE_BINDING_2D_ARRAY, LOC_CUSTOM, TYPE_INT, + TEXTURE_1D_ARRAY_INDEX, extra_MESA_texture_array }, + { GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, + CONTEXT_INT(Const.MaxArrayTextureLayers), extra_MESA_texture_array }, + + { GL_TEXTURE_GEN_S, LOC_TEXUNIT, TYPE_BIT_0, + offsetof(struct gl_texture_unit, TexGenEnabled) }, + { GL_TEXTURE_GEN_T, LOC_TEXUNIT, TYPE_BIT_1, + offsetof(struct gl_texture_unit, TexGenEnabled) }, + { GL_TEXTURE_GEN_R, LOC_TEXUNIT, TYPE_BIT_2, + offsetof(struct gl_texture_unit, TexGenEnabled) }, + { GL_TEXTURE_GEN_Q, LOC_TEXUNIT, TYPE_BIT_3, + offsetof(struct gl_texture_unit, TexGenEnabled) }, + { GL_UNPACK_LSB_FIRST, CONTEXT_BOOL(Unpack.LsbFirst) }, + { GL_UNPACK_ROW_LENGTH, CONTEXT_INT(Unpack.RowLength) }, + { GL_UNPACK_SKIP_PIXELS, CONTEXT_INT(Unpack.SkipPixels) }, + { GL_UNPACK_SKIP_ROWS, CONTEXT_INT(Unpack.SkipRows) }, + { GL_UNPACK_SWAP_BYTES, CONTEXT_BOOL(Unpack.SwapBytes) }, + { GL_UNPACK_SKIP_IMAGES_EXT, CONTEXT_INT(Unpack.SkipImages) }, + { GL_UNPACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Unpack.ImageHeight) }, + { GL_UNPACK_CLIENT_STORAGE_APPLE, CONTEXT_BOOL(Unpack.ClientStorage) }, + { GL_ZOOM_X, CONTEXT_FLOAT(Pixel.ZoomX) }, + { GL_ZOOM_Y, CONTEXT_FLOAT(Pixel.ZoomY) }, + + /* Vertex arrays */ + { GL_VERTEX_ARRAY_COUNT_EXT, CONST(0) }, + { GL_NORMAL_ARRAY_COUNT_EXT, CONST(0) }, + { GL_COLOR_ARRAY_COUNT_EXT, CONST(0) }, + { GL_INDEX_ARRAY, ARRAY_BOOL(Index.Enabled) }, + { GL_INDEX_ARRAY_TYPE, ARRAY_ENUM(Index.Type) }, + { GL_INDEX_ARRAY_STRIDE, ARRAY_INT(Index.Stride) }, + { GL_INDEX_ARRAY_COUNT_EXT, CONST(0) }, + { GL_TEXTURE_COORD_ARRAY_COUNT_EXT, CONST(0) }, + { GL_EDGE_FLAG_ARRAY, ARRAY_BOOL(EdgeFlag.Enabled) }, + { GL_EDGE_FLAG_ARRAY_STRIDE, ARRAY_INT(EdgeFlag.Stride) }, + { GL_EDGE_FLAG_ARRAY_COUNT_EXT, CONST(0) }, + + /* GL_ARB_texture_compression */ + { GL_TEXTURE_COMPRESSION_HINT_ARB, CONTEXT_INT(Hint.TextureCompression) }, + + /* GL_EXT_compiled_vertex_array */ + { GL_ARRAY_ELEMENT_LOCK_FIRST_EXT, CONTEXT_INT(Array.LockFirst), + extra_EXT_compiled_vertex_array }, + { GL_ARRAY_ELEMENT_LOCK_COUNT_EXT, CONTEXT_INT(Array.LockCount), + extra_EXT_compiled_vertex_array }, + + /* GL_ARB_transpose_matrix */ + { GL_TRANSPOSE_COLOR_MATRIX_ARB, CONTEXT_MATRIX_T(ColorMatrixStack.Top) }, + { GL_TRANSPOSE_MODELVIEW_MATRIX_ARB, + CONTEXT_MATRIX_T(ModelviewMatrixStack) }, + { GL_TRANSPOSE_PROJECTION_MATRIX_ARB, + CONTEXT_MATRIX_T(ProjectionMatrixStack.Top) }, + { GL_TRANSPOSE_TEXTURE_MATRIX_ARB, CONTEXT_MATRIX_T(TextureMatrixStack) }, + + /* GL_SGI_color_matrix (also in 1.2 imaging) */ + { GL_COLOR_MATRIX_SGI, CONTEXT_MATRIX(ColorMatrixStack.Top) }, + { GL_COLOR_MATRIX_STACK_DEPTH_SGI, LOC_CUSTOM, TYPE_INT, + offsetof(GLcontext, ColorMatrixStack.Depth) }, + { GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI, + CONST(MAX_COLOR_STACK_DEPTH) }, + { GL_POST_COLOR_MATRIX_RED_SCALE_SGI, + CONTEXT_FLOAT(Pixel.PostColorMatrixScale[0]) }, + { GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI, + CONTEXT_FLOAT(Pixel.PostColorMatrixScale[1]) }, + { GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI, + CONTEXT_FLOAT(Pixel.PostColorMatrixScale[2]) }, + { GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI, + CONTEXT_FLOAT(Pixel.PostColorMatrixScale[3]) }, + { GL_POST_COLOR_MATRIX_RED_BIAS_SGI, + CONTEXT_FLOAT(Pixel.PostColorMatrixBias[0]) }, + { GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI, + CONTEXT_FLOAT(Pixel.PostColorMatrixBias[1]) }, + { GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI, + CONTEXT_FLOAT(Pixel.PostColorMatrixBias[2]) }, + { GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI, + CONTEXT_FLOAT(Pixel.PostColorMatrixBias[3]) }, + + /* GL_EXT_convolution (also in 1.2 imaging) */ + { GL_CONVOLUTION_1D_EXT, CONTEXT_BOOL(Pixel.Convolution1DEnabled), + extra_EXT_convolution }, + { GL_CONVOLUTION_2D_EXT, CONTEXT_BOOL(Pixel.Convolution2DEnabled), + extra_EXT_convolution }, + { GL_SEPARABLE_2D_EXT, CONTEXT_BOOL(Pixel.Separable2DEnabled), + extra_EXT_convolution }, + { GL_POST_CONVOLUTION_RED_SCALE_EXT, + CONTEXT_FLOAT(Pixel.PostConvolutionScale[0]), + extra_EXT_convolution }, + { GL_POST_CONVOLUTION_GREEN_SCALE_EXT, + CONTEXT_FLOAT(Pixel.PostConvolutionScale[1]), + extra_EXT_convolution }, + { GL_POST_CONVOLUTION_BLUE_SCALE_EXT, + CONTEXT_FLOAT(Pixel.PostConvolutionScale[2]), + extra_EXT_convolution }, + { GL_POST_CONVOLUTION_ALPHA_SCALE_EXT, + CONTEXT_FLOAT(Pixel.PostConvolutionScale[3]), + extra_EXT_convolution }, + { GL_POST_CONVOLUTION_RED_BIAS_EXT, + CONTEXT_FLOAT(Pixel.PostConvolutionBias[0]), + extra_EXT_convolution }, + { GL_POST_CONVOLUTION_GREEN_BIAS_EXT, + CONTEXT_FLOAT(Pixel.PostConvolutionBias[1]), + extra_EXT_convolution }, + { GL_POST_CONVOLUTION_BLUE_BIAS_EXT, + CONTEXT_FLOAT(Pixel.PostConvolutionBias[2]), + extra_EXT_convolution }, + { GL_POST_CONVOLUTION_ALPHA_BIAS_EXT, + CONTEXT_FLOAT(Pixel.PostConvolutionBias[3]), + extra_EXT_convolution }, + + /* GL_EXT_histogram / GL_ARB_imaging */ + { GL_HISTOGRAM, CONTEXT_BOOL(Pixel.HistogramEnabled), + extra_EXT_histogram }, + { GL_MINMAX, CONTEXT_BOOL(Pixel.MinMaxEnabled), extra_EXT_histogram }, + + /* GL_SGI_color_table / GL_ARB_imaging */ + { GL_COLOR_TABLE_SGI, + CONTEXT_BOOL(Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]), + extra_SGI_color_table }, + { GL_POST_CONVOLUTION_COLOR_TABLE_SGI, + CONTEXT_BOOL(Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]), + extra_SGI_color_table }, + { GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI, + CONTEXT_BOOL(Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]), + extra_SGI_color_table }, + + /* GL_SGI_texture_color_table */ + { GL_TEXTURE_COLOR_TABLE_SGI, LOC_TEXUNIT, TYPE_BOOLEAN, + offsetof(struct gl_texture_unit, ColorTableEnabled), + extra_SGI_texture_color_table }, + + /* GL_EXT_secondary_color */ + { GL_COLOR_SUM_EXT, CONTEXT_BOOL(Fog.ColorSumEnabled), + extra_EXT_secondary_color_ARB_vertex_program }, + { GL_CURRENT_SECONDARY_COLOR_EXT, + CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR1][0], TYPE_FLOATN_4), + extra_EXT_secondary_color_flush_current }, + { GL_SECONDARY_COLOR_ARRAY_EXT, ARRAY_BOOL(SecondaryColor.Enabled), + extra_EXT_secondary_color }, + { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT, ARRAY_ENUM(SecondaryColor.Type), + extra_EXT_secondary_color }, + { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT, ARRAY_INT(SecondaryColor.Stride), + extra_EXT_secondary_color }, + { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT, ARRAY_INT(SecondaryColor.Size), + extra_EXT_secondary_color }, + + /* GL_EXT_fog_coord */ + { GL_CURRENT_FOG_COORDINATE_EXT, + CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_FOG][0]), + extra_EXT_fog_coord_flush_current }, + { GL_FOG_COORDINATE_ARRAY_EXT, ARRAY_BOOL(FogCoord.Enabled), + extra_EXT_fog_coord }, + { GL_FOG_COORDINATE_ARRAY_TYPE_EXT, ARRAY_ENUM(FogCoord.Type), + extra_EXT_fog_coord }, + { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT, ARRAY_INT(FogCoord.Stride), + extra_EXT_fog_coord }, + { GL_FOG_COORDINATE_SOURCE_EXT, CONTEXT_ENUM(Fog.FogCoordinateSource), + extra_EXT_fog_coord }, + + /* GL_IBM_rasterpos_clip */ + { GL_RASTER_POSITION_UNCLIPPED_IBM, + CONTEXT_BOOL(Transform.RasterPositionUnclipped), + extra_IBM_rasterpos_clip }, + + /* GL_NV_point_sprite */ + { GL_POINT_SPRITE_R_MODE_NV, + CONTEXT_ENUM(Point.SpriteRMode), extra_NV_point_sprite }, + { GL_POINT_SPRITE_COORD_ORIGIN, CONTEXT_ENUM(Point.SpriteOrigin), + extra_NV_point_sprite_ARB_point_sprite }, + + /* GL_NV_vertex_program */ + { GL_VERTEX_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0, + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY0_NV, ARRAY_BOOL(VertexAttrib[0].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY1_NV, ARRAY_BOOL(VertexAttrib[1].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY2_NV, ARRAY_BOOL(VertexAttrib[2].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY3_NV, ARRAY_BOOL(VertexAttrib[3].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY4_NV, ARRAY_BOOL(VertexAttrib[4].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY5_NV, ARRAY_BOOL(VertexAttrib[5].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY6_NV, ARRAY_BOOL(VertexAttrib[6].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY7_NV, ARRAY_BOOL(VertexAttrib[7].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY8_NV, ARRAY_BOOL(VertexAttrib[8].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY9_NV, ARRAY_BOOL(VertexAttrib[9].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY10_NV, ARRAY_BOOL(VertexAttrib[10].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY11_NV, ARRAY_BOOL(VertexAttrib[11].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY12_NV, ARRAY_BOOL(VertexAttrib[12].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY13_NV, ARRAY_BOOL(VertexAttrib[13].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY14_NV, ARRAY_BOOL(VertexAttrib[14].Enabled), + extra_NV_vertex_program }, + { GL_VERTEX_ATTRIB_ARRAY15_NV, ARRAY_BOOL(VertexAttrib[15].Enabled), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB0_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[0]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB1_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[1]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB2_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[2]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB3_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[3]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB4_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[4]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB5_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[5]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB6_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[6]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB7_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[7]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB8_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[8]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB9_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[9]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB10_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[10]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB11_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[11]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB12_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[12]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB13_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[13]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB14_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[14]), + extra_NV_vertex_program }, + { GL_MAP1_VERTEX_ATTRIB15_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[15]), + extra_NV_vertex_program }, + + /* GL_NV_fragment_program */ + { GL_FRAGMENT_PROGRAM_NV, CONTEXT_BOOL(FragmentProgram.Enabled), + extra_NV_fragment_program }, + { GL_FRAGMENT_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0, + extra_NV_fragment_program }, + { GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV, + CONST(MAX_NV_FRAGMENT_PROGRAM_PARAMS), + extra_NV_fragment_program }, + + /* GL_NV_texture_rectangle */ + { GL_TEXTURE_RECTANGLE_NV, + LOC_CUSTOM, TYPE_BOOLEAN, 0, extra_NV_texture_rectangle }, + { GL_TEXTURE_BINDING_RECTANGLE_NV, + LOC_CUSTOM, TYPE_INT, TEXTURE_RECT_INDEX, extra_NV_texture_rectangle }, + { GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, + CONTEXT_INT(Const.MaxTextureRectSize), extra_NV_texture_rectangle }, + + /* GL_EXT_stencil_two_side */ + { GL_STENCIL_TEST_TWO_SIDE_EXT, CONTEXT_BOOL(Stencil.TestTwoSide), + extra_EXT_stencil_two_side }, + { GL_ACTIVE_STENCIL_FACE_EXT, LOC_CUSTOM, TYPE_ENUM, 0 }, + + /* GL_NV_light_max_exponent */ + { GL_MAX_SHININESS_NV, CONTEXT_FLOAT(Const.MaxShininess), + extra_NV_light_max_exponent }, + { GL_MAX_SPOT_EXPONENT_NV, CONTEXT_FLOAT(Const.MaxSpotExponent), + extra_NV_light_max_exponent }, + + /* GL_ARB_vertex_buffer_object */ + { GL_INDEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_array_object, Index.BufferObj) }, + { GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_array_object, EdgeFlag.BufferObj) }, + { GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_array_object, SecondaryColor.BufferObj) }, + { GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT, + offsetof(struct gl_array_object, FogCoord.BufferObj) }, + + /* GL_EXT_pixel_buffer_object */ + { GL_PIXEL_PACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, + extra_EXT_pixel_buffer_object }, + { GL_PIXEL_UNPACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, + extra_EXT_pixel_buffer_object }, + + /* GL_ARB_vertex_program */ + { GL_VERTEX_PROGRAM_ARB, /* == GL_VERTEX_PROGRAM_NV */ + CONTEXT_BOOL(VertexProgram.Enabled), + extra_ARB_vertex_program_NV_vertex_program }, + { GL_VERTEX_PROGRAM_POINT_SIZE_ARB, /* == GL_VERTEX_PROGRAM_POINT_SIZE_NV*/ + CONTEXT_BOOL(VertexProgram.PointSizeEnabled), + extra_ARB_vertex_program_NV_vertex_program }, + { GL_VERTEX_PROGRAM_TWO_SIDE_ARB, /* == GL_VERTEX_PROGRAM_TWO_SIDE_NV */ + CONTEXT_BOOL(VertexProgram.TwoSideEnabled), + extra_ARB_vertex_program_NV_vertex_program }, + { GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB, /* == GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */ + CONTEXT_INT(Const.MaxProgramMatrixStackDepth), + extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, + { GL_MAX_PROGRAM_MATRICES_ARB, /* == GL_MAX_TRACK_MATRICES_NV */ + CONTEXT_INT(Const.MaxProgramMatrices), + extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, + { GL_CURRENT_MATRIX_STACK_DEPTH_ARB, /* == GL_CURRENT_MATRIX_STACK_DEPTH_NV */ + LOC_CUSTOM, TYPE_INT, 0, + extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, + + { GL_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */ + LOC_CUSTOM, TYPE_MATRIX, 0, + extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, + { GL_TRANSPOSE_CURRENT_MATRIX_ARB, /* == GL_CURRENT_MATRIX_NV */ + LOC_CUSTOM, TYPE_MATRIX, 0, + extra_ARB_vertex_program_ARB_fragment_program }, + + { GL_PROGRAM_ERROR_POSITION_ARB, /* == GL_PROGRAM_ERROR_POSITION_NV */ + CONTEXT_INT(Program.ErrorPos), + extra_NV_vertex_program_ARB_vertex_program_ARB_fragment_program_NV_vertex_program }, + + /* GL_ARB_fragment_program */ + { GL_FRAGMENT_PROGRAM_ARB, CONTEXT_BOOL(FragmentProgram.Enabled), + extra_ARB_fragment_program }, + + /* GL_EXT_depth_bounds_test */ + { GL_DEPTH_BOUNDS_TEST_EXT, CONTEXT_BOOL(Depth.BoundsTest), + extra_EXT_depth_bounds_test }, + { GL_DEPTH_BOUNDS_EXT, CONTEXT_FLOAT2(Depth.BoundsMin), + extra_EXT_depth_bounds_test }, + + /* GL_ARB_depth_clamp*/ + { GL_DEPTH_CLAMP, CONTEXT_BOOL(Transform.DepthClamp), + extra_ARB_depth_clamp }, + + /* GL_ARB_draw_buffers */ + { GL_DRAW_BUFFER0_ARB, BUFFER_ENUM(ColorDrawBuffer[0]) }, + { GL_DRAW_BUFFER1_ARB, BUFFER_ENUM(ColorDrawBuffer[1]), + extra_valid_draw_buffer }, + { GL_DRAW_BUFFER2_ARB, BUFFER_ENUM(ColorDrawBuffer[2]), + extra_valid_draw_buffer }, + { GL_DRAW_BUFFER3_ARB, BUFFER_ENUM(ColorDrawBuffer[3]), + extra_valid_draw_buffer }, + + /* GL_ATI_fragment_shader */ + { GL_NUM_FRAGMENT_REGISTERS_ATI, CONST(6), extra_ATI_fragment_shader }, + { GL_NUM_FRAGMENT_CONSTANTS_ATI, CONST(8), extra_ATI_fragment_shader }, + { GL_NUM_PASSES_ATI, CONST(2), extra_ATI_fragment_shader }, + { GL_NUM_INSTRUCTIONS_PER_PASS_ATI, CONST(8), extra_ATI_fragment_shader }, + { GL_NUM_INSTRUCTIONS_TOTAL_ATI, CONST(16), extra_ATI_fragment_shader }, + { GL_COLOR_ALPHA_PAIRING_ATI, CONST(GL_TRUE), extra_ATI_fragment_shader }, + { GL_NUM_LOOPBACK_COMPONENTS_ATI, CONST(3), extra_ATI_fragment_shader }, + { GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI, + CONST(3), extra_ATI_fragment_shader }, + + /* GL_EXT_framebuffer_object */ + { GL_MAX_COLOR_ATTACHMENTS_EXT, CONTEXT_INT(Const.MaxColorAttachments), + extra_EXT_framebuffer_object }, + + /* GL_EXT_framebuffer_blit + * NOTE: GL_DRAW_FRAMEBUFFER_BINDING_EXT == GL_FRAMEBUFFER_BINDING_EXT */ + { GL_READ_FRAMEBUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0, + extra_EXT_framebuffer_blit }, + + /* GL_EXT_provoking_vertex */ + { GL_PROVOKING_VERTEX_EXT, + CONTEXT_BOOL(Light.ProvokingVertex), extra_EXT_provoking_vertex }, + { GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT, + CONTEXT_BOOL(Const.QuadsFollowProvokingVertexConvention), + extra_EXT_provoking_vertex }, + + /* GL_ARB_framebuffer_object */ + { GL_MAX_SAMPLES, CONTEXT_INT(Const.MaxSamples), + extra_ARB_framebuffer_object }, + + /* GL_APPLE_vertex_array_object */ + { GL_VERTEX_ARRAY_BINDING_APPLE, ARRAY_INT(Name), + extra_APPLE_vertex_array_object }, + + /* GL_ARB_seamless_cube_map */ + { GL_TEXTURE_CUBE_MAP_SEAMLESS, + CONTEXT_BOOL(Texture.CubeMapSeamless), extra_ARB_seamless_cube_map }, + + /* GL_ARB_sync */ + { GL_MAX_SERVER_WAIT_TIMEOUT, + CONTEXT_INT64(Const.MaxServerWaitTimeout), extra_ARB_sync }, + + /* GL_EXT_transform_feedback */ + { GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, LOC_CUSTOM, TYPE_INT, 0, + extra_EXT_transform_feedback }, + { GL_RASTERIZER_DISCARD, CONTEXT_BOOL(TransformFeedback.RasterDiscard), + extra_EXT_transform_feedback }, + { GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, + CONTEXT_INT(Const.MaxTransformFeedbackInterleavedComponents), + extra_EXT_transform_feedback }, + { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, + CONTEXT_INT(Const.MaxTransformFeedbackSeparateAttribs), + extra_EXT_transform_feedback }, + { GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, + CONTEXT_INT(Const.MaxTransformFeedbackSeparateComponents), + extra_EXT_transform_feedback }, + + /* GL_ARB_transform_feedback2 */ + { GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED, LOC_CUSTOM, TYPE_BOOLEAN, 0, + extra_ARB_transform_feedback2 }, + { GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE, LOC_CUSTOM, TYPE_BOOLEAN, 0, + extra_ARB_transform_feedback2 }, + { GL_TRANSFORM_FEEDBACK_BINDING, LOC_CUSTOM, TYPE_INT, 0, + extra_ARB_transform_feedback2 }, + + /* GL 3.0 */ + { GL_NUM_EXTENSIONS, LOC_CUSTOM, TYPE_INT, 0, extra_version_30 }, + { GL_MAJOR_VERSION, CONTEXT_INT(VersionMajor), extra_version_30 }, + { GL_MINOR_VERSION, CONTEXT_INT(VersionMinor), extra_version_30 }, + { GL_CONTEXT_FLAGS, CONTEXT_INT(Const.ContextFlags), extra_version_30 }, + + /* GL 3.1 */ + { GL_PRIMITIVE_RESTART, CONTEXT_BOOL(Array.PrimitiveRestart), + extra_version_31 }, + { GL_PRIMITIVE_RESTART_INDEX, CONTEXT_INT(Array.RestartIndex), + extra_version_31 }, + + /* GL 3.2 */ + { GL_CONTEXT_PROFILE_MASK, CONTEXT_INT(Const.ProfileMask), + extra_version_32 }, +#endif /* FEATURE_GL */ +}; + +/* All we need now is a way to look up the value struct from the enum. + * The code generated by gcc for the old generated big switch + * statement is a big, balanced, open coded if/else tree, essentially + * an unrolled binary search. It would be natural to sort the new + * enum table and use bsearch(), but we will use a read-only hash + * table instead. bsearch() has a nice guaranteed worst case + * performance, but we're also guaranteed to hit that worst case + * (log2(n) iterations) for about half the enums. Instead, using an + * open addressing hash table, we can find the enum on the first try + * for 80% of the enums, 1 collision for 10% and never more than 5 + * collisions for any enum (typical numbers). And the code is very + * simple, even though it feels a little magic. */ + +static unsigned short table[1024]; +static const int prime_factor = 89, prime_step = 281; + +#ifdef GET_DEBUG +static void +print_table_stats(void) +{ + int i, j, collisions[11], count, hash, mask; + const struct value_desc *d; + + count = 0; + mask = Elements(table) - 1; + memset(collisions, 0, sizeof collisions); + + for (i = 0; i < Elements(table); i++) { + if (!table[i]) + continue; + count++; + d = &values[table[i]]; + hash = (d->pname * prime_factor); + j = 0; + while (1) { + if (values[table[hash & mask]].pname == d->pname) + break; + hash += prime_step; + j++; + } + + if (j < 10) + collisions[j]++; + else + collisions[10]++; } -/* - * Check if either of four extensions is enabled. + printf("number of enums: %d (total %d)\n", count, Elements(values)); + for (i = 0; i < Elements(collisions) - 1; i++) + if (collisions[i] > 0) + printf(" %d enums with %d %scollisions\n", + collisions[i], i, i == 10 ? "or more " : ""); +} +#endif + +/** + * Initialize the enum hash for a given API + * + * This is called from one_time_init() to insert the enum values that + * are valid for the API in question into the enum hash table. + * + * \param the current context, for determining the API in question */ -#define CHECK_EXT4(EXT1, EXT2, EXT3, EXT4) \ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2 && \ - !ctx->Extensions.EXT3 && !ctx->Extensions.EXT4) { \ - goto invalid_enum_error; \ +void _mesa_init_get_hash(GLcontext *ctx) +{ + int i, hash, index, mask; + int api_mask = 0, api_bit; + + mask = Elements(table) - 1; + api_bit = 1 << ctx->API; + + for (i = 0; i < Elements(values); i++) { + if (values[i].type == TYPE_API_MASK) { + api_mask = values[i].offset; + continue; + } + if (!(api_mask & api_bit)) + continue; + + hash = (values[i].pname * prime_factor) & mask; + while (1) { + index = hash & mask; + if (!table[index]) { + table[index] = i; + break; + } + hash += prime_step; + } } -/* - * Check GL version. +#ifdef GET_DEBUG + print_table_stats(); +#endif +} + +/** + * Handle irregular enums + * + * Some values don't conform to the "well-known type at context + * pointer + offset" pattern, so we have this function to catch all + * the corner cases. Typically, it's a computed value or a one-off + * pointer to a custom struct or something. + * + * In this case we can't return a pointer to the value, so we'll have + * to use the temporary variable 'v' declared back in the calling + * glGet*v() function to store the result. + * + * \param ctx the current context + * \param d the struct value_desc that describes the enum + * \param v pointer to the tmp declared in the calling glGet*v() function + */ +static void +find_custom_value(GLcontext *ctx, const struct value_desc *d, union value *v) +{ + struct gl_buffer_object *buffer_obj; + struct gl_client_array *array; + GLuint unit, *p; + + switch (d->pname) { + case GL_TEXTURE_1D: + case GL_TEXTURE_2D: + case GL_TEXTURE_3D: + case GL_TEXTURE_1D_ARRAY_EXT: + case GL_TEXTURE_2D_ARRAY_EXT: + case GL_TEXTURE_CUBE_MAP_ARB: + case GL_TEXTURE_RECTANGLE_NV: + v->value_bool = _mesa_IsEnabled(d->pname); + break; + + case GL_LINE_STIPPLE_PATTERN: + /* This is the only GLushort, special case it here by promoting + * to an int rather than introducing a new type. */ + v->value_int = ctx->Line.StipplePattern; + break; + + case GL_CURRENT_RASTER_TEXTURE_COORDS: + unit = ctx->Texture.CurrentUnit; + v->value_float_4[0] = ctx->Current.RasterTexCoords[unit][0]; + v->value_float_4[1] = ctx->Current.RasterTexCoords[unit][1]; + v->value_float_4[2] = ctx->Current.RasterTexCoords[unit][2]; + v->value_float_4[3] = ctx->Current.RasterTexCoords[unit][3]; + break; + + case GL_CURRENT_TEXTURE_COORDS: + unit = ctx->Texture.CurrentUnit; + v->value_float_4[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]; + v->value_float_4[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]; + v->value_float_4[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2]; + v->value_float_4[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3]; + break; + + case GL_COLOR_WRITEMASK: + v->value_int_4[0] = ctx->Color.ColorMask[0][RCOMP] ? 1 : 0; + v->value_int_4[1] = ctx->Color.ColorMask[0][GCOMP] ? 1 : 0; + v->value_int_4[2] = ctx->Color.ColorMask[0][BCOMP] ? 1 : 0; + v->value_int_4[3] = ctx->Color.ColorMask[0][ACOMP] ? 1 : 0; + break; + + case GL_EDGE_FLAG: + v->value_bool = ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0; + break; + + case GL_READ_BUFFER: + v->value_enum = ctx->ReadBuffer->ColorReadBuffer; + break; + + case GL_MAP2_GRID_DOMAIN: + v->value_float_4[0] = ctx->Eval.MapGrid2u1; + v->value_float_4[1] = ctx->Eval.MapGrid2u2; + v->value_float_4[2] = ctx->Eval.MapGrid2v1; + v->value_float_4[3] = ctx->Eval.MapGrid2v2; + break; + + case GL_TEXTURE_STACK_DEPTH: + unit = ctx->Texture.CurrentUnit; + v->value_int = ctx->TextureMatrixStack[unit].Depth + 1; + break; + case GL_TEXTURE_MATRIX: + unit = ctx->Texture.CurrentUnit; + v->value_matrix = ctx->TextureMatrixStack[unit].Top; + break; + + case GL_TEXTURE_COORD_ARRAY: + case GL_TEXTURE_COORD_ARRAY_SIZE: + case GL_TEXTURE_COORD_ARRAY_TYPE: + case GL_TEXTURE_COORD_ARRAY_STRIDE: + array = &ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture]; + v->value_int = *(GLuint *) ((char *) array + d->offset); + break; + + case GL_ACTIVE_TEXTURE_ARB: + v->value_int = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit; + break; + case GL_CLIENT_ACTIVE_TEXTURE_ARB: + v->value_int = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture; + break; + + case GL_MODELVIEW_STACK_DEPTH: + case GL_PROJECTION_STACK_DEPTH: + case GL_COLOR_MATRIX_STACK_DEPTH_SGI: + v->value_int = *(GLint *) ((char *) ctx + d->offset) + 1; + break; + + case GL_MAX_TEXTURE_SIZE: + case GL_MAX_3D_TEXTURE_SIZE: + case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: + p = (GLuint *) ((char *) ctx + d->offset); + v->value_int = 1 << (*p - 1); + break; + + case GL_SCISSOR_BOX: + v->value_int_4[0] = ctx->Scissor.X; + v->value_int_4[1] = ctx->Scissor.Y; + v->value_int_4[2] = ctx->Scissor.Width; + v->value_int_4[3] = ctx->Scissor.Height; + break; + + case GL_LIST_INDEX: + v->value_int = + ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0; + break; + case GL_LIST_MODE: + if (!ctx->CompileFlag) + v->value_enum = 0; + else if (ctx->ExecuteFlag) + v->value_enum = GL_COMPILE_AND_EXECUTE; + else + v->value_enum = GL_COMPILE; + break; + + case GL_VIEWPORT: + v->value_int_4[0] = ctx->Viewport.X; + v->value_int_4[1] = ctx->Viewport.Y; + v->value_int_4[2] = ctx->Viewport.Width; + v->value_int_4[3] = ctx->Viewport.Height; + break; + + case GL_ACTIVE_STENCIL_FACE_EXT: + v->value_enum = ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT; + break; + + case GL_STENCIL_FAIL: + v->value_enum = ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]; + break; + case GL_STENCIL_FUNC: + v->value_enum = ctx->Stencil.Function[ctx->Stencil.ActiveFace]; + break; + case GL_STENCIL_PASS_DEPTH_FAIL: + v->value_enum = ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]; + break; + case GL_STENCIL_PASS_DEPTH_PASS: + v->value_enum = ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]; + break; + case GL_STENCIL_REF: + v->value_int = ctx->Stencil.Ref[ctx->Stencil.ActiveFace]; + break; + case GL_STENCIL_VALUE_MASK: + v->value_int = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]; + break; + case GL_STENCIL_WRITEMASK: + v->value_int = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]; + break; + + case GL_NUM_EXTENSIONS: + v->value_int = _mesa_get_extension_count(ctx); + break; + + case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: + v->value_int = _mesa_get_color_read_type(ctx); + break; + case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: + v->value_int = _mesa_get_color_read_format(ctx); + break; + + case GL_CURRENT_MATRIX_STACK_DEPTH_ARB: + v->value_int = ctx->CurrentStack->Depth + 1; + break; + case GL_CURRENT_MATRIX_ARB: + case GL_TRANSPOSE_CURRENT_MATRIX_ARB: + v->value_matrix = ctx->CurrentStack->Top; + break; + + case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: + v->value_int = _mesa_get_compressed_formats(ctx, NULL, GL_FALSE); + break; + case GL_COMPRESSED_TEXTURE_FORMATS_ARB: + v->value_int_n.n = + _mesa_get_compressed_formats(ctx, v->value_int_n.ints, GL_FALSE); + ASSERT(v->value_int_n.n <= 100); + break; + + case GL_MAX_VARYING_FLOATS_ARB: + v->value_int = ctx->Const.MaxVarying * 4; + break; + + /* Various object names */ + + case GL_TEXTURE_BINDING_1D: + case GL_TEXTURE_BINDING_2D: + case GL_TEXTURE_BINDING_3D: + case GL_TEXTURE_BINDING_1D_ARRAY_EXT: + case GL_TEXTURE_BINDING_2D_ARRAY_EXT: + case GL_TEXTURE_BINDING_CUBE_MAP_ARB: + case GL_TEXTURE_BINDING_RECTANGLE_NV: + unit = ctx->Texture.CurrentUnit; + v->value_int = + ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name; + break; + + /* GL_ARB_vertex_buffer_object */ + case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: + case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: + case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: + case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: + case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: + case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: + case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: + buffer_obj = (struct gl_buffer_object *) + ((char *) ctx->Array.ArrayObj + d->offset); + v->value_int = buffer_obj->Name; + break; + case GL_ARRAY_BUFFER_BINDING_ARB: + v->value_int = ctx->Array.ArrayBufferObj->Name; + break; + case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: + v->value_int = + ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name; + break; + case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: + v->value_int = ctx->Array.ElementArrayBufferObj->Name; + break; + + case GL_FRAGMENT_PROGRAM_BINDING_NV: + v->value_int = + ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0; + break; + case GL_VERTEX_PROGRAM_BINDING_NV: + v->value_int = + ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0; + break; + case GL_PIXEL_PACK_BUFFER_BINDING_EXT: + v->value_int = ctx->Pack.BufferObj->Name; + break; + case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT: + v->value_int = ctx->Unpack.BufferObj->Name; + break; + case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: + v->value_int = ctx->TransformFeedback.CurrentBuffer->Name; + break; + case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED: + v->value_int = ctx->TransformFeedback.CurrentObject->Paused; + break; + case GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE: + v->value_int = ctx->TransformFeedback.CurrentObject->Active; + break; + case GL_TRANSFORM_FEEDBACK_BINDING: + v->value_int = ctx->TransformFeedback.CurrentObject->Name; + break; + case GL_CURRENT_PROGRAM: + v->value_int = + ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0; + break; + case GL_READ_FRAMEBUFFER_BINDING_EXT: + v->value_int = ctx->ReadBuffer->Name; + break; + case GL_RENDERBUFFER_BINDING_EXT: + v->value_int = + ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0; + break; + case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: + v->value_int = ctx->Array.ArrayObj->PointSize.BufferObj->Name; + break; + } +} + +/** + * Check extra constraints on a struct value_desc descriptor + * + * If a struct value_desc has a non-NULL extra pointer, it means that + * there are a number of extra constraints to check or actions to + * perform. The extras is just an integer array where each integer + * encode different constraints or actions. + * + * \param ctx current context + * \param func name of calling glGet*v() function for error reporting + * \param d the struct value_desc that has the extra constraints + * + * \return GL_FALSE if one of the constraints was not satisfied, + * otherwise GL_TRUE. */ -#define CHECK_VERSION(VERSION) \ - if (version < VERSION) { \ - goto invalid_enum_error; \ +static GLboolean +check_extra(GLcontext *ctx, const char *func, const struct value_desc *d) +{ + const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; + int total, enabled; + const int *e; + + total = 0; + enabled = 0; + for (e = d->extra; *e != EXTRA_END; e++) + switch (*e) { + case EXTRA_VERSION_30: + if (version < 30) + return GL_FALSE; + break; + case EXTRA_VERSION_31: + if (version < 31) + return GL_FALSE; + break; + case EXTRA_VERSION_32: + if (version < 32) + return GL_FALSE; + break; + case EXTRA_NEW_BUFFERS: + if (ctx->NewState & _NEW_BUFFERS) + _mesa_update_state(ctx); + break; + case EXTRA_FLUSH_CURRENT: + FLUSH_CURRENT(ctx, 0); + break; + case EXTRA_VALID_DRAW_BUFFER: + if (d->pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(draw buffer %u)", + func, d->pname - GL_DRAW_BUFFER0_ARB); + return GL_FALSE; + } + break; + case EXTRA_VALID_TEXTURE_UNIT: + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture %u)", + func, ctx->Texture.CurrentUnit); + return GL_FALSE; + } + break; + case EXTRA_END: + break; + default: /* *e is a offset into the extension struct */ + total++; + if (*(GLboolean *) ((char *) &ctx->Extensions + *e)) + enabled++; + break; + } + + if (total > 0 && enabled == 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, + _mesa_lookup_enum_by_nr(d->pname)); + return GL_FALSE; } + return GL_TRUE; +} + +static const struct value_desc error_value = { 0, 0, TYPE_INVALID }; -void GLAPIENTRY -_mesa_GetBooleanv( GLenum pname, GLboolean *params ) +/** + * Find the struct value_desc corresponding to the enum 'pname'. + * + * We hash the enum value to get an index into the 'table' array, + * which holds the index in the 'values' array of struct value_desc. + * Once we've found the entry, we do the extra checks, if any, then + * look up the value and return a pointer to it. + * + * If the value has to be computed (for example, it's the result of a + * function call or we need to add 1 to it), we use the tmp 'v' to + * store the result. + * + * \param func name of glGet*v() func for error reporting + * \param pname the enum value we're looking up + * \param p is were we return the pointer to the value + * \param v a tmp union value variable in the calling glGet*v() function + * + * \return the struct value_desc corresponding to the enum or a struct + * value_desc of TYPE_INVALID if not found. This lets the calling + * glGet*v() function jump right into a switch statement and + * handle errors there instead of having to check for NULL. + */ +static const struct value_desc * +find_value(const char *func, GLenum pname, void **p, union value *v) { GET_CURRENT_CONTEXT(ctx); - const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; - ASSERT_OUTSIDE_BEGIN_END(ctx); - (void) version; + struct gl_texture_unit *unit; + int mask, hash; + const struct value_desc *d; - if (!params) - return; + mask = Elements(table) - 1; + hash = (pname * prime_factor); + while (1) { + d = &values[table[hash & mask]]; + if (likely(d->pname == pname)) + break; - if (ctx->Driver.GetBooleanv && - ctx->Driver.GetBooleanv(ctx, pname, params)) - return; + /* If the enum isn't valid, the hash walk ends with index 0, + * which is the API mask entry at the beginning of values[]. */ + if (d->type == TYPE_API_MASK) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, + _mesa_lookup_enum_by_nr(pname)); + return &error_value; + } + hash += prime_step; + } - switch (pname) { - case GL_ACCUM_RED_BITS: - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.accumRedBits); - break; - case GL_ACCUM_GREEN_BITS: - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.accumGreenBits); - break; - case GL_ACCUM_BLUE_BITS: - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.accumBlueBits); - break; - case GL_ACCUM_ALPHA_BITS: - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.accumAlphaBits); - break; - case GL_ACCUM_CLEAR_VALUE: - params[0] = FLOAT_TO_BOOLEAN(ctx->Accum.ClearColor[0]); - params[1] = FLOAT_TO_BOOLEAN(ctx->Accum.ClearColor[1]); - params[2] = FLOAT_TO_BOOLEAN(ctx->Accum.ClearColor[2]); - params[3] = FLOAT_TO_BOOLEAN(ctx->Accum.ClearColor[3]); - break; - case GL_ALPHA_BIAS: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.AlphaBias); - break; - case GL_ALPHA_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.alphaBits); - break; - case GL_ALPHA_SCALE: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.AlphaScale); - break; - case GL_ALPHA_TEST: - params[0] = ctx->Color.AlphaEnabled; - break; - case GL_ALPHA_TEST_FUNC: - params[0] = ENUM_TO_BOOLEAN(ctx->Color.AlphaFunc); - break; - case GL_ALPHA_TEST_REF: - params[0] = FLOAT_TO_BOOLEAN(ctx->Color.AlphaRef); - break; - case GL_ATTRIB_STACK_DEPTH: - params[0] = INT_TO_BOOLEAN(ctx->AttribStackDepth); - break; - case GL_AUTO_NORMAL: - params[0] = ctx->Eval.AutoNormal; - break; - case GL_AUX_BUFFERS: - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.numAuxBuffers); - break; - case GL_BLEND: - params[0] = (ctx->Color.BlendEnabled & 1); - break; - case GL_BLEND_DST: - params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendDstRGB); - break; - case GL_BLEND_SRC: - params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendSrcRGB); - break; - case GL_BLEND_SRC_RGB_EXT: - params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendSrcRGB); - break; - case GL_BLEND_DST_RGB_EXT: - params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendDstRGB); - break; - case GL_BLEND_SRC_ALPHA_EXT: - params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendSrcA); - break; - case GL_BLEND_DST_ALPHA_EXT: - params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendDstA); - break; - case GL_BLEND_EQUATION: - params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendEquationRGB ); - break; - case GL_BLEND_EQUATION_ALPHA_EXT: - params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendEquationA ); - break; - case GL_BLEND_COLOR_EXT: - params[0] = FLOAT_TO_BOOLEAN(ctx->Color.BlendColor[0]); - params[1] = FLOAT_TO_BOOLEAN(ctx->Color.BlendColor[1]); - params[2] = FLOAT_TO_BOOLEAN(ctx->Color.BlendColor[2]); - params[3] = FLOAT_TO_BOOLEAN(ctx->Color.BlendColor[3]); - break; - case GL_BLUE_BIAS: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.BlueBias); - break; - case GL_BLUE_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.blueBits); - break; - case GL_BLUE_SCALE: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.BlueScale); - break; - case GL_CLIENT_ATTRIB_STACK_DEPTH: - params[0] = INT_TO_BOOLEAN(ctx->ClientAttribStackDepth); - break; - case GL_CLIP_PLANE0: - params[0] = (ctx->Transform.ClipPlanesEnabled >> 0) & 1; - break; - case GL_CLIP_PLANE1: - params[0] = (ctx->Transform.ClipPlanesEnabled >> 1) & 1; - break; - case GL_CLIP_PLANE2: - params[0] = (ctx->Transform.ClipPlanesEnabled >> 2) & 1; - break; - case GL_CLIP_PLANE3: - params[0] = (ctx->Transform.ClipPlanesEnabled >> 3) & 1; - break; - case GL_CLIP_PLANE4: - params[0] = (ctx->Transform.ClipPlanesEnabled >> 4) & 1; - break; - case GL_CLIP_PLANE5: - params[0] = (ctx->Transform.ClipPlanesEnabled >> 5) & 1; - break; - case GL_COLOR_CLEAR_VALUE: - params[0] = FLOAT_TO_BOOLEAN(ctx->Color.ClearColor[0]); - params[1] = FLOAT_TO_BOOLEAN(ctx->Color.ClearColor[1]); - params[2] = FLOAT_TO_BOOLEAN(ctx->Color.ClearColor[2]); - params[3] = FLOAT_TO_BOOLEAN(ctx->Color.ClearColor[3]); - break; - case GL_COLOR_MATERIAL: - params[0] = ctx->Light.ColorMaterialEnabled; - break; - case GL_COLOR_MATERIAL_FACE: - params[0] = ENUM_TO_BOOLEAN(ctx->Light.ColorMaterialFace); - break; - case GL_COLOR_MATERIAL_PARAMETER: - params[0] = ENUM_TO_BOOLEAN(ctx->Light.ColorMaterialMode); - break; - case GL_COLOR_WRITEMASK: - params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0); - params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0); - params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0); - params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0); - break; - case GL_CULL_FACE: - params[0] = ctx->Polygon.CullFlag; - break; - case GL_CULL_FACE_MODE: - params[0] = ENUM_TO_BOOLEAN(ctx->Polygon.CullFaceMode); - break; - case GL_CURRENT_COLOR: - FLUSH_CURRENT(ctx, 0); - params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]); - params[1] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]); - params[2] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]); - params[3] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]); - break; - case GL_CURRENT_INDEX: - FLUSH_CURRENT(ctx, 0); - params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]); - break; - case GL_CURRENT_NORMAL: - FLUSH_CURRENT(ctx, 0); - params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]); - params[1] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]); - params[2] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]); - break; - case GL_CURRENT_RASTER_COLOR: - params[0] = FLOAT_TO_BOOLEAN(ctx->Current.RasterColor[0]); - params[1] = FLOAT_TO_BOOLEAN(ctx->Current.RasterColor[1]); - params[2] = FLOAT_TO_BOOLEAN(ctx->Current.RasterColor[2]); - params[3] = FLOAT_TO_BOOLEAN(ctx->Current.RasterColor[3]); - break; - case GL_CURRENT_RASTER_DISTANCE: - params[0] = FLOAT_TO_BOOLEAN(ctx->Current.RasterDistance); - break; - case GL_CURRENT_RASTER_INDEX: - params[0] = FLOAT_TO_BOOLEAN(1.0); - break; - case GL_CURRENT_RASTER_POSITION: - params[0] = FLOAT_TO_BOOLEAN(ctx->Current.RasterPos[0]); - params[1] = FLOAT_TO_BOOLEAN(ctx->Current.RasterPos[1]); - params[2] = FLOAT_TO_BOOLEAN(ctx->Current.RasterPos[2]); - params[3] = FLOAT_TO_BOOLEAN(ctx->Current.RasterPos[3]); - break; - case GL_CURRENT_RASTER_SECONDARY_COLOR: - params[0] = FLOAT_TO_BOOLEAN(ctx->Current.RasterSecondaryColor[0]); - params[1] = FLOAT_TO_BOOLEAN(ctx->Current.RasterSecondaryColor[1]); - params[2] = FLOAT_TO_BOOLEAN(ctx->Current.RasterSecondaryColor[2]); - params[3] = FLOAT_TO_BOOLEAN(ctx->Current.RasterSecondaryColor[3]); - break; - case GL_CURRENT_RASTER_TEXTURE_COORDS: - { - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(raster tex coords, unit %u)", unit); - return; - } - params[0] = FLOAT_TO_BOOLEAN(ctx->Current.RasterTexCoords[unit][0]); - params[1] = FLOAT_TO_BOOLEAN(ctx->Current.RasterTexCoords[unit][1]); - params[2] = FLOAT_TO_BOOLEAN(ctx->Current.RasterTexCoords[unit][2]); - params[3] = FLOAT_TO_BOOLEAN(ctx->Current.RasterTexCoords[unit][3]); - } - break; - case GL_CURRENT_RASTER_POSITION_VALID: - params[0] = ctx->Current.RasterPosValid; - break; - case GL_CURRENT_TEXTURE_COORDS: - { - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(current tex coords, unit %u)", unit); - return; - } - FLUSH_CURRENT(ctx, 0); - params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]); - params[1] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]); - params[2] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2]); - params[3] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3]); - } - break; - case GL_DEPTH_BIAS: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.DepthBias); - break; - case GL_DEPTH_BITS: - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.depthBits); - break; - case GL_DEPTH_CLEAR_VALUE: - params[0] = FLOAT_TO_BOOLEAN(((GLfloat) ctx->Depth.Clear)); - break; - case GL_DEPTH_FUNC: - params[0] = ENUM_TO_BOOLEAN(ctx->Depth.Func); - break; - case GL_DEPTH_RANGE: - params[0] = FLOAT_TO_BOOLEAN(ctx->Viewport.Near); - params[1] = FLOAT_TO_BOOLEAN(ctx->Viewport.Far); - break; - case GL_DEPTH_SCALE: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.DepthScale); - break; - case GL_DEPTH_TEST: - params[0] = ctx->Depth.Test; - break; - case GL_DEPTH_WRITEMASK: - params[0] = ctx->Depth.Mask; - break; - case GL_DITHER: - params[0] = ctx->Color.DitherFlag; - break; - case GL_DOUBLEBUFFER: - params[0] = ctx->DrawBuffer->Visual.doubleBufferMode; - break; - case GL_DRAW_BUFFER: - params[0] = ENUM_TO_BOOLEAN(ctx->DrawBuffer->ColorDrawBuffer[0]); - break; - case GL_EDGE_FLAG: - FLUSH_CURRENT(ctx, 0); - params[0] = (ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0); - break; - case GL_FEEDBACK_BUFFER_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Feedback.BufferSize); - break; - case GL_FEEDBACK_BUFFER_TYPE: - params[0] = ENUM_TO_BOOLEAN(ctx->Feedback.Type); - break; - case GL_FOG: - params[0] = ctx->Fog.Enabled; - break; - case GL_FOG_COLOR: - params[0] = FLOAT_TO_BOOLEAN(ctx->Fog.Color[0]); - params[1] = FLOAT_TO_BOOLEAN(ctx->Fog.Color[1]); - params[2] = FLOAT_TO_BOOLEAN(ctx->Fog.Color[2]); - params[3] = FLOAT_TO_BOOLEAN(ctx->Fog.Color[3]); - break; - case GL_FOG_DENSITY: - params[0] = FLOAT_TO_BOOLEAN(ctx->Fog.Density); - break; - case GL_FOG_END: - params[0] = FLOAT_TO_BOOLEAN(ctx->Fog.End); - break; - case GL_FOG_HINT: - params[0] = ENUM_TO_BOOLEAN(ctx->Hint.Fog); - break; - case GL_FOG_INDEX: - params[0] = FLOAT_TO_BOOLEAN(ctx->Fog.Index); - break; - case GL_FOG_MODE: - params[0] = ENUM_TO_BOOLEAN(ctx->Fog.Mode); - break; - case GL_FOG_START: - params[0] = FLOAT_TO_BOOLEAN(ctx->Fog.Start); - break; - case GL_FRONT_FACE: - params[0] = ENUM_TO_BOOLEAN(ctx->Polygon.FrontFace); - break; - case GL_GREEN_BIAS: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.GreenBias); - break; - case GL_GREEN_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.greenBits); - break; - case GL_GREEN_SCALE: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.GreenScale); - break; - case GL_INDEX_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.indexBits); - break; - case GL_INDEX_CLEAR_VALUE: - params[0] = INT_TO_BOOLEAN(ctx->Color.ClearIndex); - break; - case GL_INDEX_MODE: - params[0] = GL_FALSE; - break; - case GL_INDEX_OFFSET: - params[0] = INT_TO_BOOLEAN(ctx->Pixel.IndexOffset); - break; - case GL_INDEX_SHIFT: - params[0] = INT_TO_BOOLEAN(ctx->Pixel.IndexShift); - break; - case GL_INDEX_WRITEMASK: - params[0] = INT_TO_BOOLEAN(ctx->Color.IndexMask); - break; - case GL_LIGHT0: - params[0] = ctx->Light.Light[0].Enabled; - break; - case GL_LIGHT1: - params[0] = ctx->Light.Light[1].Enabled; - break; - case GL_LIGHT2: - params[0] = ctx->Light.Light[2].Enabled; - break; - case GL_LIGHT3: - params[0] = ctx->Light.Light[3].Enabled; - break; - case GL_LIGHT4: - params[0] = ctx->Light.Light[4].Enabled; - break; - case GL_LIGHT5: - params[0] = ctx->Light.Light[5].Enabled; - break; - case GL_LIGHT6: - params[0] = ctx->Light.Light[6].Enabled; - break; - case GL_LIGHT7: - params[0] = ctx->Light.Light[7].Enabled; - break; - case GL_LIGHTING: - params[0] = ctx->Light.Enabled; - break; - case GL_LIGHT_MODEL_AMBIENT: - params[0] = FLOAT_TO_BOOLEAN(ctx->Light.Model.Ambient[0]); - params[1] = FLOAT_TO_BOOLEAN(ctx->Light.Model.Ambient[1]); - params[2] = FLOAT_TO_BOOLEAN(ctx->Light.Model.Ambient[2]); - params[3] = FLOAT_TO_BOOLEAN(ctx->Light.Model.Ambient[3]); - break; - case GL_LIGHT_MODEL_COLOR_CONTROL: - params[0] = ENUM_TO_BOOLEAN(ctx->Light.Model.ColorControl); - break; - case GL_LIGHT_MODEL_LOCAL_VIEWER: - params[0] = ctx->Light.Model.LocalViewer; - break; - case GL_LIGHT_MODEL_TWO_SIDE: - params[0] = ctx->Light.Model.TwoSide; - break; - case GL_LINE_SMOOTH: - params[0] = ctx->Line.SmoothFlag; - break; - case GL_LINE_SMOOTH_HINT: - params[0] = ENUM_TO_BOOLEAN(ctx->Hint.LineSmooth); - break; - case GL_LINE_STIPPLE: - params[0] = ctx->Line.StippleFlag; - break; - case GL_LINE_STIPPLE_PATTERN: - params[0] = INT_TO_BOOLEAN(ctx->Line.StipplePattern); - break; - case GL_LINE_STIPPLE_REPEAT: - params[0] = INT_TO_BOOLEAN(ctx->Line.StippleFactor); - break; - case GL_LINE_WIDTH: - params[0] = FLOAT_TO_BOOLEAN(ctx->Line.Width); - break; - case GL_LINE_WIDTH_GRANULARITY: - params[0] = FLOAT_TO_BOOLEAN(ctx->Const.LineWidthGranularity); - break; - case GL_LINE_WIDTH_RANGE: - params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MinLineWidthAA); - params[1] = FLOAT_TO_BOOLEAN(ctx->Const.MaxLineWidthAA); - break; - case GL_ALIASED_LINE_WIDTH_RANGE: - params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MinLineWidth); - params[1] = FLOAT_TO_BOOLEAN(ctx->Const.MaxLineWidth); - break; - case GL_LIST_BASE: - params[0] = INT_TO_BOOLEAN(ctx->List.ListBase); - break; - case GL_LIST_INDEX: - params[0] = INT_TO_BOOLEAN((ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0)); - break; - case GL_LIST_MODE: - { - GLenum mode; - if (!ctx->CompileFlag) - mode = 0; - else if (ctx->ExecuteFlag) - mode = GL_COMPILE_AND_EXECUTE; - else - mode = GL_COMPILE; - params[0] = ENUM_TO_BOOLEAN(mode); - } - break; - case GL_INDEX_LOGIC_OP: - params[0] = ctx->Color.IndexLogicOpEnabled; - break; - case GL_COLOR_LOGIC_OP: - params[0] = ctx->Color.ColorLogicOpEnabled; - break; - case GL_LOGIC_OP_MODE: - params[0] = ENUM_TO_BOOLEAN(ctx->Color.LogicOp); - break; - case GL_MAP1_COLOR_4: - params[0] = ctx->Eval.Map1Color4; - break; - case GL_MAP1_GRID_DOMAIN: - params[0] = FLOAT_TO_BOOLEAN(ctx->Eval.MapGrid1u1); - params[1] = FLOAT_TO_BOOLEAN(ctx->Eval.MapGrid1u2); - break; - case GL_MAP1_GRID_SEGMENTS: - params[0] = INT_TO_BOOLEAN(ctx->Eval.MapGrid1un); - break; - case GL_MAP1_INDEX: - params[0] = ctx->Eval.Map1Index; - break; - case GL_MAP1_NORMAL: - params[0] = ctx->Eval.Map1Normal; - break; - case GL_MAP1_TEXTURE_COORD_1: - params[0] = ctx->Eval.Map1TextureCoord1; - break; - case GL_MAP1_TEXTURE_COORD_2: - params[0] = ctx->Eval.Map1TextureCoord2; - break; - case GL_MAP1_TEXTURE_COORD_3: - params[0] = ctx->Eval.Map1TextureCoord3; - break; - case GL_MAP1_TEXTURE_COORD_4: - params[0] = ctx->Eval.Map1TextureCoord4; - break; - case GL_MAP1_VERTEX_3: - params[0] = ctx->Eval.Map1Vertex3; - break; - case GL_MAP1_VERTEX_4: - params[0] = ctx->Eval.Map1Vertex4; - break; - case GL_MAP2_COLOR_4: - params[0] = ctx->Eval.Map2Color4; - break; - case GL_MAP2_GRID_DOMAIN: - params[0] = FLOAT_TO_BOOLEAN(ctx->Eval.MapGrid2u1); - params[1] = FLOAT_TO_BOOLEAN(ctx->Eval.MapGrid2u2); - params[2] = FLOAT_TO_BOOLEAN(ctx->Eval.MapGrid2v1); - params[3] = FLOAT_TO_BOOLEAN(ctx->Eval.MapGrid2v2); - break; - case GL_MAP2_GRID_SEGMENTS: - params[0] = INT_TO_BOOLEAN(ctx->Eval.MapGrid2un); - params[1] = INT_TO_BOOLEAN(ctx->Eval.MapGrid2vn); - break; - case GL_MAP2_INDEX: - params[0] = ctx->Eval.Map2Index; - break; - case GL_MAP2_NORMAL: - params[0] = ctx->Eval.Map2Normal; - break; - case GL_MAP2_TEXTURE_COORD_1: - params[0] = ctx->Eval.Map2TextureCoord1; - break; - case GL_MAP2_TEXTURE_COORD_2: - params[0] = ctx->Eval.Map2TextureCoord2; - break; - case GL_MAP2_TEXTURE_COORD_3: - params[0] = ctx->Eval.Map2TextureCoord3; - break; - case GL_MAP2_TEXTURE_COORD_4: - params[0] = ctx->Eval.Map2TextureCoord4; - break; - case GL_MAP2_VERTEX_3: - params[0] = ctx->Eval.Map2Vertex3; - break; - case GL_MAP2_VERTEX_4: - params[0] = ctx->Eval.Map2Vertex4; - break; - case GL_MAP_COLOR: - params[0] = ctx->Pixel.MapColorFlag; - break; - case GL_MAP_STENCIL: - params[0] = ctx->Pixel.MapStencilFlag; - break; - case GL_MATRIX_MODE: - params[0] = ENUM_TO_BOOLEAN(ctx->Transform.MatrixMode); - break; - case GL_MAX_ATTRIB_STACK_DEPTH: - params[0] = INT_TO_BOOLEAN(MAX_ATTRIB_STACK_DEPTH); - break; - case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH: - params[0] = INT_TO_BOOLEAN(MAX_CLIENT_ATTRIB_STACK_DEPTH); - break; - case GL_MAX_CLIP_PLANES: - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxClipPlanes); - break; - case GL_MAX_ELEMENTS_VERTICES: - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxArrayLockSize); - break; - case GL_MAX_ELEMENTS_INDICES: - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxArrayLockSize); - break; - case GL_MAX_EVAL_ORDER: - params[0] = INT_TO_BOOLEAN(MAX_EVAL_ORDER); - break; - case GL_MAX_LIGHTS: - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxLights); - break; - case GL_MAX_LIST_NESTING: - params[0] = INT_TO_BOOLEAN(MAX_LIST_NESTING); - break; - case GL_MAX_MODELVIEW_STACK_DEPTH: - params[0] = INT_TO_BOOLEAN(MAX_MODELVIEW_STACK_DEPTH); - break; - case GL_MAX_NAME_STACK_DEPTH: - params[0] = INT_TO_BOOLEAN(MAX_NAME_STACK_DEPTH); - break; - case GL_MAX_PIXEL_MAP_TABLE: - params[0] = INT_TO_BOOLEAN(MAX_PIXEL_MAP_TABLE); - break; - case GL_MAX_PROJECTION_STACK_DEPTH: - params[0] = INT_TO_BOOLEAN(MAX_PROJECTION_STACK_DEPTH); - break; - case GL_MAX_TEXTURE_SIZE: - params[0] = INT_TO_BOOLEAN(1 << (ctx->Const.MaxTextureLevels - 1)); - break; - case GL_MAX_3D_TEXTURE_SIZE: - params[0] = INT_TO_BOOLEAN(1 << (ctx->Const.Max3DTextureLevels - 1)); - break; - case GL_MAX_TEXTURE_STACK_DEPTH: - params[0] = INT_TO_BOOLEAN(MAX_TEXTURE_STACK_DEPTH); - break; - case GL_MAX_VIEWPORT_DIMS: - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxViewportWidth); - params[1] = INT_TO_BOOLEAN(ctx->Const.MaxViewportHeight); - break; - case GL_MODELVIEW_MATRIX: - { - const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m; - params[0] = FLOAT_TO_BOOLEAN(matrix[0]); - params[1] = FLOAT_TO_BOOLEAN(matrix[1]); - params[2] = FLOAT_TO_BOOLEAN(matrix[2]); - params[3] = FLOAT_TO_BOOLEAN(matrix[3]); - params[4] = FLOAT_TO_BOOLEAN(matrix[4]); - params[5] = FLOAT_TO_BOOLEAN(matrix[5]); - params[6] = FLOAT_TO_BOOLEAN(matrix[6]); - params[7] = FLOAT_TO_BOOLEAN(matrix[7]); - params[8] = FLOAT_TO_BOOLEAN(matrix[8]); - params[9] = FLOAT_TO_BOOLEAN(matrix[9]); - params[10] = FLOAT_TO_BOOLEAN(matrix[10]); - params[11] = FLOAT_TO_BOOLEAN(matrix[11]); - params[12] = FLOAT_TO_BOOLEAN(matrix[12]); - params[13] = FLOAT_TO_BOOLEAN(matrix[13]); - params[14] = FLOAT_TO_BOOLEAN(matrix[14]); - params[15] = FLOAT_TO_BOOLEAN(matrix[15]); - } - break; - case GL_MODELVIEW_STACK_DEPTH: - params[0] = INT_TO_BOOLEAN(ctx->ModelviewMatrixStack.Depth + 1); - break; - case GL_NAME_STACK_DEPTH: - params[0] = INT_TO_BOOLEAN(ctx->Select.NameStackDepth); - break; - case GL_NORMALIZE: - params[0] = ctx->Transform.Normalize; - break; - case GL_PACK_ALIGNMENT: - params[0] = INT_TO_BOOLEAN(ctx->Pack.Alignment); - break; - case GL_PACK_LSB_FIRST: - params[0] = ctx->Pack.LsbFirst; - break; - case GL_PACK_ROW_LENGTH: - params[0] = INT_TO_BOOLEAN(ctx->Pack.RowLength); - break; - case GL_PACK_SKIP_PIXELS: - params[0] = INT_TO_BOOLEAN(ctx->Pack.SkipPixels); - break; - case GL_PACK_SKIP_ROWS: - params[0] = INT_TO_BOOLEAN(ctx->Pack.SkipRows); - break; - case GL_PACK_SWAP_BYTES: - params[0] = ctx->Pack.SwapBytes; - break; - case GL_PACK_SKIP_IMAGES_EXT: - params[0] = INT_TO_BOOLEAN(ctx->Pack.SkipImages); - break; - case GL_PACK_IMAGE_HEIGHT_EXT: - params[0] = INT_TO_BOOLEAN(ctx->Pack.ImageHeight); - break; - case GL_PACK_INVERT_MESA: - params[0] = ctx->Pack.Invert; - break; - case GL_PERSPECTIVE_CORRECTION_HINT: - params[0] = ENUM_TO_BOOLEAN(ctx->Hint.PerspectiveCorrection); - break; - case GL_PIXEL_MAP_A_TO_A_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.AtoA.Size); - break; - case GL_PIXEL_MAP_B_TO_B_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.BtoB.Size); - break; - case GL_PIXEL_MAP_G_TO_G_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.GtoG.Size); - break; - case GL_PIXEL_MAP_I_TO_A_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoA.Size); - break; - case GL_PIXEL_MAP_I_TO_B_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoB.Size); - break; - case GL_PIXEL_MAP_I_TO_G_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoG.Size); - break; - case GL_PIXEL_MAP_I_TO_I_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoI.Size); - break; - case GL_PIXEL_MAP_I_TO_R_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.ItoR.Size); - break; - case GL_PIXEL_MAP_R_TO_R_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.RtoR.Size); - break; - case GL_PIXEL_MAP_S_TO_S_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->PixelMaps.StoS.Size); - break; - case GL_POINT_SIZE: - params[0] = FLOAT_TO_BOOLEAN(ctx->Point.Size); - break; - case GL_POINT_SIZE_GRANULARITY: - params[0] = FLOAT_TO_BOOLEAN(ctx->Const.PointSizeGranularity); - break; - case GL_POINT_SIZE_RANGE: - params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MinPointSizeAA); - params[1] = FLOAT_TO_BOOLEAN(ctx->Const.MaxPointSizeAA); - break; - case GL_ALIASED_POINT_SIZE_RANGE: - params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MinPointSize); - params[1] = FLOAT_TO_BOOLEAN(ctx->Const.MaxPointSize); - break; - case GL_POINT_SMOOTH: - params[0] = ctx->Point.SmoothFlag; - break; - case GL_POINT_SMOOTH_HINT: - params[0] = ENUM_TO_BOOLEAN(ctx->Hint.PointSmooth); - break; - case GL_POINT_SIZE_MIN_EXT: - params[0] = FLOAT_TO_BOOLEAN(ctx->Point.MinSize); - break; - case GL_POINT_SIZE_MAX_EXT: - params[0] = FLOAT_TO_BOOLEAN(ctx->Point.MaxSize); - break; - case GL_POINT_FADE_THRESHOLD_SIZE_EXT: - params[0] = FLOAT_TO_BOOLEAN(ctx->Point.Threshold); - break; - case GL_DISTANCE_ATTENUATION_EXT: - params[0] = FLOAT_TO_BOOLEAN(ctx->Point.Params[0]); - params[1] = FLOAT_TO_BOOLEAN(ctx->Point.Params[1]); - params[2] = FLOAT_TO_BOOLEAN(ctx->Point.Params[2]); - break; - case GL_POLYGON_MODE: - params[0] = ENUM_TO_BOOLEAN(ctx->Polygon.FrontMode); - params[1] = ENUM_TO_BOOLEAN(ctx->Polygon.BackMode); - break; - case GL_POLYGON_OFFSET_BIAS_EXT: - params[0] = FLOAT_TO_BOOLEAN(ctx->Polygon.OffsetUnits); - break; - case GL_POLYGON_OFFSET_FACTOR: - params[0] = FLOAT_TO_BOOLEAN(ctx->Polygon.OffsetFactor ); - break; - case GL_POLYGON_OFFSET_UNITS: - params[0] = FLOAT_TO_BOOLEAN(ctx->Polygon.OffsetUnits ); - break; - case GL_POLYGON_OFFSET_POINT: - params[0] = ctx->Polygon.OffsetPoint; - break; - case GL_POLYGON_OFFSET_LINE: - params[0] = ctx->Polygon.OffsetLine; - break; - case GL_POLYGON_OFFSET_FILL: - params[0] = ctx->Polygon.OffsetFill; - break; - case GL_POLYGON_SMOOTH: - params[0] = ctx->Polygon.SmoothFlag; - break; - case GL_POLYGON_SMOOTH_HINT: - params[0] = ENUM_TO_BOOLEAN(ctx->Hint.PolygonSmooth); - break; - case GL_POLYGON_STIPPLE: - params[0] = ctx->Polygon.StippleFlag; - break; - case GL_PROJECTION_MATRIX: - { - const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m; - params[0] = FLOAT_TO_BOOLEAN(matrix[0]); - params[1] = FLOAT_TO_BOOLEAN(matrix[1]); - params[2] = FLOAT_TO_BOOLEAN(matrix[2]); - params[3] = FLOAT_TO_BOOLEAN(matrix[3]); - params[4] = FLOAT_TO_BOOLEAN(matrix[4]); - params[5] = FLOAT_TO_BOOLEAN(matrix[5]); - params[6] = FLOAT_TO_BOOLEAN(matrix[6]); - params[7] = FLOAT_TO_BOOLEAN(matrix[7]); - params[8] = FLOAT_TO_BOOLEAN(matrix[8]); - params[9] = FLOAT_TO_BOOLEAN(matrix[9]); - params[10] = FLOAT_TO_BOOLEAN(matrix[10]); - params[11] = FLOAT_TO_BOOLEAN(matrix[11]); - params[12] = FLOAT_TO_BOOLEAN(matrix[12]); - params[13] = FLOAT_TO_BOOLEAN(matrix[13]); - params[14] = FLOAT_TO_BOOLEAN(matrix[14]); - params[15] = FLOAT_TO_BOOLEAN(matrix[15]); - } - break; - case GL_PROJECTION_STACK_DEPTH: - params[0] = INT_TO_BOOLEAN(ctx->ProjectionMatrixStack.Depth + 1); - break; - case GL_READ_BUFFER: - params[0] = ENUM_TO_BOOLEAN(ctx->ReadBuffer->ColorReadBuffer); - break; - case GL_RED_BIAS: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.RedBias); - break; - case GL_RED_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.redBits); - break; - case GL_RED_SCALE: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.RedScale); - break; - case GL_RENDER_MODE: - params[0] = ENUM_TO_BOOLEAN(ctx->RenderMode); - break; - case GL_RESCALE_NORMAL: - params[0] = ctx->Transform.RescaleNormals; - break; - case GL_RGBA_MODE: - params[0] = GL_TRUE; - break; - case GL_SCISSOR_BOX: - params[0] = INT_TO_BOOLEAN(ctx->Scissor.X); - params[1] = INT_TO_BOOLEAN(ctx->Scissor.Y); - params[2] = INT_TO_BOOLEAN(ctx->Scissor.Width); - params[3] = INT_TO_BOOLEAN(ctx->Scissor.Height); - break; - case GL_SCISSOR_TEST: - params[0] = ctx->Scissor.Enabled; - break; - case GL_SELECTION_BUFFER_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Select.BufferSize); - break; - case GL_SHADE_MODEL: - params[0] = ENUM_TO_BOOLEAN(ctx->Light.ShadeModel); - break; - case GL_SHARED_TEXTURE_PALETTE_EXT: - params[0] = ctx->Texture.SharedPalette; - break; - case GL_STENCIL_BITS: - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.stencilBits); - break; - case GL_STENCIL_CLEAR_VALUE: - params[0] = INT_TO_BOOLEAN(ctx->Stencil.Clear); - break; - case GL_STENCIL_FAIL: - params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_FUNC: - params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.Function[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_PASS_DEPTH_FAIL: - params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_PASS_DEPTH_PASS: - params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_REF: - params[0] = INT_TO_BOOLEAN(ctx->Stencil.Ref[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_TEST: - params[0] = ctx->Stencil.Enabled; - break; - case GL_STENCIL_VALUE_MASK: - params[0] = INT_TO_BOOLEAN(ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_WRITEMASK: - params[0] = INT_TO_BOOLEAN(ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]); - break; - case GL_STEREO: - params[0] = ctx->DrawBuffer->Visual.stereoMode; - break; - case GL_SUBPIXEL_BITS: - params[0] = INT_TO_BOOLEAN(ctx->Const.SubPixelBits); - break; - case GL_TEXTURE_1D: - params[0] = _mesa_IsEnabled(GL_TEXTURE_1D); - break; - case GL_TEXTURE_2D: - params[0] = _mesa_IsEnabled(GL_TEXTURE_2D); - break; - case GL_TEXTURE_3D: - params[0] = _mesa_IsEnabled(GL_TEXTURE_3D); - break; - case GL_TEXTURE_1D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = _mesa_IsEnabled(GL_TEXTURE_1D_ARRAY_EXT); - break; - case GL_TEXTURE_2D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = _mesa_IsEnabled(GL_TEXTURE_2D_ARRAY_EXT); - break; - case GL_TEXTURE_BINDING_1D: - params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_INDEX]->Name); - break; - case GL_TEXTURE_BINDING_2D: - params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name); - break; - case GL_TEXTURE_BINDING_3D: - params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name); - break; - case GL_TEXTURE_BINDING_1D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_ARRAY_INDEX]->Name); - break; - case GL_TEXTURE_BINDING_2D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name); - break; - case GL_MAX_ARRAY_TEXTURE_LAYERS_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxArrayTextureLayers); - break; - case GL_TEXTURE_GEN_S: - params[0] = ((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0); - break; - case GL_TEXTURE_GEN_T: - params[0] = ((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0); - break; - case GL_TEXTURE_GEN_R: - params[0] = ((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0); - break; - case GL_TEXTURE_GEN_Q: - params[0] = ((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & Q_BIT) ? 1 : 0); - break; - case GL_TEXTURE_MATRIX: - { - const GLfloat *matrix; - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGet(texture matrix %u)", - unit); - return; - } - matrix = ctx->TextureMatrixStack[unit].Top->m; - params[0] = FLOAT_TO_BOOLEAN(matrix[0]); - params[1] = FLOAT_TO_BOOLEAN(matrix[1]); - params[2] = FLOAT_TO_BOOLEAN(matrix[2]); - params[3] = FLOAT_TO_BOOLEAN(matrix[3]); - params[4] = FLOAT_TO_BOOLEAN(matrix[4]); - params[5] = FLOAT_TO_BOOLEAN(matrix[5]); - params[6] = FLOAT_TO_BOOLEAN(matrix[6]); - params[7] = FLOAT_TO_BOOLEAN(matrix[7]); - params[8] = FLOAT_TO_BOOLEAN(matrix[8]); - params[9] = FLOAT_TO_BOOLEAN(matrix[9]); - params[10] = FLOAT_TO_BOOLEAN(matrix[10]); - params[11] = FLOAT_TO_BOOLEAN(matrix[11]); - params[12] = FLOAT_TO_BOOLEAN(matrix[12]); - params[13] = FLOAT_TO_BOOLEAN(matrix[13]); - params[14] = FLOAT_TO_BOOLEAN(matrix[14]); - params[15] = FLOAT_TO_BOOLEAN(matrix[15]); - } - break; - case GL_TEXTURE_STACK_DEPTH: - { - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(texture stack depth, unit %u)", unit); - return; - } - params[0] = INT_TO_BOOLEAN(ctx->TextureMatrixStack[unit].Depth + 1); - } - break; - case GL_UNPACK_ALIGNMENT: - params[0] = INT_TO_BOOLEAN(ctx->Unpack.Alignment); - break; - case GL_UNPACK_LSB_FIRST: - params[0] = ctx->Unpack.LsbFirst; - break; - case GL_UNPACK_ROW_LENGTH: - params[0] = INT_TO_BOOLEAN(ctx->Unpack.RowLength); - break; - case GL_UNPACK_SKIP_PIXELS: - params[0] = INT_TO_BOOLEAN(ctx->Unpack.SkipPixels); - break; - case GL_UNPACK_SKIP_ROWS: - params[0] = INT_TO_BOOLEAN(ctx->Unpack.SkipRows); - break; - case GL_UNPACK_SWAP_BYTES: - params[0] = ctx->Unpack.SwapBytes; - break; - case GL_UNPACK_SKIP_IMAGES_EXT: - params[0] = INT_TO_BOOLEAN(ctx->Unpack.SkipImages); - break; - case GL_UNPACK_IMAGE_HEIGHT_EXT: - params[0] = INT_TO_BOOLEAN(ctx->Unpack.ImageHeight); - break; - case GL_UNPACK_CLIENT_STORAGE_APPLE: - params[0] = ctx->Unpack.ClientStorage; - break; - case GL_VIEWPORT: - params[0] = INT_TO_BOOLEAN(ctx->Viewport.X); - params[1] = INT_TO_BOOLEAN(ctx->Viewport.Y); - params[2] = INT_TO_BOOLEAN(ctx->Viewport.Width); - params[3] = INT_TO_BOOLEAN(ctx->Viewport.Height); - break; - case GL_ZOOM_X: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.ZoomX); - break; - case GL_ZOOM_Y: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.ZoomY); - break; - case GL_VERTEX_ARRAY: - params[0] = ctx->Array.ArrayObj->Vertex.Enabled; - break; - case GL_VERTEX_ARRAY_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->Vertex.Size); - break; - case GL_VERTEX_ARRAY_TYPE: - params[0] = ENUM_TO_BOOLEAN(ctx->Array.ArrayObj->Vertex.Type); - break; - case GL_VERTEX_ARRAY_STRIDE: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->Vertex.Stride); - break; - case GL_VERTEX_ARRAY_COUNT_EXT: - params[0] = INT_TO_BOOLEAN(0); - break; - case GL_NORMAL_ARRAY: - params[0] = ENUM_TO_BOOLEAN(ctx->Array.ArrayObj->Normal.Enabled); - break; - case GL_NORMAL_ARRAY_TYPE: - params[0] = ENUM_TO_BOOLEAN(ctx->Array.ArrayObj->Normal.Type); - break; - case GL_NORMAL_ARRAY_STRIDE: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->Normal.Stride); - break; - case GL_NORMAL_ARRAY_COUNT_EXT: - params[0] = INT_TO_BOOLEAN(0); - break; - case GL_COLOR_ARRAY: - params[0] = ctx->Array.ArrayObj->Color.Enabled; - break; - case GL_COLOR_ARRAY_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->Color.Size); - break; - case GL_COLOR_ARRAY_TYPE: - params[0] = ENUM_TO_BOOLEAN(ctx->Array.ArrayObj->Color.Type); - break; - case GL_COLOR_ARRAY_STRIDE: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->Color.Stride); - break; - case GL_COLOR_ARRAY_COUNT_EXT: - params[0] = INT_TO_BOOLEAN(0); - break; - case GL_INDEX_ARRAY: - params[0] = ctx->Array.ArrayObj->Index.Enabled; - break; - case GL_INDEX_ARRAY_TYPE: - params[0] = ENUM_TO_BOOLEAN(ctx->Array.ArrayObj->Index.Type); - break; - case GL_INDEX_ARRAY_STRIDE: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->Index.Stride); - break; - case GL_INDEX_ARRAY_COUNT_EXT: - params[0] = INT_TO_BOOLEAN(0); - break; - case GL_TEXTURE_COORD_ARRAY: - params[0] = ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled; - break; - case GL_TEXTURE_COORD_ARRAY_SIZE: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size); - break; - case GL_TEXTURE_COORD_ARRAY_TYPE: - params[0] = ENUM_TO_BOOLEAN(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Type); - break; - case GL_TEXTURE_COORD_ARRAY_STRIDE: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride); - break; - case GL_TEXTURE_COORD_ARRAY_COUNT_EXT: - params[0] = INT_TO_BOOLEAN(0); - break; - case GL_EDGE_FLAG_ARRAY: - params[0] = ctx->Array.ArrayObj->EdgeFlag.Enabled; - break; - case GL_EDGE_FLAG_ARRAY_STRIDE: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->EdgeFlag.Stride); - break; - case GL_EDGE_FLAG_ARRAY_COUNT_EXT: - params[0] = INT_TO_BOOLEAN(0); - break; - case GL_MAX_TEXTURE_UNITS_ARB: - CHECK_EXT1(ARB_multitexture); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTextureUnits); - break; - case GL_ACTIVE_TEXTURE_ARB: - CHECK_EXT1(ARB_multitexture); - params[0] = INT_TO_BOOLEAN(GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit); - break; - case GL_CLIENT_ACTIVE_TEXTURE_ARB: - CHECK_EXT1(ARB_multitexture); - params[0] = INT_TO_BOOLEAN(GL_TEXTURE0_ARB + ctx->Array.ActiveTexture); - break; - case GL_TEXTURE_CUBE_MAP_ARB: - CHECK_EXT1(ARB_texture_cube_map); - params[0] = _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB); - break; - case GL_TEXTURE_BINDING_CUBE_MAP_ARB: - CHECK_EXT1(ARB_texture_cube_map); - params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_CUBE_INDEX]->Name); - break; - case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: - CHECK_EXT1(ARB_texture_cube_map); - params[0] = INT_TO_BOOLEAN((1 << (ctx->Const.MaxCubeTextureLevels - 1))); - break; - case GL_TEXTURE_COMPRESSION_HINT_ARB: - params[0] = INT_TO_BOOLEAN(ctx->Hint.TextureCompression); - break; - case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: - params[0] = INT_TO_BOOLEAN(_mesa_get_compressed_formats(ctx, NULL, GL_FALSE)); - break; - case GL_COMPRESSED_TEXTURE_FORMATS_ARB: - { - GLint formats[100]; - GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE); - ASSERT(n <= 100); - for (i = 0; i < n; i++) - params[i] = ENUM_TO_BOOLEAN(formats[i]); - } - break; - case GL_ARRAY_ELEMENT_LOCK_FIRST_EXT: - CHECK_EXT1(EXT_compiled_vertex_array); - params[0] = INT_TO_BOOLEAN(ctx->Array.LockFirst); - break; - case GL_ARRAY_ELEMENT_LOCK_COUNT_EXT: - CHECK_EXT1(EXT_compiled_vertex_array); - params[0] = INT_TO_BOOLEAN(ctx->Array.LockCount); - break; - case GL_TRANSPOSE_COLOR_MATRIX_ARB: - { - const GLfloat *matrix = ctx->ColorMatrixStack.Top->m; - params[0] = FLOAT_TO_BOOLEAN(matrix[0]); - params[1] = FLOAT_TO_BOOLEAN(matrix[4]); - params[2] = FLOAT_TO_BOOLEAN(matrix[8]); - params[3] = FLOAT_TO_BOOLEAN(matrix[12]); - params[4] = FLOAT_TO_BOOLEAN(matrix[1]); - params[5] = FLOAT_TO_BOOLEAN(matrix[5]); - params[6] = FLOAT_TO_BOOLEAN(matrix[9]); - params[7] = FLOAT_TO_BOOLEAN(matrix[13]); - params[8] = FLOAT_TO_BOOLEAN(matrix[2]); - params[9] = FLOAT_TO_BOOLEAN(matrix[6]); - params[10] = FLOAT_TO_BOOLEAN(matrix[10]); - params[11] = FLOAT_TO_BOOLEAN(matrix[14]); - params[12] = FLOAT_TO_BOOLEAN(matrix[3]); - params[13] = FLOAT_TO_BOOLEAN(matrix[7]); - params[14] = FLOAT_TO_BOOLEAN(matrix[11]); - params[15] = FLOAT_TO_BOOLEAN(matrix[15]); - } - break; - case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB: - { - const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m; - params[0] = FLOAT_TO_BOOLEAN(matrix[0]); - params[1] = FLOAT_TO_BOOLEAN(matrix[4]); - params[2] = FLOAT_TO_BOOLEAN(matrix[8]); - params[3] = FLOAT_TO_BOOLEAN(matrix[12]); - params[4] = FLOAT_TO_BOOLEAN(matrix[1]); - params[5] = FLOAT_TO_BOOLEAN(matrix[5]); - params[6] = FLOAT_TO_BOOLEAN(matrix[9]); - params[7] = FLOAT_TO_BOOLEAN(matrix[13]); - params[8] = FLOAT_TO_BOOLEAN(matrix[2]); - params[9] = FLOAT_TO_BOOLEAN(matrix[6]); - params[10] = FLOAT_TO_BOOLEAN(matrix[10]); - params[11] = FLOAT_TO_BOOLEAN(matrix[14]); - params[12] = FLOAT_TO_BOOLEAN(matrix[3]); - params[13] = FLOAT_TO_BOOLEAN(matrix[7]); - params[14] = FLOAT_TO_BOOLEAN(matrix[11]); - params[15] = FLOAT_TO_BOOLEAN(matrix[15]); - } - break; - case GL_TRANSPOSE_PROJECTION_MATRIX_ARB: - { - const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m; - params[0] = FLOAT_TO_BOOLEAN(matrix[0]); - params[1] = FLOAT_TO_BOOLEAN(matrix[4]); - params[2] = FLOAT_TO_BOOLEAN(matrix[8]); - params[3] = FLOAT_TO_BOOLEAN(matrix[12]); - params[4] = FLOAT_TO_BOOLEAN(matrix[1]); - params[5] = FLOAT_TO_BOOLEAN(matrix[5]); - params[6] = FLOAT_TO_BOOLEAN(matrix[9]); - params[7] = FLOAT_TO_BOOLEAN(matrix[13]); - params[8] = FLOAT_TO_BOOLEAN(matrix[2]); - params[9] = FLOAT_TO_BOOLEAN(matrix[6]); - params[10] = FLOAT_TO_BOOLEAN(matrix[10]); - params[11] = FLOAT_TO_BOOLEAN(matrix[14]); - params[12] = FLOAT_TO_BOOLEAN(matrix[3]); - params[13] = FLOAT_TO_BOOLEAN(matrix[7]); - params[14] = FLOAT_TO_BOOLEAN(matrix[11]); - params[15] = FLOAT_TO_BOOLEAN(matrix[15]); - } - break; - case GL_TRANSPOSE_TEXTURE_MATRIX_ARB: - { - const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m; - params[0] = FLOAT_TO_BOOLEAN(matrix[0]); - params[1] = FLOAT_TO_BOOLEAN(matrix[4]); - params[2] = FLOAT_TO_BOOLEAN(matrix[8]); - params[3] = FLOAT_TO_BOOLEAN(matrix[12]); - params[4] = FLOAT_TO_BOOLEAN(matrix[1]); - params[5] = FLOAT_TO_BOOLEAN(matrix[5]); - params[6] = FLOAT_TO_BOOLEAN(matrix[9]); - params[7] = FLOAT_TO_BOOLEAN(matrix[13]); - params[8] = FLOAT_TO_BOOLEAN(matrix[2]); - params[9] = FLOAT_TO_BOOLEAN(matrix[6]); - params[10] = FLOAT_TO_BOOLEAN(matrix[10]); - params[11] = FLOAT_TO_BOOLEAN(matrix[14]); - params[12] = FLOAT_TO_BOOLEAN(matrix[3]); - params[13] = FLOAT_TO_BOOLEAN(matrix[7]); - params[14] = FLOAT_TO_BOOLEAN(matrix[11]); - params[15] = FLOAT_TO_BOOLEAN(matrix[15]); - } - break; - case GL_COLOR_MATRIX_SGI: - { - const GLfloat *matrix = ctx->ColorMatrixStack.Top->m; - params[0] = FLOAT_TO_BOOLEAN(matrix[0]); - params[1] = FLOAT_TO_BOOLEAN(matrix[1]); - params[2] = FLOAT_TO_BOOLEAN(matrix[2]); - params[3] = FLOAT_TO_BOOLEAN(matrix[3]); - params[4] = FLOAT_TO_BOOLEAN(matrix[4]); - params[5] = FLOAT_TO_BOOLEAN(matrix[5]); - params[6] = FLOAT_TO_BOOLEAN(matrix[6]); - params[7] = FLOAT_TO_BOOLEAN(matrix[7]); - params[8] = FLOAT_TO_BOOLEAN(matrix[8]); - params[9] = FLOAT_TO_BOOLEAN(matrix[9]); - params[10] = FLOAT_TO_BOOLEAN(matrix[10]); - params[11] = FLOAT_TO_BOOLEAN(matrix[11]); - params[12] = FLOAT_TO_BOOLEAN(matrix[12]); - params[13] = FLOAT_TO_BOOLEAN(matrix[13]); - params[14] = FLOAT_TO_BOOLEAN(matrix[14]); - params[15] = FLOAT_TO_BOOLEAN(matrix[15]); - } - break; - case GL_COLOR_MATRIX_STACK_DEPTH_SGI: - params[0] = INT_TO_BOOLEAN(ctx->ColorMatrixStack.Depth + 1); - break; - case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: - params[0] = INT_TO_BOOLEAN(MAX_COLOR_STACK_DEPTH); - break; - case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixScale[0]); - break; - case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixScale[1]); - break; - case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixScale[2]); - break; - case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixScale[3]); - break; - case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixBias[0]); - break; - case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixBias[1]); - break; - case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixBias[2]); - break; - case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixBias[3]); - break; - case GL_CONVOLUTION_1D_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = ctx->Pixel.Convolution1DEnabled; - break; - case GL_CONVOLUTION_2D_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = ctx->Pixel.Convolution2DEnabled; - break; - case GL_SEPARABLE_2D_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = ctx->Pixel.Separable2DEnabled; - break; - case GL_POST_CONVOLUTION_RED_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionScale[0]); - break; - case GL_POST_CONVOLUTION_GREEN_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionScale[1]); - break; - case GL_POST_CONVOLUTION_BLUE_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionScale[2]); - break; - case GL_POST_CONVOLUTION_ALPHA_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionScale[3]); - break; - case GL_POST_CONVOLUTION_RED_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionBias[0]); - break; - case GL_POST_CONVOLUTION_GREEN_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionBias[1]); - break; - case GL_POST_CONVOLUTION_BLUE_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionBias[2]); - break; - case GL_POST_CONVOLUTION_ALPHA_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionBias[3]); - break; - case GL_HISTOGRAM: - CHECK_EXT1(EXT_histogram); - params[0] = ctx->Pixel.HistogramEnabled; - break; - case GL_MINMAX: - CHECK_EXT1(EXT_histogram); - params[0] = ctx->Pixel.MinMaxEnabled; - break; - case GL_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_color_table); - params[0] = ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]; - break; - case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_color_table); - params[0] = ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]; - break; - case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_color_table); - params[0] = ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]; - break; - case GL_TEXTURE_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_texture_color_table); - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled; - break; - case GL_COLOR_SUM_EXT: - CHECK_EXT2(EXT_secondary_color, ARB_vertex_program); - params[0] = ctx->Fog.ColorSumEnabled; - break; - case GL_CURRENT_SECONDARY_COLOR_EXT: - CHECK_EXT1(EXT_secondary_color); - FLUSH_CURRENT(ctx, 0); - params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]); - params[1] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]); - params[2] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]); - params[3] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]); - break; - case GL_SECONDARY_COLOR_ARRAY_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = ctx->Array.ArrayObj->SecondaryColor.Enabled; - break; - case GL_SECONDARY_COLOR_ARRAY_TYPE_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = ENUM_TO_BOOLEAN(ctx->Array.ArrayObj->SecondaryColor.Type); - break; - case GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->SecondaryColor.Stride); - break; - case GL_SECONDARY_COLOR_ARRAY_SIZE_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->SecondaryColor.Size); - break; - case GL_CURRENT_FOG_COORDINATE_EXT: - CHECK_EXT1(EXT_fog_coord); - FLUSH_CURRENT(ctx, 0); - params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_FOG][0]); - break; - case GL_FOG_COORDINATE_ARRAY_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = ctx->Array.ArrayObj->FogCoord.Enabled; - break; - case GL_FOG_COORDINATE_ARRAY_TYPE_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = ENUM_TO_BOOLEAN(ctx->Array.ArrayObj->FogCoord.Type); - break; - case GL_FOG_COORDINATE_ARRAY_STRIDE_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->FogCoord.Stride); - break; - case GL_FOG_COORDINATE_SOURCE_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = ENUM_TO_BOOLEAN(ctx->Fog.FogCoordinateSource); - break; - case GL_MAX_TEXTURE_LOD_BIAS_EXT: - CHECK_EXT1(EXT_texture_lod_bias); - params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MaxTextureLodBias); - break; - case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: - CHECK_EXT1(EXT_texture_filter_anisotropic); - params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MaxTextureMaxAnisotropy); - break; - case GL_MULTISAMPLE_ARB: - params[0] = ctx->Multisample.Enabled; - break; - case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: - params[0] = ctx->Multisample.SampleAlphaToCoverage; - break; - case GL_SAMPLE_ALPHA_TO_ONE_ARB: - params[0] = ctx->Multisample.SampleAlphaToOne; - break; - case GL_SAMPLE_COVERAGE_ARB: - params[0] = ctx->Multisample.SampleCoverage; - break; - case GL_SAMPLE_COVERAGE_VALUE_ARB: - params[0] = FLOAT_TO_BOOLEAN(ctx->Multisample.SampleCoverageValue); - break; - case GL_SAMPLE_COVERAGE_INVERT_ARB: - params[0] = ctx->Multisample.SampleCoverageInvert; - break; - case GL_SAMPLE_BUFFERS_ARB: - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.sampleBuffers); - break; - case GL_SAMPLES_ARB: - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.samples); - break; - case GL_RASTER_POSITION_UNCLIPPED_IBM: - CHECK_EXT1(IBM_rasterpos_clip); - params[0] = ctx->Transform.RasterPositionUnclipped; - break; - case GL_POINT_SPRITE_NV: - CHECK_EXT2(NV_point_sprite, ARB_point_sprite); - params[0] = ctx->Point.PointSprite; - break; - case GL_POINT_SPRITE_R_MODE_NV: - CHECK_EXT1(NV_point_sprite); - params[0] = ENUM_TO_BOOLEAN(ctx->Point.SpriteRMode); - break; - case GL_POINT_SPRITE_COORD_ORIGIN: - CHECK_EXT2(NV_point_sprite, ARB_point_sprite); - params[0] = ENUM_TO_BOOLEAN(ctx->Point.SpriteOrigin); - break; - case GL_GENERATE_MIPMAP_HINT_SGIS: - CHECK_EXT1(SGIS_generate_mipmap); - params[0] = ENUM_TO_BOOLEAN(ctx->Hint.GenerateMipmap); - break; - case GL_VERTEX_PROGRAM_BINDING_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = INT_TO_BOOLEAN((ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0)); - break; - case GL_VERTEX_ATTRIB_ARRAY0_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[0].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY1_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[1].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY2_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[2].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY3_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[3].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[4].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY5_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[5].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY6_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[6].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY7_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[7].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY8_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[8].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY9_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[9].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY10_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[10].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY11_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[11].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY12_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[12].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY13_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[13].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY14_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[14].Enabled; - break; - case GL_VERTEX_ATTRIB_ARRAY15_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Array.ArrayObj->VertexAttrib[15].Enabled; - break; - case GL_MAP1_VERTEX_ATTRIB0_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[0]; - break; - case GL_MAP1_VERTEX_ATTRIB1_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[1]; - break; - case GL_MAP1_VERTEX_ATTRIB2_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[2]; - break; - case GL_MAP1_VERTEX_ATTRIB3_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[3]; - break; - case GL_MAP1_VERTEX_ATTRIB4_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[4]; - break; - case GL_MAP1_VERTEX_ATTRIB5_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[5]; - break; - case GL_MAP1_VERTEX_ATTRIB6_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[6]; - break; - case GL_MAP1_VERTEX_ATTRIB7_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[7]; - break; - case GL_MAP1_VERTEX_ATTRIB8_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[8]; - break; - case GL_MAP1_VERTEX_ATTRIB9_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[9]; - break; - case GL_MAP1_VERTEX_ATTRIB10_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[10]; - break; - case GL_MAP1_VERTEX_ATTRIB11_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[11]; - break; - case GL_MAP1_VERTEX_ATTRIB12_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[12]; - break; - case GL_MAP1_VERTEX_ATTRIB13_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[13]; - break; - case GL_MAP1_VERTEX_ATTRIB14_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[14]; - break; - case GL_MAP1_VERTEX_ATTRIB15_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = ctx->Eval.Map1Attrib[15]; - break; - case GL_FRAGMENT_PROGRAM_NV: - CHECK_EXT1(NV_fragment_program); - params[0] = ctx->FragmentProgram.Enabled; - break; - case GL_FRAGMENT_PROGRAM_BINDING_NV: - CHECK_EXT1(NV_fragment_program); - params[0] = INT_TO_BOOLEAN(ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0); - break; - case GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV: - CHECK_EXT1(NV_fragment_program); - params[0] = INT_TO_BOOLEAN(MAX_NV_FRAGMENT_PROGRAM_PARAMS); - break; - case GL_TEXTURE_RECTANGLE_NV: - CHECK_EXT1(NV_texture_rectangle); - params[0] = _mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV); - break; - case GL_TEXTURE_BINDING_RECTANGLE_NV: - CHECK_EXT1(NV_texture_rectangle); - params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_RECT_INDEX]->Name); - break; - case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV: - CHECK_EXT1(NV_texture_rectangle); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTextureRectSize); - break; - case GL_STENCIL_TEST_TWO_SIDE_EXT: - CHECK_EXT1(EXT_stencil_two_side); - params[0] = ctx->Stencil.TestTwoSide; - break; - case GL_ACTIVE_STENCIL_FACE_EXT: - CHECK_EXT1(EXT_stencil_two_side); - params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT); - break; - case GL_MAX_SHININESS_NV: - CHECK_EXT1(NV_light_max_exponent); - params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MaxShininess); - break; - case GL_MAX_SPOT_EXPONENT_NV: - CHECK_EXT1(NV_light_max_exponent); - params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MaxSpotExponent); - break; - case GL_ARRAY_BUFFER_BINDING_ARB: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayBufferObj->Name); - break; - case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->Vertex.BufferObj->Name); - break; - case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->Normal.BufferObj->Name); - break; - case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->Color.BufferObj->Name); - break; - case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->Index.BufferObj->Name); - break; - case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name); - break; - case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->EdgeFlag.BufferObj->Name); - break; - case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->SecondaryColor.BufferObj->Name); - break; - case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->FogCoord.BufferObj->Name); - break; - case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: - params[0] = INT_TO_BOOLEAN(ctx->Array.ElementArrayBufferObj->Name); - break; - case GL_PIXEL_PACK_BUFFER_BINDING_EXT: - CHECK_EXT1(EXT_pixel_buffer_object); - params[0] = INT_TO_BOOLEAN(ctx->Pack.BufferObj->Name); - break; - case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT: - CHECK_EXT1(EXT_pixel_buffer_object); - params[0] = INT_TO_BOOLEAN(ctx->Unpack.BufferObj->Name); - break; - case GL_VERTEX_PROGRAM_ARB: - CHECK_EXT2(ARB_vertex_program, NV_vertex_program); - params[0] = ctx->VertexProgram.Enabled; - break; - case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: - CHECK_EXT2(ARB_vertex_program, NV_vertex_program); - params[0] = ctx->VertexProgram.PointSizeEnabled; - break; - case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: - CHECK_EXT2(ARB_vertex_program, NV_vertex_program); - params[0] = ctx->VertexProgram.TwoSideEnabled; - break; - case GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxProgramMatrixStackDepth); - break; - case GL_MAX_PROGRAM_MATRICES_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxProgramMatrices); - break; - case GL_CURRENT_MATRIX_STACK_DEPTH_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program); - params[0] = ctx->CurrentStack->Depth + 1; - break; - case GL_CURRENT_MATRIX_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_fragment_program); - { - const GLfloat *matrix = ctx->CurrentStack->Top->m; - params[0] = FLOAT_TO_BOOLEAN(matrix[0]); - params[1] = FLOAT_TO_BOOLEAN(matrix[1]); - params[2] = FLOAT_TO_BOOLEAN(matrix[2]); - params[3] = FLOAT_TO_BOOLEAN(matrix[3]); - params[4] = FLOAT_TO_BOOLEAN(matrix[4]); - params[5] = FLOAT_TO_BOOLEAN(matrix[5]); - params[6] = FLOAT_TO_BOOLEAN(matrix[6]); - params[7] = FLOAT_TO_BOOLEAN(matrix[7]); - params[8] = FLOAT_TO_BOOLEAN(matrix[8]); - params[9] = FLOAT_TO_BOOLEAN(matrix[9]); - params[10] = FLOAT_TO_BOOLEAN(matrix[10]); - params[11] = FLOAT_TO_BOOLEAN(matrix[11]); - params[12] = FLOAT_TO_BOOLEAN(matrix[12]); - params[13] = FLOAT_TO_BOOLEAN(matrix[13]); - params[14] = FLOAT_TO_BOOLEAN(matrix[14]); - params[15] = FLOAT_TO_BOOLEAN(matrix[15]); - } - break; - case GL_TRANSPOSE_CURRENT_MATRIX_ARB: - CHECK_EXT2(ARB_vertex_program, ARB_fragment_program); - { - const GLfloat *matrix = ctx->CurrentStack->Top->m; - params[0] = FLOAT_TO_BOOLEAN(matrix[0]); - params[1] = FLOAT_TO_BOOLEAN(matrix[4]); - params[2] = FLOAT_TO_BOOLEAN(matrix[8]); - params[3] = FLOAT_TO_BOOLEAN(matrix[12]); - params[4] = FLOAT_TO_BOOLEAN(matrix[1]); - params[5] = FLOAT_TO_BOOLEAN(matrix[5]); - params[6] = FLOAT_TO_BOOLEAN(matrix[9]); - params[7] = FLOAT_TO_BOOLEAN(matrix[13]); - params[8] = FLOAT_TO_BOOLEAN(matrix[2]); - params[9] = FLOAT_TO_BOOLEAN(matrix[6]); - params[10] = FLOAT_TO_BOOLEAN(matrix[10]); - params[11] = FLOAT_TO_BOOLEAN(matrix[14]); - params[12] = FLOAT_TO_BOOLEAN(matrix[3]); - params[13] = FLOAT_TO_BOOLEAN(matrix[7]); - params[14] = FLOAT_TO_BOOLEAN(matrix[11]); - params[15] = FLOAT_TO_BOOLEAN(matrix[15]); - } - break; - case GL_MAX_VERTEX_ATTRIBS_ARB: - CHECK_EXT1(ARB_vertex_program); - params[0] = INT_TO_BOOLEAN(ctx->Const.VertexProgram.MaxAttribs); - break; - case GL_PROGRAM_ERROR_POSITION_ARB: - CHECK_EXT4(NV_vertex_program, ARB_vertex_program, NV_fragment_program, ARB_fragment_program); - params[0] = INT_TO_BOOLEAN(ctx->Program.ErrorPos); - break; - case GL_FRAGMENT_PROGRAM_ARB: - CHECK_EXT1(ARB_fragment_program); - params[0] = ctx->FragmentProgram.Enabled; - break; - case GL_MAX_TEXTURE_COORDS_ARB: - CHECK_EXT2(ARB_fragment_program, NV_fragment_program); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTextureCoordUnits); - break; - case GL_MAX_TEXTURE_IMAGE_UNITS_ARB: - CHECK_EXT2(ARB_fragment_program, NV_fragment_program); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTextureImageUnits); - break; - case GL_DEPTH_BOUNDS_TEST_EXT: - CHECK_EXT1(EXT_depth_bounds_test); - params[0] = ctx->Depth.BoundsTest; - break; - case GL_DEPTH_BOUNDS_EXT: - CHECK_EXT1(EXT_depth_bounds_test); - params[0] = FLOAT_TO_BOOLEAN(ctx->Depth.BoundsMin); - params[1] = FLOAT_TO_BOOLEAN(ctx->Depth.BoundsMax); - break; - case GL_DEPTH_CLAMP: - CHECK_EXT1(ARB_depth_clamp); - params[0] = ctx->Transform.DepthClamp; - break; - case GL_MAX_DRAW_BUFFERS_ARB: - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxDrawBuffers); - break; - case GL_DRAW_BUFFER0_ARB: - params[0] = ENUM_TO_BOOLEAN(ctx->DrawBuffer->ColorDrawBuffer[0]); - break; - case GL_DRAW_BUFFER1_ARB: - { - GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[1]; - params[0] = ENUM_TO_BOOLEAN(buffer); - } - break; - case GL_DRAW_BUFFER2_ARB: - { - GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[2]; - params[0] = ENUM_TO_BOOLEAN(buffer); - } - break; - case GL_DRAW_BUFFER3_ARB: - { - GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[3]; - params[0] = ENUM_TO_BOOLEAN(buffer); - } - break; - case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: - CHECK_EXT1(OES_read_format); - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = INT_TO_BOOLEAN(_mesa_get_color_read_type(ctx)); - break; - case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: - CHECK_EXT1(OES_read_format); - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = INT_TO_BOOLEAN(_mesa_get_color_read_format(ctx)); - break; - case GL_NUM_FRAGMENT_REGISTERS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = INT_TO_BOOLEAN(6); - break; - case GL_NUM_FRAGMENT_CONSTANTS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = INT_TO_BOOLEAN(8); - break; - case GL_NUM_PASSES_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = INT_TO_BOOLEAN(2); - break; - case GL_NUM_INSTRUCTIONS_PER_PASS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = INT_TO_BOOLEAN(8); - break; - case GL_NUM_INSTRUCTIONS_TOTAL_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = INT_TO_BOOLEAN(16); - break; - case GL_COLOR_ALPHA_PAIRING_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = GL_TRUE; - break; - case GL_NUM_LOOPBACK_COMPONENTS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = INT_TO_BOOLEAN(3); - break; - case GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = INT_TO_BOOLEAN(3); - break; - case GL_STENCIL_BACK_FUNC: - params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.Function[1]); - break; - case GL_STENCIL_BACK_VALUE_MASK: - params[0] = INT_TO_BOOLEAN(ctx->Stencil.ValueMask[1]); - break; - case GL_STENCIL_BACK_WRITEMASK: - params[0] = INT_TO_BOOLEAN(ctx->Stencil.WriteMask[1]); - break; - case GL_STENCIL_BACK_REF: - params[0] = INT_TO_BOOLEAN(ctx->Stencil.Ref[1]); - break; - case GL_STENCIL_BACK_FAIL: - params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.FailFunc[1]); - break; - case GL_STENCIL_BACK_PASS_DEPTH_FAIL: - params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.ZFailFunc[1]); - break; - case GL_STENCIL_BACK_PASS_DEPTH_PASS: - params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.ZPassFunc[1]); - break; - case GL_FRAMEBUFFER_BINDING_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Name); - break; - case GL_RENDERBUFFER_BINDING_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = INT_TO_BOOLEAN(ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0); - break; - case GL_MAX_COLOR_ATTACHMENTS_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxColorAttachments); - break; - case GL_MAX_RENDERBUFFER_SIZE_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxRenderbufferSize); - break; - case GL_READ_FRAMEBUFFER_BINDING_EXT: - CHECK_EXT1(EXT_framebuffer_blit); - params[0] = INT_TO_BOOLEAN(ctx->ReadBuffer->Name); - break; - case GL_PROVOKING_VERTEX_EXT: - CHECK_EXT1(EXT_provoking_vertex); - params[0] = ctx->Light.ProvokingVertex; - break; - case GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT: - CHECK_EXT1(EXT_provoking_vertex); - params[0] = ctx->Const.QuadsFollowProvokingVertexConvention; - break; - case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB: - CHECK_EXT1(ARB_fragment_shader); - params[0] = INT_TO_BOOLEAN(ctx->Const.FragmentProgram.MaxUniformComponents); - break; - case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB: - CHECK_EXT1(ARB_fragment_shader); - params[0] = ENUM_TO_BOOLEAN(ctx->Hint.FragmentShaderDerivative); - break; - case GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = INT_TO_BOOLEAN(ctx->Const.VertexProgram.MaxUniformComponents); - break; - case GL_MAX_VARYING_FLOATS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxVarying * 4); - break; - case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxVertexTextureImageUnits); - break; - case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxCombinedTextureImageUnits); - break; - case GL_CURRENT_PROGRAM: - CHECK_EXT1(ARB_shader_objects); - params[0] = INT_TO_BOOLEAN(ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0); - break; - case GL_MAX_SAMPLES: - CHECK_EXT1(ARB_framebuffer_object); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxSamples); - break; - case GL_VERTEX_ARRAY_BINDING_APPLE: - CHECK_EXT1(APPLE_vertex_array_object); - params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayObj->Name); - break; - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - CHECK_EXT1(ARB_seamless_cube_map); - params[0] = ctx->Texture.CubeMapSeamless; - break; - case GL_MAX_SERVER_WAIT_TIMEOUT: - CHECK_EXT1(ARB_sync); - params[0] = INT64_TO_BOOLEAN(ctx->Const.MaxServerWaitTimeout); - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: - CHECK_EXT1(EXT_transform_feedback); - params[0] = INT_TO_BOOLEAN(ctx->TransformFeedback.CurrentBuffer->Name); - break; - case GL_RASTERIZER_DISCARD: - CHECK_EXT1(EXT_transform_feedback); - params[0] = ctx->TransformFeedback.RasterDiscard; - break; - case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: - CHECK_EXT1(EXT_transform_feedback); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTransformFeedbackInterleavedComponents); - break; - case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: - CHECK_EXT1(EXT_transform_feedback); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTransformFeedbackSeparateAttribs); - break; - case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: - CHECK_EXT1(EXT_transform_feedback); - params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTransformFeedbackSeparateComponents); - break; - case GL_NUM_EXTENSIONS: - CHECK_VERSION(30); - params[0] = INT_TO_BOOLEAN(_mesa_get_extension_count(ctx)); - break; - case GL_MAJOR_VERSION: - CHECK_VERSION(30); - params[0] = INT_TO_BOOLEAN(ctx->VersionMajor); - break; - case GL_MINOR_VERSION: - CHECK_VERSION(30); - params[0] = INT_TO_BOOLEAN(ctx->VersionMinor); - break; - case GL_CONTEXT_FLAGS: - CHECK_VERSION(30); - params[0] = INT_TO_BOOLEAN(ctx->Const.ContextFlags); - break; - case GL_PRIMITIVE_RESTART: - CHECK_VERSION(31); - params[0] = ctx->Array.PrimitiveRestart; - break; - case GL_PRIMITIVE_RESTART_INDEX: - CHECK_VERSION(31); - params[0] = INT_TO_BOOLEAN(ctx->Array.RestartIndex); - break; - case GL_CONTEXT_PROFILE_MASK: - CHECK_VERSION(32); - params[0] = INT_TO_BOOLEAN(ctx->Const.ProfileMask); - break; - default: - goto invalid_enum_error; + if (unlikely(d->extra && !check_extra(ctx, func, d))) + return &error_value; + + switch (d->location) { + case LOC_BUFFER: + *p = ((char *) ctx->DrawBuffer + d->offset); + return d; + case LOC_CONTEXT: + *p = ((char *) ctx + d->offset); + return d; + case LOC_ARRAY: + *p = ((char *) ctx->Array.ArrayObj + d->offset); + return d; + case LOC_TEXUNIT: + unit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + *p = ((char *) unit + d->offset); + return d; + case LOC_CUSTOM: + find_custom_value(ctx, d, v); + *p = v; + return d; + default: + assert(0); + break; } - return; -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv(pname=0x%x)", pname); + /* silence warning */ + return &error_value; } +static const int transpose[] = { + 0, 4, 8, 12, + 1, 5, 9, 13, + 2, 6, 10, 14, + 3, 7, 11, 15 +}; + void GLAPIENTRY -_mesa_GetFloatv( GLenum pname, GLfloat *params ) +_mesa_GetBooleanv(GLenum pname, GLboolean *params) { - GET_CURRENT_CONTEXT(ctx); - const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; - ASSERT_OUTSIDE_BEGIN_END(ctx); - (void) version; + const struct value_desc *d; + union value v; + GLmatrix *m; + int shift, i; + void *p; - if (!params) - return; + d = find_value("glGetBooleanv", pname, &p, &v); + switch (d->type) { + case TYPE_INVALID: + break; + case TYPE_CONST: + params[0] = INT_TO_BOOLEAN(d->offset); + break; - if (ctx->Driver.GetFloatv && - ctx->Driver.GetFloatv(ctx, pname, params)) - return; + case TYPE_FLOAT_4: + case TYPE_FLOATN_4: + params[3] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[3]); + case TYPE_FLOAT_3: + case TYPE_FLOATN_3: + params[2] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[2]); + case TYPE_FLOAT_2: + case TYPE_FLOATN_2: + params[1] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[1]); + case TYPE_FLOAT: + case TYPE_FLOATN: + params[0] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[0]); + break; - switch (pname) { - case GL_ACCUM_RED_BITS: - params[0] = (GLfloat)(ctx->DrawBuffer->Visual.accumRedBits); - break; - case GL_ACCUM_GREEN_BITS: - params[0] = (GLfloat)(ctx->DrawBuffer->Visual.accumGreenBits); - break; - case GL_ACCUM_BLUE_BITS: - params[0] = (GLfloat)(ctx->DrawBuffer->Visual.accumBlueBits); - break; - case GL_ACCUM_ALPHA_BITS: - params[0] = (GLfloat)(ctx->DrawBuffer->Visual.accumAlphaBits); - break; - case GL_ACCUM_CLEAR_VALUE: - params[0] = ctx->Accum.ClearColor[0]; - params[1] = ctx->Accum.ClearColor[1]; - params[2] = ctx->Accum.ClearColor[2]; - params[3] = ctx->Accum.ClearColor[3]; - break; - case GL_ALPHA_BIAS: - params[0] = ctx->Pixel.AlphaBias; - break; - case GL_ALPHA_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = (GLfloat)(ctx->DrawBuffer->Visual.alphaBits); - break; - case GL_ALPHA_SCALE: - params[0] = ctx->Pixel.AlphaScale; - break; - case GL_ALPHA_TEST: - params[0] = BOOLEAN_TO_FLOAT(ctx->Color.AlphaEnabled); - break; - case GL_ALPHA_TEST_FUNC: - params[0] = ENUM_TO_FLOAT(ctx->Color.AlphaFunc); - break; - case GL_ALPHA_TEST_REF: - params[0] = ctx->Color.AlphaRef; - break; - case GL_ATTRIB_STACK_DEPTH: - params[0] = (GLfloat)(ctx->AttribStackDepth); - break; - case GL_AUTO_NORMAL: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.AutoNormal); - break; - case GL_AUX_BUFFERS: - params[0] = (GLfloat)(ctx->DrawBuffer->Visual.numAuxBuffers); - break; - case GL_BLEND: - params[0] = BOOLEAN_TO_FLOAT((ctx->Color.BlendEnabled & 1)); - break; - case GL_BLEND_DST: - params[0] = ENUM_TO_FLOAT(ctx->Color.BlendDstRGB); - break; - case GL_BLEND_SRC: - params[0] = ENUM_TO_FLOAT(ctx->Color.BlendSrcRGB); - break; - case GL_BLEND_SRC_RGB_EXT: - params[0] = ENUM_TO_FLOAT(ctx->Color.BlendSrcRGB); - break; - case GL_BLEND_DST_RGB_EXT: - params[0] = ENUM_TO_FLOAT(ctx->Color.BlendDstRGB); - break; - case GL_BLEND_SRC_ALPHA_EXT: - params[0] = ENUM_TO_FLOAT(ctx->Color.BlendSrcA); - break; - case GL_BLEND_DST_ALPHA_EXT: - params[0] = ENUM_TO_FLOAT(ctx->Color.BlendDstA); - break; - case GL_BLEND_EQUATION: - params[0] = ENUM_TO_FLOAT(ctx->Color.BlendEquationRGB ); - break; - case GL_BLEND_EQUATION_ALPHA_EXT: - params[0] = ENUM_TO_FLOAT(ctx->Color.BlendEquationA ); - break; - case GL_BLEND_COLOR_EXT: - params[0] = ctx->Color.BlendColor[0]; - params[1] = ctx->Color.BlendColor[1]; - params[2] = ctx->Color.BlendColor[2]; - params[3] = ctx->Color.BlendColor[3]; - break; - case GL_BLUE_BIAS: - params[0] = ctx->Pixel.BlueBias; - break; - case GL_BLUE_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = (GLfloat)(ctx->DrawBuffer->Visual.blueBits); - break; - case GL_BLUE_SCALE: - params[0] = ctx->Pixel.BlueScale; - break; - case GL_CLIENT_ATTRIB_STACK_DEPTH: - params[0] = (GLfloat)(ctx->ClientAttribStackDepth); - break; - case GL_CLIP_PLANE0: - params[0] = BOOLEAN_TO_FLOAT((ctx->Transform.ClipPlanesEnabled >> 0) & 1); - break; - case GL_CLIP_PLANE1: - params[0] = BOOLEAN_TO_FLOAT((ctx->Transform.ClipPlanesEnabled >> 1) & 1); - break; - case GL_CLIP_PLANE2: - params[0] = BOOLEAN_TO_FLOAT((ctx->Transform.ClipPlanesEnabled >> 2) & 1); - break; - case GL_CLIP_PLANE3: - params[0] = BOOLEAN_TO_FLOAT((ctx->Transform.ClipPlanesEnabled >> 3) & 1); - break; - case GL_CLIP_PLANE4: - params[0] = BOOLEAN_TO_FLOAT((ctx->Transform.ClipPlanesEnabled >> 4) & 1); - break; - case GL_CLIP_PLANE5: - params[0] = BOOLEAN_TO_FLOAT((ctx->Transform.ClipPlanesEnabled >> 5) & 1); - break; - case GL_COLOR_CLEAR_VALUE: - params[0] = ctx->Color.ClearColor[0]; - params[1] = ctx->Color.ClearColor[1]; - params[2] = ctx->Color.ClearColor[2]; - params[3] = ctx->Color.ClearColor[3]; - break; - case GL_COLOR_MATERIAL: - params[0] = BOOLEAN_TO_FLOAT(ctx->Light.ColorMaterialEnabled); - break; - case GL_COLOR_MATERIAL_FACE: - params[0] = ENUM_TO_FLOAT(ctx->Light.ColorMaterialFace); - break; - case GL_COLOR_MATERIAL_PARAMETER: - params[0] = ENUM_TO_FLOAT(ctx->Light.ColorMaterialMode); - break; - case GL_COLOR_WRITEMASK: - params[0] = (GLfloat)(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0); - params[1] = (GLfloat)(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0); - params[2] = (GLfloat)(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0); - params[3] = (GLfloat)(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0); - break; - case GL_CULL_FACE: - params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.CullFlag); - break; - case GL_CULL_FACE_MODE: - params[0] = ENUM_TO_FLOAT(ctx->Polygon.CullFaceMode); - break; - case GL_CURRENT_COLOR: - FLUSH_CURRENT(ctx, 0); - params[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]; - params[1] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]; - params[2] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]; - params[3] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]; - break; - case GL_CURRENT_INDEX: - FLUSH_CURRENT(ctx, 0); - params[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]; - break; - case GL_CURRENT_NORMAL: - FLUSH_CURRENT(ctx, 0); - params[0] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]; - params[1] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]; - params[2] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]; - break; - case GL_CURRENT_RASTER_COLOR: - params[0] = ctx->Current.RasterColor[0]; - params[1] = ctx->Current.RasterColor[1]; - params[2] = ctx->Current.RasterColor[2]; - params[3] = ctx->Current.RasterColor[3]; - break; - case GL_CURRENT_RASTER_DISTANCE: - params[0] = ctx->Current.RasterDistance; - break; - case GL_CURRENT_RASTER_INDEX: - params[0] = 1.0; - break; - case GL_CURRENT_RASTER_POSITION: - params[0] = ctx->Current.RasterPos[0]; - params[1] = ctx->Current.RasterPos[1]; - params[2] = ctx->Current.RasterPos[2]; - params[3] = ctx->Current.RasterPos[3]; - break; - case GL_CURRENT_RASTER_SECONDARY_COLOR: - params[0] = ctx->Current.RasterSecondaryColor[0]; - params[1] = ctx->Current.RasterSecondaryColor[1]; - params[2] = ctx->Current.RasterSecondaryColor[2]; - params[3] = ctx->Current.RasterSecondaryColor[3]; - break; - case GL_CURRENT_RASTER_TEXTURE_COORDS: - { - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(raster tex coords, unit %u)", unit); - return; - } - params[0] = ctx->Current.RasterTexCoords[unit][0]; - params[1] = ctx->Current.RasterTexCoords[unit][1]; - params[2] = ctx->Current.RasterTexCoords[unit][2]; - params[3] = ctx->Current.RasterTexCoords[unit][3]; - } - break; - case GL_CURRENT_RASTER_POSITION_VALID: - params[0] = BOOLEAN_TO_FLOAT(ctx->Current.RasterPosValid); - break; - case GL_CURRENT_TEXTURE_COORDS: - { - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(current tex coords, unit %u)", unit); - return; - } - FLUSH_CURRENT(ctx, 0); - params[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]; - params[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]; - params[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2]; - params[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3]; - } - break; - case GL_DEPTH_BIAS: - params[0] = ctx->Pixel.DepthBias; - break; - case GL_DEPTH_BITS: - params[0] = (GLfloat)(ctx->DrawBuffer->Visual.depthBits); - break; - case GL_DEPTH_CLEAR_VALUE: - params[0] = ((GLfloat) ctx->Depth.Clear); - break; - case GL_DEPTH_FUNC: - params[0] = ENUM_TO_FLOAT(ctx->Depth.Func); - break; - case GL_DEPTH_RANGE: - params[0] = ctx->Viewport.Near; - params[1] = ctx->Viewport.Far; - break; - case GL_DEPTH_SCALE: - params[0] = ctx->Pixel.DepthScale; - break; - case GL_DEPTH_TEST: - params[0] = BOOLEAN_TO_FLOAT(ctx->Depth.Test); - break; - case GL_DEPTH_WRITEMASK: - params[0] = BOOLEAN_TO_FLOAT(ctx->Depth.Mask); - break; - case GL_DITHER: - params[0] = BOOLEAN_TO_FLOAT(ctx->Color.DitherFlag); - break; - case GL_DOUBLEBUFFER: - params[0] = BOOLEAN_TO_FLOAT(ctx->DrawBuffer->Visual.doubleBufferMode); - break; - case GL_DRAW_BUFFER: - params[0] = ENUM_TO_FLOAT(ctx->DrawBuffer->ColorDrawBuffer[0]); - break; - case GL_EDGE_FLAG: - FLUSH_CURRENT(ctx, 0); - params[0] = BOOLEAN_TO_FLOAT((ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0)); - break; - case GL_FEEDBACK_BUFFER_SIZE: - params[0] = (GLfloat)(ctx->Feedback.BufferSize); - break; - case GL_FEEDBACK_BUFFER_TYPE: - params[0] = ENUM_TO_FLOAT(ctx->Feedback.Type); - break; - case GL_FOG: - params[0] = BOOLEAN_TO_FLOAT(ctx->Fog.Enabled); - break; - case GL_FOG_COLOR: - params[0] = ctx->Fog.Color[0]; - params[1] = ctx->Fog.Color[1]; - params[2] = ctx->Fog.Color[2]; - params[3] = ctx->Fog.Color[3]; - break; - case GL_FOG_DENSITY: - params[0] = ctx->Fog.Density; - break; - case GL_FOG_END: - params[0] = ctx->Fog.End; - break; - case GL_FOG_HINT: - params[0] = ENUM_TO_FLOAT(ctx->Hint.Fog); - break; - case GL_FOG_INDEX: - params[0] = ctx->Fog.Index; - break; - case GL_FOG_MODE: - params[0] = ENUM_TO_FLOAT(ctx->Fog.Mode); - break; - case GL_FOG_START: - params[0] = ctx->Fog.Start; - break; - case GL_FRONT_FACE: - params[0] = ENUM_TO_FLOAT(ctx->Polygon.FrontFace); - break; - case GL_GREEN_BIAS: - params[0] = ctx->Pixel.GreenBias; - break; - case GL_GREEN_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = (GLfloat)(ctx->DrawBuffer->Visual.greenBits); - break; - case GL_GREEN_SCALE: - params[0] = ctx->Pixel.GreenScale; - break; - case GL_INDEX_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = (GLfloat)(ctx->DrawBuffer->Visual.indexBits); - break; - case GL_INDEX_CLEAR_VALUE: - params[0] = (GLfloat)(ctx->Color.ClearIndex); - break; - case GL_INDEX_MODE: - params[0] = BOOLEAN_TO_FLOAT(GL_FALSE); - break; - case GL_INDEX_OFFSET: - params[0] = (GLfloat)(ctx->Pixel.IndexOffset); - break; - case GL_INDEX_SHIFT: - params[0] = (GLfloat)(ctx->Pixel.IndexShift); - break; - case GL_INDEX_WRITEMASK: - params[0] = (GLfloat)(ctx->Color.IndexMask); - break; - case GL_LIGHT0: - params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[0].Enabled); - break; - case GL_LIGHT1: - params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[1].Enabled); - break; - case GL_LIGHT2: - params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[2].Enabled); - break; - case GL_LIGHT3: - params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[3].Enabled); - break; - case GL_LIGHT4: - params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[4].Enabled); - break; - case GL_LIGHT5: - params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[5].Enabled); - break; - case GL_LIGHT6: - params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[6].Enabled); - break; - case GL_LIGHT7: - params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[7].Enabled); - break; - case GL_LIGHTING: - params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Enabled); - break; - case GL_LIGHT_MODEL_AMBIENT: - params[0] = ctx->Light.Model.Ambient[0]; - params[1] = ctx->Light.Model.Ambient[1]; - params[2] = ctx->Light.Model.Ambient[2]; - params[3] = ctx->Light.Model.Ambient[3]; - break; - case GL_LIGHT_MODEL_COLOR_CONTROL: - params[0] = ENUM_TO_FLOAT(ctx->Light.Model.ColorControl); - break; - case GL_LIGHT_MODEL_LOCAL_VIEWER: - params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Model.LocalViewer); - break; - case GL_LIGHT_MODEL_TWO_SIDE: - params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Model.TwoSide); - break; - case GL_LINE_SMOOTH: - params[0] = BOOLEAN_TO_FLOAT(ctx->Line.SmoothFlag); - break; - case GL_LINE_SMOOTH_HINT: - params[0] = ENUM_TO_FLOAT(ctx->Hint.LineSmooth); - break; - case GL_LINE_STIPPLE: - params[0] = BOOLEAN_TO_FLOAT(ctx->Line.StippleFlag); - break; - case GL_LINE_STIPPLE_PATTERN: - params[0] = (GLfloat)(ctx->Line.StipplePattern); - break; - case GL_LINE_STIPPLE_REPEAT: - params[0] = (GLfloat)(ctx->Line.StippleFactor); - break; - case GL_LINE_WIDTH: - params[0] = ctx->Line.Width; - break; - case GL_LINE_WIDTH_GRANULARITY: - params[0] = ctx->Const.LineWidthGranularity; - break; - case GL_LINE_WIDTH_RANGE: - params[0] = ctx->Const.MinLineWidthAA; - params[1] = ctx->Const.MaxLineWidthAA; - break; - case GL_ALIASED_LINE_WIDTH_RANGE: - params[0] = ctx->Const.MinLineWidth; - params[1] = ctx->Const.MaxLineWidth; - break; - case GL_LIST_BASE: - params[0] = (GLfloat)(ctx->List.ListBase); - break; - case GL_LIST_INDEX: - params[0] = (GLfloat)((ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0)); - break; - case GL_LIST_MODE: - { - GLenum mode; - if (!ctx->CompileFlag) - mode = 0; - else if (ctx->ExecuteFlag) - mode = GL_COMPILE_AND_EXECUTE; - else - mode = GL_COMPILE; - params[0] = ENUM_TO_FLOAT(mode); - } - break; - case GL_INDEX_LOGIC_OP: - params[0] = BOOLEAN_TO_FLOAT(ctx->Color.IndexLogicOpEnabled); - break; - case GL_COLOR_LOGIC_OP: - params[0] = BOOLEAN_TO_FLOAT(ctx->Color.ColorLogicOpEnabled); - break; - case GL_LOGIC_OP_MODE: - params[0] = ENUM_TO_FLOAT(ctx->Color.LogicOp); - break; - case GL_MAP1_COLOR_4: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Color4); - break; - case GL_MAP1_GRID_DOMAIN: - params[0] = ctx->Eval.MapGrid1u1; - params[1] = ctx->Eval.MapGrid1u2; - break; - case GL_MAP1_GRID_SEGMENTS: - params[0] = (GLfloat)(ctx->Eval.MapGrid1un); - break; - case GL_MAP1_INDEX: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Index); - break; - case GL_MAP1_NORMAL: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Normal); - break; - case GL_MAP1_TEXTURE_COORD_1: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1TextureCoord1); - break; - case GL_MAP1_TEXTURE_COORD_2: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1TextureCoord2); - break; - case GL_MAP1_TEXTURE_COORD_3: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1TextureCoord3); - break; - case GL_MAP1_TEXTURE_COORD_4: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1TextureCoord4); - break; - case GL_MAP1_VERTEX_3: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Vertex3); - break; - case GL_MAP1_VERTEX_4: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Vertex4); - break; - case GL_MAP2_COLOR_4: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2Color4); - break; - case GL_MAP2_GRID_DOMAIN: - params[0] = ctx->Eval.MapGrid2u1; - params[1] = ctx->Eval.MapGrid2u2; - params[2] = ctx->Eval.MapGrid2v1; - params[3] = ctx->Eval.MapGrid2v2; - break; - case GL_MAP2_GRID_SEGMENTS: - params[0] = (GLfloat)(ctx->Eval.MapGrid2un); - params[1] = (GLfloat)(ctx->Eval.MapGrid2vn); - break; - case GL_MAP2_INDEX: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2Index); - break; - case GL_MAP2_NORMAL: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2Normal); - break; - case GL_MAP2_TEXTURE_COORD_1: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2TextureCoord1); - break; - case GL_MAP2_TEXTURE_COORD_2: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2TextureCoord2); - break; - case GL_MAP2_TEXTURE_COORD_3: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2TextureCoord3); - break; - case GL_MAP2_TEXTURE_COORD_4: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2TextureCoord4); - break; - case GL_MAP2_VERTEX_3: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2Vertex3); - break; - case GL_MAP2_VERTEX_4: - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2Vertex4); - break; - case GL_MAP_COLOR: - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.MapColorFlag); - break; - case GL_MAP_STENCIL: - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.MapStencilFlag); - break; - case GL_MATRIX_MODE: - params[0] = ENUM_TO_FLOAT(ctx->Transform.MatrixMode); - break; - case GL_MAX_ATTRIB_STACK_DEPTH: - params[0] = (GLfloat)(MAX_ATTRIB_STACK_DEPTH); - break; - case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH: - params[0] = (GLfloat)(MAX_CLIENT_ATTRIB_STACK_DEPTH); - break; - case GL_MAX_CLIP_PLANES: - params[0] = (GLfloat)(ctx->Const.MaxClipPlanes); - break; - case GL_MAX_ELEMENTS_VERTICES: - params[0] = (GLfloat)(ctx->Const.MaxArrayLockSize); - break; - case GL_MAX_ELEMENTS_INDICES: - params[0] = (GLfloat)(ctx->Const.MaxArrayLockSize); - break; - case GL_MAX_EVAL_ORDER: - params[0] = (GLfloat)(MAX_EVAL_ORDER); - break; - case GL_MAX_LIGHTS: - params[0] = (GLfloat)(ctx->Const.MaxLights); - break; - case GL_MAX_LIST_NESTING: - params[0] = (GLfloat)(MAX_LIST_NESTING); - break; - case GL_MAX_MODELVIEW_STACK_DEPTH: - params[0] = (GLfloat)(MAX_MODELVIEW_STACK_DEPTH); - break; - case GL_MAX_NAME_STACK_DEPTH: - params[0] = (GLfloat)(MAX_NAME_STACK_DEPTH); - break; - case GL_MAX_PIXEL_MAP_TABLE: - params[0] = (GLfloat)(MAX_PIXEL_MAP_TABLE); - break; - case GL_MAX_PROJECTION_STACK_DEPTH: - params[0] = (GLfloat)(MAX_PROJECTION_STACK_DEPTH); - break; - case GL_MAX_TEXTURE_SIZE: - params[0] = (GLfloat)(1 << (ctx->Const.MaxTextureLevels - 1)); - break; - case GL_MAX_3D_TEXTURE_SIZE: - params[0] = (GLfloat)(1 << (ctx->Const.Max3DTextureLevels - 1)); - break; - case GL_MAX_TEXTURE_STACK_DEPTH: - params[0] = (GLfloat)(MAX_TEXTURE_STACK_DEPTH); - break; - case GL_MAX_VIEWPORT_DIMS: - params[0] = (GLfloat)(ctx->Const.MaxViewportWidth); - params[1] = (GLfloat)(ctx->Const.MaxViewportHeight); - break; - case GL_MODELVIEW_MATRIX: - { - const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m; - params[0] = matrix[0]; - params[1] = matrix[1]; - params[2] = matrix[2]; - params[3] = matrix[3]; - params[4] = matrix[4]; - params[5] = matrix[5]; - params[6] = matrix[6]; - params[7] = matrix[7]; - params[8] = matrix[8]; - params[9] = matrix[9]; - params[10] = matrix[10]; - params[11] = matrix[11]; - params[12] = matrix[12]; - params[13] = matrix[13]; - params[14] = matrix[14]; - params[15] = matrix[15]; - } - break; - case GL_MODELVIEW_STACK_DEPTH: - params[0] = (GLfloat)(ctx->ModelviewMatrixStack.Depth + 1); - break; - case GL_NAME_STACK_DEPTH: - params[0] = (GLfloat)(ctx->Select.NameStackDepth); - break; - case GL_NORMALIZE: - params[0] = BOOLEAN_TO_FLOAT(ctx->Transform.Normalize); - break; - case GL_PACK_ALIGNMENT: - params[0] = (GLfloat)(ctx->Pack.Alignment); - break; - case GL_PACK_LSB_FIRST: - params[0] = BOOLEAN_TO_FLOAT(ctx->Pack.LsbFirst); - break; - case GL_PACK_ROW_LENGTH: - params[0] = (GLfloat)(ctx->Pack.RowLength); - break; - case GL_PACK_SKIP_PIXELS: - params[0] = (GLfloat)(ctx->Pack.SkipPixels); - break; - case GL_PACK_SKIP_ROWS: - params[0] = (GLfloat)(ctx->Pack.SkipRows); - break; - case GL_PACK_SWAP_BYTES: - params[0] = BOOLEAN_TO_FLOAT(ctx->Pack.SwapBytes); - break; - case GL_PACK_SKIP_IMAGES_EXT: - params[0] = (GLfloat)(ctx->Pack.SkipImages); - break; - case GL_PACK_IMAGE_HEIGHT_EXT: - params[0] = (GLfloat)(ctx->Pack.ImageHeight); - break; - case GL_PACK_INVERT_MESA: - params[0] = BOOLEAN_TO_FLOAT(ctx->Pack.Invert); - break; - case GL_PERSPECTIVE_CORRECTION_HINT: - params[0] = ENUM_TO_FLOAT(ctx->Hint.PerspectiveCorrection); - break; - case GL_PIXEL_MAP_A_TO_A_SIZE: - params[0] = (GLfloat)(ctx->PixelMaps.AtoA.Size); - break; - case GL_PIXEL_MAP_B_TO_B_SIZE: - params[0] = (GLfloat)(ctx->PixelMaps.BtoB.Size); - break; - case GL_PIXEL_MAP_G_TO_G_SIZE: - params[0] = (GLfloat)(ctx->PixelMaps.GtoG.Size); - break; - case GL_PIXEL_MAP_I_TO_A_SIZE: - params[0] = (GLfloat)(ctx->PixelMaps.ItoA.Size); - break; - case GL_PIXEL_MAP_I_TO_B_SIZE: - params[0] = (GLfloat)(ctx->PixelMaps.ItoB.Size); - break; - case GL_PIXEL_MAP_I_TO_G_SIZE: - params[0] = (GLfloat)(ctx->PixelMaps.ItoG.Size); - break; - case GL_PIXEL_MAP_I_TO_I_SIZE: - params[0] = (GLfloat)(ctx->PixelMaps.ItoI.Size); - break; - case GL_PIXEL_MAP_I_TO_R_SIZE: - params[0] = (GLfloat)(ctx->PixelMaps.ItoR.Size); - break; - case GL_PIXEL_MAP_R_TO_R_SIZE: - params[0] = (GLfloat)(ctx->PixelMaps.RtoR.Size); - break; - case GL_PIXEL_MAP_S_TO_S_SIZE: - params[0] = (GLfloat)(ctx->PixelMaps.StoS.Size); - break; - case GL_POINT_SIZE: - params[0] = ctx->Point.Size; - break; - case GL_POINT_SIZE_GRANULARITY: - params[0] = ctx->Const.PointSizeGranularity; - break; - case GL_POINT_SIZE_RANGE: - params[0] = ctx->Const.MinPointSizeAA; - params[1] = ctx->Const.MaxPointSizeAA; - break; - case GL_ALIASED_POINT_SIZE_RANGE: - params[0] = ctx->Const.MinPointSize; - params[1] = ctx->Const.MaxPointSize; - break; - case GL_POINT_SMOOTH: - params[0] = BOOLEAN_TO_FLOAT(ctx->Point.SmoothFlag); - break; - case GL_POINT_SMOOTH_HINT: - params[0] = ENUM_TO_FLOAT(ctx->Hint.PointSmooth); - break; - case GL_POINT_SIZE_MIN_EXT: - params[0] = ctx->Point.MinSize; - break; - case GL_POINT_SIZE_MAX_EXT: - params[0] = ctx->Point.MaxSize; - break; - case GL_POINT_FADE_THRESHOLD_SIZE_EXT: - params[0] = ctx->Point.Threshold; - break; - case GL_DISTANCE_ATTENUATION_EXT: - params[0] = ctx->Point.Params[0]; - params[1] = ctx->Point.Params[1]; - params[2] = ctx->Point.Params[2]; - break; - case GL_POLYGON_MODE: - params[0] = ENUM_TO_FLOAT(ctx->Polygon.FrontMode); - params[1] = ENUM_TO_FLOAT(ctx->Polygon.BackMode); - break; - case GL_POLYGON_OFFSET_BIAS_EXT: - params[0] = ctx->Polygon.OffsetUnits; - break; - case GL_POLYGON_OFFSET_FACTOR: - params[0] = ctx->Polygon.OffsetFactor ; - break; - case GL_POLYGON_OFFSET_UNITS: - params[0] = ctx->Polygon.OffsetUnits ; - break; - case GL_POLYGON_OFFSET_POINT: - params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.OffsetPoint); - break; - case GL_POLYGON_OFFSET_LINE: - params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.OffsetLine); - break; - case GL_POLYGON_OFFSET_FILL: - params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.OffsetFill); - break; - case GL_POLYGON_SMOOTH: - params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.SmoothFlag); - break; - case GL_POLYGON_SMOOTH_HINT: - params[0] = ENUM_TO_FLOAT(ctx->Hint.PolygonSmooth); - break; - case GL_POLYGON_STIPPLE: - params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.StippleFlag); - break; - case GL_PROJECTION_MATRIX: - { - const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m; - params[0] = matrix[0]; - params[1] = matrix[1]; - params[2] = matrix[2]; - params[3] = matrix[3]; - params[4] = matrix[4]; - params[5] = matrix[5]; - params[6] = matrix[6]; - params[7] = matrix[7]; - params[8] = matrix[8]; - params[9] = matrix[9]; - params[10] = matrix[10]; - params[11] = matrix[11]; - params[12] = matrix[12]; - params[13] = matrix[13]; - params[14] = matrix[14]; - params[15] = matrix[15]; - } - break; - case GL_PROJECTION_STACK_DEPTH: - params[0] = (GLfloat)(ctx->ProjectionMatrixStack.Depth + 1); - break; - case GL_READ_BUFFER: - params[0] = ENUM_TO_FLOAT(ctx->ReadBuffer->ColorReadBuffer); - break; - case GL_RED_BIAS: - params[0] = ctx->Pixel.RedBias; - break; - case GL_RED_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = (GLfloat)(ctx->DrawBuffer->Visual.redBits); - break; - case GL_RED_SCALE: - params[0] = ctx->Pixel.RedScale; - break; - case GL_RENDER_MODE: - params[0] = ENUM_TO_FLOAT(ctx->RenderMode); - break; - case GL_RESCALE_NORMAL: - params[0] = BOOLEAN_TO_FLOAT(ctx->Transform.RescaleNormals); - break; - case GL_RGBA_MODE: - params[0] = BOOLEAN_TO_FLOAT(GL_TRUE); - break; - case GL_SCISSOR_BOX: - params[0] = (GLfloat)(ctx->Scissor.X); - params[1] = (GLfloat)(ctx->Scissor.Y); - params[2] = (GLfloat)(ctx->Scissor.Width); - params[3] = (GLfloat)(ctx->Scissor.Height); - break; - case GL_SCISSOR_TEST: - params[0] = BOOLEAN_TO_FLOAT(ctx->Scissor.Enabled); - break; - case GL_SELECTION_BUFFER_SIZE: - params[0] = (GLfloat)(ctx->Select.BufferSize); - break; - case GL_SHADE_MODEL: - params[0] = ENUM_TO_FLOAT(ctx->Light.ShadeModel); - break; - case GL_SHARED_TEXTURE_PALETTE_EXT: - params[0] = BOOLEAN_TO_FLOAT(ctx->Texture.SharedPalette); - break; - case GL_STENCIL_BITS: - params[0] = (GLfloat)(ctx->DrawBuffer->Visual.stencilBits); - break; - case GL_STENCIL_CLEAR_VALUE: - params[0] = (GLfloat)(ctx->Stencil.Clear); - break; - case GL_STENCIL_FAIL: - params[0] = ENUM_TO_FLOAT(ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_FUNC: - params[0] = ENUM_TO_FLOAT(ctx->Stencil.Function[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_PASS_DEPTH_FAIL: - params[0] = ENUM_TO_FLOAT(ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_PASS_DEPTH_PASS: - params[0] = ENUM_TO_FLOAT(ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_REF: - params[0] = (GLfloat)(ctx->Stencil.Ref[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_TEST: - params[0] = BOOLEAN_TO_FLOAT(ctx->Stencil.Enabled); - break; - case GL_STENCIL_VALUE_MASK: - params[0] = (GLfloat)(ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_WRITEMASK: - params[0] = (GLfloat)(ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]); - break; - case GL_STEREO: - params[0] = BOOLEAN_TO_FLOAT(ctx->DrawBuffer->Visual.stereoMode); - break; - case GL_SUBPIXEL_BITS: - params[0] = (GLfloat)(ctx->Const.SubPixelBits); - break; - case GL_TEXTURE_1D: - params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_1D)); - break; - case GL_TEXTURE_2D: - params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_2D)); - break; - case GL_TEXTURE_3D: - params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_3D)); - break; - case GL_TEXTURE_1D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_1D_ARRAY_EXT)); - break; - case GL_TEXTURE_2D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_2D_ARRAY_EXT)); - break; - case GL_TEXTURE_BINDING_1D: - params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_INDEX]->Name); - break; - case GL_TEXTURE_BINDING_2D: - params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name); - break; - case GL_TEXTURE_BINDING_3D: - params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name); - break; - case GL_TEXTURE_BINDING_1D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_ARRAY_INDEX]->Name); - break; - case GL_TEXTURE_BINDING_2D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name); - break; - case GL_MAX_ARRAY_TEXTURE_LAYERS_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = (GLfloat)(ctx->Const.MaxArrayTextureLayers); - break; - case GL_TEXTURE_GEN_S: - params[0] = BOOLEAN_TO_FLOAT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)); - break; - case GL_TEXTURE_GEN_T: - params[0] = BOOLEAN_TO_FLOAT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0)); - break; - case GL_TEXTURE_GEN_R: - params[0] = BOOLEAN_TO_FLOAT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0)); - break; - case GL_TEXTURE_GEN_Q: - params[0] = BOOLEAN_TO_FLOAT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & Q_BIT) ? 1 : 0)); - break; - case GL_TEXTURE_MATRIX: - { - const GLfloat *matrix; - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGet(texture matrix %u)", - unit); - return; - } - matrix = ctx->TextureMatrixStack[unit].Top->m; - params[0] = matrix[0]; - params[1] = matrix[1]; - params[2] = matrix[2]; - params[3] = matrix[3]; - params[4] = matrix[4]; - params[5] = matrix[5]; - params[6] = matrix[6]; - params[7] = matrix[7]; - params[8] = matrix[8]; - params[9] = matrix[9]; - params[10] = matrix[10]; - params[11] = matrix[11]; - params[12] = matrix[12]; - params[13] = matrix[13]; - params[14] = matrix[14]; - params[15] = matrix[15]; - } - break; - case GL_TEXTURE_STACK_DEPTH: - { - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(texture stack depth, unit %u)", unit); - return; - } - params[0] = (GLfloat)(ctx->TextureMatrixStack[unit].Depth + 1); - } - break; - case GL_UNPACK_ALIGNMENT: - params[0] = (GLfloat)(ctx->Unpack.Alignment); - break; - case GL_UNPACK_LSB_FIRST: - params[0] = BOOLEAN_TO_FLOAT(ctx->Unpack.LsbFirst); - break; - case GL_UNPACK_ROW_LENGTH: - params[0] = (GLfloat)(ctx->Unpack.RowLength); - break; - case GL_UNPACK_SKIP_PIXELS: - params[0] = (GLfloat)(ctx->Unpack.SkipPixels); - break; - case GL_UNPACK_SKIP_ROWS: - params[0] = (GLfloat)(ctx->Unpack.SkipRows); - break; - case GL_UNPACK_SWAP_BYTES: - params[0] = BOOLEAN_TO_FLOAT(ctx->Unpack.SwapBytes); - break; - case GL_UNPACK_SKIP_IMAGES_EXT: - params[0] = (GLfloat)(ctx->Unpack.SkipImages); - break; - case GL_UNPACK_IMAGE_HEIGHT_EXT: - params[0] = (GLfloat)(ctx->Unpack.ImageHeight); - break; - case GL_UNPACK_CLIENT_STORAGE_APPLE: - params[0] = BOOLEAN_TO_FLOAT(ctx->Unpack.ClientStorage); - break; - case GL_VIEWPORT: - params[0] = (GLfloat)(ctx->Viewport.X); - params[1] = (GLfloat)(ctx->Viewport.Y); - params[2] = (GLfloat)(ctx->Viewport.Width); - params[3] = (GLfloat)(ctx->Viewport.Height); - break; - case GL_ZOOM_X: - params[0] = ctx->Pixel.ZoomX; - break; - case GL_ZOOM_Y: - params[0] = ctx->Pixel.ZoomY; - break; - case GL_VERTEX_ARRAY: - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->Vertex.Enabled); - break; - case GL_VERTEX_ARRAY_SIZE: - params[0] = (GLfloat)(ctx->Array.ArrayObj->Vertex.Size); - break; - case GL_VERTEX_ARRAY_TYPE: - params[0] = ENUM_TO_FLOAT(ctx->Array.ArrayObj->Vertex.Type); - break; - case GL_VERTEX_ARRAY_STRIDE: - params[0] = (GLfloat)(ctx->Array.ArrayObj->Vertex.Stride); - break; - case GL_VERTEX_ARRAY_COUNT_EXT: - params[0] = (GLfloat)(0); - break; - case GL_NORMAL_ARRAY: - params[0] = ENUM_TO_FLOAT(ctx->Array.ArrayObj->Normal.Enabled); - break; - case GL_NORMAL_ARRAY_TYPE: - params[0] = ENUM_TO_FLOAT(ctx->Array.ArrayObj->Normal.Type); - break; - case GL_NORMAL_ARRAY_STRIDE: - params[0] = (GLfloat)(ctx->Array.ArrayObj->Normal.Stride); - break; - case GL_NORMAL_ARRAY_COUNT_EXT: - params[0] = (GLfloat)(0); - break; - case GL_COLOR_ARRAY: - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->Color.Enabled); - break; - case GL_COLOR_ARRAY_SIZE: - params[0] = (GLfloat)(ctx->Array.ArrayObj->Color.Size); - break; - case GL_COLOR_ARRAY_TYPE: - params[0] = ENUM_TO_FLOAT(ctx->Array.ArrayObj->Color.Type); - break; - case GL_COLOR_ARRAY_STRIDE: - params[0] = (GLfloat)(ctx->Array.ArrayObj->Color.Stride); - break; - case GL_COLOR_ARRAY_COUNT_EXT: - params[0] = (GLfloat)(0); - break; - case GL_INDEX_ARRAY: - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->Index.Enabled); - break; - case GL_INDEX_ARRAY_TYPE: - params[0] = ENUM_TO_FLOAT(ctx->Array.ArrayObj->Index.Type); - break; - case GL_INDEX_ARRAY_STRIDE: - params[0] = (GLfloat)(ctx->Array.ArrayObj->Index.Stride); - break; - case GL_INDEX_ARRAY_COUNT_EXT: - params[0] = (GLfloat)(0); - break; - case GL_TEXTURE_COORD_ARRAY: - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled); - break; - case GL_TEXTURE_COORD_ARRAY_SIZE: - params[0] = (GLfloat)(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size); - break; - case GL_TEXTURE_COORD_ARRAY_TYPE: - params[0] = ENUM_TO_FLOAT(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Type); - break; - case GL_TEXTURE_COORD_ARRAY_STRIDE: - params[0] = (GLfloat)(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride); - break; - case GL_TEXTURE_COORD_ARRAY_COUNT_EXT: - params[0] = (GLfloat)(0); - break; - case GL_EDGE_FLAG_ARRAY: - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->EdgeFlag.Enabled); - break; - case GL_EDGE_FLAG_ARRAY_STRIDE: - params[0] = (GLfloat)(ctx->Array.ArrayObj->EdgeFlag.Stride); - break; - case GL_EDGE_FLAG_ARRAY_COUNT_EXT: - params[0] = (GLfloat)(0); - break; - case GL_MAX_TEXTURE_UNITS_ARB: - CHECK_EXT1(ARB_multitexture); - params[0] = (GLfloat)(ctx->Const.MaxTextureUnits); - break; - case GL_ACTIVE_TEXTURE_ARB: - CHECK_EXT1(ARB_multitexture); - params[0] = (GLfloat)(GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit); - break; - case GL_CLIENT_ACTIVE_TEXTURE_ARB: - CHECK_EXT1(ARB_multitexture); - params[0] = (GLfloat)(GL_TEXTURE0_ARB + ctx->Array.ActiveTexture); - break; - case GL_TEXTURE_CUBE_MAP_ARB: - CHECK_EXT1(ARB_texture_cube_map); - params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB)); - break; - case GL_TEXTURE_BINDING_CUBE_MAP_ARB: - CHECK_EXT1(ARB_texture_cube_map); - params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_CUBE_INDEX]->Name); - break; - case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: - CHECK_EXT1(ARB_texture_cube_map); - params[0] = (GLfloat)((1 << (ctx->Const.MaxCubeTextureLevels - 1))); - break; - case GL_TEXTURE_COMPRESSION_HINT_ARB: - params[0] = (GLfloat)(ctx->Hint.TextureCompression); - break; - case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: - params[0] = (GLfloat)(_mesa_get_compressed_formats(ctx, NULL, GL_FALSE)); - break; - case GL_COMPRESSED_TEXTURE_FORMATS_ARB: - { - GLint formats[100]; - GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE); - ASSERT(n <= 100); - for (i = 0; i < n; i++) - params[i] = ENUM_TO_FLOAT(formats[i]); - } - break; - case GL_ARRAY_ELEMENT_LOCK_FIRST_EXT: - CHECK_EXT1(EXT_compiled_vertex_array); - params[0] = (GLfloat)(ctx->Array.LockFirst); - break; - case GL_ARRAY_ELEMENT_LOCK_COUNT_EXT: - CHECK_EXT1(EXT_compiled_vertex_array); - params[0] = (GLfloat)(ctx->Array.LockCount); - break; - case GL_TRANSPOSE_COLOR_MATRIX_ARB: - { - const GLfloat *matrix = ctx->ColorMatrixStack.Top->m; - params[0] = matrix[0]; - params[1] = matrix[4]; - params[2] = matrix[8]; - params[3] = matrix[12]; - params[4] = matrix[1]; - params[5] = matrix[5]; - params[6] = matrix[9]; - params[7] = matrix[13]; - params[8] = matrix[2]; - params[9] = matrix[6]; - params[10] = matrix[10]; - params[11] = matrix[14]; - params[12] = matrix[3]; - params[13] = matrix[7]; - params[14] = matrix[11]; - params[15] = matrix[15]; - } - break; - case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB: - { - const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m; - params[0] = matrix[0]; - params[1] = matrix[4]; - params[2] = matrix[8]; - params[3] = matrix[12]; - params[4] = matrix[1]; - params[5] = matrix[5]; - params[6] = matrix[9]; - params[7] = matrix[13]; - params[8] = matrix[2]; - params[9] = matrix[6]; - params[10] = matrix[10]; - params[11] = matrix[14]; - params[12] = matrix[3]; - params[13] = matrix[7]; - params[14] = matrix[11]; - params[15] = matrix[15]; - } - break; - case GL_TRANSPOSE_PROJECTION_MATRIX_ARB: - { - const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m; - params[0] = matrix[0]; - params[1] = matrix[4]; - params[2] = matrix[8]; - params[3] = matrix[12]; - params[4] = matrix[1]; - params[5] = matrix[5]; - params[6] = matrix[9]; - params[7] = matrix[13]; - params[8] = matrix[2]; - params[9] = matrix[6]; - params[10] = matrix[10]; - params[11] = matrix[14]; - params[12] = matrix[3]; - params[13] = matrix[7]; - params[14] = matrix[11]; - params[15] = matrix[15]; - } - break; - case GL_TRANSPOSE_TEXTURE_MATRIX_ARB: - { - const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m; - params[0] = matrix[0]; - params[1] = matrix[4]; - params[2] = matrix[8]; - params[3] = matrix[12]; - params[4] = matrix[1]; - params[5] = matrix[5]; - params[6] = matrix[9]; - params[7] = matrix[13]; - params[8] = matrix[2]; - params[9] = matrix[6]; - params[10] = matrix[10]; - params[11] = matrix[14]; - params[12] = matrix[3]; - params[13] = matrix[7]; - params[14] = matrix[11]; - params[15] = matrix[15]; - } - break; - case GL_COLOR_MATRIX_SGI: - { - const GLfloat *matrix = ctx->ColorMatrixStack.Top->m; - params[0] = matrix[0]; - params[1] = matrix[1]; - params[2] = matrix[2]; - params[3] = matrix[3]; - params[4] = matrix[4]; - params[5] = matrix[5]; - params[6] = matrix[6]; - params[7] = matrix[7]; - params[8] = matrix[8]; - params[9] = matrix[9]; - params[10] = matrix[10]; - params[11] = matrix[11]; - params[12] = matrix[12]; - params[13] = matrix[13]; - params[14] = matrix[14]; - params[15] = matrix[15]; - } - break; - case GL_COLOR_MATRIX_STACK_DEPTH_SGI: - params[0] = (GLfloat)(ctx->ColorMatrixStack.Depth + 1); - break; - case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: - params[0] = (GLfloat)(MAX_COLOR_STACK_DEPTH); - break; - case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: - params[0] = ctx->Pixel.PostColorMatrixScale[0]; - break; - case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: - params[0] = ctx->Pixel.PostColorMatrixScale[1]; - break; - case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: - params[0] = ctx->Pixel.PostColorMatrixScale[2]; - break; - case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: - params[0] = ctx->Pixel.PostColorMatrixScale[3]; - break; - case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: - params[0] = ctx->Pixel.PostColorMatrixBias[0]; - break; - case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: - params[0] = ctx->Pixel.PostColorMatrixBias[1]; - break; - case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: - params[0] = ctx->Pixel.PostColorMatrixBias[2]; - break; - case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: - params[0] = ctx->Pixel.PostColorMatrixBias[3]; - break; - case GL_CONVOLUTION_1D_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.Convolution1DEnabled); - break; - case GL_CONVOLUTION_2D_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.Convolution2DEnabled); - break; - case GL_SEPARABLE_2D_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.Separable2DEnabled); - break; - case GL_POST_CONVOLUTION_RED_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = ctx->Pixel.PostConvolutionScale[0]; - break; - case GL_POST_CONVOLUTION_GREEN_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = ctx->Pixel.PostConvolutionScale[1]; - break; - case GL_POST_CONVOLUTION_BLUE_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = ctx->Pixel.PostConvolutionScale[2]; - break; - case GL_POST_CONVOLUTION_ALPHA_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = ctx->Pixel.PostConvolutionScale[3]; - break; - case GL_POST_CONVOLUTION_RED_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = ctx->Pixel.PostConvolutionBias[0]; - break; - case GL_POST_CONVOLUTION_GREEN_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = ctx->Pixel.PostConvolutionBias[1]; - break; - case GL_POST_CONVOLUTION_BLUE_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = ctx->Pixel.PostConvolutionBias[2]; - break; - case GL_POST_CONVOLUTION_ALPHA_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = ctx->Pixel.PostConvolutionBias[3]; - break; - case GL_HISTOGRAM: - CHECK_EXT1(EXT_histogram); - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.HistogramEnabled); - break; - case GL_MINMAX: - CHECK_EXT1(EXT_histogram); - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.MinMaxEnabled); - break; - case GL_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_color_table); - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]); - break; - case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_color_table); - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]); - break; - case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_color_table); - params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]); - break; - case GL_TEXTURE_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_texture_color_table); - params[0] = BOOLEAN_TO_FLOAT(ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled); - break; - case GL_COLOR_SUM_EXT: - CHECK_EXT2(EXT_secondary_color, ARB_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Fog.ColorSumEnabled); - break; - case GL_CURRENT_SECONDARY_COLOR_EXT: - CHECK_EXT1(EXT_secondary_color); - FLUSH_CURRENT(ctx, 0); - params[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]; - params[1] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]; - params[2] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]; - params[3] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]; - break; - case GL_SECONDARY_COLOR_ARRAY_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->SecondaryColor.Enabled); - break; - case GL_SECONDARY_COLOR_ARRAY_TYPE_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = ENUM_TO_FLOAT(ctx->Array.ArrayObj->SecondaryColor.Type); - break; - case GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = (GLfloat)(ctx->Array.ArrayObj->SecondaryColor.Stride); - break; - case GL_SECONDARY_COLOR_ARRAY_SIZE_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = (GLfloat)(ctx->Array.ArrayObj->SecondaryColor.Size); - break; - case GL_CURRENT_FOG_COORDINATE_EXT: - CHECK_EXT1(EXT_fog_coord); - FLUSH_CURRENT(ctx, 0); - params[0] = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; - break; - case GL_FOG_COORDINATE_ARRAY_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->FogCoord.Enabled); - break; - case GL_FOG_COORDINATE_ARRAY_TYPE_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = ENUM_TO_FLOAT(ctx->Array.ArrayObj->FogCoord.Type); - break; - case GL_FOG_COORDINATE_ARRAY_STRIDE_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = (GLfloat)(ctx->Array.ArrayObj->FogCoord.Stride); - break; - case GL_FOG_COORDINATE_SOURCE_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = ENUM_TO_FLOAT(ctx->Fog.FogCoordinateSource); - break; - case GL_MAX_TEXTURE_LOD_BIAS_EXT: - CHECK_EXT1(EXT_texture_lod_bias); - params[0] = ctx->Const.MaxTextureLodBias; - break; - case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: - CHECK_EXT1(EXT_texture_filter_anisotropic); - params[0] = ctx->Const.MaxTextureMaxAnisotropy; - break; - case GL_MULTISAMPLE_ARB: - params[0] = BOOLEAN_TO_FLOAT(ctx->Multisample.Enabled); - break; - case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: - params[0] = BOOLEAN_TO_FLOAT(ctx->Multisample.SampleAlphaToCoverage); - break; - case GL_SAMPLE_ALPHA_TO_ONE_ARB: - params[0] = BOOLEAN_TO_FLOAT(ctx->Multisample.SampleAlphaToOne); - break; - case GL_SAMPLE_COVERAGE_ARB: - params[0] = BOOLEAN_TO_FLOAT(ctx->Multisample.SampleCoverage); - break; - case GL_SAMPLE_COVERAGE_VALUE_ARB: - params[0] = ctx->Multisample.SampleCoverageValue; - break; - case GL_SAMPLE_COVERAGE_INVERT_ARB: - params[0] = BOOLEAN_TO_FLOAT(ctx->Multisample.SampleCoverageInvert); - break; - case GL_SAMPLE_BUFFERS_ARB: - params[0] = (GLfloat)(ctx->DrawBuffer->Visual.sampleBuffers); - break; - case GL_SAMPLES_ARB: - params[0] = (GLfloat)(ctx->DrawBuffer->Visual.samples); - break; - case GL_RASTER_POSITION_UNCLIPPED_IBM: - CHECK_EXT1(IBM_rasterpos_clip); - params[0] = BOOLEAN_TO_FLOAT(ctx->Transform.RasterPositionUnclipped); - break; - case GL_POINT_SPRITE_NV: - CHECK_EXT2(NV_point_sprite, ARB_point_sprite); - params[0] = BOOLEAN_TO_FLOAT(ctx->Point.PointSprite); - break; - case GL_POINT_SPRITE_R_MODE_NV: - CHECK_EXT1(NV_point_sprite); - params[0] = ENUM_TO_FLOAT(ctx->Point.SpriteRMode); - break; - case GL_POINT_SPRITE_COORD_ORIGIN: - CHECK_EXT2(NV_point_sprite, ARB_point_sprite); - params[0] = ENUM_TO_FLOAT(ctx->Point.SpriteOrigin); - break; - case GL_GENERATE_MIPMAP_HINT_SGIS: - CHECK_EXT1(SGIS_generate_mipmap); - params[0] = ENUM_TO_FLOAT(ctx->Hint.GenerateMipmap); - break; - case GL_VERTEX_PROGRAM_BINDING_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = (GLfloat)((ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0)); - break; - case GL_VERTEX_ATTRIB_ARRAY0_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[0].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY1_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[1].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY2_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[2].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY3_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[3].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[4].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY5_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[5].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY6_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[6].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY7_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[7].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY8_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[8].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY9_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[9].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY10_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[10].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY11_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[11].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY12_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[12].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY13_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[13].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY14_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[14].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY15_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.ArrayObj->VertexAttrib[15].Enabled); - break; - case GL_MAP1_VERTEX_ATTRIB0_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[0]); - break; - case GL_MAP1_VERTEX_ATTRIB1_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[1]); - break; - case GL_MAP1_VERTEX_ATTRIB2_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[2]); - break; - case GL_MAP1_VERTEX_ATTRIB3_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[3]); - break; - case GL_MAP1_VERTEX_ATTRIB4_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[4]); - break; - case GL_MAP1_VERTEX_ATTRIB5_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[5]); - break; - case GL_MAP1_VERTEX_ATTRIB6_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[6]); - break; - case GL_MAP1_VERTEX_ATTRIB7_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[7]); - break; - case GL_MAP1_VERTEX_ATTRIB8_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[8]); - break; - case GL_MAP1_VERTEX_ATTRIB9_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[9]); - break; - case GL_MAP1_VERTEX_ATTRIB10_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[10]); - break; - case GL_MAP1_VERTEX_ATTRIB11_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[11]); - break; - case GL_MAP1_VERTEX_ATTRIB12_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[12]); - break; - case GL_MAP1_VERTEX_ATTRIB13_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[13]); - break; - case GL_MAP1_VERTEX_ATTRIB14_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[14]); - break; - case GL_MAP1_VERTEX_ATTRIB15_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[15]); - break; - case GL_FRAGMENT_PROGRAM_NV: - CHECK_EXT1(NV_fragment_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->FragmentProgram.Enabled); - break; - case GL_FRAGMENT_PROGRAM_BINDING_NV: - CHECK_EXT1(NV_fragment_program); - params[0] = (GLfloat)(ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0); - break; - case GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV: - CHECK_EXT1(NV_fragment_program); - params[0] = (GLfloat)(MAX_NV_FRAGMENT_PROGRAM_PARAMS); - break; - case GL_TEXTURE_RECTANGLE_NV: - CHECK_EXT1(NV_texture_rectangle); - params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV)); - break; - case GL_TEXTURE_BINDING_RECTANGLE_NV: - CHECK_EXT1(NV_texture_rectangle); - params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_RECT_INDEX]->Name); - break; - case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV: - CHECK_EXT1(NV_texture_rectangle); - params[0] = (GLfloat)(ctx->Const.MaxTextureRectSize); - break; - case GL_STENCIL_TEST_TWO_SIDE_EXT: - CHECK_EXT1(EXT_stencil_two_side); - params[0] = BOOLEAN_TO_FLOAT(ctx->Stencil.TestTwoSide); - break; - case GL_ACTIVE_STENCIL_FACE_EXT: - CHECK_EXT1(EXT_stencil_two_side); - params[0] = ENUM_TO_FLOAT(ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT); - break; - case GL_MAX_SHININESS_NV: - CHECK_EXT1(NV_light_max_exponent); - params[0] = ctx->Const.MaxShininess; - break; - case GL_MAX_SPOT_EXPONENT_NV: - CHECK_EXT1(NV_light_max_exponent); - params[0] = ctx->Const.MaxSpotExponent; - break; - case GL_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLfloat)(ctx->Array.ArrayBufferObj->Name); - break; - case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLfloat)(ctx->Array.ArrayObj->Vertex.BufferObj->Name); - break; - case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLfloat)(ctx->Array.ArrayObj->Normal.BufferObj->Name); - break; - case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLfloat)(ctx->Array.ArrayObj->Color.BufferObj->Name); - break; - case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLfloat)(ctx->Array.ArrayObj->Index.BufferObj->Name); - break; - case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLfloat)(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name); - break; - case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLfloat)(ctx->Array.ArrayObj->EdgeFlag.BufferObj->Name); - break; - case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLfloat)(ctx->Array.ArrayObj->SecondaryColor.BufferObj->Name); - break; - case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLfloat)(ctx->Array.ArrayObj->FogCoord.BufferObj->Name); - break; - case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLfloat)(ctx->Array.ElementArrayBufferObj->Name); - break; - case GL_PIXEL_PACK_BUFFER_BINDING_EXT: - CHECK_EXT1(EXT_pixel_buffer_object); - params[0] = (GLfloat)(ctx->Pack.BufferObj->Name); - break; - case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT: - CHECK_EXT1(EXT_pixel_buffer_object); - params[0] = (GLfloat)(ctx->Unpack.BufferObj->Name); - break; - case GL_VERTEX_PROGRAM_ARB: - CHECK_EXT2(ARB_vertex_program, NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->VertexProgram.Enabled); - break; - case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: - CHECK_EXT2(ARB_vertex_program, NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->VertexProgram.PointSizeEnabled); - break; - case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: - CHECK_EXT2(ARB_vertex_program, NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->VertexProgram.TwoSideEnabled); - break; - case GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program); - params[0] = (GLfloat)(ctx->Const.MaxProgramMatrixStackDepth); - break; - case GL_MAX_PROGRAM_MATRICES_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program); - params[0] = (GLfloat)(ctx->Const.MaxProgramMatrices); - break; - case GL_CURRENT_MATRIX_STACK_DEPTH_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->CurrentStack->Depth + 1); - break; - case GL_CURRENT_MATRIX_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_fragment_program); - { - const GLfloat *matrix = ctx->CurrentStack->Top->m; - params[0] = matrix[0]; - params[1] = matrix[1]; - params[2] = matrix[2]; - params[3] = matrix[3]; - params[4] = matrix[4]; - params[5] = matrix[5]; - params[6] = matrix[6]; - params[7] = matrix[7]; - params[8] = matrix[8]; - params[9] = matrix[9]; - params[10] = matrix[10]; - params[11] = matrix[11]; - params[12] = matrix[12]; - params[13] = matrix[13]; - params[14] = matrix[14]; - params[15] = matrix[15]; - } - break; - case GL_TRANSPOSE_CURRENT_MATRIX_ARB: - CHECK_EXT2(ARB_vertex_program, ARB_fragment_program); - { - const GLfloat *matrix = ctx->CurrentStack->Top->m; - params[0] = matrix[0]; - params[1] = matrix[4]; - params[2] = matrix[8]; - params[3] = matrix[12]; - params[4] = matrix[1]; - params[5] = matrix[5]; - params[6] = matrix[9]; - params[7] = matrix[13]; - params[8] = matrix[2]; - params[9] = matrix[6]; - params[10] = matrix[10]; - params[11] = matrix[14]; - params[12] = matrix[3]; - params[13] = matrix[7]; - params[14] = matrix[11]; - params[15] = matrix[15]; - } - break; - case GL_MAX_VERTEX_ATTRIBS_ARB: - CHECK_EXT1(ARB_vertex_program); - params[0] = (GLfloat)(ctx->Const.VertexProgram.MaxAttribs); - break; - case GL_PROGRAM_ERROR_POSITION_ARB: - CHECK_EXT4(NV_vertex_program, ARB_vertex_program, NV_fragment_program, ARB_fragment_program); - params[0] = (GLfloat)(ctx->Program.ErrorPos); - break; - case GL_FRAGMENT_PROGRAM_ARB: - CHECK_EXT1(ARB_fragment_program); - params[0] = BOOLEAN_TO_FLOAT(ctx->FragmentProgram.Enabled); - break; - case GL_MAX_TEXTURE_COORDS_ARB: - CHECK_EXT2(ARB_fragment_program, NV_fragment_program); - params[0] = (GLfloat)(ctx->Const.MaxTextureCoordUnits); - break; - case GL_MAX_TEXTURE_IMAGE_UNITS_ARB: - CHECK_EXT2(ARB_fragment_program, NV_fragment_program); - params[0] = (GLfloat)(ctx->Const.MaxTextureImageUnits); - break; - case GL_DEPTH_BOUNDS_TEST_EXT: - CHECK_EXT1(EXT_depth_bounds_test); - params[0] = BOOLEAN_TO_FLOAT(ctx->Depth.BoundsTest); - break; - case GL_DEPTH_BOUNDS_EXT: - CHECK_EXT1(EXT_depth_bounds_test); - params[0] = ctx->Depth.BoundsMin; - params[1] = ctx->Depth.BoundsMax; - break; - case GL_DEPTH_CLAMP: - CHECK_EXT1(ARB_depth_clamp); - params[0] = BOOLEAN_TO_FLOAT(ctx->Transform.DepthClamp); - break; - case GL_MAX_DRAW_BUFFERS_ARB: - params[0] = (GLfloat)(ctx->Const.MaxDrawBuffers); - break; - case GL_DRAW_BUFFER0_ARB: - params[0] = ENUM_TO_FLOAT(ctx->DrawBuffer->ColorDrawBuffer[0]); - break; - case GL_DRAW_BUFFER1_ARB: - { - GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[1]; - params[0] = ENUM_TO_FLOAT(buffer); - } - break; - case GL_DRAW_BUFFER2_ARB: - { - GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[2]; - params[0] = ENUM_TO_FLOAT(buffer); - } - break; - case GL_DRAW_BUFFER3_ARB: - { - GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[3]; - params[0] = ENUM_TO_FLOAT(buffer); - } - break; - case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: - CHECK_EXT1(OES_read_format); - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = (GLfloat)(_mesa_get_color_read_type(ctx)); - break; - case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: - CHECK_EXT1(OES_read_format); - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = (GLfloat)(_mesa_get_color_read_format(ctx)); - break; - case GL_NUM_FRAGMENT_REGISTERS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = (GLfloat)(6); - break; - case GL_NUM_FRAGMENT_CONSTANTS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = (GLfloat)(8); - break; - case GL_NUM_PASSES_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = (GLfloat)(2); - break; - case GL_NUM_INSTRUCTIONS_PER_PASS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = (GLfloat)(8); - break; - case GL_NUM_INSTRUCTIONS_TOTAL_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = (GLfloat)(16); - break; - case GL_COLOR_ALPHA_PAIRING_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = BOOLEAN_TO_FLOAT(GL_TRUE); - break; - case GL_NUM_LOOPBACK_COMPONENTS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = (GLfloat)(3); - break; - case GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = (GLfloat)(3); - break; - case GL_STENCIL_BACK_FUNC: - params[0] = ENUM_TO_FLOAT(ctx->Stencil.Function[1]); - break; - case GL_STENCIL_BACK_VALUE_MASK: - params[0] = (GLfloat)(ctx->Stencil.ValueMask[1]); - break; - case GL_STENCIL_BACK_WRITEMASK: - params[0] = (GLfloat)(ctx->Stencil.WriteMask[1]); - break; - case GL_STENCIL_BACK_REF: - params[0] = (GLfloat)(ctx->Stencil.Ref[1]); - break; - case GL_STENCIL_BACK_FAIL: - params[0] = ENUM_TO_FLOAT(ctx->Stencil.FailFunc[1]); - break; - case GL_STENCIL_BACK_PASS_DEPTH_FAIL: - params[0] = ENUM_TO_FLOAT(ctx->Stencil.ZFailFunc[1]); - break; - case GL_STENCIL_BACK_PASS_DEPTH_PASS: - params[0] = ENUM_TO_FLOAT(ctx->Stencil.ZPassFunc[1]); - break; - case GL_FRAMEBUFFER_BINDING_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = (GLfloat)(ctx->DrawBuffer->Name); - break; - case GL_RENDERBUFFER_BINDING_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = (GLfloat)(ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0); - break; - case GL_MAX_COLOR_ATTACHMENTS_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = (GLfloat)(ctx->Const.MaxColorAttachments); - break; - case GL_MAX_RENDERBUFFER_SIZE_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = (GLfloat)(ctx->Const.MaxRenderbufferSize); - break; - case GL_READ_FRAMEBUFFER_BINDING_EXT: - CHECK_EXT1(EXT_framebuffer_blit); - params[0] = (GLfloat)(ctx->ReadBuffer->Name); - break; - case GL_PROVOKING_VERTEX_EXT: - CHECK_EXT1(EXT_provoking_vertex); - params[0] = BOOLEAN_TO_FLOAT(ctx->Light.ProvokingVertex); - break; - case GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT: - CHECK_EXT1(EXT_provoking_vertex); - params[0] = BOOLEAN_TO_FLOAT(ctx->Const.QuadsFollowProvokingVertexConvention); - break; - case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB: - CHECK_EXT1(ARB_fragment_shader); - params[0] = (GLfloat)(ctx->Const.FragmentProgram.MaxUniformComponents); - break; - case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB: - CHECK_EXT1(ARB_fragment_shader); - params[0] = ENUM_TO_FLOAT(ctx->Hint.FragmentShaderDerivative); - break; - case GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = (GLfloat)(ctx->Const.VertexProgram.MaxUniformComponents); - break; - case GL_MAX_VARYING_FLOATS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = (GLfloat)(ctx->Const.MaxVarying * 4); - break; - case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = (GLfloat)(ctx->Const.MaxVertexTextureImageUnits); - break; - case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = (GLfloat)(ctx->Const.MaxCombinedTextureImageUnits); - break; - case GL_CURRENT_PROGRAM: - CHECK_EXT1(ARB_shader_objects); - params[0] = (GLfloat)(ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0); - break; - case GL_MAX_SAMPLES: - CHECK_EXT1(ARB_framebuffer_object); - params[0] = (GLfloat)(ctx->Const.MaxSamples); - break; - case GL_VERTEX_ARRAY_BINDING_APPLE: - CHECK_EXT1(APPLE_vertex_array_object); - params[0] = (GLfloat)(ctx->Array.ArrayObj->Name); - break; - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - CHECK_EXT1(ARB_seamless_cube_map); - params[0] = BOOLEAN_TO_FLOAT(ctx->Texture.CubeMapSeamless); - break; - case GL_MAX_SERVER_WAIT_TIMEOUT: - CHECK_EXT1(ARB_sync); - params[0] = (GLfloat)(ctx->Const.MaxServerWaitTimeout); - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: - CHECK_EXT1(EXT_transform_feedback); - params[0] = (GLfloat)(ctx->TransformFeedback.CurrentBuffer->Name); - break; - case GL_RASTERIZER_DISCARD: - CHECK_EXT1(EXT_transform_feedback); - params[0] = BOOLEAN_TO_FLOAT(ctx->TransformFeedback.RasterDiscard); - break; - case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: - CHECK_EXT1(EXT_transform_feedback); - params[0] = (GLfloat)(ctx->Const.MaxTransformFeedbackInterleavedComponents); - break; - case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: - CHECK_EXT1(EXT_transform_feedback); - params[0] = (GLfloat)(ctx->Const.MaxTransformFeedbackSeparateAttribs); - break; - case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: - CHECK_EXT1(EXT_transform_feedback); - params[0] = (GLfloat)(ctx->Const.MaxTransformFeedbackSeparateComponents); - break; - case GL_NUM_EXTENSIONS: - CHECK_VERSION(30); - params[0] = (GLfloat)(_mesa_get_extension_count(ctx)); - break; - case GL_MAJOR_VERSION: - CHECK_VERSION(30); - params[0] = (GLfloat)(ctx->VersionMajor); - break; - case GL_MINOR_VERSION: - CHECK_VERSION(30); - params[0] = (GLfloat)(ctx->VersionMinor); - break; - case GL_CONTEXT_FLAGS: - CHECK_VERSION(30); - params[0] = (GLfloat)(ctx->Const.ContextFlags); - break; - case GL_PRIMITIVE_RESTART: - CHECK_VERSION(31); - params[0] = BOOLEAN_TO_FLOAT(ctx->Array.PrimitiveRestart); - break; - case GL_PRIMITIVE_RESTART_INDEX: - CHECK_VERSION(31); - params[0] = (GLfloat)(ctx->Array.RestartIndex); - break; - case GL_CONTEXT_PROFILE_MASK: - CHECK_VERSION(32); - params[0] = (GLfloat)(ctx->Const.ProfileMask); - break; - default: - goto invalid_enum_error; - } - return; + case TYPE_DOUBLEN: + params[0] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[0]); + break; + + case TYPE_INT_4: + params[3] = INT_TO_BOOLEAN(((GLint *) p)[3]); + case TYPE_INT_3: + params[2] = INT_TO_BOOLEAN(((GLint *) p)[2]); + case TYPE_INT_2: + case TYPE_ENUM_2: + params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]); + case TYPE_INT: + case TYPE_ENUM: + params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]); + break; -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv(pname=0x%x)", pname); + case TYPE_INT_N: + for (i = 0; i < v.value_int_n.n; i++) + params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]); + break; + + case TYPE_INT64: + params[0] = INT64_TO_BOOLEAN(((GLint64 *) p)[0]); + break; + + case TYPE_BOOLEAN: + params[0] = ((GLboolean*) p)[0]; + break; + + case TYPE_MATRIX: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_BOOLEAN(m->m[i]); + break; + + case TYPE_MATRIX_T: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_BOOLEAN(m->m[transpose[i]]); + break; + + case TYPE_BIT_0: + case TYPE_BIT_1: + case TYPE_BIT_2: + case TYPE_BIT_3: + case TYPE_BIT_4: + case TYPE_BIT_5: + shift = d->type - TYPE_BIT_0; + params[0] = (*(GLbitfield *) p >> shift) & 1; + break; + } } void GLAPIENTRY -_mesa_GetIntegerv( GLenum pname, GLint *params ) +_mesa_GetFloatv(GLenum pname, GLfloat *params) { - GET_CURRENT_CONTEXT(ctx); - const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; - ASSERT_OUTSIDE_BEGIN_END(ctx); - (void) version; + const struct value_desc *d; + union value v; + GLmatrix *m; + int shift, i; + void *p; - if (!params) - return; + d = find_value("glGetFloatv", pname, &p, &v); + switch (d->type) { + case TYPE_INVALID: + break; + case TYPE_CONST: + params[0] = (GLfloat) d->offset; + break; - if (ctx->Driver.GetIntegerv && - ctx->Driver.GetIntegerv(ctx, pname, params)) - return; + case TYPE_FLOAT_4: + case TYPE_FLOATN_4: + params[3] = ((GLfloat *) p)[3]; + case TYPE_FLOAT_3: + case TYPE_FLOATN_3: + params[2] = ((GLfloat *) p)[2]; + case TYPE_FLOAT_2: + case TYPE_FLOATN_2: + params[1] = ((GLfloat *) p)[1]; + case TYPE_FLOAT: + case TYPE_FLOATN: + params[0] = ((GLfloat *) p)[0]; + break; - switch (pname) { - case GL_ACCUM_RED_BITS: - params[0] = ctx->DrawBuffer->Visual.accumRedBits; - break; - case GL_ACCUM_GREEN_BITS: - params[0] = ctx->DrawBuffer->Visual.accumGreenBits; - break; - case GL_ACCUM_BLUE_BITS: - params[0] = ctx->DrawBuffer->Visual.accumBlueBits; - break; - case GL_ACCUM_ALPHA_BITS: - params[0] = ctx->DrawBuffer->Visual.accumAlphaBits; - break; - case GL_ACCUM_CLEAR_VALUE: - params[0] = FLOAT_TO_INT(ctx->Accum.ClearColor[0]); - params[1] = FLOAT_TO_INT(ctx->Accum.ClearColor[1]); - params[2] = FLOAT_TO_INT(ctx->Accum.ClearColor[2]); - params[3] = FLOAT_TO_INT(ctx->Accum.ClearColor[3]); - break; - case GL_ALPHA_BIAS: - params[0] = IROUND(ctx->Pixel.AlphaBias); - break; - case GL_ALPHA_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = ctx->DrawBuffer->Visual.alphaBits; - break; - case GL_ALPHA_SCALE: - params[0] = IROUND(ctx->Pixel.AlphaScale); - break; - case GL_ALPHA_TEST: - params[0] = BOOLEAN_TO_INT(ctx->Color.AlphaEnabled); - break; - case GL_ALPHA_TEST_FUNC: - params[0] = ENUM_TO_INT(ctx->Color.AlphaFunc); - break; - case GL_ALPHA_TEST_REF: - params[0] = FLOAT_TO_INT(ctx->Color.AlphaRef); - break; - case GL_ATTRIB_STACK_DEPTH: - params[0] = ctx->AttribStackDepth; - break; - case GL_AUTO_NORMAL: - params[0] = BOOLEAN_TO_INT(ctx->Eval.AutoNormal); - break; - case GL_AUX_BUFFERS: - params[0] = ctx->DrawBuffer->Visual.numAuxBuffers; - break; - case GL_BLEND: - params[0] = BOOLEAN_TO_INT((ctx->Color.BlendEnabled & 1)); - break; - case GL_BLEND_DST: - params[0] = ENUM_TO_INT(ctx->Color.BlendDstRGB); - break; - case GL_BLEND_SRC: - params[0] = ENUM_TO_INT(ctx->Color.BlendSrcRGB); - break; - case GL_BLEND_SRC_RGB_EXT: - params[0] = ENUM_TO_INT(ctx->Color.BlendSrcRGB); - break; - case GL_BLEND_DST_RGB_EXT: - params[0] = ENUM_TO_INT(ctx->Color.BlendDstRGB); - break; - case GL_BLEND_SRC_ALPHA_EXT: - params[0] = ENUM_TO_INT(ctx->Color.BlendSrcA); - break; - case GL_BLEND_DST_ALPHA_EXT: - params[0] = ENUM_TO_INT(ctx->Color.BlendDstA); - break; - case GL_BLEND_EQUATION: - params[0] = ENUM_TO_INT(ctx->Color.BlendEquationRGB ); - break; - case GL_BLEND_EQUATION_ALPHA_EXT: - params[0] = ENUM_TO_INT(ctx->Color.BlendEquationA ); - break; - case GL_BLEND_COLOR_EXT: - params[0] = FLOAT_TO_INT(ctx->Color.BlendColor[0]); - params[1] = FLOAT_TO_INT(ctx->Color.BlendColor[1]); - params[2] = FLOAT_TO_INT(ctx->Color.BlendColor[2]); - params[3] = FLOAT_TO_INT(ctx->Color.BlendColor[3]); - break; - case GL_BLUE_BIAS: - params[0] = IROUND(ctx->Pixel.BlueBias); - break; - case GL_BLUE_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = ctx->DrawBuffer->Visual.blueBits; - break; - case GL_BLUE_SCALE: - params[0] = IROUND(ctx->Pixel.BlueScale); - break; - case GL_CLIENT_ATTRIB_STACK_DEPTH: - params[0] = ctx->ClientAttribStackDepth; - break; - case GL_CLIP_PLANE0: - params[0] = BOOLEAN_TO_INT((ctx->Transform.ClipPlanesEnabled >> 0) & 1); - break; - case GL_CLIP_PLANE1: - params[0] = BOOLEAN_TO_INT((ctx->Transform.ClipPlanesEnabled >> 1) & 1); - break; - case GL_CLIP_PLANE2: - params[0] = BOOLEAN_TO_INT((ctx->Transform.ClipPlanesEnabled >> 2) & 1); - break; - case GL_CLIP_PLANE3: - params[0] = BOOLEAN_TO_INT((ctx->Transform.ClipPlanesEnabled >> 3) & 1); - break; - case GL_CLIP_PLANE4: - params[0] = BOOLEAN_TO_INT((ctx->Transform.ClipPlanesEnabled >> 4) & 1); - break; - case GL_CLIP_PLANE5: - params[0] = BOOLEAN_TO_INT((ctx->Transform.ClipPlanesEnabled >> 5) & 1); - break; - case GL_COLOR_CLEAR_VALUE: - params[0] = FLOAT_TO_INT(ctx->Color.ClearColor[0]); - params[1] = FLOAT_TO_INT(ctx->Color.ClearColor[1]); - params[2] = FLOAT_TO_INT(ctx->Color.ClearColor[2]); - params[3] = FLOAT_TO_INT(ctx->Color.ClearColor[3]); - break; - case GL_COLOR_MATERIAL: - params[0] = BOOLEAN_TO_INT(ctx->Light.ColorMaterialEnabled); - break; - case GL_COLOR_MATERIAL_FACE: - params[0] = ENUM_TO_INT(ctx->Light.ColorMaterialFace); - break; - case GL_COLOR_MATERIAL_PARAMETER: - params[0] = ENUM_TO_INT(ctx->Light.ColorMaterialMode); - break; - case GL_COLOR_WRITEMASK: - params[0] = ctx->Color.ColorMask[0][RCOMP] ? 1 : 0; - params[1] = ctx->Color.ColorMask[0][GCOMP] ? 1 : 0; - params[2] = ctx->Color.ColorMask[0][BCOMP] ? 1 : 0; - params[3] = ctx->Color.ColorMask[0][ACOMP] ? 1 : 0; - break; - case GL_CULL_FACE: - params[0] = BOOLEAN_TO_INT(ctx->Polygon.CullFlag); - break; - case GL_CULL_FACE_MODE: - params[0] = ENUM_TO_INT(ctx->Polygon.CullFaceMode); - break; - case GL_CURRENT_COLOR: - FLUSH_CURRENT(ctx, 0); - params[0] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]); - params[1] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]); - params[2] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]); - params[3] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]); - break; - case GL_CURRENT_INDEX: - FLUSH_CURRENT(ctx, 0); - params[0] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]); - break; - case GL_CURRENT_NORMAL: - FLUSH_CURRENT(ctx, 0); - params[0] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]); - params[1] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]); - params[2] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]); - break; - case GL_CURRENT_RASTER_COLOR: - params[0] = FLOAT_TO_INT(ctx->Current.RasterColor[0]); - params[1] = FLOAT_TO_INT(ctx->Current.RasterColor[1]); - params[2] = FLOAT_TO_INT(ctx->Current.RasterColor[2]); - params[3] = FLOAT_TO_INT(ctx->Current.RasterColor[3]); - break; - case GL_CURRENT_RASTER_DISTANCE: - params[0] = IROUND(ctx->Current.RasterDistance); - break; - case GL_CURRENT_RASTER_INDEX: - params[0] = IROUND(1.0); - break; - case GL_CURRENT_RASTER_POSITION: - params[0] = IROUND(ctx->Current.RasterPos[0]); - params[1] = IROUND(ctx->Current.RasterPos[1]); - params[2] = IROUND(ctx->Current.RasterPos[2]); - params[3] = IROUND(ctx->Current.RasterPos[3]); - break; - case GL_CURRENT_RASTER_SECONDARY_COLOR: - params[0] = FLOAT_TO_INT(ctx->Current.RasterSecondaryColor[0]); - params[1] = FLOAT_TO_INT(ctx->Current.RasterSecondaryColor[1]); - params[2] = FLOAT_TO_INT(ctx->Current.RasterSecondaryColor[2]); - params[3] = FLOAT_TO_INT(ctx->Current.RasterSecondaryColor[3]); - break; - case GL_CURRENT_RASTER_TEXTURE_COORDS: - { - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(raster tex coords, unit %u)", unit); - return; - } - params[0] = IROUND(ctx->Current.RasterTexCoords[unit][0]); - params[1] = IROUND(ctx->Current.RasterTexCoords[unit][1]); - params[2] = IROUND(ctx->Current.RasterTexCoords[unit][2]); - params[3] = IROUND(ctx->Current.RasterTexCoords[unit][3]); - } - break; - case GL_CURRENT_RASTER_POSITION_VALID: - params[0] = BOOLEAN_TO_INT(ctx->Current.RasterPosValid); - break; - case GL_CURRENT_TEXTURE_COORDS: - { - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(current tex coords, unit %u)", unit); - return; - } - FLUSH_CURRENT(ctx, 0); - params[0] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]); - params[1] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]); - params[2] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2]); - params[3] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3]); - } - break; - case GL_DEPTH_BIAS: - params[0] = IROUND(ctx->Pixel.DepthBias); - break; - case GL_DEPTH_BITS: - params[0] = ctx->DrawBuffer->Visual.depthBits; - break; - case GL_DEPTH_CLEAR_VALUE: - params[0] = FLOAT_TO_INT(((GLfloat) ctx->Depth.Clear)); - break; - case GL_DEPTH_FUNC: - params[0] = ENUM_TO_INT(ctx->Depth.Func); - break; - case GL_DEPTH_RANGE: - params[0] = FLOAT_TO_INT(ctx->Viewport.Near); - params[1] = FLOAT_TO_INT(ctx->Viewport.Far); - break; - case GL_DEPTH_SCALE: - params[0] = IROUND(ctx->Pixel.DepthScale); - break; - case GL_DEPTH_TEST: - params[0] = BOOLEAN_TO_INT(ctx->Depth.Test); - break; - case GL_DEPTH_WRITEMASK: - params[0] = BOOLEAN_TO_INT(ctx->Depth.Mask); - break; - case GL_DITHER: - params[0] = BOOLEAN_TO_INT(ctx->Color.DitherFlag); - break; - case GL_DOUBLEBUFFER: - params[0] = BOOLEAN_TO_INT(ctx->DrawBuffer->Visual.doubleBufferMode); - break; - case GL_DRAW_BUFFER: - params[0] = ENUM_TO_INT(ctx->DrawBuffer->ColorDrawBuffer[0]); - break; - case GL_EDGE_FLAG: - FLUSH_CURRENT(ctx, 0); - params[0] = BOOLEAN_TO_INT((ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0)); - break; - case GL_FEEDBACK_BUFFER_SIZE: - params[0] = ctx->Feedback.BufferSize; - break; - case GL_FEEDBACK_BUFFER_TYPE: - params[0] = ENUM_TO_INT(ctx->Feedback.Type); - break; - case GL_FOG: - params[0] = BOOLEAN_TO_INT(ctx->Fog.Enabled); - break; - case GL_FOG_COLOR: - params[0] = FLOAT_TO_INT(ctx->Fog.Color[0]); - params[1] = FLOAT_TO_INT(ctx->Fog.Color[1]); - params[2] = FLOAT_TO_INT(ctx->Fog.Color[2]); - params[3] = FLOAT_TO_INT(ctx->Fog.Color[3]); - break; - case GL_FOG_DENSITY: - params[0] = IROUND(ctx->Fog.Density); - break; - case GL_FOG_END: - params[0] = IROUND(ctx->Fog.End); - break; - case GL_FOG_HINT: - params[0] = ENUM_TO_INT(ctx->Hint.Fog); - break; - case GL_FOG_INDEX: - params[0] = IROUND(ctx->Fog.Index); - break; - case GL_FOG_MODE: - params[0] = ENUM_TO_INT(ctx->Fog.Mode); - break; - case GL_FOG_START: - params[0] = IROUND(ctx->Fog.Start); - break; - case GL_FRONT_FACE: - params[0] = ENUM_TO_INT(ctx->Polygon.FrontFace); - break; - case GL_GREEN_BIAS: - params[0] = IROUND(ctx->Pixel.GreenBias); - break; - case GL_GREEN_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = ctx->DrawBuffer->Visual.greenBits; - break; - case GL_GREEN_SCALE: - params[0] = IROUND(ctx->Pixel.GreenScale); - break; - case GL_INDEX_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = ctx->DrawBuffer->Visual.indexBits; - break; - case GL_INDEX_CLEAR_VALUE: - params[0] = ctx->Color.ClearIndex; - break; - case GL_INDEX_MODE: - params[0] = BOOLEAN_TO_INT(GL_FALSE); - break; - case GL_INDEX_OFFSET: - params[0] = ctx->Pixel.IndexOffset; - break; - case GL_INDEX_SHIFT: - params[0] = ctx->Pixel.IndexShift; - break; - case GL_INDEX_WRITEMASK: - params[0] = ctx->Color.IndexMask; - break; - case GL_LIGHT0: - params[0] = BOOLEAN_TO_INT(ctx->Light.Light[0].Enabled); - break; - case GL_LIGHT1: - params[0] = BOOLEAN_TO_INT(ctx->Light.Light[1].Enabled); - break; - case GL_LIGHT2: - params[0] = BOOLEAN_TO_INT(ctx->Light.Light[2].Enabled); - break; - case GL_LIGHT3: - params[0] = BOOLEAN_TO_INT(ctx->Light.Light[3].Enabled); - break; - case GL_LIGHT4: - params[0] = BOOLEAN_TO_INT(ctx->Light.Light[4].Enabled); - break; - case GL_LIGHT5: - params[0] = BOOLEAN_TO_INT(ctx->Light.Light[5].Enabled); - break; - case GL_LIGHT6: - params[0] = BOOLEAN_TO_INT(ctx->Light.Light[6].Enabled); - break; - case GL_LIGHT7: - params[0] = BOOLEAN_TO_INT(ctx->Light.Light[7].Enabled); - break; - case GL_LIGHTING: - params[0] = BOOLEAN_TO_INT(ctx->Light.Enabled); - break; - case GL_LIGHT_MODEL_AMBIENT: - params[0] = FLOAT_TO_INT(ctx->Light.Model.Ambient[0]); - params[1] = FLOAT_TO_INT(ctx->Light.Model.Ambient[1]); - params[2] = FLOAT_TO_INT(ctx->Light.Model.Ambient[2]); - params[3] = FLOAT_TO_INT(ctx->Light.Model.Ambient[3]); - break; - case GL_LIGHT_MODEL_COLOR_CONTROL: - params[0] = ENUM_TO_INT(ctx->Light.Model.ColorControl); - break; - case GL_LIGHT_MODEL_LOCAL_VIEWER: - params[0] = BOOLEAN_TO_INT(ctx->Light.Model.LocalViewer); - break; - case GL_LIGHT_MODEL_TWO_SIDE: - params[0] = BOOLEAN_TO_INT(ctx->Light.Model.TwoSide); - break; - case GL_LINE_SMOOTH: - params[0] = BOOLEAN_TO_INT(ctx->Line.SmoothFlag); - break; - case GL_LINE_SMOOTH_HINT: - params[0] = ENUM_TO_INT(ctx->Hint.LineSmooth); - break; - case GL_LINE_STIPPLE: - params[0] = BOOLEAN_TO_INT(ctx->Line.StippleFlag); - break; - case GL_LINE_STIPPLE_PATTERN: - params[0] = ctx->Line.StipplePattern; - break; - case GL_LINE_STIPPLE_REPEAT: - params[0] = ctx->Line.StippleFactor; - break; - case GL_LINE_WIDTH: - params[0] = IROUND(ctx->Line.Width); - break; - case GL_LINE_WIDTH_GRANULARITY: - params[0] = IROUND(ctx->Const.LineWidthGranularity); - break; - case GL_LINE_WIDTH_RANGE: - params[0] = IROUND(ctx->Const.MinLineWidthAA); - params[1] = IROUND(ctx->Const.MaxLineWidthAA); - break; - case GL_ALIASED_LINE_WIDTH_RANGE: - params[0] = IROUND(ctx->Const.MinLineWidth); - params[1] = IROUND(ctx->Const.MaxLineWidth); - break; - case GL_LIST_BASE: - params[0] = ctx->List.ListBase; - break; - case GL_LIST_INDEX: - params[0] = (ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0); - break; - case GL_LIST_MODE: - { - GLenum mode; - if (!ctx->CompileFlag) - mode = 0; - else if (ctx->ExecuteFlag) - mode = GL_COMPILE_AND_EXECUTE; - else - mode = GL_COMPILE; - params[0] = ENUM_TO_INT(mode); - } - break; - case GL_INDEX_LOGIC_OP: - params[0] = BOOLEAN_TO_INT(ctx->Color.IndexLogicOpEnabled); - break; - case GL_COLOR_LOGIC_OP: - params[0] = BOOLEAN_TO_INT(ctx->Color.ColorLogicOpEnabled); - break; - case GL_LOGIC_OP_MODE: - params[0] = ENUM_TO_INT(ctx->Color.LogicOp); - break; - case GL_MAP1_COLOR_4: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Color4); - break; - case GL_MAP1_GRID_DOMAIN: - params[0] = IROUND(ctx->Eval.MapGrid1u1); - params[1] = IROUND(ctx->Eval.MapGrid1u2); - break; - case GL_MAP1_GRID_SEGMENTS: - params[0] = ctx->Eval.MapGrid1un; - break; - case GL_MAP1_INDEX: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Index); - break; - case GL_MAP1_NORMAL: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Normal); - break; - case GL_MAP1_TEXTURE_COORD_1: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1TextureCoord1); - break; - case GL_MAP1_TEXTURE_COORD_2: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1TextureCoord2); - break; - case GL_MAP1_TEXTURE_COORD_3: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1TextureCoord3); - break; - case GL_MAP1_TEXTURE_COORD_4: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1TextureCoord4); - break; - case GL_MAP1_VERTEX_3: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Vertex3); - break; - case GL_MAP1_VERTEX_4: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Vertex4); - break; - case GL_MAP2_COLOR_4: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2Color4); - break; - case GL_MAP2_GRID_DOMAIN: - params[0] = IROUND(ctx->Eval.MapGrid2u1); - params[1] = IROUND(ctx->Eval.MapGrid2u2); - params[2] = IROUND(ctx->Eval.MapGrid2v1); - params[3] = IROUND(ctx->Eval.MapGrid2v2); - break; - case GL_MAP2_GRID_SEGMENTS: - params[0] = ctx->Eval.MapGrid2un; - params[1] = ctx->Eval.MapGrid2vn; - break; - case GL_MAP2_INDEX: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2Index); - break; - case GL_MAP2_NORMAL: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2Normal); - break; - case GL_MAP2_TEXTURE_COORD_1: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2TextureCoord1); - break; - case GL_MAP2_TEXTURE_COORD_2: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2TextureCoord2); - break; - case GL_MAP2_TEXTURE_COORD_3: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2TextureCoord3); - break; - case GL_MAP2_TEXTURE_COORD_4: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2TextureCoord4); - break; - case GL_MAP2_VERTEX_3: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2Vertex3); - break; - case GL_MAP2_VERTEX_4: - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2Vertex4); - break; - case GL_MAP_COLOR: - params[0] = BOOLEAN_TO_INT(ctx->Pixel.MapColorFlag); - break; - case GL_MAP_STENCIL: - params[0] = BOOLEAN_TO_INT(ctx->Pixel.MapStencilFlag); - break; - case GL_MATRIX_MODE: - params[0] = ENUM_TO_INT(ctx->Transform.MatrixMode); - break; - case GL_MAX_ATTRIB_STACK_DEPTH: - params[0] = MAX_ATTRIB_STACK_DEPTH; - break; - case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH: - params[0] = MAX_CLIENT_ATTRIB_STACK_DEPTH; - break; - case GL_MAX_CLIP_PLANES: - params[0] = ctx->Const.MaxClipPlanes; - break; - case GL_MAX_ELEMENTS_VERTICES: - params[0] = ctx->Const.MaxArrayLockSize; - break; - case GL_MAX_ELEMENTS_INDICES: - params[0] = ctx->Const.MaxArrayLockSize; - break; - case GL_MAX_EVAL_ORDER: - params[0] = MAX_EVAL_ORDER; - break; - case GL_MAX_LIGHTS: - params[0] = ctx->Const.MaxLights; - break; - case GL_MAX_LIST_NESTING: - params[0] = MAX_LIST_NESTING; - break; - case GL_MAX_MODELVIEW_STACK_DEPTH: - params[0] = MAX_MODELVIEW_STACK_DEPTH; - break; - case GL_MAX_NAME_STACK_DEPTH: - params[0] = MAX_NAME_STACK_DEPTH; - break; - case GL_MAX_PIXEL_MAP_TABLE: - params[0] = MAX_PIXEL_MAP_TABLE; - break; - case GL_MAX_PROJECTION_STACK_DEPTH: - params[0] = MAX_PROJECTION_STACK_DEPTH; - break; - case GL_MAX_TEXTURE_SIZE: - params[0] = 1 << (ctx->Const.MaxTextureLevels - 1); - break; - case GL_MAX_3D_TEXTURE_SIZE: - params[0] = 1 << (ctx->Const.Max3DTextureLevels - 1); - break; - case GL_MAX_TEXTURE_STACK_DEPTH: - params[0] = MAX_TEXTURE_STACK_DEPTH; - break; - case GL_MAX_VIEWPORT_DIMS: - params[0] = ctx->Const.MaxViewportWidth; - params[1] = ctx->Const.MaxViewportHeight; - break; - case GL_MODELVIEW_MATRIX: - { - const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m; - params[0] = IROUND(matrix[0]); - params[1] = IROUND(matrix[1]); - params[2] = IROUND(matrix[2]); - params[3] = IROUND(matrix[3]); - params[4] = IROUND(matrix[4]); - params[5] = IROUND(matrix[5]); - params[6] = IROUND(matrix[6]); - params[7] = IROUND(matrix[7]); - params[8] = IROUND(matrix[8]); - params[9] = IROUND(matrix[9]); - params[10] = IROUND(matrix[10]); - params[11] = IROUND(matrix[11]); - params[12] = IROUND(matrix[12]); - params[13] = IROUND(matrix[13]); - params[14] = IROUND(matrix[14]); - params[15] = IROUND(matrix[15]); - } - break; - case GL_MODELVIEW_STACK_DEPTH: - params[0] = ctx->ModelviewMatrixStack.Depth + 1; - break; - case GL_NAME_STACK_DEPTH: - params[0] = ctx->Select.NameStackDepth; - break; - case GL_NORMALIZE: - params[0] = BOOLEAN_TO_INT(ctx->Transform.Normalize); - break; - case GL_PACK_ALIGNMENT: - params[0] = ctx->Pack.Alignment; - break; - case GL_PACK_LSB_FIRST: - params[0] = BOOLEAN_TO_INT(ctx->Pack.LsbFirst); - break; - case GL_PACK_ROW_LENGTH: - params[0] = ctx->Pack.RowLength; - break; - case GL_PACK_SKIP_PIXELS: - params[0] = ctx->Pack.SkipPixels; - break; - case GL_PACK_SKIP_ROWS: - params[0] = ctx->Pack.SkipRows; - break; - case GL_PACK_SWAP_BYTES: - params[0] = BOOLEAN_TO_INT(ctx->Pack.SwapBytes); - break; - case GL_PACK_SKIP_IMAGES_EXT: - params[0] = ctx->Pack.SkipImages; - break; - case GL_PACK_IMAGE_HEIGHT_EXT: - params[0] = ctx->Pack.ImageHeight; - break; - case GL_PACK_INVERT_MESA: - params[0] = BOOLEAN_TO_INT(ctx->Pack.Invert); - break; - case GL_PERSPECTIVE_CORRECTION_HINT: - params[0] = ENUM_TO_INT(ctx->Hint.PerspectiveCorrection); - break; - case GL_PIXEL_MAP_A_TO_A_SIZE: - params[0] = ctx->PixelMaps.AtoA.Size; - break; - case GL_PIXEL_MAP_B_TO_B_SIZE: - params[0] = ctx->PixelMaps.BtoB.Size; - break; - case GL_PIXEL_MAP_G_TO_G_SIZE: - params[0] = ctx->PixelMaps.GtoG.Size; - break; - case GL_PIXEL_MAP_I_TO_A_SIZE: - params[0] = ctx->PixelMaps.ItoA.Size; - break; - case GL_PIXEL_MAP_I_TO_B_SIZE: - params[0] = ctx->PixelMaps.ItoB.Size; - break; - case GL_PIXEL_MAP_I_TO_G_SIZE: - params[0] = ctx->PixelMaps.ItoG.Size; - break; - case GL_PIXEL_MAP_I_TO_I_SIZE: - params[0] = ctx->PixelMaps.ItoI.Size; - break; - case GL_PIXEL_MAP_I_TO_R_SIZE: - params[0] = ctx->PixelMaps.ItoR.Size; - break; - case GL_PIXEL_MAP_R_TO_R_SIZE: - params[0] = ctx->PixelMaps.RtoR.Size; - break; - case GL_PIXEL_MAP_S_TO_S_SIZE: - params[0] = ctx->PixelMaps.StoS.Size; - break; - case GL_POINT_SIZE: - params[0] = IROUND(ctx->Point.Size); - break; - case GL_POINT_SIZE_GRANULARITY: - params[0] = IROUND(ctx->Const.PointSizeGranularity); - break; - case GL_POINT_SIZE_RANGE: - params[0] = IROUND(ctx->Const.MinPointSizeAA); - params[1] = IROUND(ctx->Const.MaxPointSizeAA); - break; - case GL_ALIASED_POINT_SIZE_RANGE: - params[0] = IROUND(ctx->Const.MinPointSize); - params[1] = IROUND(ctx->Const.MaxPointSize); - break; - case GL_POINT_SMOOTH: - params[0] = BOOLEAN_TO_INT(ctx->Point.SmoothFlag); - break; - case GL_POINT_SMOOTH_HINT: - params[0] = ENUM_TO_INT(ctx->Hint.PointSmooth); - break; - case GL_POINT_SIZE_MIN_EXT: - params[0] = IROUND(ctx->Point.MinSize); - break; - case GL_POINT_SIZE_MAX_EXT: - params[0] = IROUND(ctx->Point.MaxSize); - break; - case GL_POINT_FADE_THRESHOLD_SIZE_EXT: - params[0] = IROUND(ctx->Point.Threshold); - break; - case GL_DISTANCE_ATTENUATION_EXT: - params[0] = IROUND(ctx->Point.Params[0]); - params[1] = IROUND(ctx->Point.Params[1]); - params[2] = IROUND(ctx->Point.Params[2]); - break; - case GL_POLYGON_MODE: - params[0] = ENUM_TO_INT(ctx->Polygon.FrontMode); - params[1] = ENUM_TO_INT(ctx->Polygon.BackMode); - break; - case GL_POLYGON_OFFSET_BIAS_EXT: - params[0] = IROUND(ctx->Polygon.OffsetUnits); - break; - case GL_POLYGON_OFFSET_FACTOR: - params[0] = IROUND(ctx->Polygon.OffsetFactor ); - break; - case GL_POLYGON_OFFSET_UNITS: - params[0] = IROUND(ctx->Polygon.OffsetUnits ); - break; - case GL_POLYGON_OFFSET_POINT: - params[0] = BOOLEAN_TO_INT(ctx->Polygon.OffsetPoint); - break; - case GL_POLYGON_OFFSET_LINE: - params[0] = BOOLEAN_TO_INT(ctx->Polygon.OffsetLine); - break; - case GL_POLYGON_OFFSET_FILL: - params[0] = BOOLEAN_TO_INT(ctx->Polygon.OffsetFill); - break; - case GL_POLYGON_SMOOTH: - params[0] = BOOLEAN_TO_INT(ctx->Polygon.SmoothFlag); - break; - case GL_POLYGON_SMOOTH_HINT: - params[0] = ENUM_TO_INT(ctx->Hint.PolygonSmooth); - break; - case GL_POLYGON_STIPPLE: - params[0] = BOOLEAN_TO_INT(ctx->Polygon.StippleFlag); - break; - case GL_PROJECTION_MATRIX: - { - const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m; - params[0] = IROUND(matrix[0]); - params[1] = IROUND(matrix[1]); - params[2] = IROUND(matrix[2]); - params[3] = IROUND(matrix[3]); - params[4] = IROUND(matrix[4]); - params[5] = IROUND(matrix[5]); - params[6] = IROUND(matrix[6]); - params[7] = IROUND(matrix[7]); - params[8] = IROUND(matrix[8]); - params[9] = IROUND(matrix[9]); - params[10] = IROUND(matrix[10]); - params[11] = IROUND(matrix[11]); - params[12] = IROUND(matrix[12]); - params[13] = IROUND(matrix[13]); - params[14] = IROUND(matrix[14]); - params[15] = IROUND(matrix[15]); - } - break; - case GL_PROJECTION_STACK_DEPTH: - params[0] = ctx->ProjectionMatrixStack.Depth + 1; - break; - case GL_READ_BUFFER: - params[0] = ENUM_TO_INT(ctx->ReadBuffer->ColorReadBuffer); - break; - case GL_RED_BIAS: - params[0] = IROUND(ctx->Pixel.RedBias); - break; - case GL_RED_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = ctx->DrawBuffer->Visual.redBits; - break; - case GL_RED_SCALE: - params[0] = IROUND(ctx->Pixel.RedScale); - break; - case GL_RENDER_MODE: - params[0] = ENUM_TO_INT(ctx->RenderMode); - break; - case GL_RESCALE_NORMAL: - params[0] = BOOLEAN_TO_INT(ctx->Transform.RescaleNormals); - break; - case GL_RGBA_MODE: - params[0] = BOOLEAN_TO_INT(GL_TRUE); - break; - case GL_SCISSOR_BOX: - params[0] = ctx->Scissor.X; - params[1] = ctx->Scissor.Y; - params[2] = ctx->Scissor.Width; - params[3] = ctx->Scissor.Height; - break; - case GL_SCISSOR_TEST: - params[0] = BOOLEAN_TO_INT(ctx->Scissor.Enabled); - break; - case GL_SELECTION_BUFFER_SIZE: - params[0] = ctx->Select.BufferSize; - break; - case GL_SHADE_MODEL: - params[0] = ENUM_TO_INT(ctx->Light.ShadeModel); - break; - case GL_SHARED_TEXTURE_PALETTE_EXT: - params[0] = BOOLEAN_TO_INT(ctx->Texture.SharedPalette); - break; - case GL_STENCIL_BITS: - params[0] = ctx->DrawBuffer->Visual.stencilBits; - break; - case GL_STENCIL_CLEAR_VALUE: - params[0] = ctx->Stencil.Clear; - break; - case GL_STENCIL_FAIL: - params[0] = ENUM_TO_INT(ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_FUNC: - params[0] = ENUM_TO_INT(ctx->Stencil.Function[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_PASS_DEPTH_FAIL: - params[0] = ENUM_TO_INT(ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_PASS_DEPTH_PASS: - params[0] = ENUM_TO_INT(ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_REF: - params[0] = ctx->Stencil.Ref[ctx->Stencil.ActiveFace]; - break; - case GL_STENCIL_TEST: - params[0] = BOOLEAN_TO_INT(ctx->Stencil.Enabled); - break; - case GL_STENCIL_VALUE_MASK: - params[0] = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]; - break; - case GL_STENCIL_WRITEMASK: - params[0] = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]; - break; - case GL_STEREO: - params[0] = BOOLEAN_TO_INT(ctx->DrawBuffer->Visual.stereoMode); - break; - case GL_SUBPIXEL_BITS: - params[0] = ctx->Const.SubPixelBits; - break; - case GL_TEXTURE_1D: - params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_1D)); - break; - case GL_TEXTURE_2D: - params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_2D)); - break; - case GL_TEXTURE_3D: - params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_3D)); - break; - case GL_TEXTURE_1D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_1D_ARRAY_EXT)); - break; - case GL_TEXTURE_2D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_2D_ARRAY_EXT)); - break; - case GL_TEXTURE_BINDING_1D: - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_INDEX]->Name; - break; - case GL_TEXTURE_BINDING_2D: - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name; - break; - case GL_TEXTURE_BINDING_3D: - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name; - break; - case GL_TEXTURE_BINDING_1D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_ARRAY_INDEX]->Name; - break; - case GL_TEXTURE_BINDING_2D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name; - break; - case GL_MAX_ARRAY_TEXTURE_LAYERS_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = ctx->Const.MaxArrayTextureLayers; - break; - case GL_TEXTURE_GEN_S: - params[0] = BOOLEAN_TO_INT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)); - break; - case GL_TEXTURE_GEN_T: - params[0] = BOOLEAN_TO_INT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0)); - break; - case GL_TEXTURE_GEN_R: - params[0] = BOOLEAN_TO_INT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0)); - break; - case GL_TEXTURE_GEN_Q: - params[0] = BOOLEAN_TO_INT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & Q_BIT) ? 1 : 0)); - break; - case GL_TEXTURE_MATRIX: - { - const GLfloat *matrix; - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGet(texture matrix %u)", - unit); - return; - } - matrix = ctx->TextureMatrixStack[unit].Top->m; - params[0] = IROUND(matrix[0]); - params[1] = IROUND(matrix[1]); - params[2] = IROUND(matrix[2]); - params[3] = IROUND(matrix[3]); - params[4] = IROUND(matrix[4]); - params[5] = IROUND(matrix[5]); - params[6] = IROUND(matrix[6]); - params[7] = IROUND(matrix[7]); - params[8] = IROUND(matrix[8]); - params[9] = IROUND(matrix[9]); - params[10] = IROUND(matrix[10]); - params[11] = IROUND(matrix[11]); - params[12] = IROUND(matrix[12]); - params[13] = IROUND(matrix[13]); - params[14] = IROUND(matrix[14]); - params[15] = IROUND(matrix[15]); - } - break; - case GL_TEXTURE_STACK_DEPTH: - { - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(texture stack depth, unit %u)", unit); - return; - } - params[0] = ctx->TextureMatrixStack[unit].Depth + 1; - } - break; - case GL_UNPACK_ALIGNMENT: - params[0] = ctx->Unpack.Alignment; - break; - case GL_UNPACK_LSB_FIRST: - params[0] = BOOLEAN_TO_INT(ctx->Unpack.LsbFirst); - break; - case GL_UNPACK_ROW_LENGTH: - params[0] = ctx->Unpack.RowLength; - break; - case GL_UNPACK_SKIP_PIXELS: - params[0] = ctx->Unpack.SkipPixels; - break; - case GL_UNPACK_SKIP_ROWS: - params[0] = ctx->Unpack.SkipRows; - break; - case GL_UNPACK_SWAP_BYTES: - params[0] = BOOLEAN_TO_INT(ctx->Unpack.SwapBytes); - break; - case GL_UNPACK_SKIP_IMAGES_EXT: - params[0] = ctx->Unpack.SkipImages; - break; - case GL_UNPACK_IMAGE_HEIGHT_EXT: - params[0] = ctx->Unpack.ImageHeight; - break; - case GL_UNPACK_CLIENT_STORAGE_APPLE: - params[0] = BOOLEAN_TO_INT(ctx->Unpack.ClientStorage); - break; - case GL_VIEWPORT: - params[0] = ctx->Viewport.X; - params[1] = ctx->Viewport.Y; - params[2] = ctx->Viewport.Width; - params[3] = ctx->Viewport.Height; - break; - case GL_ZOOM_X: - params[0] = IROUND(ctx->Pixel.ZoomX); - break; - case GL_ZOOM_Y: - params[0] = IROUND(ctx->Pixel.ZoomY); - break; - case GL_VERTEX_ARRAY: - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->Vertex.Enabled); - break; - case GL_VERTEX_ARRAY_SIZE: - params[0] = ctx->Array.ArrayObj->Vertex.Size; - break; - case GL_VERTEX_ARRAY_TYPE: - params[0] = ENUM_TO_INT(ctx->Array.ArrayObj->Vertex.Type); - break; - case GL_VERTEX_ARRAY_STRIDE: - params[0] = ctx->Array.ArrayObj->Vertex.Stride; - break; - case GL_VERTEX_ARRAY_COUNT_EXT: - params[0] = 0; - break; - case GL_NORMAL_ARRAY: - params[0] = ENUM_TO_INT(ctx->Array.ArrayObj->Normal.Enabled); - break; - case GL_NORMAL_ARRAY_TYPE: - params[0] = ENUM_TO_INT(ctx->Array.ArrayObj->Normal.Type); - break; - case GL_NORMAL_ARRAY_STRIDE: - params[0] = ctx->Array.ArrayObj->Normal.Stride; - break; - case GL_NORMAL_ARRAY_COUNT_EXT: - params[0] = 0; - break; - case GL_COLOR_ARRAY: - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->Color.Enabled); - break; - case GL_COLOR_ARRAY_SIZE: - params[0] = ctx->Array.ArrayObj->Color.Size; - break; - case GL_COLOR_ARRAY_TYPE: - params[0] = ENUM_TO_INT(ctx->Array.ArrayObj->Color.Type); - break; - case GL_COLOR_ARRAY_STRIDE: - params[0] = ctx->Array.ArrayObj->Color.Stride; - break; - case GL_COLOR_ARRAY_COUNT_EXT: - params[0] = 0; - break; - case GL_INDEX_ARRAY: - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->Index.Enabled); - break; - case GL_INDEX_ARRAY_TYPE: - params[0] = ENUM_TO_INT(ctx->Array.ArrayObj->Index.Type); - break; - case GL_INDEX_ARRAY_STRIDE: - params[0] = ctx->Array.ArrayObj->Index.Stride; - break; - case GL_INDEX_ARRAY_COUNT_EXT: - params[0] = 0; - break; - case GL_TEXTURE_COORD_ARRAY: - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled); - break; - case GL_TEXTURE_COORD_ARRAY_SIZE: - params[0] = ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size; - break; - case GL_TEXTURE_COORD_ARRAY_TYPE: - params[0] = ENUM_TO_INT(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Type); - break; - case GL_TEXTURE_COORD_ARRAY_STRIDE: - params[0] = ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride; - break; - case GL_TEXTURE_COORD_ARRAY_COUNT_EXT: - params[0] = 0; - break; - case GL_EDGE_FLAG_ARRAY: - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->EdgeFlag.Enabled); - break; - case GL_EDGE_FLAG_ARRAY_STRIDE: - params[0] = ctx->Array.ArrayObj->EdgeFlag.Stride; - break; - case GL_EDGE_FLAG_ARRAY_COUNT_EXT: - params[0] = 0; - break; - case GL_MAX_TEXTURE_UNITS_ARB: - CHECK_EXT1(ARB_multitexture); - params[0] = ctx->Const.MaxTextureUnits; - break; - case GL_ACTIVE_TEXTURE_ARB: - CHECK_EXT1(ARB_multitexture); - params[0] = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit; - break; - case GL_CLIENT_ACTIVE_TEXTURE_ARB: - CHECK_EXT1(ARB_multitexture); - params[0] = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture; - break; - case GL_TEXTURE_CUBE_MAP_ARB: - CHECK_EXT1(ARB_texture_cube_map); - params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB)); - break; - case GL_TEXTURE_BINDING_CUBE_MAP_ARB: - CHECK_EXT1(ARB_texture_cube_map); - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_CUBE_INDEX]->Name; - break; - case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: - CHECK_EXT1(ARB_texture_cube_map); - params[0] = (1 << (ctx->Const.MaxCubeTextureLevels - 1)); - break; - case GL_TEXTURE_COMPRESSION_HINT_ARB: - params[0] = ctx->Hint.TextureCompression; - break; - case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: - params[0] = _mesa_get_compressed_formats(ctx, NULL, GL_FALSE); - break; - case GL_COMPRESSED_TEXTURE_FORMATS_ARB: - { - GLint formats[100]; - GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE); - ASSERT(n <= 100); - for (i = 0; i < n; i++) - params[i] = ENUM_TO_INT(formats[i]); - } - break; - case GL_ARRAY_ELEMENT_LOCK_FIRST_EXT: - CHECK_EXT1(EXT_compiled_vertex_array); - params[0] = ctx->Array.LockFirst; - break; - case GL_ARRAY_ELEMENT_LOCK_COUNT_EXT: - CHECK_EXT1(EXT_compiled_vertex_array); - params[0] = ctx->Array.LockCount; - break; - case GL_TRANSPOSE_COLOR_MATRIX_ARB: - { - const GLfloat *matrix = ctx->ColorMatrixStack.Top->m; - params[0] = IROUND(matrix[0]); - params[1] = IROUND(matrix[4]); - params[2] = IROUND(matrix[8]); - params[3] = IROUND(matrix[12]); - params[4] = IROUND(matrix[1]); - params[5] = IROUND(matrix[5]); - params[6] = IROUND(matrix[9]); - params[7] = IROUND(matrix[13]); - params[8] = IROUND(matrix[2]); - params[9] = IROUND(matrix[6]); - params[10] = IROUND(matrix[10]); - params[11] = IROUND(matrix[14]); - params[12] = IROUND(matrix[3]); - params[13] = IROUND(matrix[7]); - params[14] = IROUND(matrix[11]); - params[15] = IROUND(matrix[15]); - } - break; - case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB: - { - const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m; - params[0] = IROUND(matrix[0]); - params[1] = IROUND(matrix[4]); - params[2] = IROUND(matrix[8]); - params[3] = IROUND(matrix[12]); - params[4] = IROUND(matrix[1]); - params[5] = IROUND(matrix[5]); - params[6] = IROUND(matrix[9]); - params[7] = IROUND(matrix[13]); - params[8] = IROUND(matrix[2]); - params[9] = IROUND(matrix[6]); - params[10] = IROUND(matrix[10]); - params[11] = IROUND(matrix[14]); - params[12] = IROUND(matrix[3]); - params[13] = IROUND(matrix[7]); - params[14] = IROUND(matrix[11]); - params[15] = IROUND(matrix[15]); - } - break; - case GL_TRANSPOSE_PROJECTION_MATRIX_ARB: - { - const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m; - params[0] = IROUND(matrix[0]); - params[1] = IROUND(matrix[4]); - params[2] = IROUND(matrix[8]); - params[3] = IROUND(matrix[12]); - params[4] = IROUND(matrix[1]); - params[5] = IROUND(matrix[5]); - params[6] = IROUND(matrix[9]); - params[7] = IROUND(matrix[13]); - params[8] = IROUND(matrix[2]); - params[9] = IROUND(matrix[6]); - params[10] = IROUND(matrix[10]); - params[11] = IROUND(matrix[14]); - params[12] = IROUND(matrix[3]); - params[13] = IROUND(matrix[7]); - params[14] = IROUND(matrix[11]); - params[15] = IROUND(matrix[15]); - } - break; - case GL_TRANSPOSE_TEXTURE_MATRIX_ARB: - { - const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m; - params[0] = IROUND(matrix[0]); - params[1] = IROUND(matrix[4]); - params[2] = IROUND(matrix[8]); - params[3] = IROUND(matrix[12]); - params[4] = IROUND(matrix[1]); - params[5] = IROUND(matrix[5]); - params[6] = IROUND(matrix[9]); - params[7] = IROUND(matrix[13]); - params[8] = IROUND(matrix[2]); - params[9] = IROUND(matrix[6]); - params[10] = IROUND(matrix[10]); - params[11] = IROUND(matrix[14]); - params[12] = IROUND(matrix[3]); - params[13] = IROUND(matrix[7]); - params[14] = IROUND(matrix[11]); - params[15] = IROUND(matrix[15]); - } - break; - case GL_COLOR_MATRIX_SGI: - { - const GLfloat *matrix = ctx->ColorMatrixStack.Top->m; - params[0] = IROUND(matrix[0]); - params[1] = IROUND(matrix[1]); - params[2] = IROUND(matrix[2]); - params[3] = IROUND(matrix[3]); - params[4] = IROUND(matrix[4]); - params[5] = IROUND(matrix[5]); - params[6] = IROUND(matrix[6]); - params[7] = IROUND(matrix[7]); - params[8] = IROUND(matrix[8]); - params[9] = IROUND(matrix[9]); - params[10] = IROUND(matrix[10]); - params[11] = IROUND(matrix[11]); - params[12] = IROUND(matrix[12]); - params[13] = IROUND(matrix[13]); - params[14] = IROUND(matrix[14]); - params[15] = IROUND(matrix[15]); - } - break; - case GL_COLOR_MATRIX_STACK_DEPTH_SGI: - params[0] = ctx->ColorMatrixStack.Depth + 1; - break; - case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: - params[0] = MAX_COLOR_STACK_DEPTH; - break; - case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: - params[0] = IROUND(ctx->Pixel.PostColorMatrixScale[0]); - break; - case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: - params[0] = IROUND(ctx->Pixel.PostColorMatrixScale[1]); - break; - case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: - params[0] = IROUND(ctx->Pixel.PostColorMatrixScale[2]); - break; - case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: - params[0] = IROUND(ctx->Pixel.PostColorMatrixScale[3]); - break; - case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: - params[0] = IROUND(ctx->Pixel.PostColorMatrixBias[0]); - break; - case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: - params[0] = IROUND(ctx->Pixel.PostColorMatrixBias[1]); - break; - case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: - params[0] = IROUND(ctx->Pixel.PostColorMatrixBias[2]); - break; - case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: - params[0] = IROUND(ctx->Pixel.PostColorMatrixBias[3]); - break; - case GL_CONVOLUTION_1D_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = BOOLEAN_TO_INT(ctx->Pixel.Convolution1DEnabled); - break; - case GL_CONVOLUTION_2D_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = BOOLEAN_TO_INT(ctx->Pixel.Convolution2DEnabled); - break; - case GL_SEPARABLE_2D_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = BOOLEAN_TO_INT(ctx->Pixel.Separable2DEnabled); - break; - case GL_POST_CONVOLUTION_RED_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND(ctx->Pixel.PostConvolutionScale[0]); - break; - case GL_POST_CONVOLUTION_GREEN_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND(ctx->Pixel.PostConvolutionScale[1]); - break; - case GL_POST_CONVOLUTION_BLUE_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND(ctx->Pixel.PostConvolutionScale[2]); - break; - case GL_POST_CONVOLUTION_ALPHA_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND(ctx->Pixel.PostConvolutionScale[3]); - break; - case GL_POST_CONVOLUTION_RED_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND(ctx->Pixel.PostConvolutionBias[0]); - break; - case GL_POST_CONVOLUTION_GREEN_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND(ctx->Pixel.PostConvolutionBias[1]); - break; - case GL_POST_CONVOLUTION_BLUE_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND(ctx->Pixel.PostConvolutionBias[2]); - break; - case GL_POST_CONVOLUTION_ALPHA_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND(ctx->Pixel.PostConvolutionBias[3]); - break; - case GL_HISTOGRAM: - CHECK_EXT1(EXT_histogram); - params[0] = BOOLEAN_TO_INT(ctx->Pixel.HistogramEnabled); - break; - case GL_MINMAX: - CHECK_EXT1(EXT_histogram); - params[0] = BOOLEAN_TO_INT(ctx->Pixel.MinMaxEnabled); - break; - case GL_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_color_table); - params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]); - break; - case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_color_table); - params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]); - break; - case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_color_table); - params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]); - break; - case GL_TEXTURE_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_texture_color_table); - params[0] = BOOLEAN_TO_INT(ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled); - break; - case GL_COLOR_SUM_EXT: - CHECK_EXT2(EXT_secondary_color, ARB_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Fog.ColorSumEnabled); - break; - case GL_CURRENT_SECONDARY_COLOR_EXT: - CHECK_EXT1(EXT_secondary_color); - FLUSH_CURRENT(ctx, 0); - params[0] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]); - params[1] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]); - params[2] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]); - params[3] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]); - break; - case GL_SECONDARY_COLOR_ARRAY_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->SecondaryColor.Enabled); - break; - case GL_SECONDARY_COLOR_ARRAY_TYPE_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = ENUM_TO_INT(ctx->Array.ArrayObj->SecondaryColor.Type); - break; - case GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = ctx->Array.ArrayObj->SecondaryColor.Stride; - break; - case GL_SECONDARY_COLOR_ARRAY_SIZE_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = ctx->Array.ArrayObj->SecondaryColor.Size; - break; - case GL_CURRENT_FOG_COORDINATE_EXT: - CHECK_EXT1(EXT_fog_coord); - FLUSH_CURRENT(ctx, 0); - params[0] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_FOG][0]); - break; - case GL_FOG_COORDINATE_ARRAY_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->FogCoord.Enabled); - break; - case GL_FOG_COORDINATE_ARRAY_TYPE_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = ENUM_TO_INT(ctx->Array.ArrayObj->FogCoord.Type); - break; - case GL_FOG_COORDINATE_ARRAY_STRIDE_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = ctx->Array.ArrayObj->FogCoord.Stride; - break; - case GL_FOG_COORDINATE_SOURCE_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = ENUM_TO_INT(ctx->Fog.FogCoordinateSource); - break; - case GL_MAX_TEXTURE_LOD_BIAS_EXT: - CHECK_EXT1(EXT_texture_lod_bias); - params[0] = IROUND(ctx->Const.MaxTextureLodBias); - break; - case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: - CHECK_EXT1(EXT_texture_filter_anisotropic); - params[0] = IROUND(ctx->Const.MaxTextureMaxAnisotropy); - break; - case GL_MULTISAMPLE_ARB: - params[0] = BOOLEAN_TO_INT(ctx->Multisample.Enabled); - break; - case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: - params[0] = BOOLEAN_TO_INT(ctx->Multisample.SampleAlphaToCoverage); - break; - case GL_SAMPLE_ALPHA_TO_ONE_ARB: - params[0] = BOOLEAN_TO_INT(ctx->Multisample.SampleAlphaToOne); - break; - case GL_SAMPLE_COVERAGE_ARB: - params[0] = BOOLEAN_TO_INT(ctx->Multisample.SampleCoverage); - break; - case GL_SAMPLE_COVERAGE_VALUE_ARB: - params[0] = IROUND(ctx->Multisample.SampleCoverageValue); - break; - case GL_SAMPLE_COVERAGE_INVERT_ARB: - params[0] = BOOLEAN_TO_INT(ctx->Multisample.SampleCoverageInvert); - break; - case GL_SAMPLE_BUFFERS_ARB: - params[0] = ctx->DrawBuffer->Visual.sampleBuffers; - break; - case GL_SAMPLES_ARB: - params[0] = ctx->DrawBuffer->Visual.samples; - break; - case GL_RASTER_POSITION_UNCLIPPED_IBM: - CHECK_EXT1(IBM_rasterpos_clip); - params[0] = BOOLEAN_TO_INT(ctx->Transform.RasterPositionUnclipped); - break; - case GL_POINT_SPRITE_NV: - CHECK_EXT2(NV_point_sprite, ARB_point_sprite); - params[0] = BOOLEAN_TO_INT(ctx->Point.PointSprite); - break; - case GL_POINT_SPRITE_R_MODE_NV: - CHECK_EXT1(NV_point_sprite); - params[0] = ENUM_TO_INT(ctx->Point.SpriteRMode); - break; - case GL_POINT_SPRITE_COORD_ORIGIN: - CHECK_EXT2(NV_point_sprite, ARB_point_sprite); - params[0] = ENUM_TO_INT(ctx->Point.SpriteOrigin); - break; - case GL_GENERATE_MIPMAP_HINT_SGIS: - CHECK_EXT1(SGIS_generate_mipmap); - params[0] = ENUM_TO_INT(ctx->Hint.GenerateMipmap); - break; - case GL_VERTEX_PROGRAM_BINDING_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = (ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0); - break; - case GL_VERTEX_ATTRIB_ARRAY0_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[0].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY1_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[1].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY2_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[2].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY3_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[3].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[4].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY5_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[5].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY6_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[6].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY7_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[7].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY8_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[8].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY9_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[9].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY10_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[10].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY11_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[11].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY12_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[12].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY13_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[13].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY14_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[14].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY15_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Array.ArrayObj->VertexAttrib[15].Enabled); - break; - case GL_MAP1_VERTEX_ATTRIB0_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[0]); - break; - case GL_MAP1_VERTEX_ATTRIB1_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[1]); - break; - case GL_MAP1_VERTEX_ATTRIB2_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[2]); - break; - case GL_MAP1_VERTEX_ATTRIB3_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[3]); - break; - case GL_MAP1_VERTEX_ATTRIB4_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[4]); - break; - case GL_MAP1_VERTEX_ATTRIB5_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[5]); - break; - case GL_MAP1_VERTEX_ATTRIB6_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[6]); - break; - case GL_MAP1_VERTEX_ATTRIB7_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[7]); - break; - case GL_MAP1_VERTEX_ATTRIB8_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[8]); - break; - case GL_MAP1_VERTEX_ATTRIB9_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[9]); - break; - case GL_MAP1_VERTEX_ATTRIB10_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[10]); - break; - case GL_MAP1_VERTEX_ATTRIB11_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[11]); - break; - case GL_MAP1_VERTEX_ATTRIB12_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[12]); - break; - case GL_MAP1_VERTEX_ATTRIB13_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[13]); - break; - case GL_MAP1_VERTEX_ATTRIB14_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[14]); - break; - case GL_MAP1_VERTEX_ATTRIB15_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[15]); - break; - case GL_FRAGMENT_PROGRAM_NV: - CHECK_EXT1(NV_fragment_program); - params[0] = BOOLEAN_TO_INT(ctx->FragmentProgram.Enabled); - break; - case GL_FRAGMENT_PROGRAM_BINDING_NV: - CHECK_EXT1(NV_fragment_program); - params[0] = ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0; - break; - case GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV: - CHECK_EXT1(NV_fragment_program); - params[0] = MAX_NV_FRAGMENT_PROGRAM_PARAMS; - break; - case GL_TEXTURE_RECTANGLE_NV: - CHECK_EXT1(NV_texture_rectangle); - params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV)); - break; - case GL_TEXTURE_BINDING_RECTANGLE_NV: - CHECK_EXT1(NV_texture_rectangle); - params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_RECT_INDEX]->Name; - break; - case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV: - CHECK_EXT1(NV_texture_rectangle); - params[0] = ctx->Const.MaxTextureRectSize; - break; - case GL_STENCIL_TEST_TWO_SIDE_EXT: - CHECK_EXT1(EXT_stencil_two_side); - params[0] = BOOLEAN_TO_INT(ctx->Stencil.TestTwoSide); - break; - case GL_ACTIVE_STENCIL_FACE_EXT: - CHECK_EXT1(EXT_stencil_two_side); - params[0] = ENUM_TO_INT(ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT); - break; - case GL_MAX_SHININESS_NV: - CHECK_EXT1(NV_light_max_exponent); - params[0] = IROUND(ctx->Const.MaxShininess); - break; - case GL_MAX_SPOT_EXPONENT_NV: - CHECK_EXT1(NV_light_max_exponent); - params[0] = IROUND(ctx->Const.MaxSpotExponent); - break; - case GL_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayBufferObj->Name; - break; - case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->Vertex.BufferObj->Name; - break; - case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->Normal.BufferObj->Name; - break; - case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->Color.BufferObj->Name; - break; - case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->Index.BufferObj->Name; - break; - case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name; - break; - case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->EdgeFlag.BufferObj->Name; - break; - case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->SecondaryColor.BufferObj->Name; - break; - case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ArrayObj->FogCoord.BufferObj->Name; - break; - case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: - params[0] = ctx->Array.ElementArrayBufferObj->Name; - break; - case GL_PIXEL_PACK_BUFFER_BINDING_EXT: - CHECK_EXT1(EXT_pixel_buffer_object); - params[0] = ctx->Pack.BufferObj->Name; - break; - case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT: - CHECK_EXT1(EXT_pixel_buffer_object); - params[0] = ctx->Unpack.BufferObj->Name; - break; - case GL_VERTEX_PROGRAM_ARB: - CHECK_EXT2(ARB_vertex_program, NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->VertexProgram.Enabled); - break; - case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: - CHECK_EXT2(ARB_vertex_program, NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->VertexProgram.PointSizeEnabled); - break; - case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: - CHECK_EXT2(ARB_vertex_program, NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->VertexProgram.TwoSideEnabled); - break; - case GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program); - params[0] = ctx->Const.MaxProgramMatrixStackDepth; - break; - case GL_MAX_PROGRAM_MATRICES_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program); - params[0] = ctx->Const.MaxProgramMatrices; - break; - case GL_CURRENT_MATRIX_STACK_DEPTH_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program); - params[0] = BOOLEAN_TO_INT(ctx->CurrentStack->Depth + 1); - break; - case GL_CURRENT_MATRIX_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_fragment_program); - { - const GLfloat *matrix = ctx->CurrentStack->Top->m; - params[0] = IROUND(matrix[0]); - params[1] = IROUND(matrix[1]); - params[2] = IROUND(matrix[2]); - params[3] = IROUND(matrix[3]); - params[4] = IROUND(matrix[4]); - params[5] = IROUND(matrix[5]); - params[6] = IROUND(matrix[6]); - params[7] = IROUND(matrix[7]); - params[8] = IROUND(matrix[8]); - params[9] = IROUND(matrix[9]); - params[10] = IROUND(matrix[10]); - params[11] = IROUND(matrix[11]); - params[12] = IROUND(matrix[12]); - params[13] = IROUND(matrix[13]); - params[14] = IROUND(matrix[14]); - params[15] = IROUND(matrix[15]); - } - break; - case GL_TRANSPOSE_CURRENT_MATRIX_ARB: - CHECK_EXT2(ARB_vertex_program, ARB_fragment_program); - { - const GLfloat *matrix = ctx->CurrentStack->Top->m; - params[0] = IROUND(matrix[0]); - params[1] = IROUND(matrix[4]); - params[2] = IROUND(matrix[8]); - params[3] = IROUND(matrix[12]); - params[4] = IROUND(matrix[1]); - params[5] = IROUND(matrix[5]); - params[6] = IROUND(matrix[9]); - params[7] = IROUND(matrix[13]); - params[8] = IROUND(matrix[2]); - params[9] = IROUND(matrix[6]); - params[10] = IROUND(matrix[10]); - params[11] = IROUND(matrix[14]); - params[12] = IROUND(matrix[3]); - params[13] = IROUND(matrix[7]); - params[14] = IROUND(matrix[11]); - params[15] = IROUND(matrix[15]); - } - break; - case GL_MAX_VERTEX_ATTRIBS_ARB: - CHECK_EXT1(ARB_vertex_program); - params[0] = ctx->Const.VertexProgram.MaxAttribs; - break; - case GL_PROGRAM_ERROR_POSITION_ARB: - CHECK_EXT4(NV_vertex_program, ARB_vertex_program, NV_fragment_program, ARB_fragment_program); - params[0] = ctx->Program.ErrorPos; - break; - case GL_FRAGMENT_PROGRAM_ARB: - CHECK_EXT1(ARB_fragment_program); - params[0] = BOOLEAN_TO_INT(ctx->FragmentProgram.Enabled); - break; - case GL_MAX_TEXTURE_COORDS_ARB: - CHECK_EXT2(ARB_fragment_program, NV_fragment_program); - params[0] = ctx->Const.MaxTextureCoordUnits; - break; - case GL_MAX_TEXTURE_IMAGE_UNITS_ARB: - CHECK_EXT2(ARB_fragment_program, NV_fragment_program); - params[0] = ctx->Const.MaxTextureImageUnits; - break; - case GL_DEPTH_BOUNDS_TEST_EXT: - CHECK_EXT1(EXT_depth_bounds_test); - params[0] = BOOLEAN_TO_INT(ctx->Depth.BoundsTest); - break; - case GL_DEPTH_BOUNDS_EXT: - CHECK_EXT1(EXT_depth_bounds_test); - params[0] = IROUND(ctx->Depth.BoundsMin); - params[1] = IROUND(ctx->Depth.BoundsMax); - break; - case GL_DEPTH_CLAMP: - CHECK_EXT1(ARB_depth_clamp); - params[0] = BOOLEAN_TO_INT(ctx->Transform.DepthClamp); - break; - case GL_MAX_DRAW_BUFFERS_ARB: - params[0] = ctx->Const.MaxDrawBuffers; - break; - case GL_DRAW_BUFFER0_ARB: - params[0] = ENUM_TO_INT(ctx->DrawBuffer->ColorDrawBuffer[0]); - break; - case GL_DRAW_BUFFER1_ARB: - { - GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[1]; - params[0] = ENUM_TO_INT(buffer); - } - break; - case GL_DRAW_BUFFER2_ARB: - { - GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[2]; - params[0] = ENUM_TO_INT(buffer); - } - break; - case GL_DRAW_BUFFER3_ARB: - { - GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[3]; - params[0] = ENUM_TO_INT(buffer); - } - break; - case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: - CHECK_EXT1(OES_read_format); - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = _mesa_get_color_read_type(ctx); - break; - case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: - CHECK_EXT1(OES_read_format); - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = _mesa_get_color_read_format(ctx); - break; - case GL_NUM_FRAGMENT_REGISTERS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = 6; - break; - case GL_NUM_FRAGMENT_CONSTANTS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = 8; - break; - case GL_NUM_PASSES_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = 2; - break; - case GL_NUM_INSTRUCTIONS_PER_PASS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = 8; - break; - case GL_NUM_INSTRUCTIONS_TOTAL_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = 16; - break; - case GL_COLOR_ALPHA_PAIRING_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = BOOLEAN_TO_INT(GL_TRUE); - break; - case GL_NUM_LOOPBACK_COMPONENTS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = 3; - break; - case GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = 3; - break; - case GL_STENCIL_BACK_FUNC: - params[0] = ENUM_TO_INT(ctx->Stencil.Function[1]); - break; - case GL_STENCIL_BACK_VALUE_MASK: - params[0] = ctx->Stencil.ValueMask[1]; - break; - case GL_STENCIL_BACK_WRITEMASK: - params[0] = ctx->Stencil.WriteMask[1]; - break; - case GL_STENCIL_BACK_REF: - params[0] = ctx->Stencil.Ref[1]; - break; - case GL_STENCIL_BACK_FAIL: - params[0] = ENUM_TO_INT(ctx->Stencil.FailFunc[1]); - break; - case GL_STENCIL_BACK_PASS_DEPTH_FAIL: - params[0] = ENUM_TO_INT(ctx->Stencil.ZFailFunc[1]); - break; - case GL_STENCIL_BACK_PASS_DEPTH_PASS: - params[0] = ENUM_TO_INT(ctx->Stencil.ZPassFunc[1]); - break; - case GL_FRAMEBUFFER_BINDING_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = ctx->DrawBuffer->Name; - break; - case GL_RENDERBUFFER_BINDING_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0; - break; - case GL_MAX_COLOR_ATTACHMENTS_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = ctx->Const.MaxColorAttachments; - break; - case GL_MAX_RENDERBUFFER_SIZE_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = ctx->Const.MaxRenderbufferSize; - break; - case GL_READ_FRAMEBUFFER_BINDING_EXT: - CHECK_EXT1(EXT_framebuffer_blit); - params[0] = ctx->ReadBuffer->Name; - break; - case GL_PROVOKING_VERTEX_EXT: - CHECK_EXT1(EXT_provoking_vertex); - params[0] = BOOLEAN_TO_INT(ctx->Light.ProvokingVertex); - break; - case GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT: - CHECK_EXT1(EXT_provoking_vertex); - params[0] = BOOLEAN_TO_INT(ctx->Const.QuadsFollowProvokingVertexConvention); - break; - case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB: - CHECK_EXT1(ARB_fragment_shader); - params[0] = ctx->Const.FragmentProgram.MaxUniformComponents; - break; - case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB: - CHECK_EXT1(ARB_fragment_shader); - params[0] = ENUM_TO_INT(ctx->Hint.FragmentShaderDerivative); - break; - case GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = ctx->Const.VertexProgram.MaxUniformComponents; - break; - case GL_MAX_VARYING_FLOATS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = ctx->Const.MaxVarying * 4; - break; - case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = ctx->Const.MaxVertexTextureImageUnits; - break; - case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = ctx->Const.MaxCombinedTextureImageUnits; - break; - case GL_CURRENT_PROGRAM: - CHECK_EXT1(ARB_shader_objects); - params[0] = ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0; - break; - case GL_MAX_SAMPLES: - CHECK_EXT1(ARB_framebuffer_object); - params[0] = ctx->Const.MaxSamples; - break; - case GL_VERTEX_ARRAY_BINDING_APPLE: - CHECK_EXT1(APPLE_vertex_array_object); - params[0] = ctx->Array.ArrayObj->Name; - break; - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - CHECK_EXT1(ARB_seamless_cube_map); - params[0] = BOOLEAN_TO_INT(ctx->Texture.CubeMapSeamless); - break; - case GL_MAX_SERVER_WAIT_TIMEOUT: - CHECK_EXT1(ARB_sync); - params[0] = INT64_TO_INT(ctx->Const.MaxServerWaitTimeout); - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: - CHECK_EXT1(EXT_transform_feedback); - params[0] = ctx->TransformFeedback.CurrentBuffer->Name; - break; - case GL_RASTERIZER_DISCARD: - CHECK_EXT1(EXT_transform_feedback); - params[0] = BOOLEAN_TO_INT(ctx->TransformFeedback.RasterDiscard); - break; - case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: - CHECK_EXT1(EXT_transform_feedback); - params[0] = ctx->Const.MaxTransformFeedbackInterleavedComponents; - break; - case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: - CHECK_EXT1(EXT_transform_feedback); - params[0] = ctx->Const.MaxTransformFeedbackSeparateAttribs; - break; - case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: - CHECK_EXT1(EXT_transform_feedback); - params[0] = ctx->Const.MaxTransformFeedbackSeparateComponents; - break; - case GL_NUM_EXTENSIONS: - CHECK_VERSION(30); - params[0] = _mesa_get_extension_count(ctx); - break; - case GL_MAJOR_VERSION: - CHECK_VERSION(30); - params[0] = ctx->VersionMajor; - break; - case GL_MINOR_VERSION: - CHECK_VERSION(30); - params[0] = ctx->VersionMinor; - break; - case GL_CONTEXT_FLAGS: - CHECK_VERSION(30); - params[0] = ctx->Const.ContextFlags; - break; - case GL_PRIMITIVE_RESTART: - CHECK_VERSION(31); - params[0] = BOOLEAN_TO_INT(ctx->Array.PrimitiveRestart); - break; - case GL_PRIMITIVE_RESTART_INDEX: - CHECK_VERSION(31); - params[0] = ctx->Array.RestartIndex; - break; - case GL_CONTEXT_PROFILE_MASK: - CHECK_VERSION(32); - params[0] = ctx->Const.ProfileMask; - break; - default: - goto invalid_enum_error; + case TYPE_DOUBLEN: + params[0] = ((GLdouble *) p)[0]; + break; + + case TYPE_INT_4: + params[3] = (GLfloat) (((GLint *) p)[3]); + case TYPE_INT_3: + params[2] = (GLfloat) (((GLint *) p)[2]); + case TYPE_INT_2: + case TYPE_ENUM_2: + params[1] = (GLfloat) (((GLint *) p)[1]); + case TYPE_INT: + case TYPE_ENUM: + params[0] = (GLfloat) (((GLint *) p)[0]); + break; + + case TYPE_INT_N: + for (i = 0; i < v.value_int_n.n; i++) + params[i] = INT_TO_FLOAT(v.value_int_n.ints[i]); + break; + + case TYPE_INT64: + params[0] = ((GLint64 *) p)[0]; + break; + + case TYPE_BOOLEAN: + params[0] = BOOLEAN_TO_FLOAT(*(GLboolean*) p); + break; + + case TYPE_MATRIX: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = m->m[i]; + break; + + case TYPE_MATRIX_T: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = m->m[transpose[i]]; + break; + + case TYPE_BIT_0: + case TYPE_BIT_1: + case TYPE_BIT_2: + case TYPE_BIT_3: + case TYPE_BIT_4: + case TYPE_BIT_5: + shift = d->type - TYPE_BIT_0; + params[0] = BOOLEAN_TO_FLOAT((*(GLbitfield *) p >> shift) & 1); + break; } - return; +} + +void GLAPIENTRY +_mesa_GetIntegerv(GLenum pname, GLint *params) +{ + const struct value_desc *d; + union value v; + GLmatrix *m; + int shift, i; + void *p; + + d = find_value("glGetIntegerv", pname, &p, &v); + switch (d->type) { + case TYPE_INVALID: + break; + case TYPE_CONST: + params[0] = d->offset; + break; + + case TYPE_FLOAT_4: + params[3] = IROUND(((GLfloat *) p)[3]); + case TYPE_FLOAT_3: + params[2] = IROUND(((GLfloat *) p)[2]); + case TYPE_FLOAT_2: + params[1] = IROUND(((GLfloat *) p)[1]); + case TYPE_FLOAT: + params[0] = IROUND(((GLfloat *) p)[0]); + break; + + case TYPE_FLOATN_4: + params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]); + case TYPE_FLOATN_3: + params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]); + case TYPE_FLOATN_2: + params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]); + case TYPE_FLOATN: + params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]); + break; + + case TYPE_DOUBLEN: + params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]); + break; + + case TYPE_INT_4: + params[3] = ((GLint *) p)[3]; + case TYPE_INT_3: + params[2] = ((GLint *) p)[2]; + case TYPE_INT_2: + case TYPE_ENUM_2: + params[1] = ((GLint *) p)[1]; + case TYPE_INT: + case TYPE_ENUM: + params[0] = ((GLint *) p)[0]; + break; -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv(pname=0x%x)", pname); + case TYPE_INT_N: + for (i = 0; i < v.value_int_n.n; i++) + params[i] = v.value_int_n.ints[i]; + break; + + case TYPE_INT64: + params[0] = INT64_TO_INT(((GLint64 *) p)[0]); + break; + + case TYPE_BOOLEAN: + params[0] = BOOLEAN_TO_INT(*(GLboolean*) p); + break; + + case TYPE_MATRIX: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_INT(m->m[i]); + break; + + case TYPE_MATRIX_T: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_INT(m->m[transpose[i]]); + break; + + case TYPE_BIT_0: + case TYPE_BIT_1: + case TYPE_BIT_2: + case TYPE_BIT_3: + case TYPE_BIT_4: + case TYPE_BIT_5: + shift = d->type - TYPE_BIT_0; + params[0] = (*(GLbitfield *) p >> shift) & 1; + break; + } } #if FEATURE_ARB_sync void GLAPIENTRY -_mesa_GetInteger64v( GLenum pname, GLint64 *params ) +_mesa_GetInteger64v(GLenum pname, GLint64 *params) { - GET_CURRENT_CONTEXT(ctx); - const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; - ASSERT_OUTSIDE_BEGIN_END(ctx); - (void) version; + const struct value_desc *d; + union value v; + GLmatrix *m; + int shift, i; + void *p; - if (!params) - return; + d = find_value("glGetInteger64v", pname, &p, &v); + switch (d->type) { + case TYPE_INVALID: + break; + case TYPE_CONST: + params[0] = d->offset; + break; - if (ctx->Driver.GetInteger64v && - ctx->Driver.GetInteger64v(ctx, pname, params)) - return; + case TYPE_FLOAT_4: + params[3] = IROUND64(((GLfloat *) p)[3]); + case TYPE_FLOAT_3: + params[2] = IROUND64(((GLfloat *) p)[2]); + case TYPE_FLOAT_2: + params[1] = IROUND64(((GLfloat *) p)[1]); + case TYPE_FLOAT: + params[0] = IROUND64(((GLfloat *) p)[0]); + break; - switch (pname) { - case GL_ACCUM_RED_BITS: - params[0] = (GLint64)(ctx->DrawBuffer->Visual.accumRedBits); - break; - case GL_ACCUM_GREEN_BITS: - params[0] = (GLint64)(ctx->DrawBuffer->Visual.accumGreenBits); - break; - case GL_ACCUM_BLUE_BITS: - params[0] = (GLint64)(ctx->DrawBuffer->Visual.accumBlueBits); - break; - case GL_ACCUM_ALPHA_BITS: - params[0] = (GLint64)(ctx->DrawBuffer->Visual.accumAlphaBits); - break; - case GL_ACCUM_CLEAR_VALUE: - params[0] = FLOAT_TO_INT64(ctx->Accum.ClearColor[0]); - params[1] = FLOAT_TO_INT64(ctx->Accum.ClearColor[1]); - params[2] = FLOAT_TO_INT64(ctx->Accum.ClearColor[2]); - params[3] = FLOAT_TO_INT64(ctx->Accum.ClearColor[3]); - break; - case GL_ALPHA_BIAS: - params[0] = IROUND64(ctx->Pixel.AlphaBias); - break; - case GL_ALPHA_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = (GLint64)(ctx->DrawBuffer->Visual.alphaBits); - break; - case GL_ALPHA_SCALE: - params[0] = IROUND64(ctx->Pixel.AlphaScale); - break; - case GL_ALPHA_TEST: - params[0] = BOOLEAN_TO_INT64(ctx->Color.AlphaEnabled); - break; - case GL_ALPHA_TEST_FUNC: - params[0] = ENUM_TO_INT64(ctx->Color.AlphaFunc); - break; - case GL_ALPHA_TEST_REF: - params[0] = FLOAT_TO_INT64(ctx->Color.AlphaRef); - break; - case GL_ATTRIB_STACK_DEPTH: - params[0] = (GLint64)(ctx->AttribStackDepth); - break; - case GL_AUTO_NORMAL: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.AutoNormal); - break; - case GL_AUX_BUFFERS: - params[0] = (GLint64)(ctx->DrawBuffer->Visual.numAuxBuffers); - break; - case GL_BLEND: - params[0] = BOOLEAN_TO_INT64((ctx->Color.BlendEnabled & 1)); - break; - case GL_BLEND_DST: - params[0] = ENUM_TO_INT64(ctx->Color.BlendDstRGB); - break; - case GL_BLEND_SRC: - params[0] = ENUM_TO_INT64(ctx->Color.BlendSrcRGB); - break; - case GL_BLEND_SRC_RGB_EXT: - params[0] = ENUM_TO_INT64(ctx->Color.BlendSrcRGB); - break; - case GL_BLEND_DST_RGB_EXT: - params[0] = ENUM_TO_INT64(ctx->Color.BlendDstRGB); - break; - case GL_BLEND_SRC_ALPHA_EXT: - params[0] = ENUM_TO_INT64(ctx->Color.BlendSrcA); - break; - case GL_BLEND_DST_ALPHA_EXT: - params[0] = ENUM_TO_INT64(ctx->Color.BlendDstA); - break; - case GL_BLEND_EQUATION: - params[0] = ENUM_TO_INT64(ctx->Color.BlendEquationRGB ); - break; - case GL_BLEND_EQUATION_ALPHA_EXT: - params[0] = ENUM_TO_INT64(ctx->Color.BlendEquationA ); - break; - case GL_BLEND_COLOR_EXT: - params[0] = FLOAT_TO_INT64(ctx->Color.BlendColor[0]); - params[1] = FLOAT_TO_INT64(ctx->Color.BlendColor[1]); - params[2] = FLOAT_TO_INT64(ctx->Color.BlendColor[2]); - params[3] = FLOAT_TO_INT64(ctx->Color.BlendColor[3]); - break; - case GL_BLUE_BIAS: - params[0] = IROUND64(ctx->Pixel.BlueBias); - break; - case GL_BLUE_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = (GLint64)(ctx->DrawBuffer->Visual.blueBits); - break; - case GL_BLUE_SCALE: - params[0] = IROUND64(ctx->Pixel.BlueScale); - break; - case GL_CLIENT_ATTRIB_STACK_DEPTH: - params[0] = (GLint64)(ctx->ClientAttribStackDepth); - break; - case GL_CLIP_PLANE0: - params[0] = BOOLEAN_TO_INT64((ctx->Transform.ClipPlanesEnabled >> 0) & 1); - break; - case GL_CLIP_PLANE1: - params[0] = BOOLEAN_TO_INT64((ctx->Transform.ClipPlanesEnabled >> 1) & 1); - break; - case GL_CLIP_PLANE2: - params[0] = BOOLEAN_TO_INT64((ctx->Transform.ClipPlanesEnabled >> 2) & 1); - break; - case GL_CLIP_PLANE3: - params[0] = BOOLEAN_TO_INT64((ctx->Transform.ClipPlanesEnabled >> 3) & 1); - break; - case GL_CLIP_PLANE4: - params[0] = BOOLEAN_TO_INT64((ctx->Transform.ClipPlanesEnabled >> 4) & 1); - break; - case GL_CLIP_PLANE5: - params[0] = BOOLEAN_TO_INT64((ctx->Transform.ClipPlanesEnabled >> 5) & 1); - break; - case GL_COLOR_CLEAR_VALUE: - params[0] = FLOAT_TO_INT64(ctx->Color.ClearColor[0]); - params[1] = FLOAT_TO_INT64(ctx->Color.ClearColor[1]); - params[2] = FLOAT_TO_INT64(ctx->Color.ClearColor[2]); - params[3] = FLOAT_TO_INT64(ctx->Color.ClearColor[3]); - break; - case GL_COLOR_MATERIAL: - params[0] = BOOLEAN_TO_INT64(ctx->Light.ColorMaterialEnabled); - break; - case GL_COLOR_MATERIAL_FACE: - params[0] = ENUM_TO_INT64(ctx->Light.ColorMaterialFace); - break; - case GL_COLOR_MATERIAL_PARAMETER: - params[0] = ENUM_TO_INT64(ctx->Light.ColorMaterialMode); - break; - case GL_COLOR_WRITEMASK: - params[0] = (GLint64)(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0); - params[1] = (GLint64)(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0); - params[2] = (GLint64)(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0); - params[3] = (GLint64)(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0); - break; - case GL_CULL_FACE: - params[0] = BOOLEAN_TO_INT64(ctx->Polygon.CullFlag); - break; - case GL_CULL_FACE_MODE: - params[0] = ENUM_TO_INT64(ctx->Polygon.CullFaceMode); - break; - case GL_CURRENT_COLOR: - FLUSH_CURRENT(ctx, 0); - params[0] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]); - params[1] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]); - params[2] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]); - params[3] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]); - break; - case GL_CURRENT_INDEX: - FLUSH_CURRENT(ctx, 0); - params[0] = IROUND64(ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]); - break; - case GL_CURRENT_NORMAL: - FLUSH_CURRENT(ctx, 0); - params[0] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]); - params[1] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]); - params[2] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]); - break; - case GL_CURRENT_RASTER_COLOR: - params[0] = FLOAT_TO_INT64(ctx->Current.RasterColor[0]); - params[1] = FLOAT_TO_INT64(ctx->Current.RasterColor[1]); - params[2] = FLOAT_TO_INT64(ctx->Current.RasterColor[2]); - params[3] = FLOAT_TO_INT64(ctx->Current.RasterColor[3]); - break; - case GL_CURRENT_RASTER_DISTANCE: - params[0] = IROUND64(ctx->Current.RasterDistance); - break; - case GL_CURRENT_RASTER_INDEX: - params[0] = IROUND64(1.0); - break; - case GL_CURRENT_RASTER_POSITION: - params[0] = IROUND64(ctx->Current.RasterPos[0]); - params[1] = IROUND64(ctx->Current.RasterPos[1]); - params[2] = IROUND64(ctx->Current.RasterPos[2]); - params[3] = IROUND64(ctx->Current.RasterPos[3]); - break; - case GL_CURRENT_RASTER_SECONDARY_COLOR: - params[0] = FLOAT_TO_INT64(ctx->Current.RasterSecondaryColor[0]); - params[1] = FLOAT_TO_INT64(ctx->Current.RasterSecondaryColor[1]); - params[2] = FLOAT_TO_INT64(ctx->Current.RasterSecondaryColor[2]); - params[3] = FLOAT_TO_INT64(ctx->Current.RasterSecondaryColor[3]); - break; - case GL_CURRENT_RASTER_TEXTURE_COORDS: - { - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(raster tex coords, unit %u)", unit); - return; - } - params[0] = IROUND64(ctx->Current.RasterTexCoords[unit][0]); - params[1] = IROUND64(ctx->Current.RasterTexCoords[unit][1]); - params[2] = IROUND64(ctx->Current.RasterTexCoords[unit][2]); - params[3] = IROUND64(ctx->Current.RasterTexCoords[unit][3]); - } - break; - case GL_CURRENT_RASTER_POSITION_VALID: - params[0] = BOOLEAN_TO_INT64(ctx->Current.RasterPosValid); - break; - case GL_CURRENT_TEXTURE_COORDS: - { - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(current tex coords, unit %u)", unit); - return; - } - FLUSH_CURRENT(ctx, 0); - params[0] = IROUND64(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]); - params[1] = IROUND64(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]); - params[2] = IROUND64(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2]); - params[3] = IROUND64(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3]); - } - break; - case GL_DEPTH_BIAS: - params[0] = IROUND64(ctx->Pixel.DepthBias); - break; - case GL_DEPTH_BITS: - params[0] = (GLint64)(ctx->DrawBuffer->Visual.depthBits); - break; - case GL_DEPTH_CLEAR_VALUE: - params[0] = FLOAT_TO_INT64(((GLfloat) ctx->Depth.Clear)); - break; - case GL_DEPTH_FUNC: - params[0] = ENUM_TO_INT64(ctx->Depth.Func); - break; - case GL_DEPTH_RANGE: - params[0] = FLOAT_TO_INT64(ctx->Viewport.Near); - params[1] = FLOAT_TO_INT64(ctx->Viewport.Far); - break; - case GL_DEPTH_SCALE: - params[0] = IROUND64(ctx->Pixel.DepthScale); - break; - case GL_DEPTH_TEST: - params[0] = BOOLEAN_TO_INT64(ctx->Depth.Test); - break; - case GL_DEPTH_WRITEMASK: - params[0] = BOOLEAN_TO_INT64(ctx->Depth.Mask); - break; - case GL_DITHER: - params[0] = BOOLEAN_TO_INT64(ctx->Color.DitherFlag); - break; - case GL_DOUBLEBUFFER: - params[0] = BOOLEAN_TO_INT64(ctx->DrawBuffer->Visual.doubleBufferMode); - break; - case GL_DRAW_BUFFER: - params[0] = ENUM_TO_INT64(ctx->DrawBuffer->ColorDrawBuffer[0]); - break; - case GL_EDGE_FLAG: - FLUSH_CURRENT(ctx, 0); - params[0] = BOOLEAN_TO_INT64((ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0)); - break; - case GL_FEEDBACK_BUFFER_SIZE: - params[0] = (GLint64)(ctx->Feedback.BufferSize); - break; - case GL_FEEDBACK_BUFFER_TYPE: - params[0] = ENUM_TO_INT64(ctx->Feedback.Type); - break; - case GL_FOG: - params[0] = BOOLEAN_TO_INT64(ctx->Fog.Enabled); - break; - case GL_FOG_COLOR: - params[0] = FLOAT_TO_INT64(ctx->Fog.Color[0]); - params[1] = FLOAT_TO_INT64(ctx->Fog.Color[1]); - params[2] = FLOAT_TO_INT64(ctx->Fog.Color[2]); - params[3] = FLOAT_TO_INT64(ctx->Fog.Color[3]); - break; - case GL_FOG_DENSITY: - params[0] = IROUND64(ctx->Fog.Density); - break; - case GL_FOG_END: - params[0] = IROUND64(ctx->Fog.End); - break; - case GL_FOG_HINT: - params[0] = ENUM_TO_INT64(ctx->Hint.Fog); - break; - case GL_FOG_INDEX: - params[0] = IROUND64(ctx->Fog.Index); - break; - case GL_FOG_MODE: - params[0] = ENUM_TO_INT64(ctx->Fog.Mode); - break; - case GL_FOG_START: - params[0] = IROUND64(ctx->Fog.Start); - break; - case GL_FRONT_FACE: - params[0] = ENUM_TO_INT64(ctx->Polygon.FrontFace); - break; - case GL_GREEN_BIAS: - params[0] = IROUND64(ctx->Pixel.GreenBias); - break; - case GL_GREEN_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = (GLint64)(ctx->DrawBuffer->Visual.greenBits); - break; - case GL_GREEN_SCALE: - params[0] = IROUND64(ctx->Pixel.GreenScale); - break; - case GL_INDEX_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = (GLint64)(ctx->DrawBuffer->Visual.indexBits); - break; - case GL_INDEX_CLEAR_VALUE: - params[0] = (GLint64)(ctx->Color.ClearIndex); - break; - case GL_INDEX_MODE: - params[0] = BOOLEAN_TO_INT64(GL_FALSE); - break; - case GL_INDEX_OFFSET: - params[0] = (GLint64)(ctx->Pixel.IndexOffset); - break; - case GL_INDEX_SHIFT: - params[0] = (GLint64)(ctx->Pixel.IndexShift); - break; - case GL_INDEX_WRITEMASK: - params[0] = (GLint64)(ctx->Color.IndexMask); - break; - case GL_LIGHT0: - params[0] = BOOLEAN_TO_INT64(ctx->Light.Light[0].Enabled); - break; - case GL_LIGHT1: - params[0] = BOOLEAN_TO_INT64(ctx->Light.Light[1].Enabled); - break; - case GL_LIGHT2: - params[0] = BOOLEAN_TO_INT64(ctx->Light.Light[2].Enabled); - break; - case GL_LIGHT3: - params[0] = BOOLEAN_TO_INT64(ctx->Light.Light[3].Enabled); - break; - case GL_LIGHT4: - params[0] = BOOLEAN_TO_INT64(ctx->Light.Light[4].Enabled); - break; - case GL_LIGHT5: - params[0] = BOOLEAN_TO_INT64(ctx->Light.Light[5].Enabled); - break; - case GL_LIGHT6: - params[0] = BOOLEAN_TO_INT64(ctx->Light.Light[6].Enabled); - break; - case GL_LIGHT7: - params[0] = BOOLEAN_TO_INT64(ctx->Light.Light[7].Enabled); - break; - case GL_LIGHTING: - params[0] = BOOLEAN_TO_INT64(ctx->Light.Enabled); - break; - case GL_LIGHT_MODEL_AMBIENT: - params[0] = FLOAT_TO_INT64(ctx->Light.Model.Ambient[0]); - params[1] = FLOAT_TO_INT64(ctx->Light.Model.Ambient[1]); - params[2] = FLOAT_TO_INT64(ctx->Light.Model.Ambient[2]); - params[3] = FLOAT_TO_INT64(ctx->Light.Model.Ambient[3]); - break; - case GL_LIGHT_MODEL_COLOR_CONTROL: - params[0] = ENUM_TO_INT64(ctx->Light.Model.ColorControl); - break; - case GL_LIGHT_MODEL_LOCAL_VIEWER: - params[0] = BOOLEAN_TO_INT64(ctx->Light.Model.LocalViewer); - break; - case GL_LIGHT_MODEL_TWO_SIDE: - params[0] = BOOLEAN_TO_INT64(ctx->Light.Model.TwoSide); - break; - case GL_LINE_SMOOTH: - params[0] = BOOLEAN_TO_INT64(ctx->Line.SmoothFlag); - break; - case GL_LINE_SMOOTH_HINT: - params[0] = ENUM_TO_INT64(ctx->Hint.LineSmooth); - break; - case GL_LINE_STIPPLE: - params[0] = BOOLEAN_TO_INT64(ctx->Line.StippleFlag); - break; - case GL_LINE_STIPPLE_PATTERN: - params[0] = (GLint64)(ctx->Line.StipplePattern); - break; - case GL_LINE_STIPPLE_REPEAT: - params[0] = (GLint64)(ctx->Line.StippleFactor); - break; - case GL_LINE_WIDTH: - params[0] = IROUND64(ctx->Line.Width); - break; - case GL_LINE_WIDTH_GRANULARITY: - params[0] = IROUND64(ctx->Const.LineWidthGranularity); - break; - case GL_LINE_WIDTH_RANGE: - params[0] = IROUND64(ctx->Const.MinLineWidthAA); - params[1] = IROUND64(ctx->Const.MaxLineWidthAA); - break; - case GL_ALIASED_LINE_WIDTH_RANGE: - params[0] = IROUND64(ctx->Const.MinLineWidth); - params[1] = IROUND64(ctx->Const.MaxLineWidth); - break; - case GL_LIST_BASE: - params[0] = (GLint64)(ctx->List.ListBase); - break; - case GL_LIST_INDEX: - params[0] = (GLint64)((ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0)); - break; - case GL_LIST_MODE: - { - GLenum mode; - if (!ctx->CompileFlag) - mode = 0; - else if (ctx->ExecuteFlag) - mode = GL_COMPILE_AND_EXECUTE; - else - mode = GL_COMPILE; - params[0] = ENUM_TO_INT64(mode); - } - break; - case GL_INDEX_LOGIC_OP: - params[0] = BOOLEAN_TO_INT64(ctx->Color.IndexLogicOpEnabled); - break; - case GL_COLOR_LOGIC_OP: - params[0] = BOOLEAN_TO_INT64(ctx->Color.ColorLogicOpEnabled); - break; - case GL_LOGIC_OP_MODE: - params[0] = ENUM_TO_INT64(ctx->Color.LogicOp); - break; - case GL_MAP1_COLOR_4: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Color4); - break; - case GL_MAP1_GRID_DOMAIN: - params[0] = IROUND64(ctx->Eval.MapGrid1u1); - params[1] = IROUND64(ctx->Eval.MapGrid1u2); - break; - case GL_MAP1_GRID_SEGMENTS: - params[0] = (GLint64)(ctx->Eval.MapGrid1un); - break; - case GL_MAP1_INDEX: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Index); - break; - case GL_MAP1_NORMAL: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Normal); - break; - case GL_MAP1_TEXTURE_COORD_1: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1TextureCoord1); - break; - case GL_MAP1_TEXTURE_COORD_2: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1TextureCoord2); - break; - case GL_MAP1_TEXTURE_COORD_3: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1TextureCoord3); - break; - case GL_MAP1_TEXTURE_COORD_4: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1TextureCoord4); - break; - case GL_MAP1_VERTEX_3: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Vertex3); - break; - case GL_MAP1_VERTEX_4: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Vertex4); - break; - case GL_MAP2_COLOR_4: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map2Color4); - break; - case GL_MAP2_GRID_DOMAIN: - params[0] = IROUND64(ctx->Eval.MapGrid2u1); - params[1] = IROUND64(ctx->Eval.MapGrid2u2); - params[2] = IROUND64(ctx->Eval.MapGrid2v1); - params[3] = IROUND64(ctx->Eval.MapGrid2v2); - break; - case GL_MAP2_GRID_SEGMENTS: - params[0] = (GLint64)(ctx->Eval.MapGrid2un); - params[1] = (GLint64)(ctx->Eval.MapGrid2vn); - break; - case GL_MAP2_INDEX: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map2Index); - break; - case GL_MAP2_NORMAL: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map2Normal); - break; - case GL_MAP2_TEXTURE_COORD_1: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map2TextureCoord1); - break; - case GL_MAP2_TEXTURE_COORD_2: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map2TextureCoord2); - break; - case GL_MAP2_TEXTURE_COORD_3: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map2TextureCoord3); - break; - case GL_MAP2_TEXTURE_COORD_4: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map2TextureCoord4); - break; - case GL_MAP2_VERTEX_3: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map2Vertex3); - break; - case GL_MAP2_VERTEX_4: - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map2Vertex4); - break; - case GL_MAP_COLOR: - params[0] = BOOLEAN_TO_INT64(ctx->Pixel.MapColorFlag); - break; - case GL_MAP_STENCIL: - params[0] = BOOLEAN_TO_INT64(ctx->Pixel.MapStencilFlag); - break; - case GL_MATRIX_MODE: - params[0] = ENUM_TO_INT64(ctx->Transform.MatrixMode); - break; - case GL_MAX_ATTRIB_STACK_DEPTH: - params[0] = (GLint64)(MAX_ATTRIB_STACK_DEPTH); - break; - case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH: - params[0] = (GLint64)(MAX_CLIENT_ATTRIB_STACK_DEPTH); - break; - case GL_MAX_CLIP_PLANES: - params[0] = (GLint64)(ctx->Const.MaxClipPlanes); - break; - case GL_MAX_ELEMENTS_VERTICES: - params[0] = (GLint64)(ctx->Const.MaxArrayLockSize); - break; - case GL_MAX_ELEMENTS_INDICES: - params[0] = (GLint64)(ctx->Const.MaxArrayLockSize); - break; - case GL_MAX_EVAL_ORDER: - params[0] = (GLint64)(MAX_EVAL_ORDER); - break; - case GL_MAX_LIGHTS: - params[0] = (GLint64)(ctx->Const.MaxLights); - break; - case GL_MAX_LIST_NESTING: - params[0] = (GLint64)(MAX_LIST_NESTING); - break; - case GL_MAX_MODELVIEW_STACK_DEPTH: - params[0] = (GLint64)(MAX_MODELVIEW_STACK_DEPTH); - break; - case GL_MAX_NAME_STACK_DEPTH: - params[0] = (GLint64)(MAX_NAME_STACK_DEPTH); - break; - case GL_MAX_PIXEL_MAP_TABLE: - params[0] = (GLint64)(MAX_PIXEL_MAP_TABLE); - break; - case GL_MAX_PROJECTION_STACK_DEPTH: - params[0] = (GLint64)(MAX_PROJECTION_STACK_DEPTH); - break; - case GL_MAX_TEXTURE_SIZE: - params[0] = (GLint64)(1 << (ctx->Const.MaxTextureLevels - 1)); - break; - case GL_MAX_3D_TEXTURE_SIZE: - params[0] = (GLint64)(1 << (ctx->Const.Max3DTextureLevels - 1)); - break; - case GL_MAX_TEXTURE_STACK_DEPTH: - params[0] = (GLint64)(MAX_TEXTURE_STACK_DEPTH); - break; - case GL_MAX_VIEWPORT_DIMS: - params[0] = (GLint64)(ctx->Const.MaxViewportWidth); - params[1] = (GLint64)(ctx->Const.MaxViewportHeight); - break; - case GL_MODELVIEW_MATRIX: - { - const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m; - params[0] = IROUND64(matrix[0]); - params[1] = IROUND64(matrix[1]); - params[2] = IROUND64(matrix[2]); - params[3] = IROUND64(matrix[3]); - params[4] = IROUND64(matrix[4]); - params[5] = IROUND64(matrix[5]); - params[6] = IROUND64(matrix[6]); - params[7] = IROUND64(matrix[7]); - params[8] = IROUND64(matrix[8]); - params[9] = IROUND64(matrix[9]); - params[10] = IROUND64(matrix[10]); - params[11] = IROUND64(matrix[11]); - params[12] = IROUND64(matrix[12]); - params[13] = IROUND64(matrix[13]); - params[14] = IROUND64(matrix[14]); - params[15] = IROUND64(matrix[15]); - } - break; - case GL_MODELVIEW_STACK_DEPTH: - params[0] = (GLint64)(ctx->ModelviewMatrixStack.Depth + 1); - break; - case GL_NAME_STACK_DEPTH: - params[0] = (GLint64)(ctx->Select.NameStackDepth); - break; - case GL_NORMALIZE: - params[0] = BOOLEAN_TO_INT64(ctx->Transform.Normalize); - break; - case GL_PACK_ALIGNMENT: - params[0] = (GLint64)(ctx->Pack.Alignment); - break; - case GL_PACK_LSB_FIRST: - params[0] = BOOLEAN_TO_INT64(ctx->Pack.LsbFirst); - break; - case GL_PACK_ROW_LENGTH: - params[0] = (GLint64)(ctx->Pack.RowLength); - break; - case GL_PACK_SKIP_PIXELS: - params[0] = (GLint64)(ctx->Pack.SkipPixels); - break; - case GL_PACK_SKIP_ROWS: - params[0] = (GLint64)(ctx->Pack.SkipRows); - break; - case GL_PACK_SWAP_BYTES: - params[0] = BOOLEAN_TO_INT64(ctx->Pack.SwapBytes); - break; - case GL_PACK_SKIP_IMAGES_EXT: - params[0] = (GLint64)(ctx->Pack.SkipImages); - break; - case GL_PACK_IMAGE_HEIGHT_EXT: - params[0] = (GLint64)(ctx->Pack.ImageHeight); - break; - case GL_PACK_INVERT_MESA: - params[0] = BOOLEAN_TO_INT64(ctx->Pack.Invert); - break; - case GL_PERSPECTIVE_CORRECTION_HINT: - params[0] = ENUM_TO_INT64(ctx->Hint.PerspectiveCorrection); - break; - case GL_PIXEL_MAP_A_TO_A_SIZE: - params[0] = (GLint64)(ctx->PixelMaps.AtoA.Size); - break; - case GL_PIXEL_MAP_B_TO_B_SIZE: - params[0] = (GLint64)(ctx->PixelMaps.BtoB.Size); - break; - case GL_PIXEL_MAP_G_TO_G_SIZE: - params[0] = (GLint64)(ctx->PixelMaps.GtoG.Size); - break; - case GL_PIXEL_MAP_I_TO_A_SIZE: - params[0] = (GLint64)(ctx->PixelMaps.ItoA.Size); - break; - case GL_PIXEL_MAP_I_TO_B_SIZE: - params[0] = (GLint64)(ctx->PixelMaps.ItoB.Size); - break; - case GL_PIXEL_MAP_I_TO_G_SIZE: - params[0] = (GLint64)(ctx->PixelMaps.ItoG.Size); - break; - case GL_PIXEL_MAP_I_TO_I_SIZE: - params[0] = (GLint64)(ctx->PixelMaps.ItoI.Size); - break; - case GL_PIXEL_MAP_I_TO_R_SIZE: - params[0] = (GLint64)(ctx->PixelMaps.ItoR.Size); - break; - case GL_PIXEL_MAP_R_TO_R_SIZE: - params[0] = (GLint64)(ctx->PixelMaps.RtoR.Size); - break; - case GL_PIXEL_MAP_S_TO_S_SIZE: - params[0] = (GLint64)(ctx->PixelMaps.StoS.Size); - break; - case GL_POINT_SIZE: - params[0] = IROUND64(ctx->Point.Size); - break; - case GL_POINT_SIZE_GRANULARITY: - params[0] = IROUND64(ctx->Const.PointSizeGranularity); - break; - case GL_POINT_SIZE_RANGE: - params[0] = IROUND64(ctx->Const.MinPointSizeAA); - params[1] = IROUND64(ctx->Const.MaxPointSizeAA); - break; - case GL_ALIASED_POINT_SIZE_RANGE: - params[0] = IROUND64(ctx->Const.MinPointSize); - params[1] = IROUND64(ctx->Const.MaxPointSize); - break; - case GL_POINT_SMOOTH: - params[0] = BOOLEAN_TO_INT64(ctx->Point.SmoothFlag); - break; - case GL_POINT_SMOOTH_HINT: - params[0] = ENUM_TO_INT64(ctx->Hint.PointSmooth); - break; - case GL_POINT_SIZE_MIN_EXT: - params[0] = IROUND64(ctx->Point.MinSize); - break; - case GL_POINT_SIZE_MAX_EXT: - params[0] = IROUND64(ctx->Point.MaxSize); - break; - case GL_POINT_FADE_THRESHOLD_SIZE_EXT: - params[0] = IROUND64(ctx->Point.Threshold); - break; - case GL_DISTANCE_ATTENUATION_EXT: - params[0] = IROUND64(ctx->Point.Params[0]); - params[1] = IROUND64(ctx->Point.Params[1]); - params[2] = IROUND64(ctx->Point.Params[2]); - break; - case GL_POLYGON_MODE: - params[0] = ENUM_TO_INT64(ctx->Polygon.FrontMode); - params[1] = ENUM_TO_INT64(ctx->Polygon.BackMode); - break; - case GL_POLYGON_OFFSET_BIAS_EXT: - params[0] = IROUND64(ctx->Polygon.OffsetUnits); - break; - case GL_POLYGON_OFFSET_FACTOR: - params[0] = IROUND64(ctx->Polygon.OffsetFactor ); - break; - case GL_POLYGON_OFFSET_UNITS: - params[0] = IROUND64(ctx->Polygon.OffsetUnits ); - break; - case GL_POLYGON_OFFSET_POINT: - params[0] = BOOLEAN_TO_INT64(ctx->Polygon.OffsetPoint); - break; - case GL_POLYGON_OFFSET_LINE: - params[0] = BOOLEAN_TO_INT64(ctx->Polygon.OffsetLine); - break; - case GL_POLYGON_OFFSET_FILL: - params[0] = BOOLEAN_TO_INT64(ctx->Polygon.OffsetFill); - break; - case GL_POLYGON_SMOOTH: - params[0] = BOOLEAN_TO_INT64(ctx->Polygon.SmoothFlag); - break; - case GL_POLYGON_SMOOTH_HINT: - params[0] = ENUM_TO_INT64(ctx->Hint.PolygonSmooth); - break; - case GL_POLYGON_STIPPLE: - params[0] = BOOLEAN_TO_INT64(ctx->Polygon.StippleFlag); - break; - case GL_PROJECTION_MATRIX: - { - const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m; - params[0] = IROUND64(matrix[0]); - params[1] = IROUND64(matrix[1]); - params[2] = IROUND64(matrix[2]); - params[3] = IROUND64(matrix[3]); - params[4] = IROUND64(matrix[4]); - params[5] = IROUND64(matrix[5]); - params[6] = IROUND64(matrix[6]); - params[7] = IROUND64(matrix[7]); - params[8] = IROUND64(matrix[8]); - params[9] = IROUND64(matrix[9]); - params[10] = IROUND64(matrix[10]); - params[11] = IROUND64(matrix[11]); - params[12] = IROUND64(matrix[12]); - params[13] = IROUND64(matrix[13]); - params[14] = IROUND64(matrix[14]); - params[15] = IROUND64(matrix[15]); - } - break; - case GL_PROJECTION_STACK_DEPTH: - params[0] = (GLint64)(ctx->ProjectionMatrixStack.Depth + 1); - break; - case GL_READ_BUFFER: - params[0] = ENUM_TO_INT64(ctx->ReadBuffer->ColorReadBuffer); - break; - case GL_RED_BIAS: - params[0] = IROUND64(ctx->Pixel.RedBias); - break; - case GL_RED_BITS: - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = (GLint64)(ctx->DrawBuffer->Visual.redBits); - break; - case GL_RED_SCALE: - params[0] = IROUND64(ctx->Pixel.RedScale); - break; - case GL_RENDER_MODE: - params[0] = ENUM_TO_INT64(ctx->RenderMode); - break; - case GL_RESCALE_NORMAL: - params[0] = BOOLEAN_TO_INT64(ctx->Transform.RescaleNormals); - break; - case GL_RGBA_MODE: - params[0] = BOOLEAN_TO_INT64(GL_TRUE); - break; - case GL_SCISSOR_BOX: - params[0] = (GLint64)(ctx->Scissor.X); - params[1] = (GLint64)(ctx->Scissor.Y); - params[2] = (GLint64)(ctx->Scissor.Width); - params[3] = (GLint64)(ctx->Scissor.Height); - break; - case GL_SCISSOR_TEST: - params[0] = BOOLEAN_TO_INT64(ctx->Scissor.Enabled); - break; - case GL_SELECTION_BUFFER_SIZE: - params[0] = (GLint64)(ctx->Select.BufferSize); - break; - case GL_SHADE_MODEL: - params[0] = ENUM_TO_INT64(ctx->Light.ShadeModel); - break; - case GL_SHARED_TEXTURE_PALETTE_EXT: - params[0] = BOOLEAN_TO_INT64(ctx->Texture.SharedPalette); - break; - case GL_STENCIL_BITS: - params[0] = (GLint64)(ctx->DrawBuffer->Visual.stencilBits); - break; - case GL_STENCIL_CLEAR_VALUE: - params[0] = (GLint64)(ctx->Stencil.Clear); - break; - case GL_STENCIL_FAIL: - params[0] = ENUM_TO_INT64(ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_FUNC: - params[0] = ENUM_TO_INT64(ctx->Stencil.Function[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_PASS_DEPTH_FAIL: - params[0] = ENUM_TO_INT64(ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_PASS_DEPTH_PASS: - params[0] = ENUM_TO_INT64(ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_REF: - params[0] = (GLint64)(ctx->Stencil.Ref[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_TEST: - params[0] = BOOLEAN_TO_INT64(ctx->Stencil.Enabled); - break; - case GL_STENCIL_VALUE_MASK: - params[0] = (GLint64)(ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]); - break; - case GL_STENCIL_WRITEMASK: - params[0] = (GLint64)(ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]); - break; - case GL_STEREO: - params[0] = BOOLEAN_TO_INT64(ctx->DrawBuffer->Visual.stereoMode); - break; - case GL_SUBPIXEL_BITS: - params[0] = (GLint64)(ctx->Const.SubPixelBits); - break; - case GL_TEXTURE_1D: - params[0] = BOOLEAN_TO_INT64(_mesa_IsEnabled(GL_TEXTURE_1D)); - break; - case GL_TEXTURE_2D: - params[0] = BOOLEAN_TO_INT64(_mesa_IsEnabled(GL_TEXTURE_2D)); - break; - case GL_TEXTURE_3D: - params[0] = BOOLEAN_TO_INT64(_mesa_IsEnabled(GL_TEXTURE_3D)); - break; - case GL_TEXTURE_1D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = BOOLEAN_TO_INT64(_mesa_IsEnabled(GL_TEXTURE_1D_ARRAY_EXT)); - break; - case GL_TEXTURE_2D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = BOOLEAN_TO_INT64(_mesa_IsEnabled(GL_TEXTURE_2D_ARRAY_EXT)); - break; - case GL_TEXTURE_BINDING_1D: - params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_INDEX]->Name); - break; - case GL_TEXTURE_BINDING_2D: - params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name); - break; - case GL_TEXTURE_BINDING_3D: - params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name); - break; - case GL_TEXTURE_BINDING_1D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_ARRAY_INDEX]->Name); - break; - case GL_TEXTURE_BINDING_2D_ARRAY_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name); - break; - case GL_MAX_ARRAY_TEXTURE_LAYERS_EXT: - CHECK_EXT1(MESA_texture_array); - params[0] = (GLint64)(ctx->Const.MaxArrayTextureLayers); - break; - case GL_TEXTURE_GEN_S: - params[0] = BOOLEAN_TO_INT64(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)); - break; - case GL_TEXTURE_GEN_T: - params[0] = BOOLEAN_TO_INT64(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0)); - break; - case GL_TEXTURE_GEN_R: - params[0] = BOOLEAN_TO_INT64(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0)); - break; - case GL_TEXTURE_GEN_Q: - params[0] = BOOLEAN_TO_INT64(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & Q_BIT) ? 1 : 0)); - break; - case GL_TEXTURE_MATRIX: - { - const GLfloat *matrix; - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGet(texture matrix %u)", - unit); - return; - } - matrix = ctx->TextureMatrixStack[unit].Top->m; - params[0] = IROUND64(matrix[0]); - params[1] = IROUND64(matrix[1]); - params[2] = IROUND64(matrix[2]); - params[3] = IROUND64(matrix[3]); - params[4] = IROUND64(matrix[4]); - params[5] = IROUND64(matrix[5]); - params[6] = IROUND64(matrix[6]); - params[7] = IROUND64(matrix[7]); - params[8] = IROUND64(matrix[8]); - params[9] = IROUND64(matrix[9]); - params[10] = IROUND64(matrix[10]); - params[11] = IROUND64(matrix[11]); - params[12] = IROUND64(matrix[12]); - params[13] = IROUND64(matrix[13]); - params[14] = IROUND64(matrix[14]); - params[15] = IROUND64(matrix[15]); - } - break; - case GL_TEXTURE_STACK_DEPTH: - { - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(texture stack depth, unit %u)", unit); - return; - } - params[0] = (GLint64)(ctx->TextureMatrixStack[unit].Depth + 1); - } - break; - case GL_UNPACK_ALIGNMENT: - params[0] = (GLint64)(ctx->Unpack.Alignment); - break; - case GL_UNPACK_LSB_FIRST: - params[0] = BOOLEAN_TO_INT64(ctx->Unpack.LsbFirst); - break; - case GL_UNPACK_ROW_LENGTH: - params[0] = (GLint64)(ctx->Unpack.RowLength); - break; - case GL_UNPACK_SKIP_PIXELS: - params[0] = (GLint64)(ctx->Unpack.SkipPixels); - break; - case GL_UNPACK_SKIP_ROWS: - params[0] = (GLint64)(ctx->Unpack.SkipRows); - break; - case GL_UNPACK_SWAP_BYTES: - params[0] = BOOLEAN_TO_INT64(ctx->Unpack.SwapBytes); - break; - case GL_UNPACK_SKIP_IMAGES_EXT: - params[0] = (GLint64)(ctx->Unpack.SkipImages); - break; - case GL_UNPACK_IMAGE_HEIGHT_EXT: - params[0] = (GLint64)(ctx->Unpack.ImageHeight); - break; - case GL_UNPACK_CLIENT_STORAGE_APPLE: - params[0] = BOOLEAN_TO_INT64(ctx->Unpack.ClientStorage); - break; - case GL_VIEWPORT: - params[0] = (GLint64)(ctx->Viewport.X); - params[1] = (GLint64)(ctx->Viewport.Y); - params[2] = (GLint64)(ctx->Viewport.Width); - params[3] = (GLint64)(ctx->Viewport.Height); - break; - case GL_ZOOM_X: - params[0] = IROUND64(ctx->Pixel.ZoomX); - break; - case GL_ZOOM_Y: - params[0] = IROUND64(ctx->Pixel.ZoomY); - break; - case GL_VERTEX_ARRAY: - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->Vertex.Enabled); - break; - case GL_VERTEX_ARRAY_SIZE: - params[0] = (GLint64)(ctx->Array.ArrayObj->Vertex.Size); - break; - case GL_VERTEX_ARRAY_TYPE: - params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Vertex.Type); - break; - case GL_VERTEX_ARRAY_STRIDE: - params[0] = (GLint64)(ctx->Array.ArrayObj->Vertex.Stride); - break; - case GL_VERTEX_ARRAY_COUNT_EXT: - params[0] = (GLint64)(0); - break; - case GL_NORMAL_ARRAY: - params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Normal.Enabled); - break; - case GL_NORMAL_ARRAY_TYPE: - params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Normal.Type); - break; - case GL_NORMAL_ARRAY_STRIDE: - params[0] = (GLint64)(ctx->Array.ArrayObj->Normal.Stride); - break; - case GL_NORMAL_ARRAY_COUNT_EXT: - params[0] = (GLint64)(0); - break; - case GL_COLOR_ARRAY: - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->Color.Enabled); - break; - case GL_COLOR_ARRAY_SIZE: - params[0] = (GLint64)(ctx->Array.ArrayObj->Color.Size); - break; - case GL_COLOR_ARRAY_TYPE: - params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Color.Type); - break; - case GL_COLOR_ARRAY_STRIDE: - params[0] = (GLint64)(ctx->Array.ArrayObj->Color.Stride); - break; - case GL_COLOR_ARRAY_COUNT_EXT: - params[0] = (GLint64)(0); - break; - case GL_INDEX_ARRAY: - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->Index.Enabled); - break; - case GL_INDEX_ARRAY_TYPE: - params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->Index.Type); - break; - case GL_INDEX_ARRAY_STRIDE: - params[0] = (GLint64)(ctx->Array.ArrayObj->Index.Stride); - break; - case GL_INDEX_ARRAY_COUNT_EXT: - params[0] = (GLint64)(0); - break; - case GL_TEXTURE_COORD_ARRAY: - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled); - break; - case GL_TEXTURE_COORD_ARRAY_SIZE: - params[0] = (GLint64)(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size); - break; - case GL_TEXTURE_COORD_ARRAY_TYPE: - params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Type); - break; - case GL_TEXTURE_COORD_ARRAY_STRIDE: - params[0] = (GLint64)(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride); - break; - case GL_TEXTURE_COORD_ARRAY_COUNT_EXT: - params[0] = (GLint64)(0); - break; - case GL_EDGE_FLAG_ARRAY: - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->EdgeFlag.Enabled); - break; - case GL_EDGE_FLAG_ARRAY_STRIDE: - params[0] = (GLint64)(ctx->Array.ArrayObj->EdgeFlag.Stride); - break; - case GL_EDGE_FLAG_ARRAY_COUNT_EXT: - params[0] = (GLint64)(0); - break; - case GL_MAX_TEXTURE_UNITS_ARB: - CHECK_EXT1(ARB_multitexture); - params[0] = (GLint64)(ctx->Const.MaxTextureUnits); - break; - case GL_ACTIVE_TEXTURE_ARB: - CHECK_EXT1(ARB_multitexture); - params[0] = (GLint64)(GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit); - break; - case GL_CLIENT_ACTIVE_TEXTURE_ARB: - CHECK_EXT1(ARB_multitexture); - params[0] = (GLint64)(GL_TEXTURE0_ARB + ctx->Array.ActiveTexture); - break; - case GL_TEXTURE_CUBE_MAP_ARB: - CHECK_EXT1(ARB_texture_cube_map); - params[0] = BOOLEAN_TO_INT64(_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB)); - break; - case GL_TEXTURE_BINDING_CUBE_MAP_ARB: - CHECK_EXT1(ARB_texture_cube_map); - params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_CUBE_INDEX]->Name); - break; - case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: - CHECK_EXT1(ARB_texture_cube_map); - params[0] = (GLint64)((1 << (ctx->Const.MaxCubeTextureLevels - 1))); - break; - case GL_TEXTURE_COMPRESSION_HINT_ARB: - params[0] = (GLint64)(ctx->Hint.TextureCompression); - break; - case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: - params[0] = (GLint64)(_mesa_get_compressed_formats(ctx, NULL, GL_FALSE)); - break; - case GL_COMPRESSED_TEXTURE_FORMATS_ARB: - { - GLint formats[100]; - GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE); - ASSERT(n <= 100); - for (i = 0; i < n; i++) - params[i] = ENUM_TO_INT64(formats[i]); - } - break; - case GL_ARRAY_ELEMENT_LOCK_FIRST_EXT: - CHECK_EXT1(EXT_compiled_vertex_array); - params[0] = (GLint64)(ctx->Array.LockFirst); - break; - case GL_ARRAY_ELEMENT_LOCK_COUNT_EXT: - CHECK_EXT1(EXT_compiled_vertex_array); - params[0] = (GLint64)(ctx->Array.LockCount); - break; - case GL_TRANSPOSE_COLOR_MATRIX_ARB: - { - const GLfloat *matrix = ctx->ColorMatrixStack.Top->m; - params[0] = IROUND64(matrix[0]); - params[1] = IROUND64(matrix[4]); - params[2] = IROUND64(matrix[8]); - params[3] = IROUND64(matrix[12]); - params[4] = IROUND64(matrix[1]); - params[5] = IROUND64(matrix[5]); - params[6] = IROUND64(matrix[9]); - params[7] = IROUND64(matrix[13]); - params[8] = IROUND64(matrix[2]); - params[9] = IROUND64(matrix[6]); - params[10] = IROUND64(matrix[10]); - params[11] = IROUND64(matrix[14]); - params[12] = IROUND64(matrix[3]); - params[13] = IROUND64(matrix[7]); - params[14] = IROUND64(matrix[11]); - params[15] = IROUND64(matrix[15]); - } - break; - case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB: - { - const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m; - params[0] = IROUND64(matrix[0]); - params[1] = IROUND64(matrix[4]); - params[2] = IROUND64(matrix[8]); - params[3] = IROUND64(matrix[12]); - params[4] = IROUND64(matrix[1]); - params[5] = IROUND64(matrix[5]); - params[6] = IROUND64(matrix[9]); - params[7] = IROUND64(matrix[13]); - params[8] = IROUND64(matrix[2]); - params[9] = IROUND64(matrix[6]); - params[10] = IROUND64(matrix[10]); - params[11] = IROUND64(matrix[14]); - params[12] = IROUND64(matrix[3]); - params[13] = IROUND64(matrix[7]); - params[14] = IROUND64(matrix[11]); - params[15] = IROUND64(matrix[15]); - } - break; - case GL_TRANSPOSE_PROJECTION_MATRIX_ARB: - { - const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m; - params[0] = IROUND64(matrix[0]); - params[1] = IROUND64(matrix[4]); - params[2] = IROUND64(matrix[8]); - params[3] = IROUND64(matrix[12]); - params[4] = IROUND64(matrix[1]); - params[5] = IROUND64(matrix[5]); - params[6] = IROUND64(matrix[9]); - params[7] = IROUND64(matrix[13]); - params[8] = IROUND64(matrix[2]); - params[9] = IROUND64(matrix[6]); - params[10] = IROUND64(matrix[10]); - params[11] = IROUND64(matrix[14]); - params[12] = IROUND64(matrix[3]); - params[13] = IROUND64(matrix[7]); - params[14] = IROUND64(matrix[11]); - params[15] = IROUND64(matrix[15]); - } - break; - case GL_TRANSPOSE_TEXTURE_MATRIX_ARB: - { - const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m; - params[0] = IROUND64(matrix[0]); - params[1] = IROUND64(matrix[4]); - params[2] = IROUND64(matrix[8]); - params[3] = IROUND64(matrix[12]); - params[4] = IROUND64(matrix[1]); - params[5] = IROUND64(matrix[5]); - params[6] = IROUND64(matrix[9]); - params[7] = IROUND64(matrix[13]); - params[8] = IROUND64(matrix[2]); - params[9] = IROUND64(matrix[6]); - params[10] = IROUND64(matrix[10]); - params[11] = IROUND64(matrix[14]); - params[12] = IROUND64(matrix[3]); - params[13] = IROUND64(matrix[7]); - params[14] = IROUND64(matrix[11]); - params[15] = IROUND64(matrix[15]); - } - break; - case GL_COLOR_MATRIX_SGI: - { - const GLfloat *matrix = ctx->ColorMatrixStack.Top->m; - params[0] = IROUND64(matrix[0]); - params[1] = IROUND64(matrix[1]); - params[2] = IROUND64(matrix[2]); - params[3] = IROUND64(matrix[3]); - params[4] = IROUND64(matrix[4]); - params[5] = IROUND64(matrix[5]); - params[6] = IROUND64(matrix[6]); - params[7] = IROUND64(matrix[7]); - params[8] = IROUND64(matrix[8]); - params[9] = IROUND64(matrix[9]); - params[10] = IROUND64(matrix[10]); - params[11] = IROUND64(matrix[11]); - params[12] = IROUND64(matrix[12]); - params[13] = IROUND64(matrix[13]); - params[14] = IROUND64(matrix[14]); - params[15] = IROUND64(matrix[15]); - } - break; - case GL_COLOR_MATRIX_STACK_DEPTH_SGI: - params[0] = (GLint64)(ctx->ColorMatrixStack.Depth + 1); - break; - case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: - params[0] = (GLint64)(MAX_COLOR_STACK_DEPTH); - break; - case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: - params[0] = IROUND64(ctx->Pixel.PostColorMatrixScale[0]); - break; - case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: - params[0] = IROUND64(ctx->Pixel.PostColorMatrixScale[1]); - break; - case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: - params[0] = IROUND64(ctx->Pixel.PostColorMatrixScale[2]); - break; - case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: - params[0] = IROUND64(ctx->Pixel.PostColorMatrixScale[3]); - break; - case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: - params[0] = IROUND64(ctx->Pixel.PostColorMatrixBias[0]); - break; - case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: - params[0] = IROUND64(ctx->Pixel.PostColorMatrixBias[1]); - break; - case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: - params[0] = IROUND64(ctx->Pixel.PostColorMatrixBias[2]); - break; - case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: - params[0] = IROUND64(ctx->Pixel.PostColorMatrixBias[3]); - break; - case GL_CONVOLUTION_1D_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = BOOLEAN_TO_INT64(ctx->Pixel.Convolution1DEnabled); - break; - case GL_CONVOLUTION_2D_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = BOOLEAN_TO_INT64(ctx->Pixel.Convolution2DEnabled); - break; - case GL_SEPARABLE_2D_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = BOOLEAN_TO_INT64(ctx->Pixel.Separable2DEnabled); - break; - case GL_POST_CONVOLUTION_RED_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND64(ctx->Pixel.PostConvolutionScale[0]); - break; - case GL_POST_CONVOLUTION_GREEN_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND64(ctx->Pixel.PostConvolutionScale[1]); - break; - case GL_POST_CONVOLUTION_BLUE_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND64(ctx->Pixel.PostConvolutionScale[2]); - break; - case GL_POST_CONVOLUTION_ALPHA_SCALE_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND64(ctx->Pixel.PostConvolutionScale[3]); - break; - case GL_POST_CONVOLUTION_RED_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND64(ctx->Pixel.PostConvolutionBias[0]); - break; - case GL_POST_CONVOLUTION_GREEN_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND64(ctx->Pixel.PostConvolutionBias[1]); - break; - case GL_POST_CONVOLUTION_BLUE_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND64(ctx->Pixel.PostConvolutionBias[2]); - break; - case GL_POST_CONVOLUTION_ALPHA_BIAS_EXT: - CHECK_EXT1(EXT_convolution); - params[0] = IROUND64(ctx->Pixel.PostConvolutionBias[3]); - break; - case GL_HISTOGRAM: - CHECK_EXT1(EXT_histogram); - params[0] = BOOLEAN_TO_INT64(ctx->Pixel.HistogramEnabled); - break; - case GL_MINMAX: - CHECK_EXT1(EXT_histogram); - params[0] = BOOLEAN_TO_INT64(ctx->Pixel.MinMaxEnabled); - break; - case GL_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_color_table); - params[0] = BOOLEAN_TO_INT64(ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]); - break; - case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_color_table); - params[0] = BOOLEAN_TO_INT64(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]); - break; - case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_color_table); - params[0] = BOOLEAN_TO_INT64(ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]); - break; - case GL_TEXTURE_COLOR_TABLE_SGI: - CHECK_EXT1(SGI_texture_color_table); - params[0] = BOOLEAN_TO_INT64(ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled); - break; - case GL_COLOR_SUM_EXT: - CHECK_EXT2(EXT_secondary_color, ARB_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Fog.ColorSumEnabled); - break; - case GL_CURRENT_SECONDARY_COLOR_EXT: - CHECK_EXT1(EXT_secondary_color); - FLUSH_CURRENT(ctx, 0); - params[0] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]); - params[1] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]); - params[2] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]); - params[3] = FLOAT_TO_INT64(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]); - break; - case GL_SECONDARY_COLOR_ARRAY_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->SecondaryColor.Enabled); - break; - case GL_SECONDARY_COLOR_ARRAY_TYPE_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->SecondaryColor.Type); - break; - case GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = (GLint64)(ctx->Array.ArrayObj->SecondaryColor.Stride); - break; - case GL_SECONDARY_COLOR_ARRAY_SIZE_EXT: - CHECK_EXT1(EXT_secondary_color); - params[0] = (GLint64)(ctx->Array.ArrayObj->SecondaryColor.Size); - break; - case GL_CURRENT_FOG_COORDINATE_EXT: - CHECK_EXT1(EXT_fog_coord); - FLUSH_CURRENT(ctx, 0); - params[0] = IROUND64(ctx->Current.Attrib[VERT_ATTRIB_FOG][0]); - break; - case GL_FOG_COORDINATE_ARRAY_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->FogCoord.Enabled); - break; - case GL_FOG_COORDINATE_ARRAY_TYPE_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = ENUM_TO_INT64(ctx->Array.ArrayObj->FogCoord.Type); - break; - case GL_FOG_COORDINATE_ARRAY_STRIDE_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = (GLint64)(ctx->Array.ArrayObj->FogCoord.Stride); - break; - case GL_FOG_COORDINATE_SOURCE_EXT: - CHECK_EXT1(EXT_fog_coord); - params[0] = ENUM_TO_INT64(ctx->Fog.FogCoordinateSource); - break; - case GL_MAX_TEXTURE_LOD_BIAS_EXT: - CHECK_EXT1(EXT_texture_lod_bias); - params[0] = IROUND64(ctx->Const.MaxTextureLodBias); - break; - case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: - CHECK_EXT1(EXT_texture_filter_anisotropic); - params[0] = IROUND64(ctx->Const.MaxTextureMaxAnisotropy); - break; - case GL_MULTISAMPLE_ARB: - params[0] = BOOLEAN_TO_INT64(ctx->Multisample.Enabled); - break; - case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: - params[0] = BOOLEAN_TO_INT64(ctx->Multisample.SampleAlphaToCoverage); - break; - case GL_SAMPLE_ALPHA_TO_ONE_ARB: - params[0] = BOOLEAN_TO_INT64(ctx->Multisample.SampleAlphaToOne); - break; - case GL_SAMPLE_COVERAGE_ARB: - params[0] = BOOLEAN_TO_INT64(ctx->Multisample.SampleCoverage); - break; - case GL_SAMPLE_COVERAGE_VALUE_ARB: - params[0] = IROUND64(ctx->Multisample.SampleCoverageValue); - break; - case GL_SAMPLE_COVERAGE_INVERT_ARB: - params[0] = BOOLEAN_TO_INT64(ctx->Multisample.SampleCoverageInvert); - break; - case GL_SAMPLE_BUFFERS_ARB: - params[0] = (GLint64)(ctx->DrawBuffer->Visual.sampleBuffers); - break; - case GL_SAMPLES_ARB: - params[0] = (GLint64)(ctx->DrawBuffer->Visual.samples); - break; - case GL_RASTER_POSITION_UNCLIPPED_IBM: - CHECK_EXT1(IBM_rasterpos_clip); - params[0] = BOOLEAN_TO_INT64(ctx->Transform.RasterPositionUnclipped); - break; - case GL_POINT_SPRITE_NV: - CHECK_EXT2(NV_point_sprite, ARB_point_sprite); - params[0] = BOOLEAN_TO_INT64(ctx->Point.PointSprite); - break; - case GL_POINT_SPRITE_R_MODE_NV: - CHECK_EXT1(NV_point_sprite); - params[0] = ENUM_TO_INT64(ctx->Point.SpriteRMode); - break; - case GL_POINT_SPRITE_COORD_ORIGIN: - CHECK_EXT2(NV_point_sprite, ARB_point_sprite); - params[0] = ENUM_TO_INT64(ctx->Point.SpriteOrigin); - break; - case GL_GENERATE_MIPMAP_HINT_SGIS: - CHECK_EXT1(SGIS_generate_mipmap); - params[0] = ENUM_TO_INT64(ctx->Hint.GenerateMipmap); - break; - case GL_VERTEX_PROGRAM_BINDING_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = (GLint64)((ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0)); - break; - case GL_VERTEX_ATTRIB_ARRAY0_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[0].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY1_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[1].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY2_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[2].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY3_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[3].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[4].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY5_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[5].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY6_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[6].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY7_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[7].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY8_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[8].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY9_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[9].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY10_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[10].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY11_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[11].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY12_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[12].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY13_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[13].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY14_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[14].Enabled); - break; - case GL_VERTEX_ATTRIB_ARRAY15_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Array.ArrayObj->VertexAttrib[15].Enabled); - break; - case GL_MAP1_VERTEX_ATTRIB0_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[0]); - break; - case GL_MAP1_VERTEX_ATTRIB1_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[1]); - break; - case GL_MAP1_VERTEX_ATTRIB2_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[2]); - break; - case GL_MAP1_VERTEX_ATTRIB3_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[3]); - break; - case GL_MAP1_VERTEX_ATTRIB4_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[4]); - break; - case GL_MAP1_VERTEX_ATTRIB5_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[5]); - break; - case GL_MAP1_VERTEX_ATTRIB6_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[6]); - break; - case GL_MAP1_VERTEX_ATTRIB7_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[7]); - break; - case GL_MAP1_VERTEX_ATTRIB8_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[8]); - break; - case GL_MAP1_VERTEX_ATTRIB9_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[9]); - break; - case GL_MAP1_VERTEX_ATTRIB10_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[10]); - break; - case GL_MAP1_VERTEX_ATTRIB11_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[11]); - break; - case GL_MAP1_VERTEX_ATTRIB12_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[12]); - break; - case GL_MAP1_VERTEX_ATTRIB13_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[13]); - break; - case GL_MAP1_VERTEX_ATTRIB14_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[14]); - break; - case GL_MAP1_VERTEX_ATTRIB15_4_NV: - CHECK_EXT1(NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->Eval.Map1Attrib[15]); - break; - case GL_FRAGMENT_PROGRAM_NV: - CHECK_EXT1(NV_fragment_program); - params[0] = BOOLEAN_TO_INT64(ctx->FragmentProgram.Enabled); - break; - case GL_FRAGMENT_PROGRAM_BINDING_NV: - CHECK_EXT1(NV_fragment_program); - params[0] = (GLint64)(ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0); - break; - case GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV: - CHECK_EXT1(NV_fragment_program); - params[0] = (GLint64)(MAX_NV_FRAGMENT_PROGRAM_PARAMS); - break; - case GL_TEXTURE_RECTANGLE_NV: - CHECK_EXT1(NV_texture_rectangle); - params[0] = BOOLEAN_TO_INT64(_mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV)); - break; - case GL_TEXTURE_BINDING_RECTANGLE_NV: - CHECK_EXT1(NV_texture_rectangle); - params[0] = (GLint64)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_RECT_INDEX]->Name); - break; - case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV: - CHECK_EXT1(NV_texture_rectangle); - params[0] = (GLint64)(ctx->Const.MaxTextureRectSize); - break; - case GL_STENCIL_TEST_TWO_SIDE_EXT: - CHECK_EXT1(EXT_stencil_two_side); - params[0] = BOOLEAN_TO_INT64(ctx->Stencil.TestTwoSide); - break; - case GL_ACTIVE_STENCIL_FACE_EXT: - CHECK_EXT1(EXT_stencil_two_side); - params[0] = ENUM_TO_INT64(ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT); - break; - case GL_MAX_SHININESS_NV: - CHECK_EXT1(NV_light_max_exponent); - params[0] = IROUND64(ctx->Const.MaxShininess); - break; - case GL_MAX_SPOT_EXPONENT_NV: - CHECK_EXT1(NV_light_max_exponent); - params[0] = IROUND64(ctx->Const.MaxSpotExponent); - break; - case GL_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLint64)(ctx->Array.ArrayBufferObj->Name); - break; - case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLint64)(ctx->Array.ArrayObj->Vertex.BufferObj->Name); - break; - case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLint64)(ctx->Array.ArrayObj->Normal.BufferObj->Name); - break; - case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLint64)(ctx->Array.ArrayObj->Color.BufferObj->Name); - break; - case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLint64)(ctx->Array.ArrayObj->Index.BufferObj->Name); - break; - case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLint64)(ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name); - break; - case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLint64)(ctx->Array.ArrayObj->EdgeFlag.BufferObj->Name); - break; - case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLint64)(ctx->Array.ArrayObj->SecondaryColor.BufferObj->Name); - break; - case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLint64)(ctx->Array.ArrayObj->FogCoord.BufferObj->Name); - break; - case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: - params[0] = (GLint64)(ctx->Array.ElementArrayBufferObj->Name); - break; - case GL_PIXEL_PACK_BUFFER_BINDING_EXT: - CHECK_EXT1(EXT_pixel_buffer_object); - params[0] = (GLint64)(ctx->Pack.BufferObj->Name); - break; - case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT: - CHECK_EXT1(EXT_pixel_buffer_object); - params[0] = (GLint64)(ctx->Unpack.BufferObj->Name); - break; - case GL_VERTEX_PROGRAM_ARB: - CHECK_EXT2(ARB_vertex_program, NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->VertexProgram.Enabled); - break; - case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: - CHECK_EXT2(ARB_vertex_program, NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->VertexProgram.PointSizeEnabled); - break; - case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: - CHECK_EXT2(ARB_vertex_program, NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->VertexProgram.TwoSideEnabled); - break; - case GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program); - params[0] = (GLint64)(ctx->Const.MaxProgramMatrixStackDepth); - break; - case GL_MAX_PROGRAM_MATRICES_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program); - params[0] = (GLint64)(ctx->Const.MaxProgramMatrices); - break; - case GL_CURRENT_MATRIX_STACK_DEPTH_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_vertex_program); - params[0] = BOOLEAN_TO_INT64(ctx->CurrentStack->Depth + 1); - break; - case GL_CURRENT_MATRIX_ARB: - CHECK_EXT3(ARB_vertex_program, ARB_fragment_program, NV_fragment_program); - { - const GLfloat *matrix = ctx->CurrentStack->Top->m; - params[0] = IROUND64(matrix[0]); - params[1] = IROUND64(matrix[1]); - params[2] = IROUND64(matrix[2]); - params[3] = IROUND64(matrix[3]); - params[4] = IROUND64(matrix[4]); - params[5] = IROUND64(matrix[5]); - params[6] = IROUND64(matrix[6]); - params[7] = IROUND64(matrix[7]); - params[8] = IROUND64(matrix[8]); - params[9] = IROUND64(matrix[9]); - params[10] = IROUND64(matrix[10]); - params[11] = IROUND64(matrix[11]); - params[12] = IROUND64(matrix[12]); - params[13] = IROUND64(matrix[13]); - params[14] = IROUND64(matrix[14]); - params[15] = IROUND64(matrix[15]); - } - break; - case GL_TRANSPOSE_CURRENT_MATRIX_ARB: - CHECK_EXT2(ARB_vertex_program, ARB_fragment_program); - { - const GLfloat *matrix = ctx->CurrentStack->Top->m; - params[0] = IROUND64(matrix[0]); - params[1] = IROUND64(matrix[4]); - params[2] = IROUND64(matrix[8]); - params[3] = IROUND64(matrix[12]); - params[4] = IROUND64(matrix[1]); - params[5] = IROUND64(matrix[5]); - params[6] = IROUND64(matrix[9]); - params[7] = IROUND64(matrix[13]); - params[8] = IROUND64(matrix[2]); - params[9] = IROUND64(matrix[6]); - params[10] = IROUND64(matrix[10]); - params[11] = IROUND64(matrix[14]); - params[12] = IROUND64(matrix[3]); - params[13] = IROUND64(matrix[7]); - params[14] = IROUND64(matrix[11]); - params[15] = IROUND64(matrix[15]); - } - break; - case GL_MAX_VERTEX_ATTRIBS_ARB: - CHECK_EXT1(ARB_vertex_program); - params[0] = (GLint64)(ctx->Const.VertexProgram.MaxAttribs); - break; - case GL_PROGRAM_ERROR_POSITION_ARB: - CHECK_EXT4(NV_vertex_program, ARB_vertex_program, NV_fragment_program, ARB_fragment_program); - params[0] = (GLint64)(ctx->Program.ErrorPos); - break; - case GL_FRAGMENT_PROGRAM_ARB: - CHECK_EXT1(ARB_fragment_program); - params[0] = BOOLEAN_TO_INT64(ctx->FragmentProgram.Enabled); - break; - case GL_MAX_TEXTURE_COORDS_ARB: - CHECK_EXT2(ARB_fragment_program, NV_fragment_program); - params[0] = (GLint64)(ctx->Const.MaxTextureCoordUnits); - break; - case GL_MAX_TEXTURE_IMAGE_UNITS_ARB: - CHECK_EXT2(ARB_fragment_program, NV_fragment_program); - params[0] = (GLint64)(ctx->Const.MaxTextureImageUnits); - break; - case GL_DEPTH_BOUNDS_TEST_EXT: - CHECK_EXT1(EXT_depth_bounds_test); - params[0] = BOOLEAN_TO_INT64(ctx->Depth.BoundsTest); - break; - case GL_DEPTH_BOUNDS_EXT: - CHECK_EXT1(EXT_depth_bounds_test); - params[0] = IROUND64(ctx->Depth.BoundsMin); - params[1] = IROUND64(ctx->Depth.BoundsMax); - break; - case GL_DEPTH_CLAMP: - CHECK_EXT1(ARB_depth_clamp); - params[0] = BOOLEAN_TO_INT64(ctx->Transform.DepthClamp); - break; - case GL_MAX_DRAW_BUFFERS_ARB: - params[0] = (GLint64)(ctx->Const.MaxDrawBuffers); - break; - case GL_DRAW_BUFFER0_ARB: - params[0] = ENUM_TO_INT64(ctx->DrawBuffer->ColorDrawBuffer[0]); - break; - case GL_DRAW_BUFFER1_ARB: - { - GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[1]; - params[0] = ENUM_TO_INT64(buffer); - } - break; - case GL_DRAW_BUFFER2_ARB: - { - GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[2]; - params[0] = ENUM_TO_INT64(buffer); - } - break; - case GL_DRAW_BUFFER3_ARB: - { - GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[3]; - params[0] = ENUM_TO_INT64(buffer); - } - break; - case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: - CHECK_EXT1(OES_read_format); - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = (GLint64)(_mesa_get_color_read_type(ctx)); - break; - case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: - CHECK_EXT1(OES_read_format); - if (ctx->NewState & _NEW_BUFFERS) - _mesa_update_state(ctx); - params[0] = (GLint64)(_mesa_get_color_read_format(ctx)); - break; - case GL_NUM_FRAGMENT_REGISTERS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = (GLint64)(6); - break; - case GL_NUM_FRAGMENT_CONSTANTS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = (GLint64)(8); - break; - case GL_NUM_PASSES_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = (GLint64)(2); - break; - case GL_NUM_INSTRUCTIONS_PER_PASS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = (GLint64)(8); - break; - case GL_NUM_INSTRUCTIONS_TOTAL_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = (GLint64)(16); - break; - case GL_COLOR_ALPHA_PAIRING_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = BOOLEAN_TO_INT64(GL_TRUE); - break; - case GL_NUM_LOOPBACK_COMPONENTS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = (GLint64)(3); - break; - case GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI: - CHECK_EXT1(ATI_fragment_shader); - params[0] = (GLint64)(3); - break; - case GL_STENCIL_BACK_FUNC: - params[0] = ENUM_TO_INT64(ctx->Stencil.Function[1]); - break; - case GL_STENCIL_BACK_VALUE_MASK: - params[0] = (GLint64)(ctx->Stencil.ValueMask[1]); - break; - case GL_STENCIL_BACK_WRITEMASK: - params[0] = (GLint64)(ctx->Stencil.WriteMask[1]); - break; - case GL_STENCIL_BACK_REF: - params[0] = (GLint64)(ctx->Stencil.Ref[1]); - break; - case GL_STENCIL_BACK_FAIL: - params[0] = ENUM_TO_INT64(ctx->Stencil.FailFunc[1]); - break; - case GL_STENCIL_BACK_PASS_DEPTH_FAIL: - params[0] = ENUM_TO_INT64(ctx->Stencil.ZFailFunc[1]); - break; - case GL_STENCIL_BACK_PASS_DEPTH_PASS: - params[0] = ENUM_TO_INT64(ctx->Stencil.ZPassFunc[1]); - break; - case GL_FRAMEBUFFER_BINDING_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = (GLint64)(ctx->DrawBuffer->Name); - break; - case GL_RENDERBUFFER_BINDING_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = (GLint64)(ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0); - break; - case GL_MAX_COLOR_ATTACHMENTS_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = (GLint64)(ctx->Const.MaxColorAttachments); - break; - case GL_MAX_RENDERBUFFER_SIZE_EXT: - CHECK_EXT1(EXT_framebuffer_object); - params[0] = (GLint64)(ctx->Const.MaxRenderbufferSize); - break; - case GL_READ_FRAMEBUFFER_BINDING_EXT: - CHECK_EXT1(EXT_framebuffer_blit); - params[0] = (GLint64)(ctx->ReadBuffer->Name); - break; - case GL_PROVOKING_VERTEX_EXT: - CHECK_EXT1(EXT_provoking_vertex); - params[0] = BOOLEAN_TO_INT64(ctx->Light.ProvokingVertex); - break; - case GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT: - CHECK_EXT1(EXT_provoking_vertex); - params[0] = BOOLEAN_TO_INT64(ctx->Const.QuadsFollowProvokingVertexConvention); - break; - case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB: - CHECK_EXT1(ARB_fragment_shader); - params[0] = (GLint64)(ctx->Const.FragmentProgram.MaxUniformComponents); - break; - case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB: - CHECK_EXT1(ARB_fragment_shader); - params[0] = ENUM_TO_INT64(ctx->Hint.FragmentShaderDerivative); - break; - case GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = (GLint64)(ctx->Const.VertexProgram.MaxUniformComponents); - break; - case GL_MAX_VARYING_FLOATS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = (GLint64)(ctx->Const.MaxVarying * 4); - break; - case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = (GLint64)(ctx->Const.MaxVertexTextureImageUnits); - break; - case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB: - CHECK_EXT1(ARB_vertex_shader); - params[0] = (GLint64)(ctx->Const.MaxCombinedTextureImageUnits); - break; - case GL_CURRENT_PROGRAM: - CHECK_EXT1(ARB_shader_objects); - params[0] = (GLint64)(ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0); - break; - case GL_MAX_SAMPLES: - CHECK_EXT1(ARB_framebuffer_object); - params[0] = (GLint64)(ctx->Const.MaxSamples); - break; - case GL_VERTEX_ARRAY_BINDING_APPLE: - CHECK_EXT1(APPLE_vertex_array_object); - params[0] = (GLint64)(ctx->Array.ArrayObj->Name); - break; - case GL_TEXTURE_CUBE_MAP_SEAMLESS: - CHECK_EXT1(ARB_seamless_cube_map); - params[0] = BOOLEAN_TO_INT64(ctx->Texture.CubeMapSeamless); - break; - case GL_MAX_SERVER_WAIT_TIMEOUT: - CHECK_EXT1(ARB_sync); - params[0] = ctx->Const.MaxServerWaitTimeout; - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: - CHECK_EXT1(EXT_transform_feedback); - params[0] = (GLint64)(ctx->TransformFeedback.CurrentBuffer->Name); - break; - case GL_RASTERIZER_DISCARD: - CHECK_EXT1(EXT_transform_feedback); - params[0] = BOOLEAN_TO_INT64(ctx->TransformFeedback.RasterDiscard); - break; - case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: - CHECK_EXT1(EXT_transform_feedback); - params[0] = (GLint64)(ctx->Const.MaxTransformFeedbackInterleavedComponents); - break; - case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: - CHECK_EXT1(EXT_transform_feedback); - params[0] = (GLint64)(ctx->Const.MaxTransformFeedbackSeparateAttribs); - break; - case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: - CHECK_EXT1(EXT_transform_feedback); - params[0] = (GLint64)(ctx->Const.MaxTransformFeedbackSeparateComponents); - break; - case GL_NUM_EXTENSIONS: - CHECK_VERSION(30); - params[0] = (GLint64)(_mesa_get_extension_count(ctx)); - break; - case GL_MAJOR_VERSION: - CHECK_VERSION(30); - params[0] = (GLint64)(ctx->VersionMajor); - break; - case GL_MINOR_VERSION: - CHECK_VERSION(30); - params[0] = (GLint64)(ctx->VersionMinor); - break; - case GL_CONTEXT_FLAGS: - CHECK_VERSION(30); - params[0] = (GLint64)(ctx->Const.ContextFlags); - break; - case GL_PRIMITIVE_RESTART: - CHECK_VERSION(31); - params[0] = BOOLEAN_TO_INT64(ctx->Array.PrimitiveRestart); - break; - case GL_PRIMITIVE_RESTART_INDEX: - CHECK_VERSION(31); - params[0] = (GLint64)(ctx->Array.RestartIndex); - break; - case GL_CONTEXT_PROFILE_MASK: - CHECK_VERSION(32); - params[0] = (GLint64)(ctx->Const.ProfileMask); - break; - default: - goto invalid_enum_error; - } - return; + case TYPE_FLOATN_4: + params[3] = FLOAT_TO_INT64(((GLfloat *) p)[3]); + case TYPE_FLOATN_3: + params[2] = FLOAT_TO_INT64(((GLfloat *) p)[2]); + case TYPE_FLOATN_2: + params[1] = FLOAT_TO_INT64(((GLfloat *) p)[1]); + case TYPE_FLOATN: + params[0] = FLOAT_TO_INT64(((GLfloat *) p)[0]); + break; + + case TYPE_DOUBLEN: + params[0] = FLOAT_TO_INT64(((GLdouble *) p)[0]); + break; + + case TYPE_INT_4: + params[3] = ((GLint *) p)[3]; + case TYPE_INT_3: + params[2] = ((GLint *) p)[2]; + case TYPE_INT_2: + case TYPE_ENUM_2: + params[1] = ((GLint *) p)[1]; + case TYPE_INT: + case TYPE_ENUM: + params[0] = ((GLint *) p)[0]; + break; + + case TYPE_INT_N: + for (i = 0; i < v.value_int_n.n; i++) + params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]); + break; + + case TYPE_INT64: + params[0] = ((GLint64 *) p)[0]; + break; + + case TYPE_BOOLEAN: + params[0] = ((GLboolean*) p)[0]; + break; + + case TYPE_MATRIX: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_INT64(m->m[i]); + break; + + case TYPE_MATRIX_T: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_INT64(m->m[transpose[i]]); + break; -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64v(pname=0x%x)", pname); + case TYPE_BIT_0: + case TYPE_BIT_1: + case TYPE_BIT_2: + case TYPE_BIT_3: + case TYPE_BIT_4: + case TYPE_BIT_5: + shift = d->type - TYPE_BIT_0; + params[0] = (*(GLbitfield *) p >> shift) & 1; + break; + } } #endif /* FEATURE_ARB_sync */ - void GLAPIENTRY -_mesa_GetDoublev( GLenum pname, GLdouble *params ) +_mesa_GetDoublev(GLenum pname, GLdouble *params) { - const GLfloat magic = -1234.5F; - GLfloat values[16]; - GLuint i; + const struct value_desc *d; + union value v; + GLmatrix *m; + int shift, i; + void *p; - if (!params) - return; + d = find_value("glGetDoublev", pname, &p, &v); + switch (d->type) { + case TYPE_INVALID: + break; + case TYPE_CONST: + params[0] = d->offset; + break; - /* Init temp array to magic numbers so we can figure out how many values - * are returned by the GetFloatv() call. - */ - for (i = 0; i < 16; i++) - values[i] = magic; + case TYPE_FLOAT_4: + case TYPE_FLOATN_4: + params[3] = ((GLfloat *) p)[3]; + case TYPE_FLOAT_3: + case TYPE_FLOATN_3: + params[2] = ((GLfloat *) p)[2]; + case TYPE_FLOAT_2: + case TYPE_FLOATN_2: + params[1] = ((GLfloat *) p)[1]; + case TYPE_FLOAT: + case TYPE_FLOATN: + params[0] = ((GLfloat *) p)[0]; + break; - _mesa_GetFloatv(pname, values); - - for (i = 0; i < 16 && values[i] != magic; i++) - params[i] = (GLdouble) values[i]; + case TYPE_DOUBLEN: + params[0] = ((GLdouble *) p)[0]; + break; + + case TYPE_INT_4: + params[3] = ((GLint *) p)[3]; + case TYPE_INT_3: + params[2] = ((GLint *) p)[2]; + case TYPE_INT_2: + case TYPE_ENUM_2: + params[1] = ((GLint *) p)[1]; + case TYPE_INT: + case TYPE_ENUM: + params[0] = ((GLint *) p)[0]; + break; + + case TYPE_INT_N: + for (i = 0; i < v.value_int_n.n; i++) + params[i] = v.value_int_n.ints[i]; + break; + + case TYPE_INT64: + params[0] = ((GLint64 *) p)[0]; + break; + + case TYPE_BOOLEAN: + params[0] = *(GLboolean*) p; + break; + + case TYPE_MATRIX: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = m->m[i]; + break; + + case TYPE_MATRIX_T: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = m->m[transpose[i]]; + break; + + case TYPE_BIT_0: + case TYPE_BIT_1: + case TYPE_BIT_2: + case TYPE_BIT_3: + case TYPE_BIT_4: + case TYPE_BIT_5: + shift = d->type - TYPE_BIT_0; + params[0] = (*(GLbitfield *) p >> shift) & 1; + break; + } } -void GLAPIENTRY -_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ) +static enum value_type +find_value_indexed(const char *func, GLenum pname, int index, union value *v) { GET_CURRENT_CONTEXT(ctx); - const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; - ASSERT_OUTSIDE_BEGIN_END(ctx); - (void) version; - - if (!params) - return; switch (pname) { - case GL_BLEND: - CHECK_EXT1(EXT_draw_buffers2); - if (index >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); - return; - } - params[0] = INT_TO_BOOLEAN(((ctx->Color.BlendEnabled >> index) & 1)); - break; - case GL_COLOR_WRITEMASK: - CHECK_EXT1(EXT_draw_buffers2); - if (index >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); - return; - } - params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][RCOMP] ? 1 : 0); - params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][GCOMP] ? 1 : 0); - params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][BCOMP] ? 1 : 0); - params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][ACOMP] ? 1 : 0); - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_START: - CHECK_EXT1(EXT_transform_feedback); - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); - return; - } - params[0] = INT64_TO_BOOLEAN(ctx->TransformFeedback.Offset[index]); - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: - CHECK_EXT1(EXT_transform_feedback); - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); - return; - } - params[0] = INT64_TO_BOOLEAN(ctx->TransformFeedback.Size[index]); - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: - CHECK_EXT1(EXT_transform_feedback); - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); - return; - } - params[0] = INT_TO_BOOLEAN(ctx->TransformFeedback.Buffers[index]->Name); - break; - default: - goto invalid_enum_error; + + case GL_BLEND: + if (index >= ctx->Const.MaxDrawBuffers) + goto invalid_value; + if (!ctx->Extensions.EXT_draw_buffers2) + goto invalid_enum; + v->value_int = (ctx->Color.BlendEnabled >> index) & 1; + return TYPE_INT; + + case GL_COLOR_WRITEMASK: + if (index >= ctx->Const.MaxDrawBuffers) + goto invalid_value; + if (!ctx->Extensions.EXT_draw_buffers2) + goto invalid_enum; + v->value_int_4[0] = ctx->Color.ColorMask[index][RCOMP] ? 1 : 0; + v->value_int_4[1] = ctx->Color.ColorMask[index][GCOMP] ? 1 : 0; + v->value_int_4[2] = ctx->Color.ColorMask[index][BCOMP] ? 1 : 0; + v->value_int_4[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0; + return TYPE_INT_4; + + case GL_TRANSFORM_FEEDBACK_BUFFER_START: + if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) + goto invalid_value; + if (!ctx->Extensions.EXT_transform_feedback) + goto invalid_enum; + v->value_int64 = ctx->TransformFeedback.CurrentObject->Offset[index]; + return TYPE_INT64; + + case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: + if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) + goto invalid_value; + if (!ctx->Extensions.EXT_transform_feedback) + goto invalid_enum; + v->value_int64 = ctx->TransformFeedback.CurrentObject->Size[index]; + return TYPE_INT64; + + case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: + if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) + goto invalid_value; + if (!ctx->Extensions.EXT_transform_feedback) + goto invalid_enum; + v->value_int = ctx->TransformFeedback.CurrentObject->Buffers[index]->Name; + return TYPE_INT; } - return; -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanIndexedv(pname=0x%x)", pname); + invalid_enum: + _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func, + _mesa_lookup_enum_by_nr(pname)); + return TYPE_INVALID; + invalid_value: + _mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s)", func, + _mesa_lookup_enum_by_nr(pname)); + return TYPE_INVALID; } void GLAPIENTRY -_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) +_mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ) { - GET_CURRENT_CONTEXT(ctx); - const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; - ASSERT_OUTSIDE_BEGIN_END(ctx); - (void) version; + union value v; - if (!params) - return; - - switch (pname) { - case GL_BLEND: - CHECK_EXT1(EXT_draw_buffers2); - if (index >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); - return; - } - params[0] = ((ctx->Color.BlendEnabled >> index) & 1); - break; - case GL_COLOR_WRITEMASK: - CHECK_EXT1(EXT_draw_buffers2); - if (index >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); - return; - } - params[0] = ctx->Color.ColorMask[index][RCOMP] ? 1 : 0; - params[1] = ctx->Color.ColorMask[index][GCOMP] ? 1 : 0; - params[2] = ctx->Color.ColorMask[index][BCOMP] ? 1 : 0; - params[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0; - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_START: - CHECK_EXT1(EXT_transform_feedback); - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); - return; - } - params[0] = INT64_TO_INT(ctx->TransformFeedback.Offset[index]); - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: - CHECK_EXT1(EXT_transform_feedback); - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); - return; - } - params[0] = INT64_TO_INT(ctx->TransformFeedback.Size[index]); - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: - CHECK_EXT1(EXT_transform_feedback); - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); - return; - } - params[0] = ctx->TransformFeedback.Buffers[index]->Name; - break; - default: - goto invalid_enum_error; + switch (find_value_indexed("glGetBooleanIndexedv", pname, index, &v)) { + case TYPE_INT: + params[0] = INT_TO_BOOLEAN(v.value_int); + break; + case TYPE_INT_4: + params[0] = INT_TO_BOOLEAN(v.value_int_4[0]); + params[1] = INT_TO_BOOLEAN(v.value_int_4[1]); + params[2] = INT_TO_BOOLEAN(v.value_int_4[2]); + params[3] = INT_TO_BOOLEAN(v.value_int_4[3]); + break; + case TYPE_INT64: + params[0] = INT64_TO_BOOLEAN(v.value_int); + break; + default: + assert(0); } - return; +} + +void GLAPIENTRY +_mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) +{ + union value v; -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerIndexedv(pname=0x%x)", pname); + switch (find_value_indexed("glGetIntegerIndexedv", pname, index, &v)) { + case TYPE_INT: + params[0] = v.value_int; + break; + case TYPE_INT_4: + params[0] = v.value_int_4[0]; + params[1] = v.value_int_4[1]; + params[2] = v.value_int_4[2]; + params[3] = v.value_int_4[3]; + break; + case TYPE_INT64: + params[0] = INT64_TO_INT(v.value_int); + break; + default: + assert(0); + } } #if FEATURE_ARB_sync void GLAPIENTRY _mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ) { - GET_CURRENT_CONTEXT(ctx); - const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor; - ASSERT_OUTSIDE_BEGIN_END(ctx); - (void) version; + union value v; - if (!params) - return; - - switch (pname) { - case GL_BLEND: - CHECK_EXT1(EXT_draw_buffers2); - if (index >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); - return; - } - params[0] = (GLint64)(((ctx->Color.BlendEnabled >> index) & 1)); - break; - case GL_COLOR_WRITEMASK: - CHECK_EXT1(EXT_draw_buffers2); - if (index >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); - return; - } - params[0] = (GLint64)(ctx->Color.ColorMask[index][RCOMP] ? 1 : 0); - params[1] = (GLint64)(ctx->Color.ColorMask[index][GCOMP] ? 1 : 0); - params[2] = (GLint64)(ctx->Color.ColorMask[index][BCOMP] ? 1 : 0); - params[3] = (GLint64)(ctx->Color.ColorMask[index][ACOMP] ? 1 : 0); - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_START: - CHECK_EXT1(EXT_transform_feedback); - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); - return; - } - params[0] = ctx->TransformFeedback.Offset[index]; - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: - CHECK_EXT1(EXT_transform_feedback); - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); - return; - } - params[0] = ctx->TransformFeedback.Size[index]; - break; - case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: - CHECK_EXT1(EXT_transform_feedback); - if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); - return; - } - params[0] = (GLint64)(ctx->TransformFeedback.Buffers[index]->Name); - break; - default: - goto invalid_enum_error; + switch (find_value_indexed("glGetIntegerIndexedv", pname, index, &v)) { + case TYPE_INT: + params[0] = v.value_int; + break; + case TYPE_INT_4: + params[0] = v.value_int_4[0]; + params[1] = v.value_int_4[1]; + params[2] = v.value_int_4[2]; + params[3] = v.value_int_4[3]; + break; + case TYPE_INT64: + params[0] = v.value_int; + break; + default: + assert(0); } - return; - -invalid_enum_error: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64Indexedv(pname=0x%x)", pname); } #endif /* FEATURE_ARB_sync */ +#if FEATURE_ES1 +void GLAPIENTRY +_mesa_GetFixedv(GLenum pname, GLfixed *params) +{ + const struct value_desc *d; + union value v; + GLmatrix *m; + int shift, i; + void *p; + + d = find_value("glGetDoublev", pname, &p, &v); + switch (d->type) { + case TYPE_INVALID: + break; + case TYPE_CONST: + params[0] = INT_TO_FIXED(d->offset); + break; + + case TYPE_FLOAT_4: + case TYPE_FLOATN_4: + params[3] = FLOAT_TO_FIXED(((GLfloat *) p)[3]); + case TYPE_FLOAT_3: + case TYPE_FLOATN_3: + params[2] = FLOAT_TO_FIXED(((GLfloat *) p)[2]); + case TYPE_FLOAT_2: + case TYPE_FLOATN_2: + params[1] = FLOAT_TO_FIXED(((GLfloat *) p)[1]); + case TYPE_FLOAT: + case TYPE_FLOATN: + params[0] = FLOAT_TO_FIXED(((GLfloat *) p)[0]); + break; + + case TYPE_DOUBLEN: + params[0] = FLOAT_TO_FIXED(((GLdouble *) p)[0]); + break; + + case TYPE_INT_4: + params[3] = INT_TO_FIXED(((GLint *) p)[3]); + case TYPE_INT_3: + params[2] = INT_TO_FIXED(((GLint *) p)[2]); + case TYPE_INT_2: + case TYPE_ENUM_2: + params[1] = INT_TO_FIXED(((GLint *) p)[1]); + case TYPE_INT: + case TYPE_ENUM: + params[0] = INT_TO_FIXED(((GLint *) p)[0]); + break; + + case TYPE_INT_N: + for (i = 0; i < v.value_int_n.n; i++) + params[i] = INT_TO_FIXED(v.value_int_n.ints[i]); + break; + + case TYPE_INT64: + params[0] = ((GLint64 *) p)[0]; + break; + + case TYPE_BOOLEAN: + params[0] = BOOLEAN_TO_FIXED(((GLboolean*) p)[0]); + break; + + case TYPE_MATRIX: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_FIXED(m->m[i]); + break; + + case TYPE_MATRIX_T: + m = *(GLmatrix **) p; + for (i = 0; i < 16; i++) + params[i] = FLOAT_TO_FIXED(m->m[transpose[i]]); + break; + + case TYPE_BIT_0: + case TYPE_BIT_1: + case TYPE_BIT_2: + case TYPE_BIT_3: + case TYPE_BIT_4: + case TYPE_BIT_5: + shift = d->type - TYPE_BIT_0; + params[0] = BOOLEAN_TO_FIXED((*(GLbitfield *) p >> shift) & 1); + break; + } +} +#endif diff --git a/src/mesa/main/get.h b/src/mesa/main/get.h index 47e549e396b..320492b4ce2 100644 --- a/src/mesa/main/get.h +++ b/src/mesa/main/get.h @@ -51,6 +51,9 @@ extern void GLAPIENTRY _mesa_GetInteger64v( GLenum pname, GLint64 *params ); extern void GLAPIENTRY +_mesa_GetFixedv(GLenum pname, GLfixed *params); + +extern void GLAPIENTRY _mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ); extern void GLAPIENTRY @@ -71,27 +74,4 @@ _mesa_GetStringi(GLenum name, GLuint index); extern GLenum GLAPIENTRY _mesa_GetError( void ); - -extern void GLAPIENTRY -_es1_GetBooleanv( GLenum pname, GLboolean *params ); - -extern void GLAPIENTRY -_es1_GetFloatv( GLenum pname, GLfloat *params ); - -extern void GLAPIENTRY -_es1_GetIntegerv( GLenum pname, GLint *params ); - -extern void GLAPIENTRY -_es1_GetFixedv( GLenum pname, GLfixed *params ); - - -extern void GLAPIENTRY -_es2_GetBooleanv( GLenum pname, GLboolean *params ); - -extern void GLAPIENTRY -_es2_GetFloatv( GLenum pname, GLfloat *params ); - -extern void GLAPIENTRY -_es2_GetIntegerv( GLenum pname, GLint *params ); - #endif diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py deleted file mode 100644 index 21f7750dbd7..00000000000 --- a/src/mesa/main/get_gen.py +++ /dev/null @@ -1,1467 +0,0 @@ -#!/usr/bin/env python - -# Mesa 3-D graphics library -# -# Copyright (C) 1999-2006 Brian Paul All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -# This script is used to generate the get.c file: -# python get_gen.py > get.c - - -import string -import sys - - -GLint = 1 -GLenum = 2 -GLfloat = 3 -GLdouble = 4 -GLboolean = 5 -GLfloatN = 6 # A normalized value, such as a color or depth range -GLint64 = 7 - - -TypeStrings = { - GLint : "GLint", - GLenum : "GLenum", - GLfloat : "GLfloat", - GLdouble : "GLdouble", - GLboolean : "GLboolean", - GLint64 : "GLint64" -} - - -NoState = None -NoExt = None -FlushCurrent = 1 - - -# Each entry is a tuple of: -# - the GL state name, such as GL_CURRENT_COLOR -# - the state datatype, one of GLint, GLfloat, GLboolean or GLenum -# - list of code fragments to get the state, such as ["ctx->Foo.Bar"] -# - optional extra code or empty string. If present, "CONVERSION" will be -# replaced by ENUM_TO_FLOAT, INT_TO_FLOAT, etc. -# - state flags: either NoExt, FlushCurrent or "_NEW_xxx" -# if NoExt, do nothing special -# if FlushCurrent, emit FLUSH_CURRENT() call -# if "_NEW_xxx", call _mesa_update_state() if that dirty state flag is set -# - optional extensions to check, or NoExt -# -StateVars = [ - ( "GL_ACCUM_RED_BITS", GLint, ["ctx->DrawBuffer->Visual.accumRedBits"], - "", NoState, NoExt ), - ( "GL_ACCUM_GREEN_BITS", GLint, ["ctx->DrawBuffer->Visual.accumGreenBits"], - "", NoState, NoExt ), - ( "GL_ACCUM_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.accumBlueBits"], - "", NoState, NoExt ), - ( "GL_ACCUM_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.accumAlphaBits"], - "", NoState, NoExt ), - ( "GL_ACCUM_CLEAR_VALUE", GLfloatN, - [ "ctx->Accum.ClearColor[0]", - "ctx->Accum.ClearColor[1]", - "ctx->Accum.ClearColor[2]", - "ctx->Accum.ClearColor[3]" ], - "", NoState, NoExt ), - ( "GL_ALPHA_BIAS", GLfloat, ["ctx->Pixel.AlphaBias"], "", NoState, NoExt ), - ( "GL_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.alphaBits"], - "", "_NEW_BUFFERS", NoExt ), - ( "GL_ALPHA_SCALE", GLfloat, ["ctx->Pixel.AlphaScale"], "", NoState, NoExt ), - ( "GL_ALPHA_TEST", GLboolean, ["ctx->Color.AlphaEnabled"], "", NoState, NoExt ), - ( "GL_ALPHA_TEST_FUNC", GLenum, ["ctx->Color.AlphaFunc"], "", NoState, NoExt ), - ( "GL_ALPHA_TEST_REF", GLfloatN, ["ctx->Color.AlphaRef"], "", NoState, NoExt ), - ( "GL_ATTRIB_STACK_DEPTH", GLint, ["ctx->AttribStackDepth"], "", NoState, NoExt ), - ( "GL_AUTO_NORMAL", GLboolean, ["ctx->Eval.AutoNormal"], "", NoState, NoExt ), - ( "GL_AUX_BUFFERS", GLint, ["ctx->DrawBuffer->Visual.numAuxBuffers"], - "", NoState, NoExt ), - ( "GL_BLEND", GLboolean, ["(ctx->Color.BlendEnabled & 1)"], "", NoState, NoExt ), - ( "GL_BLEND_DST", GLenum, ["ctx->Color.BlendDstRGB"], "", NoState, NoExt ), - ( "GL_BLEND_SRC", GLenum, ["ctx->Color.BlendSrcRGB"], "", NoState, NoExt ), - ( "GL_BLEND_SRC_RGB_EXT", GLenum, ["ctx->Color.BlendSrcRGB"], "", NoState, NoExt ), - ( "GL_BLEND_DST_RGB_EXT", GLenum, ["ctx->Color.BlendDstRGB"], "", NoState, NoExt ), - ( "GL_BLEND_SRC_ALPHA_EXT", GLenum, ["ctx->Color.BlendSrcA"], "", NoState, NoExt ), - ( "GL_BLEND_DST_ALPHA_EXT", GLenum, ["ctx->Color.BlendDstA"], "", NoState, NoExt ), - ( "GL_BLEND_EQUATION", GLenum, ["ctx->Color.BlendEquationRGB "], "", NoState, NoExt), - ( "GL_BLEND_EQUATION_ALPHA_EXT", GLenum, ["ctx->Color.BlendEquationA "], - "", NoState, NoExt ), - ( "GL_BLEND_COLOR_EXT", GLfloatN, - [ "ctx->Color.BlendColor[0]", - "ctx->Color.BlendColor[1]", - "ctx->Color.BlendColor[2]", - "ctx->Color.BlendColor[3]"], "", NoState, NoExt ), - ( "GL_BLUE_BIAS", GLfloat, ["ctx->Pixel.BlueBias"], "", NoState, NoExt ), - ( "GL_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.blueBits"], "", "_NEW_BUFFERS", NoExt ), - ( "GL_BLUE_SCALE", GLfloat, ["ctx->Pixel.BlueScale"], "", NoState, NoExt ), - ( "GL_CLIENT_ATTRIB_STACK_DEPTH", GLint, - ["ctx->ClientAttribStackDepth"], "", NoState, NoExt ), - ( "GL_CLIP_PLANE0", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 0) & 1" ], "", NoState, NoExt ), - ( "GL_CLIP_PLANE1", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 1) & 1" ], "", NoState, NoExt ), - ( "GL_CLIP_PLANE2", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 2) & 1" ], "", NoState, NoExt ), - ( "GL_CLIP_PLANE3", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 3) & 1" ], "", NoState, NoExt ), - ( "GL_CLIP_PLANE4", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 4) & 1" ], "", NoState, NoExt ), - ( "GL_CLIP_PLANE5", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 5) & 1" ], "", NoState, NoExt ), - ( "GL_COLOR_CLEAR_VALUE", GLfloatN, - [ "ctx->Color.ClearColor[0]", - "ctx->Color.ClearColor[1]", - "ctx->Color.ClearColor[2]", - "ctx->Color.ClearColor[3]" ], "", NoState, NoExt ), - ( "GL_COLOR_MATERIAL", GLboolean, - ["ctx->Light.ColorMaterialEnabled"], "", NoState, NoExt ), - ( "GL_COLOR_MATERIAL_FACE", GLenum, - ["ctx->Light.ColorMaterialFace"], "", NoState, NoExt ), - ( "GL_COLOR_MATERIAL_PARAMETER", GLenum, - ["ctx->Light.ColorMaterialMode"], "", NoState, NoExt ), - ( "GL_COLOR_WRITEMASK", GLint, - [ "ctx->Color.ColorMask[0][RCOMP] ? 1 : 0", - "ctx->Color.ColorMask[0][GCOMP] ? 1 : 0", - "ctx->Color.ColorMask[0][BCOMP] ? 1 : 0", - "ctx->Color.ColorMask[0][ACOMP] ? 1 : 0" ], "", NoState, NoExt ), - ( "GL_CULL_FACE", GLboolean, ["ctx->Polygon.CullFlag"], "", NoState, NoExt ), - ( "GL_CULL_FACE_MODE", GLenum, ["ctx->Polygon.CullFaceMode"], "", NoState, NoExt ), - ( "GL_CURRENT_COLOR", GLfloatN, - [ "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]", - "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]", - "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]", - "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]" ], - "", FlushCurrent, NoExt ), - ( "GL_CURRENT_INDEX", GLfloat, - [ "ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]" ], - "", FlushCurrent, NoExt ), - ( "GL_CURRENT_NORMAL", GLfloatN, - [ "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]", - "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]", - "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]"], - "", FlushCurrent, NoExt ), - ( "GL_CURRENT_RASTER_COLOR", GLfloatN, - ["ctx->Current.RasterColor[0]", - "ctx->Current.RasterColor[1]", - "ctx->Current.RasterColor[2]", - "ctx->Current.RasterColor[3]"], "", NoState, NoExt ), - ( "GL_CURRENT_RASTER_DISTANCE", GLfloat, - ["ctx->Current.RasterDistance"], "", NoState, NoExt ), - ( "GL_CURRENT_RASTER_INDEX", GLfloat, - ["1.0"], "", NoState, NoExt ), - ( "GL_CURRENT_RASTER_POSITION", GLfloat, - ["ctx->Current.RasterPos[0]", - "ctx->Current.RasterPos[1]", - "ctx->Current.RasterPos[2]", - "ctx->Current.RasterPos[3]"], "", NoState, NoExt ), - ( "GL_CURRENT_RASTER_SECONDARY_COLOR", GLfloatN, - ["ctx->Current.RasterSecondaryColor[0]", - "ctx->Current.RasterSecondaryColor[1]", - "ctx->Current.RasterSecondaryColor[2]", - "ctx->Current.RasterSecondaryColor[3]"], "", NoState, NoExt ), - ( "GL_CURRENT_RASTER_TEXTURE_COORDS", GLfloat, - ["ctx->Current.RasterTexCoords[unit][0]", - "ctx->Current.RasterTexCoords[unit][1]", - "ctx->Current.RasterTexCoords[unit][2]", - "ctx->Current.RasterTexCoords[unit][3]"], - """const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(raster tex coords, unit %u)", unit); - return; - }""", - NoState, NoExt ), - ( "GL_CURRENT_RASTER_POSITION_VALID", GLboolean, - ["ctx->Current.RasterPosValid"], "", NoState, NoExt ), - ( "GL_CURRENT_TEXTURE_COORDS", GLfloat, - ["ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][0]", - "ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][1]", - "ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2]", - "ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3]"], - """const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(current tex coords, unit %u)", unit); - return; - } - FLUSH_CURRENT(ctx, 0);""", - NoState, NoExt ), - ( "GL_DEPTH_BIAS", GLfloat, ["ctx->Pixel.DepthBias"], "", NoState, NoExt ), - ( "GL_DEPTH_BITS", GLint, ["ctx->DrawBuffer->Visual.depthBits"], - "", NoState, NoExt ), - ( "GL_DEPTH_CLEAR_VALUE", GLfloatN, ["((GLfloat) ctx->Depth.Clear)"], "", NoState, NoExt ), - ( "GL_DEPTH_FUNC", GLenum, ["ctx->Depth.Func"], "", NoState, NoExt ), - ( "GL_DEPTH_RANGE", GLfloatN, - [ "ctx->Viewport.Near", "ctx->Viewport.Far" ], "", NoState, NoExt ), - ( "GL_DEPTH_SCALE", GLfloat, ["ctx->Pixel.DepthScale"], "", NoState, NoExt ), - ( "GL_DEPTH_TEST", GLboolean, ["ctx->Depth.Test"], "", NoState, NoExt ), - ( "GL_DEPTH_WRITEMASK", GLboolean, ["ctx->Depth.Mask"], "", NoState, NoExt ), - ( "GL_DITHER", GLboolean, ["ctx->Color.DitherFlag"], "", NoState, NoExt ), - ( "GL_DOUBLEBUFFER", GLboolean, - ["ctx->DrawBuffer->Visual.doubleBufferMode"], "", NoState, NoExt ), - ( "GL_DRAW_BUFFER", GLenum, ["ctx->DrawBuffer->ColorDrawBuffer[0]"], "", NoState, NoExt ), - ( "GL_EDGE_FLAG", GLboolean, ["(ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] == 1.0)"], - "", FlushCurrent, NoExt ), - ( "GL_FEEDBACK_BUFFER_SIZE", GLint, ["ctx->Feedback.BufferSize"], "", NoState, NoExt ), - ( "GL_FEEDBACK_BUFFER_TYPE", GLenum, ["ctx->Feedback.Type"], "", NoState, NoExt ), - ( "GL_FOG", GLboolean, ["ctx->Fog.Enabled"], "", NoState, NoExt ), - ( "GL_FOG_COLOR", GLfloatN, - [ "ctx->Fog.Color[0]", - "ctx->Fog.Color[1]", - "ctx->Fog.Color[2]", - "ctx->Fog.Color[3]" ], "", NoState, NoExt ), - ( "GL_FOG_DENSITY", GLfloat, ["ctx->Fog.Density"], "", NoState, NoExt ), - ( "GL_FOG_END", GLfloat, ["ctx->Fog.End"], "", NoState, NoExt ), - ( "GL_FOG_HINT", GLenum, ["ctx->Hint.Fog"], "", NoState, NoExt ), - ( "GL_FOG_INDEX", GLfloat, ["ctx->Fog.Index"], "", NoState, NoExt ), - ( "GL_FOG_MODE", GLenum, ["ctx->Fog.Mode"], "", NoState, NoExt ), - ( "GL_FOG_START", GLfloat, ["ctx->Fog.Start"], "", NoState, NoExt ), - ( "GL_FRONT_FACE", GLenum, ["ctx->Polygon.FrontFace"], "", NoState, NoExt ), - ( "GL_GREEN_BIAS", GLfloat, ["ctx->Pixel.GreenBias"], "", NoState, NoExt ), - ( "GL_GREEN_BITS", GLint, ["ctx->DrawBuffer->Visual.greenBits"], - "", "_NEW_BUFFERS", NoExt ), - ( "GL_GREEN_SCALE", GLfloat, ["ctx->Pixel.GreenScale"], "", NoState, NoExt ), - ( "GL_INDEX_BITS", GLint, ["ctx->DrawBuffer->Visual.indexBits"], - "", "_NEW_BUFFERS", NoExt ), - ( "GL_INDEX_CLEAR_VALUE", GLint, ["ctx->Color.ClearIndex"], "", NoState, NoExt ), - ( "GL_INDEX_MODE", GLboolean, ["GL_FALSE"], - "", NoState, NoExt ), - ( "GL_INDEX_OFFSET", GLint, ["ctx->Pixel.IndexOffset"], "", NoState, NoExt ), - ( "GL_INDEX_SHIFT", GLint, ["ctx->Pixel.IndexShift"], "", NoState, NoExt ), - ( "GL_INDEX_WRITEMASK", GLint, ["ctx->Color.IndexMask"], "", NoState, NoExt ), - ( "GL_LIGHT0", GLboolean, ["ctx->Light.Light[0].Enabled"], "", NoState, NoExt ), - ( "GL_LIGHT1", GLboolean, ["ctx->Light.Light[1].Enabled"], "", NoState, NoExt ), - ( "GL_LIGHT2", GLboolean, ["ctx->Light.Light[2].Enabled"], "", NoState, NoExt ), - ( "GL_LIGHT3", GLboolean, ["ctx->Light.Light[3].Enabled"], "", NoState, NoExt ), - ( "GL_LIGHT4", GLboolean, ["ctx->Light.Light[4].Enabled"], "", NoState, NoExt ), - ( "GL_LIGHT5", GLboolean, ["ctx->Light.Light[5].Enabled"], "", NoState, NoExt ), - ( "GL_LIGHT6", GLboolean, ["ctx->Light.Light[6].Enabled"], "", NoState, NoExt ), - ( "GL_LIGHT7", GLboolean, ["ctx->Light.Light[7].Enabled"], "", NoState, NoExt ), - ( "GL_LIGHTING", GLboolean, ["ctx->Light.Enabled"], "", NoState, NoExt ), - ( "GL_LIGHT_MODEL_AMBIENT", GLfloatN, - ["ctx->Light.Model.Ambient[0]", - "ctx->Light.Model.Ambient[1]", - "ctx->Light.Model.Ambient[2]", - "ctx->Light.Model.Ambient[3]"], "", NoState, NoExt ), - ( "GL_LIGHT_MODEL_COLOR_CONTROL", GLenum, - ["ctx->Light.Model.ColorControl"], "", NoState, NoExt ), - ( "GL_LIGHT_MODEL_LOCAL_VIEWER", GLboolean, - ["ctx->Light.Model.LocalViewer"], "", NoState, NoExt ), - ( "GL_LIGHT_MODEL_TWO_SIDE", GLboolean, ["ctx->Light.Model.TwoSide"], "", NoState, NoExt ), - ( "GL_LINE_SMOOTH", GLboolean, ["ctx->Line.SmoothFlag"], "", NoState, NoExt ), - ( "GL_LINE_SMOOTH_HINT", GLenum, ["ctx->Hint.LineSmooth"], "", NoState, NoExt ), - ( "GL_LINE_STIPPLE", GLboolean, ["ctx->Line.StippleFlag"], "", NoState, NoExt ), - ( "GL_LINE_STIPPLE_PATTERN", GLint, ["ctx->Line.StipplePattern"], "", NoState, NoExt ), - ( "GL_LINE_STIPPLE_REPEAT", GLint, ["ctx->Line.StippleFactor"], "", NoState, NoExt ), - ( "GL_LINE_WIDTH", GLfloat, ["ctx->Line.Width"], "", NoState, NoExt ), - ( "GL_LINE_WIDTH_GRANULARITY", GLfloat, - ["ctx->Const.LineWidthGranularity"], "", NoState, NoExt ), - ( "GL_LINE_WIDTH_RANGE", GLfloat, - ["ctx->Const.MinLineWidthAA", - "ctx->Const.MaxLineWidthAA"], "", NoState, NoExt ), - ( "GL_ALIASED_LINE_WIDTH_RANGE", GLfloat, - ["ctx->Const.MinLineWidth", - "ctx->Const.MaxLineWidth"], "", NoState, NoExt ), - ( "GL_LIST_BASE", GLint, ["ctx->List.ListBase"], "", NoState, NoExt ), - ( "GL_LIST_INDEX", GLint, ["(ctx->ListState.CurrentList ? ctx->ListState.CurrentList->Name : 0)"], "", NoState, NoExt ), - ( "GL_LIST_MODE", GLenum, ["mode"], - """GLenum mode; - if (!ctx->CompileFlag) - mode = 0; - else if (ctx->ExecuteFlag) - mode = GL_COMPILE_AND_EXECUTE; - else - mode = GL_COMPILE;""", NoState, NoExt ), - ( "GL_INDEX_LOGIC_OP", GLboolean, ["ctx->Color.IndexLogicOpEnabled"], "", NoState, NoExt ), - ( "GL_COLOR_LOGIC_OP", GLboolean, ["ctx->Color.ColorLogicOpEnabled"], "", NoState, NoExt ), - ( "GL_LOGIC_OP_MODE", GLenum, ["ctx->Color.LogicOp"], "", NoState, NoExt ), - ( "GL_MAP1_COLOR_4", GLboolean, ["ctx->Eval.Map1Color4"], "", NoState, NoExt ), - ( "GL_MAP1_GRID_DOMAIN", GLfloat, - ["ctx->Eval.MapGrid1u1", - "ctx->Eval.MapGrid1u2"], "", NoState, NoExt ), - ( "GL_MAP1_GRID_SEGMENTS", GLint, ["ctx->Eval.MapGrid1un"], "", NoState, NoExt ), - ( "GL_MAP1_INDEX", GLboolean, ["ctx->Eval.Map1Index"], "", NoState, NoExt ), - ( "GL_MAP1_NORMAL", GLboolean, ["ctx->Eval.Map1Normal"], "", NoState, NoExt ), - ( "GL_MAP1_TEXTURE_COORD_1", GLboolean, ["ctx->Eval.Map1TextureCoord1"], "", NoState, NoExt ), - ( "GL_MAP1_TEXTURE_COORD_2", GLboolean, ["ctx->Eval.Map1TextureCoord2"], "", NoState, NoExt ), - ( "GL_MAP1_TEXTURE_COORD_3", GLboolean, ["ctx->Eval.Map1TextureCoord3"], "", NoState, NoExt ), - ( "GL_MAP1_TEXTURE_COORD_4", GLboolean, ["ctx->Eval.Map1TextureCoord4"], "", NoState, NoExt ), - ( "GL_MAP1_VERTEX_3", GLboolean, ["ctx->Eval.Map1Vertex3"], "", NoState, NoExt ), - ( "GL_MAP1_VERTEX_4", GLboolean, ["ctx->Eval.Map1Vertex4"], "", NoState, NoExt ), - ( "GL_MAP2_COLOR_4", GLboolean, ["ctx->Eval.Map2Color4"], "", NoState, NoExt ), - ( "GL_MAP2_GRID_DOMAIN", GLfloat, - ["ctx->Eval.MapGrid2u1", - "ctx->Eval.MapGrid2u2", - "ctx->Eval.MapGrid2v1", - "ctx->Eval.MapGrid2v2"], "", NoState, NoExt ), - ( "GL_MAP2_GRID_SEGMENTS", GLint, - ["ctx->Eval.MapGrid2un", - "ctx->Eval.MapGrid2vn"], "", NoState, NoExt ), - ( "GL_MAP2_INDEX", GLboolean, ["ctx->Eval.Map2Index"], "", NoState, NoExt ), - ( "GL_MAP2_NORMAL", GLboolean, ["ctx->Eval.Map2Normal"], "", NoState, NoExt ), - ( "GL_MAP2_TEXTURE_COORD_1", GLboolean, ["ctx->Eval.Map2TextureCoord1"], "", NoState, NoExt ), - ( "GL_MAP2_TEXTURE_COORD_2", GLboolean, ["ctx->Eval.Map2TextureCoord2"], "", NoState, NoExt ), - ( "GL_MAP2_TEXTURE_COORD_3", GLboolean, ["ctx->Eval.Map2TextureCoord3"], "", NoState, NoExt ), - ( "GL_MAP2_TEXTURE_COORD_4", GLboolean, ["ctx->Eval.Map2TextureCoord4"], "", NoState, NoExt ), - ( "GL_MAP2_VERTEX_3", GLboolean, ["ctx->Eval.Map2Vertex3"], "", NoState, NoExt ), - ( "GL_MAP2_VERTEX_4", GLboolean, ["ctx->Eval.Map2Vertex4"], "", NoState, NoExt ), - ( "GL_MAP_COLOR", GLboolean, ["ctx->Pixel.MapColorFlag"], "", NoState, NoExt ), - ( "GL_MAP_STENCIL", GLboolean, ["ctx->Pixel.MapStencilFlag"], "", NoState, NoExt ), - ( "GL_MATRIX_MODE", GLenum, ["ctx->Transform.MatrixMode"], "", NoState, NoExt ), - - ( "GL_MAX_ATTRIB_STACK_DEPTH", GLint, ["MAX_ATTRIB_STACK_DEPTH"], "", NoState, NoExt ), - ( "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", GLint, ["MAX_CLIENT_ATTRIB_STACK_DEPTH"], "", NoState, NoExt ), - ( "GL_MAX_CLIP_PLANES", GLint, ["ctx->Const.MaxClipPlanes"], "", NoState, NoExt ), - ( "GL_MAX_ELEMENTS_VERTICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", NoState, NoExt ), - ( "GL_MAX_ELEMENTS_INDICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", NoState, NoExt ), - ( "GL_MAX_EVAL_ORDER", GLint, ["MAX_EVAL_ORDER"], "", NoState, NoExt ), - ( "GL_MAX_LIGHTS", GLint, ["ctx->Const.MaxLights"], "", NoState, NoExt ), - ( "GL_MAX_LIST_NESTING", GLint, ["MAX_LIST_NESTING"], "", NoState, NoExt ), - ( "GL_MAX_MODELVIEW_STACK_DEPTH", GLint, ["MAX_MODELVIEW_STACK_DEPTH"], "", NoState, NoExt ), - ( "GL_MAX_NAME_STACK_DEPTH", GLint, ["MAX_NAME_STACK_DEPTH"], "", NoState, NoExt ), - ( "GL_MAX_PIXEL_MAP_TABLE", GLint, ["MAX_PIXEL_MAP_TABLE"], "", NoState, NoExt ), - ( "GL_MAX_PROJECTION_STACK_DEPTH", GLint, ["MAX_PROJECTION_STACK_DEPTH"], "", NoState, NoExt ), - ( "GL_MAX_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.MaxTextureLevels - 1)"], "", NoState, NoExt ), - ( "GL_MAX_3D_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.Max3DTextureLevels - 1)"], "", NoState, NoExt ), - ( "GL_MAX_TEXTURE_STACK_DEPTH", GLint, ["MAX_TEXTURE_STACK_DEPTH"], "", NoState, NoExt ), - ( "GL_MAX_VIEWPORT_DIMS", GLint, - ["ctx->Const.MaxViewportWidth", "ctx->Const.MaxViewportHeight"], - "", NoState, NoExt ), - ( "GL_MODELVIEW_MATRIX", GLfloat, - [ "matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", - "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", - "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", - "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], - "const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;", NoState, NoExt ), - ( "GL_MODELVIEW_STACK_DEPTH", GLint, ["ctx->ModelviewMatrixStack.Depth + 1"], "", NoState, NoExt ), - ( "GL_NAME_STACK_DEPTH", GLint, ["ctx->Select.NameStackDepth"], "", NoState, NoExt ), - ( "GL_NORMALIZE", GLboolean, ["ctx->Transform.Normalize"], "", NoState, NoExt ), - ( "GL_PACK_ALIGNMENT", GLint, ["ctx->Pack.Alignment"], "", NoState, NoExt ), - ( "GL_PACK_LSB_FIRST", GLboolean, ["ctx->Pack.LsbFirst"], "", NoState, NoExt ), - ( "GL_PACK_ROW_LENGTH", GLint, ["ctx->Pack.RowLength"], "", NoState, NoExt ), - ( "GL_PACK_SKIP_PIXELS", GLint, ["ctx->Pack.SkipPixels"], "", NoState, NoExt ), - ( "GL_PACK_SKIP_ROWS", GLint, ["ctx->Pack.SkipRows"], "", NoState, NoExt ), - ( "GL_PACK_SWAP_BYTES", GLboolean, ["ctx->Pack.SwapBytes"], "", NoState, NoExt ), - ( "GL_PACK_SKIP_IMAGES_EXT", GLint, ["ctx->Pack.SkipImages"], "", NoState, NoExt ), - ( "GL_PACK_IMAGE_HEIGHT_EXT", GLint, ["ctx->Pack.ImageHeight"], "", NoState, NoExt ), - ( "GL_PACK_INVERT_MESA", GLboolean, ["ctx->Pack.Invert"], "", NoState, NoExt ), - ( "GL_PERSPECTIVE_CORRECTION_HINT", GLenum, - ["ctx->Hint.PerspectiveCorrection"], "", NoState, NoExt ), - ( "GL_PIXEL_MAP_A_TO_A_SIZE", GLint, ["ctx->PixelMaps.AtoA.Size"], "", NoState, NoExt ), - ( "GL_PIXEL_MAP_B_TO_B_SIZE", GLint, ["ctx->PixelMaps.BtoB.Size"], "", NoState, NoExt ), - ( "GL_PIXEL_MAP_G_TO_G_SIZE", GLint, ["ctx->PixelMaps.GtoG.Size"], "", NoState, NoExt ), - ( "GL_PIXEL_MAP_I_TO_A_SIZE", GLint, ["ctx->PixelMaps.ItoA.Size"], "", NoState, NoExt ), - ( "GL_PIXEL_MAP_I_TO_B_SIZE", GLint, ["ctx->PixelMaps.ItoB.Size"], "", NoState, NoExt ), - ( "GL_PIXEL_MAP_I_TO_G_SIZE", GLint, ["ctx->PixelMaps.ItoG.Size"], "", NoState, NoExt ), - ( "GL_PIXEL_MAP_I_TO_I_SIZE", GLint, ["ctx->PixelMaps.ItoI.Size"], "", NoState, NoExt ), - ( "GL_PIXEL_MAP_I_TO_R_SIZE", GLint, ["ctx->PixelMaps.ItoR.Size"], "", NoState, NoExt ), - ( "GL_PIXEL_MAP_R_TO_R_SIZE", GLint, ["ctx->PixelMaps.RtoR.Size"], "", NoState, NoExt ), - ( "GL_PIXEL_MAP_S_TO_S_SIZE", GLint, ["ctx->PixelMaps.StoS.Size"], "", NoState, NoExt ), - ( "GL_POINT_SIZE", GLfloat, ["ctx->Point.Size"], "", NoState, NoExt ), - ( "GL_POINT_SIZE_GRANULARITY", GLfloat, - ["ctx->Const.PointSizeGranularity"], "", NoState, NoExt ), - ( "GL_POINT_SIZE_RANGE", GLfloat, - ["ctx->Const.MinPointSizeAA", - "ctx->Const.MaxPointSizeAA"], "", NoState, NoExt ), - ( "GL_ALIASED_POINT_SIZE_RANGE", GLfloat, - ["ctx->Const.MinPointSize", - "ctx->Const.MaxPointSize"], "", NoState, NoExt ), - ( "GL_POINT_SMOOTH", GLboolean, ["ctx->Point.SmoothFlag"], "", NoState, NoExt ), - ( "GL_POINT_SMOOTH_HINT", GLenum, ["ctx->Hint.PointSmooth"], "", NoState, NoExt ), - ( "GL_POINT_SIZE_MIN_EXT", GLfloat, ["ctx->Point.MinSize"], "", NoState, NoExt ), - ( "GL_POINT_SIZE_MAX_EXT", GLfloat, ["ctx->Point.MaxSize"], "", NoState, NoExt ), - ( "GL_POINT_FADE_THRESHOLD_SIZE_EXT", GLfloat, - ["ctx->Point.Threshold"], "", NoState, NoExt ), - ( "GL_DISTANCE_ATTENUATION_EXT", GLfloat, - ["ctx->Point.Params[0]", - "ctx->Point.Params[1]", - "ctx->Point.Params[2]"], "", NoState, NoExt ), - ( "GL_POLYGON_MODE", GLenum, - ["ctx->Polygon.FrontMode", - "ctx->Polygon.BackMode"], "", NoState, NoExt ), - ( "GL_POLYGON_OFFSET_BIAS_EXT", GLfloat, ["ctx->Polygon.OffsetUnits"], "", NoState, NoExt ), - ( "GL_POLYGON_OFFSET_FACTOR", GLfloat, ["ctx->Polygon.OffsetFactor "], "", NoState, NoExt ), - ( "GL_POLYGON_OFFSET_UNITS", GLfloat, ["ctx->Polygon.OffsetUnits "], "", NoState, NoExt ), - ( "GL_POLYGON_OFFSET_POINT", GLboolean, ["ctx->Polygon.OffsetPoint"], "", NoState, NoExt ), - ( "GL_POLYGON_OFFSET_LINE", GLboolean, ["ctx->Polygon.OffsetLine"], "", NoState, NoExt ), - ( "GL_POLYGON_OFFSET_FILL", GLboolean, ["ctx->Polygon.OffsetFill"], "", NoState, NoExt ), - ( "GL_POLYGON_SMOOTH", GLboolean, ["ctx->Polygon.SmoothFlag"], "", NoState, NoExt ), - ( "GL_POLYGON_SMOOTH_HINT", GLenum, ["ctx->Hint.PolygonSmooth"], "", NoState, NoExt ), - ( "GL_POLYGON_STIPPLE", GLboolean, ["ctx->Polygon.StippleFlag"], "", NoState, NoExt ), - ( "GL_PROJECTION_MATRIX", GLfloat, - [ "matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", - "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", - "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", - "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], - "const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;", NoState, NoExt ), - ( "GL_PROJECTION_STACK_DEPTH", GLint, - ["ctx->ProjectionMatrixStack.Depth + 1"], "", NoState, NoExt ), - ( "GL_READ_BUFFER", GLenum, ["ctx->ReadBuffer->ColorReadBuffer"], "", NoState, NoExt ), - ( "GL_RED_BIAS", GLfloat, ["ctx->Pixel.RedBias"], "", NoState, NoExt ), - ( "GL_RED_BITS", GLint, ["ctx->DrawBuffer->Visual.redBits"], "", "_NEW_BUFFERS", NoExt ), - ( "GL_RED_SCALE", GLfloat, ["ctx->Pixel.RedScale"], "", NoState, NoExt ), - ( "GL_RENDER_MODE", GLenum, ["ctx->RenderMode"], "", NoState, NoExt ), - ( "GL_RESCALE_NORMAL", GLboolean, - ["ctx->Transform.RescaleNormals"], "", NoState, NoExt ), - ( "GL_RGBA_MODE", GLboolean, ["GL_TRUE"], - "", NoState, NoExt ), - ( "GL_SCISSOR_BOX", GLint, - ["ctx->Scissor.X", - "ctx->Scissor.Y", - "ctx->Scissor.Width", - "ctx->Scissor.Height"], "", NoState, NoExt ), - ( "GL_SCISSOR_TEST", GLboolean, ["ctx->Scissor.Enabled"], "", NoState, NoExt ), - ( "GL_SELECTION_BUFFER_SIZE", GLint, ["ctx->Select.BufferSize"], "", NoState, NoExt ), - ( "GL_SHADE_MODEL", GLenum, ["ctx->Light.ShadeModel"], "", NoState, NoExt ), - ( "GL_SHARED_TEXTURE_PALETTE_EXT", GLboolean, - ["ctx->Texture.SharedPalette"], "", NoState, NoExt ), - ( "GL_STENCIL_BITS", GLint, ["ctx->DrawBuffer->Visual.stencilBits"], "", NoState, NoExt ), - ( "GL_STENCIL_CLEAR_VALUE", GLint, ["ctx->Stencil.Clear"], "", NoState, NoExt ), - ( "GL_STENCIL_FAIL", GLenum, - ["ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ), - ( "GL_STENCIL_FUNC", GLenum, - ["ctx->Stencil.Function[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ), - ( "GL_STENCIL_PASS_DEPTH_FAIL", GLenum, - ["ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ), - ( "GL_STENCIL_PASS_DEPTH_PASS", GLenum, - ["ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ), - ( "GL_STENCIL_REF", GLint, - ["ctx->Stencil.Ref[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ), - ( "GL_STENCIL_TEST", GLboolean, ["ctx->Stencil.Enabled"], "", NoState, NoExt ), - ( "GL_STENCIL_VALUE_MASK", GLint, - ["ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ), - ( "GL_STENCIL_WRITEMASK", GLint, - ["ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]"], "", NoState, NoExt ), - ( "GL_STEREO", GLboolean, ["ctx->DrawBuffer->Visual.stereoMode"], - "", NoState, NoExt ), - ( "GL_SUBPIXEL_BITS", GLint, ["ctx->Const.SubPixelBits"], "", NoState, NoExt ), - ( "GL_TEXTURE_1D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_1D)"], "", NoState, NoExt ), - ( "GL_TEXTURE_2D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D)"], "", NoState, NoExt ), - ( "GL_TEXTURE_3D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_3D)"], "", NoState, NoExt ), - ( "GL_TEXTURE_1D_ARRAY_EXT", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_1D_ARRAY_EXT)"], "", NoState, ["MESA_texture_array"] ), - ( "GL_TEXTURE_2D_ARRAY_EXT", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D_ARRAY_EXT)"], "", NoState, ["MESA_texture_array"] ), - ( "GL_TEXTURE_BINDING_1D", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_INDEX]->Name"], "", NoState, NoExt ), - ( "GL_TEXTURE_BINDING_2D", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name"], "", NoState, NoExt ), - ( "GL_TEXTURE_BINDING_3D", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name"], "", NoState, NoExt ), - ( "GL_TEXTURE_BINDING_1D_ARRAY_EXT", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_1D_ARRAY_INDEX]->Name"], "", NoState, ["MESA_texture_array"] ), - ( "GL_TEXTURE_BINDING_2D_ARRAY_EXT", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_ARRAY_INDEX]->Name"], "", NoState, ["MESA_texture_array"] ), - ( "GL_MAX_ARRAY_TEXTURE_LAYERS_EXT", GLint, - ["ctx->Const.MaxArrayTextureLayers"], "", NoState, ["MESA_texture_array"] ), - ( "GL_TEXTURE_GEN_S", GLboolean, - ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)"], "", NoState, NoExt ), - ( "GL_TEXTURE_GEN_T", GLboolean, - ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0)"], "", NoState, NoExt ), - ( "GL_TEXTURE_GEN_R", GLboolean, - ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0)"], "", NoState, NoExt ), - ( "GL_TEXTURE_GEN_Q", GLboolean, - ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & Q_BIT) ? 1 : 0)"], "", NoState, NoExt ), - ( "GL_TEXTURE_MATRIX", GLfloat, - ["matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", - "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", - "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", - "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], - """const GLfloat *matrix; - const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGet(texture matrix %u)", - unit); - return; - } - matrix = ctx->TextureMatrixStack[unit].Top->m;""", - NoState, NoExt ), - ( "GL_TEXTURE_STACK_DEPTH", GLint, - ["ctx->TextureMatrixStack[unit].Depth + 1"], - """const GLuint unit = ctx->Texture.CurrentUnit; - if (unit >= ctx->Const.MaxTextureCoordUnits) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGet(texture stack depth, unit %u)", unit); - return; - }""", - NoState, NoExt ), - ( "GL_UNPACK_ALIGNMENT", GLint, ["ctx->Unpack.Alignment"], "", NoState, NoExt ), - ( "GL_UNPACK_LSB_FIRST", GLboolean, ["ctx->Unpack.LsbFirst"], "", NoState, NoExt ), - ( "GL_UNPACK_ROW_LENGTH", GLint, ["ctx->Unpack.RowLength"], "", NoState, NoExt ), - ( "GL_UNPACK_SKIP_PIXELS", GLint, ["ctx->Unpack.SkipPixels"], "", NoState, NoExt ), - ( "GL_UNPACK_SKIP_ROWS", GLint, ["ctx->Unpack.SkipRows"], "", NoState, NoExt ), - ( "GL_UNPACK_SWAP_BYTES", GLboolean, ["ctx->Unpack.SwapBytes"], "", NoState, NoExt ), - ( "GL_UNPACK_SKIP_IMAGES_EXT", GLint, ["ctx->Unpack.SkipImages"], "", NoState, NoExt ), - ( "GL_UNPACK_IMAGE_HEIGHT_EXT", GLint, ["ctx->Unpack.ImageHeight"], "", NoState, NoExt ), - ( "GL_UNPACK_CLIENT_STORAGE_APPLE", GLboolean, ["ctx->Unpack.ClientStorage"], "", NoState, NoExt ), - ( "GL_VIEWPORT", GLint, [ "ctx->Viewport.X", "ctx->Viewport.Y", - "ctx->Viewport.Width", "ctx->Viewport.Height" ], "", NoState, NoExt ), - ( "GL_ZOOM_X", GLfloat, ["ctx->Pixel.ZoomX"], "", NoState, NoExt ), - ( "GL_ZOOM_Y", GLfloat, ["ctx->Pixel.ZoomY"], "", NoState, NoExt ), - - # Vertex arrays - ( "GL_VERTEX_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Vertex.Enabled"], "", NoState, NoExt ), - ( "GL_VERTEX_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Vertex.Size"], "", NoState, NoExt ), - ( "GL_VERTEX_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Vertex.Type"], "", NoState, NoExt ), - ( "GL_VERTEX_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Vertex.Stride"], "", NoState, NoExt ), - ( "GL_VERTEX_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ), - ( "GL_NORMAL_ARRAY", GLenum, ["ctx->Array.ArrayObj->Normal.Enabled"], "", NoState, NoExt ), - ( "GL_NORMAL_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Normal.Type"], "", NoState, NoExt ), - ( "GL_NORMAL_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Normal.Stride"], "", NoState, NoExt ), - ( "GL_NORMAL_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ), - ( "GL_COLOR_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Color.Enabled"], "", NoState, NoExt ), - ( "GL_COLOR_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Color.Size"], "", NoState, NoExt ), - ( "GL_COLOR_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Color.Type"], "", NoState, NoExt ), - ( "GL_COLOR_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Color.Stride"], "", NoState, NoExt ), - ( "GL_COLOR_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ), - ( "GL_INDEX_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Index.Enabled"], "", NoState, NoExt ), - ( "GL_INDEX_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Index.Type"], "", NoState, NoExt ), - ( "GL_INDEX_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Index.Stride"], "", NoState, NoExt ), - ( "GL_INDEX_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ), - ( "GL_TEXTURE_COORD_ARRAY", GLboolean, - ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled"], "", NoState, NoExt ), - ( "GL_TEXTURE_COORD_ARRAY_SIZE", GLint, - ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size"], "", NoState, NoExt ), - ( "GL_TEXTURE_COORD_ARRAY_TYPE", GLenum, - ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Type"], "", NoState, NoExt ), - ( "GL_TEXTURE_COORD_ARRAY_STRIDE", GLint, - ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride"], "", NoState, NoExt ), - ( "GL_TEXTURE_COORD_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ), - ( "GL_EDGE_FLAG_ARRAY", GLboolean, ["ctx->Array.ArrayObj->EdgeFlag.Enabled"], "", NoState, NoExt ), - ( "GL_EDGE_FLAG_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->EdgeFlag.Stride"], "", NoState, NoExt ), - ( "GL_EDGE_FLAG_ARRAY_COUNT_EXT", GLint, ["0"], "", NoState, NoExt ), - - # GL_ARB_multitexture - ( "GL_MAX_TEXTURE_UNITS_ARB", GLint, - ["ctx->Const.MaxTextureUnits"], "", NoState, ["ARB_multitexture"] ), - ( "GL_ACTIVE_TEXTURE_ARB", GLint, - [ "GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit"], "", NoState, ["ARB_multitexture"] ), - ( "GL_CLIENT_ACTIVE_TEXTURE_ARB", GLint, - ["GL_TEXTURE0_ARB + ctx->Array.ActiveTexture"], "", NoState, ["ARB_multitexture"] ), - - # GL_ARB_texture_cube_map - ( "GL_TEXTURE_CUBE_MAP_ARB", GLboolean, - ["_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB)"], "", NoState, ["ARB_texture_cube_map"] ), - ( "GL_TEXTURE_BINDING_CUBE_MAP_ARB", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_CUBE_INDEX]->Name"], - "", NoState, ["ARB_texture_cube_map"] ), - ( "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB", GLint, - ["(1 << (ctx->Const.MaxCubeTextureLevels - 1))"], - "", NoState, ["ARB_texture_cube_map"]), - - # GL_ARB_texture_compression */ - ( "GL_TEXTURE_COMPRESSION_HINT_ARB", GLint, - ["ctx->Hint.TextureCompression"], "", NoState, NoExt ), - ( "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB", GLint, - ["_mesa_get_compressed_formats(ctx, NULL, GL_FALSE)"], - "", NoState, NoExt ), - ( "GL_COMPRESSED_TEXTURE_FORMATS_ARB", GLenum, - [], - """GLint formats[100]; - GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE); - ASSERT(n <= 100); - for (i = 0; i < n; i++) - params[i] = CONVERSION(formats[i]);""", - NoState, NoExt ), - - # GL_EXT_compiled_vertex_array - ( "GL_ARRAY_ELEMENT_LOCK_FIRST_EXT", GLint, ["ctx->Array.LockFirst"], - "", NoState, ["EXT_compiled_vertex_array"] ), - ( "GL_ARRAY_ELEMENT_LOCK_COUNT_EXT", GLint, ["ctx->Array.LockCount"], - "", NoState, ["EXT_compiled_vertex_array"] ), - - # GL_ARB_transpose_matrix - ( "GL_TRANSPOSE_COLOR_MATRIX_ARB", GLfloat, - ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]", - "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]", - "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]", - "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"], - "const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;", - NoState, NoExt ), - ( "GL_TRANSPOSE_MODELVIEW_MATRIX_ARB", GLfloat, - ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]", - "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]", - "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]", - "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"], - "const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;", - NoState, NoExt ), - ( "GL_TRANSPOSE_PROJECTION_MATRIX_ARB", GLfloat, - ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]", - "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]", - "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]", - "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"], - "const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;", - NoState, NoExt ), - ( "GL_TRANSPOSE_TEXTURE_MATRIX_ARB", GLfloat, - ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]", - "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]", - "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]", - "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"], - "const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;", - NoState, NoExt ), - - # GL_SGI_color_matrix (also in 1.2 imaging) - ( "GL_COLOR_MATRIX_SGI", GLfloat, - ["matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", - "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", - "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", - "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], - "const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;", - NoState, NoExt ), - ( "GL_COLOR_MATRIX_STACK_DEPTH_SGI", GLint, - ["ctx->ColorMatrixStack.Depth + 1"], "", NoState, NoExt ), - ( "GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI", GLint, - ["MAX_COLOR_STACK_DEPTH"], "", NoState, NoExt ), - ( "GL_POST_COLOR_MATRIX_RED_SCALE_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixScale[0]"], "", NoState, NoExt ), - ( "GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixScale[1]"], "", NoState, NoExt ), - ( "GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixScale[2]"], "", NoState, NoExt ), - ( "GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixScale[3]"], "", NoState, NoExt ), - ( "GL_POST_COLOR_MATRIX_RED_BIAS_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixBias[0]"], "", NoState, NoExt ), - ( "GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixBias[1]"], "", NoState, NoExt ), - ( "GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixBias[2]"], "", NoState, NoExt ), - ( "GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI", GLfloat, - ["ctx->Pixel.PostColorMatrixBias[3]"], "", NoState, NoExt ), - - # GL_EXT_convolution (also in 1.2 imaging) - ( "GL_CONVOLUTION_1D_EXT", GLboolean, - ["ctx->Pixel.Convolution1DEnabled"], "", NoState, ["EXT_convolution"] ), - ( "GL_CONVOLUTION_2D_EXT", GLboolean, - ["ctx->Pixel.Convolution2DEnabled"], "", NoState, ["EXT_convolution"] ), - ( "GL_SEPARABLE_2D_EXT", GLboolean, - ["ctx->Pixel.Separable2DEnabled"], "", NoState, ["EXT_convolution"] ), - ( "GL_POST_CONVOLUTION_RED_SCALE_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionScale[0]"], "", NoState, ["EXT_convolution"] ), - ( "GL_POST_CONVOLUTION_GREEN_SCALE_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionScale[1]"], "", NoState, ["EXT_convolution"] ), - ( "GL_POST_CONVOLUTION_BLUE_SCALE_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionScale[2]"], "", NoState, ["EXT_convolution"] ), - ( "GL_POST_CONVOLUTION_ALPHA_SCALE_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionScale[3]"], "", NoState, ["EXT_convolution"] ), - ( "GL_POST_CONVOLUTION_RED_BIAS_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionBias[0]"], "", NoState, ["EXT_convolution"] ), - ( "GL_POST_CONVOLUTION_GREEN_BIAS_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionBias[1]"], "", NoState, ["EXT_convolution"] ), - ( "GL_POST_CONVOLUTION_BLUE_BIAS_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionBias[2]"], "", NoState, ["EXT_convolution"] ), - ( "GL_POST_CONVOLUTION_ALPHA_BIAS_EXT", GLfloat, - ["ctx->Pixel.PostConvolutionBias[3]"], "", NoState, ["EXT_convolution"] ), - - # GL_EXT_histogram / GL_ARB_imaging - ( "GL_HISTOGRAM", GLboolean, - [ "ctx->Pixel.HistogramEnabled" ], "", NoState, ["EXT_histogram"] ), - ( "GL_MINMAX", GLboolean, - [ "ctx->Pixel.MinMaxEnabled" ], "", NoState, ["EXT_histogram"] ), - - # GL_SGI_color_table / GL_ARB_imaging - ( "GL_COLOR_TABLE_SGI", GLboolean, - ["ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION]"], "", - NoState, ["SGI_color_table"] ), - ( "GL_POST_CONVOLUTION_COLOR_TABLE_SGI", GLboolean, - ["ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION]"], "", - NoState, ["SGI_color_table"] ), - ( "GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI", GLboolean, - ["ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX]"], "", - NoState, ["SGI_color_table"] ), - - # GL_SGI_texture_color_table - ( "GL_TEXTURE_COLOR_TABLE_SGI", GLboolean, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled"], - "", NoState, ["SGI_texture_color_table"] ), - - # GL_EXT_secondary_color - ( "GL_COLOR_SUM_EXT", GLboolean, - ["ctx->Fog.ColorSumEnabled"], "", NoState, - ["EXT_secondary_color", "ARB_vertex_program"] ), - ( "GL_CURRENT_SECONDARY_COLOR_EXT", GLfloatN, - ["ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]", - "ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]", - "ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]", - "ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]"], - "", FlushCurrent, ["EXT_secondary_color"] ), - ( "GL_SECONDARY_COLOR_ARRAY_EXT", GLboolean, - ["ctx->Array.ArrayObj->SecondaryColor.Enabled"], - "", NoState, ["EXT_secondary_color"] ), - ( "GL_SECONDARY_COLOR_ARRAY_TYPE_EXT", GLenum, - ["ctx->Array.ArrayObj->SecondaryColor.Type"], - "", NoState, ["EXT_secondary_color"] ), - ( "GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT", GLint, - ["ctx->Array.ArrayObj->SecondaryColor.Stride"], - "", NoState, ["EXT_secondary_color"] ), - ( "GL_SECONDARY_COLOR_ARRAY_SIZE_EXT", GLint, - ["ctx->Array.ArrayObj->SecondaryColor.Size"], - "", NoState, ["EXT_secondary_color"] ), - - # GL_EXT_fog_coord - ( "GL_CURRENT_FOG_COORDINATE_EXT", GLfloat, - ["ctx->Current.Attrib[VERT_ATTRIB_FOG][0]"], - "", FlushCurrent, ["EXT_fog_coord"] ), - ( "GL_FOG_COORDINATE_ARRAY_EXT", GLboolean, - ["ctx->Array.ArrayObj->FogCoord.Enabled"], - "", NoState, ["EXT_fog_coord"] ), - ( "GL_FOG_COORDINATE_ARRAY_TYPE_EXT", GLenum, - ["ctx->Array.ArrayObj->FogCoord.Type"], - "", NoState, ["EXT_fog_coord"] ), - ( "GL_FOG_COORDINATE_ARRAY_STRIDE_EXT", GLint, - ["ctx->Array.ArrayObj->FogCoord.Stride"], - "", NoState, ["EXT_fog_coord"] ), - ( "GL_FOG_COORDINATE_SOURCE_EXT", GLenum, - ["ctx->Fog.FogCoordinateSource"], - "", NoState, ["EXT_fog_coord"] ), - - # GL_EXT_texture_lod_bias - ( "GL_MAX_TEXTURE_LOD_BIAS_EXT", GLfloat, - ["ctx->Const.MaxTextureLodBias"], "", NoState, ["EXT_texture_lod_bias"]), - - # GL_EXT_texture_filter_anisotropic - ( "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT", GLfloat, - ["ctx->Const.MaxTextureMaxAnisotropy"], - "", NoState, ["EXT_texture_filter_anisotropic"]), - - # GL_ARB_multisample - ( "GL_MULTISAMPLE_ARB", GLboolean, - ["ctx->Multisample.Enabled"], "", NoState, NoExt ), - ( "GL_SAMPLE_ALPHA_TO_COVERAGE_ARB", GLboolean, - ["ctx->Multisample.SampleAlphaToCoverage"], "", NoState, NoExt ), - ( "GL_SAMPLE_ALPHA_TO_ONE_ARB", GLboolean, - ["ctx->Multisample.SampleAlphaToOne"], "", NoState, NoExt ), - ( "GL_SAMPLE_COVERAGE_ARB", GLboolean, - ["ctx->Multisample.SampleCoverage"], "", NoState, NoExt ), - ( "GL_SAMPLE_COVERAGE_VALUE_ARB", GLfloat, - ["ctx->Multisample.SampleCoverageValue"], "", NoState, NoExt ), - ( "GL_SAMPLE_COVERAGE_INVERT_ARB", GLboolean, - ["ctx->Multisample.SampleCoverageInvert"], "", NoState, NoExt ), - ( "GL_SAMPLE_BUFFERS_ARB", GLint, - ["ctx->DrawBuffer->Visual.sampleBuffers"], "", NoState, NoExt ), - ( "GL_SAMPLES_ARB", GLint, - ["ctx->DrawBuffer->Visual.samples"], "", NoState, NoExt ), - - # GL_IBM_rasterpos_clip - ( "GL_RASTER_POSITION_UNCLIPPED_IBM", GLboolean, - ["ctx->Transform.RasterPositionUnclipped"], - "", NoState, ["IBM_rasterpos_clip"] ), - - # GL_NV_point_sprite - ( "GL_POINT_SPRITE_NV", GLboolean, ["ctx->Point.PointSprite"], # == GL_POINT_SPRITE_ARB - "", NoState, ["NV_point_sprite", "ARB_point_sprite"] ), - ( "GL_POINT_SPRITE_R_MODE_NV", GLenum, ["ctx->Point.SpriteRMode"], - "", NoState, ["NV_point_sprite"] ), - ( "GL_POINT_SPRITE_COORD_ORIGIN", GLenum, ["ctx->Point.SpriteOrigin"], - "", NoState, ["NV_point_sprite", "ARB_point_sprite"] ), - - # GL_SGIS_generate_mipmap - ( "GL_GENERATE_MIPMAP_HINT_SGIS", GLenum, ["ctx->Hint.GenerateMipmap"], - "", NoState, ["SGIS_generate_mipmap"] ), - - # GL_NV_vertex_program - ( "GL_VERTEX_PROGRAM_BINDING_NV", GLint, - ["(ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0)"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY0_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[0].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY1_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[1].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY2_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[2].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY3_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[3].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY4_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[4].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY5_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[5].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY6_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[6].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY7_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[7].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY8_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[8].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY9_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[9].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY10_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[10].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY11_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[11].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY12_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[12].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY13_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[13].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY14_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[14].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_VERTEX_ATTRIB_ARRAY15_NV", GLboolean, - ["ctx->Array.ArrayObj->VertexAttrib[15].Enabled"], - "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB0_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[0]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB1_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[1]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB2_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[2]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB3_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[3]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB4_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[4]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB5_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[5]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB6_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[6]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB7_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[7]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB8_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[8]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB9_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[9]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB10_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[10]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB11_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[11]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB12_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[12]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB13_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[13]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB14_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[14]"], "", NoState, ["NV_vertex_program"] ), - ( "GL_MAP1_VERTEX_ATTRIB15_4_NV", GLboolean, - ["ctx->Eval.Map1Attrib[15]"], "", NoState, ["NV_vertex_program"] ), - - # GL_NV_fragment_program - ( "GL_FRAGMENT_PROGRAM_NV", GLboolean, - ["ctx->FragmentProgram.Enabled"], "", NoState, ["NV_fragment_program"] ), - ( "GL_FRAGMENT_PROGRAM_BINDING_NV", GLint, - ["ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0"], - "", NoState, ["NV_fragment_program"] ), - ( "GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV", GLint, - ["MAX_NV_FRAGMENT_PROGRAM_PARAMS"], "", NoState, ["NV_fragment_program"] ), - - # GL_NV_texture_rectangle - ( "GL_TEXTURE_RECTANGLE_NV", GLboolean, - ["_mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV)"], "", NoState, ["NV_texture_rectangle"] ), - ( "GL_TEXTURE_BINDING_RECTANGLE_NV", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_RECT_INDEX]->Name"], - "", NoState, ["NV_texture_rectangle"] ), - ( "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV", GLint, - ["ctx->Const.MaxTextureRectSize"], "", NoState, ["NV_texture_rectangle"] ), - - # GL_EXT_stencil_two_side - ( "GL_STENCIL_TEST_TWO_SIDE_EXT", GLboolean, - ["ctx->Stencil.TestTwoSide"], "", NoState, ["EXT_stencil_two_side"] ), - ( "GL_ACTIVE_STENCIL_FACE_EXT", GLenum, - ["ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT"], - "", NoState, ["EXT_stencil_two_side"] ), - - # GL_NV_light_max_exponent - ( "GL_MAX_SHININESS_NV", GLfloat, - ["ctx->Const.MaxShininess"], "", NoState, ["NV_light_max_exponent"] ), - ( "GL_MAX_SPOT_EXPONENT_NV", GLfloat, - ["ctx->Const.MaxSpotExponent"], "", NoState, ["NV_light_max_exponent"] ), - - # GL_ARB_vertex_buffer_object - ( "GL_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayBufferObj->Name"], "", NoState, NoExt ), - ( "GL_VERTEX_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->Vertex.BufferObj->Name"], "", NoState, NoExt ), - ( "GL_NORMAL_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->Normal.BufferObj->Name"], "", NoState, NoExt ), - ( "GL_COLOR_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->Color.BufferObj->Name"], "", NoState, NoExt ), - ( "GL_INDEX_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->Index.BufferObj->Name"], "", NoState, NoExt ), - ( "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name"], - "", NoState, NoExt ), - ( "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->EdgeFlag.BufferObj->Name"], "", NoState, NoExt ), - ( "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->SecondaryColor.BufferObj->Name"], - "", NoState, NoExt ), - ( "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->FogCoord.BufferObj->Name"], - "", NoState, NoExt ), - # GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported - ( "GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ElementArrayBufferObj->Name"], - "", NoState, NoExt ), - - # GL_EXT_pixel_buffer_object - ( "GL_PIXEL_PACK_BUFFER_BINDING_EXT", GLint, - ["ctx->Pack.BufferObj->Name"], "", NoState, ["EXT_pixel_buffer_object"] ), - ( "GL_PIXEL_UNPACK_BUFFER_BINDING_EXT", GLint, - ["ctx->Unpack.BufferObj->Name"], "", NoState, ["EXT_pixel_buffer_object"] ), - - # GL_ARB_vertex_program - ( "GL_VERTEX_PROGRAM_ARB", GLboolean, # == GL_VERTEX_PROGRAM_NV - ["ctx->VertexProgram.Enabled"], "", NoState, - ["ARB_vertex_program", "NV_vertex_program"] ), - ( "GL_VERTEX_PROGRAM_POINT_SIZE_ARB", GLboolean, # == GL_VERTEX_PROGRAM_POINT_SIZE_NV - ["ctx->VertexProgram.PointSizeEnabled"], "", NoState, - ["ARB_vertex_program", "NV_vertex_program"] ), - ( "GL_VERTEX_PROGRAM_TWO_SIDE_ARB", GLboolean, # == GL_VERTEX_PROGRAM_TWO_SIDE_NV - ["ctx->VertexProgram.TwoSideEnabled"], "", NoState, - ["ARB_vertex_program", "NV_vertex_program"] ), - ( "GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB", GLint, # == GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV - ["ctx->Const.MaxProgramMatrixStackDepth"], "", NoState, - ["ARB_vertex_program", "ARB_fragment_program", "NV_vertex_program"] ), - ( "GL_MAX_PROGRAM_MATRICES_ARB", GLint, # == GL_MAX_TRACK_MATRICES_NV - ["ctx->Const.MaxProgramMatrices"], "", NoState, - ["ARB_vertex_program", "ARB_fragment_program", "NV_vertex_program"] ), - ( "GL_CURRENT_MATRIX_STACK_DEPTH_ARB", GLboolean, # == GL_CURRENT_MATRIX_STACK_DEPTH_NV - ["ctx->CurrentStack->Depth + 1"], "", NoState, - ["ARB_vertex_program", "ARB_fragment_program", "NV_vertex_program"] ), - ( "GL_CURRENT_MATRIX_ARB", GLfloat, # == GL_CURRENT_MATRIX_NV - ["matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", - "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", - "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", - "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], - "const GLfloat *matrix = ctx->CurrentStack->Top->m;", NoState, - ["ARB_vertex_program", "ARB_fragment_program", "NV_fragment_program"] ), - ( "GL_TRANSPOSE_CURRENT_MATRIX_ARB", GLfloat, - ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]", - "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]", - "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]", - "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"], - "const GLfloat *matrix = ctx->CurrentStack->Top->m;", NoState, - ["ARB_vertex_program", "ARB_fragment_program"] ), - ( "GL_MAX_VERTEX_ATTRIBS_ARB", GLint, - ["ctx->Const.VertexProgram.MaxAttribs"], "", NoState, ["ARB_vertex_program"] ), - ( "GL_PROGRAM_ERROR_POSITION_ARB", GLint, # == GL_PROGRAM_ERROR_POSITION_NV - ["ctx->Program.ErrorPos"], "", NoState, ["NV_vertex_program", - "ARB_vertex_program", "NV_fragment_program", "ARB_fragment_program"] ), - - # GL_ARB_fragment_program - ( "GL_FRAGMENT_PROGRAM_ARB", GLboolean, - ["ctx->FragmentProgram.Enabled"], "", NoState, ["ARB_fragment_program"] ), - ( "GL_MAX_TEXTURE_COORDS_ARB", GLint, # == GL_MAX_TEXTURE_COORDS_NV - ["ctx->Const.MaxTextureCoordUnits"], "", NoState, - ["ARB_fragment_program", "NV_fragment_program"] ), - ( "GL_MAX_TEXTURE_IMAGE_UNITS_ARB", GLint, # == GL_MAX_TEXTURE_IMAGE_UNITS_NV - ["ctx->Const.MaxTextureImageUnits"], "", NoState, - ["ARB_fragment_program", "NV_fragment_program"] ), - - # GL_EXT_depth_bounds_test - ( "GL_DEPTH_BOUNDS_TEST_EXT", GLboolean, - ["ctx->Depth.BoundsTest"], "", NoState, ["EXT_depth_bounds_test"] ), - ( "GL_DEPTH_BOUNDS_EXT", GLfloat, - ["ctx->Depth.BoundsMin", "ctx->Depth.BoundsMax"], - "", NoState, ["EXT_depth_bounds_test"] ), - - # GL_ARB_depth_clamp - ( "GL_DEPTH_CLAMP", GLboolean, ["ctx->Transform.DepthClamp"], "", - NoState, ["ARB_depth_clamp"] ), - - # GL_ARB_draw_buffers - ( "GL_MAX_DRAW_BUFFERS_ARB", GLint, - ["ctx->Const.MaxDrawBuffers"], "", NoState, NoExt ), - ( "GL_DRAW_BUFFER0_ARB", GLenum, - ["ctx->DrawBuffer->ColorDrawBuffer[0]"], "", NoState, NoExt ), - ( "GL_DRAW_BUFFER1_ARB", GLenum, - ["buffer"], - """GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[1];""", NoState, NoExt ), - ( "GL_DRAW_BUFFER2_ARB", GLenum, - ["buffer"], - """GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[2];""", NoState, NoExt ), - ( "GL_DRAW_BUFFER3_ARB", GLenum, - ["buffer"], - """GLenum buffer; - if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)"); - return; - } - buffer = ctx->DrawBuffer->ColorDrawBuffer[3];""", NoState, NoExt ), - # XXX Add more GL_DRAW_BUFFERn_ARB entries as needed in the future - - # GL_OES_read_format - ( "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES", GLint, - ["_mesa_get_color_read_type(ctx)"], "", "_NEW_BUFFERS", ["OES_read_format"] ), - ( "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES", GLint, - ["_mesa_get_color_read_format(ctx)"], "", "_NEW_BUFFERS", ["OES_read_format"] ), - - # GL_ATI_fragment_shader - ( "GL_NUM_FRAGMENT_REGISTERS_ATI", GLint, ["6"], - "", NoState, ["ATI_fragment_shader"] ), - ( "GL_NUM_FRAGMENT_CONSTANTS_ATI", GLint, ["8"], - "", NoState, ["ATI_fragment_shader"] ), - ( "GL_NUM_PASSES_ATI", GLint, ["2"], - "", NoState, ["ATI_fragment_shader"] ), - ( "GL_NUM_INSTRUCTIONS_PER_PASS_ATI", GLint, ["8"], - "", NoState, ["ATI_fragment_shader"] ), - ( "GL_NUM_INSTRUCTIONS_TOTAL_ATI", GLint, ["16"], - "", NoState, ["ATI_fragment_shader"] ), - ( "GL_COLOR_ALPHA_PAIRING_ATI", GLboolean, ["GL_TRUE"], - "", NoState, ["ATI_fragment_shader"] ), - ( "GL_NUM_LOOPBACK_COMPONENTS_ATI", GLint, ["3"], - "", NoState, ["ATI_fragment_shader"] ), - ( "GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI", GLint, ["3"], - "", NoState, ["ATI_fragment_shader"] ), - - # OpenGL 2.0 - ( "GL_STENCIL_BACK_FUNC", GLenum, ["ctx->Stencil.Function[1]"], - "", NoState, NoExt ), - ( "GL_STENCIL_BACK_VALUE_MASK", GLint, ["ctx->Stencil.ValueMask[1]"], - "", NoState, NoExt ), - ( "GL_STENCIL_BACK_WRITEMASK", GLint, ["ctx->Stencil.WriteMask[1]"], - "", NoState, NoExt ), - ( "GL_STENCIL_BACK_REF", GLint, ["ctx->Stencil.Ref[1]"], - "", NoState, NoExt ), - ( "GL_STENCIL_BACK_FAIL", GLenum, ["ctx->Stencil.FailFunc[1]"], - "", NoState, NoExt ), - ( "GL_STENCIL_BACK_PASS_DEPTH_FAIL", GLenum, ["ctx->Stencil.ZFailFunc[1]"], - "", NoState, NoExt ), - ( "GL_STENCIL_BACK_PASS_DEPTH_PASS", GLenum, ["ctx->Stencil.ZPassFunc[1]"], - "", NoState, NoExt ), - - # GL_EXT_framebuffer_object - ( "GL_FRAMEBUFFER_BINDING_EXT", GLint, ["ctx->DrawBuffer->Name"], "", - NoState, ["EXT_framebuffer_object"] ), - ( "GL_RENDERBUFFER_BINDING_EXT", GLint, - ["ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0"], "", - NoState, ["EXT_framebuffer_object"] ), - ( "GL_MAX_COLOR_ATTACHMENTS_EXT", GLint, - ["ctx->Const.MaxColorAttachments"], "", - NoState, ["EXT_framebuffer_object"] ), - ( "GL_MAX_RENDERBUFFER_SIZE_EXT", GLint, - ["ctx->Const.MaxRenderbufferSize"], "", - NoState, ["EXT_framebuffer_object"] ), - - # GL_EXT_framebuffer_blit - # NOTE: GL_DRAW_FRAMEBUFFER_BINDING_EXT == GL_FRAMEBUFFER_BINDING_EXT - ( "GL_READ_FRAMEBUFFER_BINDING_EXT", GLint, ["ctx->ReadBuffer->Name"], "", - NoState, ["EXT_framebuffer_blit"] ), - - # GL_EXT_provoking_vertex - ( "GL_PROVOKING_VERTEX_EXT", GLboolean, - ["ctx->Light.ProvokingVertex"], "", NoState, ["EXT_provoking_vertex"] ), - ( "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT", GLboolean, - ["ctx->Const.QuadsFollowProvokingVertexConvention"], "", - NoState, ["EXT_provoking_vertex"] ), - - # GL_ARB_fragment_shader - ( "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB", GLint, - ["ctx->Const.FragmentProgram.MaxUniformComponents"], "", - NoState, ["ARB_fragment_shader"] ), - ( "GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB", GLenum, - ["ctx->Hint.FragmentShaderDerivative"], - "", NoState, ["ARB_fragment_shader"] ), - - # GL_ARB_vertex_shader - ( "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB", GLint, - ["ctx->Const.VertexProgram.MaxUniformComponents"], "", - NoState, ["ARB_vertex_shader"] ), - ( "GL_MAX_VARYING_FLOATS_ARB", GLint, - ["ctx->Const.MaxVarying * 4"], "", NoState, ["ARB_vertex_shader"] ), - ( "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB", GLint, - ["ctx->Const.MaxVertexTextureImageUnits"], - "", NoState, ["ARB_vertex_shader"] ), - ( "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB", GLint, - ["ctx->Const.MaxCombinedTextureImageUnits"], - "", NoState, ["ARB_vertex_shader"] ), - - # GL_ARB_shader_objects - # Actually, this token isn't part of GL_ARB_shader_objects, but is - # close enough for now. - ( "GL_CURRENT_PROGRAM", GLint, - ["ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0"], - "", NoState, ["ARB_shader_objects"] ), - - # GL_ARB_framebuffer_object - ( "GL_MAX_SAMPLES", GLint, ["ctx->Const.MaxSamples"], "", - NoState, ["ARB_framebuffer_object"] ), - - # GL_APPLE_vertex_array_object - ( "GL_VERTEX_ARRAY_BINDING_APPLE", GLint, ["ctx->Array.ArrayObj->Name"], "", - NoState, ["APPLE_vertex_array_object"] ), - - # GL_ARB_seamless_cube_map - ( "GL_TEXTURE_CUBE_MAP_SEAMLESS", GLboolean, ["ctx->Texture.CubeMapSeamless"], "", - NoState, ["ARB_seamless_cube_map"] ), - - # GL_ARB_sync - ( "GL_MAX_SERVER_WAIT_TIMEOUT", GLint64, ["ctx->Const.MaxServerWaitTimeout"], "", - NoState, ["ARB_sync"] ), - - # GL_EXT_transform_feedback - ( "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING", GLint, - ["ctx->TransformFeedback.CurrentBuffer->Name"], "", - NoState, ["EXT_transform_feedback"] ), - ( "GL_RASTERIZER_DISCARD", GLboolean, - ["ctx->TransformFeedback.RasterDiscard"], "", - NoState, ["EXT_transform_feedback"] ), - ( "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS", GLint, - ["ctx->Const.MaxTransformFeedbackInterleavedComponents"], "", - NoState, ["EXT_transform_feedback"] ), - ( "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS", GLint, - ["ctx->Const.MaxTransformFeedbackSeparateAttribs"], "", - NoState, ["EXT_transform_feedback"] ), - ( "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS", GLint, - ["ctx->Const.MaxTransformFeedbackSeparateComponents"], "", - NoState, ["EXT_transform_feedback"] ), - - # GL 3.0 - ( "GL_NUM_EXTENSIONS", GLint, - ["_mesa_get_extension_count(ctx)"], "", NoState, "30" ), - ( "GL_MAJOR_VERSION", GLint, - ["ctx->VersionMajor"], "", NoState, "30" ), - ( "GL_MINOR_VERSION", GLint, - ["ctx->VersionMinor"], "", NoState, "30" ), - ( "GL_CONTEXT_FLAGS", GLint, - ["ctx->Const.ContextFlags"], "", NoState, "30" ), - - # GL 3.1 - ( "GL_PRIMITIVE_RESTART", GLboolean, - ["ctx->Array.PrimitiveRestart"], "", NoState, "31" ), - ( "GL_PRIMITIVE_RESTART_INDEX", GLint, - ["ctx->Array.RestartIndex"], "", NoState, "31" ), - - # GL 3.2 - ( "GL_CONTEXT_PROFILE_MASK", GLint, ["ctx->Const.ProfileMask"], "", - NoState, "32" ) - -] - - -# These are queried via glGetIntegetIndexdvEXT() or glGetIntegeri_v() -# The tuples are the same as above, with one exception: the "optional" -# code field is instead the max legal index value. -IndexedStateVars = [ - # GL_EXT_draw_buffers2 / GL3 - ( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"], - "ctx->Const.MaxDrawBuffers", NoState, ["EXT_draw_buffers2"] ), - ( "GL_COLOR_WRITEMASK", GLint, - [ "ctx->Color.ColorMask[index][RCOMP] ? 1 : 0", - "ctx->Color.ColorMask[index][GCOMP] ? 1 : 0", - "ctx->Color.ColorMask[index][BCOMP] ? 1 : 0", - "ctx->Color.ColorMask[index][ACOMP] ? 1 : 0" ], - "ctx->Const.MaxDrawBuffers", NoState, ["EXT_draw_buffers2"] ), - - # GL_EXT_transform_feedback - ( "GL_TRANSFORM_FEEDBACK_BUFFER_START", GLint64, - ["ctx->TransformFeedback.Offset[index]"], - "ctx->Const.MaxTransformFeedbackSeparateAttribs", - NoState, ["EXT_transform_feedback"] ), - ( "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE", GLint64, - ["ctx->TransformFeedback.Size[index]"], - "ctx->Const.MaxTransformFeedbackSeparateAttribs", - NoState, ["EXT_transform_feedback"] ), - ( "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING", GLint, - ["ctx->TransformFeedback.Buffers[index]->Name"], - "ctx->Const.MaxTransformFeedbackSeparateAttribs", - NoState, ["EXT_transform_feedback"] ), - - # XXX more to come... -] - - - -def ConversionFunc(fromType, toType): - """Return the name of the macro to convert between two data types.""" - if fromType == toType: - return "" - elif fromType == GLfloat and toType == GLint: - return "IROUND" - elif fromType == GLfloat and toType == GLint64: - return "IROUND64" - elif fromType == GLfloatN and toType == GLfloat: - return "" - elif fromType == GLint and toType == GLfloat: # but not GLfloatN! - return "(GLfloat)" - elif fromType == GLint and toType == GLint64: - return "(GLint64)" - elif fromType == GLint64 and toType == GLfloat: # but not GLfloatN! - return "(GLfloat)" - else: - if fromType == GLfloatN: - fromType = GLfloat - fromStr = TypeStrings[fromType] - fromStr = string.upper(fromStr[2:]) - toStr = TypeStrings[toType] - toStr = string.upper(toStr[2:]) - return fromStr + "_TO_" + toStr - - -def EmitGetFunction(stateVars, returnType, indexed): - """Emit the code to implement glGetBooleanv, glGetIntegerv or glGetFloatv.""" - assert (returnType == GLboolean or - returnType == GLint or - returnType == GLint64 or - returnType == GLfloat) - - strType = TypeStrings[returnType] - # Capitalize first letter of return type - if indexed: - if returnType == GLint: - function = "GetIntegerIndexedv" - elif returnType == GLboolean: - function = "GetBooleanIndexedv" - elif returnType == GLint64: - function = "GetInteger64Indexedv" - else: - function = "Foo" - else: - if returnType == GLint: - function = "GetIntegerv" - elif returnType == GLboolean: - function = "GetBooleanv" - elif returnType == GLfloat: - function = "GetFloatv" - elif returnType == GLint64: - function = "GetInteger64v" - else: - sys.exit(1) - - if returnType == GLint64: - print "#if FEATURE_ARB_sync" - - print "void GLAPIENTRY" - if indexed: - print "_mesa_%s( GLenum pname, GLuint index, %s *params )" % (function, strType) - else: - print "_mesa_%s( GLenum pname, %s *params )" % (function, strType) - print "{" - print " GET_CURRENT_CONTEXT(ctx);" - print " const GLuint version = ctx->VersionMajor * 10 + ctx->VersionMinor;" - print " ASSERT_OUTSIDE_BEGIN_END(ctx);" - print " (void) version;" - print "" - print " if (!params)" - print " return;" - print "" - if indexed == 0: - print " if (ctx->Driver.%s &&" % function - print " ctx->Driver.%s(ctx, pname, params))" % function - print " return;" - print "" - print " switch (pname) {" - - for state in stateVars: - if indexed: - (name, varType, state, indexMax, dirtyFlags, extensions) = state - optionalCode = 0 - else: - (name, varType, state, optionalCode, dirtyFlags, extensions) = state - indexMax = 0 - print " case " + name + ":" - - # Do extension check - if extensions: - if extensions == "30" or extensions == "31" or extensions == "32": - print (' CHECK_VERSION(%s);' % extensions) - elif len(extensions) == 1: - print (' CHECK_EXT1(%s);' % extensions[0]) - elif len(extensions) == 2: - print (' CHECK_EXT2(%s, %s);' % (extensions[0], extensions[1])) - elif len(extensions) == 3: - print (' CHECK_EXT3(%s, %s, %s);' % - (extensions[0], extensions[1], extensions[2])) - else: - assert len(extensions) == 4 - print (' CHECK_EXT4(%s, %s, %s, %s);' % - (extensions[0], extensions[1], extensions[2], extensions[3])) - - # Do dirty state check - if dirtyFlags: - if dirtyFlags == FlushCurrent: - print (' FLUSH_CURRENT(ctx, 0);') - else: - print (' if (ctx->NewState & %s)' % dirtyFlags) - print (' _mesa_update_state(ctx);') - - # Do index validation for glGet*Indexed() calls - if indexMax: - print (' if (index >= %s) {' % indexMax) - print (' _mesa_error(ctx, GL_INVALID_VALUE, "gl%s(index=%%u), index", pname);' % function) - print (' return;') - print (' }') - - conversion = ConversionFunc(varType, returnType) - if optionalCode: - optionalCode = string.replace(optionalCode, "CONVERSION", conversion); - print " {" - print " " + optionalCode - n = len(state) - for i in range(n): - if conversion: - print " params[%d] = %s(%s);" % (i, conversion, state[i]) - else: - print " params[%d] = %s;" % (i, state[i]) - if optionalCode: - print " }" - print " break;" - - print " default:" - print " goto invalid_enum_error;" - print " }" - print " return;" - print "" - print "invalid_enum_error:" - print ' _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(pname=0x%%x)", pname);' % function - print "}" - if returnType == GLint64: - print "#endif /* FEATURE_ARB_sync */" - print "" - return - - - -def EmitHeader(): - """Print the get.c file header.""" - print """ -/*** - *** NOTE!!! DO NOT EDIT THIS FILE!!! IT IS GENERATED BY get_gen.py - ***/ - -#include "glheader.h" -#include "context.h" -#include "enable.h" -#include "extensions.h" -#include "get.h" -#include "macros.h" -#include "mtypes.h" -#include "state.h" -#include "texcompress.h" -#include "framebuffer.h" - - -#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE ) - -#define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) - -#define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) -#define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) ) - -#define BOOLEAN_TO_INT(B) ( (GLint) (B) ) -#define BOOLEAN_TO_INT64(B) ( (GLint64) (B) ) -#define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F ) - -#define ENUM_TO_INT64(E) ( (GLint64) (E) ) - - -/* - * Check if named extension is enabled, if not generate error and return. - */ -#define CHECK_EXT1(EXT1) \\ - if (!ctx->Extensions.EXT1) { \\ - goto invalid_enum_error; \\ - } - -/* - * Check if either of two extensions is enabled. - */ -#define CHECK_EXT2(EXT1, EXT2) \\ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \\ - goto invalid_enum_error; \\ - } - -/* - * Check if either of three extensions is enabled. - */ -#define CHECK_EXT3(EXT1, EXT2, EXT3) \\ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2 && \\ - !ctx->Extensions.EXT3) { \\ - goto invalid_enum_error; \\ - } - -/* - * Check if either of four extensions is enabled. - */ -#define CHECK_EXT4(EXT1, EXT2, EXT3, EXT4) \\ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2 && \\ - !ctx->Extensions.EXT3 && !ctx->Extensions.EXT4) { \\ - goto invalid_enum_error; \\ - } - -/* - * Check GL version. - */ -#define CHECK_VERSION(VERSION) \\ - if (version < VERSION) { \\ - goto invalid_enum_error; \\ - } - -""" - return - - - -def EmitGetDoublev(): - print """ -void GLAPIENTRY -_mesa_GetDoublev( GLenum pname, GLdouble *params ) -{ - const GLfloat magic = -1234.5F; - GLfloat values[16]; - GLuint i; - - if (!params) - return; - - /* Init temp array to magic numbers so we can figure out how many values - * are returned by the GetFloatv() call. - */ - for (i = 0; i < 16; i++) - values[i] = magic; - - _mesa_GetFloatv(pname, values); - - for (i = 0; i < 16 && values[i] != magic; i++) - params[i] = (GLdouble) values[i]; -} -""" - - - - -EmitHeader() -# XXX Maybe sort the StateVars list -EmitGetFunction(StateVars, GLboolean, 0) -EmitGetFunction(StateVars, GLfloat, 0) -EmitGetFunction(StateVars, GLint, 0) -EmitGetFunction(StateVars, GLint64, 0) -EmitGetDoublev() - -EmitGetFunction(IndexedStateVars, GLboolean, 1) -EmitGetFunction(IndexedStateVars, GLint, 1) -EmitGetFunction(IndexedStateVars, GLint64, 1) - diff --git a/src/mesa/main/get_gen_es.py b/src/mesa/main/get_gen_es.py deleted file mode 100644 index 5fadfee8411..00000000000 --- a/src/mesa/main/get_gen_es.py +++ /dev/null @@ -1,807 +0,0 @@ -#!/usr/bin/env python - -# Mesa 3-D graphics library -# -# Copyright (C) 1999-2006 Brian Paul All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -# This script is used to generate the get.c file: -# python get_gen.py > get.c - - -import string -import sys - - -GLint = 1 -GLenum = 2 -GLfloat = 3 -GLdouble = 4 -GLboolean = 5 -GLfloatN = 6 # A normalized value, such as a color or depth range -GLfixed = 7 - - -TypeStrings = { - GLint : "GLint", - GLenum : "GLenum", - GLfloat : "GLfloat", - GLdouble : "GLdouble", - GLboolean : "GLboolean", - GLfixed : "GLfixed" -} - - -# Each entry is a tuple of: -# - the GL state name, such as GL_CURRENT_COLOR -# - the state datatype, one of GLint, GLfloat, GLboolean or GLenum -# - list of code fragments to get the state, such as ["ctx->Foo.Bar"] -# - optional extra code or empty string -# - optional extensions to check, or None -# - -# Present in ES 1.x and 2.x: -StateVars_common = [ - ( "GL_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.alphaBits"], - "", None ), - ( "GL_BLEND", GLboolean, ["ctx->Color.BlendEnabled"], "", None ), - ( "GL_BLEND_SRC", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ), - ( "GL_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.blueBits"], "", None ), - ( "GL_COLOR_CLEAR_VALUE", GLfloatN, - [ "ctx->Color.ClearColor[0]", - "ctx->Color.ClearColor[1]", - "ctx->Color.ClearColor[2]", - "ctx->Color.ClearColor[3]" ], "", None ), - ( "GL_COLOR_WRITEMASK", GLint, - [ "ctx->Color.ColorMask[RCOMP] ? 1 : 0", - "ctx->Color.ColorMask[GCOMP] ? 1 : 0", - "ctx->Color.ColorMask[BCOMP] ? 1 : 0", - "ctx->Color.ColorMask[ACOMP] ? 1 : 0" ], "", None ), - ( "GL_CULL_FACE", GLboolean, ["ctx->Polygon.CullFlag"], "", None ), - ( "GL_CULL_FACE_MODE", GLenum, ["ctx->Polygon.CullFaceMode"], "", None ), - ( "GL_DEPTH_BITS", GLint, ["ctx->DrawBuffer->Visual.depthBits"], - "", None ), - ( "GL_DEPTH_CLEAR_VALUE", GLfloatN, ["ctx->Depth.Clear"], "", None ), - ( "GL_DEPTH_FUNC", GLenum, ["ctx->Depth.Func"], "", None ), - ( "GL_DEPTH_RANGE", GLfloatN, - [ "ctx->Viewport.Near", "ctx->Viewport.Far" ], "", None ), - ( "GL_DEPTH_TEST", GLboolean, ["ctx->Depth.Test"], "", None ), - ( "GL_DEPTH_WRITEMASK", GLboolean, ["ctx->Depth.Mask"], "", None ), - ( "GL_DITHER", GLboolean, ["ctx->Color.DitherFlag"], "", None ), - ( "GL_FRONT_FACE", GLenum, ["ctx->Polygon.FrontFace"], "", None ), - ( "GL_GREEN_BITS", GLint, ["ctx->DrawBuffer->Visual.greenBits"], - "", None ), - ( "GL_LINE_WIDTH", GLfloat, ["ctx->Line.Width"], "", None ), - ( "GL_ALIASED_LINE_WIDTH_RANGE", GLfloat, - ["ctx->Const.MinLineWidth", - "ctx->Const.MaxLineWidth"], "", None ), - ( "GL_MAX_ELEMENTS_INDICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", None ), - ( "GL_MAX_ELEMENTS_VERTICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", None ), - - ( "GL_MAX_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.MaxTextureLevels - 1)"], "", None ), - ( "GL_MAX_VIEWPORT_DIMS", GLint, - ["ctx->Const.MaxViewportWidth", "ctx->Const.MaxViewportHeight"], - "", None ), - ( "GL_PACK_ALIGNMENT", GLint, ["ctx->Pack.Alignment"], "", None ), - ( "GL_ALIASED_POINT_SIZE_RANGE", GLfloat, - ["ctx->Const.MinPointSize", - "ctx->Const.MaxPointSize"], "", None ), - ( "GL_POLYGON_OFFSET_FACTOR", GLfloat, ["ctx->Polygon.OffsetFactor "], "", None ), - ( "GL_POLYGON_OFFSET_UNITS", GLfloat, ["ctx->Polygon.OffsetUnits "], "", None ), - ( "GL_RED_BITS", GLint, ["ctx->DrawBuffer->Visual.redBits"], "", None ), - ( "GL_SCISSOR_BOX", GLint, - ["ctx->Scissor.X", - "ctx->Scissor.Y", - "ctx->Scissor.Width", - "ctx->Scissor.Height"], "", None ), - ( "GL_SCISSOR_TEST", GLboolean, ["ctx->Scissor.Enabled"], "", None ), - ( "GL_STENCIL_BITS", GLint, ["ctx->DrawBuffer->Visual.stencilBits"], "", None ), - ( "GL_STENCIL_CLEAR_VALUE", GLint, ["ctx->Stencil.Clear"], "", None ), - ( "GL_STENCIL_FAIL", GLenum, - ["ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]"], "", None ), - ( "GL_STENCIL_FUNC", GLenum, - ["ctx->Stencil.Function[ctx->Stencil.ActiveFace]"], "", None ), - ( "GL_STENCIL_PASS_DEPTH_FAIL", GLenum, - ["ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]"], "", None ), - ( "GL_STENCIL_PASS_DEPTH_PASS", GLenum, - ["ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]"], "", None ), - ( "GL_STENCIL_REF", GLint, - ["ctx->Stencil.Ref[ctx->Stencil.ActiveFace]"], "", None ), - ( "GL_STENCIL_TEST", GLboolean, ["ctx->Stencil.Enabled"], "", None ), - ( "GL_STENCIL_VALUE_MASK", GLint, - ["ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]"], "", None ), - ( "GL_STENCIL_WRITEMASK", GLint, - ["ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]"], "", None ), - ( "GL_SUBPIXEL_BITS", GLint, ["ctx->Const.SubPixelBits"], "", None ), - ( "GL_TEXTURE_BINDING_2D", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name"], "", None ), - ( "GL_UNPACK_ALIGNMENT", GLint, ["ctx->Unpack.Alignment"], "", None ), - ( "GL_VIEWPORT", GLint, [ "ctx->Viewport.X", "ctx->Viewport.Y", - "ctx->Viewport.Width", "ctx->Viewport.Height" ], "", None ), - - # GL_ARB_multitexture - ( "GL_ACTIVE_TEXTURE_ARB", GLint, - [ "GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit"], "", ["ARB_multitexture"] ), - - # Note that all the OES_* extensions require that the Mesa - # "struct gl_extensions" include a member with the name of - # the extension. That structure does not yet include OES - # extensions (and we're not sure whether it will). If - # it does, all the OES_* extensions below should mark the - # dependency. - - # OES_texture_cube_map - ( "GL_TEXTURE_BINDING_CUBE_MAP_ARB", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_CUBE_INDEX]->Name"], - "", None), - ( "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB", GLint, - ["(1 << (ctx->Const.MaxCubeTextureLevels - 1))"], - "", None), - - # OES_blend_subtract - ( "GL_BLEND_SRC_RGB_EXT", GLenum, ["ctx->Color.BlendSrcRGB"], "", None), - ( "GL_BLEND_DST_RGB_EXT", GLenum, ["ctx->Color.BlendDstRGB"], "", None), - ( "GL_BLEND_SRC_ALPHA_EXT", GLenum, ["ctx->Color.BlendSrcA"], "", None), - ( "GL_BLEND_DST_ALPHA_EXT", GLenum, ["ctx->Color.BlendDstA"], "", None), - - # GL_BLEND_EQUATION_RGB, which is what we're really after, - # is defined identically to GL_BLEND_EQUATION. - ( "GL_BLEND_EQUATION", GLenum, ["ctx->Color.BlendEquationRGB "], "", None), - ( "GL_BLEND_EQUATION_ALPHA_EXT", GLenum, ["ctx->Color.BlendEquationA "], - "", None), - - # GL_ARB_texture_compression */ -# ( "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB", GLint, -# ["_mesa_get_compressed_formats(ctx, NULL, GL_FALSE)"], -# "", ["ARB_texture_compression"] ), -# ( "GL_COMPRESSED_TEXTURE_FORMATS_ARB", GLenum, -# [], -# """GLint formats[100]; -# GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE); -# ASSERT(n <= 100); -# for (i = 0; i < n; i++) -# params[i] = ENUM_TO_INT(formats[i]);""", -# ["ARB_texture_compression"] ), - - # GL_ARB_multisample - ( "GL_SAMPLE_ALPHA_TO_COVERAGE_ARB", GLboolean, - ["ctx->Multisample.SampleAlphaToCoverage"], "", ["ARB_multisample"] ), - ( "GL_SAMPLE_COVERAGE_ARB", GLboolean, - ["ctx->Multisample.SampleCoverage"], "", ["ARB_multisample"] ), - ( "GL_SAMPLE_COVERAGE_VALUE_ARB", GLfloat, - ["ctx->Multisample.SampleCoverageValue"], "", ["ARB_multisample"] ), - ( "GL_SAMPLE_COVERAGE_INVERT_ARB", GLboolean, - ["ctx->Multisample.SampleCoverageInvert"], "", ["ARB_multisample"] ), - ( "GL_SAMPLE_BUFFERS_ARB", GLint, - ["ctx->DrawBuffer->Visual.sampleBuffers"], "", ["ARB_multisample"] ), - ( "GL_SAMPLES_ARB", GLint, - ["ctx->DrawBuffer->Visual.samples"], "", ["ARB_multisample"] ), - - - # GL_SGIS_generate_mipmap - ( "GL_GENERATE_MIPMAP_HINT_SGIS", GLenum, ["ctx->Hint.GenerateMipmap"], - "", ["SGIS_generate_mipmap"] ), - - # GL_ARB_vertex_buffer_object - ( "GL_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayBufferObj->Name"], "", ["ARB_vertex_buffer_object"] ), - # GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported - ( "GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ElementArrayBufferObj->Name"], - "", ["ARB_vertex_buffer_object"] ), - - # GL_OES_read_format - ( "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES", GLint, - ["_mesa_get_color_read_type(ctx)"], "", ["OES_read_format"] ), - ( "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES", GLint, - ["_mesa_get_color_read_format(ctx)"], "", ["OES_read_format"] ), - - # GL_OES_framebuffer_object - ( "GL_FRAMEBUFFER_BINDING_EXT", GLint, ["ctx->DrawBuffer->Name"], "", - None), - ( "GL_RENDERBUFFER_BINDING_EXT", GLint, - ["ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0"], "", - None), - ( "GL_MAX_RENDERBUFFER_SIZE_EXT", GLint, - ["ctx->Const.MaxRenderbufferSize"], "", - None), - - # OpenGL ES 1/2 special: - ( "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB", GLint, - [ "ARRAY_SIZE(compressed_formats)" ], - "", - None ), - - ("GL_COMPRESSED_TEXTURE_FORMATS_ARB", GLint, - [], - """ - int i; - for (i = 0; i < ARRAY_SIZE(compressed_formats); i++) { - params[i] = compressed_formats[i]; - }""", - None ), - - ( "GL_POLYGON_OFFSET_FILL", GLboolean, ["ctx->Polygon.OffsetFill"], "", None ), - -] - -# Only present in ES 1.x: -StateVars_es1 = [ - ( "GL_MAX_LIGHTS", GLint, ["ctx->Const.MaxLights"], "", None ), - ( "GL_LIGHT0", GLboolean, ["ctx->Light.Light[0].Enabled"], "", None ), - ( "GL_LIGHT1", GLboolean, ["ctx->Light.Light[1].Enabled"], "", None ), - ( "GL_LIGHT2", GLboolean, ["ctx->Light.Light[2].Enabled"], "", None ), - ( "GL_LIGHT3", GLboolean, ["ctx->Light.Light[3].Enabled"], "", None ), - ( "GL_LIGHT4", GLboolean, ["ctx->Light.Light[4].Enabled"], "", None ), - ( "GL_LIGHT5", GLboolean, ["ctx->Light.Light[5].Enabled"], "", None ), - ( "GL_LIGHT6", GLboolean, ["ctx->Light.Light[6].Enabled"], "", None ), - ( "GL_LIGHT7", GLboolean, ["ctx->Light.Light[7].Enabled"], "", None ), - ( "GL_LIGHTING", GLboolean, ["ctx->Light.Enabled"], "", None ), - ( "GL_LIGHT_MODEL_AMBIENT", GLfloatN, - ["ctx->Light.Model.Ambient[0]", - "ctx->Light.Model.Ambient[1]", - "ctx->Light.Model.Ambient[2]", - "ctx->Light.Model.Ambient[3]"], "", None ), - ( "GL_LIGHT_MODEL_TWO_SIDE", GLboolean, ["ctx->Light.Model.TwoSide"], "", None ), - ( "GL_ALPHA_TEST", GLboolean, ["ctx->Color.AlphaEnabled"], "", None ), - ( "GL_ALPHA_TEST_FUNC", GLenum, ["ctx->Color.AlphaFunc"], "", None ), - ( "GL_ALPHA_TEST_REF", GLfloatN, ["ctx->Color.AlphaRef"], "", None ), - ( "GL_BLEND_DST", GLenum, ["ctx->Color.BlendDstRGB"], "", None ), - ( "GL_MAX_CLIP_PLANES", GLint, ["ctx->Const.MaxClipPlanes"], "", None ), - ( "GL_CLIP_PLANE0", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 0) & 1" ], "", None ), - ( "GL_CLIP_PLANE1", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 1) & 1" ], "", None ), - ( "GL_CLIP_PLANE2", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 2) & 1" ], "", None ), - ( "GL_CLIP_PLANE3", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 3) & 1" ], "", None ), - ( "GL_CLIP_PLANE4", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 4) & 1" ], "", None ), - ( "GL_CLIP_PLANE5", GLboolean, - [ "(ctx->Transform.ClipPlanesEnabled >> 5) & 1" ], "", None ), - ( "GL_COLOR_MATERIAL", GLboolean, - ["ctx->Light.ColorMaterialEnabled"], "", None ), - ( "GL_CURRENT_COLOR", GLfloatN, - [ "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]", - "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]", - "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]", - "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]" ], - "FLUSH_CURRENT(ctx, 0);", None ), - ( "GL_CURRENT_NORMAL", GLfloatN, - [ "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]", - "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]", - "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]"], - "FLUSH_CURRENT(ctx, 0);", None ), - ( "GL_CURRENT_TEXTURE_COORDS", GLfloat, - ["ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][0]", - "ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][1]", - "ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][2]", - "ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][3]"], - "const GLuint texUnit = ctx->Texture.CurrentUnit;", None ), - ( "GL_DISTANCE_ATTENUATION_EXT", GLfloat, - ["ctx->Point.Params[0]", - "ctx->Point.Params[1]", - "ctx->Point.Params[2]"], "", None ), - ( "GL_FOG", GLboolean, ["ctx->Fog.Enabled"], "", None ), - ( "GL_FOG_COLOR", GLfloatN, - [ "ctx->Fog.Color[0]", - "ctx->Fog.Color[1]", - "ctx->Fog.Color[2]", - "ctx->Fog.Color[3]" ], "", None ), - ( "GL_FOG_DENSITY", GLfloat, ["ctx->Fog.Density"], "", None ), - ( "GL_FOG_END", GLfloat, ["ctx->Fog.End"], "", None ), - ( "GL_FOG_HINT", GLenum, ["ctx->Hint.Fog"], "", None ), - ( "GL_FOG_MODE", GLenum, ["ctx->Fog.Mode"], "", None ), - ( "GL_FOG_START", GLfloat, ["ctx->Fog.Start"], "", None ), - ( "GL_LINE_SMOOTH", GLboolean, ["ctx->Line.SmoothFlag"], "", None ), - ( "GL_LINE_SMOOTH_HINT", GLenum, ["ctx->Hint.LineSmooth"], "", None ), - ( "GL_LINE_WIDTH_RANGE", GLfloat, - ["ctx->Const.MinLineWidthAA", - "ctx->Const.MaxLineWidthAA"], "", None ), - ( "GL_COLOR_LOGIC_OP", GLboolean, ["ctx->Color.ColorLogicOpEnabled"], "", None ), - ( "GL_LOGIC_OP_MODE", GLenum, ["ctx->Color.LogicOp"], "", None ), - ( "GL_MATRIX_MODE", GLenum, ["ctx->Transform.MatrixMode"], "", None ), - - ( "GL_MAX_MODELVIEW_STACK_DEPTH", GLint, ["MAX_MODELVIEW_STACK_DEPTH"], "", None ), - ( "GL_MAX_PROJECTION_STACK_DEPTH", GLint, ["MAX_PROJECTION_STACK_DEPTH"], "", None ), - ( "GL_MAX_TEXTURE_STACK_DEPTH", GLint, ["MAX_TEXTURE_STACK_DEPTH"], "", None ), - ( "GL_MODELVIEW_MATRIX", GLfloat, - [ "matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", - "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", - "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", - "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], - "const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;", None ), - ( "GL_MODELVIEW_STACK_DEPTH", GLint, ["ctx->ModelviewMatrixStack.Depth + 1"], "", None ), - ( "GL_NORMALIZE", GLboolean, ["ctx->Transform.Normalize"], "", None ), - ( "GL_PACK_SKIP_IMAGES_EXT", GLint, ["ctx->Pack.SkipImages"], "", None ), - ( "GL_PERSPECTIVE_CORRECTION_HINT", GLenum, - ["ctx->Hint.PerspectiveCorrection"], "", None ), - ( "GL_POINT_SIZE", GLfloat, ["ctx->Point.Size"], "", None ), - ( "GL_POINT_SIZE_RANGE", GLfloat, - ["ctx->Const.MinPointSizeAA", - "ctx->Const.MaxPointSizeAA"], "", None ), - ( "GL_POINT_SMOOTH", GLboolean, ["ctx->Point.SmoothFlag"], "", None ), - ( "GL_POINT_SMOOTH_HINT", GLenum, ["ctx->Hint.PointSmooth"], "", None ), - ( "GL_POINT_SIZE_MIN_EXT", GLfloat, ["ctx->Point.MinSize"], "", None ), - ( "GL_POINT_SIZE_MAX_EXT", GLfloat, ["ctx->Point.MaxSize"], "", None ), - ( "GL_POINT_FADE_THRESHOLD_SIZE_EXT", GLfloat, - ["ctx->Point.Threshold"], "", None ), - ( "GL_PROJECTION_MATRIX", GLfloat, - [ "matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", - "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", - "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", - "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], - "const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;", None ), - ( "GL_PROJECTION_STACK_DEPTH", GLint, - ["ctx->ProjectionMatrixStack.Depth + 1"], "", None ), - ( "GL_RESCALE_NORMAL", GLboolean, - ["ctx->Transform.RescaleNormals"], "", None ), - ( "GL_SHADE_MODEL", GLenum, ["ctx->Light.ShadeModel"], "", None ), - ( "GL_TEXTURE_2D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D)"], "", None ), - ( "GL_TEXTURE_MATRIX", GLfloat, - ["matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", - "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", - "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", - "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], - "const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;", None ), - ( "GL_TEXTURE_STACK_DEPTH", GLint, - ["ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Depth + 1"], "", None ), - ( "GL_VERTEX_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Vertex.Enabled"], "", None ), - ( "GL_VERTEX_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Vertex.Size"], "", None ), - ( "GL_VERTEX_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Vertex.Type"], "", None ), - ( "GL_VERTEX_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Vertex.Stride"], "", None ), - ( "GL_NORMAL_ARRAY", GLenum, ["ctx->Array.ArrayObj->Normal.Enabled"], "", None ), - ( "GL_NORMAL_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Normal.Type"], "", None ), - ( "GL_NORMAL_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Normal.Stride"], "", None ), - ( "GL_COLOR_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Color.Enabled"], "", None ), - ( "GL_COLOR_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Color.Size"], "", None ), - ( "GL_COLOR_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Color.Type"], "", None ), - ( "GL_COLOR_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Color.Stride"], "", None ), - ( "GL_TEXTURE_COORD_ARRAY", GLboolean, - ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled"], "", None ), - ( "GL_TEXTURE_COORD_ARRAY_SIZE", GLint, - ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size"], "", None ), - ( "GL_TEXTURE_COORD_ARRAY_TYPE", GLenum, - ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Type"], "", None ), - ( "GL_TEXTURE_COORD_ARRAY_STRIDE", GLint, - ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride"], "", None ), - # GL_ARB_multitexture - ( "GL_MAX_TEXTURE_UNITS_ARB", GLint, - ["ctx->Const.MaxTextureUnits"], "", ["ARB_multitexture"] ), - ( "GL_CLIENT_ACTIVE_TEXTURE_ARB", GLint, - ["GL_TEXTURE0_ARB + ctx->Array.ActiveTexture"], "", ["ARB_multitexture"] ), - # OES_texture_cube_map - ( "GL_TEXTURE_CUBE_MAP_ARB", GLboolean, - ["_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB)"], "", None), - ( "GL_TEXTURE_GEN_STR_OES", GLboolean, - # S, T, and R are always set at the same time - ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)"], "", None), - # ARB_multisample - ( "GL_MULTISAMPLE_ARB", GLboolean, - ["ctx->Multisample.Enabled"], "", ["ARB_multisample"] ), - ( "GL_SAMPLE_ALPHA_TO_ONE_ARB", GLboolean, - ["ctx->Multisample.SampleAlphaToOne"], "", ["ARB_multisample"] ), - - ( "GL_VERTEX_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->Vertex.BufferObj->Name"], "", ["ARB_vertex_buffer_object"] ), - ( "GL_NORMAL_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->Normal.BufferObj->Name"], "", ["ARB_vertex_buffer_object"] ), - ( "GL_COLOR_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->Color.BufferObj->Name"], "", ["ARB_vertex_buffer_object"] ), - ( "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB", GLint, - ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name"], - "", ["ARB_vertex_buffer_object"] ), - - # OES_point_sprite - ( "GL_POINT_SPRITE_NV", GLboolean, ["ctx->Point.PointSprite"], # == GL_POINT_SPRITE_ARB - "", None), - - # GL_ARB_fragment_shader - ( "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB", GLint, - ["ctx->Const.FragmentProgram.MaxUniformComponents"], "", - ["ARB_fragment_shader"] ), - - # GL_ARB_vertex_shader - ( "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB", GLint, - ["ctx->Const.VertexProgram.MaxUniformComponents"], "", - ["ARB_vertex_shader"] ), - ( "GL_MAX_VARYING_FLOATS_ARB", GLint, - ["ctx->Const.MaxVarying * 4"], "", ["ARB_vertex_shader"] ), - - # OES_matrix_get - ( "GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES", GLint, [], - """ - /* See GL_OES_matrix_get */ - { - const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m; - memcpy(params, matrix, 16 * sizeof(GLint)); - }""", - None), - - ( "GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES", GLint, [], - """ - /* See GL_OES_matrix_get */ - { - const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m; - memcpy(params, matrix, 16 * sizeof(GLint)); - }""", - None), - - ( "GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES", GLint, [], - """ - /* See GL_OES_matrix_get */ - { - const GLfloat *matrix = - ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m; - memcpy(params, matrix, 16 * sizeof(GLint)); - }""", - None), - - # OES_point_size_array - ("GL_POINT_SIZE_ARRAY_OES", GLboolean, - ["ctx->Array.ArrayObj->PointSize.Enabled"], "", None), - ("GL_POINT_SIZE_ARRAY_TYPE_OES", GLenum, - ["ctx->Array.ArrayObj->PointSize.Type"], "", None), - ("GL_POINT_SIZE_ARRAY_STRIDE_OES", GLint, - ["ctx->Array.ArrayObj->PointSize.Stride"], "", None), - ("GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES", GLint, - ["ctx->Array.ArrayObj->PointSize.BufferObj->Name"], "", None), - - # GL_EXT_texture_lod_bias - ( "GL_MAX_TEXTURE_LOD_BIAS_EXT", GLfloat, - ["ctx->Const.MaxTextureLodBias"], "", ["EXT_texture_lod_bias"]), - - # GL_EXT_texture_filter_anisotropic - ( "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT", GLfloat, - ["ctx->Const.MaxTextureMaxAnisotropy"], "", ["EXT_texture_filter_anisotropic"]), - -] - -# Only present in ES 2.x: -StateVars_es2 = [ - # XXX These entries are not spec'ed for GLES 2, but are - # needed for Mesa's GLSL: - ( "GL_MAX_LIGHTS", GLint, ["ctx->Const.MaxLights"], "", None ), - ( "GL_MAX_CLIP_PLANES", GLint, ["ctx->Const.MaxClipPlanes"], "", None ), - ( "GL_MAX_TEXTURE_COORDS_ARB", GLint, # == GL_MAX_TEXTURE_COORDS_NV - ["ctx->Const.MaxTextureCoordUnits"], "", - ["ARB_fragment_program", "NV_fragment_program"] ), - ( "GL_MAX_DRAW_BUFFERS_ARB", GLint, - ["ctx->Const.MaxDrawBuffers"], "", ["ARB_draw_buffers"] ), - ( "GL_BLEND_COLOR_EXT", GLfloatN, - [ "ctx->Color.BlendColor[0]", - "ctx->Color.BlendColor[1]", - "ctx->Color.BlendColor[2]", - "ctx->Color.BlendColor[3]"], "", None ), - - # This is required for GLES2, but also needed for GLSL: - ( "GL_MAX_TEXTURE_IMAGE_UNITS_ARB", GLint, # == GL_MAX_TEXTURE_IMAGE_UNI - ["ctx->Const.MaxTextureImageUnits"], "", - ["ARB_fragment_program", "NV_fragment_program"] ), - - ( "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB", GLint, - ["ctx->Const.MaxVertexTextureImageUnits"], "", ["ARB_vertex_shader"] ), - ( "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB", GLint, - ["MAX_COMBINED_TEXTURE_IMAGE_UNITS"], "", ["ARB_vertex_shader"] ), - - # GL_ARB_shader_objects - # Actually, this token isn't part of GL_ARB_shader_objects, but is - # close enough for now. - ( "GL_CURRENT_PROGRAM", GLint, - ["ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0"], - "", ["ARB_shader_objects"] ), - - # OpenGL 2.0 - ( "GL_STENCIL_BACK_FUNC", GLenum, ["ctx->Stencil.Function[1]"], "", None ), - ( "GL_STENCIL_BACK_VALUE_MASK", GLint, ["ctx->Stencil.ValueMask[1]"], "", None ), - ( "GL_STENCIL_BACK_WRITEMASK", GLint, ["ctx->Stencil.WriteMask[1]"], "", None ), - ( "GL_STENCIL_BACK_REF", GLint, ["ctx->Stencil.Ref[1]"], "", None ), - ( "GL_STENCIL_BACK_FAIL", GLenum, ["ctx->Stencil.FailFunc[1]"], "", None ), - ( "GL_STENCIL_BACK_PASS_DEPTH_FAIL", GLenum, ["ctx->Stencil.ZFailFunc[1]"], "", None ), - ( "GL_STENCIL_BACK_PASS_DEPTH_PASS", GLenum, ["ctx->Stencil.ZPassFunc[1]"], "", None ), - - ( "GL_MAX_VERTEX_ATTRIBS_ARB", GLint, - ["ctx->Const.VertexProgram.MaxAttribs"], "", ["ARB_vertex_program"] ), - - # OES_texture_3D - ( "GL_TEXTURE_BINDING_3D", GLint, - ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name"], "", None), - ( "GL_MAX_3D_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.Max3DTextureLevels - 1)"], "", None), - - # OES_standard_derivatives - ( "GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB", GLenum, - ["ctx->Hint.FragmentShaderDerivative"], "", ["ARB_fragment_shader"] ), - - # Unique to ES 2 (not in full GL) - ( "GL_MAX_FRAGMENT_UNIFORM_VECTORS", GLint, - ["ctx->Const.FragmentProgram.MaxUniformComponents / 4"], "", None), - ( "GL_MAX_VARYING_VECTORS", GLint, - ["ctx->Const.MaxVarying"], "", None), - ( "GL_MAX_VERTEX_UNIFORM_VECTORS", GLint, - ["ctx->Const.VertexProgram.MaxUniformComponents / 4"], "", None), - ( "GL_SHADER_COMPILER", GLint, ["1"], "", None), - # OES_get_program_binary - ( "GL_NUM_SHADER_BINARY_FORMATS", GLint, ["0"], "", None), - ( "GL_SHADER_BINARY_FORMATS", GLint, [], "", None), -] - - - -def ConversionFunc(fromType, toType): - """Return the name of the macro to convert between two data types.""" - if fromType == toType: - return "" - elif fromType == GLfloat and toType == GLint: - return "IROUND" - elif fromType == GLfloatN and toType == GLfloat: - return "" - elif fromType == GLint and toType == GLfloat: # but not GLfloatN! - return "(GLfloat)" - else: - if fromType == GLfloatN: - fromType = GLfloat - fromStr = TypeStrings[fromType] - fromStr = string.upper(fromStr[2:]) - toStr = TypeStrings[toType] - toStr = string.upper(toStr[2:]) - return fromStr + "_TO_" + toStr - - -def EmitGetFunction(stateVars, returnType, API): - """Emit the code to implement glGetBooleanv, glGetIntegerv or glGetFloatv.""" - assert (returnType == GLboolean or - returnType == GLint or - returnType == GLfloat or - returnType == GLfixed) - - strType = TypeStrings[returnType] - # Capitalize first letter of return type - if returnType == GLint: - function = "_es%d_GetIntegerv" % API - elif returnType == GLboolean: - function = "_es%d_GetBooleanv" % API - elif returnType == GLfloat: - function = "_es%d_GetFloatv" % API - elif returnType == GLfixed: - function = "_es%d_GetFixedv" % API - else: - abort() - - print "void GLAPIENTRY" - print "%s( GLenum pname, %s *params )" % (function, strType) - print "{" - print " GET_CURRENT_CONTEXT(ctx);" - print " ASSERT_OUTSIDE_BEGIN_END(ctx);" - print "" - print " if (!params)" - print " return;" - print "" - print " if (ctx->NewState)" - print " _mesa_update_state(ctx);" - print "" - print " switch (pname) {" - - for (name, varType, state, optionalCode, extensions) in stateVars: - print " case " + name + ":" - if extensions: - if len(extensions) == 1: - print (' CHECK_EXT1(%s, "%s");' % - (extensions[0], function)) - elif len(extensions) == 2: - print (' CHECK_EXT2(%s, %s, "%s");' % - (extensions[0], extensions[1], function)) - elif len(extensions) == 3: - print (' CHECK_EXT3(%s, %s, %s, "%s");' % - (extensions[0], extensions[1], extensions[2], function)) - else: - assert len(extensions) == 4 - print (' CHECK_EXT4(%s, %s, %s, %s, "%s");' % - (extensions[0], extensions[1], extensions[2], extensions[3], function)) - if optionalCode: - print " {" - print " " + optionalCode - conversion = ConversionFunc(varType, returnType) - n = len(state) - for i in range(n): - if conversion: - print " params[%d] = %s(%s);" % (i, conversion, state[i]) - else: - print " params[%d] = %s;" % (i, state[i]) - if optionalCode: - print " }" - print " break;" - - print " default:" - print ' _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(pname=0x%%x)", pname);' % function - print " }" - print "}" - print "" - return - - - -def EmitHeader(): - """Print the get.c file header.""" - print """ -/*** - *** NOTE!!! DO NOT EDIT THIS FILE!!! IT IS GENERATED BY get_gen.py - ***/ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/enable.h" -#include "main/extensions.h" -#include "main/fbobject.h" -#include "main/get.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "main/state.h" -#include "main/texcompress.h" -#include "main/framebuffer.h" - - -/* ES1 tokens that should be in gl.h but aren't */ -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 - - -/* ES2 special tokens */ -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_SHADER_COMPILER 0x8DFA -#define GL_PLATFORM_BINARY 0x8D63 -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 - - -#ifndef GL_OES_matrix_get -#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES 0x898D -#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES 0x898E -#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES 0x898F -#endif - -#ifndef GL_OES_compressed_paletted_texture -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif - -/* GL_OES_texture_cube_map */ -#ifndef GL_OES_texture_cube_map -#define GL_TEXTURE_GEN_STR_OES 0x8D60 -#endif - -#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE ) -#define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \\ - ((F) * 65536.0f < INT_MIN) ? INT_MIN : \\ - (GLint) ((F) * 65536.0f) ) - -#define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) -#define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \\ - ((I) < SHRT_MIN) ? INT_MIN : \\ - (GLint) ((I) * 65536) ) - -#define BOOLEAN_TO_INT(B) ( (GLint) (B) ) -#define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F ) -#define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 ) - -#define ENUM_TO_FIXED(E) (E) - - -/* - * Check if named extension is enabled, if not generate error and return. - */ -#define CHECK_EXT1(EXT1, FUNC) \\ - if (!ctx->Extensions.EXT1) { \\ - _mesa_error(ctx, GL_INVALID_ENUM, FUNC "(0x%x)", (int) pname); \\ - return; \\ - } - -/* - * Check if either of two extensions is enabled. - */ -#define CHECK_EXT2(EXT1, EXT2, FUNC) \\ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \\ - _mesa_error(ctx, GL_INVALID_ENUM, FUNC "(0x%x)", (int) pname); \\ - return; \\ - } - -/* - * Check if either of three extensions is enabled. - */ -#define CHECK_EXT3(EXT1, EXT2, EXT3, FUNC) \\ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2 && \\ - !ctx->Extensions.EXT3) { \\ - _mesa_error(ctx, GL_INVALID_ENUM, FUNC "(0x%x)", (int) pname); \\ - return; \\ - } - -/* - * Check if either of four extensions is enabled. - */ -#define CHECK_EXT4(EXT1, EXT2, EXT3, EXT4, FUNC) \\ - if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2 && \\ - !ctx->Extensions.EXT3 && !ctx->Extensions.EXT4) { \\ - _mesa_error(ctx, GL_INVALID_ENUM, FUNC "(0x%x)", (int) pname); \\ - return; \\ - } - - - -/** - * List of compressed texture formats supported by ES. - */ -static GLenum compressed_formats[] = { - GL_PALETTE4_RGB8_OES, - GL_PALETTE4_RGBA8_OES, - GL_PALETTE4_R5_G6_B5_OES, - GL_PALETTE4_RGBA4_OES, - GL_PALETTE4_RGB5_A1_OES, - GL_PALETTE8_RGB8_OES, - GL_PALETTE8_RGBA8_OES, - GL_PALETTE8_R5_G6_B5_OES, - GL_PALETTE8_RGBA4_OES, - GL_PALETTE8_RGB5_A1_OES -}; - -#define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0])) - -""" - return - - -def EmitAll(stateVars, API): - EmitHeader() - EmitGetFunction(stateVars, GLboolean, API) - EmitGetFunction(stateVars, GLfloat, API) - EmitGetFunction(stateVars, GLint, API) - if API == 1: - EmitGetFunction(stateVars, GLfixed, API) - - -def main(args): - # Determine whether to generate ES1 or ES2 queries - if len(args) > 1 and args[1] == "1": - API = 1 - elif len(args) > 1 and args[1] == "2": - API = 2 - else: - API = 1 - #print "len args = %d API = %d" % (len(args), API) - - if API == 1: - vars = StateVars_common + StateVars_es1 - else: - vars = StateVars_common + StateVars_es2 - - EmitAll(vars, API) - - -main(sys.argv) diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c index e3a60fa6eb5..54db5794bf6 100644 --- a/src/mesa/main/getstring.c +++ b/src/mesa/main/getstring.c @@ -172,10 +172,6 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params ) if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname)); - if (ctx->Driver.GetPointerv - && (*ctx->Driver.GetPointerv)(ctx, pname, params)) - return; - switch (pname) { case GL_VERTEX_ARRAY_POINTER: *params = (GLvoid *) ctx->Array.ArrayObj->Vertex.Ptr; diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h index 5b8e2f2d811..a4044ff5cba 100644 --- a/src/mesa/main/glheader.h +++ b/src/mesa/main/glheader.h @@ -107,6 +107,21 @@ typedef void *GLeglImageOES; #define GL_PALETTE8_RGB5_A1_OES 0x8B99 #endif +#ifndef GL_OES_matrix_get +#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES 0x898D +#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES 0x898E +#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES 0x898F +#endif + +#ifndef GL_ES_VERSION_2_0 +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#endif + /** * Special, internal token */ diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index b1389b25f2a..25080db40c4 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -243,41 +243,6 @@ _mesa_memset16( unsigned short *dst, unsigned short val, size_t n ) /** \name Math */ /*@{*/ -/** Wrapper around sin() */ -double -_mesa_sin(double a) -{ - return sin(a); -} - -/** Single precision wrapper around sin() */ -float -_mesa_sinf(float a) -{ - return (float) sin((double) a); -} - -/** Wrapper around cos() */ -double -_mesa_cos(double a) -{ - return cos(a); -} - -/** Single precision wrapper around asin() */ -float -_mesa_asinf(float x) -{ - return (float) asin((double) x); -} - -/** Single precision wrapper around atan() */ -float -_mesa_atanf(float x) -{ - return (float) atan((double) x); -} - /** Wrapper around sqrt() */ double _mesa_sqrtd(double x) @@ -486,15 +451,6 @@ _mesa_inv_sqrtf(float n) #endif } - -/** Wrapper around pow() */ -double -_mesa_pow(double x, double y) -{ - return pow(x, y); -} - - /** * Find the first bit set in a word. */ diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 1c263aabca1..da825a095ea 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -522,21 +522,6 @@ extern void _mesa_memset16( unsigned short *dst, unsigned short val, size_t n ); extern double -_mesa_sin(double a); - -extern float -_mesa_sinf(float a); - -extern double -_mesa_cos(double a); - -extern float -_mesa_asinf(float x); - -extern float -_mesa_atanf(float x); - -extern double _mesa_sqrtd(double x); extern float @@ -548,9 +533,6 @@ _mesa_inv_sqrtf(float x); extern void _mesa_init_sqrt_table(void); -extern double -_mesa_pow(double x, double y); - extern int _mesa_ffs(int32_t i); diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index 19dc96892d2..5b87b8c8acb 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -162,7 +162,7 @@ _mesa_light(GLcontext *ctx, GLuint lnum, GLenum pname, const GLfloat *params) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); light->SpotCutoff = params[0]; - light->_CosCutoffNeg = (GLfloat) (_mesa_cos(light->SpotCutoff * DEG2RAD)); + light->_CosCutoffNeg = (GLfloat) (cos(light->SpotCutoff * DEG2RAD)); if (light->_CosCutoffNeg < 0) light->_CosCutoff = 0; else @@ -950,7 +950,7 @@ validate_spot_exp_table( struct gl_light *l ) for (i = EXP_TABLE_SIZE - 1; i > 0 ;i--) { if (clamp == 0) { - tmp = _mesa_pow(i / (GLdouble) (EXP_TABLE_SIZE - 1), exponent); + tmp = pow(i / (GLdouble) (EXP_TABLE_SIZE - 1), exponent); if (tmp < FLT_MIN * 100.0) { tmp = 0.0; clamp = 1; @@ -1012,7 +1012,7 @@ validate_shine_table( GLcontext *ctx, GLuint side, GLfloat shininess ) GLdouble t, x = j / (GLfloat) (SHINE_TABLE_SIZE - 1); if (x < 0.005) /* underflow check */ x = 0.005; - t = _mesa_pow(x, shininess); + t = pow(x, shininess); if (t > 1e-20) m[j] = (GLfloat) t; else diff --git a/src/mesa/main/light.h b/src/mesa/main/light.h index 9c1a5eefadd..b3436114d40 100644 --- a/src/mesa/main/light.h +++ b/src/mesa/main/light.h @@ -94,7 +94,7 @@ do { \ int k = (int) f; \ if (k < 0 /* gcc may cast an overflow float value to negative int value*/ \ || k > SHINE_TABLE_SIZE-2) \ - result = (GLfloat) _mesa_pow( dp, _tab->shininess ); \ + result = (GLfloat) pow( dp, _tab->shininess ); \ else \ result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \ } while (0) diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index a8624574de4..40e17e53d6c 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -127,6 +127,9 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256]; #define CLAMPED_FLOAT_TO_USHORT(us, f) \ us = ( (GLushort) IROUND( (f) * 65535.0F) ) +#define UNCLAMPED_FLOAT_TO_SHORT(s, f) \ + s = ( (GLshort) IROUND( CLAMP((f), -1.0F, 1.0F) * 32767.0F) ) + /*@}*/ diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 9640b79ea7f..c34d9bac4a0 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2034,24 +2034,46 @@ struct gl_shader_state /** - * Context state for transform feedback. + * Transform feedback object state */ -struct gl_transform_feedback +struct gl_transform_feedback_object { + GLuint Name; /**< AKA the object ID */ + GLint RefCount; GLboolean Active; /**< Is transform feedback enabled? */ - GLenum Mode; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */ + GLboolean Paused; /**< Is transform feedback paused? */ + + /** The feedback buffers */ + GLuint BufferNames[MAX_FEEDBACK_ATTRIBS]; + struct gl_buffer_object *Buffers[MAX_FEEDBACK_ATTRIBS]; + /** Start of feedback data in dest buffer */ GLintptr Offset[MAX_FEEDBACK_ATTRIBS]; /** Max data to put into dest buffer (in bytes) */ GLsizeiptr Size[MAX_FEEDBACK_ATTRIBS]; +}; + + +/** + * Context state for transform feedback. + */ +struct gl_transform_feedback +{ + GLenum Mode; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */ + GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */ /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */ struct gl_buffer_object *CurrentBuffer; - /** The feedback buffers */ - GLuint BufferNames[MAX_FEEDBACK_ATTRIBS]; - struct gl_buffer_object *Buffers[MAX_FEEDBACK_ATTRIBS]; + /** The table of all transform feedback objects */ + struct _mesa_HashTable *Objects; + + /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */ + struct gl_transform_feedback_object *CurrentObject; + + /** The default xform-fb object (Name==0) */ + struct gl_transform_feedback_object *DefaultObject; }; @@ -2480,6 +2502,7 @@ struct gl_extensions GLboolean ARB_texture_float; GLboolean ARB_texture_mirrored_repeat; GLboolean ARB_texture_non_power_of_two; + GLboolean ARB_transform_feedback2; GLboolean ARB_transpose_matrix; GLboolean ARB_vertex_array_object; GLboolean ARB_vertex_buffer_object; @@ -2876,7 +2899,7 @@ struct gl_dlist_state typedef enum { API_OPENGL, API_OPENGLES, - API_OPENGLES2, + API_OPENGLES2 } gl_api; /** diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c index 82b6fe7ab9f..a0969f6b9ff 100644 --- a/src/mesa/main/querymatrix.c +++ b/src/mesa/main/querymatrix.c @@ -69,6 +69,21 @@ fpclassify(double x) return FP_NAN; } } + +#elif defined(__APPLE__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \ + defined(__DragonFly__) || (defined(__sun) && defined(__C99FEATURES__)) + +/* fpclassify is available. */ + +#elif !defined(_XOPEN_SOURCE) || _XOPEN_SOURCE < 600 + +enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL} +fpclassify(double x) +{ + /* XXX do something better someday */ + return FP_NORMAL; +} + #endif extern GLbitfield GL_APIENTRY _es_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]); diff --git a/src/mesa/main/queryobj.h b/src/mesa/main/queryobj.h index ba8b5dd0029..b044c0d5d49 100644 --- a/src/mesa/main/queryobj.h +++ b/src/mesa/main/queryobj.h @@ -80,6 +80,12 @@ _mesa_init_queryobj_dispatch(struct _glapi_table *disp); #define _MESA_INIT_QUERYOBJ_FUNCTIONS(driver, impl) do { } while (0) +static INLINE struct gl_query_object * +_mesa_lookup_query_object(GLcontext *ctx, GLuint id) +{ + return NULL; +} + static INLINE void _mesa_init_query_object_functions(struct dd_function_table *driver) { diff --git a/src/mesa/main/rbadaptors.c b/src/mesa/main/rbadaptors.c deleted file mode 100644 index 1060c5796ed..00000000000 --- a/src/mesa/main/rbadaptors.c +++ /dev/null @@ -1,565 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 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 - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * Renderbuffer adaptors. - * These fuctions are used to convert rendering from core Mesa's GLchan - * colors to 8 or 16-bit color channels in RGBA renderbuffers. - * This means Mesa can be compiled for 16 or 32-bit color processing - * and still render into 8 and 16-bit/channel renderbuffers. - */ - - -#include "glheader.h" -#include "mtypes.h" -#include "colormac.h" -#include "renderbuffer.h" -#include "rbadaptors.h" - - -static void -Delete_wrapper(struct gl_renderbuffer *rb) -{ - /* Decrement reference count on the buffer we're wrapping and delete - * it if refcount hits zero. - */ - _mesa_reference_renderbuffer(&rb->Wrapped, NULL); - - /* delete myself */ - _mesa_delete_renderbuffer(rb); -} - - -static GLboolean -AllocStorage_wrapper(GLcontext *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, GLuint width, GLuint height) -{ - GLboolean b = rb->Wrapped->AllocStorage(ctx, rb->Wrapped, internalFormat, - width, height); - if (b) { - rb->Width = width; - rb->Height = height; - } - return b; -} - - -static void * -GetPointer_wrapper(GLcontext *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y) -{ - (void) ctx; - (void) rb; - (void) x; - (void) y; - return NULL; -} - - -static void -GetRow_16wrap8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - GLubyte values8[MAX_WIDTH * 4]; - GLushort *values16 = (GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_BYTE); - ASSERT(count <= MAX_WIDTH); - - /* get 8bpp values */ - rb->Wrapped->GetRow(ctx, rb->Wrapped, count, x, y, values8); - - /* convert 8bpp to 16bpp */ - for (i = 0; i < 4 * count; i++) { - values16[i] = (values8[i] << 8) | values8[i]; - } -} - - -static void -GetValues_16wrap8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLubyte values8[MAX_WIDTH * 4]; - GLushort *values16 = (GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_BYTE); - - rb->Wrapped->GetValues(ctx, rb->Wrapped, count, x, y, values8); - - for (i = 0; i < 4 * count; i++) { - values16[i] = (values8[i] << 8) | values8[i]; - } -} - - -static void -PutRow_16wrap8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - GLubyte values8[MAX_WIDTH * 4]; - GLushort *values16 = (GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < 4 * count; i++) { - values8[i] = values16[i] >> 8; - } - rb->Wrapped->PutRow(ctx, rb->Wrapped, count, x, y, values8, mask); -} - - -static void -PutRowRGB_16wrap8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - GLubyte values8[MAX_WIDTH * 3]; - GLushort *values16 = (GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < 3 * count; i++) { - values8[i] = values16[i] >> 8; - } - rb->Wrapped->PutRowRGB(ctx, rb->Wrapped, count, x, y, values8, mask); -} - - -static void -PutMonoRow_16wrap8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - GLubyte value8[4]; - GLushort *value16 = (GLushort *) value; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_BYTE); - value8[0] = value16[0] >> 8; - value8[1] = value16[1] >> 8; - value8[2] = value16[2] >> 8; - value8[3] = value16[3] >> 8; - rb->Wrapped->PutMonoRow(ctx, rb->Wrapped, count, x, y, value8, mask); -} - - -static void -PutValues_16wrap8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - GLubyte values8[MAX_WIDTH * 4]; - GLushort *values16 = (GLushort *) values; - GLuint i; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < 4 * count; i++) { - values8[i] = values16[i] >> 8; - } - rb->Wrapped->PutValues(ctx, rb->Wrapped, count, x, y, values8, mask); -} - - -static void -PutMonoValues_16wrap8(GLcontext *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - GLubyte value8[4]; - GLushort *value16 = (GLushort *) value; - ASSERT(rb->DataType == GL_UNSIGNED_SHORT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_BYTE); - value8[0] = value16[0] >> 8; - value8[1] = value16[1] >> 8; - value8[2] = value16[2] >> 8; - value8[3] = value16[3] >> 8; - rb->Wrapped->PutMonoValues(ctx, rb->Wrapped, count, x, y, value8, mask); -} - - -/** - * Wrap an 8-bit/channel renderbuffer with a 16-bit/channel - * renderbuffer adaptor. - */ -struct gl_renderbuffer * -_mesa_new_renderbuffer_16wrap8(GLcontext *ctx, struct gl_renderbuffer *rb8) -{ - struct gl_renderbuffer *rb16; - - rb16 = _mesa_new_renderbuffer(ctx, rb8->Name); - if (rb16) { - ASSERT(rb8->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb8->_BaseFormat == GL_RGBA); - - _glthread_LOCK_MUTEX(rb8->Mutex); - rb8->RefCount++; - _glthread_UNLOCK_MUTEX(rb8->Mutex); - - rb16->InternalFormat = rb8->InternalFormat; - rb16->Format = rb8->Format; /* XXX is this right? */ - rb16->_BaseFormat = rb8->_BaseFormat; - rb16->DataType = GL_UNSIGNED_SHORT; - /* Note: passing through underlying bits/channel */ - rb16->Wrapped = rb8; - - rb16->AllocStorage = AllocStorage_wrapper; - rb16->Delete = Delete_wrapper; - rb16->GetPointer = GetPointer_wrapper; - rb16->GetRow = GetRow_16wrap8; - rb16->GetValues = GetValues_16wrap8; - rb16->PutRow = PutRow_16wrap8; - rb16->PutRowRGB = PutRowRGB_16wrap8; - rb16->PutMonoRow = PutMonoRow_16wrap8; - rb16->PutValues = PutValues_16wrap8; - rb16->PutMonoValues = PutMonoValues_16wrap8; - } - return rb16; -} - - - - -static void -GetRow_32wrap8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - GLubyte values8[MAX_WIDTH * 4]; - GLfloat *values32 = (GLfloat *) values; - GLuint i; - ASSERT(rb->DataType == GL_FLOAT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_BYTE); - ASSERT(count <= MAX_WIDTH); - - /* get 8bpp values */ - rb->Wrapped->GetRow(ctx, rb->Wrapped, count, x, y, values8); - - /* convert 8bpp to 32bpp */ - for (i = 0; i < 4 * count; i++) { - values32[i] = UBYTE_TO_FLOAT(values8[i]); - } -} - - -static void -GetValues_32wrap8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLubyte values8[MAX_WIDTH * 4]; - GLfloat *values32 = (GLfloat *) values; - GLuint i; - ASSERT(rb->DataType == GL_FLOAT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_BYTE); - - rb->Wrapped->GetValues(ctx, rb->Wrapped, count, x, y, values8); - - for (i = 0; i < 4 * count; i++) { - values32[i] = UBYTE_TO_FLOAT(values8[i]); - } -} - - -static void -PutRow_32wrap8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - GLubyte values8[MAX_WIDTH * 4]; - GLfloat *values32 = (GLfloat *) values; - GLuint i; - ASSERT(rb->DataType == GL_FLOAT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < 4 * count; i++) { - UNCLAMPED_FLOAT_TO_UBYTE(values8[i], values32[i]); - } - rb->Wrapped->PutRow(ctx, rb->Wrapped, count, x, y, values8, mask); -} - - -static void -PutRowRGB_32wrap8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - GLubyte values8[MAX_WIDTH * 3]; - GLfloat *values32 = (GLfloat *) values; - GLuint i; - ASSERT(rb->DataType == GL_FLOAT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < 3 * count; i++) { - UNCLAMPED_FLOAT_TO_UBYTE(values8[i], values32[i]); - } - rb->Wrapped->PutRowRGB(ctx, rb->Wrapped, count, x, y, values8, mask); -} - - -static void -PutMonoRow_32wrap8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - GLubyte value8[4]; - GLfloat *value32 = (GLfloat *) value; - ASSERT(rb->DataType == GL_FLOAT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_BYTE); - UNCLAMPED_FLOAT_TO_UBYTE(value8[0], value32[0]); - UNCLAMPED_FLOAT_TO_UBYTE(value8[1], value32[1]); - UNCLAMPED_FLOAT_TO_UBYTE(value8[2], value32[2]); - UNCLAMPED_FLOAT_TO_UBYTE(value8[3], value32[3]); - rb->Wrapped->PutMonoRow(ctx, rb->Wrapped, count, x, y, value8, mask); -} - - -static void -PutValues_32wrap8(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - GLubyte values8[MAX_WIDTH * 4]; - GLfloat *values32 = (GLfloat *) values; - GLuint i; - ASSERT(rb->DataType == GL_FLOAT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_BYTE); - for (i = 0; i < 4 * count; i++) { - UNCLAMPED_FLOAT_TO_UBYTE(values8[i], values32[i]); - } - rb->Wrapped->PutValues(ctx, rb->Wrapped, count, x, y, values8, mask); -} - - -static void -PutMonoValues_32wrap8(GLcontext *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - GLubyte value8[4]; - GLfloat *value32 = (GLfloat *) value; - ASSERT(rb->DataType == GL_FLOAT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_BYTE); - UNCLAMPED_FLOAT_TO_UBYTE(value8[0], value32[0]); - UNCLAMPED_FLOAT_TO_UBYTE(value8[1], value32[1]); - UNCLAMPED_FLOAT_TO_UBYTE(value8[2], value32[2]); - UNCLAMPED_FLOAT_TO_UBYTE(value8[3], value32[3]); - rb->Wrapped->PutMonoValues(ctx, rb->Wrapped, count, x, y, value8, mask); -} - - -/** - * Wrap an 8-bit/channel renderbuffer with a 32-bit/channel - * renderbuffer adaptor. - */ -struct gl_renderbuffer * -_mesa_new_renderbuffer_32wrap8(GLcontext *ctx, struct gl_renderbuffer *rb8) -{ - struct gl_renderbuffer *rb32; - - rb32 = _mesa_new_renderbuffer(ctx, rb8->Name); - if (rb32) { - ASSERT(rb8->DataType == GL_UNSIGNED_BYTE); - ASSERT(rb8->_BaseFormat == GL_RGBA); - - _glthread_LOCK_MUTEX(rb8->Mutex); - rb8->RefCount++; - _glthread_UNLOCK_MUTEX(rb8->Mutex); - - rb32->InternalFormat = rb8->InternalFormat; - rb32->Format = rb8->Format; /* XXX is this right? */ - rb32->_BaseFormat = rb8->_BaseFormat; - rb32->DataType = GL_FLOAT; - /* Note: passing through underlying bits/channel */ - rb32->Wrapped = rb8; - - rb32->AllocStorage = AllocStorage_wrapper; - rb32->Delete = Delete_wrapper; - rb32->GetPointer = GetPointer_wrapper; - rb32->GetRow = GetRow_32wrap8; - rb32->GetValues = GetValues_32wrap8; - rb32->PutRow = PutRow_32wrap8; - rb32->PutRowRGB = PutRowRGB_32wrap8; - rb32->PutMonoRow = PutMonoRow_32wrap8; - rb32->PutValues = PutValues_32wrap8; - rb32->PutMonoValues = PutMonoValues_32wrap8; - } - return rb32; -} - - - - -static void -GetRow_32wrap16(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values) -{ - GLushort values16[MAX_WIDTH * 4]; - GLfloat *values32 = (GLfloat *) values; - GLuint i; - ASSERT(rb->DataType == GL_FLOAT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_SHORT); - ASSERT(count <= MAX_WIDTH); - - /* get 16bpp values */ - rb->Wrapped->GetRow(ctx, rb->Wrapped, count, x, y, values16); - - /* convert 16bpp to 32bpp */ - for (i = 0; i < 4 * count; i++) { - values32[i] = USHORT_TO_FLOAT(values16[i]); - } -} - - -static void -GetValues_32wrap16(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values) -{ - GLushort values16[MAX_WIDTH * 4]; - GLfloat *values32 = (GLfloat *) values; - GLuint i; - ASSERT(rb->DataType == GL_FLOAT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_SHORT); - - rb->Wrapped->GetValues(ctx, rb->Wrapped, count, x, y, values16); - - for (i = 0; i < 4 * count; i++) { - values32[i] = USHORT_TO_FLOAT(values16[i]); - } -} - - -static void -PutRow_32wrap16(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - GLushort values16[MAX_WIDTH * 4]; - GLfloat *values32 = (GLfloat *) values; - GLuint i; - ASSERT(rb->DataType == GL_FLOAT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_SHORT); - for (i = 0; i < 4 * count; i++) { - UNCLAMPED_FLOAT_TO_USHORT(values16[i], values32[i]); - } - rb->Wrapped->PutRow(ctx, rb->Wrapped, count, x, y, values16, mask); -} - - -static void -PutRowRGB_32wrap16(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask) -{ - GLushort values16[MAX_WIDTH * 3]; - GLfloat *values32 = (GLfloat *) values; - GLuint i; - ASSERT(rb->DataType == GL_FLOAT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_SHORT); - for (i = 0; i < 3 * count; i++) { - UNCLAMPED_FLOAT_TO_USHORT(values16[i], values32[i]); - } - rb->Wrapped->PutRowRGB(ctx, rb->Wrapped, count, x, y, values16, mask); -} - - -static void -PutMonoRow_32wrap16(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask) -{ - GLushort value16[4]; - GLfloat *value32 = (GLfloat *) value; - ASSERT(rb->DataType == GL_FLOAT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_SHORT); - UNCLAMPED_FLOAT_TO_USHORT(value16[0], value32[0]); - UNCLAMPED_FLOAT_TO_USHORT(value16[1], value32[1]); - UNCLAMPED_FLOAT_TO_USHORT(value16[2], value32[2]); - UNCLAMPED_FLOAT_TO_USHORT(value16[3], value32[3]); - rb->Wrapped->PutMonoRow(ctx, rb->Wrapped, count, x, y, value16, mask); -} - - -static void -PutValues_32wrap16(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask) -{ - GLushort values16[MAX_WIDTH * 4]; - GLfloat *values32 = (GLfloat *) values; - GLuint i; - ASSERT(rb->DataType == GL_FLOAT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_SHORT); - for (i = 0; i < 4 * count; i++) { - UNCLAMPED_FLOAT_TO_USHORT(values16[i], values32[i]); - } - rb->Wrapped->PutValues(ctx, rb->Wrapped, count, x, y, values16, mask); -} - - -static void -PutMonoValues_32wrap16(GLcontext *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask) -{ - GLushort value16[4]; - GLfloat *value32 = (GLfloat *) value; - ASSERT(rb->DataType == GL_FLOAT); - ASSERT(rb->Wrapped->DataType == GL_UNSIGNED_SHORT); - UNCLAMPED_FLOAT_TO_USHORT(value16[0], value32[0]); - UNCLAMPED_FLOAT_TO_USHORT(value16[1], value32[1]); - UNCLAMPED_FLOAT_TO_USHORT(value16[2], value32[2]); - UNCLAMPED_FLOAT_TO_USHORT(value16[3], value32[3]); - rb->Wrapped->PutMonoValues(ctx, rb->Wrapped, count, x, y, value16, mask); -} - - -/** - * Wrap an 16-bit/channel renderbuffer with a 32-bit/channel - * renderbuffer adaptor. - */ -struct gl_renderbuffer * -_mesa_new_renderbuffer_32wrap16(GLcontext *ctx, struct gl_renderbuffer *rb16) -{ - struct gl_renderbuffer *rb32; - - rb32 = _mesa_new_renderbuffer(ctx, rb16->Name); - if (rb32) { - ASSERT(rb16->DataType == GL_UNSIGNED_SHORT); - ASSERT(rb16->_BaseFormat == GL_RGBA); - - _glthread_LOCK_MUTEX(rb16->Mutex); - rb16->RefCount++; - _glthread_UNLOCK_MUTEX(rb16->Mutex); - - rb32->InternalFormat = rb16->InternalFormat; - rb32->Format = rb16->Format; /* XXX is this right? */ - rb32->_BaseFormat = rb16->_BaseFormat; - rb32->DataType = GL_FLOAT; - /* Note: passing through underlying bits/channel */ - rb32->Wrapped = rb16; - - rb32->AllocStorage = AllocStorage_wrapper; - rb32->Delete = Delete_wrapper; - rb32->GetPointer = GetPointer_wrapper; - rb32->GetRow = GetRow_32wrap16; - rb32->GetValues = GetValues_32wrap16; - rb32->PutRow = PutRow_32wrap16; - rb32->PutRowRGB = PutRowRGB_32wrap16; - rb32->PutMonoRow = PutMonoRow_32wrap16; - rb32->PutValues = PutValues_32wrap16; - rb32->PutMonoValues = PutMonoValues_32wrap16; - } - return rb32; -} diff --git a/src/mesa/main/rbadaptors.h b/src/mesa/main/rbadaptors.h deleted file mode 100644 index 1d45b287ddf..00000000000 --- a/src/mesa/main/rbadaptors.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef RBADAPTORS_H -#define RBADAPTORS_H - - -extern struct gl_renderbuffer * -_mesa_new_renderbuffer_16wrap8(GLcontext *ctx, struct gl_renderbuffer *rb8); - -extern struct gl_renderbuffer * -_mesa_new_renderbuffer_32wrap8(GLcontext *ctx, struct gl_renderbuffer *rb8); - -extern struct gl_renderbuffer * -_mesa_new_renderbuffer_32wrap16(GLcontext *ctx, struct gl_renderbuffer *rb16); - - -#endif /* RBADAPTORS_H */ diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index 4d7b0aff046..adc1199d87a 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -49,12 +49,6 @@ #include "fbobject.h" #include "renderbuffer.h" -#include "rbadaptors.h" - - -/* 32-bit color index format. Not a public format. */ -#define COLOR_INDEX32 0x424243 - /* * Routines for get/put values in common buffer formats follow. @@ -992,6 +986,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, pixelSize = 4 * sizeof(GLubyte); break; case GL_RGBA16: + case GL_RGBA16_SNORM: /* for accum buffer */ rb->Format = MESA_FORMAT_SIGNED_RGBA_16; rb->DataType = GL_SHORT; @@ -1091,21 +1086,6 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->PutMonoValues = put_mono_values_uint; pixelSize = sizeof(GLuint); break; - case GL_COLOR_INDEX8_EXT: - case GL_COLOR_INDEX16_EXT: - case COLOR_INDEX32: - rb->Format = MESA_FORMAT_CI8; - rb->DataType = GL_UNSIGNED_BYTE; - rb->GetPointer = get_pointer_ubyte; - rb->GetRow = get_row_ubyte; - rb->GetValues = get_values_ubyte; - rb->PutRow = put_row_ubyte; - rb->PutRowRGB = NULL; - rb->PutMonoRow = put_mono_row_ubyte; - rb->PutValues = put_values_ubyte; - rb->PutMonoValues = put_mono_values_ubyte; - pixelSize = sizeof(GLubyte); - break; default: _mesa_problem(ctx, "Bad internalFormat in _mesa_soft_renderbuffer_storage"); return GL_FALSE; @@ -1777,7 +1757,7 @@ _mesa_add_accum_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb, } rb->Format = MESA_FORMAT_SIGNED_RGBA_16; - rb->InternalFormat = GL_RGBA16; + rb->InternalFormat = GL_RGBA16_SNORM; rb->AllocStorage = _mesa_soft_renderbuffer_storage; _mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb); @@ -1909,8 +1889,6 @@ void _mesa_add_renderbuffer(struct gl_framebuffer *fb, GLuint bufferName, struct gl_renderbuffer *rb) { - GLenum baseFormat; - assert(fb); assert(rb); assert(bufferName < BUFFER_COUNT); @@ -1931,26 +1909,6 @@ _mesa_add_renderbuffer(struct gl_framebuffer *fb, assert(!rb->Name); } - /* If Mesa's compiled with deep color channels (16 or 32 bits / channel) - * and the device driver is expecting 8-bit values (GLubyte), we can - * use a "renderbuffer adaptor/wrapper" to do the necessary conversions. - */ - baseFormat = _mesa_get_format_base_format(rb->Format); - if (baseFormat == GL_RGBA) { - if (CHAN_BITS == 16 && rb->DataType == GL_UNSIGNED_BYTE) { - GET_CURRENT_CONTEXT(ctx); - rb = _mesa_new_renderbuffer_16wrap8(ctx, rb); - } - else if (CHAN_BITS == 32 && rb->DataType == GL_UNSIGNED_BYTE) { - GET_CURRENT_CONTEXT(ctx); - rb = _mesa_new_renderbuffer_32wrap8(ctx, rb); - } - else if (CHAN_BITS == 32 && rb->DataType == GL_UNSIGNED_SHORT) { - GET_CURRENT_CONTEXT(ctx); - rb = _mesa_new_renderbuffer_32wrap16(ctx, rb); - } - } - fb->Attachment[bufferName].Type = GL_RENDERBUFFER_EXT; fb->Attachment[bufferName].Complete = GL_TRUE; _mesa_reference_renderbuffer(&fb->Attachment[bufferName].Renderbuffer, rb); diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index cff6de89ee3..f4b1119eb17 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -107,6 +107,24 @@ _mesa_get_compressed_formats(GLcontext *ctx, GLint *formats, GLboolean all) } #endif /* FEATURE_EXT_texture_sRGB */ return n; + +#if FEATURE_ES1 || FEATURE_ES2 + if (formats) { + formats[n++] = GL_PALETTE4_RGB8_OES; + formats[n++] = GL_PALETTE4_RGBA8_OES; + formats[n++] = GL_PALETTE4_R5_G6_B5_OES; + formats[n++] = GL_PALETTE4_RGBA4_OES; + formats[n++] = GL_PALETTE4_RGB5_A1_OES; + formats[n++] = GL_PALETTE8_RGB8_OES; + formats[n++] = GL_PALETTE8_RGBA8_OES; + formats[n++] = GL_PALETTE8_R5_G6_B5_OES; + formats[n++] = GL_PALETTE8_RGBA4_OES; + formats[n++] = GL_PALETTE8_RGB5_A1_OES; + } + else { + n += 10; + } +#endif } diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c index 12c2e903eb5..85c394b051f 100644 --- a/src/mesa/main/texcompress_s3tc.c +++ b/src/mesa/main/texcompress_s3tc.c @@ -78,7 +78,7 @@ nonlinear_to_linear(GLubyte cs8) table[i] = cs / 12.92f; } else { - table[i] = (GLfloat) _mesa_pow((cs + 0.055) / 1.055, 2.4); + table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4); } } tableReady = GL_TRUE; diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c index 48a22c19455..24d29137b0c 100644 --- a/src/mesa/main/texfetch.c +++ b/src/mesa/main/texfetch.c @@ -60,7 +60,7 @@ nonlinear_to_linear(GLubyte cs8) table[i] = cs / 12.92f; } else { - table[i] = (GLfloat) _mesa_pow((cs + 0.055) / 1.055, 2.4); + table[i] = (GLfloat) pow((cs + 0.055) / 1.055, 2.4); } } tableReady = GL_TRUE; @@ -622,6 +622,13 @@ texfetch_funcs[MESA_FORMAT_COUNT] = fetch_texel_3d_signed_rgba_16, store_texel_signed_rgba_16 }, + { + MESA_FORMAT_RGBA_16, + fetch_texel_1d_rgba_16, + fetch_texel_2d_rgba_16, + fetch_texel_3d_rgba_16, + store_texel_rgba_16 + } }; diff --git a/src/mesa/main/texfetch_tmp.h b/src/mesa/main/texfetch_tmp.h index 4df2b19181a..e51fe3a5773 100644 --- a/src/mesa/main/texfetch_tmp.h +++ b/src/mesa/main/texfetch_tmp.h @@ -1374,7 +1374,7 @@ store_texel_signed_rg_16(struct gl_texture_image *texImage, #endif -/* MESA_FORMAT_SIGNED_RGB_16 ***********************************************/ +/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/ static void FETCH(signed_rgb_16)(const struct gl_texture_image *texImage, @@ -1383,7 +1383,7 @@ FETCH(signed_rgb_16)(const struct gl_texture_image *texImage, const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 3); texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] ); texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] ); - texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[3] ); + texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] ); texel[ACOMP] = 1.0F; } @@ -1401,7 +1401,7 @@ store_texel_signed_rgb_16(struct gl_texture_image *texImage, #endif -/* MESA_FORMAT_SIGNED_RGB_16 ***********************************************/ +/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/ static void FETCH(signed_rgba_16)(const struct gl_texture_image *texImage, @@ -1410,8 +1410,8 @@ FETCH(signed_rgba_16)(const struct gl_texture_image *texImage, const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] ); texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] ); - texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[3] ); - texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[4] ); + texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] ); + texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[3] ); } #if DIM == 3 @@ -1430,6 +1430,35 @@ store_texel_signed_rgba_16(struct gl_texture_image *texImage, +/* MESA_FORMAT_RGBA_16 ***********************************************/ + +static void +FETCH(rgba_16)(const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + const GLushort *s = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); + texel[RCOMP] = USHORT_TO_FLOAT( s[0] ); + texel[GCOMP] = USHORT_TO_FLOAT( s[1] ); + texel[BCOMP] = USHORT_TO_FLOAT( s[2] ); + texel[ACOMP] = USHORT_TO_FLOAT( s[3] ); +} + +#if DIM == 3 +static void +store_texel_rgba_16(struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, const void *texel) +{ + const GLushort *rgba = (const GLushort *) texel; + GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); + dst[0] = rgba[RCOMP]; + dst[1] = rgba[GCOMP]; + dst[2] = rgba[BCOMP]; + dst[3] = rgba[ACOMP]; +} +#endif + + + /* MESA_FORMAT_YCBCR *********************************************************/ /* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats. diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 06e6fd92fca..d235485721a 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -61,12 +61,9 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, (void) type; switch (internalFormat) { - /* RGBA formats */ + /* shallow RGBA formats */ case 4: case GL_RGBA: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: case GL_RGBA8: return MESA_FORMAT_RGBA8888; case GL_RGB5_A1: @@ -76,12 +73,15 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, case GL_RGBA4: return MESA_FORMAT_ARGB4444; - /* RGB formats */ + /* deep RGBA formats */ + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return MESA_FORMAT_RGBA_16; + + /* shallow RGB formats */ case 3: case GL_RGB: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: case GL_RGB8: return MESA_FORMAT_RGB888; case GL_R3_G3_B2: @@ -91,6 +91,12 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, case GL_RGB5: return MESA_FORMAT_RGB565; + /* deep RGB formats */ + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return MESA_FORMAT_RGBA_16; + /* Alpha formats */ case GL_ALPHA: case GL_ALPHA4: diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 7ad91805bc9..00134ea9ffb 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -224,7 +224,7 @@ linear_to_nonlinear(GLfloat cl) cs = 12.92f * cl; } else { - cs = (GLfloat)(1.055 * _mesa_pow(cl, 0.41666) - 0.055); + cs = (GLfloat)(1.055 * pow(cl, 0.41666) - 0.055); } return cs; } diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 0b55097bd69..ff752155ea9 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1281,7 +1281,7 @@ texture_error_check( GLcontext *ctx, GLenum target, type != GL_UNSIGNED_SHORT_8_8_REV_MESA) { char message[100]; _mesa_snprintf(message, sizeof(message), - "glTexImage%d(format/type YCBCR mismatch", dimensions); + "glTexImage%dD(format/type YCBCR mismatch", dimensions); _mesa_error(ctx, GL_INVALID_ENUM, message); return GL_TRUE; /* error */ } @@ -1297,7 +1297,7 @@ texture_error_check( GLcontext *ctx, GLenum target, if (!isProxy) { char message[100]; _mesa_snprintf(message, sizeof(message), - "glTexImage%d(format=GL_YCBCR_MESA and border=%d)", + "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)", dimensions, border); _mesa_error(ctx, GL_INVALID_VALUE, message); } @@ -1325,7 +1325,7 @@ texture_error_check( GLcontext *ctx, GLenum target, if (_mesa_is_compressed_format(ctx, internalFormat)) { if (!target_can_be_compressed(ctx, target) && !isProxy) { _mesa_error(ctx, GL_INVALID_ENUM, - "glTexImage%d(target)", dimensions); + "glTexImage%dD(target)", dimensions); return GL_TRUE; } if (border != 0) { @@ -1691,7 +1691,7 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions, if (_mesa_is_compressed_format(ctx, internalFormat)) { if (!target_can_be_compressed(ctx, target)) { _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyTexImage%d(target)", dimensions); + "glCopyTexImage%dD(target)", dimensions); return GL_TRUE; } if (border != 0) { @@ -1877,7 +1877,7 @@ copytexsubimage_error_check2( GLcontext *ctx, GLuint dimensions, if (_mesa_is_format_compressed(teximage->TexFormat)) { if (!target_can_be_compressed(ctx, target)) { _mesa_error(ctx, GL_INVALID_ENUM, - "glCopyTexSubImage%d(target)", dimensions); + "glCopyTexSubImage%dD(target)", dimensions); return GL_TRUE; } /* offset must be multiple of 4 */ diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 94c0894de1f..ce05652c935 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -2225,6 +2225,140 @@ _mesa_texstore_al1616(TEXSTORE_PARAMS) static GLboolean +_mesa_texstore_rgba_16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_RGBA_16); + ASSERT(texelBytes == 8); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGBA && + srcFormat == GL_RGBA && + srcType == GL_UNSIGNED_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLfloat *src = tempImage; + GLint img, row, col; + if (!tempImage) + return GL_FALSE; + _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLushort *dstUS = (GLushort *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLushort r, g, b, a; + + UNCLAMPED_FLOAT_TO_USHORT(r, src[0]); + UNCLAMPED_FLOAT_TO_USHORT(g, src[1]); + UNCLAMPED_FLOAT_TO_USHORT(b, src[2]); + UNCLAMPED_FLOAT_TO_USHORT(a, src[3]); + dstUS[col*4+0] = r; + dstUS[col*4+1] = g; + dstUS[col*4+2] = b; + dstUS[col*4+3] = a; + src += 4; + } + dstRow += dstRowStride; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean +_mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) +{ + const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); + const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + + ASSERT(dstFormat == MESA_FORMAT_SIGNED_R_16 || + dstFormat == MESA_FORMAT_SIGNED_RG_16 || + dstFormat == MESA_FORMAT_SIGNED_RGB_16 || + dstFormat == MESA_FORMAT_SIGNED_RGBA_16); + + if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + baseInternalFormat == GL_RGBA && + dstFormat == MESA_FORMAT_SIGNED_RGBA_16 && + srcFormat == GL_RGBA && + srcType == GL_SHORT) { + /* simple memcpy path */ + memcpy_texture(ctx, dims, + dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, + dstRowStride, + dstImageOffsets, + srcWidth, srcHeight, srcDepth, srcFormat, srcType, + srcAddr, srcPacking); + } + else { + /* general path */ + const GLfloat *tempImage = make_temp_float_image(ctx, dims, + baseInternalFormat, + baseFormat, + srcWidth, srcHeight, srcDepth, + srcFormat, srcType, srcAddr, + srcPacking); + const GLfloat *src = tempImage; + const GLuint comps = _mesa_get_format_bytes(dstFormat) / 2; + GLint img, row, col; + + if (!tempImage) + return GL_FALSE; + + _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight); + + /* Note: tempImage is always float[4] / RGBA. We convert to 1, 2, + * 3 or 4 components/pixel here. + */ + for (img = 0; img < srcDepth; img++) { + GLubyte *dstRow = (GLubyte *) dstAddr + + dstImageOffsets[dstZoffset + img] * texelBytes + + dstYoffset * dstRowStride + + dstXoffset * texelBytes; + for (row = 0; row < srcHeight; row++) { + GLshort *dstRowS = (GLshort *) dstRow; + for (col = 0; col < srcWidth; col++) { + GLuint c; + for (c = 0; c < comps; c++) { + GLshort p; + UNCLAMPED_FLOAT_TO_SHORT(p, src[col * 4 + c]); + dstRowS[col * comps + c] = p; + } + } + dstRow += dstRowStride; + src += 4 * srcWidth; + } + } + free((void *) tempImage); + } + return GL_TRUE; +} + + +static GLboolean _mesa_texstore_rgb332(TEXSTORE_PARAMS) { const GLuint texelBytes = _mesa_get_format_bytes(dstFormat); @@ -3347,10 +3481,11 @@ texstore_funcs[MESA_FORMAT_COUNT] = { MESA_FORMAT_SIGNED_RGBA8888, _mesa_texstore_signed_rgba8888 }, { MESA_FORMAT_SIGNED_RGBA8888_REV, _mesa_texstore_signed_rgba8888 }, - { MESA_FORMAT_SIGNED_R_16, NULL/*_mesa_texstore_signed_r16*/ }, - { MESA_FORMAT_SIGNED_RG_16, NULL/*_mesa_texstore_signed_rg16*/ }, - { MESA_FORMAT_SIGNED_RGB_16, NULL/*_mesa_texstore_signed_rgb16*/ }, - { MESA_FORMAT_SIGNED_RGBA_16, NULL/*_mesa_texstore_signed_rgba16*/ }, + { MESA_FORMAT_SIGNED_R_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_SIGNED_RG_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_SIGNED_RGB_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_SIGNED_RGBA_16, _mesa_texstore_signed_rgba_16 }, + { MESA_FORMAT_RGBA_16, _mesa_texstore_rgba_16 } }; diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 74519ba38a6..050ebf02701 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -33,12 +33,58 @@ #include "buffers.h" #include "bufferobj.h" #include "context.h" +#include "hash.h" #include "transformfeedback.h" +#include "main/dispatch.h" #include "shader/prog_parameter.h" #include "shader/shader_api.h" +#if FEATURE_EXT_transform_feedback + + +/** + * Do reference counting of transform feedback buffers. + */ +static void +reference_transform_feedback_object(struct gl_transform_feedback_object **ptr, + struct gl_transform_feedback_object *obj) +{ + if (*ptr == obj) + return; + + if (*ptr) { + /* Unreference the old object */ + struct gl_transform_feedback_object *oldObj = *ptr; + + ASSERT(oldObj->RefCount > 0); + oldObj->RefCount--; + + if (oldObj->RefCount == 0) { + GET_CURRENT_CONTEXT(ctx); + if (ctx) + ctx->Driver.DeleteTransformFeedback(ctx, oldObj); + } + + *ptr = NULL; + } + ASSERT(!*ptr); + + if (obj) { + /* reference new object */ + if (obj->RefCount == 0) { + _mesa_problem(NULL, "referencing deleted transform feedback object"); + *ptr = NULL; + } + else { + obj->RefCount++; + *ptr = obj; + } + } +} + + /** * Check if the given primitive mode (as in glBegin(mode)) is compatible * with the current transform feedback mode (if it's enabled). @@ -49,7 +95,7 @@ GLboolean _mesa_validate_primitive_mode(GLcontext *ctx, GLenum mode) { - if (ctx->TransformFeedback.Active) { + if (ctx->TransformFeedback.CurrentObject->Active) { switch (mode) { case GL_POINTS: return ctx->TransformFeedback.Mode == GL_POINTS; @@ -74,7 +120,7 @@ _mesa_validate_primitive_mode(GLcontext *ctx, GLenum mode) GLboolean _mesa_validate_transform_feedback_buffers(GLcontext *ctx) { - + /* XXX to do */ return GL_TRUE; } @@ -86,29 +132,186 @@ _mesa_validate_transform_feedback_buffers(GLcontext *ctx) void _mesa_init_transform_feedback(GLcontext *ctx) { + if (!ctx->Driver.NewTransformFeedback) { + /* this feature/extension may not be supported by the driver */ + return; + } + + ctx->TransformFeedback.DefaultObject = + ctx->Driver.NewTransformFeedback(ctx, 0); + + assert(ctx->TransformFeedback.DefaultObject->RefCount == 1); + + reference_transform_feedback_object(&ctx->TransformFeedback.CurrentObject, + ctx->TransformFeedback.DefaultObject); + + assert(ctx->TransformFeedback.DefaultObject->RefCount == 2); + + ctx->TransformFeedback.Objects = _mesa_NewHashTable(); + _mesa_reference_buffer_object(ctx, &ctx->TransformFeedback.CurrentBuffer, ctx->Shared->NullBufferObj); } + +/** + * Callback for _mesa_HashDeleteAll(). + */ +static void +delete_cb(GLuint key, void *data, void *userData) +{ + GLcontext *ctx = (GLcontext *) userData; + struct gl_transform_feedback_object *obj = + (struct gl_transform_feedback_object *) data; + + ctx->Driver.DeleteTransformFeedback(ctx, obj); +} + + /** * Per-context free/clean-up for transform feedback. */ void _mesa_free_transform_feedback(GLcontext *ctx) { + if (!ctx->Driver.NewTransformFeedback) { + /* this feature/extension may not be supported by the driver */ + return; + } + _mesa_reference_buffer_object(ctx, &ctx->TransformFeedback.CurrentBuffer, NULL); + + /* Delete all feedback objects */ + _mesa_HashDeleteAll(ctx->TransformFeedback.Objects, delete_cb, ctx); + + /* Delete the default feedback object */ + assert(ctx->Driver.DeleteTransformFeedback); + ctx->Driver.DeleteTransformFeedback(ctx, + ctx->TransformFeedback.DefaultObject); + + ctx->TransformFeedback.CurrentObject = NULL; +} + + +/** Default fallback for ctx->Driver.NewTransformFeedback() */ +static struct gl_transform_feedback_object * +new_transform_feedback(GLcontext *ctx, GLuint name) +{ + struct gl_transform_feedback_object *obj; + obj = CALLOC_STRUCT(gl_transform_feedback_object); + if (obj) { + obj->Name = name; + obj->RefCount = 1; + } + return obj; +} + +/** Default fallback for ctx->Driver.DeleteTransformFeedback() */ +static void +delete_transform_feedback(GLcontext *ctx, + struct gl_transform_feedback_object *obj) +{ + GLuint i; + + for (i = 0; i < Elements(obj->Buffers); i++) { + _mesa_reference_buffer_object(ctx, &obj->Buffers[i], NULL); + } + + free(obj); } +/** Default fallback for ctx->Driver.BeginTransformFeedback() */ +static void +begin_transform_feedback(GLcontext *ctx, GLenum mode, + struct gl_transform_feedback_object *obj) +{ + /* nop */ +} + +/** Default fallback for ctx->Driver.EndTransformFeedback() */ +static void +end_transform_feedback(GLcontext *ctx, + struct gl_transform_feedback_object *obj) +{ + /* nop */ +} + +/** Default fallback for ctx->Driver.PauseTransformFeedback() */ +static void +pause_transform_feedback(GLcontext *ctx, + struct gl_transform_feedback_object *obj) +{ + /* nop */ +} + +/** Default fallback for ctx->Driver.ResumeTransformFeedback() */ +static void +resume_transform_feedback(GLcontext *ctx, + struct gl_transform_feedback_object *obj) +{ + /* nop */ +} + +/** Default fallback for ctx->Driver.DrawTransformFeedback() */ +static void +draw_transform_feedback(GLcontext *ctx, GLenum mode, + struct gl_transform_feedback_object *obj) +{ + /* XXX to do */ + /* + * Get number of vertices in obj's feedback buffer. + * Call ctx->Exec.DrawArrays(mode, 0, count); + */ +} + + +/** + * Plug in default device driver functions for transform feedback. + * Most drivers will override some/all of these. + */ +void +_mesa_init_transform_feedback_functions(struct dd_function_table *driver) +{ + driver->NewTransformFeedback = new_transform_feedback; + driver->DeleteTransformFeedback = delete_transform_feedback; + driver->BeginTransformFeedback = begin_transform_feedback; + driver->EndTransformFeedback = end_transform_feedback; + driver->PauseTransformFeedback = pause_transform_feedback; + driver->ResumeTransformFeedback = resume_transform_feedback; + driver->DrawTransformFeedback = draw_transform_feedback; +} + + +void +_mesa_init_transform_feedback_dispatch(struct _glapi_table *disp) +{ + SET_BeginTransformFeedbackEXT(disp, _mesa_BeginTransformFeedback); + SET_EndTransformFeedbackEXT(disp, _mesa_EndTransformFeedback); + SET_BindBufferRangeEXT(disp, _mesa_BindBufferRange); + SET_BindBufferBaseEXT(disp, _mesa_BindBufferBase); + SET_BindBufferOffsetEXT(disp, _mesa_BindBufferOffsetEXT); + SET_TransformFeedbackVaryingsEXT(disp, _mesa_TransformFeedbackVaryings); + SET_GetTransformFeedbackVaryingEXT(disp, _mesa_GetTransformFeedbackVarying); +} + + +/** + ** Begin API functions + **/ + void GLAPIENTRY _mesa_BeginTransformFeedback(GLenum mode) { + struct gl_transform_feedback_object *obj; GET_CURRENT_CONTEXT(ctx); + obj = ctx->TransformFeedback.CurrentObject; + switch (mode) { case GL_POINTS: case GL_LINES: @@ -120,29 +323,38 @@ _mesa_BeginTransformFeedback(GLenum mode) return; } - if (ctx->TransformFeedback.Active) { + if (obj->Active) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginTransformFeedback(already active)"); return; } - ctx->TransformFeedback.Active = GL_TRUE; + obj->Active = GL_TRUE; ctx->TransformFeedback.Mode = mode; + + assert(ctx->Driver.BeginTransformFeedback); + ctx->Driver.BeginTransformFeedback(ctx, mode, obj); } void GLAPIENTRY _mesa_EndTransformFeedback(void) { + struct gl_transform_feedback_object *obj; GET_CURRENT_CONTEXT(ctx); - if (!ctx->TransformFeedback.Active) { + obj = ctx->TransformFeedback.CurrentObject; + + if (!obj->Active) { _mesa_error(ctx, GL_INVALID_OPERATION, "glEndTransformFeedback(not active)"); return; } - ctx->TransformFeedback.Active = GL_FALSE; + ctx->TransformFeedback.CurrentObject->Active = GL_FALSE; + + assert(ctx->Driver.EndTransformFeedback); + ctx->Driver.EndTransformFeedback(ctx, obj); } @@ -154,6 +366,9 @@ bind_buffer_range(GLcontext *ctx, GLuint index, struct gl_buffer_object *bufObj, GLintptr offset, GLsizeiptr size) { + struct gl_transform_feedback_object *obj = + ctx->TransformFeedback.CurrentObject; + /* The general binding point */ _mesa_reference_buffer_object(ctx, &ctx->TransformFeedback.CurrentBuffer, @@ -161,13 +376,13 @@ bind_buffer_range(GLcontext *ctx, GLuint index, /* The per-attribute binding point */ _mesa_reference_buffer_object(ctx, - &ctx->TransformFeedback.Buffers[index], + &obj->Buffers[index], bufObj); - ctx->TransformFeedback.BufferNames[index] = bufObj->Name; + obj->BufferNames[index] = bufObj->Name; - ctx->TransformFeedback.Offset[index] = offset; - ctx->TransformFeedback.Size[index] = size; + obj->Offset[index] = offset; + obj->Size[index] = size; } @@ -179,6 +394,7 @@ void GLAPIENTRY _mesa_BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) { + struct gl_transform_feedback_object *obj; struct gl_buffer_object *bufObj; GET_CURRENT_CONTEXT(ctx); @@ -187,7 +403,9 @@ _mesa_BindBufferRange(GLenum target, GLuint index, return; } - if (ctx->TransformFeedback.Active) { + obj = ctx->TransformFeedback.CurrentObject; + + if (obj->Active) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBindBufferRange(transform feedback active)"); return; @@ -235,16 +453,19 @@ _mesa_BindBufferRange(GLenum target, GLuint index, void GLAPIENTRY _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer) { + struct gl_transform_feedback_object *obj; struct gl_buffer_object *bufObj; - GET_CURRENT_CONTEXT(ctx); GLsizeiptr size; + GET_CURRENT_CONTEXT(ctx); if (target != GL_TRANSFORM_FEEDBACK_BUFFER) { _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferBase(target)"); return; } - if (ctx->TransformFeedback.Active) { + obj = ctx->TransformFeedback.CurrentObject; + + if (obj->Active) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBindBufferRange(transform feedback active)"); return; @@ -280,6 +501,7 @@ void GLAPIENTRY _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer, GLintptr offset) { + struct gl_transform_feedback_object *obj; struct gl_buffer_object *bufObj; GET_CURRENT_CONTEXT(ctx); GLsizeiptr size; @@ -289,7 +511,9 @@ _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer, return; } - if (ctx->TransformFeedback.Active) { + obj = ctx->TransformFeedback.CurrentObject; + + if (obj->Active) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBindBufferRange(transform feedback active)"); return; @@ -433,3 +657,250 @@ _mesa_GetTransformFeedbackVarying(GLuint program, GLuint index, } } + + +static struct gl_transform_feedback_object * +lookup_transform_feedback_object(GLcontext *ctx, GLuint name) +{ + if (name == 0) { + return ctx->TransformFeedback.DefaultObject; + } + else + return (struct gl_transform_feedback_object *) + _mesa_HashLookup(ctx->TransformFeedback.Objects, name); +} + + +/** + * Create new transform feedback objects. Transform feedback objects + * encapsulate the state related to transform feedback to allow quickly + * switching state (and drawing the results, below). + * Part of GL_ARB_transform_feedback2. + */ +void GLAPIENTRY +_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names) +{ + GLuint first; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenTransformFeedbacks(n < 0)"); + return; + } + + if (!names) + return; + + /* we don't need contiguous IDs, but this might be faster */ + first = _mesa_HashFindFreeKeyBlock(ctx->TransformFeedback.Objects, n); + if (first) { + GLsizei i; + for (i = 0; i < n; i++) { + struct gl_transform_feedback_object *obj + = ctx->Driver.NewTransformFeedback(ctx, first + i); + if (!obj) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks"); + return; + } + names[i] = first + i; + _mesa_HashInsert(ctx->TransformFeedback.Objects, first + i, obj); + } + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks"); + } +} + + +/** + * Is the given ID a transform feedback object? + * Part of GL_ARB_transform_feedback2. + */ +GLboolean GLAPIENTRY +_mesa_IsTransformFeedback(GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (name && lookup_transform_feedback_object(ctx, name)) + return GL_TRUE; + else + return GL_FALSE; +} + + +/** + * Bind the given transform feedback object. + * Part of GL_ARB_transform_feedback2. + */ +void GLAPIENTRY +_mesa_BindTransformFeedback(GLenum target, GLuint name) +{ + struct gl_transform_feedback_object *obj; + GET_CURRENT_CONTEXT(ctx); + + if (target != GL_TRANSFORM_FEEDBACK) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindTransformFeedback(target)"); + return; + } + + if (ctx->TransformFeedback.CurrentObject->Active && + !ctx->TransformFeedback.CurrentObject->Paused) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindTransformFeedback(transform is active, or not paused)"); + return; + } + + obj = lookup_transform_feedback_object(ctx, name); + if (!obj) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindTransformFeedback(name=%u)", name); + return; + } + + reference_transform_feedback_object(&ctx->TransformFeedback.CurrentObject, + obj); +} + + +/** + * Delete the given transform feedback objects. + * Part of GL_ARB_transform_feedback2. + */ +void GLAPIENTRY +_mesa_DeleteTransformFeedbacks(GLsizei n, const GLuint *names) +{ + GLint i; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteTransformFeedbacks(n < 0)"); + return; + } + + if (!names) + return; + + for (i = 0; i < n; i++) { + if (names[i] > 0) { + struct gl_transform_feedback_object *obj + = lookup_transform_feedback_object(ctx, names[i]); + if (obj) { + if (obj->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDeleteTransformFeedbacks(object %u is active)", + names[i]); + return; + } + _mesa_HashRemove(ctx->TransformFeedback.Objects, names[i]); + /* unref, but object may not be deleted until later */ + reference_transform_feedback_object(&obj, NULL); + } + } + } +} + + +/** + * Pause transform feedback. + * Part of GL_ARB_transform_feedback2. + */ +void GLAPIENTRY +_mesa_PauseTransformFeedback(void) +{ + struct gl_transform_feedback_object *obj; + GET_CURRENT_CONTEXT(ctx); + + obj = ctx->TransformFeedback.CurrentObject; + + if (!obj->Active || obj->Paused) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPauseTransformFeedback(feedback not active or already paused)"); + return; + } + + obj->Paused = GL_TRUE; + + assert(ctx->Driver.PauseTransformFeedback); + ctx->Driver.PauseTransformFeedback(ctx, obj); +} + + +/** + * Resume transform feedback. + * Part of GL_ARB_transform_feedback2. + */ +void GLAPIENTRY +_mesa_ResumeTransformFeedback(void) +{ + struct gl_transform_feedback_object *obj; + GET_CURRENT_CONTEXT(ctx); + + obj = ctx->TransformFeedback.CurrentObject; + + if (!obj->Active || !obj->Paused) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPauseTransformFeedback(feedback not active or not paused)"); + return; + } + + obj->Paused = GL_FALSE; + + assert(ctx->Driver.ResumeTransformFeedback); + ctx->Driver.ResumeTransformFeedback(ctx, obj); +} + + +/** + * Draw the vertex data in a transform feedback object. + * \param mode GL_POINTS, GL_LINES, GL_TRIANGLE_STRIP, etc. + * \param name the transform feedback object + * The number of vertices comes from the transform feedback object. + * User still has to setup of the vertex attribute info with + * glVertexPointer, glColorPointer, etc. + * Part of GL_ARB_transform_feedback2. + */ +void GLAPIENTRY +_mesa_DrawTransformFeedback(GLenum mode, GLuint name) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_transform_feedback_object *obj = + lookup_transform_feedback_object(ctx, name); + + if (mode > GL_POLYGON) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glDrawTransformFeedback(mode=0x%x)", mode); + return; + } + if (!obj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glDrawTransformFeedback(name = %u)", name); + return; + } + + /* XXX check if EndTransformFeedback has never been called while + * the object was bound + */ + + assert(ctx->Driver.DrawTransformFeedback); + ctx->Driver.DrawTransformFeedback(ctx, mode, obj); +} + + +/* +XXX misc to do: + +glGet*() for + +GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED +GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE +GL_TRANSFORM_FEEDBACK_BINDING +*/ + + +#endif /* FEATURE_EXT_transform_feedback */ diff --git a/src/mesa/main/transformfeedback.h b/src/mesa/main/transformfeedback.h index e89cc414736..b806488abdd 100644 --- a/src/mesa/main/transformfeedback.h +++ b/src/mesa/main/transformfeedback.h @@ -25,9 +25,11 @@ #ifndef TRANSFORM_FEEDBACK_H #define TRANSFORM_FEEDBACK_H -#include "glheader.h" +#include "main/mtypes.h" +#if FEATURE_EXT_transform_feedback + extern GLboolean _mesa_validate_primitive_mode(GLcontext *ctx, GLenum mode); @@ -41,6 +43,15 @@ extern void _mesa_free_transform_feedback(GLcontext *ctx); +extern void +_mesa_init_transform_feedback_functions(struct dd_function_table *driver); + +extern void +_mesa_init_transform_feedback_dispatch(struct _glapi_table *disp); + + +/*** GL_EXT_transform_feedback ***/ + extern void GLAPIENTRY _mesa_BeginTransformFeedback(GLenum mode); @@ -68,4 +79,64 @@ _mesa_GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei *size, GLenum *type, GLchar *name); + +/*** GL_ARB_transform_feedback2 ***/ + +extern void GLAPIENTRY +_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names); + +extern GLboolean GLAPIENTRY +_mesa_IsTransformFeedback(GLuint name); + +extern void GLAPIENTRY +_mesa_BindTransformFeedback(GLenum target, GLuint name); + +extern void GLAPIENTRY +_mesa_DeleteTransformFeedbacks(GLsizei n, const GLuint *names); + +extern void GLAPIENTRY +_mesa_PauseTransformFeedback(void); + +extern void GLAPIENTRY +_mesa_ResumeTransformFeedback(void); + +extern void GLAPIENTRY +_mesa_DrawTransformFeedback(GLenum mode, GLuint name); + +#else /* FEATURE_EXT_transform_feedback */ + +static INLINE GLboolean +_mesa_validate_primitive_mode(GLcontext *ctx, GLenum mode) +{ + return GL_TRUE; +} + +static INLINE GLboolean +_mesa_validate_transform_feedback_buffers(GLcontext *ctx) +{ + return GL_TRUE; +} + +static INLINE void +_mesa_init_transform_feedback(GLcontext *ctx) +{ +} + +static INLINE void +_mesa_free_transform_feedback(GLcontext *ctx) +{ +} + +static INLINE void +_mesa_init_transform_feedback_functions(struct dd_function_table *driver) +{ +} + +static INLINE void +_mesa_init_transform_feedback_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_EXT_transform_feedback */ + #endif /* TRANSFORM_FEEDBACK_H */ diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c index 4b33d0bbb37..048b231c4ed 100644 --- a/src/mesa/math/m_matrix.c +++ b/src/mesa/math/m_matrix.c @@ -804,8 +804,8 @@ _math_matrix_rotate( GLmatrix *mat, GLfloat m[16]; GLboolean optimized; - s = (GLfloat) _mesa_sin( angle * DEG2RAD ); - c = (GLfloat) _mesa_cos( angle * DEG2RAD ); + s = (GLfloat) sin( angle * DEG2RAD ); + c = (GLfloat) cos( angle * DEG2RAD ); memcpy(m, Identity, sizeof(GLfloat)*16); optimized = GL_FALSE; diff --git a/src/mesa/shader/atifragshader.c b/src/mesa/shader/atifragshader.c index 870f77e30dc..21bb9589cb0 100644 --- a/src/mesa/shader/atifragshader.c +++ b/src/mesa/shader/atifragshader.c @@ -28,13 +28,36 @@ #include "main/macros.h" #include "main/enums.h" #include "main/mtypes.h" +#include "main/dispatch.h" #include "atifragshader.h" +#if FEATURE_ATI_fragment_shader + #define MESA_DEBUG_ATI_FS 0 static struct ati_fragment_shader DummyShader; +void +_mesa_init_ati_fragment_shader_dispatch(struct _glapi_table *disp) +{ + SET_GenFragmentShadersATI(disp, _mesa_GenFragmentShadersATI); + SET_BindFragmentShaderATI(disp, _mesa_BindFragmentShaderATI); + SET_DeleteFragmentShaderATI(disp, _mesa_DeleteFragmentShaderATI); + SET_BeginFragmentShaderATI(disp, _mesa_BeginFragmentShaderATI); + SET_EndFragmentShaderATI(disp, _mesa_EndFragmentShaderATI); + SET_PassTexCoordATI(disp, _mesa_PassTexCoordATI); + SET_SampleMapATI(disp, _mesa_SampleMapATI); + SET_ColorFragmentOp1ATI(disp, _mesa_ColorFragmentOp1ATI); + SET_ColorFragmentOp2ATI(disp, _mesa_ColorFragmentOp2ATI); + SET_ColorFragmentOp3ATI(disp, _mesa_ColorFragmentOp3ATI); + SET_AlphaFragmentOp1ATI(disp, _mesa_AlphaFragmentOp1ATI); + SET_AlphaFragmentOp2ATI(disp, _mesa_AlphaFragmentOp2ATI); + SET_AlphaFragmentOp3ATI(disp, _mesa_AlphaFragmentOp3ATI); + SET_SetFragmentShaderConstantATI(disp, _mesa_SetFragmentShaderConstantATI); +} + + /** * Allocate and initialize a new ATI fragment shader object. */ @@ -767,3 +790,5 @@ _mesa_SetFragmentShaderConstantATI(GLuint dst, const GLfloat * value) COPY_4V(ctx->ATIFragmentShader.GlobalConstants[dstindex], value); } } + +#endif /* FEATURE_ATI_fragment_shader */ diff --git a/src/mesa/shader/atifragshader.h b/src/mesa/shader/atifragshader.h index e1dc20e6065..31c335ec815 100644 --- a/src/mesa/shader/atifragshader.h +++ b/src/mesa/shader/atifragshader.h @@ -60,6 +60,11 @@ struct atifs_setupinst }; +#if FEATURE_ATI_fragment_shader + +extern void +_mesa_init_ati_fragment_shader_dispatch(struct _glapi_table *disp); + extern struct ati_fragment_shader * _mesa_new_ati_fragment_shader(GLcontext *ctx, GLuint id); @@ -120,4 +125,25 @@ _mesa_AlphaFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, extern void GLAPIENTRY _mesa_SetFragmentShaderConstantATI(GLuint dst, const GLfloat * value); -#endif +#else /* FEATURE_ATI_fragment_shader */ + +static INLINE void +_mesa_init_ati_fragment_shader_dispatch(struct _glapi_table *disp) +{ +} + +static INLINE struct ati_fragment_shader * +_mesa_new_ati_fragment_shader(GLcontext *ctx, GLuint id) +{ + return NULL; +} + +static INLINE void +_mesa_delete_ati_fragment_shader(GLcontext *ctx, + struct ati_fragment_shader *s) +{ +} + +#endif /* FEATURE_ATI_fragment_shader */ + +#endif /* ATIFRAGSHADER_H */ diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index 0067512cfb2..f85c6513f31 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -762,7 +762,7 @@ _mesa_execute_program(GLcontext * ctx, GLfloat a[4], result[4]; fetch_vector1(&inst->SrcReg[0], machine, a); result[0] = result[1] = result[2] = result[3] - = (GLfloat) _mesa_cos(a[0]); + = (GLfloat) cos(a[0]); store_vector4(inst, machine, result); } break; @@ -876,7 +876,7 @@ _mesa_execute_program(GLcontext * ctx, * result.z = result.x * APPX(result.y) * We do what the ARB extension says. */ - q[2] = (GLfloat) _mesa_pow(2.0, t[0]); + q[2] = (GLfloat) pow(2.0, t[0]); } q[1] = t[0] - floor_t0; q[3] = 1.0F; @@ -887,7 +887,7 @@ _mesa_execute_program(GLcontext * ctx, { GLfloat a[4], result[4], val; fetch_vector1(&inst->SrcReg[0], machine, a); - val = (GLfloat) _mesa_pow(2.0, a[0]); + val = (GLfloat) pow(2.0, a[0]); /* if (IS_INF_OR_NAN(val)) val = 1.0e10; @@ -1009,7 +1009,7 @@ _mesa_execute_program(GLcontext * ctx, if (a[1] == 0.0 && a[3] == 0.0) result[2] = 1.0F; else - result[2] = (GLfloat) _mesa_pow(a[1], a[3]); + result[2] = (GLfloat) pow(a[1], a[3]); } else { result[2] = 0.0F; @@ -1336,7 +1336,7 @@ _mesa_execute_program(GLcontext * ctx, fetch_vector1(&inst->SrcReg[0], machine, a); fetch_vector1(&inst->SrcReg[1], machine, b); result[0] = result[1] = result[2] = result[3] - = (GLfloat) _mesa_pow(a[0], b[0]); + = (GLfloat) pow(a[0], b[0]); store_vector4(inst, machine, result); } break; @@ -1393,8 +1393,8 @@ _mesa_execute_program(GLcontext * ctx, { GLfloat a[4], result[4]; fetch_vector1(&inst->SrcReg[0], machine, a); - result[0] = (GLfloat) _mesa_cos(a[0]); - result[1] = (GLfloat) _mesa_sin(a[0]); + result[0] = (GLfloat) cos(a[0]); + result[1] = (GLfloat) sin(a[0]); result[2] = 0.0; /* undefined! */ result[3] = 0.0; /* undefined! */ store_vector4(inst, machine, result); @@ -1465,7 +1465,7 @@ _mesa_execute_program(GLcontext * ctx, GLfloat a[4], result[4]; fetch_vector1(&inst->SrcReg[0], machine, a); result[0] = result[1] = result[2] = result[3] - = (GLfloat) _mesa_sin(a[0]); + = (GLfloat) sin(a[0]); store_vector4(inst, machine, result); } break; diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 4ff032d4ec8..f47f213ac84 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -1517,12 +1517,14 @@ static void _mesa_link_program(GLcontext *ctx, GLuint program) { struct gl_shader_program *shProg; + struct gl_transform_feedback_object *obj = + ctx->TransformFeedback.CurrentObject; shProg = _mesa_lookup_shader_program_err(ctx, program, "glLinkProgram"); if (!shProg) return; - if (ctx->TransformFeedback.Active && shProg == ctx->Shader.CurrentProgram) { + if (obj->Active && shProg == ctx->Shader.CurrentProgram) { _mesa_error(ctx, GL_INVALID_OPERATION, "glLinkProgram(transform feedback active"); return; @@ -1591,8 +1593,10 @@ void _mesa_use_program(GLcontext *ctx, GLuint program) { struct gl_shader_program *shProg; + struct gl_transform_feedback_object *obj = + ctx->TransformFeedback.CurrentObject; - if (ctx->TransformFeedback.Active) { + if (obj->Active) { _mesa_error(ctx, GL_INVALID_OPERATION, "glUseProgram(transform feedback active)"); return; @@ -1749,7 +1753,8 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program, /* check that the sampler (tex unit index) is legal */ if (texUnit >= ctx->Const.MaxTextureImageUnits) { _mesa_error(ctx, GL_INVALID_VALUE, - "glUniform1(invalid sampler/tex unit index)"); + "glUniform1(invalid sampler/tex unit index for '%s')", + param->Name); return; } @@ -1797,7 +1802,8 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program, /* non-array: count must be at most one; count == 0 is handled by the loop below */ if (count > 1) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glUniform(uniform is not an array)"); + "glUniform(uniform '%s' is not an array)", + param->Name); return; } } @@ -1860,14 +1866,15 @@ _mesa_uniform(GLcontext *ctx, GLint location, GLsizei count, return; /* The standard specifies this as a no-op */ if (location < -1) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(location)"); + _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(location=%d)", + location); return; } split_location_offset(&location, &offset); if (location < 0 || location >= (GLint) shProg->Uniforms->NumUniforms) { - _mesa_error(ctx, GL_INVALID_VALUE, "glUniform(location)"); + _mesa_error(ctx, GL_INVALID_VALUE, "glUniform(location=%d)", location); return; } diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak index b69e7eeae51..74563bcf96e 100644 --- a/src/mesa/sources.mak +++ b/src/mesa/sources.mak @@ -1,12 +1,9 @@ ### Lists of source files, included by Makefiles -ES1_SOURCES = \ +# this is part of MAIN_SOURCES +MAIN_ES_SOURCES = \ main/api_exec_es1.c \ - main/get_es1.c - -ES2_SOURCES = \ - main/api_exec_es2.c \ - main/get_es2.c + main/api_exec_es2.c MAIN_SOURCES = \ main/api_arrayelt.c \ @@ -65,7 +62,6 @@ MAIN_SOURCES = \ main/queryobj.c \ main/querymatrix.c \ main/rastpos.c \ - main/rbadaptors.c \ main/readpix.c \ main/remap.c \ main/renderbuffer.c \ @@ -96,16 +92,7 @@ MAIN_SOURCES = \ main/version.c \ main/viewport.c \ main/vtxfmt.c \ - $(ES_SOURCES) - -GLAPI_SOURCES = \ - glapi/glapi.c \ - glapi/glapi_dispatch.c \ - glapi/glapi_entrypoint.c \ - glapi/glapi_execmem.c \ - glapi/glapi_getproc.c \ - glapi/glapi_nop.c \ - glapi/glthread.c + $(MAIN_ES_SOURCES) MATH_SOURCES = \ math/m_debug_clip.c \ @@ -222,6 +209,7 @@ STATETRACKER_SOURCES = \ state_tracker/st_cb_readpixels.c \ state_tracker/st_cb_strings.c \ state_tracker/st_cb_texture.c \ + state_tracker/st_cb_xformfb.c \ state_tracker/st_context.c \ state_tracker/st_debug.c \ state_tracker/st_draw.c \ @@ -310,23 +298,14 @@ X86_SOURCES = \ x86/sse_normal.S \ x86/read_rgba_span_x86.S -X86_API = \ - x86/glapi_x86.S - X86-64_SOURCES = \ x86-64/xform4.S -X86-64_API = \ - x86-64/glapi_x86-64.S - SPARC_SOURCES = \ sparc/clip.S \ sparc/norm.S \ sparc/xform.S -SPARC_API = \ - sparc/glapi_sparc.S - COMMON_DRIVER_SOURCES = \ drivers/common/driverfuncs.c \ drivers/common/meta.c @@ -360,7 +339,6 @@ MESA_GALLIUM_SOURCES = \ # All the core C sources, for dependency checking ALL_SOURCES = \ $(MESA_SOURCES) \ - $(GLAPI_SOURCES) \ $(MESA_ASM_SOURCES) \ $(STATETRACKER_SOURCES) @@ -375,10 +353,6 @@ MESA_GALLIUM_OBJECTS = \ $(MESA_GALLIUM_SOURCES:.c=.o) \ $(MESA_ASM_SOURCES:.S=.o) -GLAPI_OBJECTS = \ - $(GLAPI_SOURCES:.c=.o) \ - $(GLAPI_ASM_SOURCES:.S=.o) - COMMON_DRIVER_OBJECTS = $(COMMON_DRIVER_SOURCES:.c=.o) @@ -395,5 +369,6 @@ GLSL_LIBS = \ INCLUDE_DIRS = \ -I$(TOP)/include \ -I$(TOP)/src/mesa \ + -I$(TOP)/src/mapi \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/auxiliary diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index a8f2b879d53..28439103b23 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -44,7 +44,6 @@ #include "st_atom.h" #include "st_atom_constbuf.h" #include "st_program.h" -#include "st_inlines.h" /** @@ -84,7 +83,7 @@ void st_upload_constants( struct st_context *st, } /* load Mesa constants into the constant buffer */ - st_no_flush_pipe_buffer_write(st, *cbuf, + pipe_buffer_write(st->pipe, *cbuf, 0, paramBytes, params->ParameterValues); diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index 323de8a8bd3..b8644faaf83 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -44,10 +44,10 @@ #include "st_context.h" #include "st_format.h" #include "st_texture.h" -#include "st_inlines.h" #include "pipe/p_screen.h" #include "pipe/p_context.h" +#include "util/u_inlines.h" #include "util/u_pack_color.h" @@ -149,7 +149,7 @@ load_color_map_texture(GLcontext *ctx, struct pipe_resource *pt) uint *dest; uint i, j; - transfer = st_cond_flush_get_tex_transfer(st_context(ctx), + transfer = pipe_get_transfer(st_context(ctx)->pipe, pt, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, texSize, texSize); dest = (uint *) pipe_transfer_map(pipe, transfer); diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 5669b1f82af..2599bd5ca03 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -53,21 +53,6 @@ static GLuint translate_fill( GLenum mode ) } } -static GLboolean get_offset_flag( GLuint fill_mode, - const struct gl_polygon_attrib *p ) -{ - switch (fill_mode) { - case PIPE_POLYGON_MODE_POINT: - return p->OffsetPoint; - case PIPE_POLYGON_MODE_LINE: - return p->OffsetLine; - case PIPE_POLYGON_MODE_FILL: - return p->OffsetFill; - default: - assert(0); - return 0; - } -} static void update_raster_state( struct st_context *st ) @@ -82,10 +67,7 @@ static void update_raster_state( struct st_context *st ) /* _NEW_POLYGON, _NEW_BUFFERS */ { - if (ctx->Polygon.FrontFace == GL_CCW) - raster->front_winding = PIPE_WINDING_CCW; - else - raster->front_winding = PIPE_WINDING_CW; + raster->front_ccw = (ctx->Polygon.FrontFace == GL_CCW); /* XXX * I think the intention here is that user-created framebuffer objects @@ -94,7 +76,7 @@ static void update_raster_state( struct st_context *st ) * But this is an implementation/driver-specific artifact - remove... */ if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0) - raster->front_winding ^= PIPE_WINDING_BOTH; + raster->front_ccw ^= 1; } /* _NEW_LIGHT @@ -131,40 +113,36 @@ static void update_raster_state( struct st_context *st ) /* _NEW_POLYGON */ if (ctx->Polygon.CullFlag) { - if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) { - raster->cull_mode = PIPE_WINDING_BOTH; - } - else if (ctx->Polygon.CullFaceMode == GL_FRONT) { - raster->cull_mode = raster->front_winding; - } - else { - raster->cull_mode = raster->front_winding ^ PIPE_WINDING_BOTH; + switch (ctx->Polygon.CullFaceMode) { + case GL_FRONT: + raster->cull_face = PIPE_FACE_FRONT; + break; + case GL_BACK: + raster->cull_face = PIPE_FACE_BACK; + break; + case GL_FRONT_AND_BACK: + raster->cull_face = PIPE_FACE_FRONT_AND_BACK; + break; } } + else { + raster->cull_face = PIPE_FACE_NONE; + } /* _NEW_POLYGON */ { - GLuint fill_front = translate_fill( ctx->Polygon.FrontMode ); - GLuint fill_back = translate_fill( ctx->Polygon.BackMode ); - - if (raster->front_winding == PIPE_WINDING_CW) { - raster->fill_cw = fill_front; - raster->fill_ccw = fill_back; - } - else { - raster->fill_cw = fill_back; - raster->fill_ccw = fill_front; - } + raster->fill_front = translate_fill( ctx->Polygon.FrontMode ); + raster->fill_back = translate_fill( ctx->Polygon.BackMode ); /* Simplify when culling is active: */ - if (raster->cull_mode & PIPE_WINDING_CW) { - raster->fill_cw = raster->fill_ccw; + if (raster->cull_face & PIPE_FACE_FRONT) { + raster->fill_front = raster->fill_back; } - if (raster->cull_mode & PIPE_WINDING_CCW) { - raster->fill_ccw = raster->fill_cw; + if (raster->cull_face & PIPE_FACE_BACK) { + raster->fill_back = raster->fill_front; } } @@ -172,8 +150,14 @@ static void update_raster_state( struct st_context *st ) */ if (ctx->Polygon.OffsetUnits != 0.0 || ctx->Polygon.OffsetFactor != 0.0) { - raster->offset_cw = get_offset_flag( raster->fill_cw, &ctx->Polygon ); - raster->offset_ccw = get_offset_flag( raster->fill_ccw, &ctx->Polygon ); + raster->offset_point = ctx->Polygon.OffsetPoint; + raster->offset_line = ctx->Polygon.OffsetLine; + raster->offset_tri = ctx->Polygon.OffsetFill; + } + + if (ctx->Polygon.OffsetPoint || + ctx->Polygon.OffsetLine || + ctx->Polygon.OffsetFill) { raster->offset_units = ctx->Polygon.OffsetUnits; raster->offset_scale = ctx->Polygon.OffsetFactor; } diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 0101837f999..425e7987d33 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -39,13 +39,14 @@ #include "st_cb_accum.h" #include "st_cb_fbo.h" #include "st_texture.h" -#include "st_inlines.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "util/u_inlines.h" #include "util/u_tile.h" +#if FEATURE_accum + /** * For hardware that supports deep color buffers, we could accelerate * most/all the accum operations with blending/texturing. @@ -136,7 +137,7 @@ accum_accum(struct st_context *st, GLfloat value, if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s: fallback processing\n", __FUNCTION__); - color_trans = st_cond_flush_get_tex_transfer(st, + color_trans = pipe_get_transfer(st->pipe, color_strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, xpos, ypos, @@ -185,7 +186,7 @@ accum_load(struct st_context *st, GLfloat value, if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s: fallback processing\n", __FUNCTION__); - color_trans = st_cond_flush_get_tex_transfer(st, color_strb->texture, + color_trans = pipe_get_transfer(st->pipe, color_strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, xpos, ypos, width, height); @@ -241,7 +242,7 @@ accum_return(GLcontext *ctx, GLfloat value, else usage = PIPE_TRANSFER_WRITE; - color_trans = st_cond_flush_get_tex_transfer(st_context(ctx), + color_trans = pipe_get_transfer(st_context(ctx)->pipe, color_strb->texture, 0, 0, 0, usage, xpos, ypos, @@ -301,9 +302,6 @@ st_Accum(GLcontext *ctx, GLenum op, GLfloat value) if(!acc_strb->data) return; - /* make sure color bufs aren't cached */ - st_flush( st, PIPE_FLUSH_RENDER_CACHE, NULL ); - switch (op) { case GL_ADD: if (value != 0.0F) { @@ -337,3 +335,5 @@ void st_init_accum_functions(struct dd_function_table *functions) { functions->Accum = st_Accum; } + +#endif /* FEATURE_accum */ diff --git a/src/mesa/state_tracker/st_cb_accum.h b/src/mesa/state_tracker/st_cb_accum.h index ed9b7dab943..7d52481c82e 100644 --- a/src/mesa/state_tracker/st_cb_accum.h +++ b/src/mesa/state_tracker/st_cb_accum.h @@ -30,10 +30,28 @@ #define ST_CB_ACCUM_H +#include "main/mtypes.h" + +#if FEATURE_accum + extern void st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb); extern void st_init_accum_functions(struct dd_function_table *functions); +#else + +static INLINE void +st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) +{ + ASSERT_NO_FEATURE(); +} + +static INLINE void +st_init_accum_functions(struct dd_function_table *functions) +{ +} + +#endif /* FEATURE_accum */ #endif /* ST_CB_ACCUM_H */ diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 1b3787828e1..5aca1105eeb 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -43,7 +43,6 @@ #include "st_program.h" #include "st_cb_bitmap.h" #include "st_texture.h" -#include "st_inlines.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" @@ -54,6 +53,7 @@ #include "cso_cache/cso_context.h" +#if FEATURE_drawpix /** * glBitmaps are drawn as textured quads. The user's bitmap pattern @@ -282,7 +282,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, return NULL; } - transfer = st_no_flush_get_tex_transfer(st, pt, 0, 0, 0, + transfer = pipe_get_transfer(st->pipe, pt, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, width, height); @@ -382,7 +382,7 @@ setup_bitmap_vertex_data(struct st_context *st, } /* put vertex data into vbuf */ - st_no_flush_pipe_buffer_write_nooverlap(st, + pipe_buffer_write_nooverlap(st->pipe, st->bitmap.vbuf, st->bitmap.vbuf_slot * sizeof st->bitmap.vertices, sizeof st->bitmap.vertices, @@ -579,7 +579,7 @@ create_cache_trans(struct st_context *st) /* Map the texture transfer. * Subsequent glBitmap calls will write into the texture image. */ - cache->trans = st_no_flush_get_tex_transfer(st, cache->texture, 0, 0, 0, + cache->trans = pipe_get_transfer(st->pipe, cache->texture, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT); @@ -860,3 +860,5 @@ st_destroy_bitmap(struct st_context *st) st->bitmap.cache = NULL; } } + +#endif /* FEATURE_drawpix */ diff --git a/src/mesa/state_tracker/st_cb_bitmap.h b/src/mesa/state_tracker/st_cb_bitmap.h index 81cf61981dc..8af975b74fc 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.h +++ b/src/mesa/state_tracker/st_cb_bitmap.h @@ -30,6 +30,10 @@ #define ST_CB_BITMAP_H +#include "main/mtypes.h" + +#if FEATURE_drawpix + extern void st_init_bitmap_functions(struct dd_function_table *functions); @@ -48,5 +52,33 @@ st_flush_bitmap_cache(struct st_context *st); extern void st_flush_bitmap(struct st_context *st); +#else + +static INLINE void +st_init_bitmap_functions(struct dd_function_table *functions) +{ +} + +static INLINE void +st_init_bitmap(struct st_context *st) +{ +} + +static INLINE void +st_destroy_bitmap(struct st_context *st) +{ +} + +static INLINE void +st_flush_bitmap_cache(struct st_context *st) +{ +} + +static INLINE void +st_flush_bitmap(struct st_context *st) +{ +} + +#endif /* FEATURE_drawpix */ #endif /* ST_CB_BITMAP_H */ diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c index 3a34bdfe9a4..fb7b48a7bf6 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -60,6 +60,7 @@ st_destroy_blit(struct st_context *st) #if FEATURE_EXT_framebuffer_blit + static void st_BlitFramebuffer(GLcontext *ctx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, @@ -205,14 +206,12 @@ st_BlitFramebuffer(GLcontext *ctx, } } } -#endif /* FEATURE_EXT_framebuffer_blit */ - void st_init_blit_functions(struct dd_function_table *functions) { -#if FEATURE_EXT_framebuffer_blit functions->BlitFramebuffer = st_BlitFramebuffer; -#endif } + +#endif /* FEATURE_EXT_framebuffer_blit */ diff --git a/src/mesa/state_tracker/st_cb_blit.h b/src/mesa/state_tracker/st_cb_blit.h index ed22986b531..7ab9a54df90 100644 --- a/src/mesa/state_tracker/st_cb_blit.h +++ b/src/mesa/state_tracker/st_cb_blit.h @@ -29,18 +29,28 @@ #define ST_CB_BLIT_H +#include "main/mtypes.h" #include "st_context.h" - extern void st_init_blit(struct st_context *st); extern void st_destroy_blit(struct st_context *st); +#if FEATURE_EXT_framebuffer_blit + extern void st_init_blit_functions(struct dd_function_table *functions); +#else + +static INLINE void +st_init_blit_functions(struct dd_function_table *functions) +{ +} + +#endif /* FEATURE_EXT_framebuffer_blit */ #endif /* ST_CB_BLIT_H */ diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index b883c071f7e..7991a93a1e6 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -36,7 +36,6 @@ #include "main/arrayobj.h" #include "main/bufferobj.h" -#include "st_inlines.h" #include "st_context.h" #include "st_cb_bufferobjects.h" @@ -202,7 +201,7 @@ st_bufferobj_data(GLcontext *ctx, } if (data) - st_no_flush_pipe_buffer_write(st_context(ctx), st_obj->buffer, 0, + pipe_buffer_write(st_context(ctx)->pipe, st_obj->buffer, 0, size, data); return GL_TRUE; } diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 736180ddc6c..7e3b87351f1 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -43,7 +43,6 @@ #include "st_cb_clear.h" #include "st_cb_fbo.h" #include "st_program.h" -#include "st_inlines.h" #include "pipe/p_context.h" #include "pipe/p_state.h" @@ -163,7 +162,7 @@ draw_quad(struct st_context *st, } /* put vertex data into vbuf */ - st_no_flush_pipe_buffer_write_nooverlap(st, st->clear.vbuf, + pipe_buffer_write_nooverlap(st->pipe, st->clear.vbuf, st->clear.vbuf_slot * sizeof(st->clear.vertices), sizeof(st->clear.vertices), diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index ad20004d369..f74d8cd42d0 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -49,7 +49,6 @@ #include "st_cb_fbo.h" #include "st_format.h" #include "st_texture.h" -#include "st_inlines.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" @@ -63,6 +62,8 @@ #include "cso_cache/cso_context.h" +#if FEATURE_drawpix + /** * Check if the given program is: * 0: MOVE result.color, fragment.color; @@ -384,7 +385,7 @@ make_texture(struct st_context *st, /* we'll do pixel transfer in a fragment shader */ ctx->_ImageTransferState = 0x0; - transfer = st_no_flush_get_tex_transfer(st, pt, 0, 0, 0, + transfer = pipe_get_transfer(st->pipe, pt, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, width, height); @@ -508,7 +509,7 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, buf = pipe_buffer_create(pipe->screen, PIPE_BIND_VERTEX_BUFFER, sizeof(verts)); - st_no_flush_pipe_buffer_write(st, buf, 0, sizeof(verts), verts); + pipe_buffer_write(st->pipe, buf, 0, sizeof(verts), verts); util_draw_vertex_buffer(pipe, buf, 0, PIPE_PRIM_QUADS, @@ -685,7 +686,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, else usage = PIPE_TRANSFER_WRITE; - pt = st_cond_flush_get_tex_transfer(st_context(ctx), strb->texture, 0, 0, 0, + pt = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0, 0, usage, x, y, width, height); @@ -885,7 +886,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, dsty = rbDraw->Base.Height - dsty - height; } - ptDraw = st_cond_flush_get_tex_transfer(st_context(ctx), + ptDraw = pipe_get_transfer(st_context(ctx)->pipe, rbDraw->texture, 0, 0, 0, usage, dstx, dsty, width, height); @@ -971,8 +972,6 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, GLuint sample_count; struct gl_pixelstore_attrib pack = ctx->DefaultPacking; - pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); - st_validate_state(st); if (type == GL_STENCIL) { @@ -1075,7 +1074,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, else { /* CPU-based fallback/conversion */ struct pipe_transfer *ptRead = - st_cond_flush_get_tex_transfer(st, rbRead->texture, 0, 0, 0, + pipe_get_transfer(st->pipe, rbRead->texture, 0, 0, 0, PIPE_TRANSFER_READ, readX, readY, readW, readH); struct pipe_transfer *ptTex; @@ -1089,7 +1088,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, else transfer_usage = PIPE_TRANSFER_WRITE; - ptTex = st_cond_flush_get_tex_transfer(st, pt, 0, 0, 0, transfer_usage, + ptTex = pipe_get_transfer(st->pipe, pt, 0, 0, 0, transfer_usage, 0, 0, width, height); /* copy image from ptRead surface to ptTex surface */ @@ -1143,7 +1142,9 @@ st_destroy_drawpix(struct st_context *st) st_reference_fragprog(st, &st->drawpix.z_shader, NULL); st_reference_fragprog(st, &st->pixel_xfer.combined_prog, NULL); if (st->drawpix.vert_shaders[0]) - free(st->drawpix.vert_shaders[0]); + ureg_free_tokens(st->drawpix.vert_shaders[0]); if (st->drawpix.vert_shaders[1]) - free(st->drawpix.vert_shaders[1]); + ureg_free_tokens(st->drawpix.vert_shaders[1]); } + +#endif /* FEATURE_drawpix */ diff --git a/src/mesa/state_tracker/st_cb_drawpixels.h b/src/mesa/state_tracker/st_cb_drawpixels.h index 26fe864d185..7d5e901ccc5 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.h +++ b/src/mesa/state_tracker/st_cb_drawpixels.h @@ -30,10 +30,27 @@ #define ST_CB_DRAWPIXELS_H +#include "main/mtypes.h" + +#if FEATURE_drawpix + extern void st_init_drawpixels_functions(struct dd_function_table *functions); extern void st_destroy_drawpix(struct st_context *st); +#else + +static INLINE void +st_init_drawpixels_functions(struct dd_function_table *functions) +{ +} + +static INLINE void +st_destroy_drawpix(struct st_context *st) +{ +} + +#endif /* FEATURE_drawpix */ #endif /* ST_CB_DRAWPIXELS_H */ diff --git a/src/mesa/state_tracker/st_cb_drawtex.c b/src/mesa/state_tracker/st_cb_drawtex.c index 6d387d5ccf1..3d99d6c8a11 100644 --- a/src/mesa/state_tracker/st_cb_drawtex.c +++ b/src/mesa/state_tracker/st_cb_drawtex.c @@ -15,34 +15,29 @@ #include "main/imports.h" #include "main/image.h" #include "main/bufferobj.h" -#include "main/drawtex.h" #include "main/macros.h" -#include "main/state.h" -#include "main/texformat.h" #include "shader/program.h" -#include "shader/prog_parameter.h" #include "shader/prog_print.h" #include "st_context.h" #include "st_atom.h" -#include "st_atom_constbuf.h" -#include "st_draw.h" #include "st_cb_drawtex.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "util/u_inlines.h" #include "pipe/p_shader_tokens.h" -#include "util/u_tile.h" #include "util/u_draw_quad.h" #include "util/u_simple_shaders.h" #include "cso_cache/cso_context.h" +#if FEATURE_OES_draw_texture + + struct cached_shader { - //struct pipe_shader_state shader; void *handle; uint num_attribs; @@ -60,9 +55,6 @@ static struct cached_shader CachedShaders[MAX_SHADERS]; static GLuint NumCachedShaders = 0; -#if FEATURE_OES_draw_texture - - static void * lookup_shader(struct pipe_context *pipe, uint num_attribs, @@ -288,13 +280,10 @@ st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, } -#endif /* FEATURE_OES_draw_texture */ - - void st_init_drawtex_functions(struct dd_function_table *functions) { - _MESA_INIT_DRAWTEX_FUNCTIONS(functions, st_); + functions->DrawTex = st_DrawTex; } @@ -310,3 +299,6 @@ st_destroy_drawtex(struct st_context *st) } NumCachedShaders = 0; } + + +#endif /* FEATURE_OES_draw_texture */ diff --git a/src/mesa/state_tracker/st_cb_drawtex.h b/src/mesa/state_tracker/st_cb_drawtex.h index 7b0da702798..a3f54a349cc 100644 --- a/src/mesa/state_tracker/st_cb_drawtex.h +++ b/src/mesa/state_tracker/st_cb_drawtex.h @@ -9,10 +9,29 @@ #ifndef ST_CB_DRAWTEX_H #define ST_CB_DRAWTEX_H + +#include "main/mtypes.h" + +#if FEATURE_OES_draw_texture + extern void st_init_drawtex_functions(struct dd_function_table *functions); extern void st_destroy_drawtex(struct st_context *st); +#else + +static INLINE void +st_init_drawtex_functions(struct dd_function_table *functions) +{ +} + +static INLINE void +st_destroy_drawtex(struct st_context *st) +{ +} + +#endif /* FEATURE_OES_draw_texture */ + #endif /* ST_CB_DRAWTEX_H */ diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c index 91a42fafd19..4aaf91d5a19 100644 --- a/src/mesa/state_tracker/st_cb_eglimage.c +++ b/src/mesa/state_tracker/st_cb_eglimage.c @@ -129,6 +129,10 @@ st_bind_surface(GLcontext *ctx, GLenum target, /* FIXME create a non-default sampler view from the pipe_surface? */ pipe_resource_reference(&stImage->pt, ps->texture); + stObj->width0 = ps->width; + stObj->height0 = ps->height; + stObj->depth0 = 1; + _mesa_dirty_texobj(ctx, texObj, GL_TRUE); } diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index c85d3da84a2..e57730b5ecd 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -54,6 +54,8 @@ #include "draw/draw_pipe.h" +#if FEATURE_feedback + /** * This is actually used for both feedback and selection. */ @@ -302,3 +304,5 @@ void st_init_feedback_functions(struct dd_function_table *functions) { functions->RenderMode = st_RenderMode; } + +#endif /* FEATURE_feedback */ diff --git a/src/mesa/state_tracker/st_cb_feedback.h b/src/mesa/state_tracker/st_cb_feedback.h index 2559ba3817b..706d84960f7 100644 --- a/src/mesa/state_tracker/st_cb_feedback.h +++ b/src/mesa/state_tracker/st_cb_feedback.h @@ -30,8 +30,20 @@ #define ST_CB_FEEDBACK_H +#include "main/mtypes.h" + +#if FEATURE_feedback + extern void st_init_feedback_functions(struct dd_function_table *functions); +#else + +static INLINE void +st_init_feedback_functions(struct dd_function_table *functions) +{ +} + +#endif /* FEATURE_feedback */ #endif /* ST_CB_FEEDBACK_H */ diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c index 1896663932c..e423d9d8a51 100644 --- a/src/mesa/state_tracker/st_cb_queryobj.c +++ b/src/mesa/state_tracker/st_cb_queryobj.c @@ -43,6 +43,8 @@ #include "st_cb_queryobj.h" +#if FEATURE_queryobj + static struct gl_query_object * st_NewQueryObject(GLcontext *ctx, GLuint id) { @@ -51,6 +53,7 @@ st_NewQueryObject(GLcontext *ctx, GLuint id) stq->base.Id = id; stq->base.Ready = GL_TRUE; stq->pq = NULL; + stq->type = PIPE_QUERY_TYPES; /* an invalid value */ return &stq->base; } return NULL; @@ -78,17 +81,41 @@ st_BeginQuery(GLcontext *ctx, struct gl_query_object *q) { struct pipe_context *pipe = st_context(ctx)->pipe; struct st_query_object *stq = st_query_object(q); + unsigned type; + /* convert GL query type to Gallium query type */ switch (q->Target) { case GL_SAMPLES_PASSED_ARB: - if (!stq->pq) - stq->pq = pipe->create_query( pipe, PIPE_QUERY_OCCLUSION_COUNTER ); + type = PIPE_QUERY_OCCLUSION_COUNTER; + break; + case GL_PRIMITIVES_GENERATED: + type = PIPE_QUERY_PRIMITIVES_GENERATED; + break; + case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: + type = PIPE_QUERY_PRIMITIVES_EMITTED; + break; + case GL_TIME_ELAPSED_EXT: + type = PIPE_QUERY_TIME_ELAPSED; break; default: - assert(0); + assert(0 && "unexpected query target in st_BeginQuery()"); return; } + if (stq->pq && stq->type != type) { + /* free old query of different type */ + pipe->destroy_query(pipe, stq->pq); + stq->pq = NULL; + stq->type = PIPE_QUERY_TYPES; /* an invalid value */ + } + + if (!stq->pq) { + stq->pq = pipe->create_query(pipe, type); + stq->type = type; + } + + assert(stq->type == type); + pipe->begin_query(pipe, stq->pq); } @@ -146,3 +173,5 @@ void st_init_query_functions(struct dd_function_table *functions) functions->WaitQuery = st_WaitQuery; functions->CheckQuery = st_CheckQuery; } + +#endif /* FEATURE_queryobj */ diff --git a/src/mesa/state_tracker/st_cb_queryobj.h b/src/mesa/state_tracker/st_cb_queryobj.h index fa256b71824..017471b0b06 100644 --- a/src/mesa/state_tracker/st_cb_queryobj.h +++ b/src/mesa/state_tracker/st_cb_queryobj.h @@ -29,6 +29,8 @@ #define ST_CB_QUERYOBJ_H +#include "main/mtypes.h" + /** * Subclass of gl_query_object */ @@ -36,6 +38,7 @@ struct st_query_object { struct gl_query_object base; struct pipe_query *pq; + unsigned type; /**< PIPE_QUERY_x */ }; @@ -49,9 +52,18 @@ st_query_object(struct gl_query_object *q) } +#if FEATURE_queryobj extern void st_init_query_functions(struct dd_function_table *functions); +#else + +static INLINE void +st_init_query_functions(struct dd_function_table *functions) +{ +} + +#endif /* FEATURE_queryobj */ #endif diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 843f3200278..7b2eb8012de 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -50,6 +50,7 @@ #include "vbo/vbo.h" +#if FEATURE_rastpos /** * Our special drawing pipeline stage (replaces rasterization). @@ -267,3 +268,5 @@ void st_init_rasterpos_functions(struct dd_function_table *functions) { functions->RasterPos = st_RasterPos; } + +#endif /* FEATURE_rastpos */ diff --git a/src/mesa/state_tracker/st_cb_rasterpos.h b/src/mesa/state_tracker/st_cb_rasterpos.h index 2b992e1405e..d2ed7297f15 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.h +++ b/src/mesa/state_tracker/st_cb_rasterpos.h @@ -28,6 +28,20 @@ #ifndef ST_CB_RASTERPOS_H #define ST_CB_RASTERPOS_H + +#include "main/mtypes.h" + +#if FEATURE_rastpos + extern void st_init_rasterpos_functions(struct dd_function_table *functions); -#endif +#else + +static INLINE void +st_init_rasterpos_functions(struct dd_function_table *functions) +{ +} + +#endif /* FEATURE_rastpos */ + +#endif /* ST_CB_RASTERPOS_H */ diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 69950ac44bb..b8493dab93f 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -46,10 +46,9 @@ #include "st_debug.h" #include "st_context.h" #include "st_atom.h" +#include "st_cb_bitmap.h" #include "st_cb_readpixels.h" #include "st_cb_fbo.h" -#include "st_texture.h" -#include "st_inlines.h" /** * Special case for reading stencil buffer. @@ -75,7 +74,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, /* Create a read transfer from the renderbuffer's texture */ - pt = st_cond_flush_get_tex_transfer(st_context(ctx), strb->texture, + pt = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, x, y, width, height); @@ -231,7 +230,7 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, y = strb->texture->height0 - y - height; } - trans = st_cond_flush_get_tex_transfer(st_context(ctx), strb->texture, + trans = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, x, y, width, height); @@ -346,12 +345,12 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, return; } + st_flush_bitmap_cache(st); + dest = _mesa_map_pbo_dest(ctx, &clippedPacking, dest); if (!dest) return; - st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); - if (format == GL_STENCIL_INDEX || format == GL_DEPTH_STENCIL) { st_read_stencil_pixels(ctx, x, y, width, height, @@ -395,7 +394,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } /* Create a read transfer from the renderbuffer's texture */ - trans = st_cond_flush_get_tex_transfer(st_context(ctx), strb->texture, + trans = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, x, y, width, height); diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 92342167d92..647898ef7c9 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -44,11 +44,11 @@ #include "state_tracker/st_debug.h" #include "state_tracker/st_context.h" #include "state_tracker/st_cb_fbo.h" +#include "state_tracker/st_cb_flush.h" #include "state_tracker/st_cb_texture.h" #include "state_tracker/st_format.h" #include "state_tracker/st_texture.h" #include "state_tracker/st_gen_mipmap.h" -#include "state_tracker/st_inlines.h" #include "state_tracker/st_atom.h" #include "pipe/p_context.h" @@ -255,8 +255,10 @@ get_texture_dims(GLenum target) * * We use the given st_texture_image as a clue to determine the size of the * mipmap image at level=0. + * + * \return GL_TRUE for success, GL_FALSE if out of memory. */ -static void +static GLboolean guess_and_alloc_texture(struct st_context *st, struct st_texture_object *stObj, const struct st_texture_image *stImage) @@ -287,7 +289,8 @@ guess_and_alloc_texture(struct st_context *st, (dims >= 3 && depth == 1) ) { /* we can't determine the image size at level=0 */ stObj->width0 = stObj->height0 = stObj->depth0 = 0; - return; + /* this is not an out of memory error */ + return GL_TRUE; } } @@ -349,7 +352,9 @@ guess_and_alloc_texture(struct st_context *st, depth, bindings); - DBG("%s - success\n", __FUNCTION__); + DBG("%s returning %d\n", __FUNCTION__, (stObj->pt != NULL)); + + return stObj->pt != NULL; } @@ -459,7 +464,7 @@ compress_with_blit(GLcontext * ctx, /* Put user's tex data into the temporary texture */ - tex_xfer = st_cond_flush_get_tex_transfer(st_context(ctx), src_tex, + tex_xfer = pipe_get_transfer(st_context(ctx)->pipe, src_tex, 0, 0, 0, /* face, level are zero */ PIPE_TRANSFER_WRITE, 0, 0, width, height); /* x, y, w, h */ @@ -597,14 +602,12 @@ st_TexImage(GLcontext * ctx, } if (!stObj->pt) { - guess_and_alloc_texture(st, stObj, stImage); - if (!stObj->pt) { + if (!guess_and_alloc_texture(st, stObj, stImage)) { /* Probably out of memory. * Try flushing any pending rendering, then retry. */ st_finish(st); - guess_and_alloc_texture(st, stObj, stImage); - if (!stObj->pt) { + if (!guess_and_alloc_texture(st, stObj, stImage)) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); return; } @@ -871,7 +874,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, PIPE_TEX_MIPFILTER_NEAREST); /* map the dst_surface so we can read from it */ - tex_xfer = st_cond_flush_get_tex_transfer(st_context(ctx), + tex_xfer = pipe_get_transfer(st_context(ctx)->pipe, dst_texture, 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, width, height); @@ -957,11 +960,6 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, /* Image is stored in hardware format in a buffer managed by the * kernel. Need to explicitly map and unmap it. */ - unsigned face = _mesa_tex_target_to_face(target); - - st_teximage_flush_before_map(st, stImage->pt, face, level, - PIPE_TRANSFER_READ); - texImage->Data = st_texture_image_map(st, stImage, 0, PIPE_TRANSFER_READ, 0, 0, stImage->base.Width, @@ -1093,16 +1091,12 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level, * from uploading the buffer under us. */ if (stImage->pt) { - unsigned face = _mesa_tex_target_to_face(target); - if (format == GL_DEPTH_COMPONENT && util_format_is_depth_and_stencil(stImage->pt->format)) transfer_usage = PIPE_TRANSFER_READ_WRITE; else transfer_usage = PIPE_TRANSFER_WRITE; - st_teximage_flush_before_map(st, stImage->pt, face, level, - transfer_usage); texImage->Data = st_texture_image_map(st, stImage, zoffset, transfer_usage, xoffset, yoffset, @@ -1225,11 +1219,8 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, enum pipe_format pformat; if (stImage->pt) { - unsigned face = _mesa_tex_target_to_face(target); pformat = stImage->pt->format; - st_teximage_flush_before_map(st, stImage->pt, face, level, - PIPE_TRANSFER_WRITE); texImage->Data = st_texture_image_map(st, stImage, 0, PIPE_TRANSFER_WRITE, xoffset, yoffset, @@ -1313,7 +1304,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, srcY = strb->Base.Height - srcY - height; } - src_trans = st_cond_flush_get_tex_transfer( st_context(ctx), + src_trans = pipe_get_transfer(st_context(ctx)->pipe, strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, @@ -1327,9 +1318,6 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, else transfer_usage = PIPE_TRANSFER_WRITE; - st_teximage_flush_before_map(st, stImage->pt, 0, 0, - transfer_usage); - texDest = st_texture_image_map(st, stImage, 0, transfer_usage, destX, destY, width, height); @@ -1511,9 +1499,6 @@ st_copy_texsubimage(GLcontext *ctx, struct pipe_surface *dest_surface = NULL; GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP); - /* any rendering in progress must flushed before we grab the fb image */ - st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); - /* make sure finalize_textures has been called? */ if (0) st_validate_state(st); @@ -1787,17 +1772,12 @@ copy_image_data_to_texture(struct st_context *st, */ st_texture_image_copy(st->pipe, stObj->pt, dstLevel, /* dest texture, level */ - stImage->pt, /* src texture */ + stImage->pt, stImage->level, /* src texture, level */ stImage->face); pipe_resource_reference(&stImage->pt, NULL); } else if (stImage->base.Data) { - /* More straightforward upload. - */ - st_teximage_flush_before_map(st, stObj->pt, stImage->face, dstLevel, - PIPE_TRANSFER_WRITE); - st_texture_image_data(st, stObj->pt, stImage->face, @@ -1909,7 +1889,7 @@ st_finalize_texture(GLcontext *ctx, */ for (face = 0; face < nr_faces; face++) { GLuint level; - for (level = 0; level <= stObj->lastLevel; level++) { + for (level = stObj->base.BaseLevel; level <= stObj->lastLevel; level++) { struct st_texture_image *stImage = st_texture_image(stObj->base.Image[face][level]); diff --git a/src/mesa/state_tracker/st_cb_xformfb.c b/src/mesa/state_tracker/st_cb_xformfb.c new file mode 100644 index 00000000000..749e88e8dbc --- /dev/null +++ b/src/mesa/state_tracker/st_cb_xformfb.c @@ -0,0 +1,133 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS 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. + * + **************************************************************************/ + + +/** + * Transform feedback functions. + * + * \author Brian Paul + */ + + +#include "main/imports.h" +#include "main/context.h" +#include "main/transformfeedback.h" + +#include "st_cb_xformfb.h" + + +#if FEATURE_EXT_transform_feedback + +#if 0 +static struct gl_transform_feedback_object * +st_new_transform_feedback(GLcontext *ctx, GLuint name) +{ + struct gl_transform_feedback_object *obj; + obj = CALLOC_STRUCT(gl_transform_feedback_object); + if (obj) { + obj->Name = name; + obj->RefCount = 1; + } + return obj; +} +#endif + +#if 0 +static void +st_delete_transform_feedback(GLcontext *ctx, + struct gl_transform_feedback_object *obj) +{ + GLuint i; + + for (i = 0; i < Elements(obj->Buffers); i++) { + _mesa_reference_buffer_object(ctx, &obj->Buffers[i], NULL); + } + + free(obj); +} +#endif + + +static void +st_begin_transform_feedback(GLcontext *ctx, GLenum mode, + struct gl_transform_feedback_object *obj) +{ + /* to-do */ +} + + +static void +st_end_transform_feedback(GLcontext *ctx, + struct gl_transform_feedback_object *obj) +{ + /* to-do */ +} + + +static void +st_pause_transform_feedback(GLcontext *ctx, + struct gl_transform_feedback_object *obj) +{ + /* to-do */ +} + + +static void +st_resume_transform_feedback(GLcontext *ctx, + struct gl_transform_feedback_object *obj) +{ + /* to-do */ +} + + +static void +st_draw_transform_feedback(GLcontext *ctx, GLenum mode, + struct gl_transform_feedback_object *obj) +{ + /* XXX to do */ + /* + * Get number of vertices in obj's feedback buffer. + * Call ctx->Exec.DrawArrays(mode, 0, count); + */ +} + + +void +st_init_xformfb_functions(struct dd_function_table *functions) +{ + /* let core Mesa plug in its functions */ + _mesa_init_transform_feedback_functions(functions); + + /* then override a few: */ + functions->BeginTransformFeedback = st_begin_transform_feedback; + functions->EndTransformFeedback = st_end_transform_feedback; + functions->PauseTransformFeedback = st_pause_transform_feedback; + functions->ResumeTransformFeedback = st_resume_transform_feedback; + functions->DrawTransformFeedback = st_draw_transform_feedback; +} + +#endif /* FEATURE_EXT_transform_feedback */ diff --git a/src/mesa/state_tracker/st_cb_xformfb.h b/src/mesa/state_tracker/st_cb_xformfb.h new file mode 100644 index 00000000000..50efcb9293f --- /dev/null +++ b/src/mesa/state_tracker/st_cb_xformfb.h @@ -0,0 +1,46 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef ST_CB_XFORMFB_H +#define ST_CB_XFORMFB_H + + +#if FEATURE_EXT_transform_feedback + +extern void +st_init_xformfb_functions(struct dd_function_table *functions); + +#else + +static INLINE void +st_init_xformfb_functions(struct dd_function_table *functions) +{ +} + +#endif /* FEATURE_EXT_transform_feedback */ + +#endif /* ST_CB_XFORMFB_H */ diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index d4ea593e3f7..2070f14a5a6 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -38,22 +38,17 @@ #include "st_cb_bufferobjects.h" #include "st_cb_clear.h" #include "st_cb_condrender.h" -#if FEATURE_drawpix #include "st_cb_drawpixels.h" #include "st_cb_rasterpos.h" -#endif -#if FEATURE_OES_draw_texture #include "st_cb_drawtex.h" -#endif #include "st_cb_eglimage.h" #include "st_cb_fbo.h" -#if FEATURE_feedback #include "st_cb_feedback.h" -#endif #include "st_cb_program.h" #include "st_cb_queryobj.h" #include "st_cb_readpixels.h" #include "st_cb_texture.h" +#include "st_cb_xformfb.h" #include "st_cb_flush.h" #include "st_cb_strings.h" #include "st_atom.h" @@ -65,7 +60,6 @@ #include "util/u_inlines.h" #include "util/u_rect.h" #include "util/u_surface.h" -#include "draw/draw_context.h" #include "cso_cache/cso_context.h" @@ -116,18 +110,6 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) /* state tracker needs the VBO module */ _vbo_CreateContext(ctx); -#if FEATURE_feedback || FEATURE_drawpix - st->draw = draw_create(pipe); /* for selection/feedback */ - - /* Disable draw options that might convert points/lines to tris, etc. - * as that would foul-up feedback/selection mode. - */ - draw_wide_line_threshold(st->draw, 1000.0f); - draw_wide_point_threshold(st->draw, 1000.0f); - draw_enable_line_stipple(st->draw, FALSE); - draw_enable_point_sprites(st->draw, FALSE); -#endif - st->dirty.mesa = ~0; st->dirty.st = ~0; @@ -208,23 +190,14 @@ static void st_destroy_context_priv( struct st_context *st ) { uint i; -#if FEATURE_feedback || FEATURE_drawpix - draw_destroy(st->draw); -#endif st_destroy_atoms( st ); st_destroy_draw( st ); st_destroy_generate_mipmap(st); -#if FEATURE_EXT_framebuffer_blit st_destroy_blit(st); -#endif st_destroy_clear(st); -#if FEATURE_drawpix st_destroy_bitmap(st); st_destroy_drawpix(st); -#endif -#if FEATURE_OES_draw_texture st_destroy_drawtex(st); -#endif for (i = 0; i < Elements(st->state.sampler_views); i++) { pipe_sampler_view_reference(&st->state.sampler_views[i], NULL); @@ -284,39 +257,29 @@ void st_init_driver_functions(struct dd_function_table *functions) { _mesa_init_glsl_driver_functions(functions); -#if FEATURE_accum st_init_accum_functions(functions); -#endif -#if FEATURE_EXT_framebuffer_blit st_init_blit_functions(functions); -#endif st_init_bufferobject_functions(functions); st_init_clear_functions(functions); -#if FEATURE_drawpix st_init_bitmap_functions(functions); st_init_drawpixels_functions(functions); st_init_rasterpos_functions(functions); -#endif -#if FEATURE_OES_draw_texture st_init_drawtex_functions(functions); -#endif st_init_eglimage_functions(functions); st_init_fbo_functions(functions); -#if FEATURE_feedback st_init_feedback_functions(functions); -#endif st_init_program_functions(functions); -#if FEATURE_queryobj st_init_query_functions(functions); -#endif st_init_cond_render_functions(functions); st_init_readpixels_functions(functions); st_init_texture_functions(functions); st_init_flush_functions(functions); st_init_string_functions(functions); + st_init_xformfb_functions(functions); + functions->UpdateState = st_invalidate_state; } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 4137596bd40..eb2e5b2bbf7 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -57,6 +57,7 @@ #include "pipe/p_defines.h" #include "util/u_inlines.h" #include "util/u_format.h" +#include "draw/draw_context.h" #include "cso_cache/cso_context.h" @@ -741,11 +742,26 @@ void st_init_draw( struct st_context *st ) GLcontext *ctx = st->ctx; vbo_set_draw_func(ctx, st_draw_vbo); + +#if FEATURE_feedback || FEATURE_rastpos + st->draw = draw_create(st->pipe); /* for selection/feedback */ + + /* Disable draw options that might convert points/lines to tris, etc. + * as that would foul-up feedback/selection mode. + */ + draw_wide_line_threshold(st->draw, 1000.0f); + draw_wide_point_threshold(st->draw, 1000.0f); + draw_enable_line_stipple(st->draw, FALSE); + draw_enable_point_sprites(st->draw, FALSE); +#endif } void st_destroy_draw( struct st_context *st ) { +#if FEATURE_feedback || FEATURE_rastpos + draw_destroy(st->draw); +#endif } diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index a1f70e86936..5cf26663341 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -45,7 +45,7 @@ #include "draw/draw_context.h" -#if FEATURE_feedback || FEATURE_drawpix +#if FEATURE_feedback || FEATURE_rastpos /** * Set the (private) draw module's post-transformed vertex format when in @@ -279,5 +279,5 @@ st_feedback_draw_vbo(GLcontext *ctx, } } -#endif /* FEATURE_feedback || FEATURE_drawpix */ +#endif /* FEATURE_feedback || FEATURE_rastpos */ diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 9ada38aa483..810a0635b50 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -67,6 +67,7 @@ void st_init_limits(struct st_context *st) { struct pipe_screen *screen = st->pipe->screen; struct gl_constants *c = &st->ctx->Const; + struct gl_program_constants *pc; c->MaxTextureLevels = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), @@ -140,6 +141,26 @@ void st_init_limits(struct st_context *st) /* Quads always follow GL provoking rules. */ c->QuadsFollowProvokingVertexConvention = GL_FALSE; + + pc = &c->FragmentProgram; + pc->MaxNativeInstructions = screen->get_param(screen, PIPE_CAP_MAX_FS_INSTRUCTIONS); + pc->MaxNativeAluInstructions = screen->get_param(screen, PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS); + pc->MaxNativeTexInstructions = screen->get_param(screen, PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS); + pc->MaxNativeTexIndirections = screen->get_param(screen, PIPE_CAP_MAX_FS_TEX_INDIRECTIONS); + pc->MaxNativeAttribs = screen->get_param(screen, PIPE_CAP_MAX_FS_INPUTS); + pc->MaxNativeTemps = screen->get_param(screen, PIPE_CAP_MAX_FS_TEMPS); + pc->MaxNativeAddressRegs = screen->get_param(screen, PIPE_CAP_MAX_FS_ADDRS); + pc->MaxNativeParameters = screen->get_param(screen, PIPE_CAP_MAX_FS_CONSTS); + + pc = &c->VertexProgram; + pc->MaxNativeInstructions = screen->get_param(screen, PIPE_CAP_MAX_VS_INSTRUCTIONS); + pc->MaxNativeAluInstructions = screen->get_param(screen, PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS); + pc->MaxNativeTexInstructions = screen->get_param(screen, PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS); + pc->MaxNativeTexIndirections = screen->get_param(screen, PIPE_CAP_MAX_VS_TEX_INDIRECTIONS); + pc->MaxNativeAttribs = screen->get_param(screen, PIPE_CAP_MAX_VS_INPUTS); + pc->MaxNativeTemps = screen->get_param(screen, PIPE_CAP_MAX_VS_TEMPS); + pc->MaxNativeAddressRegs = screen->get_param(screen, PIPE_CAP_MAX_VS_ADDRS); + pc->MaxNativeParameters = screen->get_param(screen, PIPE_CAP_MAX_VS_CONSTS); } @@ -275,6 +296,9 @@ void st_init_extensions(struct st_context *st) if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY)) { ctx->Extensions.ARB_occlusion_query = GL_TRUE; } + if (screen->get_param(screen, PIPE_CAP_TIMER_QUERY)) { + ctx->Extensions.EXT_timer_query = GL_TRUE; + } if (screen->get_param(screen, PIPE_CAP_TEXTURE_SHADOW_MAP)) { ctx->Extensions.ARB_depth_texture = GL_TRUE; diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 5cf8b4a881b..2d587df6055 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -39,9 +39,9 @@ #include "st_debug.h" #include "st_context.h" +#include "st_texture.h" #include "st_gen_mipmap.h" #include "st_cb_texture.h" -#include "st_inlines.h" /** @@ -79,6 +79,7 @@ st_render_mipmap(struct st_context *st, struct pipe_sampler_view *psv = st_get_texture_sampler_view(stObj, pipe); const uint face = _mesa_tex_target_to_face(target); + assert(psv->texture == stObj->pt); assert(target != GL_TEXTURE_3D); /* not done yet */ /* check if we can render in the texture's format */ @@ -104,10 +105,32 @@ decompress_image(enum pipe_format format, unsigned width, unsigned height) { const struct util_format_description *desc = util_format_description(format); - const uint dst_stride = 4 * width; + const uint bw = util_format_get_blockwidth(format); + const uint bh = util_format_get_blockheight(format); + const uint dst_stride = 4 * MAX2(width, bw); const uint src_stride = util_format_get_stride(format, width); desc->unpack_rgba_8unorm(dst, dst_stride, src, src_stride, width, height); + + if (width < bw || height < bh) { + /* We're decompressing an image smaller than the compression + * block size. We don't want garbage pixel values in the region + * outside (width x height) so replicate pixels from the (width + * x height) region to fill out the (bw x bh) block size. + */ + uint x, y; + for (y = 0; y < bh; y++) { + for (x = 0; x < bw; x++) { + if (x >= width || y >= height) { + uint p = (y * bw + x) * 4; + dst[p + 0] = dst[0]; + dst[p + 1] = dst[1]; + dst[p + 2] = dst[2]; + dst[p + 3] = dst[3]; + } + } + } + } } @@ -176,13 +199,13 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, ubyte *dstData; int srcStride, dstStride; - srcTrans = st_cond_flush_get_tex_transfer(st_context(ctx), pt, face, + srcTrans = pipe_get_transfer(st_context(ctx)->pipe, pt, face, srcLevel, zslice, PIPE_TRANSFER_READ, 0, 0, srcWidth, srcHeight); - dstTrans = st_cond_flush_get_tex_transfer(st_context(ctx), pt, face, + dstTrans = pipe_get_transfer(st_context(ctx)->pipe, pt, face, dstLevel, zslice, PIPE_TRANSFER_WRITE, 0, 0, dstWidth, dstHeight); @@ -221,7 +244,7 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, dstWidth2); /* stride in texels */ /* compress the new image: dstTemp -> dstData */ - compress_image(format, dstTemp, dstData, dstWidth2, dstHeight2); + compress_image(format, dstTemp, dstData, dstWidth, dstHeight); free(srcTemp); free(dstTemp); @@ -261,7 +284,6 @@ compute_num_levels(GLcontext *ctx, return 1; } else { - const GLuint maxLevels = texObj->MaxLevel - texObj->BaseLevel + 1; const struct gl_texture_image *baseImage = _mesa_get_tex_image(ctx, texObj, target, texObj->BaseLevel); GLuint size, numLevels; @@ -269,14 +291,16 @@ compute_num_levels(GLcontext *ctx, size = MAX2(baseImage->Width2, baseImage->Height2); size = MAX2(size, baseImage->Depth2); - numLevels = 0; + numLevels = texObj->BaseLevel; while (size > 0) { numLevels++; size >>= 1; } - numLevels = MIN2(numLevels, maxLevels); + numLevels = MIN2(numLevels, texObj->MaxLevel + 1); + + assert(numLevels >= 1); return numLevels; } @@ -304,7 +328,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, but we're not supporting multisampled textures yet. */ assert(pt->nr_samples < 2); - /* find expected last mipmap level */ + /* find expected last mipmap level to generate*/ lastLevel = compute_num_levels(ctx, texObj, target) - 1; if (lastLevel == 0) @@ -343,7 +367,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, pt = stObj->pt; } - assert(lastLevel <= pt->last_level); + assert(pt->last_level >= lastLevel); /* Try to generate the mipmap by rendering/texturing. If that fails, * use the software fallback. diff --git a/src/mesa/state_tracker/st_inlines.h b/src/mesa/state_tracker/st_inlines.h deleted file mode 100644 index 3bf7ba185e5..00000000000 --- a/src/mesa/state_tracker/st_inlines.h +++ /dev/null @@ -1,159 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/** - * Functions for checking if buffers/textures are referenced when we need - * to read/write from/to them. Flush when needed. - */ - -#ifndef ST_INLINES_H -#define ST_INLINES_H - -#include "pipe/p_context.h" -#include "pipe/p_screen.h" -#include "pipe/p_defines.h" -#include "util/u_inlines.h" -#include "util/u_box.h" -#include "pipe/p_state.h" - -#include "st_context.h" -#include "st_texture.h" -#include "st_cb_flush.h" - -static INLINE struct pipe_transfer * -st_cond_flush_get_tex_transfer(struct st_context *st, - struct pipe_resource *pt, - unsigned int face, - unsigned int level, - unsigned int zslice, - enum pipe_transfer_usage usage, - unsigned int x, unsigned int y, - unsigned int w, unsigned int h) -{ - struct pipe_context *context = st->pipe; - struct pipe_subresource subresource; - struct pipe_box box; - - subresource.face = face; - subresource.level = level; - - u_box_2d_zslice(x, y, zslice, w, h, &box); - - st_teximage_flush_before_map(st, pt, face, level, usage); - - return context->get_transfer(context, - pt, - subresource, - usage, - &box); -} - -static INLINE struct pipe_transfer * -st_no_flush_get_tex_transfer(struct st_context *st, - struct pipe_resource *pt, - unsigned int face, - unsigned int level, - unsigned int zslice, - enum pipe_transfer_usage usage, - unsigned int x, unsigned int y, - unsigned int w, unsigned int h) -{ - struct pipe_context *context = st->pipe; - struct pipe_box box; - struct pipe_subresource subresource = u_subresource( face, level ); - - u_box_2d_zslice( x, y, zslice, - w, h, - &box ); - - return context->get_transfer(context, - pt, - subresource, - usage, - &box); -} - - -static INLINE void -st_cond_flush_pipe_buffer_write(struct st_context *st, - struct pipe_resource *buf, - unsigned int offset, - unsigned int size, - const void * data) -{ - struct pipe_context *pipe = st->pipe; - - pipe_buffer_write(pipe, buf, offset, size, data); -} - -static INLINE void -st_no_flush_pipe_buffer_write(struct st_context *st, - struct pipe_resource *buf, - unsigned int offset, - unsigned int size, - const void * data) -{ - pipe_buffer_write(st->pipe, buf, offset, size, data); -} - -static INLINE void -st_no_flush_pipe_buffer_write_nooverlap(struct st_context *st, - struct pipe_resource *buf, - unsigned int offset, - unsigned int size, - const void * data) -{ - pipe_buffer_write_nooverlap(st->pipe, buf, offset, size, data); -} - -static INLINE void -st_cond_flush_pipe_buffer_read(struct st_context *st, - struct pipe_resource *buf, - unsigned int offset, - unsigned int size, - void * data) -{ - struct pipe_context *pipe = st->pipe; - - if (pipe->is_resource_referenced(pipe, buf, 0, 0) & PIPE_REFERENCED_FOR_WRITE) - st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); - - pipe_buffer_read(pipe, buf, offset, size, data); -} - -static INLINE void -st_no_flush_pipe_buffer_read(struct st_context *st, - struct pipe_resource *buf, - unsigned int offset, - unsigned int size, - void * data) -{ - pipe_buffer_read(st->pipe, buf, offset, size, data); -} - -#endif - diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 44d59d44763..869196941c3 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -508,6 +508,7 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target struct st_texture_object *stObj; struct st_texture_image *stImage; GLenum internalFormat; + GLuint width, height, depth; switch (target) { case ST_TEXTURE_1D: @@ -527,12 +528,6 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target break; } - if (util_format_get_component_bits(internal_format, - UTIL_FORMAT_COLORSPACE_RGB, 3) > 0) - internalFormat = GL_RGBA; - else - internalFormat = GL_RGB; - texObj = _mesa_select_tex_object(ctx, texUnit, target); _mesa_lock_texture(ctx, texObj); @@ -546,17 +541,51 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target texImage = _mesa_get_tex_image(ctx, texObj, target, level); stImage = st_texture_image(texImage); if (tex) { + /* + * XXX When internal_format and tex->format differ, st_finalize_texture + * needs to allocate a new texture with internal_format and copy the + * texture here into the new one. It will result in surface_copy being + * called on surfaces whose formats differ. + * + * To avoid that, internal_format is (wrongly) ignored here. A sane fix + * is to use a sampler view. + */ + if (util_format_get_component_bits(tex->format, + UTIL_FORMAT_COLORSPACE_RGB, 3) > 0) + internalFormat = GL_RGBA; + else + internalFormat = GL_RGB; + _mesa_init_teximage_fields(ctx, target, texImage, tex->width0, tex->height0, 1, 0, internalFormat); texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat, GL_RGBA, GL_UNSIGNED_BYTE); _mesa_set_fetch_functions(texImage, 2); + + width = tex->width0; + height = tex->height0; + depth = tex->depth0; + + /* grow the image size until we hit level = 0 */ + while (level > 0) { + if (width != 1) + width <<= 1; + if (height != 1) + height <<= 1; + if (depth != 1) + depth <<= 1; + level--; + } } else { _mesa_clear_texture_image(ctx, texImage); + width = height = depth = 0; } pipe_resource_reference(&stImage->pt, tex); + stObj->width0 = width; + stObj->height0 = height; + stObj->depth0 = depth; _mesa_dirty_texobj(ctx, texObj, GL_TRUE); _mesa_unlock_texture(ctx, texObj); diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index e8eb9ec3904..6df6cdfe03d 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -62,10 +62,12 @@ struct st_translate { struct ureg_src inputs[PIPE_MAX_SHADER_INPUTS]; struct ureg_dst address[1]; struct ureg_src samplers[PIPE_MAX_SAMPLERS]; - struct ureg_dst psizregreal; - struct ureg_src pointSizeConst; - GLint psizoutindex; - GLboolean prevInstWrotePsiz; + + /* Extra info for handling point size clamping in vertex shader */ + struct ureg_dst pointSizeResult; /**< Actual point size output register */ + struct ureg_src pointSizeConst; /**< Point size range constant register */ + GLint pointSizeOutIndex; /**< Temp point size output register */ + GLboolean prevInstWrotePointSize; const GLuint *inputMapping; const GLuint *outputMapping; @@ -92,6 +94,12 @@ struct st_translate { }; +/** + * Make note of a branch to a label in the TGSI code. + * After we've emitted all instructions, we'll go over the list + * of labels built here and patch the TGSI code with the actual + * location of each label. + */ static unsigned *get_label( struct st_translate *t, unsigned branch_target ) { @@ -116,6 +124,12 @@ static unsigned *get_label( struct st_translate *t, } +/** + * Called prior to emitting the TGSI code for each Mesa instruction. + * Allocate additional space for instructions if needed. + * Update the insn[] array so the next Mesa instruction points to + * the next TGSI instruction. + */ static void set_insn_start( struct st_translate *t, unsigned start ) { @@ -135,8 +149,8 @@ static void set_insn_start( struct st_translate *t, } -/* - * Map mesa register file to TGSI register file. +/** + * Map a Mesa dst register to a TGSI ureg_dst register. */ static struct ureg_dst dst_register( struct st_translate *t, @@ -154,8 +168,18 @@ dst_register( struct st_translate *t, return t->temps[index]; case PROGRAM_OUTPUT: - if (index == t->psizoutindex) - t->prevInstWrotePsiz = GL_TRUE; + if (t->procType == TGSI_PROCESSOR_VERTEX && index == VERT_RESULT_PSIZ) + t->prevInstWrotePointSize = GL_TRUE; + + if (t->procType == TGSI_PROCESSOR_VERTEX) + assert(index < VERT_RESULT_MAX); + else if (t->procType == TGSI_PROCESSOR_FRAGMENT) + assert(index < FRAG_RESULT_MAX); + else + assert(0 && "geom shaders not handled in dst_register() yet"); + + assert(t->outputMapping[index] < Elements(t->outputs)); + return t->outputs[t->outputMapping[index]]; case PROGRAM_ADDRESS: @@ -168,6 +192,9 @@ dst_register( struct st_translate *t, } +/** + * Map a Mesa src register to a TGSI ureg_src register. + */ static struct ureg_src src_register( struct st_translate *t, gl_register_file file, @@ -244,6 +271,9 @@ translate_texture_target( GLuint textarget, } +/** + * Create a TGSI ureg_dst register from a Mesa dest register. + */ static struct ureg_dst translate_dst( struct st_translate *t, const struct prog_dst_register *DstReg, @@ -266,6 +296,9 @@ translate_dst( struct st_translate *t, } +/** + * Create a TGSI ureg_src register from a Mesa src register. + */ static struct ureg_src translate_src( struct st_translate *t, const struct prog_src_register *SrcReg ) @@ -675,6 +708,7 @@ compile_instruction( } } + /** * Emit the TGSI instructions to adjust the WPOS pixel center convention */ @@ -686,12 +720,14 @@ emit_adjusted_wpos( struct st_translate *t, struct ureg_dst wpos_temp = ureg_DECL_temporary(ureg); struct ureg_src wpos_input = t->inputs[t->inputMapping[FRAG_ATTRIB_WPOS]]; - ureg_ADD(ureg, ureg_writemask(wpos_temp, TGSI_WRITEMASK_X | TGSI_WRITEMASK_Y), - wpos_input, ureg_imm1f(ureg, value)); + ureg_ADD(ureg, + ureg_writemask(wpos_temp, TGSI_WRITEMASK_X | TGSI_WRITEMASK_Y), + wpos_input, ureg_imm1f(ureg, value)); t->inputs[t->inputMapping[FRAG_ATTRIB_WPOS]] = ureg_src(wpos_temp); } + /** * Emit the TGSI instructions for inverting the WPOS y coordinate. */ @@ -884,8 +920,8 @@ st_translate_mesa_program( t->inputMapping = inputMapping; t->outputMapping = outputMapping; t->ureg = ureg; - t->psizoutindex = -1; - t->prevInstWrotePsiz = GL_FALSE; + t->pointSizeOutIndex = -1; + t->prevInstWrotePointSize = GL_FALSE; /*_mesa_print_program(program);*/ @@ -954,6 +990,9 @@ st_translate_mesa_program( outputSemanticName[i], outputSemanticIndex[i] ); if ((outputSemanticName[i] == TGSI_SEMANTIC_PSIZE) && program->Id) { + /* Writing to the point size result register requires special + * handling to implement clamping. + */ static const gl_state_index pointSizeClampState[STATE_LENGTH] = { STATE_INTERNAL, STATE_POINT_SIZE_IMPL_CLAMP, 0, 0, 0 }; /* XXX: note we are modifying the incoming shader here! Need to @@ -965,8 +1004,8 @@ st_translate_mesa_program( pointSizeClampState); struct ureg_dst psizregtemp = ureg_DECL_temporary( ureg ); t->pointSizeConst = ureg_DECL_constant( ureg, pointSizeClampConst ); - t->psizregreal = t->outputs[i]; - t->psizoutindex = i; + t->pointSizeResult = t->outputs[i]; + t->pointSizeOutIndex = i; t->outputs[i] = psizregtemp; } } @@ -1035,19 +1074,24 @@ st_translate_mesa_program( set_insn_start( t, ureg_get_instruction_number( ureg )); compile_instruction( t, &program->Instructions[i] ); - /* note can't do that easily at the end of prog due to - possible early return */ - if (t->prevInstWrotePsiz && program->Id) { + if (t->prevInstWrotePointSize && program->Id) { + /* The previous instruction wrote to the (fake) vertex point size + * result register. Now we need to clamp that value to the min/max + * point size range, putting the result into the real point size + * register. + * Note that we can't do this easily at the end of program due to + * possible early return. + */ set_insn_start( t, ureg_get_instruction_number( ureg )); ureg_MAX( t->ureg, - ureg_writemask(t->outputs[t->psizoutindex], WRITEMASK_X), - ureg_src(t->outputs[t->psizoutindex]), + ureg_writemask(t->outputs[t->pointSizeOutIndex], WRITEMASK_X), + ureg_src(t->outputs[t->pointSizeOutIndex]), ureg_swizzle(t->pointSizeConst, 1,1,1,1)); - ureg_MIN( t->ureg, ureg_writemask(t->psizregreal, WRITEMASK_X), - ureg_src(t->outputs[t->psizoutindex]), + ureg_MIN( t->ureg, ureg_writemask(t->pointSizeResult, WRITEMASK_X), + ureg_src(t->outputs[t->pointSizeOutIndex]), ureg_swizzle(t->pointSizeConst, 2,2,2,2)); } - t->prevInstWrotePsiz = GL_FALSE; + t->prevInstWrotePointSize = GL_FALSE; } /* Fix up all emitted labels: diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 772a2ee17c9..3c865028a7a 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -65,8 +65,10 @@ st_vp_release_varients( struct st_context *st, if (vpv->driver_shader) cso_delete_vertex_shader(st->cso_context, vpv->driver_shader); +#if FEATURE_feedback || FEATURE_rastpos if (vpv->draw_shader) draw_delete_vertex_shader( st->draw, vpv->draw_shader ); +#endif if (vpv->tgsi.tokens) st_free_tokens(vpv->tgsi.tokens); diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index d0d1c5c3156..dbdf1ea1ad0 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -29,7 +29,6 @@ #include "st_format.h" #include "st_texture.h" #include "st_cb_fbo.h" -#include "st_inlines.h" #include "main/enums.h" #undef Elements /* fix re-defined macro warning */ @@ -66,6 +65,9 @@ st_texture_create(struct st_context *st, struct pipe_screen *screen = st->pipe->screen; assert(target <= PIPE_TEXTURE_CUBE); + assert(width0 > 0); + assert(height0 > 0); + assert(depth0 > 0); DBG("%s target %s format %s last_level %d\n", __FUNCTION__, _mesa_lookup_enum_by_nr(target), @@ -142,7 +144,7 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, DBG("%s \n", __FUNCTION__); - stImage->transfer = st_no_flush_get_tex_transfer(st, pt, stImage->face, + stImage->transfer = pipe_get_transfer(st->pipe, pt, stImage->face, stImage->level, zoffset, usage, x, y, w, h); @@ -217,7 +219,7 @@ st_texture_image_data(struct st_context *st, DBG("%s\n", __FUNCTION__); for (i = 0; i < depth; i++) { - dst_transfer = st_no_flush_get_tex_transfer(st, dst, face, level, i, + dst_transfer = pipe_get_transfer(st->pipe, dst, face, level, i, PIPE_TRANSFER_WRITE, 0, 0, u_minify(dst->width0, level), u_minify(dst->height0, level)); @@ -237,12 +239,47 @@ st_texture_image_data(struct st_context *st, } -/* Copy mipmap image between textures +/** + * For debug only: get/print center pixel in the src resource. + */ +static void +print_center_pixel(struct pipe_context *pipe, struct pipe_resource *src) +{ + struct pipe_subresource rect; + struct pipe_transfer *xfer; + struct pipe_box region; + ubyte *map; + + rect.face = 0; + rect.level = 0; + + region.x = src->width0 / 2; + region.y = src->height0 / 2; + region.z = 0; + region.width = 1; + region.height = 1; + region.depth = 1; + + xfer = pipe->get_transfer(pipe, src, rect, PIPE_TRANSFER_READ, ®ion); + map = pipe->transfer_map(pipe, xfer); + + printf("center pixel: %d %d %d %d\n", map[0], map[1], map[2], map[3]); + + pipe->transfer_unmap(pipe, xfer); + pipe->transfer_destroy(pipe, xfer); +} + + +/** + * Copy the image at level=0 in 'src' to the 'dst' resource at 'dstLevel'. + * This is used to copy mipmap images from one texture buffer to another. + * This typically happens when our initial guess at the total texture size + * is incorrect (see the guess_and_alloc_texture() function). */ void st_texture_image_copy(struct pipe_context *pipe, struct pipe_resource *dst, GLuint dstLevel, - struct pipe_resource *src, + struct pipe_resource *src, GLuint srcLevel, GLuint face) { GLuint width = u_minify(dst->width0, dstLevel); @@ -251,43 +288,20 @@ st_texture_image_copy(struct pipe_context *pipe, struct pipe_subresource dstsub, srcsub; GLuint i; - assert(src->width0 == dst->width0); - assert(src->height0 == dst->height0); + assert(u_minify(src->width0, srcLevel) == width); + assert(u_minify(src->height0, srcLevel) == height); + assert(u_minify(src->depth0, srcLevel) == depth); dstsub.face = face; dstsub.level = dstLevel; srcsub.face = face; - + srcsub.level = srcLevel; + /* Loop over 3D image slices */ for (i = 0; i < depth; i++) { - GLuint srcLevel; - - /* find src texture level of needed size */ - for (srcLevel = 0; srcLevel <= src->last_level; srcLevel++) { - if (u_minify(src->width0, srcLevel) == width && - u_minify(src->height0, srcLevel) == height) { - break; - } - } - assert(u_minify(src->width0, srcLevel) == width); - assert(u_minify(src->height0, srcLevel) == height); - -#if 0 - { - struct pipe_screen *screen = pipe->screen; - src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i, - PIPE_BUFFER_USAGE_CPU_READ); - ubyte *map = screen->surface_map(screen, src_surface, PIPE_BUFFER_USAGE_CPU_READ); - map += src_surface->width * src_surface->height * 4 / 2; - printf("%s center pixel: %d %d %d %d (pt %p[%d] -> %p[%d])\n", - __FUNCTION__, - map[0], map[1], map[2], map[3], - src, srcLevel, dst, dstLevel); - - screen->surface_unmap(screen, src_surface); - pipe_surface_reference(&src_surface, NULL); + + if (0) { + print_center_pixel(pipe, src); } -#endif - srcsub.level = srcLevel; pipe->resource_copy_region(pipe, dst, @@ -300,19 +314,3 @@ st_texture_image_copy(struct pipe_context *pipe, } } - -void -st_teximage_flush_before_map(struct st_context *st, - struct pipe_resource *pt, - unsigned int face, - unsigned int level, - enum pipe_transfer_usage usage) -{ - struct pipe_context *pipe = st->pipe; - unsigned referenced = - pipe->is_resource_referenced(pipe, pt, face, level); - - if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) || - (usage & PIPE_TRANSFER_WRITE))) - st->pipe->flush(st->pipe, PIPE_FLUSH_RENDER_CACHE, NULL); -} diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 447f091db1f..ed5d271597c 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -205,13 +205,7 @@ st_texture_image_data(struct st_context *st, extern void st_texture_image_copy(struct pipe_context *pipe, struct pipe_resource *dst, GLuint dstLevel, - struct pipe_resource *src, + struct pipe_resource *src, GLuint srcLevel, GLuint face); -extern void -st_teximage_flush_before_map(struct st_context *st, - struct pipe_resource *pt, - unsigned int face, - unsigned int level, - enum pipe_transfer_usage usage); #endif diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c index ebd1574c43e..0fcb7c77af0 100644 --- a/src/mesa/swrast_setup/ss_context.c +++ b/src/mesa/swrast_setup/ss_context.c @@ -115,7 +115,7 @@ setup_vertex_format(GLcontext *ctx) GLboolean intColors = !ctx->FragmentProgram._Current && !ctx->ATIFragmentShader._Enabled && ctx->RenderMode == GL_RENDER - && CHAN_TYPE == GL_UNSIGNED_BYTE; + && CHAN_TYPE != GL_FLOAT; if (intColors != swsetup->intColors || !RENDERINPUTS_EQUAL(tnl->render_inputs_bitset, diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index 13148fc3e22..580850574c9 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -198,10 +198,8 @@ GLboolean _vbo_CreateContext( GLcontext *ctx ) * vtxfmt mechanism can be removed now. */ vbo_exec_init( ctx ); -#if FEATURE_dlist if (ctx->API == API_OPENGL) vbo_save_init( ctx ); -#endif _math_init_eval(); @@ -233,10 +231,8 @@ void _vbo_DestroyContext( GLcontext *ctx ) } vbo_exec_destroy(ctx); -#if FEATURE_dlist if (ctx->API == API_OPENGL) vbo_save_destroy(ctx); -#endif FREE(vbo); ctx->swtnl_im = NULL; } diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h index 8b726dc8ac5..00cfc522a0d 100644 --- a/src/mesa/vbo/vbo_context.h +++ b/src/mesa/vbo/vbo_context.h @@ -54,9 +54,7 @@ #include "vbo.h" #include "vbo_attrib.h" #include "vbo_exec.h" -#if FEATURE_dlist #include "vbo_save.h" -#endif struct vbo_context { diff --git a/src/mesa/vbo/vbo_save.c b/src/mesa/vbo/vbo_save.c index fd9a1302705..dd5570689e7 100644 --- a/src/mesa/vbo/vbo_save.c +++ b/src/mesa/vbo/vbo_save.c @@ -33,6 +33,8 @@ #include "vbo_context.h" +#if FEATURE_dlist + static void vbo_save_callback_init( GLcontext *ctx ) { @@ -117,3 +119,4 @@ void vbo_save_fallback( GLcontext *ctx, GLboolean fallback ) } +#endif /* FEATURE_dlist */ diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h index 86bbd24f7b1..82ba6c8afe7 100644 --- a/src/mesa/vbo/vbo_save.h +++ b/src/mesa/vbo/vbo_save.h @@ -153,6 +153,7 @@ struct vbo_save_context { GLubyte *currentsz[VBO_ATTRIB_MAX]; }; +#if FEATURE_dlist void vbo_save_init( GLcontext *ctx ); void vbo_save_destroy( GLcontext *ctx ); @@ -181,4 +182,18 @@ void vbo_save_playback_vertex_list( GLcontext *ctx, void *data ); void vbo_save_api_init( struct vbo_save_context *save ); -#endif +#else /* FEATURE_dlist */ + +static INLINE void +vbo_save_init( GLcontext *ctx ) +{ +} + +static INLINE void +vbo_save_destroy( GLcontext *ctx ) +{ +} + +#endif /* FEATURE_dlist */ + +#endif /* VBO_SAVE_H */ diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index c867cb03f63..c3727cb52ac 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -83,6 +83,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "vbo_context.h" +#if FEATURE_dlist + + #ifdef ERROR #undef ERROR #endif @@ -1263,3 +1266,5 @@ void vbo_save_api_init( struct vbo_save_context *save ) _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); } + +#endif /* FEATURE_dlist */ diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index a7cf29acd4f..148ea283312 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -38,6 +38,9 @@ #include "vbo_context.h" +#if FEATURE_dlist + + /* * After playback, copy everything but the position from the * last vertex to the saved state @@ -288,3 +291,6 @@ void vbo_save_playback_vertex_list( GLcontext *ctx, void *data ) */ _playback_copy_to_current( ctx, node ); } + + +#endif /* FEATURE_dlist */ diff --git a/src/mesa/vbo/vbo_save_loopback.c b/src/mesa/vbo/vbo_save_loopback.c index 3f581ea02da..5d1c7e48102 100644 --- a/src/mesa/vbo/vbo_save_loopback.c +++ b/src/mesa/vbo/vbo_save_loopback.c @@ -36,6 +36,8 @@ #include "vbo_context.h" +#if FEATURE_dlist + typedef void (*attr_func)( GLcontext *ctx, GLint target, const GLfloat * ); @@ -188,3 +190,6 @@ void vbo_loopback_vertex_list( GLcontext *ctx, } } } + + +#endif /* FEATURE_dlist */ diff --git a/src/mesa/x86-64/Makefile b/src/mesa/x86-64/Makefile index 9c3e9d2adf8..2fd3e5f04a9 100644 --- a/src/mesa/x86-64/Makefile +++ b/src/mesa/x86-64/Makefile @@ -12,7 +12,6 @@ INCLUDE_DIRS = \ -I.. \ -I../main \ -I../math \ - -I../glapi \ -I../tnl diff --git a/src/mesa/x86/Makefile b/src/mesa/x86/Makefile index 69122c114b0..9716dc27f97 100644 --- a/src/mesa/x86/Makefile +++ b/src/mesa/x86/Makefile @@ -7,10 +7,10 @@ include $(TOP)/configs/current INCLUDE_DIRS = \ -I$(TOP)/include/GL \ -I$(TOP)/include \ + -I$(TOP)/src/mapi \ -I.. \ -I../main \ -I../math \ - -I../glapi \ -I../tnl |