mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 09:28:07 +02:00
Merge branch 'master' into gallium-texture-transfer
Conflicts: src/mesa/state_tracker/st_cb_accum.c src/mesa/state_tracker/st_cb_drawpixels.c
This commit is contained in:
commit
59d54334c9
554 changed files with 30054 additions and 30554 deletions
13
Makefile
13
Makefile
|
|
@ -45,10 +45,6 @@ install:
|
|||
done
|
||||
|
||||
|
||||
# DirectFBGL module installation
|
||||
linux-directfb-install:
|
||||
cd src/mesa/drivers/directfb && $(MAKE) install
|
||||
|
||||
.PHONY: default doxygen clean realclean install linux-directfb-install
|
||||
|
||||
# If there's no current configuration file
|
||||
|
|
@ -182,10 +178,11 @@ ultrix-gcc:
|
|||
|
||||
# Rules for making release tarballs
|
||||
|
||||
DIRECTORY = Mesa-7.4
|
||||
LIB_NAME = MesaLib-7.4
|
||||
DEMO_NAME = MesaDemos-7.4
|
||||
GLUT_NAME = MesaGLUT-7.4
|
||||
VERSION=7.5-devel
|
||||
DIRECTORY = Mesa-$(VERSION)
|
||||
LIB_NAME = MesaLib-$(VERSION)
|
||||
DEMO_NAME = MesaDemos-$(VERSION)
|
||||
GLUT_NAME = MesaGLUT-$(VERSION)
|
||||
|
||||
MAIN_FILES = \
|
||||
$(DIRECTORY)/Makefile* \
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ common.AddOptions(opts)
|
|||
opts.Add(ListOption('statetrackers', 'state trackers to build', default_statetrackers,
|
||||
['mesa', 'python']))
|
||||
opts.Add(ListOption('drivers', 'pipe drivers to build', default_drivers,
|
||||
['softpipe', 'failover', 'i915simple', 'i965simple', 'cell', 'trace']))
|
||||
['softpipe', 'failover', 'i915simple', 'i965simple', 'cell', 'trace', 'r300']))
|
||||
opts.Add(ListOption('winsys', 'winsys drivers to build', default_winsys,
|
||||
['xlib', 'intel', 'gdi']))
|
||||
['xlib', 'intel', 'gdi', 'amd']))
|
||||
|
||||
opts.Add(EnumOption('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ if test "x$SRCDIR" != "x$ORIGDIR"; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
MAKEFLAGS=""
|
||||
|
||||
autoreconf -v --install || exit 1
|
||||
|
||||
"$srcdir"/configure "$@"
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ LDFLAGS = @LDFLAGS@
|
|||
EXTRA_LIB_PATH = @EXTRA_LIB_PATH@
|
||||
|
||||
# Assembler
|
||||
ASM_SOURCES = @ASM_SOURCES@
|
||||
ASM_API = @ASM_API@
|
||||
MESA_ASM_SOURCES = @MESA_ASM_SOURCES@
|
||||
GLAPI_ASM_SOURCES = @GLAPI_ASM_SOURCES@
|
||||
|
||||
# Misc tools and flags
|
||||
MAKE = @MAKE@
|
||||
|
|
@ -50,16 +50,32 @@ GLUT_LIB_NAME = @GLUT_LIB_NAME@
|
|||
GLW_LIB_NAME = @GLW_LIB_NAME@
|
||||
OSMESA_LIB_NAME = @OSMESA_LIB_NAME@
|
||||
|
||||
# Globs used to install the lib and all symlinks
|
||||
GL_LIB_GLOB = @GL_LIB_GLOB@
|
||||
GLU_LIB_GLOB = @GLU_LIB_GLOB@
|
||||
GLUT_LIB_GLOB = @GLUT_LIB_GLOB@
|
||||
GLW_LIB_GLOB = @GLW_LIB_GLOB@
|
||||
OSMESA_LIB_GLOB = @OSMESA_LIB_GLOB@
|
||||
|
||||
# Directories to build
|
||||
LIB_DIR = @LIB_DIR@
|
||||
SRC_DIRS = @SRC_DIRS@
|
||||
GLU_DIRS = @GLU_DIRS@
|
||||
DRIVER_DIRS = @DRIVER_DIRS@
|
||||
GALLIUM_DIRS = @GALLIUM_DIRS@
|
||||
GALLIUM_AUXILIARY_DIRS = @GALLIUM_AUXILIARY_DIRS@
|
||||
GALLIUM_DRIVER_DIRS = @GALLIUM_DRIVER_DIRS@
|
||||
GALLIUM_WINSYS_DIRS = @GALLIUM_WINSYS_DIRS@
|
||||
GALLIUM_WINSYS_DRM_DIRS = @GALLIUM_WINSYS_DRM_DIRS@
|
||||
GALLIUM_STATE_TRACKERS_DIRS = @GALLIUM_STATE_TRACKERS_DIRS@
|
||||
GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a)
|
||||
GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVER_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
|
||||
|
||||
# Which subdirs under $(TOP)/progs/ to enter:
|
||||
PROGRAM_DIRS = @PROGRAM_DIRS@
|
||||
|
||||
# Driver specific build vars
|
||||
DRI_DIRS = @DRI_DIRS@
|
||||
DRI_DIRS = @DRI_DIRS@
|
||||
WINDOW_SYSTEM = @WINDOW_SYSTEM@
|
||||
USING_EGL = @USING_EGL@
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ MOTIF_CFLAGS = -I/usr/include/Motif1.2
|
|||
LIB_DIR = lib
|
||||
SRC_DIRS = mesa gallium egl gallium/winsys glu glut/glx glew glw
|
||||
GLU_DIRS = sgi
|
||||
DRIVER_DIRS =
|
||||
DRIVER_DIRS = x11 osmesa
|
||||
# Which subdirs under $(TOP)/progs/ to enter:
|
||||
PROGRAM_DIRS = demos redbook samples glsl xdemos
|
||||
|
||||
|
|
@ -89,11 +89,14 @@ PROGRAM_DIRS = demos redbook samples glsl xdemos
|
|||
EGL_DRIVERS_DIRS = demo
|
||||
|
||||
# Gallium directories and
|
||||
GALLIUM_AUXILIARY_DIRS = draw translate cso_cache pipebuffer tgsi sct rtasm util
|
||||
GALLIUM_DIRS = auxiliary drivers state_trackers
|
||||
GALLIUM_AUXILIARY_DIRS = draw translate cso_cache pipebuffer tgsi sct rtasm util indices
|
||||
GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a)
|
||||
GALLIUM_DRIVER_DIRS = softpipe i915simple i965simple nv04 nv10 nv20 nv30 nv40 nv50 failover trace
|
||||
GALLIUM_DRIVER_DIRS = softpipe i915simple i965simple failover trace
|
||||
GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVER_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
|
||||
GALLIUM_WINSYS_DIRS = xlib egl_xlib
|
||||
GALLIUM_WINSYS_DRM_DIRS =
|
||||
GALLIUM_STATE_TRACKERS_DIRS = glx
|
||||
|
||||
|
||||
# Library dependencies
|
||||
|
|
|
|||
|
|
@ -28,13 +28,16 @@ SDK = /opt/cell/sdk/usr
|
|||
CFLAGS = $(OPT_FLAGS) -Wall -Winline -Wmissing-prototypes \
|
||||
-fPIC -m32 -std=c99 -mabi=altivec -maltivec \
|
||||
-I. -I$(SDK)/include \
|
||||
-DGALLIUM_CELL -DUSE_XSHM -D_BSD_SOURCE
|
||||
-DGALLIUM_CELL -DUSE_XSHM -D_BSD_SOURCE -D_SVID_SOURCE
|
||||
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
|
||||
# Omitting glw here:
|
||||
SRC_DIRS = gallium mesa gallium/winsys glu glut/glx glew
|
||||
|
||||
# Build no traditional Mesa drivers:
|
||||
DRIVER_DIRS =
|
||||
|
||||
|
||||
MKDEP_OPTIONS = -fdepend -Y
|
||||
|
||||
|
|
|
|||
|
|
@ -57,16 +57,11 @@ PROGRAM_DIRS := egl $(PROGRAM_DIRS)
|
|||
# EGL directories
|
||||
EGL_DRIVERS_DIRS = demo glx
|
||||
|
||||
DRIVER_DIRS =
|
||||
DRIVER_DIRS = dri
|
||||
WINDOW_SYSTEM = dri
|
||||
GALLIUM_WINSYS_DIRS = drm
|
||||
GALLIUM_WINSYS_DIRS = drm
|
||||
GALLIUM_WINSYS_DRM_DIRS = intel
|
||||
GALLIUM_STATE_TRACKERS_DIRS = egl
|
||||
|
||||
# gamma are missing because they have not been converted to use the new
|
||||
# interface.
|
||||
|
||||
# XXX: need to figure out a way for gallium and non-gallium builds to
|
||||
# coexist:
|
||||
#
|
||||
|
||||
#DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
|
||||
# savage sis tdfx trident unichrome ffb
|
||||
DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
|
||||
savage sis tdfx trident unichrome ffb
|
||||
|
|
|
|||
181
configure.ac
181
configure.ac
|
|
@ -46,10 +46,14 @@ esac
|
|||
MKDEP_OPTIONS=-fdepend
|
||||
dnl Ask gcc where it's keeping its secret headers
|
||||
if test "x$GCC" = xyes; then
|
||||
GCC_INCLUDES=`$CC -print-file-name=include`
|
||||
if test "x$GCC_INCLUDES" != x; then
|
||||
MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
|
||||
fi
|
||||
for dir in include include-fixed; do
|
||||
GCC_INCLUDES=`$CC -print-file-name=$dir`
|
||||
if test "x$GCC_INCLUDES" != x && \
|
||||
test "$GCC_INCLUDES" != "$dir" && \
|
||||
test -d "$GCC_INCLUDES"; then
|
||||
MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
AC_SUBST([MKDEP_OPTIONS])
|
||||
|
||||
|
|
@ -221,24 +225,40 @@ dnl
|
|||
dnl library names
|
||||
dnl
|
||||
if test "$enable_static" = yes; then
|
||||
GL_LIB_NAME='lib$(GL_LIB).a'
|
||||
GLU_LIB_NAME='lib$(GLU_LIB).a'
|
||||
GLUT_LIB_NAME='lib$(GLUT_LIB).a'
|
||||
GLW_LIB_NAME='lib$(GLW_LIB).a'
|
||||
OSMESA_LIB_NAME='lib$(OSMESA_LIB).a'
|
||||
LIB_EXTENSION='a'
|
||||
else
|
||||
GL_LIB_NAME='lib$(GL_LIB).so'
|
||||
GLU_LIB_NAME='lib$(GLU_LIB).so'
|
||||
GLUT_LIB_NAME='lib$(GLUT_LIB).so'
|
||||
GLW_LIB_NAME='lib$(GLW_LIB).so'
|
||||
OSMESA_LIB_NAME='lib$(OSMESA_LIB).so'
|
||||
case "$host_os" in
|
||||
darwin* )
|
||||
LIB_EXTENSION='dylib' ;;
|
||||
* )
|
||||
LIB_EXTENSION='so' ;;
|
||||
esac
|
||||
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}
|
||||
|
||||
GL_LIB_GLOB='lib$(GL_LIB).*'${LIB_EXTENSION}'*'
|
||||
GLU_LIB_GLOB='lib$(GLU_LIB).*'${LIB_EXTENSION}'*'
|
||||
GLUT_LIB_GLOB='lib$(GLUT_LIB).*'${LIB_EXTENSION}'*'
|
||||
GLW_LIB_GLOB='lib$(GLW_LIB).*'${LIB_EXTENSION}'*'
|
||||
OSMESA_LIB_GLOB='lib$(OSMESA_LIB).*'${LIB_EXTENSION}'*'
|
||||
|
||||
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([GL_LIB_GLOB])
|
||||
AC_SUBST([GLU_LIB_GLOB])
|
||||
AC_SUBST([GLUT_LIB_GLOB])
|
||||
AC_SUBST([GLW_LIB_GLOB])
|
||||
AC_SUBST([OSMESA_LIB_GLOB])
|
||||
|
||||
dnl
|
||||
dnl Arch/platform-specific settings
|
||||
dnl
|
||||
|
|
@ -250,8 +270,8 @@ AC_ARG_ENABLE([asm],
|
|||
)
|
||||
asm_arch=""
|
||||
ASM_FLAGS=""
|
||||
ASM_SOURCES=""
|
||||
ASM_API=""
|
||||
MESA_ASM_SOURCES=""
|
||||
GLAPI_ASM_SOURCES=""
|
||||
AC_MSG_CHECKING([whether to enable assembly])
|
||||
test "x$enable_asm" = xno && AC_MSG_RESULT([no])
|
||||
# disable if cross compiling on x86/x86_64 since we must run gen_matypes
|
||||
|
|
@ -292,19 +312,19 @@ if test "x$enable_asm" = xyes; then
|
|||
case "$asm_arch" in
|
||||
x86)
|
||||
ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
|
||||
ASM_SOURCES='$(X86_SOURCES)'
|
||||
ASM_API='$(X86_API)'
|
||||
MESA_ASM_SOURCES='$(X86_SOURCES)'
|
||||
GLAPI_ASM_SOURCES='$(X86_API)'
|
||||
AC_MSG_RESULT([yes, x86])
|
||||
;;
|
||||
x86_64)
|
||||
ASM_FLAGS="-DUSE_X86_64_ASM"
|
||||
ASM_SOURCES='$(X86-64_SOURCES)'
|
||||
ASM_API='$(X86-64_API)'
|
||||
MESA_ASM_SOURCES='$(X86-64_SOURCES)'
|
||||
GLAPI_ASM_SOURCES='$(X86-64_API)'
|
||||
AC_MSG_RESULT([yes, x86_64])
|
||||
;;
|
||||
ppc)
|
||||
ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
|
||||
ASM_SOURCES='$(PPC_SOURCES)'
|
||||
MESA_ASM_SOURCES='$(PPC_SOURCES)'
|
||||
AC_MSG_RESULT([yes, ppc])
|
||||
;;
|
||||
*)
|
||||
|
|
@ -313,8 +333,8 @@ if test "x$enable_asm" = xyes; then
|
|||
esac
|
||||
fi
|
||||
AC_SUBST([ASM_FLAGS])
|
||||
AC_SUBST([ASM_SOURCES])
|
||||
AC_SUBST([ASM_API])
|
||||
AC_SUBST([MESA_ASM_SOURCES])
|
||||
AC_SUBST([GLAPI_ASM_SOURCES])
|
||||
|
||||
dnl PIC code macro
|
||||
MESA_PIC_FLAGS
|
||||
|
|
@ -389,9 +409,16 @@ esac
|
|||
dnl
|
||||
dnl Driver specific build directories
|
||||
dnl
|
||||
SRC_DIRS="mesa"
|
||||
SRC_DIRS="mesa egl glew"
|
||||
GLU_DIRS="sgi"
|
||||
WINDOW_SYSTEM=""
|
||||
GALLIUM_DIRS="auxiliary drivers state_trackers"
|
||||
GALLIUM_WINSYS_DIRS=""
|
||||
GALLIUM_WINSYS_DRM_DIRS=""
|
||||
GALLIUM_AUXILIARY_DIRS="draw translate cso_cache pipebuffer tgsi sct rtasm util"
|
||||
GALLIUM_DRIVER_DIRS="softpipe failover trace"
|
||||
GALLIUM_STATE_TRACKERS_DIRS=""
|
||||
|
||||
case "$mesa_driver" in
|
||||
xlib)
|
||||
DRIVER_DIRS="x11"
|
||||
|
|
@ -400,6 +427,7 @@ dri)
|
|||
SRC_DIRS="glx/x11 $SRC_DIRS"
|
||||
DRIVER_DIRS="dri"
|
||||
WINDOW_SYSTEM="dri"
|
||||
GALLIUM_WINSYS_DIRS="drm $GALLIUM_WINSYS_DIRS"
|
||||
;;
|
||||
osmesa)
|
||||
DRIVER_DIRS="osmesa"
|
||||
|
|
@ -409,6 +437,12 @@ AC_SUBST([SRC_DIRS])
|
|||
AC_SUBST([GLU_DIRS])
|
||||
AC_SUBST([DRIVER_DIRS])
|
||||
AC_SUBST([WINDOW_SYSTEM])
|
||||
AC_SUBST([GALLIUM_DIRS])
|
||||
AC_SUBST([GALLIUM_WINSYS_DIRS])
|
||||
AC_SUBST([GALLIUM_WINSYS_DRM_DIRS])
|
||||
AC_SUBST([GALLIUM_DRIVER_DIRS])
|
||||
AC_SUBST([GALLIUM_AUXILIARY_DIRS])
|
||||
AC_SUBST([GALLIUM_STATE_TRACKERS_DIRS])
|
||||
|
||||
dnl
|
||||
dnl User supplied program configuration
|
||||
|
|
@ -656,10 +690,10 @@ if test "$mesa_driver" = dri; then
|
|||
case "$host_os" in
|
||||
linux*)
|
||||
DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
|
||||
DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
|
||||
if test "x$driglx_direct" = xyes; then
|
||||
DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
|
||||
fi
|
||||
DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
|
||||
|
||||
case "$host_cpu" in
|
||||
x86_64)
|
||||
|
|
@ -1029,6 +1063,90 @@ fi
|
|||
AC_SUBST([APP_LIB_DEPS])
|
||||
AC_SUBST([PROGRAM_DIRS])
|
||||
|
||||
dnl
|
||||
dnl Gallium configuration
|
||||
dnl
|
||||
AC_ARG_ENABLE([gallium],
|
||||
[AS_HELP_STRING([--disable-gallium],
|
||||
[build gallium @<:@default=enabled@:>@])],
|
||||
[enable_gallium="$enableval"],
|
||||
[enable_gallium=yes])
|
||||
if test "x$enable_gallium" = xyes; then
|
||||
SRC_DIRS="$SRC_DIRS gallium gallium/winsys"
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Gallium state trackers configuration
|
||||
dnl
|
||||
AC_ARG_WITH([state-trackers],
|
||||
[AS_HELP_STRING([--with-state-trackers@<:@=DIRS...@:>@],
|
||||
[comma delimited state_trackers list, e.g.
|
||||
"egl,glx" @<:@default=auto@:>@])],
|
||||
[with_state_trackers="$withval"],
|
||||
[with_state_trackers=yes])
|
||||
|
||||
case "$with_state_trackers" in
|
||||
no)
|
||||
GALLIUM_STATE_TRACKERS_DIRS=""
|
||||
;;
|
||||
yes)
|
||||
# look at what else is built
|
||||
case "$mesa_driver" in
|
||||
dri)
|
||||
GALLIUM_STATE_TRACKERS_DIRS=egl
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# verify the requested state tracker exist
|
||||
state_trackers=`IFS=', '; echo $with_state_trackers`
|
||||
for tracker in $state_trackers; do
|
||||
test -d "$srcdir/src/gallium/state_trackers/$tracker" || \
|
||||
AC_MSG_ERROR([state tracker '$tracker' doesn't exist])
|
||||
done
|
||||
GALLIUM_STATE_TRACKERS_DIRS="$state_trackers"
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl
|
||||
dnl Gallium Intel configuration
|
||||
dnl
|
||||
AC_ARG_ENABLE([gallium-intel],
|
||||
[AS_HELP_STRING([--disable-gallium-intel],
|
||||
[build gallium intel @<:@default=enabled@:>@])],
|
||||
[enable_gallium_intel="$enableval"],
|
||||
[enable_gallium_intel=yes])
|
||||
if test "x$enable_gallium_intel" = xyes; then
|
||||
GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS intel"
|
||||
GALLIUM_DRIVER_DIRS="$GALLIUM_DRIVER_DIRS i915simple i965simple"
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Gallium Radeon configuration
|
||||
dnl
|
||||
AC_ARG_ENABLE([gallium-radeon],
|
||||
[AS_HELP_STRING([--enable-gallium-radeon],
|
||||
[build gallium radeon @<:@default=disabled@:>@])],
|
||||
[enable_gallium_radeon="$enableval"],
|
||||
[enable_gallium_radeon=no])
|
||||
if test "x$enable_gallium_radeon" = xyes; then
|
||||
GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS radeon"
|
||||
GALLIUM_DRIVER_DIRS="$GALLIUM_DRIVER_DIRS r300"
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Gallium Radeon configuration
|
||||
dnl
|
||||
AC_ARG_ENABLE([gallium-nouveau],
|
||||
[AS_HELP_STRING([--enable-gallium-nouveau],
|
||||
[build gallium nouveau @<:@default=disabled@:>@])],
|
||||
[enable_gallium_nouveau="$enableval"],
|
||||
[enable_gallium_nouveau=no])
|
||||
if test "x$enable_gallium_nouveau" = xyes; then
|
||||
GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS nouveau"
|
||||
GALLIUM_DRIVER_DIRS="$GALLIUM_DRIVER_DIRS nv04 nv10 nv20 nv30 nv40 nv50"
|
||||
fi
|
||||
|
||||
|
||||
dnl Restore LDFLAGS and CPPFLAGS
|
||||
LDFLAGS="$_SAVE_LDFLAGS"
|
||||
|
|
@ -1076,6 +1194,19 @@ fi
|
|||
fi
|
||||
echo " Use XCB: $enable_xcb"
|
||||
|
||||
echo ""
|
||||
if echo "$SRC_DIRS" | grep 'gallium' >/dev/null 2>&1; then
|
||||
echo " Gallium: yes"
|
||||
echo " Gallium dirs: $GALLIUM_DIRS"
|
||||
echo " Winsys dirs: $GALLIUM_WINSYS_DIRS"
|
||||
echo " Winsys drm dirs:$GALLIUM_WINSYS_DRM_DIRS"
|
||||
echo " Auxiliary dirs: $GALLIUM_AUXILIARY_DIRS"
|
||||
echo " Driver dirs: $GALLIUM_DRIVER_DIRS"
|
||||
echo " Trackers dirs: $GALLIUM_STATE_TRACKERS_DIRS"
|
||||
else
|
||||
echo " Gallium: no"
|
||||
fi
|
||||
|
||||
dnl Libraries
|
||||
echo ""
|
||||
echo " Shared libs: $enable_shared"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ Installation
|
|||
|
||||
to install OpenGL libraries and
|
||||
|
||||
make linux-directfb-install
|
||||
cd src/mesa/drivers/directfb ; make install
|
||||
|
||||
to install DirectFBGL module in the proper location.
|
||||
Actually, that last command may not be needed. Please provide feedback.
|
||||
|
||||
|
|
|
|||
|
|
@ -30,13 +30,9 @@ The second phase is now underway.
|
|||
<H2>Source Code</H2>
|
||||
|
||||
<p>
|
||||
The latest Cell driver source code is on the <code>gallium-0.2</code> branch
|
||||
of the Mesa git repository.
|
||||
After you've cloned the repository, check out the branch with:
|
||||
The latest Cell driver source code is on the master branch of the Mesa
|
||||
git repository.
|
||||
</p>
|
||||
<pre>
|
||||
git-checkout -b gallium-0.2 origin/gallium-0.2
|
||||
</pre>
|
||||
<p>
|
||||
To build the driver you'll need the IBM Cell SDK (version 2.1 or 3.0).
|
||||
To use the driver you'll need a Cell system, such as a PS3 running Linux,
|
||||
|
|
@ -50,17 +46,19 @@ special changes.
|
|||
|
||||
<p>
|
||||
To compile the code, run <code>make linux-cell</code>.
|
||||
To build in debug mode, run <code>make linux-cell-debug</code>.
|
||||
Or to build in debug mode, run <code>make linux-cell-debug</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To use the library, make sure <code>LD_LIBRARY_PATH</code> points the Mesa/lib/
|
||||
directory that contains <code>libGL.so</code>.
|
||||
</p>
|
||||
To use the library, make sure your current directory is the top of the
|
||||
Mesa tree, then set <code>LD_LIBRARY_PATH</code> like this:
|
||||
<pre>
|
||||
export LD_LIBRARY_PATH=$PWD/lib/gallium:$PWD/lib/
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Verify that the Cell driver is being used by running <code>glxinfo</code>
|
||||
and looking for:
|
||||
Verify that the Cell driver is being used by running
|
||||
<code>progs/xdemos/glxinfo</code> and looking for:
|
||||
<pre>
|
||||
OpenGL renderer string: Gallium 0.2, Cell on Xlib
|
||||
</pre>
|
||||
|
|
|
|||
56
docs/relnotes-7.5.html
Normal file
56
docs/relnotes-7.5.html
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<HTML>
|
||||
|
||||
<TITLE>Mesa Release Notes</TITLE>
|
||||
|
||||
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
|
||||
|
||||
<BODY>
|
||||
|
||||
<body bgcolor="#eeeeee">
|
||||
|
||||
<H1>Mesa 7.5 Release Notes / date TBD</H1>
|
||||
|
||||
<p>
|
||||
Mesa 7.5 is a new development release.
|
||||
</p>
|
||||
<p>
|
||||
Mesa 7.5 implements the OpenGL 2.1 API, but the version reported by
|
||||
glGetString(GL_VERSION) depends on the particular driver being used.
|
||||
Some drivers don't support all the features required in OpenGL 2.1.
|
||||
</p>
|
||||
<p>
|
||||
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
|
||||
for DRI ardware acceleration.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>MD5 checksums</h2>
|
||||
<pre>
|
||||
tbd
|
||||
</pre>
|
||||
|
||||
|
||||
<h2>New features</h2>
|
||||
<ul>
|
||||
<li>GL_ARB_framebuffer_object extension (software drivers, i965 driver)
|
||||
<li>Reworked two-sided stencil support.
|
||||
This allows a driver to support all three variations of two-sided stencil
|
||||
including GL_ATI_separate_stencil, GL_EXT_stencil_two_side and OpenGL 2.0
|
||||
<li>GL_EXT_vertex_array_bgra extension (software drivers, i965 driver)
|
||||
<li>GL_NV_texture_env_combine4 extension (software drivers, i965/i915 drivers)
|
||||
<li>GL_EXT_texture_swizzle extension (software drivers, i965 driver)
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Bug fixes</h2>
|
||||
<ul>
|
||||
</ul>
|
||||
|
||||
<h2>Changes</h2>
|
||||
<ul>
|
||||
<li>Remove support for GL_SGIX_shadow, GL_SGIX_shadow_ambient and
|
||||
GL_SGIX_depth_texture extensions. Superseded by the ARB versions.
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
<p>
|
||||
Mesa uses an even/odd version number scheme like the Linux kernel.
|
||||
Odd numbered versions (such as 6.5) designate new developmental releases.
|
||||
Even numbered versions (such as 6.4) designate stable releases.
|
||||
Odd numbered versions (such as 7.5) designate new developmental releases.
|
||||
Even numbered versions (such as 7.4) designate stable releases.
|
||||
</p>
|
||||
|
||||
|
||||
|
|
@ -20,6 +20,7 @@ The release notes summarize what's new or changed in each Mesa release.
|
|||
</p>
|
||||
|
||||
<UL>
|
||||
<LI><A HREF="relnotes-7.5.html">7.5 release notes</A>
|
||||
<LI><A HREF="relnotes-7.4.html">7.4 release notes</A>
|
||||
<LI><A HREF="relnotes-7.3.html">7.3 release notes</A>
|
||||
<LI><A HREF="relnotes-7.2.html">7.2 release notes</A>
|
||||
|
|
|
|||
|
|
@ -74,23 +74,9 @@ extern "C" {
|
|||
# define __cdecl
|
||||
# define GLUT_DEFINED___CDECL
|
||||
# endif
|
||||
# ifndef _CRTIMP
|
||||
# ifdef _NTSDK
|
||||
/* Definition compatible with NT SDK */
|
||||
# define _CRTIMP
|
||||
# else
|
||||
/* Current definition */
|
||||
# ifdef _DLL
|
||||
# define _CRTIMP __declspec(dllimport)
|
||||
# else
|
||||
# define _CRTIMP
|
||||
# endif
|
||||
# endif
|
||||
# define GLUT_DEFINED__CRTIMP
|
||||
# endif
|
||||
# ifndef GLUT_BUILDING_LIB
|
||||
extern _CRTIMP void __cdecl exit(int);
|
||||
# endif
|
||||
#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/* GLUT callback calling convention for Win32. */
|
||||
# define GLUTCALLBACK __cdecl
|
||||
|
|
@ -122,7 +108,7 @@ extern _CRTIMP void __cdecl exit(int);
|
|||
# define GLUTAPIENTRY
|
||||
# define GLUTAPIENTRYV
|
||||
# define GLUTCALLBACK
|
||||
# define GLUTAPI __attribute__((visibility("default")))
|
||||
# define GLUTAPI extern __attribute__((visibility("default")))
|
||||
|
||||
#else
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
SConscript([
|
||||
'util/SConscript',
|
||||
'demos/SConscript',
|
||||
'redbook/SConscript',
|
||||
'samples/SConscript',
|
||||
'trivial/SConscript',
|
||||
'vp/SConscript',
|
||||
])
|
||||
|
|
|
|||
|
|
@ -5,12 +5,6 @@ include $(TOP)/configs/current
|
|||
|
||||
INCDIR = $(TOP)/include
|
||||
|
||||
OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lglew -lOSMesa -lGLU -lGL $(APP_LIB_DEPS)
|
||||
|
||||
OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lglew -lOSMesa16 -lGLU -lGL $(APP_LIB_DEPS)
|
||||
|
||||
OSMESA32_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lglew -lOSMesa32 -lGLU -lGL $(APP_LIB_DEPS)
|
||||
|
||||
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
|
||||
$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
||||
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ SquareWithHole(float squareSize, float holeRadius)
|
|||
for (i = 0; i <= 360; i += 5) {
|
||||
const float x1 = holeRadius * cos(DEG_TO_RAD(i));
|
||||
const float y1 = holeRadius * sin(DEG_TO_RAD(i));
|
||||
float x2, y2;
|
||||
float x2 = 0.0F, y2 = 0.0F;
|
||||
if (i > 315 || i <= 45) {
|
||||
x2 = squareSize;
|
||||
y2 = squareSize * tan(DEG_TO_RAD(i));
|
||||
|
|
|
|||
|
|
@ -47,7 +47,10 @@ static void Idle( void )
|
|||
}
|
||||
|
||||
/*static int max( int a, int b ) { return a > b ? a : b; }*/
|
||||
|
||||
#ifndef min
|
||||
static int min( int a, int b ) { return a < b ? a : b; }
|
||||
#endif
|
||||
|
||||
static void DrawObject()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -154,11 +154,6 @@ static unsigned long align(unsigned long value, unsigned long a)
|
|||
return (value + a - 1) & ~(a-1);
|
||||
}
|
||||
|
||||
static int MIN2(int a, int b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
static void
|
||||
MeasureDownloadRate(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,9 +47,12 @@ static const char *TexFiles[2] =
|
|||
|
||||
static GLuint Program;
|
||||
|
||||
static GLfloat Xrot = -90.0, Yrot = .0, Zrot = 0.0;
|
||||
static GLfloat Xrot = 0.0, Yrot = .0, Zrot = 0.0;
|
||||
static GLfloat EyeDist = 10;
|
||||
static GLboolean Anim = GL_TRUE;
|
||||
static GLboolean UseArrays = GL_TRUE;
|
||||
|
||||
static GLint VertCoord_attr = -1, TexCoord0_attr = -1, TexCoord1_attr = -1;
|
||||
|
||||
|
||||
/* value[0] = tex unit */
|
||||
|
|
@ -60,32 +63,62 @@ static struct uniform_info Uniforms[] = {
|
|||
};
|
||||
|
||||
|
||||
static const GLfloat Tex0Coords[4][2] = {
|
||||
{ 0.0, 0.0 }, { 2.0, 0.0 }, { 2.0, 2.0 }, { 0.0, 2.0 }
|
||||
};
|
||||
|
||||
static const GLfloat Tex1Coords[4][2] = {
|
||||
{ 0.0, 0.0 }, { 1.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 1.0 }
|
||||
};
|
||||
|
||||
static const GLfloat VertCoords[4][2] = {
|
||||
{ -3.0, -3.0 }, { 3.0, -3.0 }, { 3.0, 3.0 }, { -3.0, 3.0 }
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
DrawPolygon(GLfloat size)
|
||||
DrawPolygonArray(void)
|
||||
{
|
||||
glPushMatrix();
|
||||
glRotatef(90, 1, 0, 0);
|
||||
glNormal3f(0, 0, 1);
|
||||
glBegin(GL_POLYGON);
|
||||
if (VertCoord_attr >= 0) {
|
||||
glVertexAttribPointer_func(VertCoord_attr, 2, GL_FLOAT, GL_FALSE,
|
||||
0, VertCoords);
|
||||
glEnableVertexAttribArray_func(VertCoord_attr);
|
||||
}
|
||||
else {
|
||||
glVertexPointer(2, GL_FLOAT, 0, VertCoords);
|
||||
glEnable(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
glMultiTexCoord2f(GL_TEXTURE0, 0, 0);
|
||||
glMultiTexCoord2f(GL_TEXTURE1, 0, 0);
|
||||
glVertex2f(-size, -size);
|
||||
glVertexAttribPointer_func(TexCoord0_attr, 2, GL_FLOAT, GL_FALSE,
|
||||
0, Tex0Coords);
|
||||
glEnableVertexAttribArray_func(TexCoord0_attr);
|
||||
|
||||
glMultiTexCoord2f(GL_TEXTURE0, 2, 0);
|
||||
glMultiTexCoord2f(GL_TEXTURE1, 1, 0);
|
||||
glVertex2f( size, -size);
|
||||
glVertexAttribPointer_func(TexCoord1_attr, 2, GL_FLOAT, GL_FALSE,
|
||||
0, Tex1Coords);
|
||||
glEnableVertexAttribArray_func(TexCoord1_attr);
|
||||
|
||||
glMultiTexCoord2f(GL_TEXTURE0, 2, 2);
|
||||
glMultiTexCoord2f(GL_TEXTURE1, 1, 1);
|
||||
glVertex2f( size, size);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
}
|
||||
|
||||
glMultiTexCoord2f(GL_TEXTURE0, 0, 2);
|
||||
glMultiTexCoord2f(GL_TEXTURE1, 0, 1);
|
||||
glVertex2f(-size, size);
|
||||
|
||||
static void
|
||||
DrawPolygonVert(void)
|
||||
{
|
||||
GLuint i;
|
||||
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
glVertexAttrib2fv_func(TexCoord0_attr, Tex0Coords[i]);
|
||||
glVertexAttrib2fv_func(TexCoord1_attr, Tex1Coords[i]);
|
||||
|
||||
if (VertCoord_attr >= 0)
|
||||
glVertexAttrib2fv_func(VertCoord_attr, VertCoords[i]);
|
||||
else
|
||||
glVertex2fv(VertCoords[i]);
|
||||
}
|
||||
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -100,7 +133,10 @@ draw(void)
|
|||
glRotatef(Yrot, 0, 1, 0);
|
||||
glRotatef(Xrot, 1, 0, 0);
|
||||
|
||||
DrawPolygon(3.0);
|
||||
if (UseArrays)
|
||||
DrawPolygonArray();
|
||||
else
|
||||
DrawPolygonVert();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
|
|
@ -123,8 +159,11 @@ key(unsigned char k, int x, int y)
|
|||
(void) x;
|
||||
(void) y;
|
||||
switch (k) {
|
||||
case ' ':
|
||||
case 'a':
|
||||
UseArrays = !UseArrays;
|
||||
printf("Arrays: %d\n", UseArrays);
|
||||
break;
|
||||
case ' ':
|
||||
Anim = !Anim;
|
||||
if (Anim)
|
||||
glutIdleFunc(idle);
|
||||
|
|
@ -232,6 +271,13 @@ CreateProgram(const char *vertProgFile, const char *fragProgFile,
|
|||
|
||||
InitUniforms(program, uniforms);
|
||||
|
||||
TexCoord0_attr = glGetAttribLocation_func(program, "TexCoord0");
|
||||
TexCoord1_attr = glGetAttribLocation_func(program, "TexCoord1");
|
||||
VertCoord_attr = glGetAttribLocation_func(program, "VertCoord");
|
||||
printf("TexCoord0_attr = %d\n", TexCoord0_attr);
|
||||
printf("TexCoord1_attr = %d\n", TexCoord1_attr);
|
||||
printf("VertCoord_attr = %d\n", VertCoord_attr);
|
||||
|
||||
return program;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,13 @@
|
|||
// Brian Paul
|
||||
|
||||
|
||||
attribute vec4 TexCoord0, TexCoord1;
|
||||
attribute vec4 VertCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_TexCoord[1] = gl_MultiTexCoord1;
|
||||
gl_Position = ftransform();
|
||||
gl_TexCoord[0] = TexCoord0;
|
||||
gl_TexCoord[1] = TexCoord1;
|
||||
// note: may use gl_Vertex or VertCoord here for testing:
|
||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
}
|
||||
|
|
|
|||
91
progs/redbook/SConscript
Normal file
91
progs/redbook/SConscript
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
Import('*')
|
||||
|
||||
if not env['GLUT']:
|
||||
Return()
|
||||
|
||||
env = env.Clone()
|
||||
|
||||
env.Prepend(CPPPATH = [
|
||||
'../util',
|
||||
])
|
||||
|
||||
env.Prepend(LIBS = [
|
||||
util,
|
||||
'$GLUT_LIB'
|
||||
])
|
||||
|
||||
if env['platform'] == 'windows':
|
||||
env.Append(CPPDEFINES = ['NOMINMAX'])
|
||||
env.Prepend(LIBS = ['winmm'])
|
||||
|
||||
progs = [
|
||||
'aaindex',
|
||||
'aapoly',
|
||||
'aargb',
|
||||
'accanti',
|
||||
'accpersp',
|
||||
'alpha3D',
|
||||
'alpha',
|
||||
'anti',
|
||||
'bezcurve',
|
||||
'bezmesh',
|
||||
'checker',
|
||||
'clip',
|
||||
'colormat',
|
||||
'cube',
|
||||
'depthcue',
|
||||
'dof',
|
||||
'double',
|
||||
'drawf',
|
||||
'feedback',
|
||||
'fog',
|
||||
'fogindex',
|
||||
'font',
|
||||
'hello',
|
||||
'image',
|
||||
'light',
|
||||
'lines',
|
||||
'list',
|
||||
'material',
|
||||
'mipmap',
|
||||
'model',
|
||||
'movelight',
|
||||
'nurbs',
|
||||
'pickdepth',
|
||||
'picksquare',
|
||||
'plane',
|
||||
'planet',
|
||||
'polyoff',
|
||||
'polys',
|
||||
'quadric',
|
||||
'robot',
|
||||
'sccolorlight',
|
||||
'scenebamb',
|
||||
'scene',
|
||||
'sceneflat',
|
||||
'select',
|
||||
'smooth',
|
||||
'stencil',
|
||||
'stroke',
|
||||
'surface',
|
||||
'teaambient',
|
||||
'teapots',
|
||||
'tess',
|
||||
'tesswind',
|
||||
'texbind',
|
||||
'texgen',
|
||||
'texprox',
|
||||
'texsub',
|
||||
'texturesurf',
|
||||
'torus',
|
||||
'trim',
|
||||
'unproject',
|
||||
'varray',
|
||||
'wrap',
|
||||
]
|
||||
|
||||
for prog in progs:
|
||||
env.Program(
|
||||
target = prog,
|
||||
source = prog + '.c',
|
||||
)
|
||||
|
|
@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
|
|||
|
||||
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
||||
|
||||
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
|
||||
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
|
||||
|
||||
PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
|
||||
font line logo nurb olympic overlay point prim quad select \
|
||||
|
|
|
|||
58
progs/samples/SConscript
Normal file
58
progs/samples/SConscript
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
Import('*')
|
||||
|
||||
if not env['GLUT']:
|
||||
Return()
|
||||
|
||||
env = env.Clone()
|
||||
|
||||
env.Prepend(CPPPATH = [
|
||||
'../util',
|
||||
])
|
||||
|
||||
env.Prepend(LIBS = [
|
||||
util,
|
||||
'$GLUT_LIB'
|
||||
])
|
||||
|
||||
if env['platform'] == 'windows':
|
||||
env.Append(CPPDEFINES = ['NOMINMAX'])
|
||||
env.Prepend(LIBS = ['winmm'])
|
||||
|
||||
progs = [
|
||||
'accum',
|
||||
'bitmap1',
|
||||
'bitmap2',
|
||||
'blendeq',
|
||||
'blendxor',
|
||||
'copy',
|
||||
'cursor',
|
||||
'depth',
|
||||
'eval',
|
||||
'fog',
|
||||
'font',
|
||||
'line',
|
||||
'logo',
|
||||
'nurb',
|
||||
#'oglinfo',
|
||||
'olympic',
|
||||
'overlay',
|
||||
'point',
|
||||
'prim',
|
||||
'quad',
|
||||
'rgbtoppm',
|
||||
'select',
|
||||
'shape',
|
||||
'sphere',
|
||||
'star',
|
||||
'stencil',
|
||||
'stretch',
|
||||
'texture',
|
||||
'tri',
|
||||
'wave',
|
||||
]
|
||||
|
||||
for prog in progs:
|
||||
env.Program(
|
||||
target = prog,
|
||||
source = prog + '.c',
|
||||
)
|
||||
|
|
@ -11,10 +11,7 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
|
@ -274,6 +271,8 @@ int main(int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
glewInit();
|
||||
|
||||
/* Make sure blend_logic_op extension is there. */
|
||||
s = (char *) glGetString(GL_EXTENSIONS);
|
||||
version = (char*) glGetString(GL_VERSION);
|
||||
|
|
|
|||
|
|
@ -10,13 +10,8 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#define GL_GLEXT_LEGACY
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
|
@ -176,6 +171,8 @@ int main(int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
glewInit();
|
||||
|
||||
/* Make sure blend_logic_op extension is there. */
|
||||
s = (char *) glGetString(GL_EXTENSIONS);
|
||||
version = (char*) glGetString(GL_VERSION);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ struct object
|
|||
GLuint NumVerts;
|
||||
GLuint VertexOffset;
|
||||
GLuint ColorOffset;
|
||||
GLuint VertexStride;
|
||||
GLuint ColorStride;
|
||||
GLuint NumElements;
|
||||
};
|
||||
|
||||
|
|
@ -46,7 +48,7 @@ static void CheckError(int line)
|
|||
static void DrawObject( const struct object *obj )
|
||||
{
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID);
|
||||
glVertexPointer(3, GL_FLOAT, 0, (void *) obj->VertexOffset);
|
||||
glVertexPointer(3, GL_FLOAT, obj->VertexStride, (void *) obj->VertexOffset);
|
||||
glEnable(GL_VERTEX_ARRAY);
|
||||
|
||||
/* test push/pop attrib */
|
||||
|
|
@ -60,7 +62,7 @@ static void DrawObject( const struct object *obj )
|
|||
glPopClientAttrib();
|
||||
}
|
||||
#endif
|
||||
glColorPointer(3, GL_FLOAT, 0, (void *) obj->ColorOffset);
|
||||
glColorPointer(3, GL_FLOAT, obj->ColorStride, (void *) obj->ColorOffset);
|
||||
glEnable(GL_COLOR_ARRAY);
|
||||
|
||||
if (obj->NumElements > 0) {
|
||||
|
|
@ -241,6 +243,8 @@ static void MakeObject1(struct object *obj)
|
|||
obj->NumVerts = 4;
|
||||
obj->VertexOffset = 0;
|
||||
obj->ColorOffset = 3 * sizeof(GLfloat) * obj->NumVerts;
|
||||
obj->VertexStride = 0;
|
||||
obj->ColorStride = 0;
|
||||
obj->NumElements = 0;
|
||||
|
||||
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
|
||||
|
|
@ -255,24 +259,28 @@ static void MakeObject1(struct object *obj)
|
|||
|
||||
static void MakeObject2(struct object *obj)
|
||||
{
|
||||
GLfloat *v, *c;
|
||||
GLfloat *v;
|
||||
int start = 40; /* bytes, to test non-zero array offsets */
|
||||
|
||||
glGenBuffersARB(1, &obj->BufferID);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB, 1000, NULL, GL_STATIC_DRAW_ARB);
|
||||
v = (GLfloat *) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
|
||||
|
||||
/* Make triangle */
|
||||
v[0] = -1; v[1] = -1; v[2] = 0;
|
||||
v[3] = 1; v[4] = -1; v[5] = 0;
|
||||
v[6] = 0; v[7] = 1; v[8] = 0;
|
||||
c = v + 9;
|
||||
c[0] = 0; c[1] = 1; c[2] = 0;
|
||||
c[3] = 0; c[4] = 1; c[5] = 0;
|
||||
c[6] = 1; c[7] = 1; c[8] = 0;
|
||||
v += start / sizeof(GLfloat);
|
||||
|
||||
/* Make triangle: interleaved colors, then positions */
|
||||
/* R G B X Y Z */
|
||||
v[0] = 0; v[1] = 1; v[2] = 0; v[3] = -1; v[4] = -1; v[5] = 0;
|
||||
v[6] = 0; v[7] = 1; v[8] = 0; v[9] = 1; v[10] = -1; v[11] = 0;
|
||||
v[12] = 1; v[13] = 1; v[14] = 0; v[15] = 0; v[16] = 1; v[17] = 0;
|
||||
|
||||
obj->NumVerts = 3;
|
||||
obj->VertexOffset = 0;
|
||||
obj->ColorOffset = 3 * sizeof(GLfloat) * obj->NumVerts;
|
||||
obj->VertexOffset = start + 3 * sizeof(GLfloat);
|
||||
obj->ColorOffset = start;
|
||||
obj->VertexStride = 6 * sizeof(GLfloat);
|
||||
obj->ColorStride = 6 * sizeof(GLfloat);
|
||||
|
||||
obj->NumElements = 0;
|
||||
|
||||
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
|
||||
|
|
@ -300,6 +308,8 @@ static void MakeObject3(struct object *obj)
|
|||
obj->NumVerts = 4;
|
||||
obj->VertexOffset = 0;
|
||||
obj->ColorOffset = 3 * sizeof(GLfloat) * obj->NumVerts;
|
||||
obj->VertexStride = 0;
|
||||
obj->ColorStride = 0;
|
||||
|
||||
bytes = obj->NumVerts * (3 + 3) * sizeof(GLfloat);
|
||||
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ Key( unsigned char key, int x, int y )
|
|||
static void
|
||||
Init( void )
|
||||
{
|
||||
GLboolean ARB_fbo = glutExtensionSupported("GL_ARB_framebuffer_object");
|
||||
GLint i;
|
||||
|
||||
if (!glutExtensionSupported("GL_EXT_framebuffer_object")) {
|
||||
|
|
@ -133,16 +134,20 @@ Init( void )
|
|||
glGenFramebuffersEXT(1, &MyFB);
|
||||
assert(MyFB);
|
||||
assert(!glIsFramebufferEXT(MyFB));
|
||||
glDeleteFramebuffersEXT(1, &MyFB);
|
||||
assert(!glIsFramebufferEXT(MyFB));
|
||||
if (!ARB_fbo) {
|
||||
glDeleteFramebuffersEXT(1, &MyFB);
|
||||
assert(!glIsFramebufferEXT(MyFB));
|
||||
}
|
||||
/* Note, continue to use MyFB below */
|
||||
|
||||
glGenRenderbuffersEXT(1, &MyRB);
|
||||
assert(MyRB);
|
||||
assert(!glIsRenderbufferEXT(MyRB));
|
||||
glDeleteRenderbuffersEXT(1, &MyRB);
|
||||
assert(!glIsRenderbufferEXT(MyRB));
|
||||
MyRB = 42; /* an arbitrary ID */
|
||||
if (!ARB_fbo) {
|
||||
glDeleteRenderbuffersEXT(1, &MyRB);
|
||||
assert(!glIsRenderbufferEXT(MyRB));
|
||||
MyRB = 42; /* an arbitrary ID */
|
||||
}
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
|
||||
assert(glIsFramebufferEXT(MyFB));
|
||||
|
|
|
|||
|
|
@ -32,11 +32,13 @@ static int TexWidth = 512, TexHeight = 512;
|
|||
|
||||
static GLuint MyFB;
|
||||
static GLuint TexObj;
|
||||
static GLuint DepthRB, StencilRB;
|
||||
static GLuint DepthRB = 0, StencilRB = 0;
|
||||
static GLboolean Anim = GL_FALSE;
|
||||
static GLfloat Rot = 0.0;
|
||||
static GLboolean UsePackedDepthStencil = GL_FALSE;
|
||||
static GLuint TextureLevel = 1; /* which texture level to render to */
|
||||
static GLboolean UsePackedDepthStencilBoth = GL_FALSE;
|
||||
static GLboolean Use_ARB_fbo = GL_FALSE;
|
||||
static GLuint TextureLevel = 0; /* which texture level to render to */
|
||||
static GLenum TexIntFormat = GL_RGB; /* either GL_RGB or GL_RGBA */
|
||||
static GLboolean Cull = GL_FALSE;
|
||||
static GLboolean Wireframe = GL_FALSE;
|
||||
|
|
@ -248,8 +250,7 @@ CleanUp(void)
|
|||
glDeleteRenderbuffersEXT(1, &DepthRB);
|
||||
#endif
|
||||
#if STENCIL
|
||||
if (!UsePackedDepthStencil)
|
||||
glDeleteRenderbuffersEXT(1, &StencilRB);
|
||||
glDeleteRenderbuffersEXT(1, &StencilRB);
|
||||
#endif
|
||||
glDeleteFramebuffersEXT(1, &MyFB);
|
||||
|
||||
|
|
@ -294,140 +295,294 @@ Key(unsigned char key, int x, int y)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
Usage(void)
|
||||
/**
|
||||
* Attach depth and stencil renderbuffer(s) to the given framebuffer object.
|
||||
* \param tryDepthStencil if true, try to use a combined depth+stencil buffer
|
||||
* \param bindDepthStencil if true, and tryDepthStencil is true, bind with
|
||||
* the GL_DEPTH_STENCIL_ATTACHMENT target.
|
||||
* \return GL_TRUE for success, GL_FALSE for failure
|
||||
*/
|
||||
static GLboolean
|
||||
AttachDepthAndStencilBuffers(GLuint fbo,
|
||||
GLsizei width, GLsizei height,
|
||||
GLboolean tryDepthStencil,
|
||||
GLboolean bindDepthStencil,
|
||||
GLuint *depthRbOut, GLuint *stencilRbOut)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" a Toggle animation\n");
|
||||
printf(" s/s Step/rotate\n");
|
||||
printf(" c Toggle back-face culling\n");
|
||||
printf(" w Toggle wireframe mode (front-face only)\n");
|
||||
printf(" Esc Exit\n");
|
||||
GLenum status;
|
||||
|
||||
*depthRbOut = *stencilRbOut = 0;
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
|
||||
|
||||
if (tryDepthStencil) {
|
||||
GLuint rb;
|
||||
|
||||
glGenRenderbuffersEXT(1, &rb);
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
|
||||
GL_DEPTH24_STENCIL8_EXT,
|
||||
width, height);
|
||||
if (glGetError())
|
||||
return GL_FALSE;
|
||||
|
||||
if (bindDepthStencil) {
|
||||
/* attach to both depth and stencil at once */
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
GL_DEPTH_STENCIL_ATTACHMENT,
|
||||
GL_RENDERBUFFER_EXT, rb);
|
||||
if (glGetError())
|
||||
return GL_FALSE;
|
||||
}
|
||||
else {
|
||||
/* attach to depth attachment point */
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
GL_DEPTH_ATTACHMENT_EXT,
|
||||
GL_RENDERBUFFER_EXT, rb);
|
||||
if (glGetError())
|
||||
return GL_FALSE;
|
||||
|
||||
/* and attach to stencil attachment point */
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
GL_STENCIL_ATTACHMENT_EXT,
|
||||
GL_RENDERBUFFER_EXT, rb);
|
||||
if (glGetError())
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||
return GL_FALSE;
|
||||
|
||||
*depthRbOut = *stencilRbOut = rb;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/* just depth renderbuffer */
|
||||
{
|
||||
GLuint rb;
|
||||
|
||||
glGenRenderbuffersEXT(1, &rb);
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
|
||||
GL_DEPTH_COMPONENT,
|
||||
width, height);
|
||||
if (glGetError())
|
||||
return GL_FALSE;
|
||||
|
||||
/* attach to depth attachment point */
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
GL_DEPTH_ATTACHMENT_EXT,
|
||||
GL_RENDERBUFFER_EXT, rb);
|
||||
if (glGetError())
|
||||
return GL_FALSE;
|
||||
|
||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||
return GL_FALSE;
|
||||
|
||||
*depthRbOut = rb;
|
||||
}
|
||||
|
||||
/* just stencil renderbuffer */
|
||||
{
|
||||
GLuint rb;
|
||||
|
||||
glGenRenderbuffersEXT(1, &rb);
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
|
||||
GL_STENCIL_INDEX,
|
||||
width, height);
|
||||
if (glGetError())
|
||||
return GL_FALSE;
|
||||
|
||||
/* attach to depth attachment point */
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
GL_STENCIL_ATTACHMENT_EXT,
|
||||
GL_RENDERBUFFER_EXT, rb);
|
||||
if (glGetError())
|
||||
return GL_FALSE;
|
||||
|
||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||
return GL_FALSE;
|
||||
|
||||
*stencilRbOut = rb;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(int argc, char *argv[])
|
||||
ParseArgs(int argc, char *argv[])
|
||||
{
|
||||
static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 };
|
||||
GLint i;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-ds") == 0) {
|
||||
if (!glutExtensionSupported("GL_EXT_packed_depth_stencil")) {
|
||||
printf("GL_EXT_packed_depth_stencil not found!\n");
|
||||
exit(0);
|
||||
}
|
||||
UsePackedDepthStencil = GL_TRUE;
|
||||
printf("Using GL_EXT_packed_depth_stencil\n");
|
||||
}
|
||||
else if (strcmp(argv[i], "-ds2") == 0) {
|
||||
if (!glutExtensionSupported("GL_EXT_packed_depth_stencil")) {
|
||||
printf("GL_EXT_packed_depth_stencil not found!\n");
|
||||
exit(0);
|
||||
}
|
||||
if (!glutExtensionSupported("GL_ARB_framebuffer_object")) {
|
||||
printf("GL_ARB_framebuffer_object not found!\n");
|
||||
exit(0);
|
||||
}
|
||||
UsePackedDepthStencilBoth = GL_TRUE;
|
||||
printf("Using GL_EXT_packed_depth_stencil and GL_DEPTH_STENCIL attachment point\n");
|
||||
}
|
||||
else if (strcmp(argv[i], "-arb") == 0) {
|
||||
if (!glutExtensionSupported("GL_ARB_framebuffer_object")) {
|
||||
printf("Sorry, GL_ARB_framebuffer object not supported!\n");
|
||||
}
|
||||
else {
|
||||
Use_ARB_fbo = GL_TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("Unknown option: %s\n", argv[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Make FBO to render into given texture.
|
||||
*/
|
||||
static GLuint
|
||||
MakeFBO_RenderTexture(GLuint TexObj)
|
||||
{
|
||||
GLuint fb;
|
||||
GLint sizeFudge = 0;
|
||||
|
||||
glGenFramebuffersEXT(1, &fb);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
|
||||
/* Render color to texture */
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
TexTarget, TexObj, TextureLevel);
|
||||
|
||||
if (Use_ARB_fbo) {
|
||||
/* use a smaller depth buffer to see what happens */
|
||||
sizeFudge = 90;
|
||||
}
|
||||
|
||||
/* Setup depth and stencil buffers */
|
||||
{
|
||||
GLboolean b;
|
||||
b = AttachDepthAndStencilBuffers(fb,
|
||||
TexWidth - sizeFudge,
|
||||
TexHeight - sizeFudge,
|
||||
UsePackedDepthStencil,
|
||||
UsePackedDepthStencilBoth,
|
||||
&DepthRB, &StencilRB);
|
||||
if (!b) {
|
||||
/* try !UsePackedDepthStencil */
|
||||
b = AttachDepthAndStencilBuffers(fb,
|
||||
TexWidth - sizeFudge,
|
||||
TexHeight - sizeFudge,
|
||||
!UsePackedDepthStencil,
|
||||
UsePackedDepthStencilBoth,
|
||||
&DepthRB, &StencilRB);
|
||||
}
|
||||
if (!b) {
|
||||
printf("Unable to create/attach depth and stencil renderbuffers "
|
||||
" to FBO!\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* queries */
|
||||
{
|
||||
GLint bits, w, h;
|
||||
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB);
|
||||
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
|
||||
GL_RENDERBUFFER_WIDTH_EXT, &w);
|
||||
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
|
||||
GL_RENDERBUFFER_HEIGHT_EXT, &h);
|
||||
printf("Color/Texture size: %d x %d\n", TexWidth, TexHeight);
|
||||
printf("Depth buffer size: %d x %d\n", w, h);
|
||||
|
||||
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
|
||||
GL_RENDERBUFFER_DEPTH_SIZE_EXT, &bits);
|
||||
printf("Depth renderbuffer size = %d bits\n", bits);
|
||||
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, StencilRB);
|
||||
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
|
||||
GL_RENDERBUFFER_STENCIL_SIZE_EXT, &bits);
|
||||
printf("Stencil renderbuffer size = %d bits\n", bits);
|
||||
}
|
||||
|
||||
/* bind the regular framebuffer */
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
|
||||
return fb;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
if (!glutExtensionSupported("GL_EXT_framebuffer_object")) {
|
||||
printf("GL_EXT_framebuffer_object not found!\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (argc > 1 && strcmp(argv[1], "-ds") == 0) {
|
||||
if (!glutExtensionSupported("GL_EXT_packed_depth_stencil")) {
|
||||
printf("GL_EXT_packed_depth_stencil not found!\n");
|
||||
exit(0);
|
||||
}
|
||||
UsePackedDepthStencil = GL_TRUE;
|
||||
printf("Using GL_EXT_packed_depth_stencil\n");
|
||||
}
|
||||
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* gen framebuffer id, delete it, do some assertions, just for testing */
|
||||
glGenFramebuffersEXT(1, &MyFB);
|
||||
assert(MyFB);
|
||||
assert(!glIsFramebufferEXT(MyFB));
|
||||
glDeleteFramebuffersEXT(1, &MyFB);
|
||||
assert(!glIsFramebufferEXT(MyFB));
|
||||
/* Note, continue to use MyFB below */
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
|
||||
assert(glIsFramebufferEXT(MyFB));
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &i);
|
||||
assert(i == MyFB);
|
||||
|
||||
/* Make texture object/image */
|
||||
glGenTextures(1, &TexObj);
|
||||
glBindTexture(TexTarget, TexObj);
|
||||
/* make two image levels */
|
||||
glTexImage2D(TexTarget, 0, TexIntFormat, TexWidth, TexHeight, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(TexTarget, 1, TexIntFormat, TexWidth/2, TexHeight/2, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
TexWidth = TexWidth >> TextureLevel;
|
||||
TexHeight = TexHeight >> TextureLevel;
|
||||
|
||||
glTexParameteri(TexTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(TexTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexParameteri(TexTarget, GL_TEXTURE_BASE_LEVEL, TextureLevel);
|
||||
glTexParameteri(TexTarget, GL_TEXTURE_MAX_LEVEL, TextureLevel);
|
||||
|
||||
CheckError(__LINE__);
|
||||
|
||||
/* Render color to texture */
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
TexTarget, TexObj, TextureLevel);
|
||||
|
||||
|
||||
#if DEPTH
|
||||
/* make depth renderbuffer */
|
||||
glGenRenderbuffersEXT(1, &DepthRB);
|
||||
assert(DepthRB);
|
||||
assert(!glIsRenderbufferEXT(DepthRB));
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB);
|
||||
assert(glIsRenderbufferEXT(DepthRB));
|
||||
if (UsePackedDepthStencil)
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL_EXT,
|
||||
TexWidth, TexHeight);
|
||||
else
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
|
||||
TexWidth, TexHeight);
|
||||
CheckError(__LINE__);
|
||||
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
|
||||
GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i);
|
||||
CheckError(__LINE__);
|
||||
printf("Depth renderbuffer size = %d bits\n", i);
|
||||
assert(i > 0);
|
||||
|
||||
/* attach DepthRB to MyFB */
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
|
||||
GL_RENDERBUFFER_EXT, DepthRB);
|
||||
#endif
|
||||
|
||||
CheckError(__LINE__);
|
||||
|
||||
#if STENCIL
|
||||
if (UsePackedDepthStencil) {
|
||||
/* DepthRb is a combined depth/stencil renderbuffer */
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
GL_STENCIL_ATTACHMENT_EXT,
|
||||
GL_RENDERBUFFER_EXT, DepthRB);
|
||||
}
|
||||
else {
|
||||
/* make stencil renderbuffer */
|
||||
glGenRenderbuffersEXT(1, &StencilRB);
|
||||
assert(StencilRB);
|
||||
assert(!glIsRenderbufferEXT(StencilRB));
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, StencilRB);
|
||||
assert(glIsRenderbufferEXT(StencilRB));
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX,
|
||||
TexWidth, TexHeight);
|
||||
/* attach StencilRB to MyFB */
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
GL_STENCIL_ATTACHMENT_EXT,
|
||||
GL_RENDERBUFFER_EXT, StencilRB);
|
||||
}
|
||||
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
|
||||
GL_RENDERBUFFER_STENCIL_SIZE_EXT, &i);
|
||||
CheckError(__LINE__);
|
||||
printf("Stencil renderbuffer size = %d bits\n", i);
|
||||
assert(i > 0);
|
||||
#endif
|
||||
|
||||
CheckError(__LINE__);
|
||||
|
||||
/* bind regular framebuffer */
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
|
||||
|
||||
/* lighting */
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat);
|
||||
{
|
||||
static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 };
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat);
|
||||
}
|
||||
|
||||
/*
|
||||
* Make texture object/image (we'll render into this texture)
|
||||
*/
|
||||
{
|
||||
glGenTextures(1, &TexObj);
|
||||
glBindTexture(TexTarget, TexObj);
|
||||
|
||||
/* make two image levels */
|
||||
glTexImage2D(TexTarget, 0, TexIntFormat, TexWidth, TexHeight, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(TexTarget, 1, TexIntFormat, TexWidth/2, TexHeight/2, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
TexWidth = TexWidth >> TextureLevel;
|
||||
TexHeight = TexHeight >> TextureLevel;
|
||||
|
||||
glTexParameteri(TexTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(TexTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(TexTarget, GL_TEXTURE_BASE_LEVEL, TextureLevel);
|
||||
glTexParameteri(TexTarget, GL_TEXTURE_MAX_LEVEL, TextureLevel);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
}
|
||||
|
||||
MyFB = MakeFBO_RenderTexture(TexObj);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -ds Use combined depth/stencil renderbuffer\n");
|
||||
printf(" -arb Try GL_ARB_framebuffer_object's mismatched buffer sizes\n");
|
||||
printf(" -ds2 Tye GL_ARB_framebuffer_object's GL_DEPTH_STENCIL_ATTACHMENT\n");
|
||||
printf("Keys:\n");
|
||||
printf(" a Toggle animation\n");
|
||||
printf(" s/s Step/rotate\n");
|
||||
printf(" c Toggle back-face culling\n");
|
||||
printf(" w Toggle wireframe mode (front-face only)\n");
|
||||
printf(" Esc Exit\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -444,8 +599,11 @@ main(int argc, char *argv[])
|
|||
glutDisplayFunc(Display);
|
||||
if (Anim)
|
||||
glutIdleFunc(Idle);
|
||||
Init(argc, argv);
|
||||
|
||||
ParseArgs(argc, argv);
|
||||
Init();
|
||||
Usage();
|
||||
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,8 @@ static void test_uniform_size_type1(const char *glslType, GLenum glType, const c
|
|||
GLenum type;
|
||||
GLint size;
|
||||
|
||||
printf(" Running subtest %s\n", glslType); fflush(stdout);
|
||||
printf(" Running subtest %s\n", glslType);
|
||||
fflush(stdout);
|
||||
sprintf(buffer, "#version 120\nuniform %s m[60];\nvoid main() { gl_Position[0] = m[59]%s; }\n",
|
||||
glslType, el);
|
||||
|
||||
|
|
@ -169,7 +170,8 @@ static void test_attrib_size_type1(const char *glslType, GLenum glType, const ch
|
|||
GLenum type;
|
||||
GLint size;
|
||||
|
||||
printf(" Running subtest %s\n", glslType); fflush(stdout);
|
||||
printf(" Running subtest %s\n", glslType);
|
||||
fflush(stdout);
|
||||
sprintf(buffer, "#version 120\nattribute %s m;\nvoid main() { gl_Position[0] = m%s; }\n",
|
||||
glslType, el);
|
||||
|
||||
|
|
@ -302,8 +304,6 @@ static void test_uniform_multiple_samplers(void)
|
|||
assert_no_error();
|
||||
program = make_program(NULL, "uniform sampler2D s[2];\nvoid main() { gl_FragColor = texture2D(s[1], vec2(0.0, 0.0)); }\n");
|
||||
location = glGetUniformLocation(program, "s[0]");
|
||||
if (location == -1) /* Mesa doesn't currently support indexing */
|
||||
location = glGetUniformLocation(program, "s");
|
||||
assert(location != -1);
|
||||
assert_no_error();
|
||||
glUniform1iv(location, 2, values);
|
||||
|
|
|
|||
|
|
@ -46,6 +46,13 @@ static PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f_func = NULL;
|
|||
static PFNGLVERTEXATTRIB2FPROC glVertexAttrib2f_func = NULL;
|
||||
static PFNGLVERTEXATTRIB3FPROC glVertexAttrib3f_func = NULL;
|
||||
static PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f_func = NULL;
|
||||
static PFNGLVERTEXATTRIB1FVPROC glVertexAttrib1fv_func = NULL;
|
||||
static PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv_func = NULL;
|
||||
static PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv_func = NULL;
|
||||
static PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv_func = NULL;
|
||||
static PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer_func = NULL;
|
||||
static PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray_func = NULL;
|
||||
static PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray_func = NULL;
|
||||
|
||||
/* OpenGL 2.1 */
|
||||
static PFNGLUNIFORMMATRIX2X3FVPROC glUniformMatrix2x3fv_func = NULL;
|
||||
|
|
@ -126,6 +133,14 @@ GetExtensionFuncs(void)
|
|||
glVertexAttrib2f_func = (PFNGLVERTEXATTRIB2FPROC) glutGetProcAddress("glVertexAttrib2f");
|
||||
glVertexAttrib3f_func = (PFNGLVERTEXATTRIB3FPROC) glutGetProcAddress("glVertexAttrib3f");
|
||||
glVertexAttrib4f_func = (PFNGLVERTEXATTRIB4FPROC) glutGetProcAddress("glVertexAttrib4f");
|
||||
glVertexAttrib1fv_func = (PFNGLVERTEXATTRIB1FVPROC) glutGetProcAddress("glVertexAttrib1fv");
|
||||
glVertexAttrib2fv_func = (PFNGLVERTEXATTRIB2FVPROC) glutGetProcAddress("glVertexAttrib2fv");
|
||||
glVertexAttrib3fv_func = (PFNGLVERTEXATTRIB3FVPROC) glutGetProcAddress("glVertexAttrib3fv");
|
||||
glVertexAttrib4fv_func = (PFNGLVERTEXATTRIB4FVPROC) glutGetProcAddress("glVertexAttrib4fv");
|
||||
|
||||
glVertexAttribPointer_func = (PFNGLVERTEXATTRIBPOINTERPROC) glutGetProcAddress("glVertexAttribPointer");
|
||||
glEnableVertexAttribArray_func = (PFNGLENABLEVERTEXATTRIBARRAYPROC) glutGetProcAddress("glEnableVertexAttribArray");
|
||||
glDisableVertexAttribArray_func = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) glutGetProcAddress("glDisableVertexAttribArray");
|
||||
|
||||
/* OpenGL 2.1 */
|
||||
glUniformMatrix2x3fv_func = (PFNGLUNIFORMMATRIX2X3FVPROC) glutGetProcAddress("glUniformMatrix2x3fv");
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@
|
|||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
|
||||
static int is_glx_extension_supported(Display *dpy, const char *query);
|
||||
|
||||
static void query_vsync(Display *dpy);
|
||||
|
||||
#define BENCHMARK
|
||||
|
||||
|
|
@ -560,6 +563,73 @@ make_window( Display *dpy, const char *name,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether or not a GLX extension is supported.
|
||||
*/
|
||||
int
|
||||
is_glx_extension_supported(Display *dpy, const char *query)
|
||||
{
|
||||
const int scrnum = DefaultScreen(dpy);
|
||||
const char *glx_extensions = NULL;
|
||||
const size_t len = strlen(query);
|
||||
const char *ptr;
|
||||
|
||||
if (glx_extensions == NULL) {
|
||||
glx_extensions = glXQueryExtensionsString(dpy, scrnum);
|
||||
}
|
||||
|
||||
ptr = strstr(glx_extensions, query);
|
||||
return ((ptr != NULL) && ((ptr[len] == ' ') || (ptr[len] == '\0')));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attempt to determine whether or not the display is synched to vblank.
|
||||
*/
|
||||
void
|
||||
query_vsync(Display *dpy)
|
||||
{
|
||||
int interval = 0;
|
||||
|
||||
|
||||
#ifdef GLX_MESA_swap_control
|
||||
if ((interval <= 0)
|
||||
&& is_glx_extension_supported(dpy, "GLX_MESA_swap_control")) {
|
||||
PFNGLXGETSWAPINTERVALMESAPROC pglXGetSwapIntervalMESA =
|
||||
(PFNGLXGETSWAPINTERVALMESAPROC)
|
||||
glXGetProcAddressARB((const GLubyte *) "glXGetSwapIntervalMESA");
|
||||
|
||||
interval = (*pglXGetSwapIntervalMESA)();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef GLX_SGI_video_sync
|
||||
if ((interval <= 0)
|
||||
&& is_glx_extension_supported(dpy, "GLX_SGI_video_sync")) {
|
||||
PFNGLXGETVIDEOSYNCSGIPROC pglXGetVideoSyncSGI =
|
||||
(PFNGLXGETVIDEOSYNCSGIPROC)
|
||||
glXGetProcAddressARB((const GLubyte *) "glXGetVideoSyncSGI");
|
||||
unsigned count;
|
||||
|
||||
if ((*pglXGetVideoSyncSGI)(& count) == 0) {
|
||||
interval = (int) count;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (interval > 0) {
|
||||
printf("Running synchronized to the vertical refresh. The framerate should be\n");
|
||||
if (interval == 1) {
|
||||
printf("approximately the same as the monitor refresh rate.\n");
|
||||
} else if (interval > 1) {
|
||||
printf("approximately 1/%d the monitor refresh rate.\n",
|
||||
interval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle one X event.
|
||||
* \return NOP, EXIT or DRAW
|
||||
|
|
@ -567,6 +637,9 @@ make_window( Display *dpy, const char *name,
|
|||
static int
|
||||
handle_event(Display *dpy, Window win, XEvent *event)
|
||||
{
|
||||
(void) dpy;
|
||||
(void) win;
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
return DRAW;
|
||||
|
|
@ -686,6 +759,7 @@ main(int argc, char *argv[])
|
|||
make_window(dpy, "glxgears", x, y, winWidth, winHeight, &win, &ctx);
|
||||
XMapWindow(dpy, win);
|
||||
glXMakeCurrent(dpy, win, ctx);
|
||||
query_vsync(dpy);
|
||||
|
||||
if (printInfo) {
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
|
|
|||
|
|
@ -178,6 +178,7 @@ int main( int argc, char *argv[] )
|
|||
glColor3f( 0.0, 1.0, 1.0 );
|
||||
glRectf( -0.75, -0.75, 0.75, 0.75 );
|
||||
glFlush();
|
||||
glXWaitGL();
|
||||
|
||||
XMapWindow( dpy, win );
|
||||
|
||||
|
|
|
|||
|
|
@ -165,7 +165,8 @@ MakeOverlayWindow(Display *dpy)
|
|||
/* XXX setup the colormap entries! */
|
||||
}
|
||||
else {
|
||||
printf("Error: couldn't get an overlay visual!\n");
|
||||
printf("Couldn't get an overlay visual.\n");
|
||||
printf("Your hardware probably doesn't support framebuffer overlay planes.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,6 +163,25 @@ def createInstallMethods(env):
|
|||
env.AddMethod(install_shared_library, 'InstallSharedLibrary')
|
||||
|
||||
|
||||
def num_jobs():
|
||||
try:
|
||||
return int(os.environ['NUMBER_OF_PROCESSORS'])
|
||||
except (ValueError, KeyError):
|
||||
pass
|
||||
|
||||
try:
|
||||
return os.sysconf('SC_NPROCESSORS_ONLN')
|
||||
except (ValueError, OSError, AttributeError):
|
||||
pass
|
||||
|
||||
try:
|
||||
return int(os.popen2("sysctl -n hw.ncpu")[1].read())
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
def generate(env):
|
||||
"""Common environment generation code"""
|
||||
|
||||
|
|
@ -207,6 +226,10 @@ def generate(env):
|
|||
env.SConsignFile(os.path.join(build_dir, '.sconsign'))
|
||||
env.CacheDir('build/cache')
|
||||
|
||||
# Parallel build
|
||||
if env.GetOption('num_jobs') <= 1:
|
||||
env.SetOption('num_jobs', num_jobs())
|
||||
|
||||
# C preprocessor options
|
||||
cppdefines = []
|
||||
if debug:
|
||||
|
|
@ -324,6 +347,7 @@ def generate(env):
|
|||
'/Od', # disable optimizations
|
||||
'/Oi', # enable intrinsic functions
|
||||
'/Oy-', # disable frame pointer omission
|
||||
'/GL-', # disable whole program optimization
|
||||
]
|
||||
else:
|
||||
cflags += [
|
||||
|
|
@ -414,9 +438,14 @@ def generate(env):
|
|||
linkflags += ['-m32']
|
||||
if env['machine'] == 'x86_64':
|
||||
linkflags += ['-m64']
|
||||
if platform == 'winddk':
|
||||
if platform == 'windows' and msvc:
|
||||
# See also:
|
||||
# - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
|
||||
linkflags += [
|
||||
'/fixed:no',
|
||||
'/incremental:no',
|
||||
]
|
||||
if platform == 'winddk':
|
||||
linkflags += [
|
||||
'/merge:_PAGE=PAGE',
|
||||
'/merge:_TEXT=.text',
|
||||
|
|
|
|||
|
|
@ -206,6 +206,25 @@ _bool_map = {
|
|||
}
|
||||
|
||||
|
||||
def num_jobs():
|
||||
try:
|
||||
return int(os.environ['NUMBER_OF_PROCESSORS'])
|
||||
except (ValueError, KeyError):
|
||||
pass
|
||||
|
||||
try:
|
||||
return os.sysconf('SC_NPROCESSORS_ONLN')
|
||||
except (ValueError, OSError, AttributeError):
|
||||
pass
|
||||
|
||||
try:
|
||||
return int(os.popen2("sysctl -n hw.ncpu")[1].read())
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
def generate(env):
|
||||
"""Common environment generation code"""
|
||||
|
||||
|
|
@ -266,6 +285,10 @@ def generate(env):
|
|||
# different scons versions building the same source file
|
||||
env.SConsignFile(os.path.join(env['build'], '.sconsign'))
|
||||
|
||||
# Parallel build
|
||||
if env.GetOption('num_jobs') <= 1:
|
||||
env.SetOption('num_jobs', num_jobs())
|
||||
|
||||
# Summary
|
||||
print
|
||||
print ' platform=%s' % env['platform']
|
||||
|
|
@ -274,6 +297,7 @@ def generate(env):
|
|||
print ' debug=%s' % ['no', 'yes'][env['debug']]
|
||||
print ' profile=%s' % ['no', 'yes'][env['profile']]
|
||||
print ' build=%s' % env['build']
|
||||
print ' %s jobs' % env.GetOption('num_jobs')
|
||||
print
|
||||
|
||||
# Load tool chain
|
||||
|
|
@ -401,6 +425,7 @@ def generate(env):
|
|||
'/Od', # disable optimizations
|
||||
'/Oi', # enable intrinsic functions
|
||||
'/Oy-', # disable frame pointer omission
|
||||
'/GL-', # disable whole program optimization
|
||||
]
|
||||
else:
|
||||
ccflags += [
|
||||
|
|
@ -492,9 +517,14 @@ def generate(env):
|
|||
linkflags += ['-m32']
|
||||
if env['machine'] == 'x86_64':
|
||||
linkflags += ['-m64']
|
||||
if platform == 'winddk':
|
||||
if platform == 'windows' and msvc:
|
||||
# See also:
|
||||
# - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
|
||||
linkflags += [
|
||||
'/fixed:no',
|
||||
'/incremental:no',
|
||||
]
|
||||
if platform == 'winddk':
|
||||
linkflags += [
|
||||
'/merge:_PAGE=PAGE',
|
||||
'/merge:_TEXT=.text',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# src/egl/Makefile
|
||||
|
||||
TOP = ../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
SUBDIRS = main drivers
|
||||
|
||||
|
|
@ -15,6 +16,12 @@ subdirs:
|
|||
fi \
|
||||
done
|
||||
|
||||
install:
|
||||
@for dir in $(SUBDIRS) ; do \
|
||||
if [ -d $$dir ] ; then \
|
||||
(cd $$dir && $(MAKE) install) || exit 1 ; \
|
||||
fi \
|
||||
done
|
||||
|
||||
clean:
|
||||
-@for dir in $(SUBDIRS) ; do \
|
||||
|
|
|
|||
|
|
@ -16,6 +16,12 @@ subdirs:
|
|||
fi \
|
||||
done
|
||||
|
||||
install:
|
||||
@ for dir in $(SUBDIRS) ; do \
|
||||
if [ -d $$dir ] ; then \
|
||||
(cd $$dir ; $(MAKE) install) || exit 1 ; \
|
||||
fi \
|
||||
done
|
||||
|
||||
clean:
|
||||
@for dir in $(SUBDIRS) ; do \
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ $(TOP)/$(LIB_DIR)/demodriver.so: $(OBJECTS)
|
|||
-ldflags '$(LDFLAGS)' -install $(TOP)/$(LIB_DIR) \
|
||||
$(OBJECTS)
|
||||
|
||||
|
||||
install:
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/demodriver.so $(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
|
||||
clean:
|
||||
-rm -f *.o
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ $(TOP)/$(LIB_DIR)/libEGLdri.so: $(OBJECTS)
|
|||
-major 1 -minor 0 \
|
||||
-install $(TOP)/$(LIB_DIR) -ldl $(OBJECTS) $(LIBS)
|
||||
|
||||
install: $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/libEGLdri.so $(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
|
||||
clean:
|
||||
-rm -f *.o
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ $(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(OBJECTS)
|
|||
-install $(TOP)/$(LIB_DIR) \
|
||||
$(OBJECTS) $(DRM_LIB) $(MISC_LIBS)
|
||||
|
||||
install: $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ $(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(OBJECTS)
|
|||
-install $(TOP)/$(LIB_DIR) \
|
||||
$(OBJECTS) $(DRM_LIB) $(MISC_LIBS)
|
||||
|
||||
install: $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
|
|
|||
|
|
@ -65,7 +65,9 @@ $(TOP)/$(LIB_DIR)/libEGL.so: $(OBJECTS)
|
|||
-major 1 -minor 0 \
|
||||
-install $(TOP)/$(LIB_DIR) -ldl $(OBJECTS) $(LIBS)
|
||||
|
||||
|
||||
install:
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/libEGL.so* $(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
|
||||
clean:
|
||||
-rm -f *.o *.so*
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ TOP = ../..
|
|||
include $(TOP)/configs/current
|
||||
|
||||
|
||||
SUBDIRS = auxiliary drivers state_trackers
|
||||
SUBDIRS = $(GALLIUM_DIRS)
|
||||
# Note winsys/ needs to be built after src/mesa
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ SConscript([
|
|||
'auxiliary/translate/SConscript',
|
||||
'auxiliary/draw/SConscript',
|
||||
'auxiliary/pipebuffer/SConscript',
|
||||
'auxiliary/indices/SConscript',
|
||||
])
|
||||
|
||||
for driver in env['drivers']:
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
|
|||
struct tgsi_full_immediate immed;
|
||||
uint size = 4;
|
||||
immed = tgsi_default_full_immediate();
|
||||
immed.Immediate.Size = 1 + size; /* one for the token itself */
|
||||
immed.Immediate.NrTokens = 1 + size; /* one for the token itself */
|
||||
immed.u.Pointer = (void *) value;
|
||||
ctx->emit_immediate(ctx, &immed);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -394,13 +394,14 @@ vbuf_alloc_vertices( struct vbuf_stage *vbuf )
|
|||
/* even number */
|
||||
vbuf->max_vertices = vbuf->max_vertices & ~1;
|
||||
|
||||
if(vbuf->max_vertices >= UNDEFINED_VERTEX_ID)
|
||||
vbuf->max_vertices = UNDEFINED_VERTEX_ID - 1;
|
||||
|
||||
/* Must always succeed -- driver gives us a
|
||||
* 'max_vertex_buffer_bytes' which it guarantees it can allocate,
|
||||
* and it will flush itself if necessary to do so. If this does
|
||||
* fail, we are basically without usable hardware.
|
||||
*/
|
||||
assert(vbuf->max_vertices < UNDEFINED_VERTEX_ID);
|
||||
|
||||
vbuf->vertices = (uint *) vbuf->render->allocate_vertices(vbuf->render,
|
||||
(ushort) vbuf->vertex_size,
|
||||
(ushort) vbuf->max_vertices);
|
||||
|
|
|
|||
|
|
@ -1870,7 +1870,7 @@ static boolean note_immediate( struct aos_compilation *cp,
|
|||
unsigned pos = cp->num_immediates++;
|
||||
unsigned j;
|
||||
|
||||
for (j = 0; j < imm->Immediate.Size; j++) {
|
||||
for (j = 0; j < imm->Immediate.NrTokens - 1; j++) {
|
||||
cp->vaos->machine->immediate[pos][j] = imm->u.ImmediateFloat32[j].Float;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ translate_immediate(Storage *storage,
|
|||
{
|
||||
float vec[4];
|
||||
int i;
|
||||
for (i = 0; i < imm->Immediate.Size - 1; ++i) {
|
||||
for (i = 0; i < imm->Immediate.NrTokens - 1; ++i) {
|
||||
switch (imm->Immediate.DataType) {
|
||||
case TGSI_IMM_FLOAT32:
|
||||
vec[i] = imm->u.ImmediateFloat32[i].Float;
|
||||
|
|
@ -179,7 +179,7 @@ translate_immediateir(StorageSoa *storage,
|
|||
{
|
||||
float vec[4];
|
||||
int i;
|
||||
for (i = 0; i < imm->Immediate.Size - 1; ++i) {
|
||||
for (i = 0; i < imm->Immediate.NrTokens - 1; ++i) {
|
||||
switch (imm->Immediate.DataType) {
|
||||
case TGSI_IMM_FLOAT32:
|
||||
vec[i] = imm->u.ImmediateFloat32[i].Float;
|
||||
|
|
|
|||
16
src/gallium/auxiliary/indices/Makefile
Normal file
16
src/gallium/auxiliary/indices/Makefile
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
TOP = ../../../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
LIBNAME = indices
|
||||
|
||||
C_SOURCES = \
|
||||
u_indices_gen.c
|
||||
|
||||
include ../../Makefile.template
|
||||
|
||||
u_indices_gen.c: u_indices_gen.py
|
||||
python $< > $@
|
||||
|
||||
|
||||
symlinks:
|
||||
|
||||
17
src/gallium/auxiliary/indices/SConscript
Normal file
17
src/gallium/auxiliary/indices/SConscript
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
Import('*')
|
||||
|
||||
env.CodeGenerate(
|
||||
target = 'u_indices_gen.c',
|
||||
script = 'u_indices_gen.py',
|
||||
source = [],
|
||||
command = 'python $SCRIPT > $TARGET'
|
||||
)
|
||||
|
||||
indices = env.ConvenienceLibrary(
|
||||
target = 'indices',
|
||||
source = [
|
||||
# 'u_indices.c',
|
||||
'u_indices_gen.c',
|
||||
])
|
||||
|
||||
auxiliaries.insert(0, indices)
|
||||
253
src/gallium/auxiliary/indices/u_indices.c
Normal file
253
src/gallium/auxiliary/indices/u_indices.c
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
/*
|
||||
* Copyright 2009 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* on the rights to use, copy, modify, merge, publish, distribute, sub
|
||||
* license, and/or sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "u_indices.h"
|
||||
#include "u_indices_priv.h"
|
||||
|
||||
static void translate_memcpy_ushort( const void *in,
|
||||
unsigned nr,
|
||||
void *out )
|
||||
{
|
||||
memcpy(out, in, nr*sizeof(short));
|
||||
}
|
||||
|
||||
static void translate_memcpy_uint( const void *in,
|
||||
unsigned nr,
|
||||
void *out )
|
||||
{
|
||||
memcpy(out, in, nr*sizeof(int));
|
||||
}
|
||||
|
||||
|
||||
int u_index_translator( unsigned hw_mask,
|
||||
unsigned prim,
|
||||
unsigned in_index_size,
|
||||
unsigned nr,
|
||||
unsigned in_pv,
|
||||
unsigned out_pv,
|
||||
unsigned *out_prim,
|
||||
unsigned *out_index_size,
|
||||
unsigned *out_nr,
|
||||
u_translate_func *out_translate )
|
||||
{
|
||||
unsigned in_idx;
|
||||
unsigned out_idx;
|
||||
int ret = U_TRANSLATE_NORMAL;
|
||||
|
||||
u_index_init();
|
||||
|
||||
in_idx = in_size_idx(in_index_size);
|
||||
*out_index_size = (in_index_size == 4) ? 4 : 2;
|
||||
out_idx = out_size_idx(*out_index_size);
|
||||
|
||||
if ((hw_mask & (1<<prim)) &&
|
||||
in_index_size == *out_index_size &&
|
||||
in_pv == out_pv)
|
||||
{
|
||||
if (in_index_size == 4)
|
||||
*out_translate = translate_memcpy_uint;
|
||||
else
|
||||
*out_translate = translate_memcpy_ushort;
|
||||
|
||||
*out_prim = prim;
|
||||
*out_nr = nr;
|
||||
|
||||
return U_TRANSLATE_MEMCPY;
|
||||
}
|
||||
else {
|
||||
switch (prim) {
|
||||
case PIPE_PRIM_POINTS:
|
||||
*out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_POINTS;
|
||||
*out_nr = nr;
|
||||
break;
|
||||
|
||||
case PIPE_PRIM_LINES:
|
||||
*out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_LINES;
|
||||
*out_nr = nr;
|
||||
break;
|
||||
|
||||
case PIPE_PRIM_LINE_STRIP:
|
||||
*out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_LINES;
|
||||
*out_nr = (nr - 1) * 2;
|
||||
break;
|
||||
|
||||
case PIPE_PRIM_LINE_LOOP:
|
||||
*out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_LINES;
|
||||
*out_nr = nr * 2;
|
||||
break;
|
||||
|
||||
case PIPE_PRIM_TRIANGLES:
|
||||
*out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_TRIANGLES;
|
||||
*out_nr = nr;
|
||||
break;
|
||||
|
||||
case PIPE_PRIM_TRIANGLE_STRIP:
|
||||
*out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_TRIANGLES;
|
||||
*out_nr = (nr - 2) * 3;
|
||||
break;
|
||||
|
||||
case PIPE_PRIM_TRIANGLE_FAN:
|
||||
*out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_TRIANGLES;
|
||||
*out_nr = (nr - 2) * 3;
|
||||
break;
|
||||
|
||||
case PIPE_PRIM_QUADS:
|
||||
*out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_TRIANGLES;
|
||||
*out_nr = (nr / 4) * 6;
|
||||
break;
|
||||
|
||||
case PIPE_PRIM_QUAD_STRIP:
|
||||
*out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_TRIANGLES;
|
||||
*out_nr = (nr - 2) * 3;
|
||||
break;
|
||||
|
||||
case PIPE_PRIM_POLYGON:
|
||||
*out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_TRIANGLES;
|
||||
*out_nr = (nr - 2) * 3;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
*out_translate = translate[in_idx][out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_POINTS;
|
||||
*out_nr = nr;
|
||||
return U_TRANSLATE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int u_index_generator( unsigned hw_mask,
|
||||
unsigned prim,
|
||||
unsigned start,
|
||||
unsigned nr,
|
||||
unsigned in_pv,
|
||||
unsigned out_pv,
|
||||
unsigned *out_prim,
|
||||
unsigned *out_index_size,
|
||||
unsigned *out_nr,
|
||||
u_generate_func *out_generate )
|
||||
|
||||
{
|
||||
unsigned out_idx;
|
||||
|
||||
u_index_init();
|
||||
|
||||
*out_index_size = ((start + nr) > 0xfffe) ? 4 : 2;
|
||||
out_idx = out_size_idx(*out_index_size);
|
||||
|
||||
if ((hw_mask & (1<<prim)) &&
|
||||
(in_pv == out_pv)) {
|
||||
|
||||
*out_generate = generate[out_idx][in_pv][out_pv][PIPE_PRIM_POINTS];
|
||||
*out_prim = prim;
|
||||
*out_nr = nr;
|
||||
return U_GENERATE_LINEAR;
|
||||
}
|
||||
else {
|
||||
switch (prim) {
|
||||
case PIPE_PRIM_POINTS:
|
||||
*out_generate = generate[out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_POINTS;
|
||||
*out_nr = nr;
|
||||
return U_GENERATE_REUSABLE;
|
||||
|
||||
case PIPE_PRIM_LINES:
|
||||
*out_generate = generate[out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_LINES;
|
||||
*out_nr = nr;
|
||||
return U_GENERATE_REUSABLE;
|
||||
|
||||
case PIPE_PRIM_LINE_STRIP:
|
||||
*out_generate = generate[out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_LINES;
|
||||
*out_nr = (nr - 1) * 2;
|
||||
return U_GENERATE_REUSABLE;
|
||||
|
||||
case PIPE_PRIM_LINE_LOOP:
|
||||
*out_generate = generate[out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_LINES;
|
||||
*out_nr = nr * 2;
|
||||
return U_GENERATE_ONE_OFF;
|
||||
|
||||
case PIPE_PRIM_TRIANGLES:
|
||||
*out_generate = generate[out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_TRIANGLES;
|
||||
*out_nr = nr;
|
||||
return U_GENERATE_REUSABLE;
|
||||
|
||||
case PIPE_PRIM_TRIANGLE_STRIP:
|
||||
*out_generate = generate[out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_TRIANGLES;
|
||||
*out_nr = (nr - 2) * 3;
|
||||
return U_GENERATE_REUSABLE;
|
||||
|
||||
case PIPE_PRIM_TRIANGLE_FAN:
|
||||
*out_generate = generate[out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_TRIANGLES;
|
||||
*out_nr = (nr - 2) * 3;
|
||||
return U_GENERATE_REUSABLE;
|
||||
|
||||
case PIPE_PRIM_QUADS:
|
||||
*out_generate = generate[out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_TRIANGLES;
|
||||
*out_nr = (nr / 4) * 6;
|
||||
return U_GENERATE_REUSABLE;
|
||||
|
||||
case PIPE_PRIM_QUAD_STRIP:
|
||||
*out_generate = generate[out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_TRIANGLES;
|
||||
*out_nr = (nr - 2) * 3;
|
||||
return U_GENERATE_REUSABLE;
|
||||
|
||||
case PIPE_PRIM_POLYGON:
|
||||
*out_generate = generate[out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_TRIANGLES;
|
||||
*out_nr = (nr - 2) * 3;
|
||||
return U_GENERATE_REUSABLE;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
*out_generate = generate[out_idx][in_pv][out_pv][prim];
|
||||
*out_prim = PIPE_PRIM_POINTS;
|
||||
*out_nr = nr;
|
||||
return U_TRANSLATE_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
83
src/gallium/auxiliary/indices/u_indices.h
Normal file
83
src/gallium/auxiliary/indices/u_indices.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright 2009 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* on the rights to use, copy, modify, merge, publish, distribute, sub
|
||||
* license, and/or sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef U_INDICES_H
|
||||
#define U_INDICES_H
|
||||
|
||||
#include "pipe/p_compiler.h"
|
||||
|
||||
#define PV_FIRST 0
|
||||
#define PV_LAST 1
|
||||
#define PV_COUNT 2
|
||||
|
||||
typedef void (*u_translate_func)( const void *in,
|
||||
unsigned nr,
|
||||
void *out );
|
||||
|
||||
typedef void (*u_generate_func)( unsigned nr,
|
||||
void *out );
|
||||
|
||||
|
||||
/* Return codes describe the translate/generate operation. Caller may
|
||||
* be able to reuse translated indices under some circumstances.
|
||||
*/
|
||||
#define U_TRANSLATE_ERROR -1
|
||||
#define U_TRANSLATE_NORMAL 1
|
||||
#define U_TRANSLATE_MEMCPY 2
|
||||
#define U_GENERATE_LINEAR 3
|
||||
#define U_GENERATE_REUSABLE 4
|
||||
#define U_GENERATE_ONE_OFF 5
|
||||
|
||||
|
||||
void u_index_init( void );
|
||||
|
||||
int u_index_translator( unsigned hw_mask,
|
||||
unsigned prim,
|
||||
unsigned in_index_size,
|
||||
unsigned nr,
|
||||
unsigned in_pv, /* API */
|
||||
unsigned out_pv, /* hardware */
|
||||
unsigned *out_prim,
|
||||
unsigned *out_index_size,
|
||||
unsigned *out_nr,
|
||||
u_translate_func *out_translate );
|
||||
|
||||
/* Note that even when generating it is necessary to know what the
|
||||
* API's PV is, as the indices generated will depend on whether it is
|
||||
* the same as hardware or not, and in the case of triangle strips,
|
||||
* whether it is first or last.
|
||||
*/
|
||||
int u_index_generator( unsigned hw_mask,
|
||||
unsigned prim,
|
||||
unsigned start,
|
||||
unsigned nr,
|
||||
unsigned in_pv, /* API */
|
||||
unsigned out_pv, /* hardware */
|
||||
unsigned *out_prim,
|
||||
unsigned *out_index_size,
|
||||
unsigned *out_nr,
|
||||
u_generate_func *out_generate );
|
||||
|
||||
|
||||
#endif
|
||||
5129
src/gallium/auxiliary/indices/u_indices_gen.c
Normal file
5129
src/gallium/auxiliary/indices/u_indices_gen.c
Normal file
File diff suppressed because it is too large
Load diff
319
src/gallium/auxiliary/indices/u_indices_gen.py
Normal file
319
src/gallium/auxiliary/indices/u_indices_gen.py
Normal file
|
|
@ -0,0 +1,319 @@
|
|||
#!/usr/bin/env python
|
||||
copyright = '''
|
||||
/*
|
||||
* Copyright 2009 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* on the rights to use, copy, modify, merge, publish, distribute, sub
|
||||
* license, and/or sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
'''
|
||||
|
||||
GENERATE, UBYTE, USHORT, UINT = 'generate', 'ubyte', 'ushort', 'uint'
|
||||
FIRST, LAST = 'first', 'last'
|
||||
|
||||
INTYPES = (GENERATE, UBYTE, USHORT, UINT)
|
||||
OUTTYPES = (USHORT, UINT)
|
||||
PVS=(FIRST, LAST)
|
||||
PRIMS=('points',
|
||||
'lines',
|
||||
'linestrip',
|
||||
'lineloop',
|
||||
'tris',
|
||||
'trifan',
|
||||
'tristrip',
|
||||
'quads',
|
||||
'quadstrip',
|
||||
'polygon')
|
||||
|
||||
LONGPRIMS=('PIPE_PRIM_POINTS',
|
||||
'PIPE_PRIM_LINES',
|
||||
'PIPE_PRIM_LINE_STRIP',
|
||||
'PIPE_PRIM_LINE_LOOP',
|
||||
'PIPE_PRIM_TRIANGLES',
|
||||
'PIPE_PRIM_TRIANGLE_FAN',
|
||||
'PIPE_PRIM_TRIANGLE_STRIP',
|
||||
'PIPE_PRIM_QUADS',
|
||||
'PIPE_PRIM_QUAD_STRIP',
|
||||
'PIPE_PRIM_POLYGON')
|
||||
|
||||
longprim = dict(zip(PRIMS, LONGPRIMS))
|
||||
intype_idx = dict(ubyte='IN_UBYTE', ushort='IN_USHORT', uint='IN_UINT')
|
||||
outtype_idx = dict(ushort='OUT_USHORT', uint='OUT_UINT')
|
||||
pv_idx = dict(first='PV_FIRST', last='PV_LAST')
|
||||
|
||||
|
||||
def prolog():
|
||||
print '''/* File automatically generated by indices.py */'''
|
||||
print copyright
|
||||
print r'''
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Functions to translate and generate index lists
|
||||
*/
|
||||
|
||||
#include "indices/u_indices.h"
|
||||
#include "indices/u_indices_priv.h"
|
||||
#include "pipe/p_compiler.h"
|
||||
#include "pipe/p_debug.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
|
||||
static unsigned out_size_idx( unsigned index_size )
|
||||
{
|
||||
switch (index_size) {
|
||||
case 4: return OUT_UINT;
|
||||
case 2: return OUT_USHORT;
|
||||
default: assert(0); return OUT_USHORT;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned in_size_idx( unsigned index_size )
|
||||
{
|
||||
switch (index_size) {
|
||||
case 4: return IN_UINT;
|
||||
case 2: return IN_USHORT;
|
||||
case 1: return IN_UBYTE;
|
||||
default: assert(0); return IN_UBYTE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static u_translate_func translate[IN_COUNT][OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT];
|
||||
static u_generate_func generate[OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT];
|
||||
|
||||
|
||||
'''
|
||||
|
||||
def vert( intype, outtype, v0 ):
|
||||
if intype == GENERATE:
|
||||
return '(' + outtype + ')(' + v0 + ')'
|
||||
else:
|
||||
return '(' + outtype + ')in[' + v0 + ']'
|
||||
|
||||
def point( intype, outtype, ptr, v0 ):
|
||||
print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
|
||||
|
||||
def line( intype, outtype, ptr, v0, v1 ):
|
||||
print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
|
||||
print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
|
||||
|
||||
def tri( intype, outtype, ptr, v0, v1, v2 ):
|
||||
print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
|
||||
print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
|
||||
print ' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';'
|
||||
|
||||
def do_point( intype, outtype, ptr, v0 ):
|
||||
point( intype, outtype, ptr, v0 )
|
||||
|
||||
def do_line( intype, outtype, ptr, v0, v1, inpv, outpv ):
|
||||
if inpv == outpv:
|
||||
line( intype, outtype, ptr, v0, v1 )
|
||||
else:
|
||||
line( intype, outtype, ptr, v1, v0 )
|
||||
|
||||
def do_tri( intype, outtype, ptr, v0, v1, v2, inpv, outpv ):
|
||||
if inpv == outpv:
|
||||
tri( intype, outtype, ptr, v0, v1, v2 )
|
||||
else:
|
||||
if inpv == FIRST:
|
||||
tri( intype, outtype, ptr, v1, v2, v0 )
|
||||
else:
|
||||
tri( intype, outtype, ptr, v2, v0, v1 )
|
||||
|
||||
def do_quad( intype, outtype, ptr, v0, v1, v2, v3, inpv, outpv ):
|
||||
do_tri( intype, outtype, ptr+'+0', v0, v1, v3, inpv, outpv );
|
||||
do_tri( intype, outtype, ptr+'+3', v1, v2, v3, inpv, outpv );
|
||||
|
||||
def name(intype, outtype, inpv, outpv, prim):
|
||||
if intype == GENERATE:
|
||||
return 'generate_' + prim + '_' + outtype + '_' + inpv + '2' + outpv
|
||||
else:
|
||||
return 'translate_' + prim + '_' + intype + '2' + outtype + '_' + inpv + '2' + outpv
|
||||
|
||||
def preamble(intype, outtype, inpv, outpv, prim):
|
||||
print 'static void ' + name( intype, outtype, inpv, outpv, prim ) + '('
|
||||
if intype != GENERATE:
|
||||
print ' const void * _in,'
|
||||
print ' unsigned nr,'
|
||||
print ' void *_out )'
|
||||
print '{'
|
||||
if intype != GENERATE:
|
||||
print ' const ' + intype + '*in = (const ' + intype + '*)_in;'
|
||||
print ' ' + outtype + ' *out = (' + outtype + '*)_out;'
|
||||
print ' unsigned i, j;'
|
||||
print ' (void)j;'
|
||||
|
||||
def postamble():
|
||||
print '}'
|
||||
|
||||
|
||||
def points(intype, outtype, inpv, outpv):
|
||||
preamble(intype, outtype, inpv, outpv, prim='points')
|
||||
print ' for (i = 0; i < nr; i++) { '
|
||||
do_point( intype, outtype, 'out+i', 'i' );
|
||||
print ' }'
|
||||
postamble()
|
||||
|
||||
def lines(intype, outtype, inpv, outpv):
|
||||
preamble(intype, outtype, inpv, outpv, prim='lines')
|
||||
print ' for (i = 0; i < nr; i+=2) { '
|
||||
do_line( intype, outtype, 'out+i', 'i', 'i+1', inpv, outpv );
|
||||
print ' }'
|
||||
postamble()
|
||||
|
||||
def linestrip(intype, outtype, inpv, outpv):
|
||||
preamble(intype, outtype, inpv, outpv, prim='linestrip')
|
||||
print ' for (j = i = 0; j < nr; j+=2, i++) { '
|
||||
do_line( intype, outtype, 'out+j', 'i', 'i+1', inpv, outpv );
|
||||
print ' }'
|
||||
postamble()
|
||||
|
||||
def lineloop(intype, outtype, inpv, outpv):
|
||||
preamble(intype, outtype, inpv, outpv, prim='lineloop')
|
||||
print ' for (j = i = 0; j < nr - 2; j+=2, i++) { '
|
||||
do_line( intype, outtype, 'out+j', 'i', 'i+1', inpv, outpv );
|
||||
print ' }'
|
||||
do_line( intype, outtype, 'out+j', 'i', '0', inpv, outpv );
|
||||
postamble()
|
||||
|
||||
def tris(intype, outtype, inpv, outpv):
|
||||
preamble(intype, outtype, inpv, outpv, prim='tris')
|
||||
print ' for (i = 0; i < nr; i+=3) { '
|
||||
do_tri( intype, outtype, 'out+i', 'i', 'i+1', 'i+2', inpv, outpv );
|
||||
print ' }'
|
||||
postamble()
|
||||
|
||||
|
||||
def tristrip(intype, outtype, inpv, outpv):
|
||||
preamble(intype, outtype, inpv, outpv, prim='tristrip')
|
||||
print ' for (j = i = 0; j < nr; j+=3, i++) { '
|
||||
if inpv == FIRST:
|
||||
do_tri( intype, outtype, 'out+j', 'i', 'i+1+(i&1)', 'i+2-(i&1)', inpv, outpv );
|
||||
else:
|
||||
do_tri( intype, outtype, 'out+j', 'i+(i&1)', 'i+1-(i&1)', 'i+2', inpv, outpv );
|
||||
print ' }'
|
||||
postamble()
|
||||
|
||||
|
||||
def trifan(intype, outtype, inpv, outpv):
|
||||
preamble(intype, outtype, inpv, outpv, prim='trifan')
|
||||
print ' for (j = i = 0; j < nr; j+=3, i++) { '
|
||||
do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2', inpv, outpv );
|
||||
print ' }'
|
||||
postamble()
|
||||
|
||||
|
||||
|
||||
def polygon(intype, outtype, inpv, outpv):
|
||||
preamble(intype, outtype, inpv, outpv, prim='polygon')
|
||||
print ' for (j = i = 0; j < nr; j+=3, i++) { '
|
||||
if inpv == FIRST:
|
||||
do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2', inpv, outpv );
|
||||
else:
|
||||
do_tri( intype, outtype, 'out+j', 'i+1', 'i+2', '0', inpv, outpv );
|
||||
print ' }'
|
||||
postamble()
|
||||
|
||||
|
||||
def quads(intype, outtype, inpv, outpv):
|
||||
preamble(intype, outtype, inpv, outpv, prim='quads')
|
||||
print ' for (j = i = 0; j < nr; j+=6, i+=4) { '
|
||||
do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv );
|
||||
print ' }'
|
||||
postamble()
|
||||
|
||||
|
||||
def quadstrip(intype, outtype, inpv, outpv):
|
||||
preamble(intype, outtype, inpv, outpv, prim='quadstrip')
|
||||
print ' for (j = i = 0; j < nr; j+=6, i+=2) { '
|
||||
do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3', inpv, outpv );
|
||||
print ' }'
|
||||
postamble()
|
||||
|
||||
|
||||
def emit_funcs():
|
||||
for intype in INTYPES:
|
||||
for outtype in OUTTYPES:
|
||||
for inpv in (FIRST, LAST):
|
||||
for outpv in (FIRST, LAST):
|
||||
points(intype, outtype, inpv, outpv)
|
||||
lines(intype, outtype, inpv, outpv)
|
||||
linestrip(intype, outtype, inpv, outpv)
|
||||
lineloop(intype, outtype, inpv, outpv)
|
||||
tris(intype, outtype, inpv, outpv)
|
||||
tristrip(intype, outtype, inpv, outpv)
|
||||
trifan(intype, outtype, inpv, outpv)
|
||||
quads(intype, outtype, inpv, outpv)
|
||||
quadstrip(intype, outtype, inpv, outpv)
|
||||
polygon(intype, outtype, inpv, outpv)
|
||||
|
||||
def init(intype, outtype, inpv, outpv, prim):
|
||||
if intype == GENERATE:
|
||||
print ('generate[' +
|
||||
outtype_idx[outtype] +
|
||||
'][' + pv_idx[inpv] +
|
||||
'][' + pv_idx[outpv] +
|
||||
'][' + longprim[prim] +
|
||||
'] = ' + name( intype, outtype, inpv, outpv, prim ) + ';')
|
||||
else:
|
||||
print ('translate[' +
|
||||
intype_idx[intype] +
|
||||
'][' + outtype_idx[outtype] +
|
||||
'][' + pv_idx[inpv] +
|
||||
'][' + pv_idx[outpv] +
|
||||
'][' + longprim[prim] +
|
||||
'] = ' + name( intype, outtype, inpv, outpv, prim ) + ';')
|
||||
|
||||
|
||||
def emit_all_inits():
|
||||
for intype in INTYPES:
|
||||
for outtype in OUTTYPES:
|
||||
for inpv in PVS:
|
||||
for outpv in PVS:
|
||||
for prim in PRIMS:
|
||||
init(intype, outtype, inpv, outpv, prim)
|
||||
|
||||
def emit_init():
|
||||
print 'void u_index_init( void )'
|
||||
print '{'
|
||||
print ' static int firsttime = 1;'
|
||||
print ' if (!firsttime) return;'
|
||||
print ' firsttime = 0;'
|
||||
emit_all_inits()
|
||||
print '}'
|
||||
|
||||
|
||||
|
||||
|
||||
def epilog():
|
||||
print '#include "indices/u_indices.c"'
|
||||
|
||||
|
||||
def main():
|
||||
prolog()
|
||||
emit_funcs()
|
||||
emit_init()
|
||||
epilog()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
43
src/gallium/auxiliary/indices/u_indices_priv.h
Normal file
43
src/gallium/auxiliary/indices/u_indices_priv.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright 2009 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* on the rights to use, copy, modify, merge, publish, distribute, sub
|
||||
* license, and/or sell copies of the Software, and to permit persons to whom
|
||||
* the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef U_INDICES_PRIV_H
|
||||
#define U_INDICES_PRIV_H
|
||||
|
||||
#include "pipe/p_compiler.h"
|
||||
#include "u_indices.h"
|
||||
|
||||
#define IN_UBYTE 0
|
||||
#define IN_USHORT 1
|
||||
#define IN_UINT 2
|
||||
#define IN_COUNT 3
|
||||
|
||||
#define OUT_USHORT 0
|
||||
#define OUT_UINT 1
|
||||
#define OUT_COUNT 2
|
||||
|
||||
|
||||
#define PRIM_COUNT (PIPE_PRIM_POLYGON + 1)
|
||||
|
||||
#endif
|
||||
|
|
@ -44,7 +44,6 @@
|
|||
#include "pipe/p_compiler.h"
|
||||
#include "pipe/p_error.h"
|
||||
#include "pipe/p_debug.h"
|
||||
#include "pipe/internal/p_winsys_screen.h"
|
||||
#include "pipe/p_thread.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_double_list.h"
|
||||
|
|
@ -64,7 +63,7 @@ struct fenced_buffer_list
|
|||
{
|
||||
pipe_mutex mutex;
|
||||
|
||||
struct pipe_winsys *winsys;
|
||||
struct pb_fence_ops *ops;
|
||||
|
||||
size_t numDelayed;
|
||||
|
||||
|
|
@ -140,12 +139,12 @@ static INLINE void
|
|||
_fenced_buffer_remove(struct fenced_buffer_list *fenced_list,
|
||||
struct fenced_buffer *fenced_buf)
|
||||
{
|
||||
struct pipe_winsys *winsys = fenced_list->winsys;
|
||||
struct pb_fence_ops *ops = fenced_list->ops;
|
||||
|
||||
assert(fenced_buf->fence);
|
||||
assert(fenced_buf->list == fenced_list);
|
||||
|
||||
winsys->fence_reference(winsys, &fenced_buf->fence, NULL);
|
||||
ops->fence_reference(ops, &fenced_buf->fence, NULL);
|
||||
fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE;
|
||||
|
||||
assert(fenced_buf->head.prev);
|
||||
|
|
@ -168,7 +167,7 @@ static INLINE enum pipe_error
|
|||
_fenced_buffer_finish(struct fenced_buffer *fenced_buf)
|
||||
{
|
||||
struct fenced_buffer_list *fenced_list = fenced_buf->list;
|
||||
struct pipe_winsys *winsys = fenced_list->winsys;
|
||||
struct pb_fence_ops *ops = fenced_list->ops;
|
||||
|
||||
#if 0
|
||||
debug_warning("waiting for GPU");
|
||||
|
|
@ -176,7 +175,7 @@ _fenced_buffer_finish(struct fenced_buffer *fenced_buf)
|
|||
|
||||
assert(fenced_buf->fence);
|
||||
if(fenced_buf->fence) {
|
||||
if(winsys->fence_finish(winsys, fenced_buf->fence, 0) != 0) {
|
||||
if(ops->fence_finish(ops, fenced_buf->fence, 0) != 0) {
|
||||
return PIPE_ERROR;
|
||||
}
|
||||
/* Remove from the fenced list */
|
||||
|
|
@ -196,7 +195,7 @@ static void
|
|||
_fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
|
||||
int wait)
|
||||
{
|
||||
struct pipe_winsys *winsys = fenced_list->winsys;
|
||||
struct pb_fence_ops *ops = fenced_list->ops;
|
||||
struct list_head *curr, *next;
|
||||
struct fenced_buffer *fenced_buf;
|
||||
struct pipe_fence_handle *prev_fence = NULL;
|
||||
|
|
@ -209,15 +208,15 @@ _fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
|
|||
if(fenced_buf->fence != prev_fence) {
|
||||
int signaled;
|
||||
if (wait)
|
||||
signaled = winsys->fence_finish(winsys, fenced_buf->fence, 0);
|
||||
signaled = ops->fence_finish(ops, fenced_buf->fence, 0);
|
||||
else
|
||||
signaled = winsys->fence_signalled(winsys, fenced_buf->fence, 0);
|
||||
signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
|
||||
if (signaled != 0)
|
||||
break;
|
||||
prev_fence = fenced_buf->fence;
|
||||
}
|
||||
else {
|
||||
assert(winsys->fence_signalled(winsys, fenced_buf->fence, 0) == 0);
|
||||
assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0);
|
||||
}
|
||||
|
||||
_fenced_buffer_remove(fenced_list, fenced_buf);
|
||||
|
|
@ -237,14 +236,14 @@ fenced_buffer_destroy(struct pb_buffer *buf)
|
|||
pipe_mutex_lock(fenced_list->mutex);
|
||||
assert(fenced_buf->base.base.refcount == 0);
|
||||
if (fenced_buf->fence) {
|
||||
struct pipe_winsys *winsys = fenced_list->winsys;
|
||||
if(winsys->fence_signalled(winsys, fenced_buf->fence, 0) == 0) {
|
||||
struct pb_fence_ops *ops = fenced_list->ops;
|
||||
if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) {
|
||||
struct list_head *curr, *prev;
|
||||
curr = &fenced_buf->head;
|
||||
prev = curr->prev;
|
||||
do {
|
||||
fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
|
||||
assert(winsys->fence_signalled(winsys, fenced_buf->fence, 0) == 0);
|
||||
assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0);
|
||||
_fenced_buffer_remove(fenced_list, fenced_buf);
|
||||
curr = prev;
|
||||
prev = curr->prev;
|
||||
|
|
@ -366,11 +365,11 @@ fenced_buffer_fence(struct pb_buffer *buf,
|
|||
{
|
||||
struct fenced_buffer *fenced_buf;
|
||||
struct fenced_buffer_list *fenced_list;
|
||||
struct pipe_winsys *winsys;
|
||||
struct pb_fence_ops *ops;
|
||||
|
||||
fenced_buf = fenced_buffer(buf);
|
||||
fenced_list = fenced_buf->list;
|
||||
winsys = fenced_list->winsys;
|
||||
ops = fenced_list->ops;
|
||||
|
||||
if(fence == fenced_buf->fence) {
|
||||
/* Nothing to do */
|
||||
|
|
@ -384,7 +383,7 @@ fenced_buffer_fence(struct pb_buffer *buf,
|
|||
if (fenced_buf->fence)
|
||||
_fenced_buffer_remove(fenced_list, fenced_buf);
|
||||
if (fence) {
|
||||
winsys->fence_reference(winsys, &fenced_buf->fence, fence);
|
||||
ops->fence_reference(ops, &fenced_buf->fence, fence);
|
||||
fenced_buf->flags |= fenced_buf->validation_flags;
|
||||
_fenced_buffer_add(fenced_buf);
|
||||
}
|
||||
|
|
@ -447,7 +446,7 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list,
|
|||
|
||||
|
||||
struct fenced_buffer_list *
|
||||
fenced_buffer_list_create(struct pipe_winsys *winsys)
|
||||
fenced_buffer_list_create(struct pb_fence_ops *ops)
|
||||
{
|
||||
struct fenced_buffer_list *fenced_list;
|
||||
|
||||
|
|
@ -455,7 +454,7 @@ fenced_buffer_list_create(struct pipe_winsys *winsys)
|
|||
if (!fenced_list)
|
||||
return NULL;
|
||||
|
||||
fenced_list->winsys = winsys;
|
||||
fenced_list->ops = ops;
|
||||
|
||||
LIST_INITHEAD(&fenced_list->delayed);
|
||||
|
||||
|
|
@ -494,6 +493,8 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
|
|||
|
||||
pipe_mutex_unlock(fenced_list->mutex);
|
||||
|
||||
fenced_list->ops->destroy(fenced_list->ops);
|
||||
|
||||
FREE(fenced_list);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
struct pipe_winsys;
|
||||
struct pipe_buffer;
|
||||
struct pipe_fence_handle;
|
||||
|
||||
|
|
@ -70,13 +69,42 @@ struct pipe_fence_handle;
|
|||
struct fenced_buffer_list;
|
||||
|
||||
|
||||
struct pb_fence_ops
|
||||
{
|
||||
void (*destroy)( struct pb_fence_ops *ops );
|
||||
|
||||
/** Set ptr = fence, with reference counting */
|
||||
void (*fence_reference)( struct pb_fence_ops *ops,
|
||||
struct pipe_fence_handle **ptr,
|
||||
struct pipe_fence_handle *fence );
|
||||
|
||||
/**
|
||||
* Checks whether the fence has been signalled.
|
||||
* \param flags driver-specific meaning
|
||||
* \return zero on success.
|
||||
*/
|
||||
int (*fence_signalled)( struct pb_fence_ops *ops,
|
||||
struct pipe_fence_handle *fence,
|
||||
unsigned flag );
|
||||
|
||||
/**
|
||||
* Wait for the fence to finish.
|
||||
* \param flags driver-specific meaning
|
||||
* \return zero on success.
|
||||
*/
|
||||
int (*fence_finish)( struct pb_fence_ops *ops,
|
||||
struct pipe_fence_handle *fence,
|
||||
unsigned flag );
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a fenced buffer list.
|
||||
*
|
||||
* See also fenced_bufmgr_create for a more convenient way to use this.
|
||||
*/
|
||||
struct fenced_buffer_list *
|
||||
fenced_buffer_list_create(struct pipe_winsys *winsys);
|
||||
fenced_buffer_list_create(struct pb_fence_ops *ops);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ extern "C" {
|
|||
|
||||
struct pb_desc;
|
||||
struct pipe_buffer;
|
||||
struct pipe_winsys;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -163,6 +162,8 @@ pb_cache_manager_create(struct pb_manager *provider,
|
|||
unsigned usecs);
|
||||
|
||||
|
||||
struct pb_fence_ops;
|
||||
|
||||
/**
|
||||
* Fenced buffer manager.
|
||||
*
|
||||
|
|
@ -174,7 +175,7 @@ pb_cache_manager_create(struct pb_manager *provider,
|
|||
*/
|
||||
struct pb_manager *
|
||||
fenced_bufmgr_create(struct pb_manager *provider,
|
||||
struct pipe_winsys *winsys);
|
||||
struct pb_fence_ops *ops);
|
||||
|
||||
|
||||
struct pb_manager *
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ fenced_bufmgr_destroy(struct pb_manager *mgr)
|
|||
|
||||
struct pb_manager *
|
||||
fenced_bufmgr_create(struct pb_manager *provider,
|
||||
struct pipe_winsys *winsys)
|
||||
struct pb_fence_ops *ops)
|
||||
{
|
||||
struct fenced_pb_manager *fenced_mgr;
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ fenced_bufmgr_create(struct pb_manager *provider,
|
|||
fenced_mgr->base.flush = fenced_bufmgr_flush;
|
||||
|
||||
fenced_mgr->provider = provider;
|
||||
fenced_mgr->fenced_list = fenced_buffer_list_create(winsys);
|
||||
fenced_mgr->fenced_list = fenced_buffer_list_create(ops);
|
||||
if(!fenced_mgr->fenced_list) {
|
||||
FREE(fenced_mgr);
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ tgsi_default_declaration( void )
|
|||
struct tgsi_declaration declaration;
|
||||
|
||||
declaration.Type = TGSI_TOKEN_TYPE_DECLARATION;
|
||||
declaration.Size = 1;
|
||||
declaration.NrTokens = 1;
|
||||
declaration.File = TGSI_FILE_NULL;
|
||||
declaration.UsageMask = TGSI_WRITEMASK_XYZW;
|
||||
declaration.Interpolate = TGSI_INTERPOLATE_CONSTANT;
|
||||
|
|
@ -160,9 +160,9 @@ declaration_grow(
|
|||
struct tgsi_declaration *declaration,
|
||||
struct tgsi_header *header )
|
||||
{
|
||||
assert( declaration->Size < 0xFF );
|
||||
assert( declaration->NrTokens < 0xFF );
|
||||
|
||||
declaration->Size++;
|
||||
declaration->NrTokens++;
|
||||
|
||||
header_bodysize_grow( header );
|
||||
}
|
||||
|
|
@ -308,7 +308,7 @@ tgsi_default_immediate( void )
|
|||
struct tgsi_immediate immediate;
|
||||
|
||||
immediate.Type = TGSI_TOKEN_TYPE_IMMEDIATE;
|
||||
immediate.Size = 1;
|
||||
immediate.NrTokens = 1;
|
||||
immediate.DataType = TGSI_IMM_FLOAT32;
|
||||
immediate.Padding = 0;
|
||||
immediate.Extended = 0;
|
||||
|
|
@ -345,9 +345,9 @@ immediate_grow(
|
|||
struct tgsi_immediate *immediate,
|
||||
struct tgsi_header *header )
|
||||
{
|
||||
assert( immediate->Size < 0xFF );
|
||||
assert( immediate->NrTokens < 0xFF );
|
||||
|
||||
immediate->Size++;
|
||||
immediate->NrTokens++;
|
||||
|
||||
header_bodysize_grow( header );
|
||||
}
|
||||
|
|
@ -384,7 +384,7 @@ tgsi_build_full_immediate(
|
|||
|
||||
*immediate = tgsi_build_immediate( header );
|
||||
|
||||
for( i = 0; i < full_imm->Immediate.Size - 1; i++ ) {
|
||||
for( i = 0; i < full_imm->Immediate.NrTokens - 1; i++ ) {
|
||||
struct tgsi_immediate_float32 *if32;
|
||||
|
||||
if( maxsize <= size )
|
||||
|
|
@ -411,7 +411,7 @@ tgsi_default_instruction( void )
|
|||
struct tgsi_instruction instruction;
|
||||
|
||||
instruction.Type = TGSI_TOKEN_TYPE_INSTRUCTION;
|
||||
instruction.Size = 1;
|
||||
instruction.NrTokens = 1;
|
||||
instruction.Opcode = TGSI_OPCODE_MOV;
|
||||
instruction.Saturate = TGSI_SAT_NONE;
|
||||
instruction.NumDstRegs = 1;
|
||||
|
|
@ -453,9 +453,9 @@ instruction_grow(
|
|||
struct tgsi_instruction *instruction,
|
||||
struct tgsi_header *header )
|
||||
{
|
||||
assert (instruction->Size < 0xFF);
|
||||
assert (instruction->NrTokens < 0xFF);
|
||||
|
||||
instruction->Size++;
|
||||
instruction->NrTokens++;
|
||||
|
||||
header_bodysize_grow( header );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ iter_immediate(
|
|||
ENM( imm->Immediate.DataType, immediate_type_names );
|
||||
|
||||
TXT( " { " );
|
||||
for (i = 0; i < imm->Immediate.Size - 1; i++) {
|
||||
for (i = 0; i < imm->Immediate.NrTokens - 1; i++) {
|
||||
switch (imm->Immediate.DataType) {
|
||||
case TGSI_IMM_FLOAT32:
|
||||
FLT( imm->u.ImmediateFloat32[i].Float );
|
||||
|
|
@ -294,7 +294,7 @@ iter_immediate(
|
|||
assert( 0 );
|
||||
}
|
||||
|
||||
if (i < imm->Immediate.Size - 2)
|
||||
if (i < imm->Immediate.NrTokens - 2)
|
||||
TXT( ", " );
|
||||
}
|
||||
TXT( " }" );
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ dump_immediate_verbose(
|
|||
UIX( imm->Immediate.Padding );
|
||||
}
|
||||
|
||||
for( i = 0; i < imm->Immediate.Size - 1; i++ ) {
|
||||
for( i = 0; i < imm->Immediate.NrTokens - 1; i++ ) {
|
||||
EOL();
|
||||
switch( imm->Immediate.DataType ) {
|
||||
case TGSI_IMM_FLOAT32:
|
||||
|
|
@ -675,7 +675,7 @@ tgsi_dump_c(
|
|||
ENM( parse.FullToken.Token.Type, TGSI_TOKEN_TYPES );
|
||||
if( ignored ) {
|
||||
TXT( "\nSize : " );
|
||||
UID( parse.FullToken.Token.Size );
|
||||
UID( parse.FullToken.Token.NrTokens );
|
||||
if( deflt || parse.FullToken.Token.Extended ) {
|
||||
TXT( "\nExtended : " );
|
||||
UID( parse.FullToken.Token.Extended );
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ tgsi_exec_machine_bind_shader(
|
|||
|
||||
case TGSI_TOKEN_TYPE_IMMEDIATE:
|
||||
{
|
||||
uint size = parse.FullToken.FullImmediate.Immediate.Size - 1;
|
||||
uint size = parse.FullToken.FullImmediate.Immediate.NrTokens - 1;
|
||||
assert( size % 4 == 0 );
|
||||
assert( mach->ImmLimit + size / 4 <= TGSI_EXEC_NUM_IMMEDIATES );
|
||||
|
||||
|
|
|
|||
|
|
@ -155,8 +155,8 @@ tgsi_parse_token(
|
|||
switch (imm->Immediate.DataType) {
|
||||
case TGSI_IMM_FLOAT32:
|
||||
imm->u.Pointer = MALLOC(
|
||||
sizeof( struct tgsi_immediate_float32 ) * (imm->Immediate.Size - 1) );
|
||||
for( i = 0; i < imm->Immediate.Size - 1; i++ ) {
|
||||
sizeof( struct tgsi_immediate_float32 ) * (imm->Immediate.NrTokens - 1) );
|
||||
for( i = 0; i < imm->Immediate.NrTokens - 1; i++ ) {
|
||||
next_token( ctx, (struct tgsi_immediate_float32 *) &imm->u.ImmediateFloat32[i] );
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1327,7 +1327,7 @@ tgsi_emit_ppc(const struct tgsi_token *tokens,
|
|||
case TGSI_TOKEN_TYPE_IMMEDIATE:
|
||||
/* splat each immediate component into a float[4] vector for SoA */
|
||||
{
|
||||
const uint size = parse.FullToken.FullImmediate.Immediate.Size - 1;
|
||||
const uint size = parse.FullToken.FullImmediate.Immediate.NrTokens - 1;
|
||||
uint i;
|
||||
assert(size <= 4);
|
||||
assert(num_immediates < TGSI_EXEC_NUM_IMMEDIATES);
|
||||
|
|
|
|||
|
|
@ -151,7 +151,14 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
|
|||
break;
|
||||
|
||||
case TGSI_TOKEN_TYPE_IMMEDIATE:
|
||||
info->immediate_count++;
|
||||
{
|
||||
uint reg = info->immediate_count++;
|
||||
uint file = TGSI_FILE_IMMEDIATE;
|
||||
|
||||
info->file_mask[file] |= (1 << reg);
|
||||
info->file_count[file]++;
|
||||
info->file_max[file] = MAX2(info->file_max[file], (int)reg);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -2671,7 +2671,7 @@ tgsi_emit_sse2(
|
|||
case TGSI_TOKEN_TYPE_IMMEDIATE:
|
||||
/* simply copy the immediate values into the next immediates[] slot */
|
||||
{
|
||||
const uint size = parse.FullToken.FullImmediate.Immediate.Size - 1;
|
||||
const uint size = parse.FullToken.FullImmediate.Immediate.NrTokens - 1;
|
||||
uint i;
|
||||
assert(size <= 4);
|
||||
assert(num_immediates < TGSI_EXEC_NUM_IMMEDIATES);
|
||||
|
|
|
|||
|
|
@ -1023,7 +1023,7 @@ static boolean parse_immediate( struct translate_ctx *ctx )
|
|||
ctx->cur++;
|
||||
|
||||
imm = tgsi_default_full_immediate();
|
||||
imm.Immediate.Size += 4;
|
||||
imm.Immediate.NrTokens += 4;
|
||||
imm.Immediate.DataType = TGSI_IMM_FLOAT32;
|
||||
imm.u.Pointer = values;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
#include "u_linear.h"
|
||||
|
||||
void
|
||||
pipe_linear_to_tile(size_t src_stride, void *src_ptr,
|
||||
pipe_linear_to_tile(size_t src_stride, const void *src_ptr,
|
||||
struct pipe_tile_info *t, void *dst_ptr)
|
||||
{
|
||||
int x, y, z;
|
||||
char *ptr;
|
||||
size_t bytes = t->cols * t->block.size;
|
||||
|
||||
char *dst_ptr2 = (char *) dst_ptr;
|
||||
|
||||
assert(pipe_linear_check_tile(t));
|
||||
|
||||
|
|
@ -19,20 +19,21 @@ pipe_linear_to_tile(size_t src_stride, void *src_ptr,
|
|||
/* this inner loop could be replace with SSE magic */
|
||||
ptr = (char*)src_ptr + src_stride * t->rows * y + bytes * x;
|
||||
for (z = 0; z < t->rows; z++) {
|
||||
memcpy(dst_ptr, ptr, bytes);
|
||||
dst_ptr += bytes;
|
||||
memcpy(dst_ptr2, ptr, bytes);
|
||||
dst_ptr2 += bytes;
|
||||
ptr += src_stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pipe_linear_from_tile(struct pipe_tile_info *t, void *src_ptr,
|
||||
void pipe_linear_from_tile(struct pipe_tile_info *t, const void *src_ptr,
|
||||
size_t dst_stride, void *dst_ptr)
|
||||
{
|
||||
int x, y, z;
|
||||
char *ptr;
|
||||
size_t bytes = t->cols * t->block.size;
|
||||
const char *src_ptr2 = (const char *) src_ptr;
|
||||
|
||||
/* lets read lineary from the tiled buffer */
|
||||
for (y = 0; y < t->tiles_y; y++) {
|
||||
|
|
@ -40,8 +41,8 @@ void pipe_linear_from_tile(struct pipe_tile_info *t, void *src_ptr,
|
|||
/* this inner loop could be replace with SSE magic */
|
||||
ptr = (char*)dst_ptr + dst_stride * t->rows * y + bytes * x;
|
||||
for (z = 0; z < t->rows; z++) {
|
||||
memcpy(ptr, src_ptr, bytes);
|
||||
src_ptr += bytes;
|
||||
memcpy(ptr, src_ptr2, bytes);
|
||||
src_ptr2 += bytes;
|
||||
ptr += dst_stride;
|
||||
}
|
||||
}
|
||||
|
|
@ -50,7 +51,7 @@ void pipe_linear_from_tile(struct pipe_tile_info *t, void *src_ptr,
|
|||
|
||||
void
|
||||
pipe_linear_fill_info(struct pipe_tile_info *t,
|
||||
struct pipe_format_block *block,
|
||||
const struct pipe_format_block *block,
|
||||
unsigned tile_width, unsigned tile_height,
|
||||
unsigned tiles_x, unsigned tiles_y)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#define U_LINEAR_H
|
||||
|
||||
#include "pipe/p_format.h"
|
||||
|
||||
struct pipe_tile_info
|
||||
{
|
||||
unsigned size;
|
||||
|
|
@ -23,10 +24,10 @@ struct pipe_tile_info
|
|||
struct pipe_format_block block;
|
||||
};
|
||||
|
||||
void pipe_linear_to_tile(size_t src_stride, void *src_ptr,
|
||||
void pipe_linear_to_tile(size_t src_stride, const void *src_ptr,
|
||||
struct pipe_tile_info *t, void *dst_ptr);
|
||||
|
||||
void pipe_linear_from_tile(struct pipe_tile_info *t, void *src_ptr,
|
||||
void pipe_linear_from_tile(struct pipe_tile_info *t, const void *src_ptr,
|
||||
size_t dst_stride, void *dst_ptr);
|
||||
|
||||
/**
|
||||
|
|
@ -39,11 +40,11 @@ void pipe_linear_from_tile(struct pipe_tile_info *t, void *src_ptr,
|
|||
* @tiles_y number of tiles in y axis
|
||||
*/
|
||||
void pipe_linear_fill_info(struct pipe_tile_info *t,
|
||||
struct pipe_format_block *block,
|
||||
const struct pipe_format_block *block,
|
||||
unsigned tile_width, unsigned tile_height,
|
||||
unsigned tiles_x, unsigned tiles_y);
|
||||
|
||||
static INLINE boolean pipe_linear_check_tile(struct pipe_tile_info *t)
|
||||
static INLINE boolean pipe_linear_check_tile(const struct pipe_tile_info *t)
|
||||
{
|
||||
if (t->tile.size != t->block.size * t->cols * t->rows)
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ cell_map_constant_buffers(struct cell_context *sp)
|
|||
struct pipe_winsys *ws = sp->pipe.winsys;
|
||||
uint i;
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (sp->constants[i].size) {
|
||||
if (sp->constants[i].buffer && sp->constants[i].buffer->size) {
|
||||
sp->mapped_constants[i] = ws->buffer_map(ws, sp->constants[i].buffer,
|
||||
PIPE_BUFFER_USAGE_CPU_READ);
|
||||
cell_flush_buffer_range(sp, sp->mapped_constants[i],
|
||||
|
|
@ -61,7 +61,7 @@ cell_map_constant_buffers(struct cell_context *sp)
|
|||
|
||||
draw_set_mapped_constant_buffer(sp->draw,
|
||||
sp->mapped_constants[PIPE_SHADER_VERTEX],
|
||||
sp->constants[PIPE_SHADER_VERTEX].size);
|
||||
sp->constants[PIPE_SHADER_VERTEX].buffer->size);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -70,7 +70,7 @@ cell_unmap_constant_buffers(struct cell_context *sp)
|
|||
struct pipe_winsys *ws = sp->pipe.winsys;
|
||||
uint i;
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (sp->constants[i].size)
|
||||
if (sp->constants[i].buffer && sp->constants[i].buffer->size)
|
||||
ws->buffer_unmap(ws, sp->constants[i].buffer);
|
||||
sp->mapped_constants[i] = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ gen_alpha_test(const struct pipe_depth_stencil_alpha_state *dsa,
|
|||
if ((dsa->alpha.func != PIPE_FUNC_NEVER) &&
|
||||
(dsa->alpha.func != PIPE_FUNC_ALWAYS)) {
|
||||
/* load/splat the alpha reference float value */
|
||||
spe_load_float(f, ref_reg, dsa->alpha.ref);
|
||||
spe_load_float(f, ref_reg, dsa->alpha.ref_value);
|
||||
}
|
||||
|
||||
/* emit code to do the alpha comparison, updating 'mask' */
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ cell_emit_state(struct cell_context *cell)
|
|||
|
||||
if (cell->dirty & (CELL_NEW_FS_CONSTANTS)) {
|
||||
const uint shader = PIPE_SHADER_FRAGMENT;
|
||||
const uint num_const = cell->constants[shader].size / sizeof(float);
|
||||
const uint num_const = cell->constants[shader].buffer->size / sizeof(float);
|
||||
uint i, j;
|
||||
float *buf = cell_batch_alloc16(cell, ROUNDUP16(32 + num_const * sizeof(float)));
|
||||
uint32_t *ibuf = (uint32_t *) buf;
|
||||
|
|
|
|||
|
|
@ -186,7 +186,6 @@ cell_set_constant_buffer(struct pipe_context *pipe,
|
|||
const struct pipe_constant_buffer *buf)
|
||||
{
|
||||
struct cell_context *cell = cell_context(pipe);
|
||||
struct pipe_winsys *ws = pipe->winsys;
|
||||
|
||||
assert(shader < PIPE_SHADER_TYPES);
|
||||
assert(index == 0);
|
||||
|
|
@ -197,7 +196,6 @@ cell_set_constant_buffer(struct pipe_context *pipe,
|
|||
pipe_buffer_reference(pipe->screen,
|
||||
&cell->constants[shader].buffer,
|
||||
buf->buffer);
|
||||
cell->constants[shader].size = buf->size;
|
||||
|
||||
if (shader == PIPE_SHADER_VERTEX)
|
||||
cell->dirty |= CELL_NEW_VS_CONSTANTS;
|
||||
|
|
|
|||
|
|
@ -307,9 +307,8 @@ cell_twiddle_texture(struct pipe_screen *screen,
|
|||
const uint texHeight = ct->base.height[level];
|
||||
const uint bufWidth = align(texWidth, TILE_SIZE);
|
||||
const uint bufHeight = align(texHeight, TILE_SIZE);
|
||||
const void *map = pipe_buffer_map(screen, surface->buffer,
|
||||
PIPE_BUFFER_USAGE_CPU_READ);
|
||||
const uint *src = (const uint *) ((const ubyte *) map + surface->offset);
|
||||
const void *map = screen->surface_map(screen, surface, PIPE_BUFFER_USAGE_CPU_READ);
|
||||
const uint *src = (const uint *) map;
|
||||
|
||||
switch (ct->base.format) {
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
|
|
@ -324,12 +323,12 @@ cell_twiddle_texture(struct pipe_screen *screen,
|
|||
/* allocate buffer for tiled data now */
|
||||
struct pipe_winsys *ws = screen->winsys;
|
||||
uint bytes = bufWidth * bufHeight * 4 * numFaces;
|
||||
ct->tiled_buffer[level] = ws->buffer_create(ws, 16,
|
||||
PIPE_BUFFER_USAGE_PIXEL,
|
||||
bytes);
|
||||
ct->tiled_buffer[level] =
|
||||
ws->buffer_create(ws, 16, PIPE_BUFFER_USAGE_PIXEL, bytes);
|
||||
/* and map it */
|
||||
ct->tiled_mapped[level] = ws->buffer_map(ws, ct->tiled_buffer[level],
|
||||
PIPE_BUFFER_USAGE_GPU_READ);
|
||||
ct->tiled_mapped[level] =
|
||||
ws->buffer_map(ws, ct->tiled_buffer[level],
|
||||
PIPE_BUFFER_USAGE_GPU_READ);
|
||||
}
|
||||
dst = (uint *) ((ubyte *) ct->tiled_mapped[level] + offset);
|
||||
|
||||
|
|
@ -338,11 +337,11 @@ cell_twiddle_texture(struct pipe_screen *screen,
|
|||
}
|
||||
break;
|
||||
default:
|
||||
printf("Cell: twiddle unsupported texture format %s\n", pf_name(ct->base.format));
|
||||
;
|
||||
printf("Cell: twiddle unsupported texture format %s\n",
|
||||
pf_name(ct->base.format));
|
||||
}
|
||||
|
||||
pipe_buffer_unmap(screen, surface->buffer);
|
||||
screen->surface_unmap(screen, surface);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -357,8 +356,7 @@ cell_untwiddle_texture(struct pipe_screen *screen,
|
|||
const uint level = surface->level;
|
||||
const uint texWidth = ct->base.width[level];
|
||||
const uint texHeight = ct->base.height[level];
|
||||
const void *map = pipe_buffer_map(screen, surface->buffer,
|
||||
PIPE_BUFFER_USAGE_CPU_READ);
|
||||
const void *map = screen->surface_map(screen, surface, PIPE_BUFFER_USAGE_CPU_READ);
|
||||
const uint *src = (const uint *) ((const ubyte *) map + surface->offset);
|
||||
|
||||
switch (ct->base.format) {
|
||||
|
|
@ -384,11 +382,12 @@ cell_untwiddle_texture(struct pipe_screen *screen,
|
|||
default:
|
||||
{
|
||||
ct->untiled_data[level] = NULL;
|
||||
printf("Cell: untwiddle unsupported texture format %s\n", pf_name(ct->base.format));
|
||||
printf("Cell: untwiddle unsupported texture format %s\n",
|
||||
pf_name(ct->base.format));
|
||||
}
|
||||
}
|
||||
|
||||
pipe_buffer_unmap(screen, surface->buffer);
|
||||
screen->surface_unmap(screen, surface);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -398,15 +397,13 @@ cell_get_tex_surface(struct pipe_screen *screen,
|
|||
unsigned face, unsigned level, unsigned zslice,
|
||||
unsigned usage)
|
||||
{
|
||||
struct pipe_winsys *ws = screen->winsys;
|
||||
struct cell_texture *ct = cell_texture(pt);
|
||||
struct pipe_surface *ps;
|
||||
|
||||
ps = ws->surface_alloc(ws);
|
||||
ps = CALLOC_STRUCT(pipe_surface);
|
||||
if (ps) {
|
||||
assert(ps->refcount);
|
||||
assert(ps->winsys);
|
||||
pipe_buffer_reference(screen, &ps->buffer, ct->buffer);
|
||||
ps->refcount = 1;
|
||||
pipe_texture_reference(&ps->texture, pt);
|
||||
ps->format = pt->format;
|
||||
ps->block = pt->block;
|
||||
ps->width = pt->width[level];
|
||||
|
|
@ -425,9 +422,9 @@ cell_get_tex_surface(struct pipe_screen *screen,
|
|||
ps->zslice = zslice;
|
||||
|
||||
if (pt->target == PIPE_TEXTURE_CUBE || pt->target == PIPE_TEXTURE_3D) {
|
||||
ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) *
|
||||
ps->nblocksy *
|
||||
ps->stride;
|
||||
ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) *
|
||||
ps->nblocksy *
|
||||
ps->stride;
|
||||
}
|
||||
else {
|
||||
assert(face == 0);
|
||||
|
|
@ -449,18 +446,27 @@ cell_tex_surface_release(struct pipe_screen *screen,
|
|||
{
|
||||
struct cell_texture *ct = cell_texture((*s)->texture);
|
||||
const uint level = (*s)->level;
|
||||
struct pipe_surface *surf = *s;
|
||||
|
||||
if (((*s)->usage & PIPE_BUFFER_USAGE_CPU_READ) && (ct->untiled_data[level]))
|
||||
if ((surf->usage & PIPE_BUFFER_USAGE_CPU_READ) && (ct->untiled_data[level]))
|
||||
{
|
||||
align_free(ct->untiled_data[level]);
|
||||
ct->untiled_data[level] = NULL;
|
||||
}
|
||||
|
||||
if ((ct->base.tex_usage & PIPE_TEXTURE_USAGE_SAMPLER) &&
|
||||
(surf->usage & PIPE_BUFFER_USAGE_CPU_WRITE)) {
|
||||
/* convert from linear to tiled layout */
|
||||
cell_twiddle_texture(screen, surf);
|
||||
}
|
||||
|
||||
/* XXX if done rendering to teximage, re-tile */
|
||||
|
||||
pipe_texture_reference(&(*s)->texture, NULL);
|
||||
|
||||
screen->winsys->surface_release(screen->winsys, s);
|
||||
if (--surf->refcount == 0) {
|
||||
pipe_texture_reference(&surf->texture, NULL);
|
||||
FREE(surf);
|
||||
}
|
||||
*s = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -475,17 +481,20 @@ cell_surface_map(struct pipe_screen *screen,
|
|||
|
||||
assert(ct);
|
||||
|
||||
#if 0
|
||||
if (flags & ~surface->usage) {
|
||||
assert(0);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
map = pipe_buffer_map( screen, surface->buffer, flags );
|
||||
if (map == NULL)
|
||||
map = pipe_buffer_map( screen, ct->buffer, flags );
|
||||
if (map == NULL) {
|
||||
return NULL;
|
||||
else
|
||||
{
|
||||
if ((surface->usage & PIPE_BUFFER_USAGE_CPU_READ) && (ct->untiled_data[level])) {
|
||||
}
|
||||
else {
|
||||
if ((surface->usage & PIPE_BUFFER_USAGE_CPU_READ) &&
|
||||
(ct->untiled_data[level])) {
|
||||
return (void *) ((ubyte *) ct->untiled_data[level] + surface->offset);
|
||||
}
|
||||
else {
|
||||
|
|
@ -503,13 +512,7 @@ cell_surface_unmap(struct pipe_screen *screen,
|
|||
|
||||
assert(ct);
|
||||
|
||||
if ((ct->base.tex_usage & PIPE_TEXTURE_USAGE_SAMPLER) &&
|
||||
(surface->usage & PIPE_BUFFER_USAGE_CPU_WRITE)) {
|
||||
/* convert from linear to tiled layout */
|
||||
cell_twiddle_texture(screen, surface);
|
||||
}
|
||||
|
||||
pipe_buffer_unmap( screen, surface->buffer );
|
||||
pipe_buffer_unmap( screen, ct->buffer );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,9 +33,10 @@ OLD_SOURCES = \
|
|||
spu_vertex_shader.c
|
||||
|
||||
|
||||
SPU_OBJECTS = $(SOURCES:.c=.o) \
|
||||
SPU_OBJECTS = $(SOURCES:.c=.o)
|
||||
|
||||
SPU_ASM_OUT = $(SOURCES:.c=.s)
|
||||
|
||||
SPU_ASM_OUT = $(SOURCES:.c=.s) \
|
||||
|
||||
INCLUDE_DIRS = \
|
||||
-I$(TOP)/src/mesa \
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ spu_fallback_fragment_ops(uint x, uint y,
|
|||
* Do alpha test
|
||||
*/
|
||||
if (spu.depth_stencil_alpha.alpha.enabled) {
|
||||
vector float ref = spu_splats(spu.depth_stencil_alpha.alpha.ref);
|
||||
vector float ref = spu_splats(spu.depth_stencil_alpha.alpha.ref_value);
|
||||
vector unsigned int amask;
|
||||
|
||||
switch (spu.depth_stencil_alpha.alpha.func) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
* Triangle rendering within a tile.
|
||||
*/
|
||||
|
||||
#include <transpose_matrix4x4.h>
|
||||
#include "pipe/p_compiler.h"
|
||||
#include "pipe/p_format.h"
|
||||
#include "util/u_math.h"
|
||||
|
|
@ -71,6 +70,12 @@ struct vertex_header {
|
|||
#define MASK_ALL 0xf
|
||||
|
||||
|
||||
#define CHAN0 0
|
||||
#define CHAN1 1
|
||||
#define CHAN2 2
|
||||
#define CHAN3 3
|
||||
|
||||
|
||||
#define DEBUG_VERTS 0
|
||||
|
||||
/**
|
||||
|
|
@ -144,102 +149,100 @@ struct setup_stage {
|
|||
static struct setup_stage setup;
|
||||
|
||||
|
||||
/**
|
||||
* Evaluate attribute coefficients (plane equations) to compute
|
||||
* attribute values for the four fragments in a quad.
|
||||
* Eg: four colors will be computed (in AoS format).
|
||||
*/
|
||||
static INLINE void
|
||||
eval_coeff(uint slot, float x, float y, vector float w, vector float result[4])
|
||||
static INLINE vector float
|
||||
splatx(vector float v)
|
||||
{
|
||||
switch (spu.vertex_info.attrib[slot].interp_mode) {
|
||||
case INTERP_CONSTANT:
|
||||
result[QUAD_TOP_LEFT] =
|
||||
result[QUAD_TOP_RIGHT] =
|
||||
result[QUAD_BOTTOM_LEFT] =
|
||||
result[QUAD_BOTTOM_RIGHT] = setup.coef[slot].a0;
|
||||
break;
|
||||
case INTERP_LINEAR:
|
||||
{
|
||||
vector float dadx = setup.coef[slot].dadx;
|
||||
vector float dady = setup.coef[slot].dady;
|
||||
vector float topLeft =
|
||||
spu_add(setup.coef[slot].a0,
|
||||
spu_add(spu_mul(spu_splats(x), dadx),
|
||||
spu_mul(spu_splats(y), dady)));
|
||||
return spu_splats(spu_extract(v, CHAN0));
|
||||
}
|
||||
|
||||
result[QUAD_TOP_LEFT] = topLeft;
|
||||
result[QUAD_TOP_RIGHT] = spu_add(topLeft, dadx);
|
||||
result[QUAD_BOTTOM_LEFT] = spu_add(topLeft, dady);
|
||||
result[QUAD_BOTTOM_RIGHT] = spu_add(spu_add(topLeft, dadx), dady);
|
||||
static INLINE vector float
|
||||
splaty(vector float v)
|
||||
{
|
||||
return spu_splats(spu_extract(v, CHAN1));
|
||||
}
|
||||
|
||||
static INLINE vector float
|
||||
splatz(vector float v)
|
||||
{
|
||||
return spu_splats(spu_extract(v, CHAN2));
|
||||
}
|
||||
|
||||
static INLINE vector float
|
||||
splatw(vector float v)
|
||||
{
|
||||
return spu_splats(spu_extract(v, CHAN3));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setup fragment shader inputs by evaluating triangle's vertex
|
||||
* attribute coefficient info.
|
||||
* \param x quad x pos
|
||||
* \param y quad y pos
|
||||
* \param fragZ returns quad Z values
|
||||
* \param fragInputs returns fragment program inputs
|
||||
* Note: this code could be incorporated into the fragment program
|
||||
* itself to avoid the loop and switch.
|
||||
*/
|
||||
static void
|
||||
eval_inputs(float x, float y, vector float *fragZ, vector float fragInputs[])
|
||||
{
|
||||
static const vector float deltaX = (const vector float) {0, 1, 0, 1};
|
||||
static const vector float deltaY = (const vector float) {0, 0, 1, 1};
|
||||
|
||||
const uint posSlot = 0;
|
||||
const vector float pos = setup.coef[posSlot].a0;
|
||||
const vector float dposdx = setup.coef[posSlot].dadx;
|
||||
const vector float dposdy = setup.coef[posSlot].dady;
|
||||
const vector float fragX = spu_splats(x) + deltaX;
|
||||
const vector float fragY = spu_splats(y) + deltaY;
|
||||
vector float fragW, wInv;
|
||||
uint i;
|
||||
|
||||
*fragZ = splatz(pos) + fragX * splatz(dposdx) + fragY * splatz(dposdy);
|
||||
fragW = splatw(pos) + fragX * splatw(dposdx) + fragY * splatw(dposdy);
|
||||
wInv = spu_re(fragW); /* 1 / w */
|
||||
|
||||
/* loop over fragment program inputs */
|
||||
for (i = 0; i < spu.vertex_info.num_attribs; i++) {
|
||||
uint attr = i + 1;
|
||||
enum interp_mode interp = spu.vertex_info.attrib[attr].interp_mode;
|
||||
|
||||
/* constant term */
|
||||
vector float a0 = setup.coef[attr].a0;
|
||||
vector float r0 = splatx(a0);
|
||||
vector float r1 = splaty(a0);
|
||||
vector float r2 = splatz(a0);
|
||||
vector float r3 = splatw(a0);
|
||||
|
||||
if (interp == INTERP_LINEAR || interp == INTERP_PERSPECTIVE) {
|
||||
/* linear term */
|
||||
vector float dadx = setup.coef[attr].dadx;
|
||||
vector float dady = setup.coef[attr].dady;
|
||||
/* Use SPU intrinsics here to get slightly better code.
|
||||
* originally: r0 += fragX * splatx(dadx) + fragY * splatx(dady);
|
||||
*/
|
||||
r0 = spu_madd(fragX, splatx(dadx), spu_madd(fragY, splatx(dady), r0));
|
||||
r1 = spu_madd(fragX, splaty(dadx), spu_madd(fragY, splaty(dady), r1));
|
||||
r2 = spu_madd(fragX, splatz(dadx), spu_madd(fragY, splatz(dady), r2));
|
||||
r3 = spu_madd(fragX, splatw(dadx), spu_madd(fragY, splatw(dady), r3));
|
||||
if (interp == INTERP_PERSPECTIVE) {
|
||||
/* perspective term */
|
||||
r0 *= wInv;
|
||||
r1 *= wInv;
|
||||
r2 *= wInv;
|
||||
r3 *= wInv;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case INTERP_PERSPECTIVE:
|
||||
{
|
||||
vector float dadx = setup.coef[slot].dadx;
|
||||
vector float dady = setup.coef[slot].dady;
|
||||
vector float topLeft =
|
||||
spu_add(setup.coef[slot].a0,
|
||||
spu_add(spu_mul(spu_splats(x), dadx),
|
||||
spu_mul(spu_splats(y), dady)));
|
||||
|
||||
vector float wInv = spu_re(w); /* 1.0 / w */
|
||||
|
||||
result[QUAD_TOP_LEFT] = spu_mul(topLeft, wInv);
|
||||
result[QUAD_TOP_RIGHT] = spu_mul(spu_add(topLeft, dadx), wInv);
|
||||
result[QUAD_BOTTOM_LEFT] = spu_mul(spu_add(topLeft, dady), wInv);
|
||||
result[QUAD_BOTTOM_RIGHT] = spu_mul(spu_add(spu_add(topLeft, dadx), dady), wInv);
|
||||
}
|
||||
break;
|
||||
case INTERP_POS:
|
||||
case INTERP_NONE:
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
fragInputs[CHAN0] = r0;
|
||||
fragInputs[CHAN1] = r1;
|
||||
fragInputs[CHAN2] = r2;
|
||||
fragInputs[CHAN3] = r3;
|
||||
fragInputs += 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* As above, but return 4 vectors in SOA format.
|
||||
* XXX this will all be re-written someday.
|
||||
*/
|
||||
static INLINE void
|
||||
eval_coeff_soa(uint slot, float x, float y, vector float w, vector float result[4])
|
||||
{
|
||||
eval_coeff(slot, x, y, w, result);
|
||||
_transpose_matrix4x4(result, result);
|
||||
}
|
||||
|
||||
|
||||
/** Evalute coefficients to get Z for four pixels in a quad */
|
||||
static INLINE vector float
|
||||
eval_z(float x, float y)
|
||||
{
|
||||
const uint slot = 0;
|
||||
const float dzdx = spu_extract(setup.coef[slot].dadx, 2);
|
||||
const float dzdy = spu_extract(setup.coef[slot].dady, 2);
|
||||
const float topLeft = spu_extract(setup.coef[slot].a0, 2) + x * dzdx + y * dzdy;
|
||||
const vector float topLeftv = spu_splats(topLeft);
|
||||
const vector float derivs = (vector float) { 0.0, dzdx, dzdy, dzdx + dzdy };
|
||||
return spu_add(topLeftv, derivs);
|
||||
}
|
||||
|
||||
|
||||
/** Evalute coefficients to get W for four pixels in a quad */
|
||||
static INLINE vector float
|
||||
eval_w(float x, float y)
|
||||
{
|
||||
const uint slot = 0;
|
||||
const float dwdx = spu_extract(setup.coef[slot].dadx, 3);
|
||||
const float dwdy = spu_extract(setup.coef[slot].dady, 3);
|
||||
const float topLeft = spu_extract(setup.coef[slot].a0, 3) + x * dwdx + y * dwdy;
|
||||
const vector float topLeftv = spu_splats(topLeft);
|
||||
const vector float derivs = (vector float) { 0.0, dwdx, dwdy, dwdx + dwdy };
|
||||
return spu_add(topLeftv, derivs);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Emit a quad (pass to next stage). No clipping is done.
|
||||
* Note: about 1/5 to 1/7 of the time, mask is zero and this function
|
||||
|
|
@ -262,19 +265,11 @@ emit_quad( int x, int y, mask_t mask)
|
|||
* Run fragment shader, execute per-fragment ops, update fb/tile.
|
||||
*/
|
||||
vector float inputs[4*4], outputs[2*4];
|
||||
vector float fragZ = eval_z((float) x, (float) y);
|
||||
vector float fragW = eval_w((float) x, (float) y);
|
||||
vector unsigned int kill_mask;
|
||||
vector float fragZ;
|
||||
|
||||
eval_inputs((float) x, (float) y, &fragZ, inputs);
|
||||
|
||||
/* setup inputs */
|
||||
#if 0
|
||||
eval_coeff_soa(1, (float) x, (float) y, fragW, inputs);
|
||||
#else
|
||||
uint i;
|
||||
for (i = 0; i < spu.vertex_info.num_attribs; i++) {
|
||||
eval_coeff_soa(i+1, (float) x, (float) y, fragW, inputs + i * 4);
|
||||
}
|
||||
#endif
|
||||
ASSERT(spu.fragment_program);
|
||||
ASSERT(spu.fragment_ops);
|
||||
|
||||
|
|
|
|||
|
|
@ -964,7 +964,7 @@ i915_translate_instructions(struct i915_fp_compile *p,
|
|||
= &parse.FullToken.FullImmediate;
|
||||
const uint pos = p->num_immediates++;
|
||||
uint j;
|
||||
for (j = 0; j < imm->Immediate.Size; j++) {
|
||||
for (j = 0; j < imm->Immediate.NrTokens - 1; j++) {
|
||||
p->immediates[pos][j] = imm->u.ImmediateFloat32[j].Float;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1293,7 +1293,7 @@ void brw_vs_emit(struct brw_vs_compile *c)
|
|||
break;
|
||||
case TGSI_TOKEN_TYPE_IMMEDIATE: {
|
||||
struct tgsi_full_immediate *imm = &parse.FullToken.FullImmediate;
|
||||
/*assert(imm->Immediate.Size == 4);*/
|
||||
assert(imm->Immediate.NrTokens == 4 + 1);
|
||||
c->prog_data.imm_buf[c->prog_data.num_imm][0] = imm->u.ImmediateFloat32[0].Float;
|
||||
c->prog_data.imm_buf[c->prog_data.num_imm][1] = imm->u.ImmediateFloat32[1].Float;
|
||||
c->prog_data.imm_buf[c->prog_data.num_imm][2] = imm->u.ImmediateFloat32[2].Float;
|
||||
|
|
|
|||
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007 Nouveau Project
|
||||
*
|
||||
* 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 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 __NOUVEAU_BO_H__
|
||||
#define __NOUVEAU_BO_H__
|
||||
|
||||
/* Relocation/Buffer type flags */
|
||||
#define NOUVEAU_BO_VRAM (1 << 0)
|
||||
#define NOUVEAU_BO_GART (1 << 1)
|
||||
#define NOUVEAU_BO_RD (1 << 2)
|
||||
#define NOUVEAU_BO_WR (1 << 3)
|
||||
#define NOUVEAU_BO_RDWR (NOUVEAU_BO_RD | NOUVEAU_BO_WR)
|
||||
#define NOUVEAU_BO_MAP (1 << 4)
|
||||
#define NOUVEAU_BO_PIN (1 << 5)
|
||||
#define NOUVEAU_BO_LOW (1 << 6)
|
||||
#define NOUVEAU_BO_HIGH (1 << 7)
|
||||
#define NOUVEAU_BO_OR (1 << 8)
|
||||
#define NOUVEAU_BO_LOCAL (1 << 9)
|
||||
#define NOUVEAU_BO_TILED (1 << 10)
|
||||
#define NOUVEAU_BO_ZTILE (1 << 11)
|
||||
#define NOUVEAU_BO_DUMMY (1 << 31)
|
||||
|
||||
struct nouveau_bo {
|
||||
struct nouveau_device *device;
|
||||
uint64_t handle;
|
||||
|
||||
uint64_t size;
|
||||
void *map;
|
||||
|
||||
uint32_t flags;
|
||||
uint64_t offset;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007 Nouveau Project
|
||||
*
|
||||
* 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 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 __NOUVEAU_CHANNEL_H__
|
||||
#define __NOUVEAU_CHANNEL_H__
|
||||
|
||||
struct nouveau_channel {
|
||||
struct nouveau_device *device;
|
||||
int id;
|
||||
|
||||
struct nouveau_pushbuf *pushbuf;
|
||||
|
||||
struct nouveau_grobj *nullobj;
|
||||
struct nouveau_grobj *vram;
|
||||
struct nouveau_grobj *gart;
|
||||
|
||||
void *user_private;
|
||||
void (*hang_notify)(struct nouveau_channel *);
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007 Nouveau Project
|
||||
*
|
||||
* 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 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 __NOUVEAU_DEVICE_H__
|
||||
#define __NOUVEAU_DEVICE_H__
|
||||
|
||||
struct nouveau_device {
|
||||
unsigned chipset;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007 Nouveau Project
|
||||
*
|
||||
* 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 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 __NOUVEAU_GROBJ_H__
|
||||
#define __NOUVEAU_GROBJ_H__
|
||||
|
||||
#include "nouveau_channel.h"
|
||||
|
||||
struct nouveau_grobj {
|
||||
struct nouveau_channel *channel;
|
||||
int grclass;
|
||||
uint32_t handle;
|
||||
int subc;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007 Nouveau Project
|
||||
*
|
||||
* 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 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 __NOUVEAU_NOTIFIER_H__
|
||||
#define __NOUVEAU_NOTIFIER_H__
|
||||
|
||||
#define NV_NOTIFIER_SIZE 32
|
||||
#define NV_NOTIFY_TIME_0 0x00000000
|
||||
#define NV_NOTIFY_TIME_1 0x00000004
|
||||
#define NV_NOTIFY_RETURN_VALUE 0x00000008
|
||||
#define NV_NOTIFY_STATE 0x0000000C
|
||||
#define NV_NOTIFY_STATE_STATUS_MASK 0xFF000000
|
||||
#define NV_NOTIFY_STATE_STATUS_SHIFT 24
|
||||
#define NV_NOTIFY_STATE_STATUS_COMPLETED 0x00
|
||||
#define NV_NOTIFY_STATE_STATUS_IN_PROCESS 0x01
|
||||
#define NV_NOTIFY_STATE_ERROR_CODE_MASK 0x0000FFFF
|
||||
#define NV_NOTIFY_STATE_ERROR_CODE_SHIFT 0
|
||||
|
||||
struct nouveau_notifier {
|
||||
struct nouveau_channel *channel;
|
||||
uint32_t handle;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007 Nouveau Project
|
||||
*
|
||||
* 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 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 __NOUVEAU_PUSHBUF_H__
|
||||
#define __NOUVEAU_PUSHBUF_H__
|
||||
|
||||
struct nouveau_pushbuf {
|
||||
struct nouveau_channel *channel;
|
||||
unsigned remaining;
|
||||
uint32_t *cur;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007 Nouveau Project
|
||||
*
|
||||
* 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 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 __NOUVEAU_RESOURCE_H__
|
||||
#define __NOUVEAU_RESOURCE_H__
|
||||
|
||||
struct nouveau_resource {
|
||||
struct nouveau_resource *prev;
|
||||
struct nouveau_resource *next;
|
||||
|
||||
int in_use;
|
||||
void *priv;
|
||||
|
||||
unsigned int start;
|
||||
unsigned int size;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -147,8 +147,9 @@ so_emit_reloc_markers(struct nouveau_winsys *nvws, struct nouveau_stateobj *so)
|
|||
struct nouveau_stateobj_reloc *r = &so->reloc[i];
|
||||
|
||||
nvws->push_reloc(nvws, pb->cur++, r->bo, r->packet,
|
||||
(r->flags &
|
||||
(NOUVEAU_BO_VRAM | NOUVEAU_BO_GART)) |
|
||||
(r->flags & (NOUVEAU_BO_VRAM |
|
||||
NOUVEAU_BO_GART |
|
||||
NOUVEAU_BO_RDWR)) |
|
||||
NOUVEAU_BO_DUMMY, 0, 0);
|
||||
nvws->push_reloc(nvws, pb->cur++, r->bo, r->data,
|
||||
r->flags | NOUVEAU_BO_DUMMY, r->vor, r->tor);
|
||||
|
|
|
|||
|
|
@ -50,13 +50,15 @@ struct nouveau_winsys {
|
|||
uint32_t (*notifier_status)(struct nouveau_notifier *, int id);
|
||||
uint32_t (*notifier_retval)(struct nouveau_notifier *, int id);
|
||||
int (*notifier_wait)(struct nouveau_notifier *, int id,
|
||||
int status, int timeout);
|
||||
int status, double timeout);
|
||||
|
||||
int (*surface_copy)(struct nouveau_winsys *, struct pipe_surface *,
|
||||
unsigned, unsigned, struct pipe_surface *,
|
||||
unsigned, unsigned, unsigned, unsigned);
|
||||
int (*surface_fill)(struct nouveau_winsys *, struct pipe_surface *,
|
||||
unsigned, unsigned, unsigned, unsigned, unsigned);
|
||||
|
||||
struct nouveau_bo *(*get_bo)(struct pipe_buffer *);
|
||||
};
|
||||
|
||||
extern struct pipe_screen *
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ include $(TOP)/configs/current
|
|||
LIBNAME = nv04
|
||||
|
||||
DRIVER_SOURCES = \
|
||||
nv04_surface_2d.c \
|
||||
nv04_clear.c \
|
||||
nv04_context.c \
|
||||
nv04_fragprog.c \
|
||||
|
|
|
|||
|
|
@ -69,6 +69,31 @@ nv04_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
|
|||
return &mt->base;
|
||||
}
|
||||
|
||||
static struct pipe_texture *
|
||||
nv04_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
|
||||
const unsigned *stride, struct pipe_buffer *pb)
|
||||
{
|
||||
struct nv04_miptree *mt;
|
||||
|
||||
/* Only supports 2D, non-mipmapped textures for the moment */
|
||||
if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
|
||||
pt->depth[0] != 1)
|
||||
return NULL;
|
||||
|
||||
mt = CALLOC_STRUCT(nv04_miptree);
|
||||
if (!mt)
|
||||
return NULL;
|
||||
|
||||
mt->base = *pt;
|
||||
mt->base.refcount = 1;
|
||||
mt->base.screen = pscreen;
|
||||
mt->level[0].pitch = stride[0];
|
||||
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
|
||||
|
||||
pipe_buffer_reference(pscreen, &mt->buffer, pb);
|
||||
return &mt->base;
|
||||
}
|
||||
|
||||
static void
|
||||
nv04_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
|
||||
{
|
||||
|
|
@ -144,6 +169,7 @@ void
|
|||
nv04_screen_init_miptree_functions(struct pipe_screen *pscreen)
|
||||
{
|
||||
pscreen->texture_create = nv04_miptree_create;
|
||||
pscreen->texture_blanket = nv04_miptree_blanket;
|
||||
pscreen->texture_release = nv04_miptree_release;
|
||||
pscreen->get_tex_surface = nv04_miptree_surface_new;
|
||||
pscreen->tex_surface_release = nv04_miptree_surface_del;
|
||||
|
|
|
|||
|
|
@ -149,10 +149,19 @@ nv04_screen_destroy(struct pipe_screen *pscreen)
|
|||
|
||||
nvws->notifier_free(&screen->sync);
|
||||
nvws->grobj_free(&screen->fahrenheit);
|
||||
nv04_surface_2d_takedown(&screen->eng2d);
|
||||
|
||||
FREE(pscreen);
|
||||
}
|
||||
|
||||
static struct pipe_buffer *
|
||||
nv04_surface_buffer(struct pipe_surface *surf)
|
||||
{
|
||||
struct nv04_miptree *mt = (struct nv04_miptree *)surf->texture;
|
||||
|
||||
return mt->buffer;
|
||||
}
|
||||
|
||||
struct pipe_screen *
|
||||
nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
|
||||
{
|
||||
|
|
@ -181,6 +190,10 @@ nv04_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* 2D engine setup */
|
||||
screen->eng2d = nv04_surface_2d_init(nvws);
|
||||
screen->eng2d->buf = nv04_surface_buffer;
|
||||
|
||||
/* 3D object */
|
||||
ret = nvws->grobj_alloc(nvws, fahrenheit_class, &screen->fahrenheit);
|
||||
if (ret) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define __NV04_SCREEN_H__
|
||||
|
||||
#include "pipe/p_screen.h"
|
||||
#include "nv04_surface_2d.h"
|
||||
|
||||
struct nv04_screen {
|
||||
struct pipe_screen pipe;
|
||||
|
|
@ -10,6 +11,7 @@ struct nv04_screen {
|
|||
unsigned chipset;
|
||||
|
||||
/* HW graphics objects */
|
||||
struct nv04_surface_2d *eng2d;
|
||||
struct nouveau_grobj *fahrenheit;
|
||||
struct nouveau_grobj *context_surfaces_3d;
|
||||
struct nouveau_notifier *sync;
|
||||
|
|
|
|||
|
|
@ -39,10 +39,18 @@ nv04_surface_copy(struct pipe_context *pipe, boolean do_flip,
|
|||
unsigned width, unsigned height)
|
||||
{
|
||||
struct nv04_context *nv04 = nv04_context(pipe);
|
||||
struct nouveau_winsys *nvws = nv04->nvws;
|
||||
struct nv04_surface_2d *eng2d = nv04->screen->eng2d;
|
||||
|
||||
nvws->surface_copy(nvws, dest, destx, desty, src, srcx, srcy,
|
||||
width, height);
|
||||
if (do_flip) {
|
||||
desty += height;
|
||||
while (height--) {
|
||||
eng2d->copy(eng2d, dest, destx, desty--, src,
|
||||
srcx, srcy++, width, 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -51,9 +59,9 @@ nv04_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
|
|||
unsigned height, unsigned value)
|
||||
{
|
||||
struct nv04_context *nv04 = nv04_context(pipe);
|
||||
struct nouveau_winsys *nvws = nv04->nvws;
|
||||
struct nv04_surface_2d *eng2d = nv04->screen->eng2d;
|
||||
|
||||
nvws->surface_fill(nvws, dest, destx, desty, width, height, value);
|
||||
eng2d->fill(eng2d, dest, destx, desty, width, height, value);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
448
src/gallium/drivers/nv04/nv04_surface_2d.c
Normal file
448
src/gallium/drivers/nv04/nv04_surface_2d.c
Normal file
|
|
@ -0,0 +1,448 @@
|
|||
#include "pipe/p_context.h"
|
||||
#include "pipe/p_format.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
#include "nouveau/nouveau_winsys.h"
|
||||
#include "nouveau/nouveau_util.h"
|
||||
#include "nv04_surface_2d.h"
|
||||
|
||||
static INLINE int
|
||||
nv04_surface_format(enum pipe_format format)
|
||||
{
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_A8_UNORM:
|
||||
return NV04_CONTEXT_SURFACES_2D_FORMAT_Y8;
|
||||
case PIPE_FORMAT_R16_SNORM:
|
||||
case PIPE_FORMAT_R5G6B5_UNORM:
|
||||
return NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5;
|
||||
case PIPE_FORMAT_X8R8G8B8_UNORM:
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
return NV04_CONTEXT_SURFACES_2D_FORMAT_A8R8G8B8;
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
return NV04_CONTEXT_SURFACES_2D_FORMAT_Y32;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE int
|
||||
nv04_rect_format(enum pipe_format format)
|
||||
{
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_A8_UNORM:
|
||||
return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
|
||||
case PIPE_FORMAT_R5G6B5_UNORM:
|
||||
return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5;
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE int
|
||||
nv04_scaled_image_format(enum pipe_format format)
|
||||
{
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_A1R5G5B5_UNORM:
|
||||
return NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A1R5G5B5;
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
return NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A8R8G8B8;
|
||||
case PIPE_FORMAT_X8R8G8B8_UNORM:
|
||||
return NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_X8R8G8B8;
|
||||
case PIPE_FORMAT_R5G6B5_UNORM:
|
||||
case PIPE_FORMAT_R16_SNORM:
|
||||
return NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_R5G6B5;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE unsigned
|
||||
nv04_swizzle_bits(unsigned x, unsigned y)
|
||||
{
|
||||
unsigned u = (x & 0x001) << 0 |
|
||||
(x & 0x002) << 1 |
|
||||
(x & 0x004) << 2 |
|
||||
(x & 0x008) << 3 |
|
||||
(x & 0x010) << 4 |
|
||||
(x & 0x020) << 5 |
|
||||
(x & 0x040) << 6 |
|
||||
(x & 0x080) << 7 |
|
||||
(x & 0x100) << 8 |
|
||||
(x & 0x200) << 9 |
|
||||
(x & 0x400) << 10 |
|
||||
(x & 0x800) << 11;
|
||||
|
||||
unsigned v = (y & 0x001) << 1 |
|
||||
(y & 0x002) << 2 |
|
||||
(y & 0x004) << 3 |
|
||||
(y & 0x008) << 4 |
|
||||
(y & 0x010) << 5 |
|
||||
(y & 0x020) << 6 |
|
||||
(y & 0x040) << 7 |
|
||||
(y & 0x080) << 8 |
|
||||
(y & 0x100) << 9 |
|
||||
(y & 0x200) << 10 |
|
||||
(y & 0x400) << 11 |
|
||||
(y & 0x800) << 12;
|
||||
return v | u;
|
||||
}
|
||||
|
||||
static int
|
||||
nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
|
||||
struct pipe_surface *dst, int dx, int dy,
|
||||
struct pipe_surface *src, int sx, int sy,
|
||||
int w, int h)
|
||||
{
|
||||
struct nouveau_channel *chan = ctx->nvws->channel;
|
||||
struct nouveau_grobj *swzsurf = ctx->swzsurf;
|
||||
struct nouveau_grobj *sifm = ctx->sifm;
|
||||
struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src));
|
||||
struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst));
|
||||
const unsigned max_w = 1024;
|
||||
const unsigned max_h = 1024;
|
||||
const unsigned sub_w = w > max_w ? max_w : w;
|
||||
const unsigned sub_h = h > max_h ? max_h : h;
|
||||
unsigned cx;
|
||||
unsigned cy;
|
||||
|
||||
/* POT or GTFO */
|
||||
assert(!(w & (w - 1)) && !(h & (h - 1)));
|
||||
|
||||
BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_DMA_IMAGE, 1);
|
||||
OUT_RELOCo(chan, dst_bo,
|
||||
NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
|
||||
BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_FORMAT, 1);
|
||||
OUT_RING (chan, nv04_surface_format(dst->format) |
|
||||
log2i(w) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_U_SHIFT |
|
||||
log2i(h) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_V_SHIFT);
|
||||
|
||||
BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_DMA_IMAGE, 1);
|
||||
OUT_RELOCo(chan, src_bo,
|
||||
NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
|
||||
BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_SURFACE, 1);
|
||||
OUT_RING (chan, swzsurf->handle);
|
||||
|
||||
for (cy = 0; cy < h; cy += sub_h) {
|
||||
for (cx = 0; cx < w; cx += sub_w) {
|
||||
BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_OFFSET, 1);
|
||||
OUT_RELOCl(chan, dst_bo, dst->offset + nv04_swizzle_bits(cx, cy) *
|
||||
dst->block.size, NOUVEAU_BO_GART |
|
||||
NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
|
||||
BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 9);
|
||||
OUT_RING (chan, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE);
|
||||
OUT_RING (chan, nv04_scaled_image_format(src->format));
|
||||
OUT_RING (chan, NV04_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY);
|
||||
OUT_RING (chan, 0);
|
||||
OUT_RING (chan, sub_h << 16 | sub_w);
|
||||
OUT_RING (chan, 0);
|
||||
OUT_RING (chan, sub_h << 16 | sub_w);
|
||||
OUT_RING (chan, 1 << 20);
|
||||
OUT_RING (chan, 1 << 20);
|
||||
|
||||
BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_SIZE, 4);
|
||||
OUT_RING (chan, sub_h << 16 | sub_w);
|
||||
OUT_RING (chan, src->stride |
|
||||
NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER |
|
||||
NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE);
|
||||
OUT_RELOCl(chan, src_bo, src->offset + cy * src->stride +
|
||||
cx * src->block.size, NOUVEAU_BO_GART |
|
||||
NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
|
||||
OUT_RING (chan, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx,
|
||||
struct pipe_surface *dst, int dx, int dy,
|
||||
struct pipe_surface *src, int sx, int sy, int w, int h)
|
||||
{
|
||||
struct nouveau_channel *chan = ctx->nvws->channel;
|
||||
struct nouveau_grobj *m2mf = ctx->m2mf;
|
||||
struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src));
|
||||
struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst));
|
||||
unsigned dst_offset, src_offset;
|
||||
|
||||
dst_offset = dst->offset + (dy * dst->stride) + (dx * dst->block.size);
|
||||
src_offset = src->offset + (sy * src->stride) + (sx * src->block.size);
|
||||
|
||||
WAIT_RING (chan, 3 + ((h / 2047) + 1) * 9);
|
||||
BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_BUFFER_IN, 2);
|
||||
OUT_RELOCo(chan, src_bo,
|
||||
NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
|
||||
OUT_RELOCo(chan, dst_bo,
|
||||
NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
|
||||
while (h) {
|
||||
int count = (h > 2047) ? 2047 : h;
|
||||
|
||||
BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
|
||||
OUT_RELOCl(chan, src_bo, src_offset,
|
||||
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
|
||||
OUT_RELOCl(chan, dst_bo, dst_offset,
|
||||
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_WR);
|
||||
OUT_RING (chan, src->stride);
|
||||
OUT_RING (chan, dst->stride);
|
||||
OUT_RING (chan, w * src->block.size);
|
||||
OUT_RING (chan, count);
|
||||
OUT_RING (chan, 0x0101);
|
||||
OUT_RING (chan, 0);
|
||||
|
||||
h -= count;
|
||||
src_offset += src->stride * count;
|
||||
dst_offset += dst->stride * count;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
|
||||
int dx, int dy, struct pipe_surface *src, int sx, int sy,
|
||||
int w, int h)
|
||||
{
|
||||
struct nouveau_channel *chan = ctx->nvws->channel;
|
||||
struct nouveau_grobj *surf2d = ctx->surf2d;
|
||||
struct nouveau_grobj *blit = ctx->blit;
|
||||
struct nouveau_bo *src_bo = ctx->nvws->get_bo(ctx->buf(src));
|
||||
struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst));
|
||||
int format;
|
||||
|
||||
format = nv04_surface_format(dst->format);
|
||||
if (format < 0)
|
||||
return 1;
|
||||
|
||||
WAIT_RING (chan, 12);
|
||||
BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
|
||||
OUT_RELOCo(chan, src_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
|
||||
OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
|
||||
OUT_RING (chan, format);
|
||||
OUT_RING (chan, (dst->stride << 16) | src->stride);
|
||||
OUT_RELOCl(chan, src_bo, src->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
|
||||
OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
|
||||
BEGIN_RING(chan, blit, 0x0300, 3);
|
||||
OUT_RING (chan, (sy << 16) | sx);
|
||||
OUT_RING (chan, (dy << 16) | dx);
|
||||
OUT_RING (chan, ( h << 16) | w);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
nv04_surface_copy(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
|
||||
int dx, int dy, struct pipe_surface *src, int sx, int sy,
|
||||
int w, int h)
|
||||
{
|
||||
int src_linear = src->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR;
|
||||
int dst_linear = dst->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR;
|
||||
|
||||
assert(src->format == dst->format);
|
||||
|
||||
/* Setup transfer to swizzle the texture to vram if needed */
|
||||
if (src_linear && !dst_linear && w > 1 && h > 1) {
|
||||
nv04_surface_copy_swizzle(ctx, dst, dx, dy, src, sx, sy, w, h);
|
||||
return;
|
||||
}
|
||||
|
||||
/* NV_CONTEXT_SURFACES_2D has buffer alignment restrictions, fallback
|
||||
* to NV_MEMORY_TO_MEMORY_FORMAT in this case.
|
||||
*/
|
||||
if ((src->offset & 63) || (dst->offset & 63) ||
|
||||
(src->stride & 63) || (dst->stride & 63)) {
|
||||
nv04_surface_copy_m2mf(ctx, dst, dx, dy, src, sx, sy, w, h);
|
||||
return;
|
||||
}
|
||||
|
||||
nv04_surface_copy_blit(ctx, dst, dx, dy, src, sx, sy, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
|
||||
int dx, int dy, int w, int h, unsigned value)
|
||||
{
|
||||
struct nouveau_channel *chan = ctx->nvws->channel;
|
||||
struct nouveau_grobj *surf2d = ctx->surf2d;
|
||||
struct nouveau_grobj *rect = ctx->rect;
|
||||
struct nouveau_bo *dst_bo = ctx->nvws->get_bo(ctx->buf(dst));
|
||||
int cs2d_format, gdirect_format;
|
||||
|
||||
cs2d_format = nv04_surface_format(dst->format);
|
||||
assert(cs2d_format >= 0);
|
||||
|
||||
gdirect_format = nv04_rect_format(dst->format);
|
||||
assert(gdirect_format >= 0);
|
||||
|
||||
WAIT_RING (chan, 16);
|
||||
BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
|
||||
OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
|
||||
OUT_RING (chan, cs2d_format);
|
||||
OUT_RING (chan, (dst->stride << 16) | dst->stride);
|
||||
OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
|
||||
BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT, 1);
|
||||
OUT_RING (chan, gdirect_format);
|
||||
BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_COLOR1_A, 1);
|
||||
OUT_RING (chan, value);
|
||||
BEGIN_RING(chan, rect,
|
||||
NV04_GDI_RECTANGLE_TEXT_UNCLIPPED_RECTANGLE_POINT(0), 2);
|
||||
OUT_RING (chan, (dx << 16) | dy);
|
||||
OUT_RING (chan, ( w << 16) | h);
|
||||
}
|
||||
|
||||
void
|
||||
nv04_surface_2d_takedown(struct nv04_surface_2d **pctx)
|
||||
{
|
||||
struct nv04_surface_2d *ctx;
|
||||
|
||||
if (!pctx || !*pctx)
|
||||
return;
|
||||
ctx = *pctx;
|
||||
*pctx = NULL;
|
||||
|
||||
nouveau_notifier_free(&ctx->ntfy);
|
||||
nouveau_grobj_free(&ctx->m2mf);
|
||||
nouveau_grobj_free(&ctx->surf2d);
|
||||
nouveau_grobj_free(&ctx->swzsurf);
|
||||
nouveau_grobj_free(&ctx->rect);
|
||||
nouveau_grobj_free(&ctx->blit);
|
||||
nouveau_grobj_free(&ctx->sifm);
|
||||
|
||||
FREE(ctx);
|
||||
}
|
||||
|
||||
struct nv04_surface_2d *
|
||||
nv04_surface_2d_init(struct nouveau_winsys *nvws)
|
||||
{
|
||||
struct nv04_surface_2d *ctx = CALLOC_STRUCT(nv04_surface_2d);
|
||||
struct nouveau_channel *chan = nvws->channel;
|
||||
unsigned handle = 0x88000000, class;
|
||||
int ret;
|
||||
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
|
||||
ret = nouveau_notifier_alloc(chan, handle++, 1, &ctx->ntfy);
|
||||
if (ret) {
|
||||
nv04_surface_2d_takedown(&ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = nouveau_grobj_alloc(chan, handle++, 0x0039, &ctx->m2mf);
|
||||
if (ret) {
|
||||
nv04_surface_2d_takedown(&ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BEGIN_RING(chan, ctx->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 1);
|
||||
OUT_RING (chan, ctx->ntfy->handle);
|
||||
|
||||
if (chan->device->chipset < 0x10)
|
||||
class = NV04_CONTEXT_SURFACES_2D;
|
||||
else
|
||||
class = NV10_CONTEXT_SURFACES_2D;
|
||||
|
||||
ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->surf2d);
|
||||
if (ret) {
|
||||
nv04_surface_2d_takedown(&ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BEGIN_RING(chan, ctx->surf2d,
|
||||
NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
|
||||
OUT_RING (chan, chan->vram->handle);
|
||||
OUT_RING (chan, chan->vram->handle);
|
||||
|
||||
if (chan->device->chipset < 0x10)
|
||||
class = NV04_IMAGE_BLIT;
|
||||
else
|
||||
class = NV12_IMAGE_BLIT;
|
||||
|
||||
ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->blit);
|
||||
if (ret) {
|
||||
nv04_surface_2d_takedown(&ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BEGIN_RING(chan, ctx->blit, NV04_IMAGE_BLIT_DMA_NOTIFY, 1);
|
||||
OUT_RING (chan, ctx->ntfy->handle);
|
||||
BEGIN_RING(chan, ctx->blit, NV04_IMAGE_BLIT_SURFACE, 1);
|
||||
OUT_RING (chan, ctx->surf2d->handle);
|
||||
BEGIN_RING(chan, ctx->blit, NV04_IMAGE_BLIT_OPERATION, 1);
|
||||
OUT_RING (chan, NV04_IMAGE_BLIT_OPERATION_SRCCOPY);
|
||||
|
||||
ret = nouveau_grobj_alloc(chan, handle++, NV04_GDI_RECTANGLE_TEXT,
|
||||
&ctx->rect);
|
||||
if (ret) {
|
||||
nv04_surface_2d_takedown(&ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_DMA_NOTIFY, 1);
|
||||
OUT_RING (chan, ctx->ntfy->handle);
|
||||
BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_SURFACE, 1);
|
||||
OUT_RING (chan, ctx->surf2d->handle);
|
||||
BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_OPERATION, 1);
|
||||
OUT_RING (chan, NV04_GDI_RECTANGLE_TEXT_OPERATION_SRCCOPY);
|
||||
BEGIN_RING(chan, ctx->rect,
|
||||
NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT, 1);
|
||||
OUT_RING (chan, NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT_LE);
|
||||
|
||||
switch (chan->device->chipset & 0xf0) {
|
||||
case 0x00:
|
||||
case 0x10:
|
||||
class = NV04_SWIZZLED_SURFACE;
|
||||
break;
|
||||
case 0x20:
|
||||
class = NV20_SWIZZLED_SURFACE;
|
||||
break;
|
||||
case 0x30:
|
||||
class = NV30_SWIZZLED_SURFACE;
|
||||
break;
|
||||
case 0x40:
|
||||
case 0x60:
|
||||
class = NV40_SWIZZLED_SURFACE;
|
||||
break;
|
||||
default:
|
||||
/* Famous last words: this really can't happen.. */
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
|
||||
ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->swzsurf);
|
||||
if (ret) {
|
||||
nv04_surface_2d_takedown(&ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (chan->device->chipset < 0x10) {
|
||||
class = NV04_SCALED_IMAGE_FROM_MEMORY;
|
||||
} else
|
||||
if (chan->device->chipset < 0x40) {
|
||||
class = NV10_SCALED_IMAGE_FROM_MEMORY;
|
||||
} else {
|
||||
class = NV40_SCALED_IMAGE_FROM_MEMORY;
|
||||
}
|
||||
|
||||
ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->sifm);
|
||||
if (ret) {
|
||||
nv04_surface_2d_takedown(&ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx->nvws = nvws;
|
||||
ctx->copy = nv04_surface_copy;
|
||||
ctx->fill = nv04_surface_fill;
|
||||
return ctx;
|
||||
}
|
||||
29
src/gallium/drivers/nv04/nv04_surface_2d.h
Normal file
29
src/gallium/drivers/nv04/nv04_surface_2d.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef __NV04_SURFACE_2D_H__
|
||||
#define __NV04_SURFACE_2D_H__
|
||||
|
||||
struct nv04_surface_2d {
|
||||
struct nouveau_winsys *nvws;
|
||||
struct nouveau_notifier *ntfy;
|
||||
struct nouveau_grobj *surf2d;
|
||||
struct nouveau_grobj *swzsurf;
|
||||
struct nouveau_grobj *m2mf;
|
||||
struct nouveau_grobj *rect;
|
||||
struct nouveau_grobj *blit;
|
||||
struct nouveau_grobj *sifm;
|
||||
|
||||
struct pipe_buffer *(*buf)(struct pipe_surface *);
|
||||
|
||||
void (*copy)(struct nv04_surface_2d *, struct pipe_surface *dst,
|
||||
int dx, int dy, struct pipe_surface *src, int sx, int sy,
|
||||
int w, int h);
|
||||
void (*fill)(struct nv04_surface_2d *, struct pipe_surface *dst,
|
||||
int dx, int dy, int w, int h, unsigned value);
|
||||
};
|
||||
|
||||
struct nv04_surface_2d *
|
||||
nv04_surface_2d_init(struct nouveau_winsys *nvws);
|
||||
|
||||
void
|
||||
nv04_surface_2d_takedown(struct nv04_surface_2d **);
|
||||
|
||||
#endif
|
||||
|
|
@ -50,6 +50,31 @@ nv10_miptree_layout(struct nv10_miptree *nv10mt)
|
|||
nv10mt->total_size = offset;
|
||||
}
|
||||
|
||||
static struct pipe_texture *
|
||||
nv10_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
|
||||
const unsigned *stride, struct pipe_buffer *pb)
|
||||
{
|
||||
struct nv10_miptree *mt;
|
||||
|
||||
/* Only supports 2D, non-mipmapped textures for the moment */
|
||||
if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
|
||||
pt->depth[0] != 1)
|
||||
return NULL;
|
||||
|
||||
mt = CALLOC_STRUCT(nv10_miptree);
|
||||
if (!mt)
|
||||
return NULL;
|
||||
|
||||
mt->base = *pt;
|
||||
mt->base.refcount = 1;
|
||||
mt->base.screen = pscreen;
|
||||
mt->level[0].pitch = stride[0];
|
||||
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
|
||||
|
||||
pipe_buffer_reference(pscreen, &mt->buffer, pb);
|
||||
return &mt->base;
|
||||
}
|
||||
|
||||
static struct pipe_texture *
|
||||
nv10_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
|
||||
{
|
||||
|
|
@ -141,6 +166,7 @@ nv10_miptree_surface_release(struct pipe_screen *screen,
|
|||
void nv10_screen_init_miptree_functions(struct pipe_screen *pscreen)
|
||||
{
|
||||
pscreen->texture_create = nv10_miptree_create;
|
||||
pscreen->texture_blanket = nv10_miptree_blanket;
|
||||
pscreen->texture_release = nv10_miptree_release;
|
||||
pscreen->get_tex_surface = nv10_miptree_surface_get;
|
||||
pscreen->tex_surface_release = nv10_miptree_surface_release;
|
||||
|
|
|
|||
|
|
@ -152,6 +152,14 @@ nv10_screen_destroy(struct pipe_screen *pscreen)
|
|||
FREE(pscreen);
|
||||
}
|
||||
|
||||
static struct pipe_buffer *
|
||||
nv10_surface_buffer(struct pipe_surface *surf)
|
||||
{
|
||||
struct nv10_miptree *mt = (struct nv10_miptree *)surf->texture;
|
||||
|
||||
return mt->buffer;
|
||||
}
|
||||
|
||||
struct pipe_screen *
|
||||
nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
|
||||
{
|
||||
|
|
@ -164,6 +172,10 @@ nv10_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
|
|||
return NULL;
|
||||
screen->nvws = nvws;
|
||||
|
||||
/* 2D engine setup */
|
||||
screen->eng2d = nv04_surface_2d_init(nvws);
|
||||
screen->eng2d->buf = nv10_surface_buffer;
|
||||
|
||||
/* 3D object */
|
||||
if (chipset>=0x20)
|
||||
celsius_class=NV11TCL;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define __NV10_SCREEN_H__
|
||||
|
||||
#include "pipe/p_screen.h"
|
||||
#include "nv04/nv04_surface_2d.h"
|
||||
|
||||
struct nv10_screen {
|
||||
struct pipe_screen pipe;
|
||||
|
|
@ -9,6 +10,7 @@ struct nv10_screen {
|
|||
struct nouveau_winsys *nvws;
|
||||
|
||||
/* HW graphics objects */
|
||||
struct nv04_surface_2d *eng2d;
|
||||
struct nouveau_grobj *celsius;
|
||||
struct nouveau_notifier *sync;
|
||||
};
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue