Merge branch 'master' of git://anongit.freedesktop.org/mesa/mesa

This commit is contained in:
Stéphane Marchesin 2011-08-26 17:37:25 -07:00
commit f8e6d19f3f
690 changed files with 49856 additions and 22237 deletions

48
Android.common.mk Normal file
View file

@ -0,0 +1,48 @@
# Mesa 3-D graphics library
#
# Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
# Copyright (C) 2010-2011 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.
LOCAL_C_INCLUDES += \
$(MESA_TOP)/include
LOCAL_CFLAGS += \
-DPTHREADS \
-fvisibility=hidden \
-Wno-sign-compare
ifeq ($(strip $(MESA_ENABLE_ASM)),true)
ifeq ($(TARGET_ARCH),x86)
LOCAL_CFLAGS += \
-DUSE_X86_ASM
endif
endif
LOCAL_CPPFLAGS += \
-Wno-error=non-virtual-dtor \
-Wno-non-virtual-dtor
# uncomment to keep the debug symbols
#LOCAL_STRIP_MODULE := false
ifeq ($(strip $(LOCAL_MODULE_TAGS)),)
LOCAL_MODULE_TAGS := optional
endif

147
Android.mk Normal file
View file

@ -0,0 +1,147 @@
# Mesa 3-D graphics library
#
# Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
# Copyright (C) 2010-2011 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.
# BOARD_GPU_DRIVERS should be defined. The valid values are
#
# classic drivers:
# gallium drivers: swrast r600g
#
# The main target is libGLES_mesa. There is no classic drivers yet.
MESA_TOP := $(call my-dir)
MESA_COMMON_MK := $(MESA_TOP)/Android.common.mk
MESA_PYTHON2 := python
DRM_TOP := external/drm
DRM_GRALLOC_TOP := hardware/drm_gralloc
classic_drivers :=
gallium_drivers := swrast r600g
MESA_GPU_DRIVERS := $(BOARD_GPU_DRIVERS)
# warn about invalid drivers
invalid_drivers := $(filter-out \
$(classic_drivers) $(gallium_drivers), $(MESA_GPU_DRIVERS))
ifneq ($(invalid_drivers),)
$(warning invalid GPU drivers: $(invalid_drivers))
# tidy up
MESA_GPU_DRIVERS := $(filter-out $(invalid_drivers), $(MESA_GPU_DRIVERS))
endif
# host and target must be the same arch to generate matypes.h
ifeq ($(TARGET_ARCH),$(HOST_ARCH))
MESA_ENABLE_ASM := true
else
MESA_ENABLE_ASM := false
endif
ifneq ($(filter $(classic_drivers), $(MESA_GPU_DRIVERS)),)
MESA_BUILD_CLASSIC := true
else
MESA_BUILD_CLASSIC := false
endif
ifneq ($(filter $(gallium_drivers), $(MESA_GPU_DRIVERS)),)
MESA_BUILD_GALLIUM := true
else
MESA_BUILD_GALLIUM := false
endif
ifneq ($(strip $(MESA_GPU_DRIVERS)),)
SUBDIRS := \
src/mapi \
src/glsl \
src/mesa \
src/egl/main
ifeq ($(strip $(MESA_BUILD_GALLIUM)),true)
SUBDIRS += src/gallium
endif
# ---------------------------------------
# Build libGLES_mesa
# ---------------------------------------
LOCAL_PATH := $(MESA_TOP)
include $(CLEAR_VARS)
LOCAL_SRC_FILES :=
LOCAL_CFLAGS :=
LOCAL_C_INCLUDES :=
LOCAL_STATIC_LIBRARIES :=
LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_egl
LOCAL_SHARED_LIBRARIES := \
libglapi \
libdrm \
libdl \
libhardware \
liblog \
libcutils
ifeq ($(strip $(MESA_BUILD_GALLIUM)),true)
gallium_DRIVERS :=
# swrast
gallium_DRIVERS += libmesa_pipe_softpipe libmesa_winsys_sw_android
# r600g
ifneq ($(filter r600g, $(MESA_GPU_DRIVERS)),)
gallium_DRIVERS += libmesa_winsys_radeon
gallium_DRIVERS += libmesa_pipe_r600 libmesa_winsys_r600
endif
#
# Notes about the order here:
#
# * libmesa_st_egl depends on libmesa_winsys_sw_android in $(gallium_DRIVERS)
# * libmesa_st_mesa depends on libmesa_glsl
# * libmesa_glsl depends on libmesa_glsl_utils
#
LOCAL_STATIC_LIBRARIES := \
libmesa_egl_gallium \
libmesa_st_egl \
$(gallium_DRIVERS) \
libmesa_st_mesa \
libmesa_glsl \
libmesa_glsl_utils \
libmesa_gallium \
$(LOCAL_STATIC_LIBRARIES)
endif # MESA_BUILD_GALLIUM
LOCAL_MODULE := libGLES_mesa
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
include $(MESA_COMMON_MK)
include $(BUILD_SHARED_LIBRARY)
mkfiles := $(patsubst %,$(MESA_TOP)/%/Android.mk,$(SUBDIRS))
include $(mkfiles)
endif # MESA_GPU_DRIVERS

View file

@ -21,6 +21,10 @@ all: default
doxygen:
cd doxygen && $(MAKE)
check:
cd src/glsl/tests/ && ./optimization-test
@echo "All tests passed."
clean:
-@touch $(TOP)/configs/current
-@for dir in $(SUBDIRS) ; do \
@ -51,7 +55,7 @@ install:
done
.PHONY: default doxygen clean realclean distclean install
.PHONY: default doxygen clean realclean distclean install check
# If there's no current configuration file
$(TOP)/configs/current:
@ -203,12 +207,6 @@ EXTRA_FILES = \
IGNORE_FILES = \
-x autogen.sh
DEPEND_FILES = \
src/mesa/depend \
src/glx/depend \
src/glw/depend \
src/glu/sgi/depend
parsers: configure
-@touch $(TOP)/configs/current
@ -231,15 +229,9 @@ AUTOCONF = autoconf
AC_FLAGS =
aclocal.m4: configure.ac acinclude.m4
$(ACLOCAL) $(ACLOCAL_FLAGS)
configure: rm_depend configure.ac aclocal.m4 acinclude.m4
configure: configure.ac aclocal.m4 acinclude.m4
$(AUTOCONF) $(AC_FLAGS)
rm_depend:
@for dep in $(DEPEND_FILES) ; do \
rm -f $$dep ; \
touch $$dep ; \
done
manifest.txt: .git
( \
ls -1 $(EXTRA_FILES) ; \
@ -269,4 +261,4 @@ md5: $(ARCHIVES)
@-md5sum $(PACKAGE_NAME).tar.bz2
@-md5sum $(PACKAGE_NAME).zip
.PHONY: tarballs rm_depend md5
.PHONY: tarballs md5

View file

@ -88,6 +88,7 @@ def AddOptions(opts):
opts.Add('toolchain', 'compiler toolchain', default_toolchain)
opts.Add(BoolOption('gles', 'EXPERIMENTAL: enable OpenGL ES support', 'no'))
opts.Add(BoolOption('llvm', 'use LLVM', default_llvm))
opts.Add(BoolOption('openmp', 'EXPERIMENTAL: compile with openmp (swrast)', 'no'))
opts.Add(BoolOption('debug', 'DEPRECATED: debug build', 'yes'))
opts.Add(BoolOption('profile', 'DEPRECATED: profile build', 'no'))
opts.Add(BoolOption('quiet', 'DEPRECATED: profile build', 'yes'))

View file

@ -50,7 +50,6 @@ GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXt
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 mapi/glapi mapi/vgapi glx/apple mesa gallium glu
GLU_DIRS = sgi
DRIVER_DIRS = osmesa

View file

@ -105,7 +105,7 @@ MOTIF_CFLAGS = -I/usr/include/Motif1.2
# Directories to build
LIB_DIR = lib
SRC_DIRS = glsl mapi/glapi mapi/vgapi mesa \
gallium egl gallium/winsys gallium/targets glu glw
gallium egl gallium/winsys gallium/targets glu
GLU_DIRS = sgi
DRIVER_DIRS = x11 osmesa

View file

@ -42,7 +42,7 @@ GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/local/lib -lGL -lXt -lX11
# Directories
SRC_DIRS = glx gallium mesa glu glw
SRC_DIRS = glx gallium mesa glu
DRIVER_DIRS = dri
DRM_SOURCE_PATH=$(TOP)/../drm

View file

@ -36,7 +36,6 @@ CFLAGS = $(COMMON_C_CPP_FLAGS) -Wmissing-prototypes -std=c99
CXXFLAGS = $(COMMON_C_CPP_FLAGS)
# Omitting glw here:
SRC_DIRS = glsl mapi/glapi mapi/vgapi mesa \
gallium gallium/winsys gallium/targets glu

View file

@ -49,7 +49,7 @@ DRI_LIB_DEPS = $(MESA_MODULES) $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(L
GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lm -lpthread -ldl \
$(LIBDRM_LIB) $(shell pkg-config --libs xcb) $(shell pkg-config --libs x11-xcb) $(shell pkg-config --libs xcb-glx)
SRC_DIRS = glx gallium mesa glu glw
SRC_DIRS = glx gallium mesa glu
DRIVER_DIRS = dri
DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon \

View file

@ -48,5 +48,5 @@ GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lm -lpthread -ldl
# Directories
SRC_DIRS = glx glu glw
SRC_DIRS = glx glu
DRIVER_DIRS =

View file

@ -359,7 +359,6 @@ fi
GL_LIB_NAME='lib$(GL_LIB).'${LIB_EXTENSION}
GLU_LIB_NAME='lib$(GLU_LIB).'${LIB_EXTENSION}
GLUT_LIB_NAME='lib$(GLUT_LIB).'${LIB_EXTENSION}
GLW_LIB_NAME='lib$(GLW_LIB).'${LIB_EXTENSION}
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}
@ -372,7 +371,6 @@ GBM_LIB_NAME='lib$(GBM_LIB).'${LIB_EXTENSION}
GL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
GLU_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLU_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
GLUT_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLUT_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
GLW_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GLW_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
OSMESA_LIB_GLOB=${LIB_PREFIX_GLOB}'$(OSMESA_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
EGL_LIB_GLOB=${LIB_PREFIX_GLOB}'$(EGL_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTENSION}'*'
@ -386,7 +384,6 @@ GBM_LIB_GLOB=${LIB_PREFIX_GLOB}'$(GBM_LIB)'${LIB_VERSION_SEPARATOR}'*'${LIB_EXTE
AC_SUBST([GL_LIB_NAME])
AC_SUBST([GLU_LIB_NAME])
AC_SUBST([GLUT_LIB_NAME])
AC_SUBST([GLW_LIB_NAME])
AC_SUBST([OSMESA_LIB_NAME])
AC_SUBST([EGL_LIB_NAME])
AC_SUBST([GLESv1_CM_LIB_NAME])
@ -399,7 +396,6 @@ AC_SUBST([GBM_LIB_NAME])
AC_SUBST([GL_LIB_GLOB])
AC_SUBST([GLU_LIB_GLOB])
AC_SUBST([GLUT_LIB_GLOB])
AC_SUBST([GLW_LIB_GLOB])
AC_SUBST([OSMESA_LIB_GLOB])
AC_SUBST([EGL_LIB_GLOB])
AC_SUBST([GLESv1_CM_LIB_GLOB])
@ -951,7 +947,7 @@ xyesyes)
GL_PC_LIB_PRIV="$GL_LIB_DEPS"
GL_PC_CFLAGS="$X11_INCLUDES"
fi
GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread"
GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $DLOPEN_LIBS"
GL_PC_LIB_PRIV="$GL_PC_LIB_PRIV $SELINUX_LIBS -lm -lpthread"
# if static, move the external libraries to the programs
@ -1073,11 +1069,6 @@ AC_SUBST([MESA_MODULES])
AC_SUBST([HAVE_XF86VIDMODE])
PKG_CHECK_MODULES([LIBDRM_RADEON],
[libdrm_radeon >= $LIBDRM_RADEON_REQUIRED],
HAVE_LIBDRM_RADEON=yes,
HAVE_LIBDRM_RADEON=no)
dnl
dnl More GLX setup
dnl
@ -1270,6 +1261,11 @@ esac
case $DRI_DIRS in
*radeon*|*r200*|*r300*|*r600*)
PKG_CHECK_MODULES([LIBDRM_RADEON],
[libdrm_radeon >= $LIBDRM_RADEON_REQUIRED],
HAVE_LIBDRM_RADEON=yes,
HAVE_LIBDRM_RADEON=no)
if test "x$HAVE_LIBDRM_RADEON" = xyes; then
RADEON_CFLAGS="-DHAVE_LIBDRM_RADEON=1 $LIBDRM_RADEON_CFLAGS"
RADEON_LDFLAGS=$LIBDRM_RADEON_LIBS
@ -1325,47 +1321,6 @@ AC_SUBST([OSMESA_MESA_DEPS])
AC_SUBST([OSMESA_PC_REQ])
AC_SUBST([OSMESA_PC_LIB_PRIV])
dnl
dnl EGL configuration
dnl
EGL_CLIENT_APIS=""
if test "x$enable_egl" = xyes; then
SRC_DIRS="$SRC_DIRS egl"
EGL_LIB_DEPS="$DLOPEN_LIBS $SELINUX_LIBS -lpthread"
EGL_DRIVERS_DIRS=""
if test "$enable_static" != yes; then
# build egl_glx when libGL is built
if test "x$enable_glx" = xyes; then
EGL_DRIVERS_DIRS="glx"
fi
PKG_CHECK_MODULES([LIBUDEV], [libudev > 150],
[have_libudev=yes],[have_libudev=no])
if test "$have_libudev" = yes; then
DEFINES="$DEFINES -DHAVE_LIBUDEV"
fi
if test "x$enable_dri" = xyes; then
# build egl_dri2 when xcb-dri2 is available
PKG_CHECK_MODULES([XCB_DRI2], [x11-xcb xcb-dri2 xcb-xfixes],
[have_xcb_dri2=yes],[have_xcb_dri2=no])
if test "$have_xcb_dri2" = yes; then
EGL_DRIVER_DRI2=dri2
DEFINES="$DEFINES -DHAVE_XCB_DRI2"
# workaround a bug in xcb-dri2 generated by xcb-proto 1.6
AC_CHECK_LIB(xcb-dri2, xcb_dri2_connect_alignment_pad, [],
[DEFINES="$DEFINES -DXCB_DRI2_CONNECT_DEVICE_NAME_BROKEN"])
fi
fi
EGL_DRIVERS_DIRS="$EGL_DRIVERS_DIRS $EGL_DRIVER_DRI2"
fi
fi
AC_SUBST([EGL_LIB_DEPS])
AC_SUBST([EGL_DRIVERS_DIRS])
dnl
dnl gbm configuration
dnl
@ -1401,6 +1356,49 @@ AC_SUBST([GBM_PC_REQ_PRIV])
AC_SUBST([GBM_PC_LIB_PRIV])
AC_SUBST([GBM_PC_CFLAGS])
dnl
dnl EGL configuration
dnl
EGL_CLIENT_APIS=""
if test "x$enable_egl" = xyes; then
SRC_DIRS="$SRC_DIRS egl"
EGL_LIB_DEPS="$DLOPEN_LIBS $SELINUX_LIBS -lpthread"
EGL_DRIVERS_DIRS=""
AC_CHECK_FUNC(mincore, [DEFINES="$DEFINES -DHAVE_MINCORE"])
if test "$enable_static" != yes; then
# build egl_glx when libGL is built
if test "x$enable_glx" = xyes; then
EGL_DRIVERS_DIRS="glx"
fi
PKG_CHECK_MODULES([LIBUDEV], [libudev > 150],
[have_libudev=yes],[have_libudev=no])
if test "$have_libudev" = yes; then
DEFINES="$DEFINES -DHAVE_LIBUDEV"
fi
if test "x$enable_dri" = xyes; then
# build egl_dri2 when xcb-dri2 is available
PKG_CHECK_MODULES([XCB_DRI2], [x11-xcb xcb-dri2 xcb-xfixes],
[have_xcb_dri2=yes],[have_xcb_dri2=no])
if test "$have_xcb_dri2" = yes; then
EGL_DRIVER_DRI2=dri2
DEFINES="$DEFINES -DHAVE_XCB_DRI2"
# workaround a bug in xcb-dri2 generated by xcb-proto 1.6
AC_CHECK_LIB(xcb-dri2, xcb_dri2_connect_alignment_pad, [],
[DEFINES="$DEFINES -DXCB_DRI2_CONNECT_DEVICE_NAME_BROKEN"])
fi
fi
EGL_DRIVERS_DIRS="$EGL_DRIVERS_DIRS $EGL_DRIVER_DRI2"
fi
fi
AC_SUBST([EGL_LIB_DEPS])
AC_SUBST([EGL_DRIVERS_DIRS])
dnl
dnl EGL Gallium configuration
dnl
@ -1602,77 +1600,6 @@ AC_SUBST([GLU_PC_REQ_PRIV])
AC_SUBST([GLU_PC_LIB_PRIV])
AC_SUBST([GLU_PC_CFLAGS])
dnl
dnl GLw configuration
dnl
AC_ARG_ENABLE([glw],
[AS_HELP_STRING([--disable-glw],
[enable Xt/Motif widget library @<:@default=enabled@:>@])],
[enable_glw="$enableval"],
[enable_glw=yes])
dnl Don't build GLw on osmesa
if test "x$enable_glw" = xyes -a "x$enable_glx" = xno; then
AC_MSG_NOTICE([Disabling GLw since there is no OpenGL driver])
enable_glw=no
fi
AC_ARG_ENABLE([motif],
[AS_HELP_STRING([--enable-motif],
[use Motif widgets in GLw @<:@default=disabled@:>@])],
[enable_motif="$enableval"],
[enable_motif=no])
if test "x$enable_glw" = xyes; then
SRC_DIRS="$SRC_DIRS glw"
if test "$x11_pkgconfig" = yes; then
PKG_CHECK_MODULES([GLW],[x11 xt])
GLW_PC_REQ_PRIV="x11 xt"
GLW_LIB_DEPS="$GLW_LIBS"
else
# should check these...
GLW_LIB_DEPS="$X_LIBS -lXt -lX11"
GLW_PC_LIB_PRIV="$GLW_LIB_DEPS"
GLW_PC_CFLAGS="$X11_INCLUDES"
fi
GLW_SOURCES="GLwDrawA.c"
MOTIF_CFLAGS=
if test "x$enable_motif" = xyes; then
GLW_SOURCES="$GLW_SOURCES GLwMDrawA.c"
AC_PATH_PROG([MOTIF_CONFIG], [motif-config], [no])
if test "x$MOTIF_CONFIG" != xno; then
MOTIF_CFLAGS=`$MOTIF_CONFIG --cflags`
MOTIF_LIBS=`$MOTIF_CONFIG --libs`
else
AC_CHECK_HEADER([Xm/PrimitiveP.h], [],
[AC_MSG_ERROR([Can't locate Motif headers])])
AC_CHECK_LIB([Xm], [XmGetPixmap], [MOTIF_LIBS="-lXm"],
[AC_MSG_ERROR([Can't locate Motif Xm library])])
fi
# MOTIF_LIBS is prepended to GLW_LIB_DEPS since Xm needs Xt/X11
GLW_LIB_DEPS="$MOTIF_LIBS $GLW_LIB_DEPS"
GLW_PC_LIB_PRIV="$MOTIF_LIBS $GLW_PC_LIB_PRIV"
GLW_PC_CFLAGS="$MOTIF_CFLAGS $GLW_PC_CFLAGS"
fi
# If static, empty GLW_LIB_DEPS and add libs for programs to link
GLW_PC_LIB_PRIV="$GLW_PC_LIB_PRIV"
if test "$enable_static" = no; then
GLW_MESA_DEPS='-l$(GL_LIB)'
GLW_LIB_DEPS="$GLW_LIB_DEPS"
else
APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
GLW_LIB_DEPS=""
GLW_MESA_DEPS=""
fi
fi
AC_SUBST([GLW_LIB_DEPS])
AC_SUBST([GLW_MESA_DEPS])
AC_SUBST([GLW_SOURCES])
AC_SUBST([MOTIF_CFLAGS])
AC_SUBST([GLW_PC_REQ_PRIV])
AC_SUBST([GLW_PC_LIB_PRIV])
AC_SUBST([GLW_PC_CFLAGS])
dnl
dnl Program library dependencies
dnl Only libm is added here if necessary as the libraries should
@ -1699,9 +1626,6 @@ dnl Gallium configuration
dnl
if test "x$with_gallium_drivers" != x; then
SRC_DIRS="$SRC_DIRS gallium gallium/winsys gallium/targets"
AC_PATH_PROG([LLVM_CONFIG], [llvm-config], [no])
else
LLVM_CONFIG=no
fi
AC_SUBST([LLVM_CFLAGS])
@ -1821,6 +1745,8 @@ if test "x$enable_gallium_llvm" = xauto; then
esac
fi
if test "x$enable_gallium_llvm" = xyes; then
AC_PATH_PROG([LLVM_CONFIG], [llvm-config], [no])
if test "x$LLVM_CONFIG" != xno; then
LLVM_VERSION=`$LLVM_CONFIG --version`
LLVM_CFLAGS=`$LLVM_CONFIG --cppflags|sed 's/-DNDEBUG\>//g'`
@ -1929,7 +1855,7 @@ if test "x$with_gallium_drivers" != x; then
;;
xr600)
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600"
gallium_check_st "r600/drm" "dri-r600" "" "" "xvmc-r600" "vdpau-r600" "va-r600"
gallium_check_st "r600/drm radeon/drm" "dri-r600" "xorg-r600" "" "xvmc-r600" "vdpau-r600" "va-r600"
;;
xnouveau)
PKG_CHECK_MODULES([NOUVEAU], [libdrm_nouveau >= $LIBDRM_NOUVEAU_REQUIRED])
@ -1937,11 +1863,12 @@ if test "x$with_gallium_drivers" != x; then
gallium_check_st "nouveau/drm" "dri-nouveau" "xorg-nouveau" "" "xvmc-nouveau"
;;
xswrast)
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS softpipe"
if test "x$MESA_LLVM" = x1; then
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
fi
if test "x$HAVE_ST_DRI" = xyes; then
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS softpipe"
if test "x$MESA_LLVM" = x1; then
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
fi
GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS dri-swrast"
fi
if test "x$HAVE_ST_VDPAU" = xyes; then
@ -1959,9 +1886,6 @@ if test "x$with_gallium_drivers" != x; then
if test "x$HAVE_WINSYS_XLIB" != xyes; then
GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS sw/xlib"
fi
if test "x$HAVE_ST_DRI" != xyes; then
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS softpipe"
fi
fi
;;
*)
@ -2054,7 +1978,6 @@ esac
echo ""
echo " GLU: $enable_glu"
echo " GLw: $enable_glw (Motif: $enable_motif)"
dnl EGL
echo ""

View file

@ -114,6 +114,19 @@ GL_ARB_vertex_attrib_64bit not started
GL_ARB_viewport_array not started
GL 4.2:
GLSL 4.2 not started
GL_ARB_texture_compression_bptc not started
GL_ARB_compressed_texture_pixel_storage not started
GL_ARB_shader_atomic_counters not started
GL_ARB_texture_storage not started
GL_ARB_transform_feedback_instanced not started
GL_ARB_base_instance not started
GL_ARB_shader_image_load_store not started
GL_ARB_conservative_depth DONE (compiler)
GL_ARB_shading_language_420pack not started
GL_ARB_internalformat_query not started
GL_ARB_map_buffer_alignment not started
More info about these features and the work involved can be found at

View file

@ -20,7 +20,6 @@
<li><a href="#library">Library Options</a></li>
<ul>
<li><a href="#glu">GLU</a></li>
<li><a href="#glw">GLw</a></li>
</ul>
<li><a href="#demos">Demo Program Options</a></li>
</ol>
@ -245,12 +244,6 @@ instructions</a>.
on all drivers. This can be disable with the option
<code>--disable-glu</code>.
</li>
<a name="glw">
<li><b><em>GLw</em></b> - The libGLw library will be built by default
if libGLU has been enabled. This can be disable with the option
<code>--disable-glw</code>.
</li>
</ul>
</p>

View file

@ -63,6 +63,7 @@ a:visited {
<LI><A HREF="extensions.html" target="MainFrame">Mesa Extensions</A>
<LI><A HREF="mangling.html" target="MainFrame">Function Name Mangling</A>
<LI><A href="llvmpipe.html" target="MainFrame">Gallium llvmpipe driver</A>
<LI><A href="postprocess.html" target="MainFrame">Gallium post-processing</A>
</ul>
<b>Developer Topics</b>

View file

@ -71,6 +71,13 @@ well documented. Also, strive to write clean, easily understandable code.
If you use tabs, set them to 8 columns
</p>
<p>
Line width: the preferred width to fill comments and code in Mesa is 78
columns. Exceptions are sometimes made for clarity (e.g. tabular data is
sometimes filled to a much larger width so that extraneous carriage returns
don't obscure the table).
</p>
<p>
Brace example:
</p>
@ -81,10 +88,26 @@ Brace example:
else {
bar;
}
switch (condition) {
case 0:
foo();
break;
case 1: {
...
break;
}
default:
...
break;
}
</pre>
<p>
Here's the GNU indent command which will best approximate my preferred style:
(Note that it won't format switch statements in the preferred way)
</p>
<pre>
indent -br -i3 -npcs --no-tabs infile.c -o outfile.c
@ -114,6 +137,16 @@ Function name examples:
_mesa_foo_bar() - an internal non-static Mesa function
</pre>
<p>
Places that are not directly visible to the GL API should prefer the use
of <tt>bool</tt>, <tt>true</tt>, and
<tt>false</tt> over <tt>GLboolean</tt>, <tt>GL_TRUE</tt>, and
<tt>GL_FALSE</tt>. In C code, this may mean that
<tt>#include &lt;stdbool.h&gt;</tt> need to be added. The
<tt>try_emit_</tt>* methods in src/mesa/program/ir_to_mesa.cpp and
src/mesa/state_tracker/st_glsl_to_tgsi.cpp can serve as an example.
</p>
<H2>Making a New Mesa Release</H2>

View file

@ -84,7 +84,6 @@ src/mesa - sources for the main Mesa library and device drivers
src/gallium - sources for Gallium and Gallium drivers
src/glu - libGLU source code
src/glx - sources for building libGL with full GLX and DRI support
src/glw - Xt/Motif/OpenGL widget code
</pre>
If you downloaded and unpacked the MesaGLUT.x.y.z package:

View file

@ -204,8 +204,13 @@ If you don't already have GLUT installed, you should grab
</a></p>
<h2><a name="part2">2.4 Where is the GLw library?</a></h2>
<p>
<a name="part2">GLw (OpenGL widget library) is now available from a separate <a href="http://cgit.freedesktop.org/mesa/glw/">git repository</a>. Unless you're using very old Xt/Motif applications with OpenGL, you shouldn't need it.
</a></p>
<h2><a name="part2">2.4 What's the proper place for the libraries and headers?</a></h2>
<h2><a name="part2">2.5 What's the proper place for the libraries and headers?</a></h2>
<p>
<a name="part2">On Linux-based systems you'll want to follow the
</a><a href="http://oss.sgi.com/projects/ogl-sample/ABI/index.html"

View file

@ -157,9 +157,6 @@ lrwxrwxrwx 1 brian users 20 Mar 26 07:53 libGLU.so.1 -> libGLU.so
lrwxrwxrwx 1 brian users 12 Mar 26 07:53 libglut.so -> libglut.so.3*
lrwxrwxrwx 1 brian users 16 Mar 26 07:53 libglut.so.3 -> libglut.so.3.7.1*
-rwxr-xr-x 1 brian users 597754 Mar 26 07:53 libglut.so.3.7.1*
lrwxrwxrwx 1 brian users 11 Mar 26 08:04 libGLw.so -> libGLw.so.1*
lrwxrwxrwx 1 brian users 15 Mar 26 08:04 libGLw.so.1 -> libGLw.so.1.0.0*
-rwxr-xr-x 1 brian users 20750 Mar 26 08:04 libGLw.so.1.0.0*
lrwxrwxrwx 1 brian users 14 Mar 26 07:53 libOSMesa.so -> libOSMesa.so.6*
lrwxrwxrwx 1 brian users 23 Mar 26 07:53 libOSMesa.so.6 -> libOSMesa.so.6.1.060100*
-rwxr-xr-x 1 brian users 23871 Mar 26 07:53 libOSMesa.so.6.1.060100*
@ -172,8 +169,6 @@ lrwxrwxrwx 1 brian users 23 Mar 26 07:53 libOSMesa.so.6 -> libOSM
<br>
<b>libglut</b> is the GLUT library.
<br>
<b>libGLw</b> is the Xt/Motif OpenGL drawing area widget library.
<br>
<b>libOSMesa</b> is the OSMesa (Off-Screen) interface library.
</p>

56
docs/postprocess.html Normal file
View file

@ -0,0 +1,56 @@
<HTML>
<TITLE>Gallium Post-processing</TITLE>
<link rel="stylesheet" type="text/css" href="mesa.css"></head>
<BODY>
<H1>Gallium Post-processing</H1>
<p>
The Gallium drivers support user-defined image post-processing.
At the end of drawing a frame a post-processing filter can be applied to
the rendered image.
Example filters include morphological antialiasing and cell shading.
</p>
<p>
The filters can be toggled per-app via driconf, or per-session via the
corresponding environment variables.
</p>
<p>
Multiple filters can be used together.
</p>
<H2>PP environment variables</H2>
<ul>
<li>PP_DEBUG - If defined debug information will be printed to stderr.
</ul>
<h2>Current filters</h2>
<ul>
<li>pp_nored, pp_nogreen, pp_noblue - set to 1 to remove the corresponding color channel.
These are basic filters for easy testing of the PP queue.
<li>pp_jimenezmlaa, pp_jimenezmlaa_color -
<a href="http://www.iryokufx.com/mlaa/" target=_blank>Jimenez's MLAA</a>
is a morphological antialiasing filter.
The two versions use depth and color data, respectively.
Which works better depends on the app - depth will not blur text, but it will
miss transparent textures for example.
Set to a number from 2 to 32, roughly corresponding to quality.
Numbers higher than 8 see minimizing gains.
<li>pp_celshade - set to 1 to enable cell shading (a more complex color filter).
</ul>
<br>
<br>
</BODY>
</HTML>

View file

@ -153,8 +153,6 @@ each directory.
<li><b>glx</b> - The GLX library code for building libGL. This is used for
direct rendering drivers. It will dynamically load one of the
xxx_dri.so drivers.
<li><b>glw</b> - Widgets for Xt/Motif.
<li><b>glew</b> - OpenGL Extension Wrangler library (used by demo programs)
</ul>
<li><b>progs</b> - OpenGL test and demonstration programs
<li><b>lib</b> - where the GL libraries are placed

View file

@ -390,6 +390,20 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOK) (EGLDisplay dpy, EG
#define EGL_Y_INVERTED_NOK 0x307F
#endif /* EGL_NOK_texture_from_pixmap */
#ifndef EGL_ANDROID_image_native_buffer
#define EGL_ANDROID_image_native_buffer 1
struct android_native_buffer_t;
#define EGL_NATIVE_BUFFER_ANDROID 0x3140 /* eglCreateImageKHR target */
#endif
#ifndef EGL_ANDROID_swap_rectangle
#define EGL_ANDROID_swap_rectangle 1
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglSetSwapRectangleANDROID (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSWAPRECTANGLEANDROIDPROC) (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height);
#endif
#ifdef __cplusplus
}

View file

@ -90,6 +90,15 @@ typedef struct gbm_device *EGLNativeDisplayType;
typedef struct gbm_bo *EGLNativePixmapType;
typedef void *EGLNativeWindowType;
#elif defined(ANDROID) /* Android */
struct ANativeWindow;
struct egl_native_pixmap_t;
typedef struct ANativeWindow *EGLNativeWindowType;
typedef struct egl_native_pixmap_t *EGLNativePixmapType;
typedef void *EGLNativeDisplayType;
#elif defined(__unix__) || defined(__unix)
#ifdef MESA_EGL_NO_X11_HEADERS

View file

@ -29,9 +29,9 @@ extern "C" {
*/
/* Header file version number, required by OpenGL ABI for Linux */
/* glext.h last updated $Date: 2011-07-06 02:49:14 -0700 (Wed, 06 Jul 2011) $ */
/* glext.h last updated $Date: 2011-08-08 00:34:29 -0700 (Mon, 08 Aug 2011) $ */
/* Current version at http://www.opengl.org/registry/ */
#define GL_GLEXT_VERSION 71
#define GL_GLEXT_VERSION 72
/* Function declaration macros - to move into glplatform.h */
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
@ -1047,6 +1047,124 @@ extern "C" {
/* reuse GL_UNDEFINED_VERTEX */
#endif
#ifndef GL_VERSION_4_2
/* Reuse tokens from ARB_base_instance (none) */
/* Reuse tokens from ARB_shading_language_420pack (none) */
/* Reuse tokens from ARB_transform_feedback_instanced (none) */
/* Reuse tokens from ARB_compressed_texture_pixel_storage */
/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */
/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */
/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */
/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */
/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */
/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */
/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */
/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */
/* Reuse tokens from ARB_conservative_depth (none) */
/* Reuse tokens from ARB_internalformat_query */
/* reuse GL_NUM_SAMPLE_COUNTS */
/* Reuse tokens from ARB_map_buffer_alignment */
/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */
/* Reuse tokens from ARB_shader_atomic_counters */
/* reuse GL_ATOMIC_COUNTER_BUFFER */
/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */
/* reuse GL_ATOMIC_COUNTER_BUFFER_START */
/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */
/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */
/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */
/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */
/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */
/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */
/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */
/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */
/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */
/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */
/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */
/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */
/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */
/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */
/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */
/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */
/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */
/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */
/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */
/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */
/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */
/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */
/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */
/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */
/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */
/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */
/* Reuse tokens from ARB_shader_image_load_store */
/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */
/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */
/* reuse GL_UNIFORM_BARRIER_BIT */
/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */
/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */
/* reuse GL_COMMAND_BARRIER_BIT */
/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */
/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */
/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */
/* reuse GL_FRAMEBUFFER_BARRIER_BIT */
/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */
/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */
/* reuse GL_ALL_BARRIER_BITS */
/* reuse GL_MAX_IMAGE_UNITS */
/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */
/* reuse GL_IMAGE_BINDING_NAME */
/* reuse GL_IMAGE_BINDING_LEVEL */
/* reuse GL_IMAGE_BINDING_LAYERED */
/* reuse GL_IMAGE_BINDING_LAYER */
/* reuse GL_IMAGE_BINDING_ACCESS */
/* reuse GL_IMAGE_1D */
/* reuse GL_IMAGE_2D */
/* reuse GL_IMAGE_3D */
/* reuse GL_IMAGE_2D_RECT */
/* reuse GL_IMAGE_CUBE */
/* reuse GL_IMAGE_BUFFER */
/* reuse GL_IMAGE_1D_ARRAY */
/* reuse GL_IMAGE_2D_ARRAY */
/* reuse GL_IMAGE_CUBE_MAP_ARRAY */
/* reuse GL_IMAGE_2D_MULTISAMPLE */
/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */
/* reuse GL_INT_IMAGE_1D */
/* reuse GL_INT_IMAGE_2D */
/* reuse GL_INT_IMAGE_3D */
/* reuse GL_INT_IMAGE_2D_RECT */
/* reuse GL_INT_IMAGE_CUBE */
/* reuse GL_INT_IMAGE_BUFFER */
/* reuse GL_INT_IMAGE_1D_ARRAY */
/* reuse GL_INT_IMAGE_2D_ARRAY */
/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */
/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */
/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */
/* reuse GL_UNSIGNED_INT_IMAGE_1D */
/* reuse GL_UNSIGNED_INT_IMAGE_2D */
/* reuse GL_UNSIGNED_INT_IMAGE_3D */
/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */
/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */
/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */
/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */
/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */
/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */
/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */
/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */
/* reuse GL_MAX_IMAGE_SAMPLES */
/* reuse GL_IMAGE_BINDING_FORMAT */
/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */
/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */
/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */
/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */
/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */
/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */
/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */
/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */
/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */
/* Reuse tokens from ARB_shading_language_packing (none) */
/* Reuse tokens from ARB_texture_storage */
/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */
#endif
#ifndef GL_ARB_multitexture
#define GL_TEXTURE0_ARB 0x84C0
#define GL_TEXTURE1_ARB 0x84C1
@ -2140,6 +2258,143 @@ extern "C" {
#ifndef GL_ARB_shader_stencil_export
#endif
#ifndef GL_ARB_base_instance
#endif
#ifndef GL_ARB_shading_language_420pack
#endif
#ifndef GL_ARB_transform_feedback_instanced
#endif
#ifndef GL_ARB_compressed_texture_pixel_storage
#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127
#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128
#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129
#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A
#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B
#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C
#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D
#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E
#endif
#ifndef GL_ARB_conservative_depth
#endif
#ifndef GL_ARB_internalformat_query
#define GL_NUM_SAMPLE_COUNTS 0x9380
#endif
#ifndef GL_ARB_map_buffer_alignment
#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC
#endif
#ifndef GL_ARB_shader_atomic_counters
#define GL_ATOMIC_COUNTER_BUFFER 0x92C0
#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1
#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2
#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3
#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4
#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5
#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6
#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7
#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8
#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9
#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA
#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB
#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC
#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD
#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE
#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF
#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0
#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1
#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2
#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3
#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4
#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5
#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6
#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7
#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8
#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC
#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9
#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA
#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB
#endif
#ifndef GL_ARB_shader_image_load_store
#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001
#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002
#define GL_UNIFORM_BARRIER_BIT 0x00000004
#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008
#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
#define GL_COMMAND_BARRIER_BIT 0x00000040
#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080
#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100
#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200
#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400
#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800
#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000
#define GL_ALL_BARRIER_BITS 0xFFFFFFFF
#define GL_MAX_IMAGE_UNITS 0x8F38
#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39
#define GL_IMAGE_BINDING_NAME 0x8F3A
#define GL_IMAGE_BINDING_LEVEL 0x8F3B
#define GL_IMAGE_BINDING_LAYERED 0x8F3C
#define GL_IMAGE_BINDING_LAYER 0x8F3D
#define GL_IMAGE_BINDING_ACCESS 0x8F3E
#define GL_IMAGE_1D 0x904C
#define GL_IMAGE_2D 0x904D
#define GL_IMAGE_3D 0x904E
#define GL_IMAGE_2D_RECT 0x904F
#define GL_IMAGE_CUBE 0x9050
#define GL_IMAGE_BUFFER 0x9051
#define GL_IMAGE_1D_ARRAY 0x9052
#define GL_IMAGE_2D_ARRAY 0x9053
#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054
#define GL_IMAGE_2D_MULTISAMPLE 0x9055
#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056
#define GL_INT_IMAGE_1D 0x9057
#define GL_INT_IMAGE_2D 0x9058
#define GL_INT_IMAGE_3D 0x9059
#define GL_INT_IMAGE_2D_RECT 0x905A
#define GL_INT_IMAGE_CUBE 0x905B
#define GL_INT_IMAGE_BUFFER 0x905C
#define GL_INT_IMAGE_1D_ARRAY 0x905D
#define GL_INT_IMAGE_2D_ARRAY 0x905E
#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F
#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060
#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061
#define GL_UNSIGNED_INT_IMAGE_1D 0x9062
#define GL_UNSIGNED_INT_IMAGE_2D 0x9063
#define GL_UNSIGNED_INT_IMAGE_3D 0x9064
#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065
#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066
#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067
#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068
#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069
#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A
#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B
#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C
#define GL_MAX_IMAGE_SAMPLES 0x906D
#define GL_IMAGE_BINDING_FORMAT 0x906E
#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7
#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8
#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9
#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA
#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB
#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC
#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD
#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE
#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF
#endif
#ifndef GL_ARB_shading_language_packing
#endif
#ifndef GL_ARB_texture_storage
#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F
#endif
#ifndef GL_EXT_abgr
#define GL_ABGR_EXT 0x8000
#endif
@ -5917,7 +6172,7 @@ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB,
#ifndef GL_VERSION_4_1
#define GL_VERSION_4_1 1
/* OpenGL 4.1 also reuses entry points from these extensions: */
/* OpenGL 4.1 reuses entry points from these extensions: */
/* ARB_ES2_compatibility */
/* ARB_get_program_binary */
/* ARB_separate_shader_objects */
@ -5926,6 +6181,22 @@ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB,
/* ARB_viewport_array */
#endif
#ifndef GL_VERSION_4_2
#define GL_VERSION_4_2 1
/* OpenGL 4.2 reuses entry points from these extensions: */
/* ARB_base_instance */
/* ARB_shading_language_420pack (no entry points) */
/* ARB_transform_feedback_instanced */
/* ARB_compressed_texture_pixel_storage (no entry points) */
/* ARB_conservative_depth (no entry points) */
/* ARB_internalformat_query */
/* ARB_map_buffer_alignment (no entry points) */
/* ARB_shader_atomic_counters */
/* ARB_shader_image_load_store */
/* ARB_shading_language_packing (no entry points) */
/* ARB_texture_storage */
#endif
#ifndef GL_ARB_multitexture
#define GL_ARB_multitexture 1
#ifdef GL_GLEXT_PROTOTYPES
@ -6851,6 +7122,10 @@ typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum
typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params);
#endif
#ifndef GL_ARB_shader_bit_encoding
#define GL_ARB_shader_bit_encoding 1
#endif
#ifndef GL_ARB_texture_rgb10_a2ui
#define GL_ARB_texture_rgb10_a2ui 1
#endif
@ -7357,6 +7632,92 @@ typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint locati
#define GL_ARB_shader_stencil_export 1
#endif
#ifndef GL_ARB_base_instance
#define GL_ARB_base_instance 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance);
GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance);
GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance);
typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance);
typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance);
#endif
#ifndef GL_ARB_shading_language_420pack
#define GL_ARB_shading_language_420pack 1
#endif
#ifndef GL_ARB_transform_feedback_instanced
#define GL_ARB_transform_feedback_instanced 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei primcount);
GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei primcount);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount);
typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount);
#endif
#ifndef GL_ARB_compressed_texture_pixel_storage
#define GL_ARB_compressed_texture_pixel_storage 1
#endif
#ifndef GL_ARB_conservative_depth
#define GL_ARB_conservative_depth 1
#endif
#ifndef GL_ARB_internalformat_query
#define GL_ARB_internalformat_query 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
#endif
#ifndef GL_ARB_map_buffer_alignment
#define GL_ARB_map_buffer_alignment 1
#endif
#ifndef GL_ARB_shader_atomic_counters
#define GL_ARB_shader_atomic_counters 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params);
#endif
#ifndef GL_ARB_shader_image_load_store
#define GL_ARB_shader_image_load_store 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers);
#endif
#ifndef GL_ARB_shading_language_packing
#define GL_ARB_shading_language_packing 1
#endif
#ifndef GL_ARB_texture_storage
#define GL_ARB_texture_storage 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
#endif
#ifndef GL_EXT_abgr
#define GL_EXT_abgr 1
#endif

View file

@ -694,6 +694,9 @@ struct __DRIswrastExtensionRec {
#define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */
#define __DRI_BUFFER_HIZ 10
/* Inofficial and for internal use. Increase when adding a new buffer token. */
#define __DRI_BUFFER_COUNT 11
struct __DRIbufferRec {
unsigned int attachment;
unsigned int name;

View file

@ -128,6 +128,42 @@ res_builder = SCons.Builder.Builder(action=res_action, suffix='.o',
source_scanner=SCons.Tool.SourceFileScanner)
SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan)
def compile_without_gstabs(env, sources, c_file):
'''This is a hack used to compile some source files without the
-gstabs option.
It seems that some versions of mingw32's gcc (4.4.2 at least) die
when compiling large files with the -gstabs option. -gstabs is
related to debug symbols and can be omitted from the effected
files.
This function compiles the given c_file without -gstabs, removes
the c_file from the sources list, then appends the new .o file to
sources. Then return the new sources list.
'''
# Modify CCFLAGS to not have -gstabs option:
env2 = env.Clone()
flags = str(env2['CCFLAGS'])
flags = flags.replace("-gstabs", "")
env2['CCFLAGS'] = SCons.Util.CLVar(flags)
# Build the special-case files:
obj_file = env2.SharedObject(c_file)
# Replace ".cpp" or ".c" with ".o"
o_file = c_file.replace(".cpp", ".o")
o_file = o_file.replace(".c", ".o")
# Replace the .c files with the specially-compiled .o file
sources.remove(c_file)
sources.append(o_file)
return sources
def generate(env):
mingw_prefix = find(env)
@ -197,5 +233,7 @@ def generate(env):
# Avoid depending on gcc runtime DLLs
env.AppendUnique(LINKFLAGS = ['-static-libgcc'])
env.AddMethod(compile_without_gstabs, 'compile_without_gstabs')
def exists(env):
return find(env)

View file

@ -42,6 +42,7 @@ import SCons.Scanner
import fixes
import source_list
def quietCommandLines(env):
# Quiet command lines
@ -229,6 +230,40 @@ def createPkgConfigMethods(env):
env.AddMethod(pkg_use_modules, 'PkgUseModules')
def parse_source_list(env, filename, names=None):
# parse the source list file
parser = source_list.SourceListParser()
src = env.File(filename).srcnode()
sym_table = parser.parse(src.abspath)
if names:
if isinstance(names, basestring):
names = [names]
symbols = names
else:
symbols = sym_table.keys()
# convert the symbol table to source lists
src_lists = {}
for sym in symbols:
val = sym_table[sym]
src_lists[sym] = [f for f in val.split(' ') if f]
# if names are given, concatenate the lists
if names:
srcs = []
for name in names:
srcs.extend(src_lists[name])
return srcs
else:
return src_lists
def createParseSourceListMethod(env):
env.AddMethod(parse_source_list, 'ParseSourceList')
def generate(env):
"""Common environment generation code"""
@ -240,6 +275,7 @@ def generate(env):
createConvenienceLibBuilder(env)
createCodeGenerateMethod(env)
createPkgConfigMethods(env)
createParseSourceListMethod(env)
# for debugging
#print env.Dump()

View file

@ -596,6 +596,18 @@ def generate(env):
libs += ['m', 'pthread', 'dl']
env.Append(LIBS = libs)
# OpenMP
if env['openmp']:
if env['msvc']:
env.Append(CCFLAGS = ['/openmp'])
# When building openmp release VS2008 link.exe crashes with LNK1103 error.
# Workaround: overwrite PDB flags with empty value as it isn't required anyways
if env['build'] == 'release':
env['PDB'] = ''
if env['gcc']:
env.Append(CCFLAGS = ['-fopenmp'])
env.Append(LIBS = ['gomp'])
# Load tools
env.Tool('lex')
env.Tool('yacc')

View file

@ -92,7 +92,21 @@ def generate(env):
'HAVE_STDINT_H',
])
env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')])
if llvm_version >= distutils.version.LooseVersion('2.7'):
if llvm_version >= distutils.version.LooseVersion('2.9'):
# 2.9
env.Prepend(LIBS = [
'LLVMObject', 'LLVMMCJIT', 'LLVMMCDisassembler',
'LLVMLinker', 'LLVMipo', 'LLVMInterpreter',
'LLVMInstrumentation', 'LLVMJIT', 'LLVMExecutionEngine',
'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser',
'LLVMMCParser', 'LLVMX86AsmPrinter', 'LLVMX86CodeGen',
'LLVMSelectionDAG', 'LLVMX86Utils', 'LLVMX86Info', 'LLVMAsmPrinter',
'LLVMCodeGen', 'LLVMScalarOpts', 'LLVMInstCombine',
'LLVMTransformUtils', 'LLVMipa', 'LLVMAsmParser',
'LLVMArchive', 'LLVMBitReader', 'LLVMAnalysis', 'LLVMTarget',
'LLVMCore', 'LLVMMC', 'LLVMSupport',
])
elif llvm_version >= distutils.version.LooseVersion('2.7'):
# 2.7
env.Prepend(LIBS = [
'LLVMLinker', 'LLVMipo', 'LLVMInterpreter',
@ -121,6 +135,8 @@ def generate(env):
env.Append(LIBS = [
'imagehlp',
'psapi',
'shell32',
'advapi32'
])
if env['msvc']:
# Some of the LLVM C headers use the inline keyword without

123
scons/source_list.py Normal file
View file

@ -0,0 +1,123 @@
"""Source List Parser
The syntax of a source list file is a very small subset of GNU Make. These
features are supported
operators: +=, :=
line continuation
non-nested variable expansion
comment
The goal is to allow Makefile's and SConscript's to share source listing.
"""
class SourceListParser(object):
def __init__(self):
self._reset()
def _reset(self, filename=None):
self.filename = filename
self.line_no = 1
self.line_cont = ''
self.symbol_table = {}
def _error(self, msg):
raise RuntimeError('%s:%d: %s' % (self.filename, self.line_no, msg))
def _next_dereference(self, val, cur):
"""Locate the next $(...) in value."""
deref_pos = val.find('$', cur)
if deref_pos < 0:
return (-1, -1)
elif val[deref_pos + 1] != '(':
self._error('non-variable dereference')
deref_end = val.find(')', deref_pos + 2)
if deref_end < 0:
self._error('unterminated variable dereference')
return (deref_pos, deref_end + 1)
def _expand_value(self, val):
"""Perform variable expansion."""
expanded = ''
cur = 0
while True:
deref_pos, deref_end = self._next_dereference(val, cur)
if deref_pos < 0:
expanded += val[cur:]
break
sym = val[(deref_pos + 2):(deref_end - 1)]
expanded += val[cur:deref_pos] + self.symbol_table[sym]
cur = deref_end
return expanded
def _parse_definition(self, line):
"""Parse a variable definition line."""
op_pos = line.find('=')
op_end = op_pos + 1
if op_pos < 0:
self._error('not a variable definition')
if op_pos > 0 and line[op_pos - 1] in [':', '+']:
op_pos -= 1
else:
self._error('only := and += are supported')
# set op, sym, and val
op = line[op_pos:op_end]
sym = line[:op_pos].strip()
val = self._expand_value(line[op_end:].lstrip())
if op == ':=':
self.symbol_table[sym] = val
elif op == '+=':
self.symbol_table[sym] += ' ' + val
def _parse_line(self, line):
"""Parse a source list line."""
# more lines to come
if line and line[-1] == '\\':
# spaces around "\\\n" are replaced by a single space
if self.line_cont:
self.line_cont += line[:-1].strip() + ' '
else:
self.line_cont = line[:-1].rstrip() + ' '
return 0
# combine with previous lines
if self.line_cont:
line = self.line_cont + line.lstrip()
self.line_cont = ''
if line:
begins_with_tab = (line[0] == '\t')
line = line.lstrip()
if line[0] != '#':
if begins_with_tab:
self._error('recipe line not supported')
else:
self._parse_definition(line)
return 1
def parse(self, filename):
"""Parse a source list file."""
if self.filename != filename:
fp = open(filename)
lines = fp.read().splitlines()
fp.close()
try:
self._reset(filename)
for line in lines:
self.line_no += self._parse_line(line)
except:
self._reset()
raise
return self.symbol_table

View file

@ -591,6 +591,13 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
case _EGL_PLATFORM_WAYLAND:
wl_display_destroy(dri2_dpy->wl_dpy);
break;
#endif
#ifdef HAVE_DRM_PLATFORM
case _EGL_PLATFORM_DRM:
if (dri2_dpy->own_gbm_device) {
gbm_device_destroy(&dri2_dpy->gbm_dri->base.base);
}
break;
#endif
default:
break;
@ -718,6 +725,23 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
return NULL;
}
/**
* Called via eglDestroyContext(), drv->API.DestroyContext().
*/
static EGLBoolean
dri2_destroy_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)
{
struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
if (_eglPutContext(ctx)) {
dri2_dpy->core->destroyContext(dri2_ctx->dri_context);
free(dri2_ctx);
}
return EGL_TRUE;
}
/**
* Called via eglMakeCurrent(), drv->API.MakeCurrent().
*/
@ -758,9 +782,8 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
drv->API.DestroySurface(drv, disp, old_dsurf);
if (old_rsurf)
drv->API.DestroySurface(drv, disp, old_rsurf);
/* no destroy? */
if (old_ctx)
_eglPutContext(old_ctx);
drv->API.DestroyContext(drv, disp, old_ctx);
return EGL_TRUE;
} else {
@ -1341,6 +1364,7 @@ _EGL_MAIN(const char *args)
dri2_drv->base.API.Initialize = dri2_initialize;
dri2_drv->base.API.Terminate = dri2_terminate;
dri2_drv->base.API.CreateContext = dri2_create_context;
dri2_drv->base.API.DestroyContext = dri2_destroy_context;
dri2_drv->base.API.MakeCurrent = dri2_make_current;
dri2_drv->base.API.GetProcAddress = dri2_get_proc_address;
dri2_drv->base.API.WaitClient = dri2_wait_client;

View file

@ -86,6 +86,7 @@ struct dri2_egl_display
#ifdef HAVE_DRM_PLATFORM
struct gbm_dri_device *gbm_dri;
int own_gbm_device;
#endif
char *device_name;
@ -122,8 +123,6 @@ enum wayland_buffer_type {
WL_BUFFER_THIRD,
WL_BUFFER_COUNT
};
#define __DRI_BUFFER_COUNT 10
#endif
enum dri2_surface_type {

View file

@ -30,6 +30,10 @@
#include <string.h>
#include <xf86drm.h>
#include <dlfcn.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "egl_dri2.h"
@ -90,6 +94,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
{
struct dri2_egl_display *dri2_dpy;
struct gbm_device *gbm;
int fd = -1;
int i;
dri2_dpy = malloc(sizeof *dri2_dpy);
@ -100,7 +105,15 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
disp->DriverData = (void *) dri2_dpy;
gbm = (struct gbm_device *) disp->PlatformDisplay;
gbm = disp->PlatformDisplay;
if (gbm == NULL) {
fd = open("/dev/dri/card0", O_RDWR);
dri2_dpy->own_gbm_device = 1;
gbm = gbm_create_device(fd);
if (gbm == NULL)
return EGL_FALSE;
}
if (strcmp(gbm_device_get_backend_name(gbm), "drm") != 0) {
free(dri2_dpy);
return EGL_FALSE;
@ -112,7 +125,15 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
return EGL_FALSE;
}
dri2_dpy->fd = gbm_device_get_fd(gbm);
if (fd < 0) {
fd = dup(gbm_device_get_fd(gbm));
if (fd < 0) {
free(dri2_dpy);
return EGL_FALSE;
}
}
dri2_dpy->fd = fd;
dri2_dpy->device_name = dri2_get_device_name_for_fd(dri2_dpy->fd);
dri2_dpy->driver_name = dri2_dpy->gbm_dri->base.driver_name;

View file

@ -713,6 +713,24 @@ GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
return &GLX_ctx->Base;
}
/**
* Called via eglDestroyContext(), drv->API.DestroyContext().
*/
static EGLBoolean
GLX_eglDestroyContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)
{
struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
struct GLX_egl_context *GLX_ctx = GLX_egl_context(ctx);
if (_eglPutContext(ctx)) {
assert(GLX_ctx);
GLX_drv->glXDestroyContext(disp, ctx);
free(GLX_ctx);
}
return EGL_TRUE;
}
/**
* Destroy a surface. The display is allowed to be uninitialized.
@ -1142,6 +1160,7 @@ _EGL_MAIN(const char *args)
GLX_drv->Base.API.Initialize = GLX_eglInitialize;
GLX_drv->Base.API.Terminate = GLX_eglTerminate;
GLX_drv->Base.API.CreateContext = GLX_eglCreateContext;
GLX_drv->Base.API.DestroyContext = GLX_eglDestroyContext;
GLX_drv->Base.API.MakeCurrent = GLX_eglMakeCurrent;
GLX_drv->Base.API.CreateWindowSurface = GLX_eglCreateWindowSurface;
GLX_drv->Base.API.CreatePixmapSurface = GLX_eglCreatePixmapSurface;

64
src/egl/main/Android.mk Normal file
View file

@ -0,0 +1,64 @@
# Mesa 3-D graphics library
#
# Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
# Copyright (C) 2010-2011 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.
# Android.mk for core EGL
LOCAL_PATH := $(call my-dir)
# from Makefile
SOURCES = \
eglapi.c \
eglarray.c \
eglconfig.c \
eglcontext.c \
eglcurrent.c \
egldisplay.c \
egldriver.c \
eglfallbacks.c \
eglglobals.c \
eglimage.c \
egllog.c \
eglmisc.c \
eglmode.c \
eglscreen.c \
eglstring.c \
eglsurface.c \
eglsync.c
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(SOURCES)
LOCAL_CFLAGS := \
-D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_ANDROID \
-D_EGL_DRIVER_SEARCH_DIR=\"/system/lib/egl\" \
-D_EGL_OS_UNIX=1
ifeq ($(strip $(MESA_BUILD_GALLIUM)),true)
LOCAL_CFLAGS += -D_EGL_BUILT_IN_DRIVER_GALLIUM
endif
LOCAL_MODULE := libmesa_egl
include $(MESA_COMMON_MK)
include $(BUILD_STATIC_LIBRARY)

View file

@ -63,6 +63,7 @@ EGL_LIB_DEPS += $(XCB_DRI2_LIBS)
endif
ifneq ($(findstring drm, $(EGL_PLATFORMS)),)
EGL_LIB_DEPS += -lgbm
INCLUDE_DIRS += -I$(TOP)/src/gbm/main
endif
EGL_LIB_DEPS += $(LIBUDEV_LIBS) $(DLOPEN_LIBS) $(LIBDRM_LIB) $(WAYLAND_LIBS)
endif
@ -70,6 +71,7 @@ endif
ifneq ($(findstring wayland, $(EGL_PLATFORMS)),)
LOCAL_LIBS += $(TOP)/src/egl/wayland/wayland-drm/libwayland-drm.a
INCLUDE_DIRS += $(WAYLAND_CFLAGS)
endif
ifeq ($(filter glx, $(EGL_DRIVERS_DIRS)),glx)
@ -93,6 +95,19 @@ ifeq ($(firstword $(EGL_PLATFORMS)),fbdev)
EGL_NATIVE_PLATFORM=_EGL_PLATFORM_FBDEV
endif
ifneq ($(findstring x11, $(EGL_PLATFORMS)),)
LOCAL_CFLAGS += -DHAVE_X11_PLATFORM
endif
ifneq ($(findstring wayland, $(EGL_PLATFORMS)),)
LOCAL_CFLAGS += -DHAVE_WAYLAND_PLATFORM
endif
ifneq ($(findstring drm, $(EGL_PLATFORMS)),)
LOCAL_CFLAGS += -DHAVE_DRM_PLATFORM
endif
ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),)
LOCAL_CFLAGS += -DHAVE_FBDEV_PLATFORM
endif
LOCAL_CFLAGS += \
-D_EGL_NATIVE_PLATFORM=$(EGL_NATIVE_PLATFORM) \
-D_EGL_DRIVER_SEARCH_DIR=\"$(EGL_DRIVER_INSTALL_DIR)\"

View file

@ -301,7 +301,7 @@ _eglUnlockDisplay(_EGLDisplay *dpy)
EGLDisplay EGLAPIENTRY
eglGetDisplay(EGLNativeDisplayType nativeDisplay)
{
_EGLPlatformType plat = _eglGetNativePlatform();
_EGLPlatformType plat = _eglGetNativePlatform(nativeDisplay);
_EGLDisplay *dpy = _eglFindDisplay(plat, (void *) nativeDisplay);
return _eglGetDisplayHandle(dpy);
}
@ -538,7 +538,7 @@ eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
EGLSurface ret;
_EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv);
if (disp->Platform != _eglGetNativePlatform())
if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay))
RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
surf = drv->API.CreateWindowSurface(drv, disp, conf, window, attrib_list);
@ -559,7 +559,7 @@ eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
EGLSurface ret;
_EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv);
if (disp->Platform != _eglGetNativePlatform())
if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay))
RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_PIXMAP, EGL_NO_SURFACE);
surf = drv->API.CreatePixmapSurface(drv, disp, conf, pixmap, attrib_list);
@ -720,7 +720,7 @@ eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
EGLBoolean ret;
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
if (disp->Platform != _eglGetNativePlatform())
if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay))
RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_PIXMAP, EGL_FALSE);
ret = drv->API.CopyBuffers(drv, disp, surf, target);
@ -947,6 +947,9 @@ eglGetProcAddress(const char *procname)
#ifdef EGL_WL_bind_wayland_display
{ "eglBindWaylandDisplayWL", (_EGLProc) eglBindWaylandDisplayWL },
{ "eglUnbindWaylandDisplayWL", (_EGLProc) eglUnbindWaylandDisplayWL },
#endif
#ifdef EGL_ANDROID_swap_rectangle
{ "eglSetSwapRectangleANDROID", (_EGLProc) eglSetSwapRectangleANDROID },
#endif
{ NULL, NULL }
};
@ -1565,3 +1568,25 @@ eglUnbindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display)
RETURN_EGL_EVAL(disp, ret);
}
#endif
#ifdef EGL_ANDROID_swap_rectangle
EGLBoolean EGLAPIENTRY
eglSetSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw,
EGLint left, EGLint top,
EGLint width, EGLint height)
{
_EGLDisplay *disp = _eglLockDisplay(dpy);
_EGLSurface *surf = _eglLookupSurface(draw, disp);
_EGLDriver *drv;
EGLBoolean ret;
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
if (!disp->Extensions.ANDROID_swap_rectangle)
RETURN_EGL_EVAL(disp, EGL_FALSE);
ret = drv->API.SetSwapRectangleANDROID(drv, disp, surf, left, top, width, height);
RETURN_EGL_EVAL(disp, ret);
}
#endif

View file

@ -131,6 +131,10 @@ typedef EGLBoolean (*BindWaylandDisplayWL_t)(_EGLDriver *drv, _EGLDisplay *disp,
typedef EGLBoolean (*UnbindWaylandDisplayWL_t)(_EGLDriver *drv, _EGLDisplay *disp, struct wl_display *display);
#endif
#ifdef EGL_ANDROID_swap_rectangle
typedef EGLBoolean (*SetSwapRectangleANDROID_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw, EGLint left, EGLint top, EGLint width, EGLint height);
#endif
/**
* The API dispatcher jumps through these functions
*/
@ -210,6 +214,10 @@ struct _egl_api
BindWaylandDisplayWL_t BindWaylandDisplayWL;
UnbindWaylandDisplayWL_t UnbindWaylandDisplayWL;
#endif
#ifdef EGL_ANDROID_swap_rectangle
SetSwapRectangleANDROID_t SetSwapRectangleANDROID;
#endif
};
#endif /* EGLAPI_INCLUDED */

View file

@ -529,8 +529,9 @@ _eglParseConfigAttribList(_EGLConfig *conf, _EGLDisplay *dpy,
if (!_eglValidateConfig(conf, EGL_TRUE))
return EGL_FALSE;
/* the spec says that EGL_LEVEL cannot be EGL_DONT_CARE */
if (conf->Level == EGL_DONT_CARE)
/* EGL_LEVEL and EGL_MATCH_NATIVE_PIXMAP cannot be EGL_DONT_CARE */
if (conf->Level == EGL_DONT_CARE ||
conf->MatchNativePixmap == EGL_DONT_CARE)
return EGL_FALSE;
/* ignore other attributes when EGL_CONFIG_ID is given */

View file

@ -43,6 +43,39 @@
#include "eglmutex.h"
#include "egllog.h"
/* Includes for _eglNativePlatformDetectNativeDisplay */
#ifdef HAVE_MINCORE
#include <unistd.h>
#include <sys/mman.h>
#endif
#ifdef HAVE_WAYLAND_PLATFORM
#include <wayland-client.h>
#endif
#ifdef HAVE_DRM_PLATFORM
#include <gbm.h>
#endif
#ifdef HAVE_FBDEV_PLATFORM
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#endif
/**
* Map --with-egl-platforms names to platform types.
*/
static const struct {
_EGLPlatformType platform;
const char *name;
} egl_platforms[_EGL_NUM_PLATFORMS] = {
{ _EGL_PLATFORM_WINDOWS, "gdi" },
{ _EGL_PLATFORM_X11, "x11" },
{ _EGL_PLATFORM_WAYLAND, "wayland" },
{ _EGL_PLATFORM_DRM, "drm" },
{ _EGL_PLATFORM_FBDEV, "fbdev" },
{ _EGL_PLATFORM_ANDROID, "android" }
};
/**
* Return the native platform by parsing EGL_PLATFORM.
@ -50,17 +83,6 @@
static _EGLPlatformType
_eglGetNativePlatformFromEnv(void)
{
/* map --with-egl-platforms names to platform types */
static const struct {
_EGLPlatformType platform;
const char *name;
} egl_platforms[_EGL_NUM_PLATFORMS] = {
{ _EGL_PLATFORM_WINDOWS, "gdi" },
{ _EGL_PLATFORM_X11, "x11" },
{ _EGL_PLATFORM_WAYLAND, "wayland" },
{ _EGL_PLATFORM_DRM, "drm" },
{ _EGL_PLATFORM_FBDEV, "fbdev" }
};
_EGLPlatformType plat = _EGL_INVALID_PLATFORM;
const char *plat_name;
EGLint i;
@ -83,20 +105,106 @@ _eglGetNativePlatformFromEnv(void)
}
/**
* Perform validity checks on a generic pointer.
*/
static EGLBoolean
_eglPointerIsDereferencable(void *p)
{
#ifdef HAVE_MINCORE
uintptr_t addr = (uintptr_t) p;
unsigned char valid = 0;
const long page_size = getpagesize();
if (p == NULL)
return EGL_FALSE;
/* align addr to page_size */
addr &= ~(page_size - 1);
if (mincore((void *) addr, page_size, &valid) < 0) {
_eglLog(_EGL_DEBUG, "mincore failed: %m");
return EGL_FALSE;
}
return (valid & 0x01) == 0x01;
#else
return p != NULL;
#endif
}
/**
* Try detecting native platform with the help of native display characteristcs.
*/
static _EGLPlatformType
_eglNativePlatformDetectNativeDisplay(EGLNativeDisplayType nativeDisplay)
{
#ifdef HAVE_FBDEV_PLATFORM
struct stat buf;
#endif
if (nativeDisplay == EGL_DEFAULT_DISPLAY)
return _EGL_INVALID_PLATFORM;
#ifdef HAVE_FBDEV_PLATFORM
/* fbdev is the only platform that can be a file descriptor. */
if (fstat((intptr_t) nativeDisplay, &buf) == 0 && S_ISCHR(buf.st_mode))
return _EGL_PLATFORM_FBDEV;
#endif
if (_eglPointerIsDereferencable(nativeDisplay)) {
void *first_pointer = *(void **) nativeDisplay;
#ifdef HAVE_WAYLAND_PLATFORM
/* wl_display is a wl_proxy, which is a wl_object.
* wl_object's first element points to the interfacetype. */
if (first_pointer == &wl_display_interface)
return _EGL_PLATFORM_WAYLAND;
#endif
#ifdef HAVE_DRM_PLATFORM
/* gbm has a pointer to its constructor as first element. */
if (first_pointer == gbm_create_device)
return _EGL_PLATFORM_DRM;
#endif
#ifdef HAVE_X11_PLATFORM
/* If not matched to any other platform, fallback to x11. */
return _EGL_PLATFORM_X11;
#endif
}
return _EGL_INVALID_PLATFORM;
}
/**
* Return the native platform. It is the platform of the EGL native types.
*/
_EGLPlatformType
_eglGetNativePlatform(void)
_eglGetNativePlatform(EGLNativeDisplayType nativeDisplay)
{
static _EGLPlatformType native_platform = _EGL_INVALID_PLATFORM;
char *detection_method = NULL;
if (native_platform == _EGL_INVALID_PLATFORM) {
native_platform = _eglGetNativePlatformFromEnv();
if (native_platform == _EGL_INVALID_PLATFORM)
native_platform = _EGL_NATIVE_PLATFORM;
detection_method = "environment overwrite";
if (native_platform == _EGL_INVALID_PLATFORM) {
native_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay);
detection_method = "autodetected";
if (native_platform == _EGL_INVALID_PLATFORM) {
native_platform = _EGL_NATIVE_PLATFORM;
detection_method = "build-time configuration";
}
}
}
if (detection_method != NULL)
_eglLog(_EGL_DEBUG, "Native platform type: %s (%s)",
egl_platforms[native_platform].name, detection_method);
return native_platform;
}

View file

@ -44,6 +44,7 @@ enum _egl_platform_type {
_EGL_PLATFORM_WAYLAND,
_EGL_PLATFORM_DRM,
_EGL_PLATFORM_FBDEV,
_EGL_PLATFORM_ANDROID,
_EGL_NUM_PLATFORMS,
_EGL_INVALID_PLATFORM = -1
@ -107,6 +108,9 @@ struct _egl_extensions
EGLBoolean NOK_swap_region;
EGLBoolean NOK_texture_from_pixmap;
EGLBoolean ANDROID_image_native_buffer;
EGLBoolean ANDROID_swap_rectangle;
};
@ -150,7 +154,7 @@ struct _egl_display
extern _EGLPlatformType
_eglGetNativePlatform(void);
_eglGetNativePlatform(EGLNativeDisplayType nativeDisplay);
extern void

View file

@ -113,6 +113,9 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy)
_EGL_CHECK_EXTENSION(NOK_swap_region);
_EGL_CHECK_EXTENSION(NOK_texture_from_pixmap);
_EGL_CHECK_EXTENSION(ANDROID_image_native_buffer);
_EGL_CHECK_EXTENSION(ANDROID_swap_rectangle);
#undef _EGL_CHECK_EXTENSION
}

View file

@ -269,11 +269,13 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
{
const char *func;
EGLint renderBuffer = EGL_BACK_BUFFER;
EGLint swapBehavior = EGL_BUFFER_PRESERVED;
EGLint err;
switch (type) {
case EGL_WINDOW_BIT:
func = "eglCreateWindowSurface";
swapBehavior = EGL_BUFFER_DESTROYED;
break;
case EGL_PIXMAP_BIT:
func = "eglCreatePixmapSurface";
@ -315,7 +317,7 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
surf->MipmapLevel = 0;
surf->MultisampleResolve = EGL_MULTISAMPLE_RESOLVE_DEFAULT;
surf->SwapBehavior = EGL_BUFFER_DESTROYED;
surf->SwapBehavior = swapBehavior;
surf->HorizontalResolution = EGL_UNKNOWN;
surf->VerticalResolution = EGL_UNKNOWN;

View file

@ -1,5 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="drm">
<copyright>
Copyright © 2008-2011 Kristian Høgsberg
Copyright © 2010-2011 Intel Corporation
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that\n the above copyright notice appear in
all copies and that both that copyright notice and this permission
notice appear in supporting documentation, and that the name of
the copyright holders not be used in advertising or publicity
pertaining to distribution of the software without specific,
written prior permission. The copyright holders make no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied
warranty.
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
</copyright>
<!-- drm support. This object is created by the server and published
using the display's global event. -->
<interface name="wl_drm" version="1">

View file

@ -0,0 +1,32 @@
# Mesa 3-D graphics library
#
# Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
# Copyright (C) 2010-2011 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.
# src/gallium/Android.common.mk
LOCAL_C_INCLUDES += \
$(GALLIUM_TOP)/include \
$(GALLIUM_TOP)/auxiliary \
$(GALLIUM_TOP)/winsys \
$(GALLIUM_TOP)/drivers
include $(MESA_COMMON_MK)

44
src/gallium/Android.mk Normal file
View file

@ -0,0 +1,44 @@
# Mesa 3-D graphics library
#
# Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
# Copyright (C) 2010-2011 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.
# src/gallium/Android.mk
GALLIUM_TOP := $(call my-dir)
GALLIUM_COMMON_MK := $(GALLIUM_TOP)/Android.common.mk
SUBDIRS := \
targets/egl-static \
state_trackers/egl \
auxiliary
# swrast
SUBDIRS += winsys/sw/android drivers/softpipe
# r600g
ifneq ($(filter r600g, $(MESA_GPU_DRIVERS)),)
SUBDIRS += winsys/radeon/drm
SUBDIRS += winsys/r600/drm drivers/r600
endif
mkfiles := $(patsubst %,$(GALLIUM_TOP)/%/Android.mk,$(SUBDIRS))
include $(mkfiles)

View file

@ -0,0 +1,55 @@
# Mesa 3-D graphics library
#
# Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
# Copyright (C) 2010-2011 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.
LOCAL_PATH := $(call my-dir)
# get C_SOURCES and GENERATED_SOURCES
include $(LOCAL_PATH)/Makefile.sources
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(C_SOURCES)
LOCAL_C_INCLUDES := $(GALLIUM_TOP)/auxiliary/util
LOCAL_MODULE := libmesa_gallium
# generate sources
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
intermediates := $(call local-intermediates-dir)
LOCAL_GENERATED_SOURCES := $(addprefix $(intermediates)/, $(GENERATED_SOURCES))
$(LOCAL_GENERATED_SOURCES): PRIVATE_PYTHON := $(MESA_PYTHON2)
$(LOCAL_GENERATED_SOURCES): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PYTHON) $^ > $@
$(intermediates)/indices/u_indices_gen.c \
$(intermediates)/indices/u_unfilled_gen.c \
$(intermediates)/util/u_format_srgb.c \
$(intermediates)/util/u_half.c: $(intermediates)/%.c: $(LOCAL_PATH)/%.py
$(transform-generated-source)
$(intermediates)/util/u_format_table.c: $(intermediates)/%.c: $(LOCAL_PATH)/%.py $(LOCAL_PATH)/util/u_format.csv
$(transform-generated-source)
include $(GALLIUM_COMMON_MK)
include $(BUILD_STATIC_LIBRARY)

View file

@ -3,205 +3,10 @@ include $(TOP)/configs/current
LIBNAME = gallium
C_SOURCES = \
cso_cache/cso_cache.c \
cso_cache/cso_context.c \
cso_cache/cso_hash.c \
draw/draw_context.c \
draw/draw_fs.c \
draw/draw_gs.c \
draw/draw_pipe.c \
draw/draw_pipe_aaline.c \
draw/draw_pipe_aapoint.c \
draw/draw_pipe_clip.c \
draw/draw_pipe_cull.c \
draw/draw_pipe_flatshade.c \
draw/draw_pipe_offset.c \
draw/draw_pipe_pstipple.c \
draw/draw_pipe_stipple.c \
draw/draw_pipe_twoside.c \
draw/draw_pipe_unfilled.c \
draw/draw_pipe_util.c \
draw/draw_pipe_validate.c \
draw/draw_pipe_vbuf.c \
draw/draw_pipe_wide_line.c \
draw/draw_pipe_wide_point.c \
draw/draw_pt.c \
draw/draw_pt_emit.c \
draw/draw_pt_fetch.c \
draw/draw_pt_fetch_emit.c \
draw/draw_pt_fetch_shade_emit.c \
draw/draw_pt_fetch_shade_pipeline.c \
draw/draw_pt_post_vs.c \
draw/draw_pt_so_emit.c \
draw/draw_pt_util.c \
draw/draw_pt_vsplit.c \
draw/draw_vertex.c \
draw/draw_vs.c \
draw/draw_vs_aos.c \
draw/draw_vs_aos_io.c \
draw/draw_vs_aos_machine.c \
draw/draw_vs_exec.c \
draw/draw_vs_ppc.c \
draw/draw_vs_sse.c \
draw/draw_vs_variant.c \
indices/u_indices_gen.c \
indices/u_unfilled_gen.c \
os/os_misc.c \
os/os_stream.c \
os/os_stream_log.c \
os/os_stream_null.c \
os/os_stream_stdc.c \
os/os_stream_str.c \
os/os_time.c \
pipebuffer/pb_buffer_fenced.c \
pipebuffer/pb_buffer_malloc.c \
pipebuffer/pb_bufmgr_alt.c \
pipebuffer/pb_bufmgr_cache.c \
pipebuffer/pb_bufmgr_debug.c \
pipebuffer/pb_bufmgr_mm.c \
pipebuffer/pb_bufmgr_ondemand.c \
pipebuffer/pb_bufmgr_pool.c \
pipebuffer/pb_bufmgr_slab.c \
pipebuffer/pb_validate.c \
rbug/rbug_connection.c \
rbug/rbug_context.c \
rbug/rbug_core.c \
rbug/rbug_demarshal.c \
rbug/rbug_texture.c \
rbug/rbug_shader.c \
rtasm/rtasm_cpu.c \
rtasm/rtasm_execmem.c \
rtasm/rtasm_ppc.c \
rtasm/rtasm_ppc_spe.c \
rtasm/rtasm_x86sse.c \
tgsi/tgsi_build.c \
tgsi/tgsi_dump.c \
tgsi/tgsi_exec.c \
tgsi/tgsi_info.c \
tgsi/tgsi_iterate.c \
tgsi/tgsi_parse.c \
tgsi/tgsi_ppc.c \
tgsi/tgsi_sanity.c \
tgsi/tgsi_scan.c \
tgsi/tgsi_sse2.c \
tgsi/tgsi_text.c \
tgsi/tgsi_transform.c \
tgsi/tgsi_ureg.c \
tgsi/tgsi_util.c \
translate/translate.c \
translate/translate_cache.c \
translate/translate_generic.c \
translate/translate_sse.c \
util/u_debug.c \
util/u_debug_describe.c \
util/u_debug_refcnt.c \
util/u_debug_stack.c \
util/u_debug_symbol.c \
util/u_dump_defines.c \
util/u_dump_state.c \
util/u_bitmask.c \
util/u_blit.c \
util/u_blitter.c \
util/u_cache.c \
util/u_caps.c \
util/u_cpu_detect.c \
util/u_dl.c \
util/u_draw.c \
util/u_draw_quad.c \
util/u_format.c \
util/u_format_other.c \
util/u_format_latc.c \
util/u_format_s3tc.c \
util/u_format_rgtc.c \
util/u_format_srgb.c \
util/u_format_table.c \
util/u_format_tests.c \
util/u_format_yuv.c \
util/u_format_zs.c \
util/u_framebuffer.c \
util/u_gen_mipmap.c \
util/u_half.c \
util/u_handle_table.c \
util/u_hash.c \
util/u_hash_table.c \
util/u_index_modify.c \
util/u_keymap.c \
util/u_linear.c \
util/u_linkage.c \
util/u_network.c \
util/u_math.c \
util/u_mm.c \
util/u_pstipple.c \
util/u_rect.c \
util/u_ringbuffer.c \
util/u_sampler.c \
util/u_simple_shaders.c \
util/u_slab.c \
util/u_snprintf.c \
util/u_staging.c \
util/u_surface.c \
util/u_surfaces.c \
util/u_texture.c \
util/u_tile.c \
util/u_transfer.c \
util/u_resource.c \
util/u_upload_mgr.c \
util/u_vbuf_mgr.c \
vl/vl_csc.c \
vl/vl_compositor.c \
vl/vl_decoder.c \
vl/vl_mpeg12_decoder.c \
vl/vl_mpeg12_bitstream.c \
vl/vl_zscan.c \
vl/vl_idct.c \
vl/vl_mc.c \
vl/vl_vertex_buffers.c \
vl/vl_video_buffer.c
GALLIVM_SOURCES = \
gallivm/lp_bld_arit.c \
gallivm/lp_bld_assert.c \
gallivm/lp_bld_bitarit.c \
gallivm/lp_bld_const.c \
gallivm/lp_bld_conv.c \
gallivm/lp_bld_flow.c \
gallivm/lp_bld_format_aos.c \
gallivm/lp_bld_format_soa.c \
gallivm/lp_bld_format_yuv.c \
gallivm/lp_bld_gather.c \
gallivm/lp_bld_init.c \
gallivm/lp_bld_intr.c \
gallivm/lp_bld_logic.c \
gallivm/lp_bld_pack.c \
gallivm/lp_bld_printf.c \
gallivm/lp_bld_quad.c \
gallivm/lp_bld_sample.c \
gallivm/lp_bld_sample_aos.c \
gallivm/lp_bld_sample_soa.c \
gallivm/lp_bld_struct.c \
gallivm/lp_bld_swizzle.c \
gallivm/lp_bld_tgsi_aos.c \
gallivm/lp_bld_tgsi_info.c \
gallivm/lp_bld_tgsi_soa.c \
gallivm/lp_bld_type.c \
draw/draw_llvm.c \
draw/draw_llvm_sample.c \
draw/draw_llvm_translate.c \
draw/draw_vs_llvm.c \
draw/draw_pt_fetch_shade_pipeline_llvm.c
GALLIVM_CPP_SOURCES = \
gallivm/lp_bld_debug.cpp \
gallivm/lp_bld_misc.cpp
GENERATED_SOURCES = \
indices/u_indices_gen.c \
indices/u_unfilled_gen.c \
util/u_format_srgb.c \
util/u_format_table.c \
util/u_half.c
# get source lists
include Makefile.sources
C_SOURCES += $(GENERATED_SOURCES)
ifeq ($(MESA_LLVM),1)
C_SOURCES += \

View file

@ -0,0 +1,200 @@
C_SOURCES := \
cso_cache/cso_cache.c \
cso_cache/cso_context.c \
cso_cache/cso_hash.c \
draw/draw_context.c \
draw/draw_fs.c \
draw/draw_gs.c \
draw/draw_pipe.c \
draw/draw_pipe_aaline.c \
draw/draw_pipe_aapoint.c \
draw/draw_pipe_clip.c \
draw/draw_pipe_cull.c \
draw/draw_pipe_flatshade.c \
draw/draw_pipe_offset.c \
draw/draw_pipe_pstipple.c \
draw/draw_pipe_stipple.c \
draw/draw_pipe_twoside.c \
draw/draw_pipe_unfilled.c \
draw/draw_pipe_util.c \
draw/draw_pipe_validate.c \
draw/draw_pipe_vbuf.c \
draw/draw_pipe_wide_line.c \
draw/draw_pipe_wide_point.c \
draw/draw_pt.c \
draw/draw_pt_emit.c \
draw/draw_pt_fetch.c \
draw/draw_pt_fetch_emit.c \
draw/draw_pt_fetch_shade_emit.c \
draw/draw_pt_fetch_shade_pipeline.c \
draw/draw_pt_post_vs.c \
draw/draw_pt_so_emit.c \
draw/draw_pt_util.c \
draw/draw_pt_vsplit.c \
draw/draw_vertex.c \
draw/draw_vs.c \
draw/draw_vs_aos.c \
draw/draw_vs_aos_io.c \
draw/draw_vs_aos_machine.c \
draw/draw_vs_exec.c \
draw/draw_vs_ppc.c \
draw/draw_vs_sse.c \
draw/draw_vs_variant.c \
os/os_misc.c \
os/os_stream.c \
os/os_stream_log.c \
os/os_stream_null.c \
os/os_stream_stdc.c \
os/os_stream_str.c \
os/os_time.c \
pipebuffer/pb_buffer_fenced.c \
pipebuffer/pb_buffer_malloc.c \
pipebuffer/pb_bufmgr_alt.c \
pipebuffer/pb_bufmgr_cache.c \
pipebuffer/pb_bufmgr_debug.c \
pipebuffer/pb_bufmgr_mm.c \
pipebuffer/pb_bufmgr_ondemand.c \
pipebuffer/pb_bufmgr_pool.c \
pipebuffer/pb_bufmgr_slab.c \
pipebuffer/pb_validate.c \
postprocess/pp_celshade.c \
postprocess/pp_colors.c \
postprocess/pp_init.c \
postprocess/pp_mlaa.c \
postprocess/pp_run.c \
postprocess/pp_program.c \
rbug/rbug_connection.c \
rbug/rbug_context.c \
rbug/rbug_core.c \
rbug/rbug_demarshal.c \
rbug/rbug_texture.c \
rbug/rbug_shader.c \
rtasm/rtasm_cpu.c \
rtasm/rtasm_execmem.c \
rtasm/rtasm_ppc.c \
rtasm/rtasm_ppc_spe.c \
rtasm/rtasm_x86sse.c \
tgsi/tgsi_build.c \
tgsi/tgsi_dump.c \
tgsi/tgsi_exec.c \
tgsi/tgsi_info.c \
tgsi/tgsi_iterate.c \
tgsi/tgsi_parse.c \
tgsi/tgsi_ppc.c \
tgsi/tgsi_sanity.c \
tgsi/tgsi_scan.c \
tgsi/tgsi_sse2.c \
tgsi/tgsi_text.c \
tgsi/tgsi_transform.c \
tgsi/tgsi_ureg.c \
tgsi/tgsi_util.c \
translate/translate.c \
translate/translate_cache.c \
translate/translate_generic.c \
translate/translate_sse.c \
util/u_debug.c \
util/u_debug_describe.c \
util/u_debug_memory.c \
util/u_debug_refcnt.c \
util/u_debug_stack.c \
util/u_debug_symbol.c \
util/u_dump_defines.c \
util/u_dump_state.c \
util/u_bitmask.c \
util/u_blit.c \
util/u_blitter.c \
util/u_cache.c \
util/u_caps.c \
util/u_cpu_detect.c \
util/u_dl.c \
util/u_draw.c \
util/u_draw_quad.c \
util/u_format.c \
util/u_format_other.c \
util/u_format_latc.c \
util/u_format_s3tc.c \
util/u_format_rgtc.c \
util/u_format_tests.c \
util/u_format_yuv.c \
util/u_format_zs.c \
util/u_framebuffer.c \
util/u_gen_mipmap.c \
util/u_handle_table.c \
util/u_hash.c \
util/u_hash_table.c \
util/u_index_modify.c \
util/u_keymap.c \
util/u_linear.c \
util/u_linkage.c \
util/u_network.c \
util/u_math.c \
util/u_mm.c \
util/u_pstipple.c \
util/u_rect.c \
util/u_ringbuffer.c \
util/u_sampler.c \
util/u_simple_shaders.c \
util/u_slab.c \
util/u_snprintf.c \
util/u_staging.c \
util/u_surface.c \
util/u_surfaces.c \
util/u_texture.c \
util/u_tile.c \
util/u_transfer.c \
util/u_resource.c \
util/u_upload_mgr.c \
util/u_vbuf_mgr.c \
vl/vl_csc.c \
vl/vl_compositor.c \
vl/vl_decoder.c \
vl/vl_mpeg12_decoder.c \
vl/vl_mpeg12_bitstream.c \
vl/vl_zscan.c \
vl/vl_idct.c \
vl/vl_mc.c \
vl/vl_vertex_buffers.c \
vl/vl_video_buffer.c
GENERATED_SOURCES := \
indices/u_indices_gen.c \
indices/u_unfilled_gen.c \
util/u_format_srgb.c \
util/u_format_table.c \
util/u_half.c
GALLIVM_SOURCES := \
gallivm/lp_bld_arit.c \
gallivm/lp_bld_assert.c \
gallivm/lp_bld_bitarit.c \
gallivm/lp_bld_const.c \
gallivm/lp_bld_conv.c \
gallivm/lp_bld_flow.c \
gallivm/lp_bld_format_aos.c \
gallivm/lp_bld_format_soa.c \
gallivm/lp_bld_format_yuv.c \
gallivm/lp_bld_gather.c \
gallivm/lp_bld_init.c \
gallivm/lp_bld_intr.c \
gallivm/lp_bld_logic.c \
gallivm/lp_bld_pack.c \
gallivm/lp_bld_printf.c \
gallivm/lp_bld_quad.c \
gallivm/lp_bld_sample.c \
gallivm/lp_bld_sample_aos.c \
gallivm/lp_bld_sample_soa.c \
gallivm/lp_bld_struct.c \
gallivm/lp_bld_swizzle.c \
gallivm/lp_bld_tgsi_aos.c \
gallivm/lp_bld_tgsi_info.c \
gallivm/lp_bld_tgsi_soa.c \
gallivm/lp_bld_type.c \
draw/draw_llvm.c \
draw/draw_llvm_sample.c \
draw/draw_llvm_translate.c \
draw/draw_vs_llvm.c \
draw/draw_pt_fetch_shade_pipeline_llvm.c
GALLIVM_CPP_SOURCES := \
gallivm/lp_bld_debug.cpp \
gallivm/lp_bld_misc.cpp

View file

@ -47,201 +47,20 @@ env.Depends('util/u_format_table.c', [
'util/u_format_pack.py',
])
source = [
'cso_cache/cso_cache.c',
'cso_cache/cso_context.c',
'cso_cache/cso_hash.c',
'draw/draw_context.c',
'draw/draw_fs.c',
'draw/draw_gs.c',
'draw/draw_pipe.c',
'draw/draw_pipe_aaline.c',
'draw/draw_pipe_aapoint.c',
'draw/draw_pipe_clip.c',
'draw/draw_pipe_cull.c',
'draw/draw_pipe_flatshade.c',
'draw/draw_pipe_offset.c',
'draw/draw_pipe_pstipple.c',
'draw/draw_pipe_stipple.c',
'draw/draw_pipe_twoside.c',
'draw/draw_pipe_unfilled.c',
'draw/draw_pipe_util.c',
'draw/draw_pipe_validate.c',
'draw/draw_pipe_vbuf.c',
'draw/draw_pipe_wide_line.c',
'draw/draw_pipe_wide_point.c',
'draw/draw_pt.c',
'draw/draw_pt_emit.c',
'draw/draw_pt_fetch.c',
'draw/draw_pt_fetch_emit.c',
'draw/draw_pt_fetch_shade_emit.c',
'draw/draw_pt_fetch_shade_pipeline.c',
'draw/draw_pt_post_vs.c',
'draw/draw_pt_so_emit.c',
'draw/draw_pt_util.c',
'draw/draw_pt_vsplit.c',
'draw/draw_vertex.c',
'draw/draw_vs.c',
'draw/draw_vs_aos.c',
'draw/draw_vs_aos_io.c',
'draw/draw_vs_aos_machine.c',
'draw/draw_vs_exec.c',
'draw/draw_vs_ppc.c',
'draw/draw_vs_sse.c',
'draw/draw_vs_variant.c',
#'indices/u_indices.c',
#'indices/u_unfilled_indices.c',
'indices/u_indices_gen.c',
'indices/u_unfilled_gen.c',
'os/os_misc.c',
'os/os_stream.c',
'os/os_stream_log.c',
'os/os_stream_null.c',
'os/os_stream_stdc.c',
'os/os_stream_str.c',
'os/os_time.c',
'pipebuffer/pb_buffer_fenced.c',
'pipebuffer/pb_buffer_malloc.c',
'pipebuffer/pb_bufmgr_alt.c',
'pipebuffer/pb_bufmgr_cache.c',
'pipebuffer/pb_bufmgr_debug.c',
'pipebuffer/pb_bufmgr_mm.c',
'pipebuffer/pb_bufmgr_ondemand.c',
'pipebuffer/pb_bufmgr_pool.c',
'pipebuffer/pb_bufmgr_slab.c',
'pipebuffer/pb_validate.c',
'rbug/rbug_connection.c',
'rbug/rbug_context.c',
'rbug/rbug_core.c',
'rbug/rbug_demarshal.c',
'rbug/rbug_shader.c',
'rbug/rbug_texture.c',
'rtasm/rtasm_cpu.c',
'rtasm/rtasm_execmem.c',
'rtasm/rtasm_ppc.c',
'rtasm/rtasm_ppc_spe.c',
'rtasm/rtasm_x86sse.c',
'tgsi/tgsi_build.c',
'tgsi/tgsi_dump.c',
'tgsi/tgsi_exec.c',
'tgsi/tgsi_info.c',
'tgsi/tgsi_iterate.c',
'tgsi/tgsi_parse.c',
'tgsi/tgsi_ppc.c',
'tgsi/tgsi_sanity.c',
'tgsi/tgsi_scan.c',
'tgsi/tgsi_sse2.c',
'tgsi/tgsi_text.c',
'tgsi/tgsi_transform.c',
'tgsi/tgsi_ureg.c',
'tgsi/tgsi_util.c',
'translate/translate.c',
'translate/translate_cache.c',
'translate/translate_generic.c',
'translate/translate_sse.c',
'util/u_bitmask.c',
'util/u_blit.c',
'util/u_blitter.c',
'util/u_cache.c',
'util/u_caps.c',
'util/u_cpu_detect.c',
'util/u_debug.c',
'util/u_debug_describe.c',
'util/u_debug_memory.c',
'util/u_debug_refcnt.c',
'util/u_debug_stack.c',
'util/u_debug_symbol.c',
'util/u_dump_defines.c',
'util/u_dump_state.c',
'util/u_dl.c',
'util/u_draw.c',
'util/u_draw_quad.c',
'util/u_format.c',
'util/u_format_other.c',
'util/u_format_latc.c',
'util/u_format_s3tc.c',
'util/u_format_rgtc.c',
'util/u_format_srgb.c',
'util/u_format_table.c',
'util/u_format_tests.c',
'util/u_format_yuv.c',
'util/u_format_zs.c',
'util/u_framebuffer.c',
'util/u_gen_mipmap.c',
'util/u_half.c',
'util/u_handle_table.c',
'util/u_hash.c',
'util/u_hash_table.c',
'util/u_index_modify.c',
'util/u_keymap.c',
'util/u_linear.c',
'util/u_linkage.c',
'util/u_network.c',
'util/u_math.c',
'util/u_mm.c',
'util/u_pstipple.c',
'util/u_rect.c',
'util/u_resource.c',
'util/u_ringbuffer.c',
'util/u_sampler.c',
'util/u_simple_shaders.c',
'util/u_slab.c',
'util/u_snprintf.c',
'util/u_staging.c',
'util/u_surface.c',
'util/u_surfaces.c',
'util/u_texture.c',
'util/u_tile.c',
'util/u_transfer.c',
'util/u_upload_mgr.c',
'util/u_vbuf_mgr.c',
'vl/vl_csc.c',
'vl/vl_compositor.c',
'vl/vl_decoder.c',
'vl/vl_mpeg12_decoder.c',
'vl/vl_mpeg12_bitstream.c',
'vl/vl_zscan.c',
'vl/vl_idct.c',
'vl/vl_mc.c',
'vl/vl_vertex_buffers.c',
'vl/vl_video_buffer.c',
]
source = env.ParseSourceList('Makefile.sources', [
'C_SOURCES',
'GENERATED_SOURCES'
])
if env['llvm']:
source += [
'gallivm/lp_bld_arit.c',
'gallivm/lp_bld_assert.c',
'gallivm/lp_bld_bitarit.c',
'gallivm/lp_bld_const.c',
'gallivm/lp_bld_conv.c',
'gallivm/lp_bld_debug.cpp',
'gallivm/lp_bld_flow.c',
'gallivm/lp_bld_format_aos.c',
'gallivm/lp_bld_format_soa.c',
'gallivm/lp_bld_format_yuv.c',
'gallivm/lp_bld_gather.c',
'gallivm/lp_bld_init.c',
'gallivm/lp_bld_intr.c',
'gallivm/lp_bld_logic.c',
'gallivm/lp_bld_misc.cpp',
'gallivm/lp_bld_pack.c',
'gallivm/lp_bld_printf.c',
'gallivm/lp_bld_quad.c',
'gallivm/lp_bld_sample.c',
'gallivm/lp_bld_sample_aos.c',
'gallivm/lp_bld_sample_soa.c',
'gallivm/lp_bld_struct.c',
'gallivm/lp_bld_swizzle.c',
'gallivm/lp_bld_tgsi_aos.c',
'gallivm/lp_bld_tgsi_info.c',
'gallivm/lp_bld_tgsi_soa.c',
'gallivm/lp_bld_type.c',
'draw/draw_llvm.c',
'draw/draw_llvm_sample.c',
'draw/draw_llvm_translate.c',
'draw/draw_pt_fetch_shade_pipeline_llvm.c',
'draw/draw_vs_llvm.c'
]
source += env.ParseSourceList('Makefile.sources', [
'GALLIVM_SOURCES',
'GALLIVM_CPP_SOURCES'
])
if env['toolchain'] == 'crossmingw':
# compile lp_bld_misc.cpp without -gstabs option
source = env.compile_without_gstabs(source, "gallivm/lp_bld_misc.cpp")
gallium = env.ConvenienceLibrary(
target = 'gallium',

View file

@ -96,7 +96,7 @@ draw_llvm_generate_elts(struct draw_llvm *llvm, struct draw_llvm_variant *var);
* Create LLVM type for struct draw_jit_texture
*/
static LLVMTypeRef
create_jit_texture_type(struct gallivm_state *gallivm)
create_jit_texture_type(struct gallivm_state *gallivm, const char *struct_name)
{
LLVMTargetDataRef target = gallivm->target;
LLVMTypeRef texture_type;
@ -120,13 +120,21 @@ create_jit_texture_type(struct gallivm_state *gallivm)
elem_types[DRAW_JIT_TEXTURE_BORDER_COLOR] =
LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4);
#if HAVE_LLVM >= 0x0300
texture_type = LLVMStructCreateNamed(gallivm->context, struct_name);
LLVMStructSetBody(texture_type, elem_types,
Elements(elem_types), 0);
#else
texture_type = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
LLVMAddTypeName(gallivm->module, struct_name, texture_type);
/* Make sure the target's struct layout cache doesn't return
* stale/invalid data.
*/
LLVMInvalidateStructLayout(gallivm->target, texture_type);
#endif
LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, width,
target, texture_type,
@ -176,7 +184,7 @@ create_jit_texture_type(struct gallivm_state *gallivm)
*/
static LLVMTypeRef
create_jit_context_type(struct gallivm_state *gallivm,
LLVMTypeRef texture_type)
LLVMTypeRef texture_type, const char *struct_name)
{
LLVMTargetDataRef target = gallivm->target;
LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
@ -189,11 +197,17 @@ create_jit_context_type(struct gallivm_state *gallivm,
elem_types[3] = LLVMPointerType(float_type, 0); /* viewport */
elem_types[4] = LLVMArrayType(texture_type,
PIPE_MAX_VERTEX_SAMPLERS); /* textures */
#if HAVE_LLVM >= 0x0300
context_type = LLVMStructCreateNamed(gallivm->context, struct_name);
LLVMStructSetBody(context_type, elem_types,
Elements(elem_types), 0);
#else
context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
LLVMAddTypeName(gallivm->module, struct_name, context_type);
LLVMInvalidateStructLayout(gallivm->target, context_type);
#endif
LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, vs_constants,
target, context_type, 0);
@ -215,7 +229,7 @@ create_jit_context_type(struct gallivm_state *gallivm,
* Create LLVM type for struct pipe_vertex_buffer
*/
static LLVMTypeRef
create_jit_vertex_buffer_type(struct gallivm_state *gallivm)
create_jit_vertex_buffer_type(struct gallivm_state *gallivm, const char *struct_name)
{
LLVMTargetDataRef target = gallivm->target;
LLVMTypeRef elem_types[3];
@ -225,10 +239,17 @@ create_jit_vertex_buffer_type(struct gallivm_state *gallivm)
elem_types[1] = LLVMInt32TypeInContext(gallivm->context);
elem_types[2] = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0); /* vs_constants */
#if HAVE_LLVM >= 0x0300
vb_type = LLVMStructCreateNamed(gallivm->context, struct_name);
LLVMStructSetBody(vb_type, elem_types,
Elements(elem_types), 0);
#else
vb_type = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
LLVMAddTypeName(gallivm->module, struct_name, vb_type);
LLVMInvalidateStructLayout(gallivm->target, vb_type);
#endif
LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, stride,
target, vb_type, 0);
@ -258,10 +279,17 @@ create_jit_vertex_header(struct gallivm_state *gallivm, int data_elems)
elem_types[1] = LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4);
elem_types[2] = LLVMArrayType(elem_types[1], data_elems);
#if HAVE_LLVM >= 0x0300
vertex_header = LLVMStructCreateNamed(gallivm->context, struct_name);
LLVMStructSetBody(vertex_header, elem_types,
Elements(elem_types), 0);
#else
vertex_header = LLVMStructTypeInContext(gallivm->context, elem_types,
Elements(elem_types), 0);
LLVMAddTypeName(gallivm->module, struct_name, vertex_header);
LLVMInvalidateStructLayout(gallivm->target, vertex_header);
#endif
/* these are bit-fields and we can't take address of them
LP_CHECK_MEMBER_OFFSET(struct vertex_header, clipmask,
@ -284,8 +312,6 @@ create_jit_vertex_header(struct gallivm_state *gallivm, int data_elems)
target, vertex_header,
DRAW_JIT_VERTEX_DATA);
LLVMAddTypeName(gallivm->module, struct_name, vertex_header);
return vertex_header;
}
@ -299,19 +325,15 @@ create_jit_types(struct draw_llvm *llvm)
struct gallivm_state *gallivm = llvm->gallivm;
LLVMTypeRef texture_type, context_type, buffer_type, vb_type;
texture_type = create_jit_texture_type(gallivm);
LLVMAddTypeName(gallivm->module, "texture", texture_type);
texture_type = create_jit_texture_type(gallivm, "texture");
context_type = create_jit_context_type(gallivm, texture_type);
LLVMAddTypeName(gallivm->module, "draw_jit_context", context_type);
context_type = create_jit_context_type(gallivm, texture_type, "draw_jit_context");
llvm->context_ptr_type = LLVMPointerType(context_type, 0);
buffer_type = LLVMPointerType(LLVMIntTypeInContext(gallivm->context, 8), 0);
LLVMAddTypeName(gallivm->module, "buffer", buffer_type);
llvm->buffer_ptr_type = LLVMPointerType(buffer_type, 0);
vb_type = create_jit_vertex_buffer_type(gallivm);
LLVMAddTypeName(gallivm->module, "pipe_vertex_buffer", vb_type);
vb_type = create_jit_vertex_buffer_type(gallivm, "pipe_vertex_buffer");
llvm->vb_ptr_type = LLVMPointerType(vb_type, 0);
}

View file

@ -15,8 +15,9 @@
*
* How to use this source:
*
* - Download and abuild the NTL library from
* http://shoup.net/ntl/download.html
* - Download and build the NTL library from
* http://shoup.net/ntl/download.html , or install libntl-dev package if on
* Debian.
*
* - Download boost source code matching to your distro.
*
@ -24,22 +25,32 @@
*
* - Build as
*
* g++ -o minimax -I /path/to/ntl/include main.cpp f.cpp /path/to/ntl/src/ntl.a -lboost_math_tr1
* g++ -o minimax -I /path/to/ntl/include main.cpp f.cpp /path/to/ntl/src/ntl.a
*
* - Run as
*
* ./minimax
*
* - For example, to compute exp2 5th order polynomial between [0, 1] do:
* - For example, to compute log2 5th order polynomial between [1, 2] do:
*
* variant 0
* range 1 2
* order 5 0
* step 200
* info
*
* and take the coefficients from the P = { ... } array.
*
* - To compute exp2 5th order polynomial between [0, 1] do:
*
* variant 1
* range 0 1
* order 5 0
* steps 200
* step 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
* http://www.boost.org/doc/libs/1_47_0/libs/math/doc/sf_and_dist/html/math_toolkit/toolkit/internals2/minimax.html
*/
#define L22

View file

@ -61,7 +61,7 @@
#include "lp_bld_arit.h"
#define EXP_POLY_DEGREE 3
#define EXP_POLY_DEGREE 5
#define LOG_POLY_DEGREE 5
@ -1645,7 +1645,7 @@ lp_build_rsqrt(struct lp_build_context *bld,
assert(type.floating);
if (util_cpu_caps.has_sse && type.width == 32 && type.length == 4) {
const unsigned num_iterations = 0;
const unsigned num_iterations = 1;
LLVMValueRef res;
unsigned i;
@ -2151,7 +2151,7 @@ lp_build_exp(struct lp_build_context *bld,
assert(lp_check_value(bld->type, x));
return lp_build_mul(bld, log2e, lp_build_exp2(bld, x));
return lp_build_exp2(bld, lp_build_mul(bld, log2e, x));
}
@ -2168,7 +2168,7 @@ lp_build_log(struct lp_build_context *bld,
assert(lp_check_value(bld->type, x));
return lp_build_mul(bld, log2, lp_build_exp2(bld, x));
return lp_build_mul(bld, log2, lp_build_log2(bld, x));
}
@ -2218,18 +2218,18 @@ lp_build_polynomial(struct lp_build_context *bld,
*/
const double lp_build_exp2_polynomial[] = {
#if EXP_POLY_DEGREE == 5
0.999999999690134838155,
0.583974334321735217258,
0.164553105719676828492,
0.0292811063701710962255,
0.00354944426657875141846,
0.000296253726543423377365
0.999999925063526176901,
0.693153073200168932794,
0.240153617044375388211,
0.0558263180532956664775,
0.00898934009049466391101,
0.00187757667519147912699
#elif EXP_POLY_DEGREE == 4
1.00000001502262084505,
0.563586057338685991394,
0.150436017652442413623,
0.0243220604213317927308,
0.0025359088446580436489
1.00000259337069434683,
0.693003834469974940458,
0.24144275689150793076,
0.0520114606103070150235,
0.0135341679161270268764
#elif EXP_POLY_DEGREE == 3
0.999925218562710312959,
0.695833540494823811697,
@ -2465,6 +2465,12 @@ lp_build_log2_approx(struct lp_build_context *bld,
assert(type.floating && type.width == 32);
/*
* We don't explicitly handle denormalized numbers. They will yield a
* result in the neighbourhood of -127, which appears to be adequate
* enough.
*/
i = LLVMBuildBitCast(builder, x, int_vec_type, "");
/* exp = (float) exponent(x) */

View file

@ -0,0 +1,87 @@
/**************************************************************************
*
* Copyright 2011 LunarG, 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.
*
**************************************************************************/
/**
* @file
* OS independent memory mapping (with large file support).
*
* @author Chia-I Wu <olvaffe@gmail.com>
*/
#ifndef _OS_MMAN_H_
#define _OS_MMAN_H_
#include "pipe/p_config.h"
#include "pipe/p_compiler.h"
#if defined(PIPE_OS_UNIX)
# ifndef _FILE_OFFSET_BITS
# error _FILE_OFFSET_BITS must be defined to 64
# endif
# include <sys/mman.h>
#else
# error Unsupported OS
#endif
#if defined(PIPE_OS_ANDROID)
# include <errno.h> /* for EINVAL */
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if defined(PIPE_OS_ANDROID)
extern void *__mmap2(void *, size_t, int, int, int, size_t);
static INLINE void *os_mmap(void *addr, size_t length, int prot, int flags, int fd, loff_t offset)
{
/* offset must be aligned to 4096 (not necessarily the page size) */
if (unlikely(offset & 4095)) {
errno = EINVAL;
return MAP_FAILED;
}
return __mmap2(addr, length, prot, flags, fd, (size_t) (offset >> 12));
}
#else
/* assume large file support exists */
# define os_mmap(addr, length, prot, flags, fd, offset) mmap(addr, length, prot, flags, fd, offset)
#endif
#define os_munmap(addr, length) munmap(addr, length)
#ifdef __cplusplus
}
#endif
#endif /* _OS_MMAN_H_ */

View file

@ -314,7 +314,7 @@ typedef int64_t pipe_condvar;
* pipe_barrier
*/
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU)
#if (defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU)) && !defined(PIPE_OS_ANDROID)
typedef pthread_barrier_t pipe_barrier;

View file

@ -0,0 +1,87 @@
How to add a new post-processing filter
=======================================
The Gallium post-processing queue works by passing the current screen to a fragment shader.
These shaders may be written in any supported language, but are added here in TGSI text
assembly.
You can translate GLSL/ARB fairly easily via llvmpipe (LP_DEBUG=tgsi). I don't know the
status of the D3D state tracker, but if/when that works, I'd assume HLSL would be possible
too.
Steps
=====
1. Add it to PP
2. Make it known to PP
3. Make it known to driconf
4. ????
5. Profit
1. Add it to PP
---------------
Once you have the shader(s) in TGSI asm, put them to static const char arrays in a header
file (see pp_colors.h).
Add the filter's prototypes (main and init functions) to postprocess.h. This is mostly a
copy-paste job with only changing the name.
Then create a file containing empty main and init functions, named as you specified above.
See pp_colors.c for an example.
2. Make it known to PP
----------------------
Add your filter to filters.h, in a correct place. Placement is important, AA should usually
be the last effect in the queue for example.
Name is the config option your filter will be enabled by, both in driconf and as an env var.
Inner temp means an intermediate framebuffer you may use in your filter to store
results between passes. If you have a single-pass filter, request 0 of those.
Shaders is the number of shaders your filter needs. The minimum is 2.
You could also write the init and main functions now. If your filter is single-pass without
a vertex shader and any other input than the main screen, you can use pp_nocolor as your
main function as is.
3. Make it known to driconf
---------------------------
First time outside of auxiliary/postprocess. First, add a suitable description to
drivers/dri/common/xmlpool/t_options.h, and regenerate options.h by running make in that
directory. Use the name you put into filters.h as the config option name.
With driconf aware of the option, make Gallium aware of it too. Add it to
state_trackers/dri/common/dri_screen.c in a proper section, specifying its default value and
the accepted range (if applicable).
Do check that __driNConfigOptions is still correct after the addition.
4. ????
-------
Testing, praying, hookers, blow, sacrificial lambs...
5. Profit
---------
Assuming you got here, sharing is caring. Send your filter to mesa-dev.

View file

@ -0,0 +1,58 @@
/**************************************************************************
*
* Copyright 2011 Lauri Kasanen
* 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 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 PP_EXTERNAL_FILTERS_H
#define PP_EXTERNAL_FILTERS_H
#include "postprocess/postprocess.h"
typedef void (*pp_init_func) (struct pp_queue_t *, unsigned int,
unsigned int);
struct pp_filter_t
{
const char *name; /* Config name */
unsigned int inner_tmps; /* Request how many inner temps */
unsigned int shaders; /* Request how many shaders */
unsigned int verts; /* How many are vertex shaders */
pp_init_func init; /* Init function */
pp_func main; /* Run function */
};
/* Order matters. Put new filters in a suitable place. */
static const struct pp_filter_t pp_filters[PP_FILTERS] = {
/* name inner shaders verts init run */
{ "pp_noblue", 0, 2, 1, pp_noblue_init, pp_nocolor },
{ "pp_nogreen", 0, 2, 1, pp_nogreen_init, pp_nocolor },
{ "pp_nored", 0, 2, 1, pp_nored_init, pp_nocolor },
{ "pp_celshade", 0, 2, 1, pp_celshade_init, pp_nocolor },
{ "pp_jimenezmlaa", 2, 5, 2, pp_jimenezmlaa_init, pp_jimenezmlaa },
{ "pp_jimenezmlaa_color", 2, 5, 2, pp_jimenezmlaa_init_color, pp_jimenezmlaa_color },
};
#endif

View file

@ -0,0 +1,100 @@
/**************************************************************************
*
* Copyright 2011 Lauri Kasanen
* 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 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 POSTPROCESS_H
#define POSTPROCESS_H
#include "postprocess/pp_program.h"
#define PP_FILTERS 6 /* Increment this if you add filters */
#define PP_MAX_PASSES 6
struct pp_queue_t; /* Forward definition */
/* Less typing later on */
typedef void (*pp_func) (struct pp_queue_t *, struct pipe_resource *,
struct pipe_resource *, unsigned int);
/**
* The main post-processing queue.
*/
struct pp_queue_t
{
pp_func *pp_queue; /* An array of pp_funcs */
unsigned int n_filters; /* Number of enabled filters */
struct pipe_resource *tmp[2]; /* Two temp FBOs for the queue */
struct pipe_resource *inner_tmp[3]; /* Three for filter use */
unsigned int n_tmp, n_inner_tmp;
struct pipe_resource *depth; /* depth of original input */
struct pipe_resource *stencil; /* stencil shared by inner_tmps */
struct pipe_surface *tmps[2], *inner_tmps[3], *stencils;
void ***shaders; /* Shaders in TGSI form */
unsigned int *verts;
struct program *p;
bool fbos_init;
};
/* Main functions */
struct pp_queue_t *pp_init(struct pipe_screen *, const unsigned int *);
void pp_run(struct pp_queue_t *, struct pipe_resource *,
struct pipe_resource *, struct pipe_resource *);
void pp_free(struct pp_queue_t *);
void pp_free_fbos(struct pp_queue_t *);
void pp_debug(const char *, ...);
struct program *pp_init_prog(struct pp_queue_t *, struct pipe_screen *);
void pp_init_fbos(struct pp_queue_t *, unsigned int, unsigned int,
struct pipe_resource *);
/* The filters */
void pp_nocolor(struct pp_queue_t *, struct pipe_resource *,
struct pipe_resource *, unsigned int);
void pp_jimenezmlaa(struct pp_queue_t *, struct pipe_resource *,
struct pipe_resource *, unsigned int);
void pp_jimenezmlaa_color(struct pp_queue_t *, struct pipe_resource *,
struct pipe_resource *, unsigned int);
/* The filter init functions */
void pp_celshade_init(struct pp_queue_t *, unsigned int, unsigned int);
void pp_nored_init(struct pp_queue_t *, unsigned int, unsigned int);
void pp_nogreen_init(struct pp_queue_t *, unsigned int, unsigned int);
void pp_noblue_init(struct pp_queue_t *, unsigned int, unsigned int);
void pp_jimenezmlaa_init(struct pp_queue_t *, unsigned int, unsigned int);
void pp_jimenezmlaa_init_color(struct pp_queue_t *, unsigned int,
unsigned int);
#endif

View file

@ -0,0 +1,38 @@
/**************************************************************************
*
* Copyright 2011 Lauri Kasanen
* 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 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 "postprocess/postprocess.h"
#include "postprocess/pp_celshade.h"
#include "postprocess/pp_filters.h"
/** Init function */
void
pp_celshade_init(struct pp_queue_t *ppq, unsigned int n, unsigned int val)
{
ppq->shaders[n][1] =
pp_tgsi_to_state(ppq->p->pipe, celshade, false, "celshade");
}

View file

@ -0,0 +1,79 @@
/**************************************************************************
*
* Copyright 2011 Lauri Kasanen
* 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 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 CELSHADE_H
#define CELSHADE_H
static const char celshade[] = "FRAG\n"
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
"DCL OUT[0], COLOR\n"
"DCL SAMP[0]\n"
"DCL TEMP[0..4]\n"
"IMM FLT32 { 0.2126, 0.7152, 0.0722, 4.0000}\n"
"IMM FLT32 { 0.5000, 2.0000, 1.0000, -0.1250}\n"
"IMM FLT32 { 0.2500, 0.1000, 0.1250, 3.0000}\n"
" 0: TEX TEMP[0], IN[0].xyyy, SAMP[0], 2D\n"
" 1: DP3 TEMP[1].x, TEMP[0].xyzz, IMM[0]\n"
" 2: MUL TEMP[3].x, TEMP[1].xxxx, IMM[0].wwww\n"
" 3: ROUND TEMP[2].x, TEMP[3].xxxx\n"
" 4: MUL TEMP[3].x, TEMP[2].xxxx, IMM[2].xxxx\n"
" 5: MOV TEMP[2].x, TEMP[3].xxxx\n"
" 6: ADD TEMP[4].x, TEMP[1].xxxx, -TEMP[3].xxxx\n"
" 7: SGT TEMP[1].w, TEMP[4].xxxx, IMM[2].yyyy\n"
" 8: IF TEMP[1].wwww :19\n"
" 9: ADD TEMP[4].y, TEMP[3].xxxx, IMM[2].yyyy\n"
" 10: ADD TEMP[1].z, TEMP[1].xxxx, -TEMP[4].yyyy\n"
" 11: ADD TEMP[1].y, TEMP[3].xxxx, IMM[2].zzzz\n"
" 12: ADD TEMP[2].x, TEMP[1].yyyy, -TEMP[4].yyyy\n"
" 13: RCP TEMP[4].y, TEMP[2].xxxx\n"
" 14: MUL TEMP[2].x, TEMP[1].zzzz, TEMP[4].yyyy\n"
" 15: MAD TEMP[1].y, -IMM[1].yyyy, TEMP[2].xxxx, IMM[2].wwww\n"
" 16: MUL TEMP[1].z, TEMP[2].xxxx, TEMP[1].yyyy\n"
" 17: MUL TEMP[1].y, TEMP[2].xxxx, TEMP[1].zzzz\n"
" 18: MAD TEMP[2].x, TEMP[1].yyyy, IMM[2].zzzz, TEMP[3].xxxx\n"
" 19: ENDIF\n"
" 20: SLT TEMP[3].x, TEMP[4].xxxx, -IMM[2].yyyy\n"
" 21: IF TEMP[3].xxxx :34\n"
" 22: ADD TEMP[3].x, TEMP[2].xxxx, -IMM[2].zzzz\n"
" 23: ADD TEMP[4].x, TEMP[1].xxxx, -TEMP[3].xxxx\n"
" 24: ADD TEMP[1].x, TEMP[2].xxxx, -IMM[2].yyyy\n"
" 25: ADD TEMP[4].y, TEMP[1].xxxx, -TEMP[3].xxxx\n"
" 26: RCP TEMP[3].x, TEMP[4].yyyy\n"
" 27: MUL TEMP[1].x, TEMP[4].xxxx, TEMP[3].xxxx\n"
" 28: MAD TEMP[4].x, -IMM[1].yyyy, TEMP[1].xxxx, IMM[2].wwww\n"
" 29: MUL TEMP[3].x, TEMP[1].xxxx, TEMP[4].xxxx\n"
" 30: MUL TEMP[4].x, TEMP[1].xxxx, TEMP[3].xxxx\n"
" 31: ADD TEMP[3].x, IMM[1].zzzz, -TEMP[4].xxxx\n"
" 32: MAD TEMP[1].x, TEMP[3].xxxx, -IMM[2].zzzz, TEMP[2].xxxx\n"
" 33: MOV TEMP[2].x, TEMP[1].xxxx\n"
" 34: ENDIF\n"
" 35: MAD TEMP[1].x, TEMP[2].xxxx, IMM[1].yyyy, IMM[2].yyyy\n"
" 36: MUL OUT[0], TEMP[0], TEMP[1].xxxx\n"
" 37: END\n";
#endif

View file

@ -0,0 +1,80 @@
/**************************************************************************
*
* Copyright 2011 Lauri Kasanen
* 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 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 "postprocess/postprocess.h"
#include "postprocess/pp_colors.h"
#include "postprocess/pp_filters.h"
/** The run function of the color filters */
void
pp_nocolor(struct pp_queue_t *ppq, struct pipe_resource *in,
struct pipe_resource *out, unsigned int n)
{
struct program *p = ppq->p;
pp_filter_setup_in(p, in);
pp_filter_setup_out(p, out);
pp_filter_set_fb(p);
pp_filter_misc_state(p);
cso_single_sampler(p->cso, 0, &p->sampler_point);
cso_single_sampler_done(p->cso);
cso_set_fragment_sampler_views(p->cso, 1, &p->view);
cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][0]);
cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][1]);
pp_filter_draw(p);
pp_filter_end_pass(p);
}
/* Init functions */
void
pp_nored_init(struct pp_queue_t *ppq, unsigned int n, unsigned int val)
{
ppq->shaders[n][1] = pp_tgsi_to_state(ppq->p->pipe, nored, false, "nored");
}
void
pp_nogreen_init(struct pp_queue_t *ppq, unsigned int n, unsigned int val)
{
ppq->shaders[n][1] =
pp_tgsi_to_state(ppq->p->pipe, nogreen, false, "nogreen");
}
void
pp_noblue_init(struct pp_queue_t *ppq, unsigned int n, unsigned int val)
{
ppq->shaders[n][1] =
pp_tgsi_to_state(ppq->p->pipe, noblue, false, "noblue");
}

View file

@ -0,0 +1,69 @@
/**************************************************************************
*
* Copyright 2011 Lauri Kasanen
* 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 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 PP_COLORS_H
#define PP_COLORS_H
static const char nored[] = "FRAG\n"
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
"DCL OUT[0], COLOR\n"
"DCL SAMP[0]\n"
"DCL TEMP[0]\n"
"IMM FLT32 { 0.0000, 0.0000, 0.0000, 0.0000}\n"
" 0: TEX TEMP[0], IN[0].xyyy, SAMP[0], 2D\n"
" 1: MOV TEMP[0].x, IMM[0].xxxx\n"
" 2: MOV OUT[0], TEMP[0]\n"
" 3: END\n";
static const char nogreen[] = "FRAG\n"
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
"DCL OUT[0], COLOR\n"
"DCL SAMP[0]\n"
"DCL TEMP[0]\n"
"IMM FLT32 { 0.0000, 0.0000, 0.0000, 0.0000}\n"
" 0: TEX TEMP[0], IN[0].xyyy, SAMP[0], 2D\n"
" 1: MOV TEMP[0].y, IMM[0].xxxx\n"
" 2: MOV OUT[0], TEMP[0]\n"
" 3: END\n";
static const char noblue[] = "FRAG\n"
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
"DCL OUT[0], COLOR\n"
"DCL SAMP[0]\n"
"DCL TEMP[0]\n"
"IMM FLT32 { 0.0000, 0.0000, 0.0000, 0.0000}\n"
" 0: TEX TEMP[0], IN[0].xyyy, SAMP[0], 2D\n"
" 1: MOV TEMP[0].z, IMM[0].xxxx\n"
" 2: MOV OUT[0], TEMP[0]\n"
" 3: END\n";
#endif

View file

@ -0,0 +1,57 @@
/**************************************************************************
*
* Copyright 2011 Lauri Kasanen
* 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 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 PP_FILTERS_H
#define PP_FILTERS_H
/* Internal include, mainly for the filters */
#include "cso_cache/cso_context.h"
#include "pipe/p_context.h"
#include "pipe/p_shader_tokens.h"
#include "pipe/p_state.h"
#include "tgsi/tgsi_text.h"
#include "util/u_memory.h"
#include "util/u_draw_quad.h"
#define PP_MAX_TOKENS 2048
/* Helper functions for the filters */
void pp_filter_setup_in(struct program *, struct pipe_resource *);
void pp_filter_setup_out(struct program *, struct pipe_resource *);
void pp_filter_end_pass(struct program *);
void *pp_tgsi_to_state(struct pipe_context *, const char *, bool,
const char *);
void pp_filter_misc_state(struct program *);
void pp_filter_draw(struct program *);
void pp_filter_set_fb(struct program *);
void pp_filter_set_clear_fb(struct program *);
#endif

View file

@ -0,0 +1,283 @@
/**************************************************************************
*
* Copyright 2011 Lauri Kasanen
* 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 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 <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "postprocess/filters.h"
#include "pipe/p_screen.h"
#include "util/u_inlines.h"
#include "util/u_blit.h"
#include "util/u_math.h"
#include "cso_cache/cso_context.h"
/** Initialize the post-processing queue. */
struct pp_queue_t *
pp_init(struct pipe_screen *pscreen, const unsigned int *enabled)
{
unsigned int curpos = 0, i, tmp_req = 0;
struct pp_queue_t *ppq;
pp_func *tmp_q;
pp_debug("Initializing the post-processing queue.\n");
/* How many filters were requested? */
for (i = 0; i < PP_FILTERS; i++) {
if (enabled[i])
curpos++;
}
if (!curpos)
return NULL;
ppq = calloc(1, sizeof(struct pp_queue_t));
tmp_q = calloc(curpos, sizeof(pp_func));
ppq->shaders = calloc(curpos, sizeof(void *));
ppq->verts = calloc(curpos, sizeof(unsigned int));
if (!tmp_q || !ppq || !ppq->shaders || !ppq->verts)
goto error;
ppq->p = pp_init_prog(ppq, pscreen);
if (!ppq->p)
goto error;
/* Add the enabled filters to the queue, in order */
curpos = 0;
ppq->pp_queue = tmp_q;
for (i = 0; i < PP_FILTERS; i++) {
if (enabled[i]) {
ppq->pp_queue[curpos] = pp_filters[i].main;
tmp_req = MAX2(tmp_req, pp_filters[i].inner_tmps);
if (pp_filters[i].shaders) {
ppq->shaders[curpos] =
calloc(pp_filters[i].shaders + 1, sizeof(void *));
ppq->verts[curpos] = pp_filters[i].verts;
if (!ppq->shaders[curpos])
goto error;
}
pp_filters[i].init(ppq, curpos, enabled[i]);
curpos++;
}
}
ppq->p->blitctx = util_create_blit(ppq->p->pipe, ppq->p->cso);
if (!ppq->p->blitctx)
goto error;
ppq->n_filters = curpos;
ppq->n_tmp = (curpos > 2 ? 2 : 1);
ppq->n_inner_tmp = tmp_req;
ppq->fbos_init = false;
for (i = 0; i < curpos; i++)
ppq->shaders[i][0] = ppq->p->passvs;
pp_debug("Queue successfully allocated. %u filter(s).\n", curpos);
return ppq;
error:
pp_debug("Error setting up pp\n");
if (ppq)
free(ppq->p);
free(ppq);
free(tmp_q);
return NULL;
}
/** Free any allocated FBOs (temp buffers). Called after resizing for example. */
void
pp_free_fbos(struct pp_queue_t *ppq)
{
unsigned int i;
if (!ppq->fbos_init)
return;
for (i = 0; i < ppq->n_tmp; i++) {
pipe_surface_reference(&ppq->tmps[i], NULL);
pipe_resource_reference(&ppq->tmp[i], NULL);
}
for (i = 0; i < ppq->n_inner_tmp; i++) {
pipe_surface_reference(&ppq->inner_tmps[i], NULL);
pipe_resource_reference(&ppq->inner_tmp[i], NULL);
}
pipe_surface_reference(&ppq->stencils, NULL);
pipe_resource_reference(&ppq->stencil, NULL);
ppq->fbos_init = false;
}
/** Free the pp queue. Called on context termination. */
void
pp_free(struct pp_queue_t *ppq)
{
unsigned int i, j;
pp_free_fbos(ppq);
util_destroy_blit(ppq->p->blitctx);
cso_set_fragment_sampler_views(ppq->p->cso, 0, NULL);
cso_release_all(ppq->p->cso);
for (i = 0; i < ppq->n_filters; i++) {
for (j = 0; j < PP_MAX_PASSES && ppq->shaders[i][j]; j++) {
if (j >= ppq->verts[i]) {
ppq->p->pipe->delete_fs_state(ppq->p->pipe, ppq->shaders[i][j]);
ppq->shaders[i][j] = NULL;
}
else if (ppq->shaders[i][j] != ppq->p->passvs) {
ppq->p->pipe->delete_vs_state(ppq->p->pipe, ppq->shaders[i][j]);
ppq->shaders[i][j] = NULL;
}
}
}
cso_destroy_context(ppq->p->cso);
ppq->p->pipe->destroy(ppq->p->pipe);
free(ppq->p);
free(ppq->pp_queue);
free(ppq);
pp_debug("Queue taken down.\n");
}
/** Internal debug function. Should be available to final users. */
void
pp_debug(const char *fmt, ...)
{
va_list ap;
if (!getenv("PP_DEBUG"))
return;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
}
/** Allocate the temp FBOs. Called on makecurrent and resize. */
void
pp_init_fbos(struct pp_queue_t *ppq, const unsigned int w,
const unsigned int h, struct pipe_resource *indepth)
{
struct program *p = ppq->p; /* The lazy will inherit the earth */
unsigned int i;
struct pipe_resource tmp_res;
if (ppq->fbos_init)
return;
pp_debug("Initializing FBOs, size %ux%u\n", w, h);
pp_debug("Requesting %u temps and %u inner temps\n", ppq->n_tmp,
ppq->n_inner_tmp);
memset(&tmp_res, 0, sizeof(tmp_res));
tmp_res.target = PIPE_TEXTURE_2D;
tmp_res.format = p->surf.format = PIPE_FORMAT_B8G8R8A8_UNORM;
tmp_res.width0 = w;
tmp_res.height0 = h;
tmp_res.depth0 = 1;
tmp_res.array_size = 1;
tmp_res.last_level = 0;
tmp_res.bind = p->surf.usage = PIPE_BIND_RENDER_TARGET;
if (!p->screen->is_format_supported(p->screen, tmp_res.format,
tmp_res.target, 1, tmp_res.bind))
pp_debug("Temp buffers' format fail\n");
for (i = 0; i < ppq->n_tmp; i++) {
ppq->tmp[i] = p->screen->resource_create(p->screen, &tmp_res);
ppq->tmps[i] = p->pipe->create_surface(p->pipe, ppq->tmp[i], &p->surf);
if (!ppq->tmp[i] || !ppq->tmps[i])
goto error;
}
for (i = 0; i < ppq->n_inner_tmp; i++) {
ppq->inner_tmp[i] = p->screen->resource_create(p->screen, &tmp_res);
ppq->inner_tmps[i] = p->pipe->create_surface(p->pipe,
ppq->inner_tmp[i],
&p->surf);
if (!ppq->inner_tmp[i] || !ppq->inner_tmps[i])
goto error;
}
tmp_res.format = p->surf.format = indepth->format;
tmp_res.bind = p->surf.usage = PIPE_BIND_DEPTH_STENCIL;
ppq->depth = indepth;
if (!ppq->depth)
goto error;
tmp_res.format = p->surf.format = PIPE_FORMAT_S8_USCALED_Z24_UNORM;
if (!p->screen->is_format_supported(p->screen, tmp_res.format,
tmp_res.target, 1, tmp_res.bind)) {
tmp_res.format = p->surf.format = PIPE_FORMAT_Z24_UNORM_S8_USCALED;
if (!p->screen->is_format_supported(p->screen, tmp_res.format,
tmp_res.target, 1, tmp_res.bind))
pp_debug("Temp Sbuffer format fail\n");
}
ppq->stencil = p->screen->resource_create(p->screen, &tmp_res);
ppq->stencils = p->pipe->create_surface(p->pipe, ppq->stencil, &p->surf);
if (!ppq->stencil || !ppq->stencils)
goto error;
p->framebuffer.width = w;
p->framebuffer.height = h;
p->viewport.scale[0] = p->viewport.translate[0] = (float) w / 2.0;
p->viewport.scale[1] = p->viewport.translate[1] = (float) h / 2.0;
p->viewport.scale[3] = 1.0f;
p->viewport.translate[3] = 0.0f;
ppq->fbos_init = true;
return;
error:
pp_debug("Failed to allocate temp buffers!\n");
}

View file

@ -0,0 +1,304 @@
/**
* Copyright (C) 2010 Jorge Jimenez (jorge@iryoku.com)
* Copyright (C) 2010 Belen Masia (bmasia@unizar.es)
* Copyright (C) 2010 Jose I. Echevarria (joseignacioechevarria@gmail.com)
* Copyright (C) 2010 Fernando Navarro (fernandn@microsoft.com)
* Copyright (C) 2010 Diego Gutierrez (diegog@unizar.es)
* Copyright (C) 2011 Lauri Kasanen (cand@gmx.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the following statement:
*
* "Uses Jimenez's MLAA. Copyright (C) 2010 by Jorge Jimenez, Belen Masia,
* Jose I. Echevarria, Fernando Navarro and Diego Gutierrez."
*
* Only for use in the Mesa project, this point 2 is filled by naming the
* technique Jimenez's MLAA in the Mesa config options.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holders.
*/
#include <stdio.h>
#include <string.h>
#include "postprocess/postprocess.h"
#include "postprocess/pp_mlaa.h"
#include "postprocess/pp_filters.h"
#include "util/u_blit.h"
#include "util/u_box.h"
#include "util/u_sampler.h"
#include "util/u_inlines.h"
#include "pipe/p_screen.h"
#define IMM_SPACE 80
static float constants[] = { 1, 1, 0, 0 };
static unsigned int dimensions[2] = { 0, 0 };
static struct pipe_resource *constbuf, *areamaptex;
/** Upload the constants. */
static void
up_consts(struct pipe_context *pipe)
{
struct pipe_box box;
u_box_2d(0, 0, sizeof(constants), 1, &box);
pipe->transfer_inline_write(pipe, constbuf, 0, PIPE_TRANSFER_WRITE,
&box, constants, sizeof(constants),
sizeof(constants));
}
/** Run function of the MLAA filter. */
static void
pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
struct pipe_resource *out, unsigned int n, bool iscolor)
{
struct program *p = ppq->p;
struct pipe_depth_stencil_alpha_state mstencil;
struct pipe_sampler_view v_tmp, *arr[3];
unsigned int w = p->framebuffer.width;
unsigned int h = p->framebuffer.height;
const struct pipe_stencil_ref ref = { {1} };
memset(&mstencil, 0, sizeof(mstencil));
cso_set_stencil_ref(p->cso, &ref);
/* Init the pixel size constant */
if (dimensions[0] != p->framebuffer.width ||
dimensions[1] != p->framebuffer.height) {
constants[0] = 1.0 / p->framebuffer.width;
constants[1] = 1.0 / p->framebuffer.height;
up_consts(p->pipe);
dimensions[0] = p->framebuffer.width;
dimensions[1] = p->framebuffer.height;
}
p->pipe->set_constant_buffer(p->pipe, PIPE_SHADER_VERTEX, 0, constbuf);
p->pipe->set_constant_buffer(p->pipe, PIPE_SHADER_FRAGMENT, 0, constbuf);
mstencil.stencil[0].enabled = 1;
mstencil.stencil[0].valuemask = mstencil.stencil[0].writemask = ~0;
mstencil.stencil[0].func = PIPE_FUNC_ALWAYS;
mstencil.stencil[0].fail_op = PIPE_STENCIL_OP_KEEP;
mstencil.stencil[0].zfail_op = PIPE_STENCIL_OP_KEEP;
mstencil.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE;
p->framebuffer.zsbuf = ppq->stencils;
/* First pass: depth edge detection */
if (iscolor)
pp_filter_setup_in(p, in);
else
pp_filter_setup_in(p, ppq->depth);
pp_filter_setup_out(p, ppq->inner_tmp[0]);
pp_filter_set_fb(p);
pp_filter_misc_state(p);
cso_set_depth_stencil_alpha(p->cso, &mstencil);
p->pipe->clear(p->pipe, PIPE_CLEAR_STENCIL | PIPE_CLEAR_COLOR,
p->clear_color, 0, 0);
cso_single_sampler(p->cso, 0, &p->sampler_point);
cso_single_sampler_done(p->cso);
cso_set_fragment_sampler_views(p->cso, 1, &p->view);
cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][1]); /* offsetvs */
cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][2]);
pp_filter_draw(p);
pp_filter_end_pass(p);
/* Second pass: blend weights */
/* Sampler order: areamap, edgesmap, edgesmapL (reversed, thx compiler) */
mstencil.stencil[0].func = PIPE_FUNC_EQUAL;
mstencil.stencil[0].zpass_op = PIPE_STENCIL_OP_KEEP;
cso_set_depth_stencil_alpha(p->cso, &mstencil);
pp_filter_setup_in(p, areamaptex);
pp_filter_setup_out(p, ppq->inner_tmp[1]);
u_sampler_view_default_template(&v_tmp, ppq->inner_tmp[0],
ppq->inner_tmp[0]->format);
arr[1] = arr[2] = p->pipe->create_sampler_view(p->pipe,
ppq->inner_tmp[0], &v_tmp);
pp_filter_set_clear_fb(p);
cso_single_sampler(p->cso, 0, &p->sampler_point);
cso_single_sampler(p->cso, 1, &p->sampler_point);
cso_single_sampler(p->cso, 2, &p->sampler);
cso_single_sampler_done(p->cso);
arr[0] = p->view;
cso_set_fragment_sampler_views(p->cso, 3, arr);
cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][0]); /* passvs */
cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][3]);
pp_filter_draw(p);
pp_filter_end_pass(p);
pipe_sampler_view_reference(&arr[1], NULL);
/* Third pass: smoothed edges */
/* Sampler order: colormap, blendmap (wtf compiler) */
pp_filter_setup_in(p, ppq->inner_tmp[1]);
pp_filter_setup_out(p, out);
pp_filter_set_fb(p);
/* Blit the input to the output */
util_blit_pixels(p->blitctx, in, 0, 0, 0,
w, h, 0, p->framebuffer.cbufs[0],
0, 0, w, h, 0, PIPE_TEX_MIPFILTER_NEAREST);
u_sampler_view_default_template(&v_tmp, in, in->format);
arr[0] = p->pipe->create_sampler_view(p->pipe, in, &v_tmp);
cso_single_sampler(p->cso, 0, &p->sampler_point);
cso_single_sampler(p->cso, 1, &p->sampler_point);
cso_single_sampler_done(p->cso);
arr[1] = p->view;
cso_set_fragment_sampler_views(p->cso, 2, arr);
cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][1]); /* offsetvs */
cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][4]);
p->blend.rt[0].blend_enable = 1;
cso_set_blend(p->cso, &p->blend);
pp_filter_draw(p);
pp_filter_end_pass(p);
pipe_sampler_view_reference(&arr[0], NULL);
p->blend.rt[0].blend_enable = 0;
p->framebuffer.zsbuf = NULL;
}
/** The init function of the MLAA filter. */
static void
pp_jimenezmlaa_init_run(struct pp_queue_t *ppq, unsigned int n,
unsigned int val, bool iscolor)
{
struct pipe_box box;
struct pipe_resource res;
char *tmp_text = calloc(sizeof(blend2fs_1) + sizeof(blend2fs_2) +
IMM_SPACE, sizeof(char));
constbuf = pipe_buffer_create(ppq->p->screen, PIPE_BIND_CONSTANT_BUFFER,
PIPE_USAGE_STATIC, sizeof(constants));
if (!constbuf) {
pp_debug("Failed to allocate constant buffer\n");
return;
}
pp_debug("mlaa: using %u max search steps\n", val);
if (!tmp_text) {
pp_debug("Failed to allocate shader space\n");
return;
}
sprintf(tmp_text, "%s"
"IMM FLT32 { %.8f, 0.0000, 0.0000, 0.0000}\n"
"%s\n", blend2fs_1, (float) val, blend2fs_2);
memset(&res, 0, sizeof(res));
res.target = PIPE_TEXTURE_2D;
res.format = PIPE_FORMAT_R8G8_UNORM;
res.width0 = res.height0 = 165;
res.bind = PIPE_BIND_SAMPLER_VIEW;
res.usage = PIPE_USAGE_STATIC;
res.depth0 = res.array_size = res.nr_samples = 1;
if (!ppq->p->screen->is_format_supported(ppq->p->screen, res.format,
res.target, 1, res.bind))
pp_debug("Areamap format not supported\n");
areamaptex = ppq->p->screen->resource_create(ppq->p->screen, &res);
u_box_2d(0, 0, 165, 165, &box);
ppq->p->pipe->transfer_inline_write(ppq->p->pipe, areamaptex, 0,
PIPE_TRANSFER_WRITE, &box,
areamap, 165 * 2, sizeof(areamap));
ppq->shaders[n][1] = pp_tgsi_to_state(ppq->p->pipe, offsetvs, true,
"offsetvs");
if (iscolor)
ppq->shaders[n][2] = pp_tgsi_to_state(ppq->p->pipe, color1fs,
false, "color1fs");
else
ppq->shaders[n][2] = pp_tgsi_to_state(ppq->p->pipe, depth1fs,
false, "depth1fs");
ppq->shaders[n][3] = pp_tgsi_to_state(ppq->p->pipe, tmp_text, false,
"blend2fs");
ppq->shaders[n][4] = pp_tgsi_to_state(ppq->p->pipe, neigh3fs, false,
"neigh3fs");
free(tmp_text);
}
/** Short wrapper to init the depth version. */
void
pp_jimenezmlaa_init(struct pp_queue_t *ppq, unsigned int n, unsigned int val)
{
pp_jimenezmlaa_init_run(ppq, n, val, false);
}
/** Short wrapper to init the color version. */
void
pp_jimenezmlaa_init_color(struct pp_queue_t *ppq, unsigned int n,
unsigned int val)
{
pp_jimenezmlaa_init_run(ppq, n, val, true);
}
/** Short wrapper to run the depth version. */
void
pp_jimenezmlaa(struct pp_queue_t *ppq, struct pipe_resource *in,
struct pipe_resource *out, unsigned int n)
{
pp_jimenezmlaa_run(ppq, in, out, n, false);
}
/** Short wrapper to run the color version. */
void
pp_jimenezmlaa_color(struct pp_queue_t *ppq, struct pipe_resource *in,
struct pipe_resource *out, unsigned int n)
{
pp_jimenezmlaa_run(ppq, in, out, n, true);
}

View file

@ -0,0 +1,342 @@
/**
* Copyright (C) 2010 Jorge Jimenez (jorge@iryoku.com)
* Copyright (C) 2010 Belen Masia (bmasia@unizar.es)
* Copyright (C) 2010 Jose I. Echevarria (joseignacioechevarria@gmail.com)
* Copyright (C) 2010 Fernando Navarro (fernandn@microsoft.com)
* Copyright (C) 2010 Diego Gutierrez (diegog@unizar.es)
* Copyright (C) 2011 Lauri Kasanen (cand@gmx.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the following statement:
*
* "Uses Jimenez's MLAA. Copyright (C) 2010 by Jorge Jimenez, Belen Masia,
* Jose I. Echevarria, Fernando Navarro and Diego Gutierrez."
*
* Only for use in the Mesa project, this point 2 is filled by naming the
* technique Jimenez's MLAA in the Mesa config options.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holders.
*/
#ifndef PP_MLAA_H
#define PP_MLAA_H
#include "postprocess/pp_mlaa_areamap.h"
static const char depth1fs[] = "FRAG\n"
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
"DCL IN[1], GENERIC[10], PERSPECTIVE\n"
"DCL IN[2], GENERIC[11], PERSPECTIVE\n"
"DCL OUT[0], COLOR\n"
"DCL SAMP[0]\n"
"DCL TEMP[0..2]\n"
"IMM FLT32 { 0.0030, 0.0000, 1.0000, 0.0000}\n"
" 0: TEX TEMP[0].x, IN[1].xyyy, SAMP[0], 2D\n"
" 1: MOV TEMP[1].x, TEMP[0].xxxx\n"
" 2: TEX TEMP[0].x, IN[1].zwww, SAMP[0], 2D\n"
" 3: MOV TEMP[1].y, TEMP[0].xxxx\n"
" 4: TEX TEMP[0].x, IN[2].xyyy, SAMP[0], 2D\n"
" 5: MOV TEMP[1].z, TEMP[0].xxxx\n"
" 6: TEX TEMP[0].x, IN[2].zwww, SAMP[0], 2D\n"
" 7: MOV TEMP[1].w, TEMP[0].xxxx\n"
" 8: TEX TEMP[0].x, IN[0].xyyy, SAMP[0], 2D\n"
" 9: ADD TEMP[2], TEMP[0].xxxx, -TEMP[1]\n"
" 10: ABS TEMP[0], TEMP[2]\n"
" 11: SGE TEMP[2], TEMP[0], IMM[0].xxxx\n"
" 12: DP4 TEMP[0].x, TEMP[2], IMM[0].zzzz\n"
" 13: SEQ TEMP[1].x, TEMP[0].xxxx, IMM[0].yyyy\n"
" 14: IF TEMP[1].xxxx :16\n"
" 15: KILP\n"
" 16: ENDIF\n"
" 17: MOV OUT[0], TEMP[2]\n"
" 18: END\n";
static const char color1fs[] = "FRAG\n"
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
"DCL IN[1], GENERIC[10], PERSPECTIVE\n"
"DCL IN[2], GENERIC[11], PERSPECTIVE\n"
"DCL OUT[0], COLOR\n"
"DCL SAMP[0]\n"
"DCL TEMP[0..2]\n"
"IMM FLT32 { 0.2126, 0.7152, 0.0722, 0.1000}\n"
"IMM FLT32 { 1.0000, 0.0000, 0.0000, 0.0000}\n"
" 0: TEX TEMP[1].xyz, IN[1].xyyy, SAMP[0], 2D\n"
" 1: DP3 TEMP[0].x, TEMP[1].xyzz, IMM[0]\n"
" 2: TEX TEMP[1].xyz, IN[1].zwww, SAMP[0], 2D\n"
" 3: DP3 TEMP[0].y, TEMP[1].xyzz, IMM[0].xyzz\n"
" 4: TEX TEMP[1].xyz, IN[2].xyyy, SAMP[0], 2D\n"
" 5: DP3 TEMP[0].z, TEMP[1].xyzz, IMM[0].xyzz\n"
" 6: TEX TEMP[1].xyz, IN[2].zwww, SAMP[0], 2D\n"
" 7: DP3 TEMP[0].w, TEMP[1].xyzz, IMM[0].xyzz\n"
" 8: TEX TEMP[1].xyz, IN[0].xyyy, SAMP[0], 2D\n"
" 9: DP3 TEMP[2].x, TEMP[1].xyzz, IMM[0].xyzz\n"
" 10: ADD TEMP[1], TEMP[2].xxxx, -TEMP[0]\n"
" 11: ABS TEMP[0], TEMP[1]\n"
" 12: SGE TEMP[2], TEMP[0], IMM[0].wwww\n"
" 13: DP4 TEMP[0].x, TEMP[2], IMM[1].xxxx\n"
" 14: SEQ TEMP[1].x, TEMP[0].xxxx, IMM[1].yyyy\n"
" 15: IF TEMP[1].xxxx :17\n"
" 16: KILP\n"
" 17: ENDIF\n"
" 18: MOV OUT[0], TEMP[2]\n"
" 19: END\n";
static const char neigh3fs[] = "FRAG\n"
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
"DCL IN[1], GENERIC[10], PERSPECTIVE\n"
"DCL IN[2], GENERIC[11], PERSPECTIVE\n"
"DCL OUT[0], COLOR\n"
"DCL SAMP[0]\n"
"DCL SAMP[1]\n"
"DCL TEMP[0..8]\n"
"IMM FLT32 { 1.0000, 0.00001, 0.0000, 0.0000}\n"
" 0: TEX TEMP[0], IN[0].xyyy, SAMP[1], 2D\n"
" 1: MOV TEMP[1].x, TEMP[0].xxxx\n"
" 2: TEX TEMP[2].y, IN[2].zwww, SAMP[1], 2D\n"
" 3: MOV TEMP[1].y, TEMP[2].yyyy\n"
" 4: MOV TEMP[1].z, TEMP[0].zzzz\n"
" 5: TEX TEMP[1].w, IN[2].xyyy, SAMP[1], 2D\n"
" 6: MUL TEMP[4], TEMP[1], TEMP[1]\n"
" 7: MUL TEMP[5], TEMP[4], TEMP[1]\n"
" 8: DP4 TEMP[1].x, TEMP[5], IMM[0].xxxx\n"
" 9: SLT TEMP[4].x, TEMP[1].xxxx, IMM[0].yyyy\n"
" 10: IF TEMP[4].xxxx :12\n"
" 11: KILP\n"
" 12: ENDIF\n"
" 13: TEX TEMP[4], IN[0].xyyy, SAMP[0], 2D\n"
" 14: TEX TEMP[6], IN[1].zwww, SAMP[0], 2D\n"
" 15: ADD TEMP[7].x, IMM[0].xxxx, -TEMP[0].xxxx\n"
" 16: MUL TEMP[8], TEMP[4], TEMP[7].xxxx\n"
" 17: MAD TEMP[7], TEMP[6], TEMP[0].xxxx, TEMP[8]\n"
" 18: MUL TEMP[6], TEMP[7], TEMP[5].xxxx\n"
" 19: TEX TEMP[7], IN[2].zwww, SAMP[0], 2D\n"
" 20: ADD TEMP[8].x, IMM[0].xxxx, -TEMP[2].yyyy\n"
" 21: MUL TEMP[3], TEMP[4], TEMP[8].xxxx\n"
" 22: MAD TEMP[8], TEMP[7], TEMP[2].yyyy, TEMP[3]\n"
" 23: MAD TEMP[2], TEMP[8], TEMP[5].yyyy, TEMP[6]\n"
" 24: TEX TEMP[6], IN[1].xyyy, SAMP[0], 2D\n"
" 25: ADD TEMP[7].x, IMM[0].xxxx, -TEMP[0].zzzz\n"
" 26: MUL TEMP[8], TEMP[4], TEMP[7].xxxx\n"
" 27: MAD TEMP[7], TEMP[6], TEMP[0].zzzz, TEMP[8]\n"
" 28: MAD TEMP[0], TEMP[7], TEMP[5].zzzz, TEMP[2]\n"
" 29: TEX TEMP[2], IN[2].xyyy, SAMP[0], 2D\n"
" 30: ADD TEMP[6].x, IMM[0].xxxx, -TEMP[1].wwww\n"
" 31: MUL TEMP[7], TEMP[4], TEMP[6].xxxx\n"
" 32: MAD TEMP[4], TEMP[2], TEMP[1].wwww, TEMP[7]\n"
" 33: MAD TEMP[2], TEMP[4], TEMP[5].wwww, TEMP[0]\n"
" 34: RCP TEMP[0].x, TEMP[1].xxxx\n"
" 35: MUL OUT[0], TEMP[2], TEMP[0].xxxx\n"
" 36: END\n";
static const char offsetvs[] = "VERT\n"
"DCL IN[0]\n"
"DCL IN[1]\n"
"DCL OUT[0], POSITION\n"
"DCL OUT[1], GENERIC[0]\n"
"DCL OUT[2], GENERIC[10]\n"
"DCL OUT[3], GENERIC[11]\n"
"DCL CONST[0]\n"
"IMM FLT32 { 1.0000, 0.0000, -1.0000, 0.0000}\n"
" 0: MOV OUT[0], IN[0]\n"
" 1: MOV OUT[1], IN[1]\n"
" 2: MAD OUT[2], CONST[0].xyxy, IMM[0].zyyz, IN[1].xyxy\n"
" 3: MAD OUT[3], CONST[0].xyxy, IMM[0].xyyx, IN[1].xyxy\n"
" 4: END\n";
static const char blend2fs_1[] = "FRAG\n"
"PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
"DCL IN[0], GENERIC[0], PERSPECTIVE\n"
"DCL OUT[0], COLOR\n"
"DCL SAMP[0]\n"
"DCL SAMP[1]\n"
"DCL SAMP[2]\n"
"DCL CONST[0]\n"
"DCL TEMP[0..6]\n"
"IMM FLT32 { 0.0000, -0.2500, 0.00609756, 0.5000}\n"
"IMM FLT32 { -1.5000, -2.0000, 0.9000, 1.5000}\n"
"IMM FLT32 { 2.0000, 1.0000, 4.0000, 33.0000}\n";
static const char blend2fs_2[] =
" 0: MOV TEMP[0], IMM[0].xxxx\n"
" 1: TEX TEMP[1], IN[0].xyyy, SAMP[1], 2D\n"
" 2: MOV TEMP[2].x, TEMP[1]\n"
" 3: SNE TEMP[3].x, TEMP[1].yyyy, IMM[0].xxxx\n"
" 4: IF TEMP[3].xxxx :76\n"
" 5: MOV TEMP[1].xy, IN[0].xyxx\n"
" 6: MOV TEMP[4].x, IMM[1].xxxx\n"
" 7: BGNLOOP :24\n"
" 8: MUL TEMP[5].x, IMM[1].yyyy, IMM[3].xxxx\n"
" 9: SLE TEMP[6].x, TEMP[4].xxxx, TEMP[5].xxxx\n"
" 10: IF TEMP[6].xxxx :12\n"
" 11: BRK\n"
" 12: ENDIF\n"
" 13: MOV TEMP[4].y, IMM[0].xxxx\n"
" 14: MAD TEMP[3].xyz, CONST[0].xyyy, TEMP[4].xyyy, TEMP[1].xyyy\n"
" 15: MOV TEMP[3].w, IMM[0].xxxx\n"
" 16: TXL TEMP[5], TEMP[3], SAMP[2], 2D\n"
" 17: MOV TEMP[3].x, TEMP[5].yyyy\n"
" 18: SLT TEMP[6].x, TEMP[5].yyyy, IMM[1].zzzz\n"
" 19: IF TEMP[6].xxxx :21\n"
" 20: BRK\n"
" 21: ENDIF\n"
" 22: ADD TEMP[6].x, TEMP[4].xxxx, IMM[1].yyyy\n"
" 23: MOV TEMP[4].x, TEMP[6].xxxx\n"
" 24: ENDLOOP :7\n"
" 25: ADD TEMP[1].x, TEMP[4].xxxx, IMM[1].wwww\n"
" 26: MAD TEMP[6].x, -IMM[2].xxxx, TEMP[3].xxxx, TEMP[1].xxxx\n"
" 27: MUL TEMP[1].x, IMM[1].yyyy, IMM[3].xxxx\n"
" 28: MAX TEMP[4].x, TEMP[6].xxxx, TEMP[1].xxxx\n"
" 29: MOV TEMP[1].x, TEMP[4].xxxx\n"
" 30: MOV TEMP[3].xy, IN[0].xyxx\n"
" 31: MOV TEMP[5].x, IMM[1].wwww\n"
" 32: BGNLOOP :49\n"
" 33: MUL TEMP[6].x, IMM[2].xxxx, IMM[3].xxxx\n"
" 34: SGE TEMP[4].x, TEMP[5].xxxx, TEMP[6].xxxx\n"
" 35: IF TEMP[4].xxxx :37\n"
" 36: BRK\n"
" 37: ENDIF\n"
" 38: MOV TEMP[5].y, IMM[0].xxxx\n"
" 39: MAD TEMP[4].xyz, CONST[0].xyyy, TEMP[5].xyyy, TEMP[3].xyyy\n"
" 40: MOV TEMP[4].w, IMM[0].xxxx\n"
" 41: TXL TEMP[6].xy, TEMP[4], SAMP[2], 2D\n"
" 42: MOV TEMP[4].x, TEMP[6].yyyy\n"
" 43: SLT TEMP[0].x, TEMP[6].yyyy, IMM[1].zzzz\n"
" 44: IF TEMP[0].xxxx :46\n"
" 45: BRK\n"
" 46: ENDIF\n"
" 47: ADD TEMP[6].x, TEMP[5].xxxx, IMM[2].xxxx\n"
" 48: MOV TEMP[5].x, TEMP[6].xxxx\n"
" 49: ENDLOOP :32\n"
" 50: ADD TEMP[3].x, TEMP[5].xxxx, IMM[1].xxxx\n"
" 51: MAD TEMP[5].x, IMM[2].xxxx, TEMP[4].xxxx, TEMP[3].xxxx\n"
" 52: MUL TEMP[3].x, IMM[2].xxxx, IMM[3].xxxx\n"
" 53: MIN TEMP[4].x, TEMP[5].xxxx, TEMP[3].xxxx\n"
" 54: MOV TEMP[3].x, TEMP[1].xxxx\n"
" 55: MOV TEMP[3].y, TEMP[4].xxxx\n"
" 56: MOV TEMP[5].yw, IMM[0].yyyy\n"
" 57: MOV TEMP[5].x, TEMP[1].xxxx\n"
" 58: ADD TEMP[1].x, TEMP[4].xxxx, IMM[2].yyyy\n"
" 59: MOV TEMP[5].z, TEMP[1].xxxx\n"
" 60: MAD TEMP[1], TEMP[5], CONST[0].xyxy, IN[0].xyxy\n"
" 61: MOV TEMP[4], TEMP[1].xyyy\n"
" 62: MOV TEMP[4].w, IMM[0].xxxx\n"
" 63: TXL TEMP[5].x, TEMP[4], SAMP[2], 2D\n"
" 64: MOV TEMP[4].x, TEMP[5].xxxx\n"
" 65: MOV TEMP[5], TEMP[1].zwww\n"
" 66: MOV TEMP[5].w, IMM[0].xxxx\n"
" 67: TXL TEMP[1].x, TEMP[5], SAMP[2], 2D\n"
" 68: MOV TEMP[4].y, TEMP[1].xxxx\n"
" 69: MUL TEMP[5].xy, IMM[2].zzzz, TEMP[4].xyyy\n"
" 70: ROUND TEMP[1].xy, TEMP[5].xyyy\n"
" 71: ABS TEMP[4].xy, TEMP[3].xyyy\n"
" 72: MAD TEMP[3].xy, IMM[2].wwww, TEMP[1].xyyy, TEMP[4].xyyy\n"
" 73: MUL TEMP[5].xyz, TEMP[3].xyyy, IMM[0].zzzz\n"
" 74: MOV TEMP[5].w, IMM[0].xxxx\n"
" 75: TXL TEMP[0].xy, TEMP[5], SAMP[0], 2D\n"
" 76: ENDIF\n"
" 77: SNE TEMP[1].x, TEMP[2].xxxx, IMM[0].xxxx\n"
" 78: IF TEMP[1].xxxx :151\n"
" 79: MOV TEMP[1].xy, IN[0].xyxx\n"
" 80: MOV TEMP[3].x, IMM[1].xxxx\n"
" 81: BGNLOOP :98\n"
" 82: MUL TEMP[4].x, IMM[1].yyyy, IMM[3].xxxx\n"
" 83: SLE TEMP[5].x, TEMP[3].xxxx, TEMP[4].xxxx\n"
" 84: IF TEMP[5].xxxx :86\n"
" 85: BRK\n"
" 86: ENDIF\n"
" 87: MOV TEMP[3].y, IMM[0].xxxx\n"
" 88: MAD TEMP[5].xyz, CONST[0].xyyy, TEMP[3].yxxx, TEMP[1].xyyy\n"
" 89: MOV TEMP[5].w, IMM[0].xxxx\n"
" 90: TXL TEMP[4], TEMP[5], SAMP[2], 2D\n"
" 91: MOV TEMP[2].x, TEMP[4].xxxx\n"
" 92: SLT TEMP[5].x, TEMP[4].xxxx, IMM[1].zzzz\n"
" 93: IF TEMP[5].xxxx :95\n"
" 94: BRK\n"
" 95: ENDIF\n"
" 96: ADD TEMP[4].x, TEMP[3].xxxx, IMM[1].yyyy\n"
" 97: MOV TEMP[3].x, TEMP[4].xxxx\n"
" 98: ENDLOOP :81\n"
" 99: ADD TEMP[1].x, TEMP[3].xxxx, IMM[1].wwww\n"
"100: MAD TEMP[6].x, -IMM[2].xxxx, TEMP[2].xxxx, TEMP[1].xxxx\n"
"101: MUL TEMP[1].x, IMM[1].yyyy, IMM[3].xxxx\n"
"102: MAX TEMP[3].x, TEMP[6].xxxx, TEMP[1].xxxx\n"
"103: MOV TEMP[1].x, TEMP[3].xxxx\n"
"104: MOV TEMP[2].xy, IN[0].xyxx\n"
"105: MOV TEMP[4].x, IMM[1].wwww\n"
"106: BGNLOOP :123\n"
"107: MUL TEMP[5].x, IMM[2].xxxx, IMM[3].xxxx\n"
"108: SGE TEMP[6].x, TEMP[4].xxxx, TEMP[5].xxxx\n"
"109: IF TEMP[6].xxxx :111\n"
"110: BRK\n"
"111: ENDIF\n"
"112: MOV TEMP[4].y, IMM[0].xxxx\n"
"113: MAD TEMP[5].xyz, CONST[0].xyyy, TEMP[4].yxxx, TEMP[2].xyyy\n"
"114: MOV TEMP[5].w, IMM[0].xxxx\n"
"115: TXL TEMP[6], TEMP[5], SAMP[2], 2D\n"
"116: MOV TEMP[3].x, TEMP[6].xxxx\n"
"117: SLT TEMP[5].x, TEMP[6].xxxx, IMM[1].zzzz\n"
"118: IF TEMP[5].xxxx :120\n"
"119: BRK\n"
"120: ENDIF\n"
"121: ADD TEMP[6].x, TEMP[4].xxxx, IMM[2].xxxx\n"
"122: MOV TEMP[4].x, TEMP[6].xxxx\n"
"123: ENDLOOP :106\n"
"124: ADD TEMP[2].x, TEMP[4].xxxx, IMM[1].xxxx\n"
"125: MAD TEMP[4].x, IMM[2].xxxx, TEMP[3].xxxx, TEMP[2].xxxx\n"
"126: MUL TEMP[2].x, IMM[2].xxxx, IMM[3].xxxx\n"
"127: MIN TEMP[3].x, TEMP[4].xxxx, TEMP[2].xxxx\n"
"128: MOV TEMP[2].x, TEMP[1].xxxx\n"
"129: MOV TEMP[2].y, TEMP[3].xxxx\n"
"130: MOV TEMP[4].xz, IMM[0].yyyy\n"
"131: MOV TEMP[4].y, TEMP[1].xxxx\n"
"132: ADD TEMP[1].x, TEMP[3].xxxx, IMM[2].yyyy\n"
"133: MOV TEMP[4].w, TEMP[1].xxxx\n"
"134: MAD TEMP[1], TEMP[4], CONST[0].xyxy, IN[0].xyxy\n"
"135: MOV TEMP[3], TEMP[1].xyyy\n"
"136: MOV TEMP[3].w, IMM[0].xxxx\n"
"137: TXL TEMP[4].y, TEMP[3], SAMP[2], 2D\n"
"138: MOV TEMP[3].x, TEMP[4].yyyy\n"
"139: MOV TEMP[4], TEMP[1].zwww\n"
"140: MOV TEMP[4].w, IMM[0].xxxx\n"
"141: TXL TEMP[1].y, TEMP[4], SAMP[2], 2D\n"
"142: MOV TEMP[3].y, TEMP[1].yyyy\n"
"143: MUL TEMP[4].xy, IMM[2].zzzz, TEMP[3].xyyy\n"
"144: ROUND TEMP[1].xy, TEMP[4].xyyy\n"
"145: ABS TEMP[3].xy, TEMP[2].xyyy\n"
"146: MAD TEMP[2].xy, IMM[2].wwww, TEMP[1].xyyy, TEMP[3].xyyy\n"
"147: MUL TEMP[3].xyz, TEMP[2].xyyy, IMM[0].zzzz\n"
"148: MOV TEMP[3].w, IMM[0].xxxx\n"
"149: TXL TEMP[1].xy, TEMP[3], SAMP[0], 2D\n"
"150: MOV TEMP[0].zw, TEMP[1].yyxy\n"
"151: ENDIF\n"
"152: MOV OUT[0], TEMP[0]\n"
"153: END\n";
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,139 @@
/**************************************************************************
*
* Copyright 2010 Jakob Bornecrantz
* Copyright 2011 Lauri Kasanen
* 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 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 "postprocess/postprocess.h"
#include "cso_cache/cso_context.h"
#include "pipe/p_screen.h"
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_inlines.h"
#include "util/u_simple_shaders.h"
/** Initialize the internal details */
struct program *
pp_init_prog(struct pp_queue_t *ppq, struct pipe_screen *pscreen)
{
struct program *p = calloc(1, sizeof(struct program));
pp_debug("Initializing program\n");
if (!pscreen)
return NULL;
if (!p)
return NULL;
p->screen = pscreen;
p->pipe = pscreen->context_create(pscreen, NULL);
p->cso = cso_create_context(p->pipe);
{
static const float verts[4][2][4] = {
{
{1.0f, 1.0f, 0.0f, 1.0f},
{1.0f, 1.0f, 0.0f, 1.0f}
},
{
{-1.0f, 1.0f, 0.0f, 1.0f},
{0.0f, 1.0f, 0.0f, 1.0f}
},
{
{-1.0f, -1.0f, 0.0f, 1.0f},
{0.0f, 0.0f, 0.0f, 1.0f}
},
{
{1.0f, -1.0f, 0.0f, 1.0f},
{1.0f, 0.0f, 0.0f, 1.0f}
}
};
p->vbuf = pipe_buffer_create(pscreen, PIPE_BIND_VERTEX_BUFFER,
PIPE_USAGE_STATIC, sizeof(verts));
pipe_buffer_write(p->pipe, p->vbuf, 0, sizeof(verts), verts);
}
p->blend.rt[0].colormask = PIPE_MASK_RGBA;
p->blend.rt[0].rgb_src_factor = p->blend.rt[0].alpha_src_factor =
PIPE_BLENDFACTOR_SRC_ALPHA;
p->blend.rt[0].rgb_dst_factor = p->blend.rt[0].alpha_dst_factor =
PIPE_BLENDFACTOR_INV_SRC_ALPHA;
p->rasterizer.cull_face = PIPE_FACE_NONE;
p->rasterizer.gl_rasterization_rules = 1;
p->sampler.wrap_s = p->sampler.wrap_t = p->sampler.wrap_r =
PIPE_TEX_WRAP_CLAMP_TO_EDGE;
p->sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
p->sampler.min_img_filter = p->sampler.mag_img_filter =
PIPE_TEX_FILTER_LINEAR;
p->sampler.normalized_coords = 1;
p->sampler_point.wrap_s = p->sampler_point.wrap_t =
p->sampler_point.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
p->sampler_point.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
p->sampler_point.min_img_filter = p->sampler_point.mag_img_filter =
PIPE_TEX_FILTER_NEAREST;
p->sampler_point.normalized_coords = 1;
p->velem[0].src_offset = 0;
p->velem[0].instance_divisor = 0;
p->velem[0].vertex_buffer_index = 0;
p->velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
p->velem[1].src_offset = 1 * 4 * sizeof(float);
p->velem[1].instance_divisor = 0;
p->velem[1].vertex_buffer_index = 0;
p->velem[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
if (!p->screen->is_format_supported(p->screen,
PIPE_FORMAT_R32G32B32A32_FLOAT,
PIPE_BUFFER, 1,
PIPE_BIND_VERTEX_BUFFER))
pp_debug("Vertex buf format fail\n");
{
const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
TGSI_SEMANTIC_GENERIC
};
const uint semantic_indexes[] = { 0, 0 };
p->passvs = util_make_vertex_passthrough_shader(p->pipe, 2,
semantic_names,
semantic_indexes);
}
p->framebuffer.nr_cbufs = 1;
p->surf.usage = PIPE_BIND_RENDER_TARGET;
p->surf.format = PIPE_FORMAT_B8G8R8A8_UNORM;
p->pipe->set_sample_mask(p->pipe, ~0);
return p;
}

View file

@ -0,0 +1,64 @@
/**************************************************************************
*
* Copyright 2010 Jakob Bornecrantz
* Copyright 2011 Lauri Kasanen
* 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 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 PP_PROGRAM_H
#define PP_PROGRAM_H
#include "pipe/p_state.h"
/**
* Internal control details.
*/
struct program
{
struct pipe_screen *screen;
struct pipe_context *pipe;
struct cso_context *cso;
struct pipe_blend_state blend;
struct pipe_depth_stencil_alpha_state depthstencil;
struct pipe_rasterizer_state rasterizer;
struct pipe_sampler_state sampler; /* bilinear */
struct pipe_sampler_state sampler_point; /* point */
struct pipe_viewport_state viewport;
struct pipe_framebuffer_state framebuffer;
struct pipe_vertex_element velem[2];
float clear_color[4];
void *passvs;
struct pipe_resource *vbuf;
struct pipe_surface surf;
struct pipe_sampler_view *view;
struct blit_state *blitctx;
};
#endif

View file

@ -0,0 +1,188 @@
/**************************************************************************
*
* Copyright 2011 Lauri Kasanen
* 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 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 "postprocess.h"
#include "postprocess/pp_filters.h"
#include "util/u_blit.h"
#include "util/u_inlines.h"
#include "util/u_sampler.h"
/**
* Main run function of the PP queue. Called on swapbuffers/flush.
*
* Runs all requested filters in order and handles shuffling the temp
* buffers in between.
*/
void
pp_run(struct pp_queue_t *ppq, struct pipe_resource *in,
struct pipe_resource *out, struct pipe_resource *indepth)
{
unsigned int i;
if (in->width0 != ppq->p->framebuffer.width ||
in->height0 != ppq->p->framebuffer.height) {
pp_debug("Resizing the temp pp buffers\n");
pp_free_fbos(ppq);
pp_init_fbos(ppq, in->width0, in->height0, indepth);
}
if (in == out && ppq->n_filters == 1) {
/* Make a copy of in to tmp[0] in this case. */
unsigned int w = ppq->p->framebuffer.width;
unsigned int h = ppq->p->framebuffer.height;
util_blit_pixels(ppq->p->blitctx, in, 0, 0, 0,
w, h, 0, ppq->tmps[0],
0, 0, w, h, 0, PIPE_TEX_MIPFILTER_NEAREST);
in = ppq->tmp[0];
}
switch (ppq->n_filters) {
case 1: /* No temp buf */
ppq->pp_queue[0] (ppq, in, out, 0);
break;
case 2: /* One temp buf */
ppq->pp_queue[0] (ppq, in, ppq->tmp[0], 0);
ppq->pp_queue[1] (ppq, ppq->tmp[0], out, 1);
break;
default: /* Two temp bufs */
ppq->pp_queue[0] (ppq, in, ppq->tmp[0], 0);
for (i = 1; i < (ppq->n_filters - 1); i++) {
if (i % 2 == 0)
ppq->pp_queue[i] (ppq, ppq->tmp[1], ppq->tmp[0], i);
else
ppq->pp_queue[i] (ppq, ppq->tmp[0], ppq->tmp[1], i);
}
if (i % 2 == 0)
ppq->pp_queue[i] (ppq, ppq->tmp[1], out, i);
else
ppq->pp_queue[i] (ppq, ppq->tmp[0], out, i);
break;
}
}
/* Utility functions for the filters. You're not forced to use these if */
/* your filter is more complicated. */
/** Setup this resource as the filter input. */
void
pp_filter_setup_in(struct program *p, struct pipe_resource *in)
{
struct pipe_sampler_view v_tmp;
u_sampler_view_default_template(&v_tmp, in, in->format);
p->view = p->pipe->create_sampler_view(p->pipe, in, &v_tmp);
}
/** Setup this resource as the filter output. */
void
pp_filter_setup_out(struct program *p, struct pipe_resource *out)
{
p->surf.format = out->format;
p->surf.usage = PIPE_BIND_RENDER_TARGET;
p->framebuffer.cbufs[0] = p->pipe->create_surface(p->pipe, out, &p->surf);
}
/** Clean up the input and output set with the above. */
void
pp_filter_end_pass(struct program *p)
{
pipe_surface_reference(&p->framebuffer.cbufs[0], NULL);
pipe_sampler_view_reference(&p->view, NULL);
}
/**
* Convert the TGSI assembly to a runnable shader.
*
* We need not care about geometry shaders. All we have is screen quads.
*/
void *
pp_tgsi_to_state(struct pipe_context *pipe, const char *text, bool isvs,
const char *name)
{
struct pipe_shader_state state;
struct tgsi_token tokens[PP_MAX_TOKENS];
if (tgsi_text_translate(text, tokens, Elements(tokens)) == FALSE) {
pp_debug("Failed to translate %s\n", name);
return NULL;
}
state.tokens = tokens;
if (isvs)
return pipe->create_vs_state(pipe, &state);
else
return pipe->create_fs_state(pipe, &state);
}
/** Setup misc state for the filter. */
void
pp_filter_misc_state(struct program *p)
{
cso_set_blend(p->cso, &p->blend);
cso_set_depth_stencil_alpha(p->cso, &p->depthstencil);
cso_set_rasterizer(p->cso, &p->rasterizer);
cso_set_viewport(p->cso, &p->viewport);
cso_set_vertex_elements(p->cso, 2, p->velem);
}
/** Draw with the filter to the set output. */
void
pp_filter_draw(struct program *p)
{
util_draw_vertex_buffer(p->pipe, p->cso, p->vbuf, 0,
PIPE_PRIM_QUADS, 4, 2);
p->pipe->flush(p->pipe, NULL);
}
/** Set the framebuffer as active. */
void
pp_filter_set_fb(struct program *p)
{
cso_set_framebuffer(p->cso, &p->framebuffer);
}
/** Set the framebuffer as active and clear it. */
void
pp_filter_set_clear_fb(struct program *p)
{
cso_set_framebuffer(p->cso, &p->framebuffer);
p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, p->clear_color, 0, 0);
}

View file

@ -1594,6 +1594,9 @@ store_dest(struct tgsi_exec_machine *mach,
#define FETCH(VAL,INDEX,CHAN)\
fetch_source(mach, VAL, &inst->Src[INDEX], CHAN, TGSI_EXEC_DATA_FLOAT)
#define IFETCH(VAL,INDEX,CHAN)\
fetch_source(mach, VAL, &inst->Src[INDEX], CHAN, TGSI_EXEC_DATA_INT)
/**
* Execute ARB-style KIL which is predicated by a src register.
@ -1921,6 +1924,86 @@ exec_txd(struct tgsi_exec_machine *mach,
}
static void
exec_txf(struct tgsi_exec_machine *mach,
const struct tgsi_full_instruction *inst)
{
struct tgsi_sampler *sampler;
const uint unit = inst->Src[1].Register.Index;
union tgsi_exec_channel r[4];
uint chan;
float rgba[NUM_CHANNELS][QUAD_SIZE];
int j;
IFETCH(&r[3], 0, CHAN_W);
switch(inst->Texture.Texture) {
case TGSI_TEXTURE_3D:
case TGSI_TEXTURE_2D_ARRAY:
IFETCH(&r[2], 0, CHAN_Z);
/* fallthrough */
case TGSI_TEXTURE_2D:
case TGSI_TEXTURE_RECT:
case TGSI_TEXTURE_SHADOW2D:
case TGSI_TEXTURE_SHADOWRECT:
case TGSI_TEXTURE_1D_ARRAY:
IFETCH(&r[1], 0, CHAN_Y);
/* fallthrough */
case TGSI_TEXTURE_1D:
case TGSI_TEXTURE_SHADOW1D:
IFETCH(&r[0], 0, CHAN_X);
break;
default:
assert(0);
break;
}
sampler = mach->Samplers[unit];
sampler->get_texel(sampler, r[0].i, r[1].i, r[2].i, r[3].i, rgba);
for (j = 0; j < QUAD_SIZE; j++) {
r[0].f[j] = rgba[0][j];
r[1].f[j] = rgba[1][j];
r[2].f[j] = rgba[2][j];
r[3].f[j] = rgba[3][j];
}
for (chan = 0; chan < NUM_CHANNELS; chan++) {
if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
store_dest(mach, &r[chan], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT);
}
}
}
static void
exec_txq(struct tgsi_exec_machine *mach,
const struct tgsi_full_instruction *inst)
{
struct tgsi_sampler *sampler;
const uint unit = inst->Src[1].Register.Index;
int result[4];
union tgsi_exec_channel r[4], src;
uint chan;
int i,j;
fetch_source(mach, &src, &inst->Src[0], CHAN_X, TGSI_EXEC_DATA_INT);
sampler = mach->Samplers[unit];
sampler->get_dims(sampler, src.i[0], result);
for (i = 0; i < QUAD_SIZE; i++) {
for (j = 0; j < 4; j++) {
r[j].i[i] = result[j];
}
}
for (chan = 0; chan < NUM_CHANNELS; chan++) {
if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
store_dest(mach, &r[chan], &inst->Dst[0], inst, chan,
TGSI_EXEC_DATA_INT);
}
}
}
static void
exec_sample(struct tgsi_exec_machine *mach,
@ -2988,6 +3071,17 @@ micro_xor(union tgsi_exec_channel *dst,
dst->u[3] = src0->u[3] ^ src1->u[3];
}
static void
micro_mod(union tgsi_exec_channel *dst,
const union tgsi_exec_channel *src0,
const union tgsi_exec_channel *src1)
{
dst->i[0] = src0->i[0] % src1->i[0];
dst->i[1] = src0->i[1] % src1->i[1];
dst->i[2] = src0->i[2] % src1->i[2];
dst->i[3] = src0->i[3] % src1->i[3];
}
static void
micro_f2i(union tgsi_exec_channel *dst,
const union tgsi_exec_channel *src)
@ -3691,7 +3785,7 @@ exec_instruction(
break;
case TGSI_OPCODE_MOD:
assert (0);
exec_vector_binary(mach, inst, micro_mod, TGSI_EXEC_DATA_INT, TGSI_EXEC_DATA_INT);
break;
case TGSI_OPCODE_XOR:
@ -3703,11 +3797,11 @@ exec_instruction(
break;
case TGSI_OPCODE_TXF:
assert (0);
exec_txf(mach, inst);
break;
case TGSI_OPCODE_TXQ:
assert (0);
exec_txq(mach, inst);
break;
case TGSI_OPCODE_EMIT:

View file

@ -90,6 +90,11 @@ struct tgsi_sampler
const float c0[QUAD_SIZE],
enum tgsi_sampler_control control,
float rgba[NUM_CHANNELS][QUAD_SIZE]);
void (*get_dims)(struct tgsi_sampler *sampler, int level,
int dims[4]);
void (*get_texel)(struct tgsi_sampler *sampler, const int i[QUAD_SIZE],
const int j[QUAD_SIZE], const int k[QUAD_SIZE],
const int lod[QUAD_SIZE], float rgba[NUM_CHANNELS][QUAD_SIZE]);
};
#define TGSI_EXEC_NUM_TEMPS 128
@ -400,6 +405,8 @@ tgsi_exec_get_shader_param(enum pipe_shader_cap param)
return 1;
case PIPE_SHADER_CAP_SUBROUTINES:
return 1;
case PIPE_SHADER_CAP_INTEGERS:
return 1;
default:
return 0;
}

View file

@ -200,19 +200,20 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
info->file_max[file] = MAX2(info->file_max[file], (int)reg);
}
break;
case TGSI_TOKEN_TYPE_PROPERTY:
{
const struct tgsi_full_property *fullprop
= &parse.FullToken.FullProperty;
{
const struct tgsi_full_property *fullprop
= &parse.FullToken.FullProperty;
info->properties[info->num_properties].name =
fullprop->Property.PropertyName;
memcpy(info->properties[info->num_properties].data,
fullprop->u, 8 * sizeof(unsigned));;
info->properties[info->num_properties].name =
fullprop->Property.PropertyName;
memcpy(info->properties[info->num_properties].data,
fullprop->u, 8 * sizeof(unsigned));;
++info->num_properties;
}
break;
++info->num_properties;
}
break;
default:
assert( 0 );
@ -222,6 +223,23 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
info->uses_kill = (info->opcode_count[TGSI_OPCODE_KIL] ||
info->opcode_count[TGSI_OPCODE_KILP]);
/* extract simple properties */
for (i = 0; i < info->num_properties; ++i) {
switch (info->properties[i].name) {
case TGSI_PROPERTY_FS_COORD_ORIGIN:
info->origin_lower_left = info->properties[i].data[0];
break;
case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER:
info->pixel_center_integer = info->properties[i].data[0];
break;
case TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS:
info->color0_writes_all_cbufs = info->properties[i].data[0];
break;
default:
;
}
}
tgsi_parse_free (&parse);
}

View file

@ -68,6 +68,9 @@ struct tgsi_shader_info
boolean writes_edgeflag; /**< vertex shader outputs edgeflag */
boolean uses_kill; /**< KIL or KILP instruction used? */
boolean uses_instanceid;
boolean origin_lower_left;
boolean pixel_center_integer;
boolean color0_writes_all_cbufs;
/**
* Bitmask indicating which register files are accessed with

View file

@ -26,8 +26,8 @@
/**
* @file
* Blitter utility to facilitate acceleration of the clear, clear_render_target, clear_depth_stencil
* resource_copy_region functions.
* Blitter utility to facilitate acceleration of the clear, clear_render_target,
* clear_depth_stencil, and resource_copy_region functions.
*
* @author Marek Olšák
*/
@ -197,8 +197,6 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
memset(&velem[0], 0, sizeof(velem[0]) * 2);
for (i = 0; i < 2; i++) {
velem[i].src_offset = i * 4 * sizeof(float);
velem[i].instance_divisor = 0;
velem[i].vertex_buffer_index = 0;
velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
}
ctx->velem_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]);
@ -288,26 +286,33 @@ static void blitter_restore_CSOs(struct blitter_context_priv *ctx)
unsigned i;
/* restore the state objects which are always required to be saved */
pipe->bind_blend_state(pipe, ctx->base.saved_blend_state);
pipe->bind_depth_stencil_alpha_state(pipe, ctx->base.saved_dsa_state);
pipe->bind_rasterizer_state(pipe, ctx->base.saved_rs_state);
pipe->bind_fs_state(pipe, ctx->base.saved_fs);
pipe->bind_vs_state(pipe, ctx->base.saved_vs);
pipe->bind_vertex_elements_state(pipe, ctx->base.saved_velem_state);
ctx->base.saved_blend_state = INVALID_PTR;
ctx->base.saved_dsa_state = INVALID_PTR;
ctx->base.saved_rs_state = INVALID_PTR;
ctx->base.saved_fs = INVALID_PTR;
ctx->base.saved_vs = INVALID_PTR;
ctx->base.saved_velem_state = INVALID_PTR;
/* restore the state objects which are required to be saved for clear/copy
*/
if (ctx->base.saved_blend_state != INVALID_PTR) {
pipe->bind_blend_state(pipe, ctx->base.saved_blend_state);
ctx->base.saved_blend_state = INVALID_PTR;
}
if (ctx->base.saved_dsa_state != INVALID_PTR) {
pipe->bind_depth_stencil_alpha_state(pipe, ctx->base.saved_dsa_state);
ctx->base.saved_dsa_state = INVALID_PTR;
}
if (ctx->base.saved_fs != INVALID_PTR) {
pipe->bind_fs_state(pipe, ctx->base.saved_fs);
ctx->base.saved_fs = INVALID_PTR;
}
pipe->set_stencil_ref(pipe, &ctx->base.saved_stencil_ref);
pipe->set_viewport_state(pipe, &ctx->base.saved_viewport);
pipe->set_clip_state(pipe, &ctx->base.saved_clip);
/* restore the state objects which are required to be saved before copy/fill
*/
if (ctx->base.saved_fb_state.nr_cbufs != ~0) {
pipe->set_framebuffer_state(pipe, &ctx->base.saved_fb_state);
util_unreference_framebuffer_state(&ctx->base.saved_fb_state);
@ -724,14 +729,14 @@ boolean is_overlap(unsigned sx1, unsigned sx2, unsigned sy1, unsigned sy2,
return sx1 < dx2 && sx2 > dx1 && sy1 < dy2 && sy2 > dy1;
}
void util_blitter_copy_region(struct blitter_context *blitter,
struct pipe_resource *dst,
unsigned dstlevel,
unsigned dstx, unsigned dsty, unsigned dstz,
struct pipe_resource *src,
unsigned srclevel,
const struct pipe_box *srcbox,
boolean ignore_stencil)
void util_blitter_copy_texture(struct blitter_context *blitter,
struct pipe_resource *dst,
unsigned dstlevel,
unsigned dstx, unsigned dsty, unsigned dstz,
struct pipe_resource *src,
unsigned srclevel,
const struct pipe_box *srcbox,
boolean ignore_stencil)
{
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
struct pipe_context *pipe = ctx->base.pipe;

View file

@ -126,12 +126,15 @@ struct pipe_context *util_blitter_get_pipe(struct blitter_context *blitter)
}
/*
* These CSOs must be saved before any of the following functions is called:
* These states must be saved before any of the following functions is called:
* - blend state
* - depth stencil alpha state
* - rasterizer state
* - vertex shader
* - any other shader??? (XXX)
* - fragment shader
* - vertex buffers
* - vertex elements
*/
/**
@ -169,14 +172,14 @@ void util_blitter_clear_depth_custom(struct blitter_context *blitter,
* - fragment sampler states
* - fragment sampler textures
*/
void util_blitter_copy_region(struct blitter_context *blitter,
struct pipe_resource *dst,
unsigned dstlevel,
unsigned dstx, unsigned dsty, unsigned dstz,
struct pipe_resource *src,
unsigned srclevel,
const struct pipe_box *srcbox,
boolean ignore_stencil);
void util_blitter_copy_texture(struct blitter_context *blitter,
struct pipe_resource *dst,
unsigned dstlevel,
unsigned dstx, unsigned dsty, unsigned dstz,
struct pipe_resource *src,
unsigned srclevel,
const struct pipe_box *srcbox,
boolean ignore_stencil);
/**
* Clear a region of a (color) surface to a constant value.

View file

@ -730,7 +730,7 @@ debug_dump_float_rgba_bmp(const char *filename,
pixel.rgbRed = float_to_ubyte(ptr[x*4 + 0]);
pixel.rgbGreen = float_to_ubyte(ptr[x*4 + 1]);
pixel.rgbBlue = float_to_ubyte(ptr[x*4 + 2]);
pixel.rgbAlpha = 255;
pixel.rgbAlpha = float_to_ubyte(ptr[x*4 + 3]);
os_stream_write(stream, &pixel, 4);
}
}

View file

@ -390,3 +390,53 @@ util_format_translate(enum pipe_format dst_format,
FREE(tmp_row);
}
}
void util_format_compose_swizzles(const unsigned char swz1[4],
const unsigned char swz2[4],
unsigned char dst[4])
{
unsigned i;
for (i = 0; i < 4; i++) {
dst[i] = swz2[i] <= UTIL_FORMAT_SWIZZLE_W ?
swz1[swz2[i]] : swz2[i];
}
}
void util_format_swizzle_4f(float *dst, const float *src,
const unsigned char swz[4])
{
unsigned i;
for (i = 0; i < 4; i++) {
if (swz[i] <= UTIL_FORMAT_SWIZZLE_W)
dst[i] = src[swz[i]];
else if (swz[i] == UTIL_FORMAT_SWIZZLE_0)
dst[i] = 0;
else if (swz[i] == UTIL_FORMAT_SWIZZLE_1)
dst[i] = 1;
}
}
void util_format_unswizzle_4f(float *dst, const float *src,
const unsigned char swz[4])
{
unsigned i;
for (i = 0; i < 4; i++) {
switch (swz[i]) {
case UTIL_FORMAT_SWIZZLE_X:
dst[0] = src[i];
break;
case UTIL_FORMAT_SWIZZLE_Y:
dst[1] = src[i];
break;
case UTIL_FORMAT_SWIZZLE_Z:
dst[2] = src[i];
break;
case UTIL_FORMAT_SWIZZLE_W:
dst[3] = src[i];
break;
}
}
}

View file

@ -260,10 +260,10 @@ PIPE_FORMAT_R10G10B10X2_USCALED , plain, 1, 1, u10 , u10 , u10 , x2 , xyz1, r
# A.k.a. D3DDECLTYPE_DEC3N
PIPE_FORMAT_R10G10B10X2_SNORM , plain, 1, 1, sn10, sn10, sn10 , x2 , xyz1, rgb
PIPE_FORMAT_YV12 , subsampled, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
PIPE_FORMAT_YV16 , subsampled, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
PIPE_FORMAT_IYUV , subsampled, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
PIPE_FORMAT_NV12 , subsampled, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
PIPE_FORMAT_NV21 , subsampled, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
PIPE_FORMAT_IA44 , subsampled, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
PIPE_FORMAT_AI44 , subsampled, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
PIPE_FORMAT_YV12 , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
PIPE_FORMAT_YV16 , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
PIPE_FORMAT_IYUV , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
PIPE_FORMAT_NV12 , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
PIPE_FORMAT_NV21 , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
PIPE_FORMAT_IA44 , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
PIPE_FORMAT_AI44 , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv

Can't render this file because it contains an unexpected character in line 8 and column 3.

View file

@ -815,6 +815,25 @@ util_format_translate(enum pipe_format dst_format,
unsigned src_x, unsigned src_y,
unsigned width, unsigned height);
/*
* Swizzle operations.
*/
/* Compose two sets of swizzles.
* If V is a 4D vector and the function parameters represent functions that
* swizzle vector components, this holds:
* swz2(swz1(V)) = dst(V)
*/
void util_format_compose_swizzles(const unsigned char swz1[4],
const unsigned char swz2[4],
unsigned char dst[4]);
void util_format_swizzle_4f(float *dst, const float *src,
const unsigned char swz[4]);
void util_format_unswizzle_4f(float *dst, const float *src,
const unsigned char swz[4]);
#ifdef __cplusplus
} // extern "C" {
#endif

View file

@ -119,8 +119,15 @@ util_format_s3tc_init(void)
library = util_dl_open(DXTN_LIBNAME);
if (!library) {
debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn "
"compression/decompression unavailable\n");
if (getenv("force_s3tc_enable") &&
!strcmp(getenv("force_s3tc_enable"), "true")) {
debug_printf("couldn't open " DXTN_LIBNAME ", enabling DXTn due to "
"force_s3tc_enable=true environment variable\n");
util_format_s3tc_enabled = TRUE;
} else {
debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn "
"compression/decompression unavailable\n");
}
return;
}

View file

@ -199,6 +199,16 @@ roundf(float x)
#endif /* _MSC_VER */
#ifdef PIPE_OS_ANDROID
static INLINE
double log2(double d)
{
return log(d) * (1.0 / M_LN2);
}
#endif
@ -409,7 +419,7 @@ unsigned ffs( unsigned u )
return i;
}
#elif defined(__MINGW32__)
#elif defined(__MINGW32__) || defined(PIPE_OS_ANDROID)
#define ffs __builtin_ffs
#endif

View file

@ -52,6 +52,7 @@
#include "tgsi/tgsi_transform.h"
#include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_scan.h"
/** Approx number of new tokens for instructions in pstip_transform_inst() */
#define NUM_NEW_TOKENS 50
@ -175,6 +176,7 @@ util_pstipple_create_sampler(struct pipe_context *pipe)
*/
struct pstip_transform_context {
struct tgsi_transform_context base;
struct tgsi_shader_info info;
uint tempsUsed; /**< bitmask */
int wincoordInput;
int maxInput;
@ -183,12 +185,13 @@ struct pstip_transform_context {
int texTemp; /**< temp registers */
int numImmed;
boolean firstInstruction;
uint coordOrigin;
};
/**
* TGSI declaration transform callback.
* Look for a free sampler, a free input attrib, and two free temp regs.
* Track samplers used, temps used, inputs used.
*/
static void
pstip_transform_decl(struct tgsi_transform_context *ctx,
@ -197,10 +200,11 @@ pstip_transform_decl(struct tgsi_transform_context *ctx,
struct pstip_transform_context *pctx =
(struct pstip_transform_context *) ctx;
/* XXX we can use tgsi_shader_info instead of some of this */
if (decl->Declaration.File == TGSI_FILE_SAMPLER) {
uint i;
for (i = decl->Range.First;
i <= decl->Range.Last; i++) {
for (i = decl->Range.First; i <= decl->Range.Last; i++) {
pctx->samplersUsed |= 1 << i;
}
}
@ -211,8 +215,7 @@ pstip_transform_decl(struct tgsi_transform_context *ctx,
}
else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) {
uint i;
for (i = decl->Range.First;
i <= decl->Range.Last; i++) {
for (i = decl->Range.First; i <= decl->Range.Last; i++) {
pctx->tempsUsed |= (1 << i);
}
}
@ -243,8 +246,16 @@ free_bit(uint bitfield)
/**
* TGSI instruction transform callback.
* Replace writes to result.color w/ a temp reg.
* Upon END instruction, insert texture sampling code for antialiasing.
* Before the first instruction, insert our new code to sample the
* stipple texture (using the fragment coord register) then kill the
* fragment if the stipple texture bit is off.
*
* Insert:
* declare new registers
* MUL texTemp, INPUT[wincoord], 1/32;
* TEX texTemp, texTemp, sampler;
* KIL -texTemp; # if -texTemp < 0, KILL fragment
* [...original code...]
*/
static void
pstip_transform_inst(struct tgsi_transform_context *ctx,
@ -261,7 +272,7 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
uint i;
int wincoordInput;
/* find free sampler */
/* find free texture sampler */
pctx->freeSampler = free_bit(pctx->samplersUsed);
if (pctx->freeSampler >= PIPE_MAX_SAMPLERS)
pctx->freeSampler = PIPE_MAX_SAMPLERS - 1;
@ -271,7 +282,7 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
else
wincoordInput = pctx->wincoordInput;
/* find one free temp reg */
/* find one free temp register */
for (i = 0; i < 32; i++) {
if ((pctx->tempsUsed & (1 << i)) == 0) {
/* found a free temp */
@ -397,6 +408,7 @@ util_pstipple_create_fragment_shader(struct pipe_context *pipe,
struct pipe_shader_state *new_fs;
struct pstip_transform_context transform;
const uint newLen = tgsi_num_tokens(fs->tokens) + NUM_NEW_TOKENS;
unsigned i;
new_fs = MALLOC(sizeof(*new_fs));
if (!new_fs)
@ -408,22 +420,33 @@ util_pstipple_create_fragment_shader(struct pipe_context *pipe,
return NULL;
}
/* Setup shader transformation info/context.
*/
memset(&transform, 0, sizeof(transform));
transform.wincoordInput = -1;
transform.maxInput = -1;
transform.texTemp = -1;
transform.firstInstruction = TRUE;
transform.coordOrigin = TGSI_FS_COORD_ORIGIN_UPPER_LEFT;
transform.base.transform_instruction = pstip_transform_inst;
transform.base.transform_declaration = pstip_transform_decl;
transform.base.transform_immediate = pstip_transform_immed;
tgsi_scan_shader(fs->tokens, &transform.info);
/* find fragment coordinate origin property */
for (i = 0; i < transform.info.num_properties; i++) {
if (transform.info.properties[i].name == TGSI_PROPERTY_FS_COORD_ORIGIN)
transform.coordOrigin = transform.info.properties[i].data[0];
}
tgsi_transform_shader(fs->tokens,
(struct tgsi_token *) new_fs->tokens,
newLen, &transform.base);
#if 0 /* DEBUG */
tgsi_dump(fs->tokens, 0);
tgsi_dump(pstip_fs.tokens, 0);
tgsi_dump(new_fs->tokens, 0);
#endif
assert(transform.freeSampler < PIPE_MAX_SAMPLERS);

View file

@ -34,21 +34,6 @@
#include "translate/translate.h"
#include "translate/translate_cache.h"
/* Hardware vertex fetcher limitations can be described by this structure. */
struct u_vbuf_caps {
/* Vertex format CAPs. */
/* TRUE if hardware supports it. */
unsigned format_fixed32:1; /* PIPE_FORMAT_*32*_FIXED */
unsigned format_float16:1; /* PIPE_FORMAT_*16*_FLOAT */
unsigned format_float64:1; /* PIPE_FORMAT_*64*_FLOAT */
unsigned format_norm32:1; /* PIPE_FORMAT_*32*NORM */
unsigned format_scaled32:1; /* PIPE_FORMAT_*32*SCALED */
/* Whether vertex fetches don't have to be dword-aligned. */
/* TRUE if hardware supports it. */
unsigned fetch_dword_unaligned:1;
};
struct u_vbuf_mgr_elements {
unsigned count;
struct pipe_vertex_element ve[PIPE_MAX_ATTRIBS];
@ -69,7 +54,6 @@ struct u_vbuf_mgr_elements {
struct u_vbuf_mgr_priv {
struct u_vbuf_mgr b;
struct u_vbuf_caps caps;
struct pipe_context *pipe;
struct translate_cache *translate_cache;
@ -79,6 +63,8 @@ struct u_vbuf_mgr_priv {
void *saved_ve, *fallback_ve;
boolean ve_binding_lock;
unsigned saved_buffer_offset[PIPE_MAX_ATTRIBS];
boolean any_user_vbs;
boolean incompatible_vb_layout;
};
@ -87,25 +73,25 @@ static void u_vbuf_mgr_init_format_caps(struct u_vbuf_mgr_priv *mgr)
{
struct pipe_screen *screen = mgr->pipe->screen;
mgr->caps.format_fixed32 =
mgr->b.caps.format_fixed32 =
screen->is_format_supported(screen, PIPE_FORMAT_R32_FIXED, PIPE_BUFFER,
0, PIPE_BIND_VERTEX_BUFFER);
mgr->caps.format_float16 =
mgr->b.caps.format_float16 =
screen->is_format_supported(screen, PIPE_FORMAT_R16_FLOAT, PIPE_BUFFER,
0, PIPE_BIND_VERTEX_BUFFER);
mgr->caps.format_float64 =
mgr->b.caps.format_float64 =
screen->is_format_supported(screen, PIPE_FORMAT_R64_FLOAT, PIPE_BUFFER,
0, PIPE_BIND_VERTEX_BUFFER);
mgr->caps.format_norm32 =
mgr->b.caps.format_norm32 =
screen->is_format_supported(screen, PIPE_FORMAT_R32_UNORM, PIPE_BUFFER,
0, PIPE_BIND_VERTEX_BUFFER) &&
screen->is_format_supported(screen, PIPE_FORMAT_R32_SNORM, PIPE_BUFFER,
0, PIPE_BIND_VERTEX_BUFFER);
mgr->caps.format_scaled32 =
mgr->b.caps.format_scaled32 =
screen->is_format_supported(screen, PIPE_FORMAT_R32_USCALED, PIPE_BUFFER,
0, PIPE_BIND_VERTEX_BUFFER) &&
screen->is_format_supported(screen, PIPE_FORMAT_R32_SSCALED, PIPE_BUFFER,
@ -128,7 +114,7 @@ u_vbuf_mgr_create(struct pipe_context *pipe,
upload_buffer_alignment,
upload_buffer_bind);
mgr->caps.fetch_dword_unaligned =
mgr->b.caps.fetch_dword_unaligned =
fetch_alignment == U_VERTEX_FETCH_BYTE_ALIGNED;
u_vbuf_mgr_init_format_caps(mgr);
@ -182,7 +168,7 @@ u_vbuf_translate_begin(struct u_vbuf_mgr_priv *mgr,
/* Check for support. */
if (mgr->ve->ve[i].src_format == mgr->ve->native_format[i] &&
(mgr->caps.fetch_dword_unaligned ||
(mgr->b.caps.fetch_dword_unaligned ||
(vb->buffer_offset % 4 == 0 &&
vb->stride % 4 == 0 &&
mgr->ve->ve[i].src_offset % 4 == 0))) {
@ -363,7 +349,7 @@ u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb,
/* Choose a native format.
* For now we don't care about the alignment, that's going to
* be sorted out later. */
if (!mgr->caps.format_fixed32) {
if (!mgr->b.caps.format_fixed32) {
switch (format) {
FORMAT_REPLACE(R32_FIXED, R32_FLOAT);
FORMAT_REPLACE(R32G32_FIXED, R32G32_FLOAT);
@ -372,7 +358,7 @@ u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb,
default:;
}
}
if (!mgr->caps.format_float16) {
if (!mgr->b.caps.format_float16) {
switch (format) {
FORMAT_REPLACE(R16_FLOAT, R32_FLOAT);
FORMAT_REPLACE(R16G16_FLOAT, R32G32_FLOAT);
@ -381,7 +367,7 @@ u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb,
default:;
}
}
if (!mgr->caps.format_float64) {
if (!mgr->b.caps.format_float64) {
switch (format) {
FORMAT_REPLACE(R64_FLOAT, R32_FLOAT);
FORMAT_REPLACE(R64G64_FLOAT, R32G32_FLOAT);
@ -390,7 +376,7 @@ u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb,
default:;
}
}
if (!mgr->caps.format_norm32) {
if (!mgr->b.caps.format_norm32) {
switch (format) {
FORMAT_REPLACE(R32_UNORM, R32_FLOAT);
FORMAT_REPLACE(R32G32_UNORM, R32G32_FLOAT);
@ -403,7 +389,7 @@ u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb,
default:;
}
}
if (!mgr->caps.format_scaled32) {
if (!mgr->b.caps.format_scaled32) {
switch (format) {
FORMAT_REPLACE(R32_USCALED, R32_FLOAT);
FORMAT_REPLACE(R32G32_USCALED, R32G32_FLOAT);
@ -425,11 +411,11 @@ u_vbuf_mgr_create_vertex_elements(struct u_vbuf_mgr *mgrb,
ve->incompatible_layout =
ve->incompatible_layout ||
ve->ve[i].src_format != ve->native_format[i] ||
(!mgr->caps.fetch_dword_unaligned && ve->ve[i].src_offset % 4 != 0);
(!mgr->b.caps.fetch_dword_unaligned && ve->ve[i].src_offset % 4 != 0);
}
/* Align the formats to the size of DWORD if needed. */
if (!mgr->caps.fetch_dword_unaligned) {
if (!mgr->b.caps.fetch_dword_unaligned) {
for (i = 0; i < count; i++) {
ve->native_format_size[i] = align(ve->native_format_size[i], 4);
}
@ -470,7 +456,7 @@ void u_vbuf_mgr_set_vertex_buffers(struct u_vbuf_mgr *mgrb,
mgr->any_user_vbs = FALSE;
mgr->incompatible_vb_layout = FALSE;
if (!mgr->caps.fetch_dword_unaligned) {
if (!mgr->b.caps.fetch_dword_unaligned) {
/* Check if the strides and offsets are aligned to the size of DWORD. */
for (i = 0; i < count; i++) {
if (bufs[i].buffer) {
@ -488,6 +474,7 @@ void u_vbuf_mgr_set_vertex_buffers(struct u_vbuf_mgr *mgrb,
pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, vb->buffer);
pipe_resource_reference(&mgr->b.real_vertex_buffer[i], NULL);
mgr->saved_buffer_offset[i] = vb->buffer_offset;
if (!vb->buffer) {
continue;
@ -647,6 +634,13 @@ u_vbuf_mgr_draw_begin(struct u_vbuf_mgr *mgrb,
void u_vbuf_mgr_draw_end(struct u_vbuf_mgr *mgrb)
{
struct u_vbuf_mgr_priv *mgr = (struct u_vbuf_mgr_priv*)mgrb;
unsigned i;
/* buffer offsets were modified in u_vbuf_upload_buffers */
if (mgr->any_user_vbs) {
for (i = 0; i < mgr->b.nr_vertex_buffers; i++)
mgr->b.vertex_buffer[i].buffer_offset = mgr->saved_buffer_offset[i];
}
if (mgr->fallback_ve) {
u_vbuf_translate_end(mgr);

View file

@ -37,6 +37,21 @@
#include "pipe/p_state.h"
#include "util/u_transfer.h"
/* Hardware vertex fetcher limitations can be described by this structure. */
struct u_vbuf_caps {
/* Vertex format CAPs. */
/* TRUE if hardware supports it. */
unsigned format_fixed32:1; /* PIPE_FORMAT_*32*_FIXED */
unsigned format_float16:1; /* PIPE_FORMAT_*16*_FLOAT */
unsigned format_float64:1; /* PIPE_FORMAT_*64*_FLOAT */
unsigned format_norm32:1; /* PIPE_FORMAT_*32*NORM */
unsigned format_scaled32:1; /* PIPE_FORMAT_*32*SCALED */
/* Whether vertex fetches don't have to be dword-aligned. */
/* TRUE if hardware supports it. */
unsigned fetch_dword_unaligned:1;
};
/* The manager.
* This structure should also be used to access vertex buffers
* from a driver. */
@ -63,6 +78,8 @@ struct u_vbuf_mgr {
* - u_upload_buffer
* - u_upload_flush */
struct u_upload_mgr *uploader;
struct u_vbuf_caps caps;
};
struct u_vbuf_resource {

View file

@ -231,6 +231,8 @@ init_pipe_state(struct vl_compositor *c)
struct pipe_rasterizer_state rast;
struct pipe_sampler_state sampler;
struct pipe_blend_state blend;
struct pipe_depth_stencil_alpha_state dsa;
unsigned i;
assert(c);
@ -289,6 +291,24 @@ init_pipe_state(struct vl_compositor *c)
c->rast = c->pipe->create_rasterizer_state(c->pipe, &rast);
memset(&dsa, 0, sizeof dsa);
dsa.depth.enabled = 0;
dsa.depth.writemask = 0;
dsa.depth.func = PIPE_FUNC_ALWAYS;
for (i = 0; i < 2; ++i) {
dsa.stencil[i].enabled = 0;
dsa.stencil[i].func = PIPE_FUNC_ALWAYS;
dsa.stencil[i].fail_op = PIPE_STENCIL_OP_KEEP;
dsa.stencil[i].zpass_op = PIPE_STENCIL_OP_KEEP;
dsa.stencil[i].zfail_op = PIPE_STENCIL_OP_KEEP;
dsa.stencil[i].valuemask = 0;
dsa.stencil[i].writemask = 0;
}
dsa.alpha.enabled = 0;
dsa.alpha.func = PIPE_FUNC_ALWAYS;
dsa.alpha.ref_value = 0;
c->dsa = c->pipe->create_depth_stencil_alpha_state(c->pipe, &dsa);
c->pipe->bind_depth_stencil_alpha_state(c->pipe, c->dsa);
return true;
}
@ -296,6 +316,11 @@ static void cleanup_pipe_state(struct vl_compositor *c)
{
assert(c);
/* Asserted in softpipe_delete_fs_state() for some reason */
c->pipe->bind_vs_state(c->pipe, NULL);
c->pipe->bind_fs_state(c->pipe, NULL);
c->pipe->delete_depth_stencil_alpha_state(c->pipe, c->dsa);
c->pipe->delete_sampler_state(c->pipe, c->sampler_linear);
c->pipe->delete_sampler_state(c->pipe, c->sampler_nearest);
c->pipe->delete_blend_state(c->pipe, c->blend);
@ -648,7 +673,6 @@ vl_compositor_set_rgba_layer(struct vl_compositor *c,
void
vl_compositor_render(struct vl_compositor *c,
enum pipe_mpeg12_picture_type picture_type,
struct pipe_surface *dst_surface,
struct pipe_video_rect *dst_area,
struct pipe_video_rect *dst_clip)

View file

@ -68,6 +68,7 @@ struct vl_compositor
void *sampler_nearest;
void *blend;
void *rast;
void *dsa;
void *vertex_elems_state;
void *vs;
@ -155,7 +156,6 @@ vl_compositor_set_rgba_layer(struct vl_compositor *compositor,
*/
void
vl_compositor_render(struct vl_compositor *compositor,
enum pipe_mpeg12_picture_type picture_type,
struct pipe_surface *dst_surface,
struct pipe_video_rect *dst_area,
struct pipe_video_rect *dst_clip);

View file

@ -44,6 +44,19 @@ vl_profile_supported(struct pipe_screen *screen, enum pipe_video_profile profile
}
}
unsigned
vl_num_buffers_desired(struct pipe_screen *screen, enum pipe_video_profile profile)
{
assert(screen);
switch (u_reduce_video_profile(profile)) {
case PIPE_VIDEO_CODEC_MPEG12:
return 4;
default:
return 1;
}
}
struct pipe_video_decoder *
vl_create_decoder(struct pipe_context *pipe,
enum pipe_video_profile profile,

View file

@ -37,6 +37,12 @@
bool
vl_profile_supported(struct pipe_screen *screen, enum pipe_video_profile profile);
/**
* the desired number of buffers for optimal operation
*/
unsigned
vl_num_buffers_desired(struct pipe_screen *screen, enum pipe_video_profile profile);
/**
* standard implementation of pipe->create_video_decoder
*/

View file

@ -143,7 +143,7 @@ static void *
create_mismatch_vert_shader(struct vl_idct *idct)
{
struct ureg_program *shader;
struct ureg_src vrect, vpos;
struct ureg_src vpos;
struct ureg_src scale;
struct ureg_dst t_tex;
struct ureg_dst o_vpos, o_addr[2];
@ -152,7 +152,6 @@ create_mismatch_vert_shader(struct vl_idct *idct)
if (!shader)
return NULL;
vrect = ureg_DECL_vs_input(shader, VS_I_RECT);
vpos = ureg_DECL_vs_input(shader, VS_I_VPOS);
t_tex = ureg_DECL_temporary(shader);

View file

@ -103,16 +103,15 @@ create_ref_vert_shader(struct vl_mc *r)
{
struct ureg_program *shader;
struct ureg_src mv_scale;
struct ureg_src vrect, vmv[2];
struct ureg_src vmv[2];
struct ureg_dst t_vpos;
struct ureg_dst o_vpos, o_vmv[2];
struct ureg_dst o_vmv[2];
unsigned i;
shader = ureg_create(TGSI_PROCESSOR_VERTEX);
if (!shader)
return NULL;
vrect = ureg_DECL_vs_input(shader, VS_I_RECT);
vmv[0] = ureg_DECL_vs_input(shader, VS_I_MV_TOP);
vmv[1] = ureg_DECL_vs_input(shader, VS_I_MV_BOTTOM);
@ -121,7 +120,6 @@ create_ref_vert_shader(struct vl_mc *r)
(float)MACROBLOCK_HEIGHT / r->buffer_height)
);
o_vpos = ureg_DECL_output(shader, TGSI_SEMANTIC_POSITION, VS_O_VPOS);
o_vmv[0] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_VTOP);
o_vmv[1] = ureg_DECL_output(shader, TGSI_SEMANTIC_GENERIC, VS_O_VBOTTOM);

File diff suppressed because it is too large Load diff

View file

@ -33,27 +33,22 @@
struct vl_mpg12_bs
{
unsigned width, height;
struct pipe_video_decoder *decoder;
struct pipe_mpeg12_picture_desc desc;
struct dct_coeff *intra_dct_tbl;
struct vl_vlc vlc;
unsigned *num_ycbcr_blocks;
struct pipe_ycbcr_block *ycbcr_stream[VL_MAX_PLANES];
short *ycbcr_buffer[VL_MAX_PLANES];
struct pipe_motionvector *mv_stream[VL_MAX_REF_FRAMES];
short pred_dc[3];
};
void
vl_mpg12_bs_init(struct vl_mpg12_bs *bs, unsigned width, unsigned height);
vl_mpg12_bs_init(struct vl_mpg12_bs *bs, struct pipe_video_decoder *decoder);
void
vl_mpg12_bs_set_buffers(struct vl_mpg12_bs *bs, struct pipe_ycbcr_block *ycbcr_stream[VL_MAX_PLANES],
short *ycbcr_buffer[VL_MAX_PLANES], struct pipe_motionvector *mv_stream[VL_MAX_REF_FRAMES]);
vl_mpg12_bs_set_picture_desc(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc *picture);
void
vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned num_bytes, const void *buffer,
struct pipe_mpeg12_picture_desc *picture, unsigned num_ycbcr_blocks[3]);
vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned num_bytes, const uint8_t *buffer);
#endif /* vl_mpeg12_bitstream_h */

View file

@ -30,6 +30,7 @@
#include <util/u_memory.h>
#include <util/u_rect.h>
#include <util/u_sampler.h>
#include <util/u_video.h>
#include "vl_mpeg12_decoder.h"
@ -75,36 +76,44 @@ static const struct format_config mc_format_config[] = {
static const unsigned num_mc_format_configs =
sizeof(mc_format_config) / sizeof(struct format_config);
static const unsigned const_empty_block_mask_420[3][2][2] = {
{ { 0x20, 0x10 }, { 0x08, 0x04 } },
{ { 0x02, 0x02 }, { 0x02, 0x02 } },
{ { 0x01, 0x01 }, { 0x01, 0x01 } }
};
static bool
init_zscan_buffer(struct vl_mpeg12_buffer *buffer)
init_zscan_buffer(struct vl_mpeg12_decoder *dec, struct vl_mpeg12_buffer *buffer)
{
enum pipe_format formats[3];
struct pipe_sampler_view **source;
struct pipe_resource *res, res_tmpl;
struct pipe_sampler_view sv_tmpl;
struct pipe_surface **destination;
struct vl_mpeg12_decoder *dec;
unsigned i;
assert(buffer);
assert(dec && buffer);
dec = (struct vl_mpeg12_decoder*)buffer->base.decoder;
memset(&res_tmpl, 0, sizeof(res_tmpl));
res_tmpl.target = PIPE_TEXTURE_2D;
res_tmpl.format = dec->zscan_source_format;
res_tmpl.width0 = dec->blocks_per_line * BLOCK_WIDTH * BLOCK_HEIGHT;
res_tmpl.height0 = align(dec->num_blocks, dec->blocks_per_line) / dec->blocks_per_line;
res_tmpl.depth0 = 1;
res_tmpl.array_size = 1;
res_tmpl.usage = PIPE_USAGE_STREAM;
res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW;
formats[0] = formats[1] = formats[2] = dec->zscan_source_format;
buffer->zscan_source = vl_video_buffer_create_ex
(
dec->base.context,
dec->blocks_per_line * BLOCK_WIDTH * BLOCK_HEIGHT,
align(dec->num_blocks, dec->blocks_per_line) / dec->blocks_per_line,
1, PIPE_VIDEO_CHROMA_FORMAT_444, formats, PIPE_USAGE_STATIC
);
if (!buffer->zscan_source)
res = dec->base.context->screen->resource_create(dec->base.context->screen, &res_tmpl);
if (!res)
goto error_source;
source = buffer->zscan_source->get_sampler_view_planes(buffer->zscan_source);
if (!source)
memset(&sv_tmpl, 0, sizeof(sv_tmpl));
u_sampler_view_default_template(&sv_tmpl, res, res->format);
sv_tmpl.swizzle_r = sv_tmpl.swizzle_g = sv_tmpl.swizzle_b = sv_tmpl.swizzle_a = PIPE_SWIZZLE_RED;
buffer->zscan_source = dec->base.context->create_sampler_view(dec->base.context, res, &sv_tmpl);
pipe_resource_reference(&res, NULL);
if (!buffer->zscan_source)
goto error_sampler;
if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
@ -117,7 +126,7 @@ init_zscan_buffer(struct vl_mpeg12_buffer *buffer)
for (i = 0; i < VL_MAX_PLANES; ++i)
if (!vl_zscan_init_buffer(i == 0 ? &dec->zscan_y : &dec->zscan_c,
&buffer->zscan[i], source[i], destination[i]))
&buffer->zscan[i], buffer->zscan_source, destination[i]))
goto error_plane;
return true;
@ -128,7 +137,7 @@ error_plane:
error_surface:
error_sampler:
buffer->zscan_source->destroy(buffer->zscan_source);
pipe_sampler_view_reference(&buffer->zscan_source, NULL);
error_source:
return false;
@ -143,21 +152,18 @@ cleanup_zscan_buffer(struct vl_mpeg12_buffer *buffer)
for (i = 0; i < VL_MAX_PLANES; ++i)
vl_zscan_cleanup_buffer(&buffer->zscan[i]);
buffer->zscan_source->destroy(buffer->zscan_source);
pipe_sampler_view_reference(&buffer->zscan_source, NULL);
}
static bool
init_idct_buffer(struct vl_mpeg12_buffer *buffer)
init_idct_buffer(struct vl_mpeg12_decoder *dec, struct vl_mpeg12_buffer *buffer)
{
struct pipe_sampler_view **idct_source_sv, **mc_source_sv;
struct vl_mpeg12_decoder *dec;
unsigned i;
assert(buffer);
dec = (struct vl_mpeg12_decoder*)buffer->base.decoder;
assert(dec && buffer);
idct_source_sv = dec->idct_source->get_sampler_view_planes(dec->idct_source);
if (!idct_source_sv)
@ -187,27 +193,18 @@ error_source_sv:
static void
cleanup_idct_buffer(struct vl_mpeg12_buffer *buf)
{
struct vl_mpeg12_decoder *dec;
unsigned i;
assert(buf);
dec = (struct vl_mpeg12_decoder*)buf->base.decoder;
assert(dec);
for (i = 0; i < 3; ++i)
vl_idct_cleanup_buffer(&buf->idct[0]);
}
static bool
init_mc_buffer(struct vl_mpeg12_buffer *buf)
init_mc_buffer(struct vl_mpeg12_decoder *dec, struct vl_mpeg12_buffer *buf)
{
struct vl_mpeg12_decoder *dec;
assert(buf);
dec = (struct vl_mpeg12_decoder*)buf->base.decoder;
assert(dec);
assert(dec && buf);
if(!vl_mc_init_buffer(&dec->mc_y, &buf->mc[0]))
goto error_mc_y;
@ -241,183 +238,148 @@ cleanup_mc_buffer(struct vl_mpeg12_buffer *buf)
vl_mc_cleanup_buffer(&buf->mc[i]);
}
static void
vl_mpeg12_buffer_destroy(struct pipe_video_decode_buffer *buffer)
static INLINE void
MacroBlockTypeToPipeWeights(const struct pipe_mpeg12_macroblock *mb, unsigned weights[2])
{
struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
struct vl_mpeg12_decoder *dec;
assert(mb);
assert(buf);
switch (mb->macroblock_type & (PIPE_MPEG12_MB_TYPE_MOTION_FORWARD | PIPE_MPEG12_MB_TYPE_MOTION_BACKWARD)) {
case PIPE_MPEG12_MB_TYPE_MOTION_FORWARD:
weights[0] = PIPE_VIDEO_MV_WEIGHT_MAX;
weights[1] = PIPE_VIDEO_MV_WEIGHT_MIN;
break;
dec = (struct vl_mpeg12_decoder*)buf->base.decoder;
assert(dec);
case (PIPE_MPEG12_MB_TYPE_MOTION_FORWARD | PIPE_MPEG12_MB_TYPE_MOTION_BACKWARD):
weights[0] = PIPE_VIDEO_MV_WEIGHT_HALF;
weights[1] = PIPE_VIDEO_MV_WEIGHT_HALF;
break;
cleanup_zscan_buffer(buf);
case PIPE_MPEG12_MB_TYPE_MOTION_BACKWARD:
weights[0] = PIPE_VIDEO_MV_WEIGHT_MIN;
weights[1] = PIPE_VIDEO_MV_WEIGHT_MAX;
break;
if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
cleanup_idct_buffer(buf);
cleanup_mc_buffer(buf);
vl_vb_cleanup(&buf->vertex_stream);
FREE(buf);
default:
if (mb->macroblock_type & PIPE_MPEG12_MB_TYPE_PATTERN) {
/* patern without a motion vector, just copy the old frame content */
weights[0] = PIPE_VIDEO_MV_WEIGHT_MAX;
weights[1] = PIPE_VIDEO_MV_WEIGHT_MIN;
} else {
weights[0] = PIPE_VIDEO_MV_WEIGHT_MIN;
weights[1] = PIPE_VIDEO_MV_WEIGHT_MIN;
}
break;
}
}
static void
vl_mpeg12_buffer_begin_frame(struct pipe_video_decode_buffer *buffer)
static INLINE struct vl_motionvector
MotionVectorToPipe(const struct pipe_mpeg12_macroblock *mb, unsigned vector,
unsigned field_select_mask, unsigned weight)
{
struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
struct vl_mpeg12_decoder *dec;
struct vl_motionvector mv;
struct pipe_sampler_view **sampler_views;
unsigned i;
assert(mb);
assert(buf);
if (mb->macroblock_type & (PIPE_MPEG12_MB_TYPE_MOTION_FORWARD | PIPE_MPEG12_MB_TYPE_MOTION_BACKWARD)) {
switch (mb->macroblock_modes.bits.frame_motion_type) {
case PIPE_MPEG12_MO_TYPE_FRAME:
mv.top.x = mb->PMV[0][vector][0];
mv.top.y = mb->PMV[0][vector][1];
mv.top.field_select = PIPE_VIDEO_FRAME;
mv.top.weight = weight;
dec = (struct vl_mpeg12_decoder *)buf->base.decoder;
assert(dec);
mv.bottom.x = mb->PMV[0][vector][0];
mv.bottom.y = mb->PMV[0][vector][1];
mv.bottom.weight = weight;
mv.bottom.field_select = PIPE_VIDEO_FRAME;
break;
vl_vb_map(&buf->vertex_stream, dec->base.context);
case PIPE_MPEG12_MO_TYPE_FIELD:
mv.top.x = mb->PMV[0][vector][0];
mv.top.y = mb->PMV[0][vector][1];
mv.top.field_select = (mb->motion_vertical_field_select & field_select_mask) ?
PIPE_VIDEO_BOTTOM_FIELD : PIPE_VIDEO_TOP_FIELD;
mv.top.weight = weight;
sampler_views = buf->zscan_source->get_sampler_view_planes(buf->zscan_source);
mv.bottom.x = mb->PMV[1][vector][0];
mv.bottom.y = mb->PMV[1][vector][1];
mv.bottom.field_select = (mb->motion_vertical_field_select & (field_select_mask << 2)) ?
PIPE_VIDEO_BOTTOM_FIELD : PIPE_VIDEO_TOP_FIELD;
mv.bottom.weight = weight;
break;
assert(sampler_views);
for (i = 0; i < VL_MAX_PLANES; ++i) {
struct pipe_resource *tex = sampler_views[i]->texture;
struct pipe_box rect =
{
0, 0, 0,
tex->width0,
tex->height0,
1
};
buf->tex_transfer[i] = dec->base.context->get_transfer
(
dec->base.context, tex,
0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
&rect
);
buf->texels[i] = dec->base.context->transfer_map(dec->base.context, buf->tex_transfer[i]);
}
if (dec->base.entrypoint == PIPE_VIDEO_ENTRYPOINT_BITSTREAM) {
struct pipe_ycbcr_block *ycbcr_stream[VL_MAX_PLANES];
struct pipe_motionvector *mv_stream[VL_MAX_REF_FRAMES];
for (i = 0; i < VL_MAX_PLANES; ++i)
ycbcr_stream[i] = vl_vb_get_ycbcr_stream(&buf->vertex_stream, i);
for (i = 0; i < VL_MAX_REF_FRAMES; ++i)
mv_stream[i] = vl_vb_get_mv_stream(&buf->vertex_stream, i);
vl_mpg12_bs_set_buffers(&buf->bs, ycbcr_stream, buf->texels, mv_stream);
default: // TODO: Support DUALPRIME and 16x8
break;
}
} else {
mv.top.x = mv.top.y = 0;
mv.top.field_select = PIPE_VIDEO_FRAME;
mv.top.weight = weight;
for (i = 0; i < VL_MAX_PLANES; ++i)
vl_zscan_set_layout(&buf->zscan[i], dec->zscan_linear);
mv.bottom.x = mv.bottom.y = 0;
mv.bottom.field_select = PIPE_VIDEO_FRAME;
mv.bottom.weight = weight;
}
return mv;
}
static void
vl_mpeg12_buffer_set_quant_matrix(struct pipe_video_decode_buffer *buffer,
const uint8_t intra_matrix[64],
const uint8_t non_intra_matrix[64])
static INLINE void
UploadYcbcrBlocks(struct vl_mpeg12_decoder *dec,
struct vl_mpeg12_buffer *buf,
const struct pipe_mpeg12_macroblock *mb)
{
struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
unsigned i;
unsigned intra;
unsigned tb, x, y, num_blocks = 0;
for (i = 0; i < VL_MAX_PLANES; ++i) {
vl_zscan_upload_quant(&buf->zscan[i], intra_matrix, true);
vl_zscan_upload_quant(&buf->zscan[i], non_intra_matrix, false);
assert(dec && buf);
assert(mb);
if (!mb->coded_block_pattern)
return;
intra = mb->macroblock_type & PIPE_MPEG12_MB_TYPE_INTRA ? 1 : 0;
for (y = 0; y < 2; ++y) {
for (x = 0; x < 2; ++x, ++tb) {
if (mb->coded_block_pattern & const_empty_block_mask_420[0][y][x]) {
struct vl_ycbcr_block *stream = buf->ycbcr_stream[0];
stream->x = mb->x * 2 + x;
stream->y = mb->y * 2 + y;
stream->intra = intra;
stream->coding = mb->macroblock_modes.bits.dct_type;
stream->block_num = buf->block_num++;
buf->num_ycbcr_blocks[0]++;
buf->ycbcr_stream[0]++;
num_blocks++;
}
}
}
}
static struct pipe_ycbcr_block *
vl_mpeg12_buffer_get_ycbcr_stream(struct pipe_video_decode_buffer *buffer, int component)
{
struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
/* TODO: Implement 422, 444 */
//assert(ctx->base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420);
assert(buf);
for (tb = 1; tb < 3; ++tb) {
if (mb->coded_block_pattern & const_empty_block_mask_420[tb][0][0]) {
return vl_vb_get_ycbcr_stream(&buf->vertex_stream, component);
}
struct vl_ycbcr_block *stream = buf->ycbcr_stream[tb];
stream->x = mb->x;
stream->y = mb->y;
stream->intra = intra;
stream->coding = 0;
stream->block_num = buf->block_num++;
static short *
vl_mpeg12_buffer_get_ycbcr_buffer(struct pipe_video_decode_buffer *buffer, int component)
{
struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
buf->num_ycbcr_blocks[tb]++;
buf->ycbcr_stream[tb]++;
assert(buf);
assert(component < VL_MAX_PLANES);
return buf->texels[component];
}
static unsigned
vl_mpeg12_buffer_get_mv_stream_stride(struct pipe_video_decode_buffer *buffer)
{
struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
assert(buf);
return vl_vb_get_mv_stream_stride(&buf->vertex_stream);
}
static struct pipe_motionvector *
vl_mpeg12_buffer_get_mv_stream(struct pipe_video_decode_buffer *buffer, int ref_frame)
{
struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
assert(buf);
return vl_vb_get_mv_stream(&buf->vertex_stream, ref_frame);
}
static void
vl_mpeg12_buffer_decode_bitstream(struct pipe_video_decode_buffer *buffer,
unsigned num_bytes, const void *data,
struct pipe_picture_desc *picture,
unsigned num_ycbcr_blocks[3])
{
struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
struct pipe_mpeg12_picture_desc *pic = (struct pipe_mpeg12_picture_desc *)picture;
struct vl_mpeg12_decoder *dec;
unsigned i;
assert(buf);
dec = (struct vl_mpeg12_decoder *)buf->base.decoder;
assert(dec);
for (i = 0; i < VL_MAX_PLANES; ++i)
vl_zscan_set_layout(&buf->zscan[i], pic->alternate_scan ? dec->zscan_alternate : dec->zscan_normal);
vl_mpg12_bs_decode(&buf->bs, num_bytes, data, pic, num_ycbcr_blocks);
}
static void
vl_mpeg12_buffer_end_frame(struct pipe_video_decode_buffer *buffer)
{
struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer;
struct vl_mpeg12_decoder *dec;
unsigned i;
assert(buf);
dec = (struct vl_mpeg12_decoder *)buf->base.decoder;
assert(dec);
vl_vb_unmap(&buf->vertex_stream, dec->base.context);
for (i = 0; i < VL_MAX_PLANES; ++i) {
dec->base.context->transfer_unmap(dec->base.context, buf->tex_transfer[i]);
dec->base.context->transfer_destroy(dec->base.context, buf->tex_transfer[i]);
num_blocks++;
}
}
memcpy(buf->texels, mb->blocks, 64 * sizeof(short) * num_blocks);
buf->texels += 64 * num_blocks;
}
static void
@ -452,7 +414,6 @@ vl_mpeg12_destroy(struct pipe_video_decoder *decoder)
pipe_resource_reference(&dec->quads.buffer, NULL);
pipe_resource_reference(&dec->pos.buffer, NULL);
pipe_resource_reference(&dec->block_num.buffer, NULL);
pipe_sampler_view_reference(&dec->zscan_linear, NULL);
pipe_sampler_view_reference(&dec->zscan_normal, NULL);
@ -461,7 +422,7 @@ vl_mpeg12_destroy(struct pipe_video_decoder *decoder)
FREE(dec);
}
static struct pipe_video_decode_buffer *
static void *
vl_mpeg12_create_buffer(struct pipe_video_decoder *decoder)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder*)decoder;
@ -473,38 +434,25 @@ vl_mpeg12_create_buffer(struct pipe_video_decoder *decoder)
if (buffer == NULL)
return NULL;
buffer->base.decoder = decoder;
buffer->base.destroy = vl_mpeg12_buffer_destroy;
buffer->base.begin_frame = vl_mpeg12_buffer_begin_frame;
buffer->base.set_quant_matrix = vl_mpeg12_buffer_set_quant_matrix;
buffer->base.get_ycbcr_stream = vl_mpeg12_buffer_get_ycbcr_stream;
buffer->base.get_ycbcr_buffer = vl_mpeg12_buffer_get_ycbcr_buffer;
buffer->base.get_mv_stream_stride = vl_mpeg12_buffer_get_mv_stream_stride;
buffer->base.get_mv_stream = vl_mpeg12_buffer_get_mv_stream;
buffer->base.decode_bitstream = vl_mpeg12_buffer_decode_bitstream;
buffer->base.end_frame = vl_mpeg12_buffer_end_frame;
if (!vl_vb_init(&buffer->vertex_stream, dec->base.context,
dec->base.width / MACROBLOCK_WIDTH,
dec->base.height / MACROBLOCK_HEIGHT))
goto error_vertex_buffer;
if (!init_mc_buffer(buffer))
if (!init_mc_buffer(dec, buffer))
goto error_mc;
if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
if (!init_idct_buffer(buffer))
if (!init_idct_buffer(dec, buffer))
goto error_idct;
if (!init_zscan_buffer(buffer))
if (!init_zscan_buffer(dec, buffer))
goto error_zscan;
if (dec->base.entrypoint == PIPE_VIDEO_ENTRYPOINT_BITSTREAM)
vl_mpg12_bs_init(&buffer->bs,
dec->base.width / MACROBLOCK_WIDTH,
dec->base.height / MACROBLOCK_HEIGHT);
vl_mpg12_bs_init(&buffer->bs, decoder);
return &buffer->base;
return buffer;
error_zscan:
if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
@ -522,76 +470,307 @@ error_vertex_buffer:
}
static void
vl_mpeg12_decoder_flush_buffer(struct pipe_video_decode_buffer *buffer,
unsigned num_ycbcr_blocks[3],
struct pipe_video_buffer *refs[2],
struct pipe_video_buffer *dst)
vl_mpeg12_destroy_buffer(struct pipe_video_decoder *decoder, void *buffer)
{
struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer *)buffer;
struct vl_mpeg12_decoder *dec;
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder*)decoder;
struct vl_mpeg12_buffer *buf = buffer;
struct pipe_sampler_view **sv[VL_MAX_REF_FRAMES], **mc_source_sv;
assert(dec && buf);
cleanup_zscan_buffer(buf);
if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
cleanup_idct_buffer(buf);
cleanup_mc_buffer(buf);
vl_vb_cleanup(&buf->vertex_stream);
FREE(buf);
}
static void
vl_mpeg12_set_decode_buffer(struct pipe_video_decoder *decoder, void *buffer)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
assert(dec && buffer);
dec->current_buffer = buffer;
}
static void
vl_mpeg12_set_picture_parameters(struct pipe_video_decoder *decoder,
struct pipe_picture_desc *picture)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
struct pipe_mpeg12_picture_desc *pic = (struct pipe_mpeg12_picture_desc *)picture;
assert(dec && pic);
dec->picture_desc = *pic;
}
static void
vl_mpeg12_set_quant_matrix(struct pipe_video_decoder *decoder,
const struct pipe_quant_matrix *matrix)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
const struct pipe_mpeg12_quant_matrix *m = (const struct pipe_mpeg12_quant_matrix *)matrix;
assert(dec);
assert(matrix->codec == PIPE_VIDEO_CODEC_MPEG12);
memcpy(dec->intra_matrix, m->intra_matrix, 64);
memcpy(dec->non_intra_matrix, m->non_intra_matrix, 64);
}
static void
vl_mpeg12_set_decode_target(struct pipe_video_decoder *decoder,
struct pipe_video_buffer *target)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
struct pipe_surface **surfaces;
unsigned i;
assert(dec);
surfaces = target->get_surfaces(target);
for (i = 0; i < VL_MAX_PLANES; ++i)
pipe_surface_reference(&dec->target_surfaces[i], surfaces[i]);
}
static void
vl_mpeg12_set_reference_frames(struct pipe_video_decoder *decoder,
struct pipe_video_buffer **ref_frames,
unsigned num_ref_frames)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
struct pipe_sampler_view **sv;
unsigned i,j;
assert(dec);
assert(num_ref_frames <= VL_MAX_REF_FRAMES);
for (i = 0; i < num_ref_frames; ++i) {
sv = ref_frames[i]->get_sampler_view_planes(ref_frames[i]);
for (j = 0; j < VL_MAX_PLANES; ++j)
pipe_sampler_view_reference(&dec->ref_frames[i][j], sv[j]);
}
for (; i < VL_MAX_REF_FRAMES; ++i)
for (j = 0; j < VL_MAX_PLANES; ++j)
pipe_sampler_view_reference(&dec->ref_frames[i][j], NULL);
}
static void
vl_mpeg12_begin_frame(struct pipe_video_decoder *decoder)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
struct vl_mpeg12_buffer *buf;
struct pipe_resource *tex;
struct pipe_box rect = { 0, 0, 0, 1, 1, 1 };
unsigned i;
assert(dec);
buf = dec->current_buffer;
assert(buf);
if (dec->base.entrypoint == PIPE_VIDEO_ENTRYPOINT_BITSTREAM)
dec->intra_matrix[0] = 1 << (7 - dec->picture_desc.intra_dc_precision);
for (i = 0; i < VL_MAX_PLANES; ++i) {
vl_zscan_upload_quant(&buf->zscan[i], dec->intra_matrix, true);
vl_zscan_upload_quant(&buf->zscan[i], dec->non_intra_matrix, false);
}
vl_vb_map(&buf->vertex_stream, dec->base.context);
tex = buf->zscan_source->texture;
rect.width = tex->width0;
rect.height = tex->height0;
buf->tex_transfer = dec->base.context->get_transfer
(
dec->base.context, tex,
0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
&rect
);
buf->block_num = 0;
buf->texels = dec->base.context->transfer_map(dec->base.context, buf->tex_transfer);
for (i = 0; i < VL_MAX_PLANES; ++i) {
buf->ycbcr_stream[i] = vl_vb_get_ycbcr_stream(&buf->vertex_stream, i);
buf->num_ycbcr_blocks[i] = 0;
}
for (i = 0; i < VL_MAX_REF_FRAMES; ++i)
buf->mv_stream[i] = vl_vb_get_mv_stream(&buf->vertex_stream, i);
if (dec->base.entrypoint == PIPE_VIDEO_ENTRYPOINT_BITSTREAM) {
vl_mpg12_bs_set_picture_desc(&buf->bs, &dec->picture_desc);
} else {
for (i = 0; i < VL_MAX_PLANES; ++i)
vl_zscan_set_layout(&buf->zscan[i], dec->zscan_linear);
}
}
static void
vl_mpeg12_decode_macroblock(struct pipe_video_decoder *decoder,
const struct pipe_macroblock *macroblocks,
unsigned num_macroblocks)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
const struct pipe_mpeg12_macroblock *mb = (const struct pipe_mpeg12_macroblock *)macroblocks;
struct vl_mpeg12_buffer *buf;
unsigned i, j, mv_weights[2];
assert(dec && dec->current_buffer);
assert(macroblocks && macroblocks->codec == PIPE_VIDEO_CODEC_MPEG12);
buf = dec->current_buffer;
assert(buf);
for (; num_macroblocks > 0; --num_macroblocks) {
unsigned mb_addr = mb->y * dec->width_in_macroblocks + mb->x;
if (mb->macroblock_type & (PIPE_MPEG12_MB_TYPE_PATTERN | PIPE_MPEG12_MB_TYPE_INTRA))
UploadYcbcrBlocks(dec, buf, mb);
MacroBlockTypeToPipeWeights(mb, mv_weights);
for (i = 0; i < 2; ++i) {
if (!dec->ref_frames[i][0]) continue;
buf->mv_stream[i][mb_addr] = MotionVectorToPipe
(
mb, i,
i ? PIPE_MPEG12_FS_FIRST_BACKWARD : PIPE_MPEG12_FS_FIRST_FORWARD,
mv_weights[i]
);
}
/* see section 7.6.6 of the spec */
if (mb->num_skipped_macroblocks > 0) {
struct vl_motionvector skipped_mv[2];
if (dec->ref_frames[0][0] && !dec->ref_frames[1][0]) {
skipped_mv[0].top.x = skipped_mv[0].top.y = 0;
skipped_mv[0].top.weight = PIPE_VIDEO_MV_WEIGHT_MAX;
} else {
skipped_mv[0] = buf->mv_stream[0][mb_addr];
skipped_mv[1] = buf->mv_stream[1][mb_addr];
}
skipped_mv[0].top.field_select = PIPE_VIDEO_FRAME;
skipped_mv[1].top.field_select = PIPE_VIDEO_FRAME;
skipped_mv[0].bottom = skipped_mv[0].top;
skipped_mv[1].bottom = skipped_mv[1].top;
++mb_addr;
for (i = 0; i < mb->num_skipped_macroblocks; ++i, ++mb_addr) {
for (j = 0; j < 2; ++j) {
if (!dec->ref_frames[j][0]) continue;
buf->mv_stream[j][mb_addr] = skipped_mv[j];
}
}
}
++mb;
}
}
static void
vl_mpeg12_decode_bitstream(struct pipe_video_decoder *decoder,
unsigned num_bytes, const void *data)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
struct vl_mpeg12_buffer *buf;
unsigned i;
assert(dec && dec->current_buffer);
buf = dec->current_buffer;
assert(buf);
for (i = 0; i < VL_MAX_PLANES; ++i)
vl_zscan_set_layout(&buf->zscan[i], dec->picture_desc.alternate_scan ?
dec->zscan_alternate : dec->zscan_normal);
vl_mpg12_bs_decode(&buf->bs, num_bytes, data);
}
static void
vl_mpeg12_end_frame(struct pipe_video_decoder *decoder)
{
struct vl_mpeg12_decoder *dec = (struct vl_mpeg12_decoder *)decoder;
struct pipe_sampler_view **mc_source_sv;
struct pipe_vertex_buffer vb[3];
struct vl_mpeg12_buffer *buf;
unsigned i, j, component;
unsigned nr_components;
assert(buf);
assert(dec && dec->current_buffer);
dec = (struct vl_mpeg12_decoder *)buf->base.decoder;
assert(dec);
buf = dec->current_buffer;
for (i = 0; i < 2; ++i)
sv[i] = refs[i] ? refs[i]->get_sampler_view_planes(refs[i]) : NULL;
vl_vb_unmap(&buf->vertex_stream, dec->base.context);
dec->base.context->transfer_unmap(dec->base.context, buf->tex_transfer);
dec->base.context->transfer_destroy(dec->base.context, buf->tex_transfer);
vb[0] = dec->quads;
vb[1] = dec->pos;
surfaces = dst->get_surfaces(dst);
dec->base.context->bind_vertex_elements_state(dec->base.context, dec->ves_mv);
for (i = 0; i < VL_MAX_PLANES; ++i) {
if (!surfaces[i]) continue;
if (!dec->target_surfaces[i]) continue;
vl_mc_set_surface(&buf->mc[i], surfaces[i]);
vl_mc_set_surface(&buf->mc[i], dec->target_surfaces[i]);
for (j = 0; j < VL_MAX_REF_FRAMES; ++j) {
if (!sv[j]) continue;
if (!dec->ref_frames[j][i]) continue;
vb[2] = vl_vb_get_mv(&buf->vertex_stream, j);;
dec->base.context->set_vertex_buffers(dec->base.context, 3, vb);
vl_mc_render_ref(&buf->mc[i], sv[j][i]);
vl_mc_render_ref(&buf->mc[i], dec->ref_frames[j][i]);
}
}
vb[2] = dec->block_num;
dec->base.context->bind_vertex_elements_state(dec->base.context, dec->ves_ycbcr);
for (i = 0; i < VL_MAX_PLANES; ++i) {
if (!num_ycbcr_blocks[i]) continue;
if (!buf->num_ycbcr_blocks[i]) continue;
vb[1] = vl_vb_get_ycbcr(&buf->vertex_stream, i);
dec->base.context->set_vertex_buffers(dec->base.context, 3, vb);
dec->base.context->set_vertex_buffers(dec->base.context, 2, vb);
vl_zscan_render(&buf->zscan[i] , num_ycbcr_blocks[i]);
vl_zscan_render(&buf->zscan[i] , buf->num_ycbcr_blocks[i]);
if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
vl_idct_flush(&buf->idct[i], num_ycbcr_blocks[i]);
vl_idct_flush(&buf->idct[i], buf->num_ycbcr_blocks[i]);
}
mc_source_sv = dec->mc_source->get_sampler_view_planes(dec->mc_source);
for (i = 0, component = 0; i < VL_MAX_PLANES; ++i) {
if (!surfaces[i]) continue;
if (!dec->target_surfaces[i]) continue;
nr_components = util_format_get_nr_components(surfaces[i]->texture->format);
nr_components = util_format_get_nr_components(dec->target_surfaces[i]->texture->format);
for (j = 0; j < nr_components; ++j, ++component) {
if (!num_ycbcr_blocks[i]) continue;
if (!buf->num_ycbcr_blocks[i]) continue;
vb[1] = vl_vb_get_ycbcr(&buf->vertex_stream, component);
dec->base.context->set_vertex_buffers(dec->base.context, 3, vb);
dec->base.context->set_vertex_buffers(dec->base.context, 2, vb);
if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
vl_idct_prepare_stage2(&buf->idct[component]);
@ -599,11 +778,19 @@ vl_mpeg12_decoder_flush_buffer(struct pipe_video_decode_buffer *buffer,
dec->base.context->set_fragment_sampler_views(dec->base.context, 1, &mc_source_sv[component]);
dec->base.context->bind_fragment_sampler_states(dec->base.context, 1, &dec->sampler_ycbcr);
}
vl_mc_render_ycbcr(&buf->mc[i], j, num_ycbcr_blocks[component]);
vl_mc_render_ycbcr(&buf->mc[i], j, buf->num_ycbcr_blocks[component]);
}
}
}
static void
vl_mpeg12_flush(struct pipe_video_decoder *decoder)
{
assert(decoder);
//Noop, for shaders it is much faster to flush everything in end_frame
}
static bool
init_pipe_state(struct vl_mpeg12_decoder *dec)
{
@ -870,21 +1057,21 @@ vl_create_mpeg12_decoder(struct pipe_context *context,
dec->base.destroy = vl_mpeg12_destroy;
dec->base.create_buffer = vl_mpeg12_create_buffer;
dec->base.flush_buffer = vl_mpeg12_decoder_flush_buffer;
dec->base.destroy_buffer = vl_mpeg12_destroy_buffer;
dec->base.set_decode_buffer = vl_mpeg12_set_decode_buffer;
dec->base.set_picture_parameters = vl_mpeg12_set_picture_parameters;
dec->base.set_quant_matrix = vl_mpeg12_set_quant_matrix;
dec->base.set_decode_target = vl_mpeg12_set_decode_target;
dec->base.set_reference_frames = vl_mpeg12_set_reference_frames;
dec->base.begin_frame = vl_mpeg12_begin_frame;
dec->base.decode_macroblock = vl_mpeg12_decode_macroblock;
dec->base.decode_bitstream = vl_mpeg12_decode_bitstream;
dec->base.end_frame = vl_mpeg12_end_frame;
dec->base.flush = vl_mpeg12_flush;
dec->blocks_per_line = MAX2(util_next_power_of_two(dec->base.width) / block_size_pixels, 4);
dec->num_blocks = (dec->base.width * dec->base.height) / block_size_pixels;
dec->quads = vl_vb_upload_quads(dec->base.context);
dec->pos = vl_vb_upload_pos(
dec->base.context,
dec->base.width / MACROBLOCK_WIDTH,
dec->base.height / MACROBLOCK_HEIGHT
);
dec->block_num = vl_vb_upload_block_num(dec->base.context, dec->num_blocks);
dec->ves_ycbcr = vl_vb_get_ves_ycbcr(dec->base.context);
dec->ves_mv = vl_vb_get_ves_mv(dec->base.context);
dec->width_in_macroblocks = align(dec->base.width, MACROBLOCK_WIDTH) / MACROBLOCK_WIDTH;
/* TODO: Implement 422, 444 */
assert(dec->base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420);
@ -892,14 +1079,27 @@ vl_create_mpeg12_decoder(struct pipe_context *context,
if (dec->base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
dec->chroma_width = dec->base.width / 2;
dec->chroma_height = dec->base.height / 2;
dec->num_blocks = dec->num_blocks * 2;
} else if (dec->base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422) {
dec->chroma_width = dec->base.width;
dec->chroma_height = dec->base.height / 2;
dec->num_blocks = dec->num_blocks * 2 + dec->num_blocks;
} else {
dec->chroma_width = dec->base.width;
dec->chroma_height = dec->base.height;
dec->num_blocks = dec->num_blocks * 3;
}
dec->quads = vl_vb_upload_quads(dec->base.context);
dec->pos = vl_vb_upload_pos(
dec->base.context,
dec->base.width / MACROBLOCK_WIDTH,
dec->base.height / MACROBLOCK_HEIGHT
);
dec->ves_ycbcr = vl_vb_get_ves_ycbcr(dec->base.context);
dec->ves_mv = vl_vb_get_ves_mv(dec->base.context);
switch (entrypoint) {
case PIPE_VIDEO_ENTRYPOINT_BITSTREAM:
format_config = find_format_config(dec, bitstream_format_config, num_bitstream_format_configs);
@ -946,6 +1146,9 @@ vl_create_mpeg12_decoder(struct pipe_context *context,
if (!init_pipe_state(dec))
goto error_pipe_state;
memset(dec->intra_matrix, 0x10, 64);
memset(dec->non_intra_matrix, 0x10, 64);
return &dec->base;
error_pipe_state:

View file

@ -49,12 +49,12 @@ struct vl_mpeg12_decoder
unsigned blocks_per_line;
unsigned num_blocks;
unsigned width_in_macroblocks;
enum pipe_format zscan_source_format;
struct pipe_vertex_buffer quads;
struct pipe_vertex_buffer pos;
struct pipe_vertex_buffer block_num;
void *ves_ycbcr;
void *ves_mv;
@ -73,23 +73,34 @@ struct vl_mpeg12_decoder
struct vl_mc mc_y, mc_c;
void *dsa;
struct vl_mpeg12_buffer *current_buffer;
struct pipe_mpeg12_picture_desc picture_desc;
uint8_t intra_matrix[64];
uint8_t non_intra_matrix[64];
struct pipe_sampler_view *ref_frames[VL_MAX_REF_FRAMES][VL_MAX_PLANES];
struct pipe_surface *target_surfaces[VL_MAX_PLANES];
};
struct vl_mpeg12_buffer
{
struct pipe_video_decode_buffer base;
struct vl_vertex_buffer vertex_stream;
struct pipe_video_buffer *zscan_source;
unsigned block_num;
unsigned num_ycbcr_blocks[3];
struct pipe_sampler_view *zscan_source;
struct vl_mpg12_bs bs;
struct vl_zscan_buffer zscan[VL_MAX_PLANES];
struct vl_idct_buffer idct[VL_MAX_PLANES];
struct vl_mc_buffer mc[VL_MAX_PLANES];
struct pipe_transfer *tex_transfer[VL_MAX_PLANES];
short *texels[VL_MAX_PLANES];
struct pipe_transfer *tex_transfer;
short *texels;
struct vl_ycbcr_block *ycbcr_stream[VL_MAX_PLANES];
struct vl_motionvector *mv_stream[VL_MAX_REF_FRAMES];
};
/**

View file

@ -125,49 +125,6 @@ vl_vb_upload_pos(struct pipe_context *pipe, unsigned width, unsigned height)
return pos;
}
struct pipe_vertex_buffer
vl_vb_upload_block_num(struct pipe_context *pipe, unsigned num_blocks)
{
struct pipe_vertex_buffer buf;
struct pipe_transfer *buf_transfer;
struct vertex2s *v;
unsigned i;
assert(pipe);
/* create buffer */
buf.stride = sizeof(struct vertex2s);
buf.buffer_offset = 0;
buf.buffer = pipe_buffer_create
(
pipe->screen,
PIPE_BIND_VERTEX_BUFFER,
PIPE_USAGE_STATIC,
sizeof(struct vertex2s) * num_blocks
);
if(!buf.buffer)
return buf;
/* and fill it */
v = pipe_buffer_map
(
pipe,
buf.buffer,
PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD,
&buf_transfer
);
for ( i = 0; i < num_blocks; ++i, ++v) {
v->x = i;
v->y = i;
}
pipe_buffer_unmap(pipe, buf_transfer);
return buf;
}
static struct pipe_vertex_element
vl_vb_get_quad_vertex_element(void)
{
@ -211,12 +168,10 @@ vl_vb_get_ves_ycbcr(struct pipe_context *pipe)
/* Position element */
vertex_elems[VS_I_VPOS].src_format = PIPE_FORMAT_R8G8B8A8_USCALED;
vl_vb_element_helper(&vertex_elems[VS_I_VPOS], 1, 1);
/* block num element */
vertex_elems[VS_I_BLOCK_NUM].src_format = PIPE_FORMAT_R16G16_SSCALED;
vertex_elems[VS_I_BLOCK_NUM].src_format = PIPE_FORMAT_R32_FLOAT;
vl_vb_element_helper(&vertex_elems[VS_I_BLOCK_NUM], 1, 2);
vl_vb_element_helper(&vertex_elems[VS_I_VPOS], 2, 1);
return pipe->create_vertex_elements_state(pipe, 3, vertex_elems);
}
@ -266,7 +221,7 @@ vl_vb_init(struct vl_vertex_buffer *buffer, struct pipe_context *pipe,
pipe->screen,
PIPE_BIND_VERTEX_BUFFER,
PIPE_USAGE_STREAM,
sizeof(struct pipe_ycbcr_block) * size * 4
sizeof(struct vl_ycbcr_block) * size * 4
);
if (!buffer->ycbcr[i].resource)
goto error_ycbcr;
@ -278,7 +233,7 @@ vl_vb_init(struct vl_vertex_buffer *buffer, struct pipe_context *pipe,
pipe->screen,
PIPE_BIND_VERTEX_BUFFER,
PIPE_USAGE_STREAM,
sizeof(struct pipe_motionvector) * size
sizeof(struct vl_motionvector) * size
);
if (!buffer->mv[i].resource)
goto error_mv;
@ -310,7 +265,7 @@ vl_vb_get_ycbcr(struct vl_vertex_buffer *buffer, int component)
assert(buffer);
buf.stride = sizeof(struct pipe_ycbcr_block);
buf.stride = sizeof(struct vl_ycbcr_block);
buf.buffer_offset = 0;
buf.buffer = buffer->ycbcr[component].resource;
@ -324,7 +279,7 @@ vl_vb_get_mv(struct vl_vertex_buffer *buffer, int motionvector)
assert(buffer);
buf.stride = sizeof(struct pipe_motionvector);
buf.stride = sizeof(struct vl_motionvector);
buf.buffer_offset = 0;
buf.buffer = buffer->mv[motionvector].resource;
@ -360,7 +315,7 @@ vl_vb_map(struct vl_vertex_buffer *buffer, struct pipe_context *pipe)
}
struct pipe_ycbcr_block *
struct vl_ycbcr_block *
vl_vb_get_ycbcr_stream(struct vl_vertex_buffer *buffer, int component)
{
assert(buffer);
@ -377,7 +332,7 @@ vl_vb_get_mv_stream_stride(struct vl_vertex_buffer *buffer)
return buffer->width;
}
struct pipe_motionvector *
struct vl_motionvector *
vl_vb_get_mv_stream(struct vl_vertex_buffer *buffer, int ref_frame)
{
assert(buffer);

View file

@ -52,20 +52,56 @@ enum VS_INPUT
NUM_VS_INPUTS = 4
};
enum vl_mv_weight
{
PIPE_VIDEO_MV_WEIGHT_MIN = 0,
PIPE_VIDEO_MV_WEIGHT_HALF = 128,
PIPE_VIDEO_MV_WEIGHT_MAX = 256
};
enum vl_field_select
{
PIPE_VIDEO_FRAME = 0,
PIPE_VIDEO_TOP_FIELD = 1,
PIPE_VIDEO_BOTTOM_FIELD = 3,
/* TODO
PIPE_VIDEO_DUALPRIME
PIPE_VIDEO_16x8
*/
};
struct vl_motionvector
{
struct {
int16_t x, y;
int16_t field_select; /**< enum pipe_video_field_select */
int16_t weight; /**< enum pipe_video_mv_weight */
} top, bottom;
};
struct vl_ycbcr_block
{
uint8_t x, y;
uint8_t intra;
uint8_t coding;
float block_num;
};
struct vl_vertex_buffer
{
unsigned width, height;
struct {
struct pipe_resource *resource;
struct pipe_transfer *transfer;
struct pipe_ycbcr_block *vertex_stream;
struct pipe_resource *resource;
struct pipe_transfer *transfer;
struct vl_ycbcr_block *vertex_stream;
} ycbcr[VL_MAX_PLANES];
struct {
struct pipe_resource *resource;
struct pipe_transfer *transfer;
struct pipe_motionvector *vertex_stream;
struct pipe_resource *resource;
struct pipe_transfer *transfer;
struct vl_motionvector *vertex_stream;
} mv[VL_MAX_REF_FRAMES];
};
@ -73,8 +109,6 @@ struct pipe_vertex_buffer vl_vb_upload_quads(struct pipe_context *pipe);
struct pipe_vertex_buffer vl_vb_upload_pos(struct pipe_context *pipe, unsigned width, unsigned height);
struct pipe_vertex_buffer vl_vb_upload_block_num(struct pipe_context *pipe, unsigned num_blocks);
void *vl_vb_get_ves_ycbcr(struct pipe_context *pipe);
void *vl_vb_get_ves_mv(struct pipe_context *pipe);
@ -89,13 +123,13 @@ void vl_vb_map(struct vl_vertex_buffer *buffer, struct pipe_context *pipe);
struct pipe_vertex_buffer vl_vb_get_ycbcr(struct vl_vertex_buffer *buffer, int component);
struct pipe_ycbcr_block *vl_vb_get_ycbcr_stream(struct vl_vertex_buffer *buffer, int component);
struct vl_ycbcr_block *vl_vb_get_ycbcr_stream(struct vl_vertex_buffer *buffer, int component);
struct pipe_vertex_buffer vl_vb_get_mv(struct vl_vertex_buffer *buffer, int ref_frame);
unsigned vl_vb_get_mv_stream_stride(struct vl_vertex_buffer *buffer);
struct pipe_motionvector *vl_vb_get_mv_stream(struct vl_vertex_buffer *buffer, int ref_frame);
struct vl_motionvector *vl_vb_get_mv_stream(struct vl_vertex_buffer *buffer, int ref_frame);
void vl_vb_unmap(struct vl_vertex_buffer *buffer, struct pipe_context *pipe);

View file

@ -25,116 +25,148 @@
*
**************************************************************************/
/**
* This file is based uppon slice_xvmc.c and vlc.h from the xine project,
* which in turn is based on mpeg2dec. The following is the original copyright:
*
* Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
* See http://libmpeg2.sourceforge.net/ for updates.
*
* mpeg2dec is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* mpeg2dec is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef vl_vlc_h
#define vl_vlc_h
#include "pipe/p_compiler.h"
#include <assert.h>
#include <pipe/p_compiler.h>
#include <util/u_math.h>
#include "util/u_pointer.h"
struct vl_vlc
{
uint32_t buf; /* current 32 bit working set of buffer */
int bits; /* used bits in working set */
const uint8_t *ptr; /* buffer with stream data */
const uint8_t *max; /* ptr+len of buffer */
uint64_t buffer;
unsigned valid_bits;
uint32_t *data;
uint32_t *end;
};
struct vl_vlc_entry
{
int8_t length;
int8_t value;
};
struct vl_vlc_compressed
{
uint16_t bitcode;
struct vl_vlc_entry entry;
};
static INLINE void
vl_vlc_restart(struct vl_vlc *vlc)
vl_vlc_init_table(struct vl_vlc_entry *dst, unsigned dst_size, const struct vl_vlc_compressed *src, unsigned src_size)
{
vlc->buf = (vlc->ptr[0] << 24) | (vlc->ptr[1] << 16) | (vlc->ptr[2] << 8) | vlc->ptr[3];
vlc->bits = -16;
vlc->ptr += 4;
unsigned i, bits = util_logbase2(dst_size);
for (i=0;i<dst_size;++i) {
dst[i].length = 0;
dst[i].value = 0;
}
for(; src_size > 0; --src_size, ++src) {
for(i=0; i<(1 << (bits - src->entry.length)); ++i)
dst[src->bitcode >> (16 - bits) | i] = src->entry;
}
}
static INLINE void
vl_vlc_fillbits(struct vl_vlc *vlc)
{
if (vlc->valid_bits < 32) {
uint32_t value = *vlc->data;
//assert(vlc->data <= vlc->end);
#ifndef PIPE_ARCH_BIG_ENDIAN
value = util_bswap32(value);
#endif
vlc->buffer |= (uint64_t)value << (32 - vlc->valid_bits);
++vlc->data;
vlc->valid_bits += 32;
}
}
static INLINE void
vl_vlc_init(struct vl_vlc *vlc, const uint8_t *data, unsigned len)
{
vlc->ptr = data;
vlc->max = data + len;
vl_vlc_restart(vlc);
assert(vlc);
assert(data && len);
vlc->buffer = 0;
vlc->valid_bits = 0;
/* align the data pointer */
while (pointer_to_uintptr(data) & 3) {
vlc->buffer |= (uint64_t)*data << (56 - vlc->valid_bits);
++data;
--len;
vlc->valid_bits += 8;
}
vlc->data = (uint32_t*)data;
vlc->end = (uint32_t*)(data + len);
vl_vlc_fillbits(vlc);
vl_vlc_fillbits(vlc);
}
static INLINE bool
vl_vlc_getbyte(struct vl_vlc *vlc)
static INLINE unsigned
vl_vlc_bytes_left(struct vl_vlc *vlc)
{
vlc->buf <<= 8;
vlc->buf |= vlc->ptr[0];
vlc->ptr++;
return vlc->ptr < vlc->max;
return ((uint8_t*)vlc->end)-((uint8_t*)vlc->data);
}
#define vl_vlc_getword(vlc, shift) \
do { \
(vlc)->buf |= (((vlc)->ptr[0] << 8) | (vlc)->ptr[1]) << (shift); \
(vlc)->ptr += 2; \
} while (0)
static INLINE unsigned
vl_vlc_peekbits(struct vl_vlc *vlc, unsigned num_bits)
{
//assert(vlc->valid_bits >= num_bits);
/* make sure that there are at least 16 valid bits in bit_buf */
#define vl_vlc_needbits(vlc) \
do { \
if ((vlc)->bits >= 0) { \
vl_vlc_getword(vlc, (vlc)->bits); \
(vlc)->bits -= 16; \
} \
} while (0)
return vlc->buffer >> (64 - num_bits);
}
/* make sure that the full 32 bit of the buffer are valid */
static INLINE void
vl_vlc_need32bits(struct vl_vlc *vlc)
vl_vlc_eatbits(struct vl_vlc *vlc, unsigned num_bits)
{
vl_vlc_needbits(vlc);
if (vlc->bits > -8) {
unsigned n = -vlc->bits;
vlc->buf <<= n;
vlc->buf |= *vlc->ptr << 8;
vlc->bits = -8;
vlc->ptr++;
}
if (vlc->bits > -16) {
unsigned n = -vlc->bits - 8;
vlc->buf <<= n;
vlc->buf |= *vlc->ptr;
vlc->bits = -16;
vlc->ptr++;
}
//assert(vlc->valid_bits > num_bits);
vlc->buffer <<= num_bits;
vlc->valid_bits -= num_bits;
}
/* remove num valid bits from bit_buf */
#define vl_vlc_dumpbits(vlc, num) \
do { \
(vlc)->buf <<= (num); \
(vlc)->bits += (num); \
} while (0)
static INLINE unsigned
vl_vlc_get_uimsbf(struct vl_vlc *vlc, unsigned num_bits)
{
unsigned value;
/* take num bits from the high part of bit_buf and zero extend them */
#define vl_vlc_ubits(vlc, num) (((uint32_t)((vlc)->buf)) >> (32 - (num)))
//assert(vlc->valid_bits >= num_bits);
/* take num bits from the high part of bit_buf and sign extend them */
#define vl_vlc_sbits(vlc, num) (((int32_t)((vlc)->buf)) >> (32 - (num)))
value = vlc->buffer >> (64 - num_bits);
vl_vlc_eatbits(vlc, num_bits);
return value;
}
static INLINE signed
vl_vlc_get_simsbf(struct vl_vlc *vlc, unsigned num_bits)
{
signed value;
//assert(vlc->valid_bits >= num_bits);
value = ((int64_t)vlc->buffer) >> (64 - num_bits);
vl_vlc_eatbits(vlc, num_bits);
return value;
}
static INLINE int8_t
vl_vlc_get_vlclbf(struct vl_vlc *vlc, const struct vl_vlc_entry *tbl, unsigned num_bits)
{
tbl += vl_vlc_peekbits(vlc, num_bits);
vl_vlc_eatbits(vlc, tbl->length);
return tbl->value;
}
#endif /* vl_vlc_h */

View file

@ -329,8 +329,15 @@ textured quad blitter.. The source and destination may be the same resource,
but overlapping blits are not permitted.
``resource_resolve`` resolves a multisampled resource into a non-multisampled
one. Formats and dimensions must match. This function must be present if a driver
one. Their formats must match. This function must be present if a driver
supports multisampling.
The region that is to be resolved is described by ``pipe_resolve_info``, which
provides a source and a destination rectangle.
The source rectangle may be vertically flipped, but otherwise the dimensions
of the rectangles must match, unless PIPE_CAP_SCALED_RESOLVE is supported,
in which case scaling and horizontal flipping are allowed as well.
The result of resolving depth/stencil values may be any function of the values at
the sample points, but returning the value of the centermost sample is preferred.
The interfaces to these calls are likely to change to make it easier
for a driver to batch multiple blits with the same source and

View file

@ -1031,9 +1031,21 @@ XXX so let's discuss it, yeah?
TBD
.. opcode:: TXQ - Texture Size Query
.. opcode:: TXQ - Texture Size Query (as per NV_gpu_program4)
retrieve the dimensions of the texture
depending on the target. For 1D (width), 2D/RECT/CUBE
(width, height), 3D (width, height, depth),
1D array (width, layers), 2D array (width, height, layers)
TBD
.. math::
lod = src0
dst.x = texture_width(unit, lod)
dst.y = texture_height(unit, lod)
dst.z = texture_depth(unit, lod)
.. opcode:: CONT - Continue

View file

@ -64,11 +64,16 @@ static INLINE void i915_flush_heuristically(struct i915_context* i915,
int num_vertex)
{
struct i915_winsys *iws = i915->iws;
i915->vertices_since_last_flush += num_vertex;
if ( i915->vertices_since_last_flush > 4096
|| ( i915->vertices_since_last_flush > 256 &&
!iws->buffer_is_busy(iws, i915->current.cbuf_bo)) )
i915->queued_vertices += num_vertex;
/* fire if we have more than 1/20th of the last frame's vertices */
if (i915->queued_vertices > i915->last_fired_vertices / 20) {
FLUSH_BATCH(NULL);
i915->fired_vertices += i915->queued_vertices;
i915->queued_vertices = 0;
return;
}
}

Some files were not shown because too many files have changed in this diff Show more