Merge branch 'master' of git+ssh://joukj@git.freedesktop.org/git/mesa/mesa
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
*.o
|
||||
*.so
|
||||
*.sw[a-z]
|
||||
*.pc
|
||||
*~
|
||||
depend
|
||||
depend.bak
|
||||
|
||||
@@ -66,6 +66,8 @@ aix-64 \
|
||||
aix-64-static \
|
||||
aix-gcc \
|
||||
aix-static \
|
||||
bluegene-osmesa \
|
||||
bluegene-xlc-osmesa \
|
||||
beos \
|
||||
darwin \
|
||||
darwin-static \
|
||||
@@ -151,8 +153,9 @@ sunos5-v8 \
|
||||
sunos5-v8-static \
|
||||
sunos5-v9 \
|
||||
sunos5-v9-static \
|
||||
sunos5-v9-cc-g++ \
|
||||
ultrix-gcc:
|
||||
@ if [ -e configs/current ] ; then \
|
||||
@ if test -f configs/current || test -L configs/current ; then \
|
||||
echo "Please run 'make realclean' before changing configs" ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
@@ -209,6 +212,7 @@ MAIN_FILES = \
|
||||
$(DIRECTORY)/src/mesa/Makefile* \
|
||||
$(DIRECTORY)/src/mesa/sources \
|
||||
$(DIRECTORY)/src/mesa/descrip.mms \
|
||||
$(DIRECTORY)/src/mesa/gl.pc.in \
|
||||
$(DIRECTORY)/src/mesa/depend \
|
||||
$(DIRECTORY)/src/mesa/main/*.[chS] \
|
||||
$(DIRECTORY)/src/mesa/main/descrip.mms \
|
||||
@@ -316,6 +320,7 @@ DRI_FILES = \
|
||||
SGI_GLU_FILES = \
|
||||
$(DIRECTORY)/src/glu/Makefile \
|
||||
$(DIRECTORY)/src/glu/descrip.mms \
|
||||
$(DIRECTORY)/src/glu/glu.pc.in \
|
||||
$(DIRECTORY)/src/glu/sgi/Makefile \
|
||||
$(DIRECTORY)/src/glu/sgi/Makefile.mgw \
|
||||
$(DIRECTORY)/src/glu/sgi/Makefile.win \
|
||||
@@ -392,6 +397,7 @@ GLUT_FILES = \
|
||||
$(DIRECTORY)/include/GL/glutf90.h \
|
||||
$(DIRECTORY)/src/glut/glx/Makefile* \
|
||||
$(DIRECTORY)/src/glut/glx/depend \
|
||||
$(DIRECTORY)/src/glut/glx/glut.pc.in \
|
||||
$(DIRECTORY)/src/glut/glx/*def \
|
||||
$(DIRECTORY)/src/glut/glx/descrip.mms \
|
||||
$(DIRECTORY)/src/glut/glx/mms_depend \
|
||||
@@ -414,6 +420,7 @@ DEPEND_FILES = \
|
||||
$(TOP)/src/mesa/depend \
|
||||
$(TOP)/src/glx/x11/depend \
|
||||
$(TOP)/src/glw/depend \
|
||||
$(TOP)/src/glw/glw.pc.in \
|
||||
$(TOP)/src/glut/glx/depend \
|
||||
$(TOP)/src/glu/sgi/depend
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ MINOR=0
|
||||
PATCH=""
|
||||
DEPS=""
|
||||
LINK=""
|
||||
LDFLAGS=""
|
||||
CPLUSPLUS=0
|
||||
STATIC=0
|
||||
DLOPEN=0
|
||||
@@ -63,6 +64,7 @@ do
|
||||
echo ' -LDIR search in DIR for library dependencies'
|
||||
echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
|
||||
echo ' Not observed on all systems at this time.'
|
||||
echo ' -ldflags OPT specify any additional linker flags in OPT'
|
||||
echo ' -cplusplus link with C++ runtime'
|
||||
echo ' -static make a static library (default is dynamic/shared)'
|
||||
echo ' -dlopen make a shared library suitable for dynamic loading'
|
||||
@@ -94,6 +96,10 @@ do
|
||||
shift 1;
|
||||
LINK=$1
|
||||
;;
|
||||
'-ldflags')
|
||||
shift 1;
|
||||
LDFLAGS=$1
|
||||
;;
|
||||
-l*)
|
||||
DEPS="$DEPS $1"
|
||||
;;
|
||||
@@ -215,7 +221,7 @@ case $ARCH in
|
||||
|
||||
rm -f ${LIBNAME}
|
||||
# make lib
|
||||
${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
|
||||
${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
|
||||
# finish up
|
||||
FINAL_LIBS="${LIBNAME}"
|
||||
elif [ $STATIC = 1 ] ; then
|
||||
@@ -273,7 +279,7 @@ case $ARCH in
|
||||
rm -f ${LIBNAME}.so
|
||||
|
||||
# make lib
|
||||
${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
|
||||
${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
|
||||
# make usual symlinks
|
||||
ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
|
||||
ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
|
||||
@@ -345,10 +351,10 @@ case $ARCH in
|
||||
#echo "mklib: linker is" ${LINK} ${OPTS}
|
||||
if [ $NOPREFIX = 1 ] ; then
|
||||
rm -f ${LIBNAME}
|
||||
${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
|
||||
${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
|
||||
else
|
||||
rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
|
||||
${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
|
||||
${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
|
||||
ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
|
||||
fi
|
||||
FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
|
||||
@@ -372,7 +378,7 @@ case $ARCH in
|
||||
echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
|
||||
OPTS="-shared"
|
||||
rm -f ${LIBNAME}
|
||||
${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
|
||||
${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
|
||||
FINAL_LIBS=${LIBNAME}
|
||||
elif [ $STATIC = 1 ] ; then
|
||||
STLIB="lib${LIBNAME}.a"
|
||||
@@ -386,7 +392,7 @@ case $ARCH in
|
||||
OPTS="-shared -Wl,-soname,${SHLIB}"
|
||||
echo "mklib: Making FreeBSD shared library: " ${SHLIB}
|
||||
rm -f ${SHLIB}
|
||||
${LINK} ${OPTS} -o ${SHLIB} ${OBJECTS} ${DEPS}
|
||||
${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
|
||||
ln -sf ${SHLIB} "lib${LIBNAME}.so"
|
||||
FINAL_LIBS="${SHLIB} lib${LIBNAME}.so"
|
||||
fi
|
||||
@@ -444,7 +450,7 @@ case $ARCH in
|
||||
fi
|
||||
|
||||
echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
|
||||
${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
|
||||
${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
|
||||
FINAL_LIBS=${LIBNAME}
|
||||
fi
|
||||
;;
|
||||
@@ -520,9 +526,9 @@ case $ARCH in
|
||||
# On AIX a shared library is linked differently when
|
||||
# you want to dlopen the file
|
||||
if [ $DLOPEN = "1" ] ; then
|
||||
cc -G ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
|
||||
cc -G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
|
||||
else
|
||||
cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
|
||||
cc ${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
|
||||
ar ${X64} -r ${LIBNAME} ${OFILE}
|
||||
fi
|
||||
|
||||
@@ -604,7 +610,7 @@ case $ARCH in
|
||||
fi
|
||||
|
||||
echo "mklib: Making Darwin shared library: " ${LIBNAME}
|
||||
${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
|
||||
${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
|
||||
ln -s ${LIBNAME} ${LINKNAME}
|
||||
FINAL_LIBS="${LIBNAME} ${LINKNAME}"
|
||||
fi
|
||||
@@ -681,7 +687,7 @@ case $ARCH in
|
||||
rm -f ${LIBNAME}.so.${MAJOR}
|
||||
rm -f ${LIBNAME}.so
|
||||
# make lib
|
||||
${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
|
||||
${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
|
||||
# make usual symlinks
|
||||
ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
|
||||
ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
|
||||
@@ -753,7 +759,7 @@ case $ARCH in
|
||||
rm -f ${LIBNAME}.a
|
||||
|
||||
# make lib
|
||||
${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
|
||||
${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
|
||||
# make usual symlinks
|
||||
ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
|
||||
# finish up
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# Configuration for building only libOSMesa on BlueGene, no Xlib driver
|
||||
# This doesn't really have a lot of dependencies, so it should be usable
|
||||
# on other (gcc-based) systems too.
|
||||
# It uses static linking and disables multithreading.
|
||||
|
||||
include $(TOP)/configs/default
|
||||
|
||||
CONFIG_NAME = bluegene-osmesa
|
||||
|
||||
# Compiler and flags
|
||||
CC = /bgl/BlueLight/ppcfloor/blrts-gnu/bin/powerpc-bgl-blrts-gnu-gcc
|
||||
CXX = /bgl/BlueLight/ppcfloor/blrts-gnu/bin/powerpc-bgl-blrts-gnu-g++
|
||||
CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
|
||||
CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURC
|
||||
|
||||
MKLIB_OPTIONS = -static
|
||||
|
||||
OSMESA_LIB_NAME = libOSMesa.a
|
||||
|
||||
# Directories
|
||||
SRC_DIRS = mesa glu
|
||||
DRIVER_DIRS = osmesa
|
||||
PROGRAM_DIRS = osdemos
|
||||
|
||||
|
||||
# Dependencies
|
||||
OSMESA_LIB_DEPS = -lm
|
||||
GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
|
||||
APP_LIB_DEPS = -lOSMesa -lGLU -lm
|
||||
@@ -0,0 +1,29 @@
|
||||
# Configuration for building only libOSMesa on BlueGene using the IBM xlc compiler
|
||||
# This doesn't really have a lot of dependencies, so it should be usable
|
||||
# on similar systems too.
|
||||
# It uses static linking and disables multithreading.
|
||||
|
||||
include $(TOP)/configs/default
|
||||
|
||||
CONFIG_NAME = bluegene-osmesa
|
||||
|
||||
# Compiler and flags
|
||||
CC = /opt/ibmcmp/vacpp/bg/8.0/bin/blrts_xlc
|
||||
CXX = /opt/ibmcmp/vacpp/bg/8.0/bin/blrts_xlC
|
||||
CFLAGS = -O3 -pedantic -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
|
||||
CXXFLAGS = -O3 -pedantic -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
|
||||
|
||||
MKLIB_OPTIONS = -static
|
||||
|
||||
OSMESA_LIB_NAME = libOSMesa.a
|
||||
|
||||
# Directories
|
||||
SRC_DIRS = mesa glu
|
||||
DRIVER_DIRS = osmesa
|
||||
PROGRAM_DIRS = osdemos
|
||||
|
||||
|
||||
# Dependencies
|
||||
OSMESA_LIB_DEPS = -lm
|
||||
GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
|
||||
APP_LIB_DEPS = -lOSMesa -lGLU -lm
|
||||
@@ -20,6 +20,7 @@ CC = cc
|
||||
CXX = CC
|
||||
CFLAGS = -O
|
||||
CXXFLAGS = -O
|
||||
LDFLAGS =
|
||||
GLU_CFLAGS =
|
||||
|
||||
# Misc tools and flags
|
||||
|
||||
+3
-3
@@ -13,9 +13,9 @@ OPT_FLAGS = -O2
|
||||
PIC_FLAGS = -fPIC
|
||||
|
||||
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -DUSE_XSHM \
|
||||
-DHZ=100 -DHAVE_POSIX_MEMALIGN
|
||||
-DHZ=100
|
||||
|
||||
X11_INCLUDES = -I/usr/X11R6/include
|
||||
X11_INCLUDES = -I/usr/local/include
|
||||
|
||||
CFLAGS += $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(DEFINES) $(X11_INCLUDES) -ffast-math -pedantic
|
||||
|
||||
@@ -23,5 +23,5 @@ CXXFLAGS += $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(DEFINES) $(X11_INCLUDES)
|
||||
|
||||
GLUT_CFLAGS = -fexceptions
|
||||
|
||||
EXTRA_LIB_PATH = -L/usr/X11R6/lib
|
||||
EXTRA_LIB_PATH = -L/usr/local/lib
|
||||
APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) $(EXTRA_LIB_PATH) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lXext -lXmu -lXi -lX11 -lm
|
||||
|
||||
+2
-2
@@ -9,13 +9,13 @@ CONFIG_NAME = freebsd-dri
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
WARN_FLAGS = -Wall
|
||||
OPT_FLAGS = -O
|
||||
OPT_FLAGS = -O -g
|
||||
|
||||
EXPAT_INCLUDES = -I/usr/local/include
|
||||
X11_INCLUDES = -I/usr/X11R6/include
|
||||
DEFINES = -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
|
||||
-DGLX_DIRECT_RENDERING -DGLX_INDIRECT_RENDERING \
|
||||
-DHAVE_ALIAS -DHAVE_POSIX_MEMALIGN
|
||||
-DHAVE_ALIAS
|
||||
|
||||
CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) -Wmissing-prototypes -std=c99 -Wundef -ffast-math \
|
||||
$(ASM_FLAGS) $(X11_INCLUDES) $(DEFINES)
|
||||
|
||||
+1
-1
@@ -66,5 +66,5 @@ WINDOW_SYSTEM=dri
|
||||
|
||||
# gamma are missing because they have not been converted to use the new
|
||||
# interface.
|
||||
DRI_DIRS = i810 i915tex i915 i965 mach64 mga r128 r200 r300 radeon s3v \
|
||||
DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
|
||||
savage sis tdfx trident unichrome ffb
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# Configuration for SunOS 5, SPARC V9 and cc/g++ (for C and C++ sources)
|
||||
|
||||
include $(TOP)/configs/default
|
||||
|
||||
CONFIG_NAME = sunos5-v9-cc-g++
|
||||
|
||||
MKLIB_OPTIONS = -cplusplus
|
||||
|
||||
LIB_DIR = lib64
|
||||
|
||||
# Compiler and flags
|
||||
CC = cc
|
||||
CXX = g++
|
||||
|
||||
CXX_WARN_FLAGS = -Wall
|
||||
CXX_PIC_FLAGS = -fPIC
|
||||
CXX_OPT_FLAGS = -O3 -m64 -mcpu=ultrasparc -mv8plus -mvis -g -fomit-frame-pointer -pipe
|
||||
CXX_ARCH_FLAGS = -m64
|
||||
|
||||
|
||||
CXXFLAGS = $(CXX_WARN_FLAGS) $(CXX_OPT_FLAGS) $(CXX_PIC_FLAGS) $(CXX_ARCH_FLAGS) $(DEFINES) \
|
||||
-I/usr/openwin/include
|
||||
|
||||
CFLAGS = -xarch=v9 -KPIC -O -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM -DPTHREADS
|
||||
#CXXFLAGS = -xarch=v9 -KPIC -O -I/usr/openwin/include -I/usr/dt/include -DPTHREADS
|
||||
GLUT_CFLAGS = -DSOLARIS_2_4_BUG
|
||||
|
||||
GL_LIB_DEPS = -L/usr/openwin/lib -L/usr/dt/lib -lX11 -lXext -lXmu -lXi -lm -lpthread
|
||||
GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm -lCstd -lCrun
|
||||
GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
|
||||
GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/openwin/lib -lXt -lX11
|
||||
APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -lX11 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
|
||||
+18
-4
@@ -91,9 +91,11 @@ Running the Build:
|
||||
|
||||
|
||||
|
||||
*******************This section is added by Heromyth*****************************
|
||||
Updated on 2007-7-21, by Heromyth <zxpmyth@yahoo.com.cn>
|
||||
******This section is added by Heromyth <zxpmyth@yahoo.com.cn>*************
|
||||
|
||||
====================
|
||||
Updated on 2007-7-21
|
||||
====================
|
||||
|
||||
Notice:
|
||||
1) The generated DLLs are *not* compatible with the ones built
|
||||
@@ -115,7 +117,7 @@ For example, run:
|
||||
, and delete all the lines where all the wgl*() functions are. Because they would
|
||||
be conflicted with the ones in <Mesa3D-root>\include\GL\mesa_wgl.h.
|
||||
|
||||
======= Conflicted Functions List ======
|
||||
>>>>>>>>>> Conflicted Functions List >>>>>>>>>>
|
||||
WINGDIAPI BOOL WINAPI wglCopyContext(HGLRC,HGLRC,UINT);
|
||||
WINGDIAPI HGLRC WINAPI wglCreateContext(HDC);
|
||||
WINGDIAPI HGLRC WINAPI wglCreateLayerContext(HDC,int);
|
||||
@@ -134,6 +136,18 @@ WINGDIAPI BOOL WINAPI wglUseFontBitmapsA(HDC,DWORD,DWORD,DWORD);
|
||||
WINGDIAPI BOOL WINAPI wglUseFontBitmapsW(HDC,DWORD,DWORD,DWORD);
|
||||
WINGDIAPI BOOL WINAPI wglUseFontOutlinesA(HDC,DWORD,DWORD,DWORD,FLOAT,FLOAT,int,LPGLYPHMETRICSFLOAT);
|
||||
WINGDIAPI BOOL WINAPI wglUseFontOutlinesW(HDC,DWORD,DWORD,DWORD,FLOAT,FLOAT,int,LPGLYPHMETRICSFLOAT);
|
||||
===================
|
||||
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
|
||||
====================
|
||||
Updated on 2007-7-22
|
||||
====================
|
||||
I havn't thought that I would find a better way to solve my problems so soon.
|
||||
I changed the method in which the import-libs and DLLs are made. After this update,
|
||||
the DLLs of MESA are more optimized and more compatible.
|
||||
It seems that there is no need to keep the building way of 'NO-STDCALL'.The
|
||||
way of USING_STDCALL is so nice! The file <Mesa3D-root>\configs\config.mgw is
|
||||
also not needed, and can be deleted safely!
|
||||
|
||||
|
||||
|
||||
*********************************************************************************
|
||||
+13
-9
@@ -9,9 +9,9 @@
|
||||
<H1>Bug Database</H1>
|
||||
|
||||
<p>
|
||||
The Mesa bug database is now hosted on
|
||||
<a href="http://freedesktop.org" target="_parent">freedesktop.org</a>
|
||||
instead of SourceForge.
|
||||
The Mesa bug database is hosted on
|
||||
<a href="http://freedesktop.org" target="_parent">freedesktop.org</a>.
|
||||
The old bug database on SourceForge is no longer used.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -26,16 +26,20 @@ Please follow these bug reporting guidelines:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>Make sure you're using the most recent version of Mesa
|
||||
<li>Make sure your bug isn't already reported
|
||||
<li>Include as much information as possible in the report
|
||||
<li>Check if a new version of Mesa is available which might have fixed
|
||||
the problem.
|
||||
<li>Check if your bug is already reported in the database.
|
||||
<li>Monitor your bug report for requests for additional information, etc.
|
||||
<li>If you're reporting a crash, try to use your debugger (gdb) to get a stack
|
||||
trace. Also, recompile Mesa in debug mode to get more detailed information.
|
||||
<li>Describe in detail how to reproduce the bug, especially with games
|
||||
and applications that the Mesa developers might not be familiar with.
|
||||
<li>Provide a simple GLUT-based test program if possible
|
||||
<li>Check back for follow-ups to the report
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
Bug reports will automatically be forwarded to the Mesa developer's mailing
|
||||
list.
|
||||
Bug reports will automatically be forwarded by bugzilla to the Mesa
|
||||
developer's mailing list.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -28,6 +28,12 @@ Xlib interfaces allowing some degree of application portability between
|
||||
the X and X-less environments.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Some of the files needed for building this configuration are not included
|
||||
in the normal Mesa releases so you'll need to get the latest sources
|
||||
sources from the <a href="repository.html">git repository</a>.
|
||||
</p>
|
||||
|
||||
|
||||
<h1>2. Compilation</h1>
|
||||
|
||||
|
||||
+48
-39
@@ -57,50 +57,31 @@ the DRI hardware drivers.
|
||||
|
||||
<li>
|
||||
<p>
|
||||
DRM kernel modules and header files from the
|
||||
<a href="http://dri.sf.net/" target="_parent">DRI</a> project.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If you don't already have the DRM file, you can get the sources from
|
||||
CVS by doing:
|
||||
<pre>
|
||||
cvs -z3 -d:pserver:anonymous@anoncvs.freedesktop.org:/cvs/dri co drm
|
||||
</pre>
|
||||
<p>
|
||||
See the <a href="http://dri.freedesktop.org/wiki/Building" target="_parent">
|
||||
DRI Building Instructions</a> for the steps to build the DRM modules. Mesa
|
||||
6.5 requires at least libdrm 2.0.1 or greater.
|
||||
For Mesa 7.0.2 <a href="http://dri.freedesktop.org/libdrm/">
|
||||
DRM version 2.3</a> is required.
|
||||
</p>
|
||||
<p>
|
||||
You can verify that the DRM files have been properly installed by
|
||||
running <code>pkg-config --modversion libdrm</code>
|
||||
|
||||
To check if you already have it, run:
|
||||
<br>
|
||||
<code>pkg-config --modversion libdrm</code>
|
||||
</p>
|
||||
<p>
|
||||
You can download and install a <a href="http://dri.freedesktop.org/libdrm/">
|
||||
tarball release</a> or get the code from git with:
|
||||
<br>
|
||||
<code>git clone git://anongit.freedesktop.org/git/mesa/drm</code>
|
||||
<br>
|
||||
Then revert to the drm-2.3.0 tag with:
|
||||
<br>
|
||||
<code>git-reset --hard drm-2.3.0</code>
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
Recent /usr/include/GL/glxproto.h file.
|
||||
<p>You'll need this if you get any errors about _GLXvop_BindTexImageEXT
|
||||
being undefined.
|
||||
</p>
|
||||
<p>
|
||||
Download/install the
|
||||
<a href="http://gitweb.freedesktop.org/?p=xorg/proto/glproto.git">glproto</a>
|
||||
module from X.org git, or grab the
|
||||
<A href="http://webcvs.freedesktop.org/*checkout*/xorg/proto/GL/glxproto.h?rev=1.9&content-type=text%2Fplain">glxproto.h file</a> and put it in the
|
||||
Mesa/include/GL/ directory.
|
||||
</p>
|
||||
|
||||
</li>
|
||||
|
||||
<li>DRI-enabled X server.
|
||||
<p>Visit
|
||||
<a href="http://www.xfree86.org" target="_parent">XFree86</a>
|
||||
or
|
||||
Relatively recent
|
||||
<a href="http://freedesktop.org/wiki/Software_2fXserver" target="_parent">
|
||||
X.org</a>
|
||||
for more information.
|
||||
</p>
|
||||
X.org</a> release.
|
||||
Mesa depends on a number of X header and library files.
|
||||
</li>
|
||||
|
||||
</ol>
|
||||
@@ -287,7 +268,15 @@ already installed, you'll have to choose different directories, like
|
||||
To install Mesa's headers and libraries, run <code>make install</code>.
|
||||
But first, check the Mesa/configs/default file and examine the values
|
||||
of the <b>INSTALL_DIR</b> and <b>DRI_DRIVER_INSTALL_DIR</b> variables.
|
||||
Change them if needed, then run <code>make install</code>
|
||||
Change them if needed, then run <code>make install</code>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The variable
|
||||
<b>DESTDIR</b> may also be used to install the contents to a temporary
|
||||
staging directory.
|
||||
This can be useful for package management.
|
||||
For example: <code>make install DESTDIR=/somepath/</code>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -298,6 +287,26 @@ This is a handy way to compare multiple OpenGL implementations.
|
||||
</p>
|
||||
|
||||
|
||||
<H3>1.5 pkg-config support</H3>
|
||||
|
||||
<p>
|
||||
Running <code>make install</code> will install package configuration files
|
||||
for the pkg-config utility.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
When compiling your OpenGL application you can use pkg-config to determine
|
||||
the proper compiler and linker flags.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For example, compiling and linking a GLUT application can be done with:
|
||||
</p>
|
||||
<pre>
|
||||
gcc `pkg-config --cflags --libs glut` mydemo.c -o mydemo
|
||||
</pre>
|
||||
|
||||
<br>
|
||||
|
||||
<a name="windows">
|
||||
<H2>2. Windows Compilation and Installation</H1>
|
||||
|
||||
+16
-13
@@ -86,29 +86,32 @@ and their respective licenses.
|
||||
<H1>Mesa Component Licenses</H1>
|
||||
|
||||
<pre>
|
||||
Component Location Primary Author License
|
||||
----------------------------------------------------------------------------
|
||||
Main Mesa code src/mesa/ Brian Paul Mesa (MIT)
|
||||
Component Location License
|
||||
------------------------------------------------------------------
|
||||
Main Mesa code src/mesa/ Mesa (MIT)
|
||||
|
||||
Device drivers src/mesa/drivers/* See drivers See drivers
|
||||
Device drivers src/mesa/drivers/* MIT, generally
|
||||
|
||||
Ext headers include/GL/glext.h SGI SGI Free B
|
||||
Ext headers include/GL/glext.h Khronos
|
||||
include/GL/glxext.h
|
||||
|
||||
GLUT src/glut/ Mark Kilgard Mark's copyright
|
||||
GLUT src/glut/ Mark Kilgard's copyright
|
||||
|
||||
Mesa GLU library src/glu/mesa/ Brian Paul GNU-LGPL
|
||||
SGI GLU library src/glu/sgi/ SGI Free B
|
||||
|
||||
SGI GLU library src/glu/sgi/ SGI SGI Free B
|
||||
demo programs progs/demos/ see source files
|
||||
|
||||
demo programs progs/demos/ various see source files
|
||||
X demos progs/xdemos/ see source files
|
||||
|
||||
X demos progs/xdemos/ Brian Paul see source files
|
||||
SGI demos progs/samples/ SGI license
|
||||
|
||||
SGI demos progs/samples/ SGI SGI copyright
|
||||
|
||||
RedBook demos progs/redbook/ SGI SGI copyright
|
||||
RedBook demos progs/redbook/ SGI license
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
In general, consult the source files for license terms.
|
||||
</p>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
</li><li><a href="http://innovation3d.sourceforge.net/" target="_parent">Innovation3D</a>
|
||||
- 3D modeling program
|
||||
</li><li><a href="http://mesa3d.sourceforge.net/notfound.html" target="_parent">KWRL</a> - VRML browser
|
||||
</li><li><a href="http://www.vermontel.com/%7Ecmorley/vrml.html" target="_parent">LibVRML97/Lookat</a>
|
||||
</li><li><a href="http://www.openvrml.org/" target="_parent">LibVRML97/Lookat</a>
|
||||
- VRML viewer
|
||||
</li><li><a href="http://aig.cs.man.ac.uk/systems/Maverik/" target="_parent">Maverik</a>
|
||||
- VR graphics and interaction system
|
||||
|
||||
+1
-5
@@ -58,11 +58,7 @@
|
||||
# else /* for use with static link lib build of Win32 edition only */
|
||||
# define GLAPI extern
|
||||
# endif /* _STATIC_MESA support */
|
||||
# if defined(__MINGW32__) && defined(GL_NO_STDCALL) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */
|
||||
# define GLAPIENTRY
|
||||
# else
|
||||
# define GLAPIENTRY __stdcall
|
||||
# endif
|
||||
# define GLAPIENTRY __stdcall
|
||||
#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */
|
||||
# define GLAPI extern
|
||||
# define GLAPIENTRY __stdcall
|
||||
|
||||
+11
-16
@@ -44,22 +44,17 @@
|
||||
#define GLAPIENTRYP GLAPIENTRY *
|
||||
#endif
|
||||
|
||||
#ifdef GLAPI
|
||||
#undef GLAPI
|
||||
#endif
|
||||
|
||||
# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GLU32)
|
||||
# define GLAPI __declspec(dllexport)
|
||||
# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
|
||||
# define GLAPI __declspec(dllimport)
|
||||
# else /* for use with static link lib build of Win32 edition only */
|
||||
# define GLAPI extern
|
||||
# endif /* _STATIC_MESA support */
|
||||
|
||||
|
||||
#ifndef GLAPI
|
||||
#define GLAPI
|
||||
#endif
|
||||
#if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GLU32)
|
||||
# undef GLAPI
|
||||
# define GLAPI __declspec(dllexport)
|
||||
#elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL)
|
||||
/* tag specifying we're building for DLL runtime support */
|
||||
# undef GLAPI
|
||||
# define GLAPI __declspec(dllimport)
|
||||
#elif !defined(GLAPI)
|
||||
/* for use with static link lib build of Win32 edition only */
|
||||
# define GLAPI extern
|
||||
#endif /* _STATIC_MESA support */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ extern _CRTIMP void __cdecl exit(int);
|
||||
and redifinition of Windows system defs, also removes requirement of
|
||||
pretty much any standard windows header from this file */
|
||||
|
||||
#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__CYGWIN32__)
|
||||
#if (_MSC_VER >= 800) || defined(__MINGW32__) || defined(_STDCALL_SUPPORTED) || defined(__CYGWIN32__)
|
||||
# define GLUTAPIENTRY __stdcall
|
||||
#else
|
||||
# define GLUTAPIENTRY
|
||||
|
||||
@@ -75,7 +75,7 @@ typedef void (GLUTCALLBACK *GLUTmenuStatusFCB) (int *, int *, int *);
|
||||
typedef void (GLUTCALLBACK *GLUTidleFCB) (void);
|
||||
|
||||
/* Functions that set and return Fortran callback functions. */
|
||||
GLUTAPI void* APIENTRY __glutGetFCB(int which);
|
||||
GLUTAPI void APIENTRY __glutSetFCB(int which, void *func);
|
||||
GLUTAPI GLUTproc APIENTRY __glutGetFCB(int which);
|
||||
GLUTAPI void APIENTRY __glutSetFCB(int which, GLUTproc func);
|
||||
|
||||
#endif /* __glutf90_h__ */
|
||||
|
||||
@@ -81,8 +81,6 @@ WGLAPI int GLAPIENTRY wglChoosePixelFormat(HDC, const PIXELFORMATDESCRIPTOR *)
|
||||
WGLAPI int GLAPIENTRY wglDescribePixelFormat(HDC,int, unsigned int, LPPIXELFORMATDESCRIPTOR);
|
||||
WGLAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc);
|
||||
|
||||
|
||||
#if defined(GL_NO_STDCALL) || !defined(__MINGW32__)
|
||||
WGLAPI int GLAPIENTRY wglCopyContext(HGLRC, HGLRC, unsigned int);
|
||||
WGLAPI HGLRC GLAPIENTRY wglCreateContext(HDC);
|
||||
WGLAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC,int);
|
||||
@@ -101,7 +99,6 @@ WGLAPI int GLAPIENTRY wglUseFontBitmapsA(HDC, unsigned long, unsigned long, un
|
||||
WGLAPI int GLAPIENTRY wglUseFontBitmapsW(HDC, unsigned long, unsigned long, unsigned long);
|
||||
WGLAPI int GLAPIENTRY wglUseFontOutlinesA(HDC, unsigned long, unsigned long, unsigned long, float,float, int, LPGLYPHMETRICSFLOAT);
|
||||
WGLAPI int GLAPIENTRY wglUseFontOutlinesW(HDC, unsigned long, unsigned long, unsigned long, float,float, int, LPGLYPHMETRICSFLOAT);
|
||||
#endif
|
||||
|
||||
#ifndef __MINGW32__
|
||||
WGLAPI int GLAPIENTRY SwapBuffers(HDC);
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
.cvsignore
|
||||
arbfplight
|
||||
arbfslight
|
||||
arbocclude
|
||||
bounce
|
||||
clearspd
|
||||
cubemap
|
||||
drawpix
|
||||
engine
|
||||
extfuncs.h
|
||||
fire
|
||||
fogcoord
|
||||
fplight
|
||||
fslight
|
||||
gamma
|
||||
gearbox
|
||||
gears
|
||||
geartrain
|
||||
glinfo
|
||||
gloss
|
||||
glslnoise
|
||||
gltestperf
|
||||
glutfx
|
||||
ipers
|
||||
@@ -33,8 +40,11 @@ renormal
|
||||
shadowtex
|
||||
showbuffer.c
|
||||
showbuffer.h
|
||||
singlebuffer
|
||||
spriteblast
|
||||
spectex
|
||||
stex3d
|
||||
streaming_rect
|
||||
teapot
|
||||
terrain
|
||||
tessdemo
|
||||
@@ -42,7 +52,10 @@ texcyl
|
||||
texdown
|
||||
texenv
|
||||
texobj
|
||||
trackball.c
|
||||
trackball.h
|
||||
trispd
|
||||
tunnel
|
||||
tunnel2
|
||||
vao_demo
|
||||
winpos
|
||||
|
||||
+11
-6
@@ -19,6 +19,7 @@ PROGS = \
|
||||
arbocclude \
|
||||
bounce \
|
||||
clearspd \
|
||||
copypix \
|
||||
cubemap \
|
||||
drawpix \
|
||||
engine \
|
||||
@@ -74,7 +75,7 @@ PROGS = \
|
||||
|
||||
# make executable from .c file:
|
||||
.c: $(LIB_DEP) readtex.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
|
||||
##### TARGETS #####
|
||||
@@ -118,41 +119,45 @@ extfuncs.h: $(TOP)/progs/util/extfuncs.h
|
||||
|
||||
|
||||
reflect: reflect.o showbuffer.o readtex.o
|
||||
$(CC) reflect.o showbuffer.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) $(LDFLAGS) reflect.o showbuffer.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
reflect.o: reflect.c showbuffer.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) reflect.c
|
||||
|
||||
|
||||
shadowtex: shadowtex.o showbuffer.o
|
||||
$(CC) shadowtex.o showbuffer.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) $(LDFLAGS) shadowtex.o showbuffer.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
shadowtex.o: shadowtex.c showbuffer.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c
|
||||
|
||||
|
||||
gloss: gloss.o trackball.o readtex.o
|
||||
$(CC) gloss.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) $(LDFLAGS) gloss.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
gloss.o: gloss.c trackball.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) gloss.c
|
||||
|
||||
|
||||
engine: engine.o trackball.o readtex.o
|
||||
$(CC) engine.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) $(LDFLAGS) engine.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
engine.o: engine.c trackball.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) engine.c
|
||||
|
||||
|
||||
fslight: fslight.o
|
||||
$(CC) fslight.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) $(LDFLAGS) fslight.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
fslight.o: fslight.c extfuncs.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) fslight.c
|
||||
|
||||
|
||||
|
||||
viewdds: viewdds.c
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -L. -lgltc -o $@
|
||||
|
||||
|
||||
clean:
|
||||
-rm -f $(PROGS)
|
||||
-rm -f *.o *~
|
||||
|
||||
@@ -0,0 +1,248 @@
|
||||
/**
|
||||
* glCopyPixels test
|
||||
*
|
||||
* Brian Paul
|
||||
* 14 Sep 2007
|
||||
*/
|
||||
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include "readtex.h"
|
||||
|
||||
#define IMAGE_FILE "../images/arch.rgb"
|
||||
|
||||
static int ImgWidth, ImgHeight;
|
||||
static GLenum ImgFormat;
|
||||
static GLubyte *Image = NULL;
|
||||
|
||||
static int WinWidth = 800, WinHeight = 800;
|
||||
static int Xpos, Ypos;
|
||||
static int Scissor = 0;
|
||||
static float Xzoom, Yzoom;
|
||||
static GLboolean DrawFront = GL_FALSE;
|
||||
static GLboolean Dither = GL_TRUE;
|
||||
|
||||
|
||||
static void Reset( void )
|
||||
{
|
||||
Xpos = Ypos = 20;
|
||||
Scissor = 0;
|
||||
Xzoom = Yzoom = 1.0;
|
||||
}
|
||||
|
||||
|
||||
static void Display( void )
|
||||
{
|
||||
const int dx = (WinWidth - ImgWidth) / 2;
|
||||
const int dy = (WinHeight - ImgHeight) / 2;
|
||||
|
||||
if (DrawFront) {
|
||||
glDrawBuffer(GL_FRONT);
|
||||
glReadBuffer(GL_FRONT);
|
||||
}
|
||||
else {
|
||||
glDrawBuffer(GL_BACK);
|
||||
glReadBuffer(GL_BACK);
|
||||
}
|
||||
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
/* draw original image */
|
||||
glWindowPos2iARB(dx, dy);
|
||||
glDrawPixels(ImgWidth, ImgHeight, ImgFormat, GL_UNSIGNED_BYTE, Image);
|
||||
|
||||
if (Scissor)
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
/* draw copy */
|
||||
glPixelZoom(Xzoom, Yzoom);
|
||||
glWindowPos2iARB(Xpos, Ypos);
|
||||
glCopyPixels(dx, dy, ImgWidth, ImgHeight, GL_COLOR);
|
||||
glPixelZoom(1, 1);
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
if (DrawFront)
|
||||
glFinish();
|
||||
else
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void Reshape( int width, int height )
|
||||
{
|
||||
WinWidth = width;
|
||||
WinHeight = height;
|
||||
|
||||
glViewport( 0, 0, width, height );
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadIdentity();
|
||||
glOrtho( 0.0, width, 0.0, height, 0.0, 2.0 );
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadIdentity();
|
||||
|
||||
glScissor(width/4, height/4, width/2, height/2);
|
||||
}
|
||||
|
||||
|
||||
static void Key( unsigned char key, int x, int y )
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case ' ':
|
||||
Reset();
|
||||
break;
|
||||
case 'd':
|
||||
Dither = !Dither;
|
||||
if (Dither)
|
||||
glEnable(GL_DITHER);
|
||||
else
|
||||
glDisable(GL_DITHER);
|
||||
break;
|
||||
case 's':
|
||||
Scissor = !Scissor;
|
||||
break;
|
||||
case 'x':
|
||||
Xzoom -= 0.1;
|
||||
break;
|
||||
case 'X':
|
||||
Xzoom += 0.1;
|
||||
break;
|
||||
case 'y':
|
||||
Yzoom -= 0.1;
|
||||
break;
|
||||
case 'Y':
|
||||
Yzoom += 0.1;
|
||||
break;
|
||||
case 'f':
|
||||
DrawFront = !DrawFront;
|
||||
printf("glDrawBuffer(%s)\n", DrawFront ? "GL_FRONT" : "GL_BACK");
|
||||
break;
|
||||
case 27:
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void SpecialKey( int key, int x, int y )
|
||||
{
|
||||
const int step = (glutGetModifiers() & GLUT_ACTIVE_SHIFT) ? 10 : 1;
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case GLUT_KEY_UP:
|
||||
Ypos += step;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
Ypos -= step;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
Xpos -= step;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
Xpos += step;
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void Init( GLboolean ciMode, const char *filename )
|
||||
{
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
Image = LoadRGBImage( filename, &ImgWidth, &ImgHeight, &ImgFormat );
|
||||
if (!Image) {
|
||||
printf("Couldn't read %s\n", filename);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (ciMode) {
|
||||
/* Convert RGB image to grayscale */
|
||||
GLubyte *indexImage = (GLubyte *) malloc( ImgWidth * ImgHeight );
|
||||
GLint i;
|
||||
for (i=0; i<ImgWidth*ImgHeight; i++) {
|
||||
int gray = Image[i*3] + Image[i*3+1] + Image[i*3+2];
|
||||
indexImage[i] = gray / 3;
|
||||
}
|
||||
free(Image);
|
||||
Image = indexImage;
|
||||
ImgFormat = GL_COLOR_INDEX;
|
||||
|
||||
for (i=0;i<255;i++) {
|
||||
float g = i / 255.0;
|
||||
glutSetColor(i, g, g, g);
|
||||
}
|
||||
}
|
||||
|
||||
printf("Loaded %d by %d image\n", ImgWidth, ImgHeight );
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, ImgWidth);
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
||||
static void Usage(void)
|
||||
{
|
||||
printf("Keys:\n");
|
||||
printf(" SPACE Reset Parameters\n");
|
||||
printf(" Up/Down Move image up/down (SHIFT for large step)\n");
|
||||
printf(" Left/Right Move image left/right (SHIFT for large step)\n");
|
||||
printf(" x Decrease X-axis PixelZoom\n");
|
||||
printf(" X Increase X-axis PixelZoom\n");
|
||||
printf(" y Decrease Y-axis PixelZoom\n");
|
||||
printf(" Y Increase Y-axis PixelZoom\n");
|
||||
printf(" s Toggle GL_SCISSOR_TEST\n");
|
||||
printf(" f Toggle front/back buffer drawing\n");
|
||||
printf(" ESC Exit\n");
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
GLboolean ciMode = GL_FALSE;
|
||||
const char *filename = IMAGE_FILE;
|
||||
int i = 1;
|
||||
|
||||
if (argc > i && strcmp(argv[i], "-ci")==0) {
|
||||
ciMode = GL_TRUE;
|
||||
i++;
|
||||
}
|
||||
if (argc > i) {
|
||||
filename = argv[i];
|
||||
}
|
||||
|
||||
glutInit( &argc, argv );
|
||||
glutInitWindowPosition( 0, 0 );
|
||||
glutInitWindowSize( WinWidth, WinHeight );
|
||||
|
||||
if (ciMode)
|
||||
glutInitDisplayMode( GLUT_INDEX | GLUT_DOUBLE );
|
||||
else
|
||||
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE);
|
||||
|
||||
glutCreateWindow(argv[0]);
|
||||
|
||||
Init(ciMode, filename);
|
||||
Usage();
|
||||
|
||||
glutReshapeFunc( Reshape );
|
||||
glutKeyboardFunc( Key );
|
||||
glutSpecialFunc( SpecialKey );
|
||||
glutDisplayFunc( Display );
|
||||
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
+45
-6
@@ -47,6 +47,8 @@ static GLfloat Xrot = 0, Yrot = 0;
|
||||
static GLfloat EyeDist = 10;
|
||||
static GLboolean use_vertex_arrays = GL_FALSE;
|
||||
static GLboolean anim = GL_TRUE;
|
||||
static GLboolean NoClear = GL_FALSE;
|
||||
static GLint FrameParity = 0;
|
||||
|
||||
#define eps1 0.99
|
||||
#define br 20.0 /* box radius */
|
||||
@@ -156,7 +158,30 @@ static void draw_skybox( void )
|
||||
|
||||
static void draw( void )
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
if (NoClear) {
|
||||
/* This demonstrates how we can avoid calling glClear.
|
||||
* This method only works if every pixel in the window is painted for
|
||||
* every frame.
|
||||
* We can simply skip clearing of the color buffer in this case.
|
||||
* For the depth buffer, we alternately use a different subrange of
|
||||
* the depth buffer for each frame. For the odd frame use the range
|
||||
* [0, 0.5] with GL_LESS. For the even frames, use the range [1, 0.5]
|
||||
* with GL_GREATER.
|
||||
*/
|
||||
FrameParity = 1 - FrameParity;
|
||||
if (FrameParity) {
|
||||
glDepthRange(0.0, 0.5);
|
||||
glDepthFunc(GL_LESS);
|
||||
}
|
||||
else {
|
||||
glDepthRange(1.0, 0.5);
|
||||
glDepthFunc(GL_GREATER);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* ordinary clearing */
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
glPushMatrix(); /*MODELVIEW*/
|
||||
glTranslatef( 0.0, 0.0, -EyeDist );
|
||||
@@ -452,6 +477,24 @@ static void usage(void)
|
||||
}
|
||||
|
||||
|
||||
static void parse_args(int argc, char *argv[])
|
||||
{
|
||||
int initFlag = 0;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-i") == 0)
|
||||
initFlag = 1;
|
||||
else if (strcmp(argv[i], "--noclear") == 0)
|
||||
NoClear = GL_TRUE;
|
||||
else {
|
||||
fprintf(stderr, "Bad option: %s\n", argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
init (initFlag);
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
@@ -459,17 +502,13 @@ int main( int argc, char *argv[] )
|
||||
glutInitWindowSize(600, 500);
|
||||
glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
|
||||
glutCreateWindow("Texture Cube Mapping");
|
||||
|
||||
if (argc > 1 && strcmp(argv[1] , "-i") == 0)
|
||||
init( 1 );
|
||||
else
|
||||
init( 0 );
|
||||
glutReshapeFunc( reshape );
|
||||
glutKeyboardFunc( key );
|
||||
glutSpecialFunc( specialkey );
|
||||
glutDisplayFunc( draw );
|
||||
if (anim)
|
||||
glutIdleFunc(idle);
|
||||
parse_args(argc, argv);
|
||||
usage();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
|
||||
@@ -22,7 +22,7 @@ PROGS = df_gears \
|
||||
.SUFFIXES: .c
|
||||
|
||||
.c: $(LIB_DEP)
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
|
||||
|
||||
##### TARGETS #####
|
||||
|
||||
+5
-5
@@ -25,35 +25,35 @@ default: $(PROGRAMS)
|
||||
|
||||
|
||||
demo1: demo1.o $(TOP)/$(LIB_DIR)/libEGL.so
|
||||
$(CC) $(CFLAGS) demo1.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) demo1.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@
|
||||
|
||||
demo1.o: demo1.c $(HEADERS)
|
||||
$(CC) -c $(CFLAGS) -I$(TOP)/include demo1.c
|
||||
|
||||
|
||||
demo2: demo2.o $(TOP)/$(LIB_DIR)/libEGL.so
|
||||
$(CC) $(CFLAGS) demo2.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) demo2.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
demo2.o: demo2.c $(HEADERS)
|
||||
$(CC) -c $(CFLAGS) -I$(TOP)/include demo2.c
|
||||
|
||||
|
||||
demo3: demo3.o $(TOP)/$(LIB_DIR)/libEGL.so
|
||||
$(CC) $(CFLAGS) demo3.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) demo3.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
demo3.o: demo3.c $(HEADERS)
|
||||
$(CC) -c $(CFLAGS) -I$(TOP)/include demo3.c
|
||||
|
||||
|
||||
eglinfo: eglinfo.o $(TOP)/$(LIB_DIR)/libEGL.so
|
||||
$(CC) $(CFLAGS) eglinfo.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) eglinfo.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@
|
||||
|
||||
eglinfo.o: eglinfo.c $(HEADERS)
|
||||
$(CC) -c $(CFLAGS) -I$(TOP)/include eglinfo.c
|
||||
|
||||
|
||||
eglgears: eglgears.o $(TOP)/$(LIB_DIR)/libEGL.so
|
||||
$(CC) $(CFLAGS) eglgears.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) eglgears.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
eglgears.o: eglgears.c $(HEADERS)
|
||||
$(CC) -c $(CFLAGS) -I$(TOP)/include eglgears.c
|
||||
|
||||
@@ -22,7 +22,7 @@ INCLUDES = \
|
||||
.SUFFIXES: .c
|
||||
|
||||
.c:
|
||||
$(CC) $(INCLUDES) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
$(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
|
||||
|
||||
+10
-3
@@ -8,13 +8,16 @@ INCDIR = $(TOP)/include
|
||||
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
||||
|
||||
PROGS = \
|
||||
bitmap \
|
||||
brick \
|
||||
bump \
|
||||
deriv \
|
||||
mandelbrot \
|
||||
noise \
|
||||
points \
|
||||
texdemo1 \
|
||||
toyball \
|
||||
texdemo1
|
||||
trirast
|
||||
|
||||
|
||||
##### RULES #####
|
||||
@@ -25,7 +28,7 @@ PROGS = \
|
||||
|
||||
# make executable from .c file:
|
||||
.c: $(LIB_DEP)
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
|
||||
|
||||
##### TARGETS #####
|
||||
@@ -48,16 +51,20 @@ readtex.h: $(TOP)/progs/util/readtex.h
|
||||
readtex.o: readtex.c readtex.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) readtex.c
|
||||
|
||||
bitmap.c: extfuncs.h
|
||||
|
||||
brick.c: extfuncs.h
|
||||
|
||||
bump.c: extfuncs.h
|
||||
|
||||
mandelbrot.c: extfuncs.h
|
||||
|
||||
points.c: extfuncs.h
|
||||
|
||||
toyball.c: extfuncs.h
|
||||
|
||||
texdemo1: texdemo1.o readtex.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) texdemo1.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) texdemo1.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
texdemo1.o: texdemo1.c readtex.h extfuncs.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c
|
||||
|
||||
@@ -0,0 +1,368 @@
|
||||
/**
|
||||
* Implement glRasterPos + glBitmap with textures + shaders.
|
||||
* Brian Paul
|
||||
* 14 May 2007
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
|
||||
|
||||
static GLuint FragShader;
|
||||
static GLuint VertShader;
|
||||
static GLuint Program;
|
||||
|
||||
static GLint Win = 0;
|
||||
static GLint WinWidth = 500, WinHeight = 500;
|
||||
static GLboolean Anim = GL_TRUE;
|
||||
static GLboolean Bitmap = GL_FALSE;
|
||||
static GLfloat Xrot = 20.0f, Yrot = 70.0f;
|
||||
static GLint uTex, uScale;
|
||||
static GLuint Textures[2];
|
||||
|
||||
#define TEX_WIDTH 16
|
||||
#define TEX_HEIGHT 8
|
||||
|
||||
|
||||
static void
|
||||
BitmapText(const char *s)
|
||||
{
|
||||
while (*s) {
|
||||
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Redisplay(void)
|
||||
{
|
||||
static const GLfloat px[3] = { 1.2, 0, 0};
|
||||
static const GLfloat nx[3] = {-1.2, 0, 0};
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(Xrot, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(Yrot, 0.0f, 1.0f, 0.0f);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
glPushMatrix();
|
||||
glScalef(0.5, 0.5, 0.5);
|
||||
glutSolidDodecahedron();
|
||||
glPopMatrix();
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
glColor3f(0, 1, 0);
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(-1, 0, 0);
|
||||
glVertex3f( 1, 0, 0);
|
||||
glEnd();
|
||||
|
||||
glColor3f(1, 1, 0);
|
||||
|
||||
if (Bitmap) {
|
||||
glRasterPos3fv(px);
|
||||
BitmapText("+X");
|
||||
glRasterPos3fv(nx);
|
||||
BitmapText("-X");
|
||||
}
|
||||
else {
|
||||
glUseProgram_func(Program);
|
||||
|
||||
/* vertex positions (deltas) depend on texture size and window size */
|
||||
if (uScale != -1) {
|
||||
glUniform2f_func(uScale,
|
||||
2.0 * TEX_WIDTH / WinWidth,
|
||||
2.0 * TEX_HEIGHT / WinHeight);
|
||||
}
|
||||
|
||||
/* draw +X */
|
||||
glBindTexture(GL_TEXTURE_2D, Textures[0]);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex3fv(px);
|
||||
glTexCoord2f(1, 0); glVertex3fv(px);
|
||||
glTexCoord2f(1, 1); glVertex3fv(px);
|
||||
glTexCoord2f(0, 1); glVertex3fv(px);
|
||||
glEnd();
|
||||
|
||||
/* draw -X */
|
||||
glBindTexture(GL_TEXTURE_2D, Textures[1]);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0); glVertex3fv(nx);
|
||||
glTexCoord2f(1, 0); glVertex3fv(nx);
|
||||
glTexCoord2f(1, 1); glVertex3fv(nx);
|
||||
glTexCoord2f(0, 1); glVertex3fv(nx);
|
||||
glEnd();
|
||||
|
||||
glUseProgram_func(0);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Idle(void)
|
||||
{
|
||||
Yrot = glutGet(GLUT_ELAPSED_TIME) * 0.01;
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
{
|
||||
WinWidth = width;
|
||||
WinHeight = height;
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0f, 0.0f, -10.0f);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case ' ':
|
||||
case 'a':
|
||||
Anim = !Anim;
|
||||
if (Anim)
|
||||
glutIdleFunc(Idle);
|
||||
else
|
||||
glutIdleFunc(NULL);
|
||||
break;
|
||||
case 'b':
|
||||
Bitmap = !Bitmap;
|
||||
if (Bitmap)
|
||||
printf("Using glBitmap\n");
|
||||
else
|
||||
printf("Using billboard texture\n");
|
||||
break;
|
||||
case 27:
|
||||
glDeleteShader_func(FragShader);
|
||||
glDeleteShader_func(VertShader);
|
||||
glDeleteProgram_func(Program);
|
||||
glutDestroyWindow(Win);
|
||||
exit(0);
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SpecialKey(int key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 0.125f;
|
||||
switch(key) {
|
||||
case GLUT_KEY_UP:
|
||||
Xrot -= step;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
Xrot += step;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
Yrot -= step;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
Yrot += step;
|
||||
break;
|
||||
}
|
||||
/*printf("Xrot: %f Yrot: %f\n", Xrot, Yrot);*/
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
MakeTexImage(const char *p, GLuint texobj)
|
||||
{
|
||||
GLubyte image[TEX_HEIGHT][TEX_WIDTH];
|
||||
GLuint i, j, k;
|
||||
|
||||
for (i = 0; i < TEX_HEIGHT; i++) {
|
||||
for (j = 0; j < TEX_WIDTH; j++) {
|
||||
k = i * TEX_WIDTH + j;
|
||||
if (p[k] == ' ') {
|
||||
image[i][j] = 0;
|
||||
}
|
||||
else {
|
||||
image[i][j] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texobj);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY, TEX_WIDTH, TEX_HEIGHT, 0,
|
||||
GL_RED, GL_UNSIGNED_BYTE, image);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
MakeBitmapTextures(void)
|
||||
{
|
||||
const char *px =
|
||||
" X X "
|
||||
" X X X "
|
||||
" X X X "
|
||||
" XXXXX X "
|
||||
" X X X "
|
||||
" X X X "
|
||||
" X X "
|
||||
" X X ";
|
||||
const char *nx =
|
||||
" X X "
|
||||
" X X "
|
||||
" X X "
|
||||
" XXXXX X "
|
||||
" X X "
|
||||
" X X "
|
||||
" X X "
|
||||
" X X ";
|
||||
glGenTextures(2, Textures);
|
||||
MakeTexImage(px, Textures[0]);
|
||||
MakeTexImage(nx, Textures[1]);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
/* Fragment shader: modulate raster color by texture, discard fragments
|
||||
* with alpha < 1.0
|
||||
*/
|
||||
static const char *fragShaderText =
|
||||
"uniform sampler2D tex2d; \n"
|
||||
"void main() {\n"
|
||||
" vec4 c = texture2D(tex2d, gl_TexCoord[0].xy); \n"
|
||||
" if (c.w < 1.0) \n"
|
||||
" discard; \n"
|
||||
" gl_FragColor = c * gl_Color; \n"
|
||||
"}\n";
|
||||
/* Vertex shader: compute new vertex position based on incoming vertex pos,
|
||||
* texcoords and special scale factor.
|
||||
*/
|
||||
static const char *vertShaderText =
|
||||
"uniform vec2 scale; \n"
|
||||
"void main() {\n"
|
||||
" vec4 p = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||
" gl_Position.xy = p.xy + gl_MultiTexCoord0.xy * scale * p.w; \n"
|
||||
" gl_Position.zw = p.zw; \n"
|
||||
" gl_TexCoord[0] = gl_MultiTexCoord0; \n"
|
||||
" gl_FrontColor = gl_Color; \n"
|
||||
"}\n";
|
||||
const char *version;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("This program requires OpenGL 2.x, found %s\n", version);
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
FragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
LoadAndCompileShader(FragShader, fragShaderText);
|
||||
|
||||
VertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
LoadAndCompileShader(VertShader, vertShaderText);
|
||||
|
||||
Program = glCreateProgram_func();
|
||||
glAttachShader_func(Program, FragShader);
|
||||
glAttachShader_func(Program, VertShader);
|
||||
glLinkProgram_func(Program);
|
||||
CheckLink(Program);
|
||||
glUseProgram_func(Program);
|
||||
|
||||
uScale = glGetUniformLocation_func(Program, "scale");
|
||||
uTex = glGetUniformLocation_func(Program, "tex2d");
|
||||
if (uTex != -1) {
|
||||
glUniform1i_func(uTex, 0); /* tex unit 0 */
|
||||
}
|
||||
|
||||
glUseProgram_func(0);
|
||||
|
||||
glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_NORMALIZE);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
||||
MakeBitmapTextures();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutDisplayFunc(Redisplay);
|
||||
if (Anim)
|
||||
glutIdleFunc(Idle);
|
||||
Init();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
/**
|
||||
* Implement smooth (AA) points with shaders.
|
||||
* A simple variation could be used for sprite points.
|
||||
* Brian Paul
|
||||
* 29 July 2007
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
|
||||
|
||||
static GLuint FragShader;
|
||||
static GLuint VertShader;
|
||||
static GLuint Program;
|
||||
|
||||
static GLint Win = 0;
|
||||
static GLint WinWidth = 500, WinHeight = 200;
|
||||
static GLfloat Xpos = 0.0f, Ypos = 0.0f;
|
||||
static GLint uViewportInv;
|
||||
static GLboolean Smooth = GL_TRUE, Blend = GL_TRUE;
|
||||
|
||||
|
||||
/**
|
||||
* Issue vertices for a "shader point".
|
||||
* The position is duplicated, only texcoords (or other vertex attrib) change.
|
||||
* The vertex program will compute the "real" quad corners.
|
||||
*/
|
||||
static void
|
||||
PointVertex3f(GLfloat x, GLfloat y, GLfloat z)
|
||||
{
|
||||
glTexCoord2f(-1, -1);
|
||||
glVertex3f(x, y, z);
|
||||
|
||||
glTexCoord2f( 1, -1);
|
||||
glVertex3f(x, y, z);
|
||||
|
||||
glTexCoord2f( 1, 1);
|
||||
glVertex3f(x, y, z);
|
||||
|
||||
glTexCoord2f(-1, 1);
|
||||
glVertex3f(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawPoints(GLboolean shaderPoints)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 9; i++) {
|
||||
GLfloat x = i - 4, y = 0, z = 0;
|
||||
/* note: can't call glPointSize inside Begin/End :( */
|
||||
glPointSize( 2 + i * 5 );
|
||||
if (shaderPoints) {
|
||||
glBegin(GL_QUADS);
|
||||
PointVertex3f(x, y, z);
|
||||
glEnd();
|
||||
}
|
||||
else {
|
||||
glBegin(GL_POINTS);
|
||||
glVertex3f(x, y, z);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Top row of points rendered convetionally,
|
||||
* bottom row rendered with shaders.
|
||||
*/
|
||||
static void
|
||||
Redisplay(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if (Smooth)
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
else
|
||||
glDisable(GL_POINT_SMOOTH);
|
||||
|
||||
if (Blend)
|
||||
glEnable(GL_BLEND);
|
||||
else
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(Xpos, Ypos, 0);
|
||||
|
||||
/*
|
||||
* regular points
|
||||
*/
|
||||
glPushMatrix();
|
||||
glTranslatef(0, 1.2, 0);
|
||||
glUseProgram_func(0);
|
||||
DrawPoints(GL_FALSE);
|
||||
glPopMatrix();
|
||||
|
||||
/*
|
||||
* shader points
|
||||
*/
|
||||
glPushMatrix();
|
||||
glTranslatef(0, -1.2, 0);
|
||||
glUseProgram_func(Program);
|
||||
if (uViewportInv != -1) {
|
||||
glUniform2f_func(uViewportInv, 1.0 / WinWidth, 1.0 / WinHeight);
|
||||
}
|
||||
DrawPoints(GL_TRUE);
|
||||
glPopMatrix();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
{
|
||||
WinWidth = width;
|
||||
WinHeight = height;
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 4.0, 30.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0f, 0.0f, -20.0f);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case 'b':
|
||||
Blend = !Blend;
|
||||
break;
|
||||
case 's':
|
||||
Smooth = !Smooth;
|
||||
break;
|
||||
case 27:
|
||||
glDeleteShader_func(FragShader);
|
||||
glDeleteShader_func(VertShader);
|
||||
glDeleteProgram_func(Program);
|
||||
glutDestroyWindow(Win);
|
||||
exit(0);
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SpecialKey(int key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 1/100.0;
|
||||
switch(key) {
|
||||
case GLUT_KEY_UP:
|
||||
Ypos += step;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
Ypos -= step;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
Xpos -= step;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
Xpos += step;
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
/* Fragment shader: compute distance of fragment from center of point
|
||||
* (we're using texcoords but another varying could be used).
|
||||
* if dist > 1, discard (coverage==0)
|
||||
* if dist < k, coverage = 1
|
||||
* else, coverage = func(dist)
|
||||
* Note: length() uses sqrt() and may be expensive. The distance could
|
||||
* be squared instead (with adjustments to the threshold (k) test)
|
||||
*/
|
||||
static const char *fragShaderText =
|
||||
"void main() {\n"
|
||||
" float cover; \n"
|
||||
" float k = 2.0 / gl_Point.size; \n"
|
||||
" float d = length(gl_TexCoord[0].xy); \n"
|
||||
" if (d >= 1.0) \n"
|
||||
" discard; \n"
|
||||
" if (d < 1.0 - k) \n"
|
||||
" cover = 1.0; \n"
|
||||
" else \n"
|
||||
" cover = (1.0 - d) * 0.5 * gl_Point.size; \n"
|
||||
" gl_FragColor.rgb = gl_Color.rgb; \n"
|
||||
" gl_FragColor.a = cover; \n"
|
||||
"}\n";
|
||||
/* Vertex shader: compute new vertex position based on incoming vertex pos,
|
||||
* texcoords, point size, and inverse viewport scale factor.
|
||||
* Note: should compute point size attenuation here too.
|
||||
*/
|
||||
static const char *vertShaderText =
|
||||
"uniform vec2 viewportInv; \n"
|
||||
"void main() {\n"
|
||||
" vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||
" gl_Position.xy = pos.xy + gl_MultiTexCoord0.xy * viewportInv \n"
|
||||
" * gl_Point.size * pos.w; \n"
|
||||
" gl_Position.zw = pos.zw; \n"
|
||||
" gl_TexCoord[0] = gl_MultiTexCoord0; \n"
|
||||
" gl_FrontColor = gl_Color; \n"
|
||||
"}\n";
|
||||
const char *version;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("This program requires OpenGL 2.x, found %s\n", version);
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
FragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
LoadAndCompileShader(FragShader, fragShaderText);
|
||||
|
||||
VertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
LoadAndCompileShader(VertShader, vertShaderText);
|
||||
|
||||
Program = glCreateProgram_func();
|
||||
glAttachShader_func(Program, FragShader);
|
||||
glAttachShader_func(Program, VertShader);
|
||||
glLinkProgram_func(Program);
|
||||
CheckLink(Program);
|
||||
glUseProgram_func(Program);
|
||||
|
||||
uViewportInv = glGetUniformLocation_func(Program, "viewportInv");
|
||||
|
||||
glUseProgram_func(0);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutDisplayFunc(Redisplay);
|
||||
Init();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
/**
|
||||
* Demonstration of doing triangle rasterization with a fragment program.
|
||||
* Basic idea:
|
||||
* 1. Draw screen-aligned quad / bounding box around the triangle verts.
|
||||
* 2. For each pixel in the quad, determine if pixel is inside/outside
|
||||
* the triangle edges.
|
||||
*
|
||||
* Brian Paul
|
||||
* 1 Aug 2007
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
|
||||
|
||||
static GLint WinWidth = 300, WinHeight = 300;
|
||||
static char *FragProgFile = NULL;
|
||||
static char *VertProgFile = NULL;
|
||||
static GLuint fragShader;
|
||||
static GLuint vertShader;
|
||||
static GLuint program;
|
||||
static GLint win = 0;
|
||||
static GLboolean anim = GL_TRUE;
|
||||
static GLfloat Zrot = 0.0f;
|
||||
static GLint uv0, uv1, uv2;
|
||||
|
||||
|
||||
static const GLfloat TriVerts[3][2] = {
|
||||
{ 50, 50 },
|
||||
{ 250, 50 },
|
||||
{ 150, 250 }
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
RotateVerts(GLfloat a,
|
||||
GLuint n, const GLfloat vertsIn[][2], GLfloat vertsOut[][2])
|
||||
{
|
||||
GLuint i;
|
||||
GLfloat cx = WinWidth / 2, cy = WinHeight / 2;
|
||||
for (i = 0; i < n; i++) {
|
||||
float x = vertsIn[i][0] - cx;
|
||||
float y = vertsIn[i][1] - cy;
|
||||
|
||||
vertsOut[i][0] = x * cos(a) + y * sin(a) + cx;
|
||||
vertsOut[i][1] = -x * sin(a) + y * cos(a) + cy;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ComputeBounds(GLuint n, GLfloat vertsIn[][2],
|
||||
GLfloat *xmin, GLfloat *ymin,
|
||||
GLfloat *xmax, GLfloat *ymax)
|
||||
{
|
||||
GLuint i;
|
||||
*xmin = *xmax = vertsIn[0][0];
|
||||
*ymin = *ymax = vertsIn[0][1];
|
||||
for (i = 1; i < n; i++) {
|
||||
if (vertsIn[i][0] < *xmin)
|
||||
*xmin = vertsIn[i][0];
|
||||
else if (vertsIn[i][0] > *xmax)
|
||||
*xmax = vertsIn[i][0];
|
||||
if (vertsIn[i][1] < *ymin)
|
||||
*ymin = vertsIn[i][1];
|
||||
else if (vertsIn[i][1] > *ymax)
|
||||
*ymax = vertsIn[i][1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Redisplay(void)
|
||||
{
|
||||
GLfloat v[3][2], xmin, ymin, xmax, ymax;
|
||||
|
||||
RotateVerts(Zrot, 3, TriVerts, v);
|
||||
ComputeBounds(3, v, &xmin, &ymin, &xmax, &ymax);
|
||||
|
||||
glUniform2fv_func(uv0, 1, v[0]);
|
||||
glUniform2fv_func(uv1, 1, v[1]);
|
||||
glUniform2fv_func(uv2, 1, v[2]);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glBegin(GL_POLYGON);
|
||||
glVertex2f(xmin, ymin);
|
||||
glVertex2f(xmax, ymin);
|
||||
glVertex2f(xmax, ymax);
|
||||
glVertex2f(xmin, ymax);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Idle(void)
|
||||
{
|
||||
Zrot = glutGet(GLUT_ELAPSED_TIME) * 0.0005;
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, width, 0, height, -1, 1);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CleanUp(void)
|
||||
{
|
||||
glDeleteShader_func(fragShader);
|
||||
glDeleteShader_func(vertShader);
|
||||
glDeleteProgram_func(program);
|
||||
glutDestroyWindow(win);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case ' ':
|
||||
case 'a':
|
||||
anim = !anim;
|
||||
if (anim)
|
||||
glutIdleFunc(Idle);
|
||||
else
|
||||
glutIdleFunc(NULL);
|
||||
break;
|
||||
case 27:
|
||||
CleanUp();
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a shader from a file.
|
||||
*/
|
||||
static void
|
||||
ReadShader(GLuint shader, const char *filename)
|
||||
{
|
||||
const int max = 100*1000;
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
FILE *f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "fslight: Unable to open shader file %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
n = fread(buffer, 1, max, f);
|
||||
printf("fslight: read %d bytes from shader file %s\n", n, filename);
|
||||
if (n > 0) {
|
||||
buffer[n] = 0;
|
||||
LoadAndCompileShader(shader, buffer);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
static const char *fragShaderText =
|
||||
"uniform vec2 v0, v1, v2; \n"
|
||||
"float crs(const vec2 u, const vec2 v) \n"
|
||||
"{ \n"
|
||||
" return u.x * v.y - u.y * v.x; \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
"void main() {\n"
|
||||
" vec2 p = gl_FragCoord.xy; \n"
|
||||
" if (crs(v1 - v0, p - v0) >= 0 && \n"
|
||||
" crs(v2 - v1, p - v1) >= 0 && \n"
|
||||
" crs(v0 - v2, p - v2) >= 0) \n"
|
||||
" gl_FragColor = vec4(1.0); \n"
|
||||
" else \n"
|
||||
" gl_FragColor = vec4(0.5); \n"
|
||||
"}\n";
|
||||
static const char *vertShaderText =
|
||||
"void main() {\n"
|
||||
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||
"}\n";
|
||||
const char *version;
|
||||
|
||||
version = (const char *) glGetString(GL_VERSION);
|
||||
if (version[0] != '2' || version[1] != '.') {
|
||||
printf("This program requires OpenGL 2.x, found %s\n", version);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
if (FragProgFile)
|
||||
ReadShader(fragShader, FragProgFile);
|
||||
else
|
||||
LoadAndCompileShader(fragShader, fragShaderText);
|
||||
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
if (VertProgFile)
|
||||
ReadShader(vertShader, VertProgFile);
|
||||
else
|
||||
LoadAndCompileShader(vertShader, vertShaderText);
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
glAttachShader_func(program, vertShader);
|
||||
glLinkProgram_func(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
|
||||
uv0 = glGetUniformLocation_func(program, "v0");
|
||||
uv1 = glGetUniformLocation_func(program, "v1");
|
||||
uv2 = glGetUniformLocation_func(program, "v2");
|
||||
printf("Uniforms: %d %d %d\n", uv0, uv1, uv2);
|
||||
|
||||
/*assert(glGetError() == 0);*/
|
||||
|
||||
glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
|
||||
|
||||
assert(glIsProgram_func(program));
|
||||
assert(glIsShader_func(fragShader));
|
||||
assert(glIsShader_func(vertShader));
|
||||
|
||||
glColor3f(1, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ParseOptions(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-fs") == 0) {
|
||||
FragProgFile = argv[i+1];
|
||||
}
|
||||
else if (strcmp(argv[i], "-vs") == 0) {
|
||||
VertProgFile = argv[i+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
if (anim)
|
||||
glutIdleFunc(Idle);
|
||||
ParseOptions(argc, argv);
|
||||
Init();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ INCLUDES = \
|
||||
.SUFFIXES: .c
|
||||
|
||||
.c:
|
||||
$(CC) $(INCLUDES) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
$(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
|
||||
|
||||
@@ -26,7 +26,7 @@ PROGS = \
|
||||
|
||||
# make executable from .c file:
|
||||
.c: $(LIB_DEP) readtex.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
|
||||
##### TARGETS #####
|
||||
@@ -56,19 +56,19 @@ showbuffer.o: showbuffer.c showbuffer.h
|
||||
|
||||
# special case: need the -lOSMesa library:
|
||||
osdemo: osdemo.c
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) osdemo.c $(OSMESA_LIBS) -o $@
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) osdemo.c $(OSMESA_LIBS) -o $@
|
||||
|
||||
# special case: need the -lOSMesa library:
|
||||
ostest1: ostest1.c
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) ostest1.c $(OSMESA_LIBS) -o $@
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) ostest1.c $(OSMESA_LIBS) -o $@
|
||||
|
||||
# another special case: need the -lOSMesa16 library:
|
||||
osdemo16: osdemo16.c
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) osdemo16.c $(OSMESA16_LIBS) -o $@
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) osdemo16.c $(OSMESA16_LIBS) -o $@
|
||||
|
||||
# another special case: need the -lOSMesa32 library:
|
||||
osdemo32: osdemo32.c
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) osdemo32.c $(OSMESA32_LIBS) -o $@
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) osdemo32.c $(OSMESA32_LIBS) -o $@
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -409,6 +409,8 @@ test(GLenum type, GLint bits, const char *filename)
|
||||
|
||||
printf("Rendering %d bit/channel image: %s\n", bits, filename);
|
||||
|
||||
OSMesaColorClamp(GL_TRUE);
|
||||
|
||||
init_context();
|
||||
render_image();
|
||||
if (Gradient)
|
||||
@@ -421,7 +423,7 @@ test(GLenum type, GLint bits, const char *filename)
|
||||
if (WriteFiles && filename != NULL) {
|
||||
if (type == GL_UNSIGNED_SHORT) {
|
||||
GLushort *buffer16 = (GLushort *) buffer;
|
||||
GLubyte *buffer8 = malloc(WIDTH * HEIGHT * 4);
|
||||
GLubyte *buffer8 = (GLubyte *) malloc(WIDTH * HEIGHT * 4);
|
||||
int i;
|
||||
for (i = 0; i < WIDTH * HEIGHT * 4; i++)
|
||||
buffer8[i] = buffer16[i] >> 8;
|
||||
@@ -430,8 +432,9 @@ test(GLenum type, GLint bits, const char *filename)
|
||||
}
|
||||
else if (type == GL_FLOAT) {
|
||||
GLfloat *buffer32 = (GLfloat *) buffer;
|
||||
GLubyte *buffer8 = malloc(WIDTH * HEIGHT * 4);
|
||||
GLubyte *buffer8 = (GLubyte *) malloc(WIDTH * HEIGHT * 4);
|
||||
int i;
|
||||
/* colors may be outside [0,1] so we need to clamp */
|
||||
for (i = 0; i < WIDTH * HEIGHT * 4; i++)
|
||||
buffer8[i] = (GLubyte) (buffer32[i] * 255.0);
|
||||
write_ppm(filename, buffer8, WIDTH, HEIGHT);
|
||||
|
||||
@@ -24,7 +24,7 @@ PROGS = aaindex aapoly aargb accanti accpersp alpha alpha3D anti \
|
||||
.SUFFIXES: .c
|
||||
|
||||
.c: $(LIB_DEP)
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
|
||||
.SUFFIXES: .c
|
||||
|
||||
.c: $(LIB_DEP)
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
|
||||
|
||||
##### TARGETS #####
|
||||
@@ -27,7 +27,7 @@ default: $(PROGS)
|
||||
|
||||
|
||||
sphere: sphere.o readtex.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) sphere.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) sphere.o readtex.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
sphere.o: sphere.c readtex.h
|
||||
$(CC) -c -I$(INCDIR) $(CFLAGS) sphere.c
|
||||
|
||||
@@ -53,14 +53,9 @@
|
||||
|
||||
TOP = ../..
|
||||
|
||||
include $(TOP)/configs/config.mgw
|
||||
ALL_USING_STDCALL ?= 1
|
||||
GL_USING_STDCALL ?= 1
|
||||
GLUT_USING_STDCALL ?= 1
|
||||
|
||||
CC = mingw32-gcc
|
||||
CFLAGS = -Wall -pedantic
|
||||
CFLAGS += -O2 -ffast-math
|
||||
CFLAGS += -O2 -ffast-math -D_DLL
|
||||
CFLAGS += -I$(TOP)/include -I../util
|
||||
ifeq ($(FX),1)
|
||||
CFLAGS += -DFX
|
||||
@@ -68,17 +63,6 @@ endif
|
||||
|
||||
CFLAGS += -DGLUT_DISABLE_ATEXIT_HACK
|
||||
|
||||
ifeq ($(GL_USING_STDCALL),0)
|
||||
CFLAGS += -DGL_NO_STDCALL
|
||||
endif
|
||||
|
||||
ifeq ($(GLUT_USING_STDCALL),1)
|
||||
CFLAGS += -D_STDCALL_SUPPORTED
|
||||
else
|
||||
CFLAGS += -DGLUT_NO_STDCALL
|
||||
endif
|
||||
|
||||
|
||||
LD = mingw32-g++
|
||||
LDFLAGS = -s -L$(TOP)/lib
|
||||
|
||||
@@ -87,7 +71,8 @@ LDLIBS = -lglut32 -lglu32 -lopengl32
|
||||
.c.o:
|
||||
$(CC) -o $@ $(CFLAGS) -c $<
|
||||
%.exe: ../util/readtex.o ../util/showbuffer.o %.o
|
||||
$(LD) -o $@ $(LDFLAGS) $^ $(LDLIBS)
|
||||
$(LD) -o $@ $(LDFLAGS) $(LDLIBS) $^
|
||||
|
||||
|
||||
all:
|
||||
$(error Must specify <filename.exe> to build)
|
||||
|
||||
@@ -29,13 +29,13 @@ clean:
|
||||
#
|
||||
|
||||
cltest: cltest.o framework.o $(LIB_DEP)
|
||||
$(CC) cltest.o framework.o $(APP_LIB_DEPS) -o cltest
|
||||
$(CC) $(LDFLAGS) cltest.o framework.o $(APP_LIB_DEPS) -o cltest
|
||||
|
||||
sotest: sotest.o framework.o $(LIB_DEP)
|
||||
$(CC) sotest.o framework.o $(APP_LIB_DEPS) -o sotest
|
||||
$(CC) $(LDFLAGS) sotest.o framework.o $(APP_LIB_DEPS) -o sotest
|
||||
|
||||
vstest: vstest.o framework.o $(LIB_DEP)
|
||||
$(CC) vstest.o framework.o $(APP_LIB_DEPS) -o vstest
|
||||
$(CC) $(LDFLAGS) vstest.o framework.o $(APP_LIB_DEPS) -o vstest
|
||||
|
||||
#
|
||||
# objects
|
||||
|
||||
@@ -1,23 +1,32 @@
|
||||
.cvsignore
|
||||
getproclist.h
|
||||
afsmultiarb
|
||||
antialias
|
||||
arbfpspec
|
||||
arbfptest1
|
||||
arbfptexture
|
||||
arbfptrig
|
||||
arbnpot
|
||||
arbnpot-mipmap
|
||||
arbvptest1
|
||||
arbvptest3
|
||||
arbvptorus
|
||||
arbvpwarpmesh
|
||||
arraytexture
|
||||
blendminmax
|
||||
blendsquare
|
||||
bufferobj
|
||||
bug_3050
|
||||
bug_3101
|
||||
bug_3195
|
||||
copypixrate
|
||||
crossbar
|
||||
cva
|
||||
dinoshade
|
||||
drawbuffers
|
||||
extfuncs.h
|
||||
fbotest1
|
||||
fbotest2
|
||||
fbotexture
|
||||
floattex
|
||||
fog
|
||||
@@ -25,24 +34,37 @@ fogcoord
|
||||
fptest1
|
||||
fptexture
|
||||
getprocaddress
|
||||
jkrahntest
|
||||
interleave
|
||||
invert
|
||||
manytex
|
||||
mipmap_limits
|
||||
multipal
|
||||
no_s3tc
|
||||
packedpixels
|
||||
pbo
|
||||
projtex
|
||||
prog_parameter
|
||||
random
|
||||
readrate
|
||||
readtex.c
|
||||
readtex.h
|
||||
seccolor
|
||||
sharedtex
|
||||
stencil_wrap
|
||||
stencilwrap
|
||||
subtexrate
|
||||
tex1d
|
||||
texcmp
|
||||
texcompress2
|
||||
texfilt
|
||||
texgenmix
|
||||
texline
|
||||
texobjshare
|
||||
texrect
|
||||
texwrap
|
||||
vao-01
|
||||
vao-02
|
||||
vparray
|
||||
vptest1
|
||||
vptest2
|
||||
|
||||
+25
-27
@@ -88,21 +88,6 @@ INCLUDES = -I. -I$(TOP)/include
|
||||
UTIL_FILES = readtex.h readtex.c
|
||||
|
||||
|
||||
##### RULES #####
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c
|
||||
|
||||
.c:
|
||||
$(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
.S.o:
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
|
||||
##### TARGETS #####
|
||||
|
||||
default: $(UTIL_FILES) $(PROGS)
|
||||
@@ -112,6 +97,19 @@ clean:
|
||||
rm -f *.o
|
||||
rm -f getproclist.h
|
||||
|
||||
##### RULES #####
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c
|
||||
|
||||
.c:
|
||||
$(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
.S.o:
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
# auto code generation
|
||||
getprocaddress: getprocaddress.c getproclist.h
|
||||
@@ -123,40 +121,40 @@ arraytexture: arraytexture.o readtex.o
|
||||
$(CC) $(CFLAGS) arraytexture.o readtex.o $(LIBS) -o $@
|
||||
|
||||
arraytexture.o: arraytexture.c readtex.h
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) arraytexture.c -o $@
|
||||
|
||||
afsmultiarb: afsmultiarb.o readtex.o
|
||||
$(CC) $(CFLAGS) afsmultiarb.o readtex.o $(LIBS) -o $@
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) afsmultiarb.o readtex.o $(LIBS) -o $@
|
||||
|
||||
afsmultiarb.o: afsmultiarb.c readtex.h
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) afsmultiarb.c -o $@
|
||||
|
||||
drawbuffers: drawbuffers.o
|
||||
$(CC) $(CFLAGS) drawbuffers.o $(LIBS) -o $@
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) drawbuffers.o $(LIBS) -o $@
|
||||
|
||||
drawbuffers.o: drawbuffers.c extfuncs.h
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) drawbuffers.c -o $@
|
||||
|
||||
texrect: texrect.o readtex.o
|
||||
$(CC) $(CFLAGS) texrect.o readtex.o $(LIBS) -o $@
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) texrect.o readtex.o $(LIBS) -o $@
|
||||
|
||||
texrect.o: texrect.c readtex.h
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) texrect.c -o $@
|
||||
|
||||
bug_3195: bug_3195.o readtex.o
|
||||
$(CC) $(CFLAGS) bug_3195.o readtex.o $(LIBS) -o $@
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) bug_3195.o readtex.o $(LIBS) -o $@
|
||||
|
||||
bug_3195.o: bug_3195.c readtex.h
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) bug_3195.c -o $@
|
||||
|
||||
invert: invert.o readtex.o
|
||||
$(CC) $(CFLAGS) invert.o readtex.o $(LIBS) -o $@
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) invert.o readtex.o $(LIBS) -o $@
|
||||
|
||||
invert.o: invert.c readtex.h
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) invert.c -o $@
|
||||
|
||||
readtex.o: readtex.c
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) readtex.c -o $@
|
||||
|
||||
|
||||
readtex.h: $(TOP)/progs/util/readtex.h
|
||||
|
||||
+1
-5
@@ -11,11 +11,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef __VMS
|
||||
# include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
|
||||
#else
|
||||
# include <malloc.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
|
||||
#endif
|
||||
#include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
@@ -38,11 +38,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h> /* for cos(), sin(), and sqrt() */
|
||||
#ifdef __VMS
|
||||
# include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
|
||||
#else
|
||||
# include <malloc.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
|
||||
#endif
|
||||
#include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
@@ -9,11 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef __VMS
|
||||
# include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
|
||||
#else
|
||||
# include <malloc.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
|
||||
#endif
|
||||
#include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,7 @@ default: $(TRACER)
|
||||
|
||||
$(TRACER): $(OBJECTS)
|
||||
$(TOP)/bin/mklib -o $(TRACER) -noprefix -cplusplus \
|
||||
$(MKLIB_OPTIONS) $(OBJECTS)
|
||||
-ldflags '$(LDFLAGS)' $(MKLIB_OPTIONS) $(OBJECTS)
|
||||
|
||||
gltrace.cc: gltrace.py
|
||||
PYTHONPATH=$(TOP)/src/mesa/glapi python gltrace.py -f $(TOP)/src/mesa/glapi/gl_API.xml > gltrace.cc
|
||||
|
||||
@@ -88,7 +88,7 @@ UTIL_FILES = readtex.h readtex.c
|
||||
.SUFFIXES: .c
|
||||
|
||||
.c:
|
||||
$(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@
|
||||
$(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
@@ -115,13 +115,13 @@ getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress.
|
||||
|
||||
|
||||
texrect: texrect.o readtex.o
|
||||
$(CC) texrect.o readtex.o $(LIBS) -o $@
|
||||
$(CC) $(LDFLAGS) texrect.o readtex.o $(LIBS) -o $@
|
||||
|
||||
texrect.o: texrect.c readtex.h
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
invert: invert.o readtex.o
|
||||
$(CC) invert.o readtex.o $(LIBS) -o $@
|
||||
$(CC) $(LDFLAGS) invert.o readtex.o $(LIBS) -o $@
|
||||
|
||||
invert.o: invert.c readtex.h
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
@@ -26,6 +26,13 @@ static PFNGLISSHADERPROC glIsShader_func = NULL;
|
||||
static PFNGLLINKPROGRAMPROC glLinkProgram_func = NULL;
|
||||
static PFNGLSHADERSOURCEPROC glShaderSource_func = NULL;
|
||||
static PFNGLUNIFORM1IPROC glUniform1i_func = NULL;
|
||||
static PFNGLUNIFORM2IPROC glUniform2i_func = NULL;
|
||||
static PFNGLUNIFORM3IPROC glUniform3i_func = NULL;
|
||||
static PFNGLUNIFORM4IPROC glUniform4i_func = NULL;
|
||||
static PFNGLUNIFORM1FPROC glUniform1f_func = NULL;
|
||||
static PFNGLUNIFORM2FPROC glUniform2f_func = NULL;
|
||||
static PFNGLUNIFORM3FPROC glUniform3f_func = NULL;
|
||||
static PFNGLUNIFORM4FPROC glUniform4f_func = NULL;
|
||||
static PFNGLUNIFORM1FVPROC glUniform1fv_func = NULL;
|
||||
static PFNGLUNIFORM2FVPROC glUniform2fv_func = NULL;
|
||||
static PFNGLUNIFORM3FVPROC glUniform3fv_func = NULL;
|
||||
@@ -47,6 +54,9 @@ static PFNGLUNIFORMMATRIX4X2FVPROC glUniformMatrix4x2fv_func = NULL;
|
||||
static PFNGLUNIFORMMATRIX3X4FVPROC glUniformMatrix3x4fv_func = NULL;
|
||||
static PFNGLUNIFORMMATRIX4X3FVPROC glUniformMatrix4x3fv_func = NULL;
|
||||
|
||||
/* OpenGL 1.4 */
|
||||
static PFNGLPOINTPARAMETERFVPROC glPointParameterfv_func = NULL;
|
||||
|
||||
/* GL_ARB_vertex/fragment_program */
|
||||
static PFNGLBINDPROGRAMARBPROC glBindProgramARB_func = NULL;
|
||||
static PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB_func = NULL;
|
||||
@@ -94,6 +104,13 @@ GetExtensionFuncs(void)
|
||||
glLinkProgram_func = (PFNGLLINKPROGRAMPROC) glutGetProcAddress("glLinkProgram");
|
||||
glShaderSource_func = (PFNGLSHADERSOURCEPROC) glutGetProcAddress("glShaderSource");
|
||||
glUniform1i_func = (PFNGLUNIFORM1IPROC) glutGetProcAddress("glUniform1i");
|
||||
glUniform2i_func = (PFNGLUNIFORM2IPROC) glutGetProcAddress("glUniform2i");
|
||||
glUniform3i_func = (PFNGLUNIFORM3IPROC) glutGetProcAddress("glUniform3i");
|
||||
glUniform4i_func = (PFNGLUNIFORM4IPROC) glutGetProcAddress("glUniform3i");
|
||||
glUniform1f_func = (PFNGLUNIFORM1FPROC) glutGetProcAddress("glUniform1f");
|
||||
glUniform2f_func = (PFNGLUNIFORM2FPROC) glutGetProcAddress("glUniform2f");
|
||||
glUniform3f_func = (PFNGLUNIFORM3FPROC) glutGetProcAddress("glUniform3f");
|
||||
glUniform4f_func = (PFNGLUNIFORM4FPROC) glutGetProcAddress("glUniform3f");
|
||||
glUniform1fv_func = (PFNGLUNIFORM1FVPROC) glutGetProcAddress("glUniform1fv");
|
||||
glUniform2fv_func = (PFNGLUNIFORM2FVPROC) glutGetProcAddress("glUniform2fv");
|
||||
glUniform3fv_func = (PFNGLUNIFORM3FVPROC) glutGetProcAddress("glUniform3fv");
|
||||
@@ -115,6 +132,8 @@ GetExtensionFuncs(void)
|
||||
glUniformMatrix3x4fv_func = (PFNGLUNIFORMMATRIX3X4FVPROC) glutGetProcAddress("glUniformMatrix3x4fv");
|
||||
glUniformMatrix4x3fv_func = (PFNGLUNIFORMMATRIX4X3FVPROC) glutGetProcAddress("glUniformMatrix4x3fv");
|
||||
|
||||
glPointParameterfv_func = (PFNGLPOINTPARAMETERFVPROC) glutGetProcAddress("glPointParameterfv");
|
||||
|
||||
/* GL_ARB_vertex/fragment_program */
|
||||
glBindProgramARB_func = (PFNGLBINDPROGRAMARBPROC) glutGetProcAddress("glBindProgramARB");
|
||||
glDeleteProgramsARB_func = (PFNGLDELETEPROGRAMSARBPROC) glutGetProcAddress("glDeleteProgramsARB");
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ INCLUDES = -I. -I$(TOP)/include -I../samples
|
||||
.SUFFIXES: .c
|
||||
|
||||
.c:
|
||||
$(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@
|
||||
$(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
glthreads
|
||||
glxcontexts
|
||||
glxdemo
|
||||
glxgears
|
||||
glxgears_fbconfig
|
||||
glxheads
|
||||
glxinfo
|
||||
glxpixmap
|
||||
@@ -8,9 +10,12 @@ glxpbdemo
|
||||
glxswapcontrol
|
||||
manywin
|
||||
offset
|
||||
overlay
|
||||
pbinfo
|
||||
pbdemo
|
||||
texture_from_pixmap
|
||||
wincopy
|
||||
xdemo
|
||||
xfont
|
||||
xrotfontdemo
|
||||
yuvrect_client
|
||||
|
||||
+11
-11
@@ -38,7 +38,7 @@ PROGS = glthreads \
|
||||
.SUFFIXES: .c
|
||||
|
||||
.c: $(LIB_DEP)
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
$(CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
|
||||
|
||||
|
||||
##### TARGETS #####
|
||||
@@ -53,32 +53,32 @@ clean:
|
||||
|
||||
# special cases
|
||||
pbinfo: pbinfo.o pbutil.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) pbinfo.o pbutil.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) $(LDFLAGS) pbinfo.o pbutil.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
pbdemo: pbdemo.o pbutil.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) pbdemo.o pbutil.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) $(LDFLAGS) pbdemo.o pbutil.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
pbinfo.o: pbinfo.c pbutil.h
|
||||
$(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbinfo.c
|
||||
$(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbinfo.c
|
||||
|
||||
pbdemo.o: pbdemo.c pbutil.h
|
||||
$(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbdemo.c
|
||||
$(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbdemo.c
|
||||
|
||||
pbutil.o: pbutil.c pbutil.h
|
||||
$(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbutil.c
|
||||
$(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbutil.c
|
||||
|
||||
glxgears_fbconfig: glxgears_fbconfig.o pbutil.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) glxgears_fbconfig.o pbutil.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) $(LDFLAGS) glxgears_fbconfig.o pbutil.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
glxgears_fbconfig.o: glxgears_fbconfig.c pbutil.h
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) -c -I. $(CFLAGS) glxgears_fbconfig.c
|
||||
$(CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) -c -I. $(CFLAGS) glxgears_fbconfig.c
|
||||
|
||||
xrotfontdemo: xrotfontdemo.o xuserotfont.o
|
||||
$(CC) -I$(INCDIR) $(CFLAGS) xrotfontdemo.o xuserotfont.o $(APP_LIB_DEPS) -o $@
|
||||
$(CC) $(LDFLAGS) xrotfontdemo.o xuserotfont.o $(APP_LIB_DEPS) -o $@
|
||||
|
||||
xuserotfont.o: xuserotfont.c xuserotfont.h
|
||||
$(CC) -c -I. -I$(INCDIR) $(CFLAGS) xuserotfont.c
|
||||
$(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) xuserotfont.c
|
||||
|
||||
xrotfontdemo.o: xrotfontdemo.c xuserotfont.h
|
||||
$(CC) -c -I. -I$(INCDIR) $(CFLAGS) xrotfontdemo.c
|
||||
$(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) xrotfontdemo.c
|
||||
|
||||
|
||||
+10
-3
@@ -433,7 +433,7 @@ make_window( Display *dpy, const char *name,
|
||||
attr.override_redirect = fullscreen;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
|
||||
|
||||
win = XCreateWindow( dpy, root, 0, 0, width, height,
|
||||
win = XCreateWindow( dpy, root, x, y, width, height,
|
||||
0, visinfo->depth, InputOutput,
|
||||
visinfo->visual, mask, &attr );
|
||||
|
||||
@@ -548,13 +548,16 @@ usage(void)
|
||||
printf(" -stereo run in stereo mode\n");
|
||||
printf(" -fullscreen run in fullscreen mode\n");
|
||||
printf(" -info display OpenGL renderer info\n");
|
||||
printf(" -winwidth <width> window width (default: 300)\n");
|
||||
printf(" -winheight <height> window height (default: 300)\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const int winWidth = 300, winHeight = 300;
|
||||
unsigned int winWidth = 300, winHeight = 300;
|
||||
int x = 0, y = 0;
|
||||
Display *dpy;
|
||||
Window win;
|
||||
GLXContext ctx;
|
||||
@@ -576,6 +579,10 @@ main(int argc, char *argv[])
|
||||
else if (strcmp(argv[i], "-fullscreen") == 0) {
|
||||
fullscreen = GL_TRUE;
|
||||
}
|
||||
else if (i < argc-1 && strcmp(argv[i], "-geometry") == 0) {
|
||||
XParseGeometry(argv[i+1], &x, &y, &winWidth, &winHeight);
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
return -1;
|
||||
@@ -589,7 +596,7 @@ main(int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
make_window(dpy, "glxgears", 0, 0, winWidth, winHeight, &win, &ctx);
|
||||
make_window(dpy, "glxgears", x, y, winWidth, winHeight, &win, &ctx);
|
||||
XMapWindow(dpy, win);
|
||||
glXMakeCurrent(dpy, win, ctx);
|
||||
|
||||
|
||||
@@ -814,6 +814,11 @@ main(int argc, char *argv[])
|
||||
|
||||
init();
|
||||
|
||||
/* Set initial projection/viewing transformation.
|
||||
* same as glxgears.c
|
||||
*/
|
||||
reshape(300, 300);
|
||||
|
||||
event_loop(dpy, win);
|
||||
|
||||
glXDestroyContext(dpy, ctx);
|
||||
|
||||
@@ -21,7 +21,7 @@ default: $(TOP)/$(LIB_DIR)/demodriver.so
|
||||
|
||||
|
||||
$(TOP)/$(LIB_DIR)/demodriver.so: $(OBJECTS)
|
||||
$(TOP)/bin/mklib -o demodriver.so -noprefix \
|
||||
$(TOP)/bin/mklib -o demodriver.so -noprefix -ldflags '$(LDFLAGS)' \
|
||||
-install $(TOP)/$(LIB_DIR) $(OBJECTS)
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ default: depend library Makefile
|
||||
library: $(TOP)/$(LIB_DIR)/libEGLdri.so
|
||||
|
||||
$(TOP)/$(LIB_DIR)/libEGLdri.so: $(OBJECTS)
|
||||
$(TOP)/bin/mklib -o EGLdri -major 1 -minor 0 \
|
||||
$(TOP)/bin/mklib -o EGLdri -ldflags '$(LDFLAGS)' -major 1 -minor 0 \
|
||||
-install $(TOP)/$(LIB_DIR) -ldl $(OBJECTS)
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ default: depend library
|
||||
library: $(TOP)/$(LIB_DIR)/libEGL.so
|
||||
|
||||
$(TOP)/$(LIB_DIR)/libEGL.so: $(OBJECTS)
|
||||
$(TOP)/bin/mklib -o EGL -major 1 -minor 0 \
|
||||
$(TOP)/bin/mklib -o EGL -ldflags '$(LDFLAGS)' -major 1 -minor 0 \
|
||||
-install $(TOP)/$(LIB_DIR) -ldl $(OBJECTS)
|
||||
|
||||
|
||||
|
||||
+13
-3
@@ -13,9 +13,19 @@ default: $(TOP)/configs/current
|
||||
(cd $$dir ; $(MAKE)) ; \
|
||||
done
|
||||
|
||||
install:
|
||||
$(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/libGLU.* $(INSTALL_DIR)/$(LIB_DIR)
|
||||
# GLU pkg-config file
|
||||
pcedit = sed \
|
||||
-e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
|
||||
-e 's,@LIB_DIR@,$(LIB_DIR),' \
|
||||
-e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),'
|
||||
glu.pc: glu.pc.in
|
||||
$(pcedit) $< > $@
|
||||
|
||||
install: glu.pc
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/libGLU.* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
|
||||
$(INSTALL) -m 644 glu.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
|
||||
|
||||
clean:
|
||||
@for dir in $(SUBDIRS) ; do \
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
prefix=@INSTALL_DIR@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/@LIB_DIR@
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: glu
|
||||
Description: Mesa OpenGL Utility library
|
||||
Requires: gl
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lGLU
|
||||
Cflags: -I${includedir}
|
||||
@@ -23,7 +23,7 @@ C_SOURCES = \
|
||||
|
||||
OBJECTS = $(C_SOURCES:.c=.o)
|
||||
|
||||
INCLUDES = -I. -I- -I$(TOP)/include
|
||||
INCLUDES = -I. -I$(TOP)/include
|
||||
|
||||
##### RULES #####
|
||||
|
||||
@@ -45,7 +45,7 @@ $(TOP)/$(LIB_DIR):
|
||||
|
||||
# Make the library:
|
||||
$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME): $(OBJECTS)
|
||||
@ $(TOP)/bin/mklib -o $(GLU_LIB) -linker '$(CC)' \
|
||||
@ $(TOP)/bin/mklib -o $(GLU_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
-major $(GLU_MAJOR) -minor $(GLU_MINOR) -patch $(GLU_TINY) \
|
||||
$(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
|
||||
$(GLU_LIB_DEPS) $(OBJECTS)
|
||||
|
||||
@@ -346,7 +346,8 @@ gluUnProject(GLdouble winx, GLdouble winy, GLdouble winz,
|
||||
|
||||
/* calcul transformation inverse */
|
||||
matmul(A, proj, model);
|
||||
invert_matrix(A, m);
|
||||
if (!invert_matrix(A, m))
|
||||
return GL_FALSE;
|
||||
|
||||
/* d'ou les coordonnees objets */
|
||||
transform_point(out, m, in);
|
||||
@@ -386,7 +387,8 @@ gluUnProject4(GLdouble winx, GLdouble winy, GLdouble winz, GLdouble clipw,
|
||||
|
||||
/* calcul transformation inverse */
|
||||
matmul(A, projMatrix, modelMatrix);
|
||||
invert_matrix(A, m);
|
||||
if (!invert_matrix(A, m))
|
||||
return GL_FALSE;
|
||||
|
||||
/* d'ou les coordonnees objets */
|
||||
transform_point(out, m, in);
|
||||
|
||||
@@ -347,7 +347,8 @@ gluUnProject(GLdouble winx, GLdouble winy, GLdouble winz,
|
||||
|
||||
/* calcul transformation inverse */
|
||||
matmul(A, proj, model);
|
||||
invert_matrix(A, m);
|
||||
if (!invert_matrix(A, m))
|
||||
return GL_FALSE;
|
||||
|
||||
/* d'ou les coordonnees objets */
|
||||
transform_point(out, m, in);
|
||||
@@ -387,7 +388,8 @@ gluUnProject4(GLdouble winx, GLdouble winy, GLdouble winz, GLdouble clipw,
|
||||
|
||||
/* calcul transformation inverse */
|
||||
matmul(A, projMatrix, modelMatrix);
|
||||
invert_matrix(A, m);
|
||||
if (!invert_matrix(A, m))
|
||||
return GL_FALSE;
|
||||
|
||||
/* d'ou les coordonnees objets */
|
||||
transform_point(out, m, in);
|
||||
|
||||
@@ -136,7 +136,7 @@ $(TOP)/$(LIB_DIR):
|
||||
|
||||
# Make the library:
|
||||
$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME): $(OBJECTS)
|
||||
$(TOP)/bin/mklib -o $(GLU_LIB) -linker '$(CXX)' \
|
||||
$(TOP)/bin/mklib -o $(GLU_LIB) -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
|
||||
-major $(GLU_MAJOR) -minor $(GLU_MINOR) -patch $(GLU_TINY) \
|
||||
-cplusplus $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
|
||||
$(GLU_LIB_DEPS) $(OBJECTS)
|
||||
|
||||
+18
-17
@@ -70,30 +70,31 @@
|
||||
TOOLS_PREFIX = mingw32-
|
||||
|
||||
TOP = ../../..
|
||||
|
||||
LIBDIR = $(TOP)/lib
|
||||
|
||||
GLU_DLL = glu32.dll
|
||||
GLU_IMP = libglu32.a
|
||||
GLU_DEF = glu.def
|
||||
LIB_NAME = glu32
|
||||
DLL_EXT = .dll
|
||||
IMP_EXT = .a
|
||||
LIB_PRE = lib
|
||||
STRIP = -s
|
||||
|
||||
include $(TOP)/configs/config.mgw
|
||||
GL_USING_STDCALL ?= 1
|
||||
AR = ar
|
||||
ARFLAGS = crus
|
||||
DLLTOOL = dlltool
|
||||
|
||||
GLU_DLL = $(LIB_NAME)$(DLL_EXT)
|
||||
GLU_IMP = $(LIB_PRE)$(LIB_NAME)$(IMP_EXT)
|
||||
GLU_DEF = $(LIB_NAME).def
|
||||
|
||||
LDLIBS = -L$(LIBDIR) -lopengl32
|
||||
LDFLAGS = -Wl,--out-implib=$(LIBDIR)/$(GLU_IMP) -Wl,--output-def=$(LIBDIR)/$(GLU_DEF)
|
||||
LDFLAGS = $(STRIP) -shared -fPIC -Wl,--kill-at
|
||||
|
||||
CFLAGS += -DBUILD_GLU32 -D_DLL
|
||||
|
||||
ifeq ($(GL_USING_STDCALL),1)
|
||||
LDFLAGS += -Wl,--add-stdcall-alias
|
||||
else
|
||||
CFLAGS += -DGL_NO_STDCALL
|
||||
endif
|
||||
|
||||
CC = gcc
|
||||
CC = $(TOOLS_PREFIX)gcc
|
||||
CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include -Iinclude
|
||||
CXX = g++
|
||||
CXX = $(TOOLS_PREFIX)g++
|
||||
CXXFLAGS = $(CFLAGS) -Ilibnurbs/internals -Ilibnurbs/interface -Ilibnurbs/nurbtess
|
||||
|
||||
AR = ar
|
||||
@@ -216,9 +217,9 @@ $(LIBDIR):
|
||||
mkdir -p $(LIBDIR)
|
||||
|
||||
$(LIBDIR)/$(GLU_DLL) $(LIBDIR)/$(GLU_IMP): $(OBJECTS)
|
||||
g++ -shared -fPIC -o $(LIBDIR)/$(GLU_DLL) $(LDFLAGS) \
|
||||
$^ $(LDLIBS)
|
||||
|
||||
$(CXX) $(LDFLAGS) -o $(LIBDIR)/$(GLU_DLL) $^ $(LDLIBS)
|
||||
$(DLLTOOL) --as=as --dllname $(LIB_NAME) --output-def $(LIBDIR)/$(GLU_DEF) $^
|
||||
$(DLLTOOL) --as=as -k --dllname $(LIB_NAME) --output-lib $(LIBDIR)/$(GLU_IMP) --def $(LIBDIR)/$(GLU_DEF)
|
||||
|
||||
|
||||
clean:
|
||||
|
||||
@@ -111,8 +111,11 @@ void bezierPatchDelete(bezierPatch *b)
|
||||
void bezierPatchDeleteList(bezierPatch *b)
|
||||
{
|
||||
bezierPatch *temp;
|
||||
for(temp = b; temp != NULL; temp = temp->next)
|
||||
bezierPatchDelete(temp);
|
||||
while (b != NULL) {
|
||||
temp = b;
|
||||
b = b->next;
|
||||
bezierPatchDelete(temp);
|
||||
}
|
||||
}
|
||||
|
||||
bezierPatch* bezierPatchInsert(bezierPatch *list, bezierPatch *b)
|
||||
|
||||
@@ -1533,8 +1533,8 @@ void OpenGLSurfaceEvaluator::inEvalVStrip(int n_left, REAL u_left, REAL* left_va
|
||||
}
|
||||
//clean up
|
||||
free(leftXYZ);
|
||||
free(leftXYZ);
|
||||
free(rightNormal);
|
||||
free(rightXYZ);
|
||||
free(leftNormal);
|
||||
free(rightNormal);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ gluErrorString(GLenum errorCode)
|
||||
if ((errorCode >= GLU_NURBS_ERROR1) && (errorCode <= GLU_NURBS_ERROR37)) {
|
||||
return (const GLubyte *) __gluNURBSErrorString(errorCode - (GLU_NURBS_ERROR1 - 1));
|
||||
}
|
||||
if ((errorCode >= GLU_TESS_ERROR1) && (errorCode <= GLU_TESS_ERROR8)) {
|
||||
if ((errorCode >= GLU_TESS_ERROR1) && (errorCode <= GLU_TESS_ERROR6)) {
|
||||
return (const GLubyte *) __gluTessErrorString(errorCode - (GLU_TESS_ERROR1 - 1));
|
||||
}
|
||||
return (const GLubyte *) 0;
|
||||
|
||||
@@ -168,74 +168,57 @@ static void __gluMultMatrixVecd(const GLdouble matrix[16], const GLdouble in[4],
|
||||
}
|
||||
|
||||
/*
|
||||
** inverse = invert(src)
|
||||
** New, faster implementation by Shan Hao Bo, April 2006.
|
||||
** Invert 4x4 matrix.
|
||||
** Contributed by David Moore (See Mesa bug #6748)
|
||||
*/
|
||||
static int __gluInvertMatrixd(const GLdouble src[16], GLdouble inverse[16])
|
||||
static int __gluInvertMatrixd(const GLdouble m[16], GLdouble invOut[16])
|
||||
{
|
||||
int i, j, k;
|
||||
double t;
|
||||
GLdouble temp[4][4];
|
||||
|
||||
for (i=0; i<4; i++) {
|
||||
for (j=0; j<4; j++) {
|
||||
temp[i][j] = src[i*4+j];
|
||||
}
|
||||
}
|
||||
__gluMakeIdentityd(inverse);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (temp[i][i] == 0.0f) {
|
||||
/*
|
||||
** Look for non-zero element in column
|
||||
*/
|
||||
for (j = i + 1; j < 4; j++) {
|
||||
if (temp[j][i] != 0.0f) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (j != 4) {
|
||||
/*
|
||||
** Swap rows.
|
||||
*/
|
||||
for (k = 0; k < 4; k++) {
|
||||
t = temp[i][k];
|
||||
temp[i][k] = temp[j][k];
|
||||
temp[j][k] = t;
|
||||
|
||||
t = inverse[i*4+k];
|
||||
inverse[i*4+k] = inverse[j*4+k];
|
||||
inverse[j*4+k] = t;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*
|
||||
** No non-zero pivot. The matrix is singular,
|
||||
which shouldn't
|
||||
** happen. This means the user gave us a bad
|
||||
matrix.
|
||||
*/
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
t = 1.0f / temp[i][i];
|
||||
for (k = 0; k < 4; k++) {
|
||||
temp[i][k] *= t;
|
||||
inverse[i*4+k] *= t;
|
||||
}
|
||||
for (j = 0; j < 4; j++) {
|
||||
if (j != i) {
|
||||
t = temp[j][i];
|
||||
for (k = 0; k < 4; k++) {
|
||||
temp[j][k] -= temp[i][k]*t;
|
||||
inverse[j*4+k] -= inverse[i*4+k]*t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
double inv[16], det;
|
||||
int i;
|
||||
|
||||
inv[0] = m[5]*m[10]*m[15] - m[5]*m[11]*m[14] - m[9]*m[6]*m[15]
|
||||
+ m[9]*m[7]*m[14] + m[13]*m[6]*m[11] - m[13]*m[7]*m[10];
|
||||
inv[4] = -m[4]*m[10]*m[15] + m[4]*m[11]*m[14] + m[8]*m[6]*m[15]
|
||||
- m[8]*m[7]*m[14] - m[12]*m[6]*m[11] + m[12]*m[7]*m[10];
|
||||
inv[8] = m[4]*m[9]*m[15] - m[4]*m[11]*m[13] - m[8]*m[5]*m[15]
|
||||
+ m[8]*m[7]*m[13] + m[12]*m[5]*m[11] - m[12]*m[7]*m[9];
|
||||
inv[12] = -m[4]*m[9]*m[14] + m[4]*m[10]*m[13] + m[8]*m[5]*m[14]
|
||||
- m[8]*m[6]*m[13] - m[12]*m[5]*m[10] + m[12]*m[6]*m[9];
|
||||
inv[1] = -m[1]*m[10]*m[15] + m[1]*m[11]*m[14] + m[9]*m[2]*m[15]
|
||||
- m[9]*m[3]*m[14] - m[13]*m[2]*m[11] + m[13]*m[3]*m[10];
|
||||
inv[5] = m[0]*m[10]*m[15] - m[0]*m[11]*m[14] - m[8]*m[2]*m[15]
|
||||
+ m[8]*m[3]*m[14] + m[12]*m[2]*m[11] - m[12]*m[3]*m[10];
|
||||
inv[9] = -m[0]*m[9]*m[15] + m[0]*m[11]*m[13] + m[8]*m[1]*m[15]
|
||||
- m[8]*m[3]*m[13] - m[12]*m[1]*m[11] + m[12]*m[3]*m[9];
|
||||
inv[13] = m[0]*m[9]*m[14] - m[0]*m[10]*m[13] - m[8]*m[1]*m[14]
|
||||
+ m[8]*m[2]*m[13] + m[12]*m[1]*m[10] - m[12]*m[2]*m[9];
|
||||
inv[2] = m[1]*m[6]*m[15] - m[1]*m[7]*m[14] - m[5]*m[2]*m[15]
|
||||
+ m[5]*m[3]*m[14] + m[13]*m[2]*m[7] - m[13]*m[3]*m[6];
|
||||
inv[6] = -m[0]*m[6]*m[15] + m[0]*m[7]*m[14] + m[4]*m[2]*m[15]
|
||||
- m[4]*m[3]*m[14] - m[12]*m[2]*m[7] + m[12]*m[3]*m[6];
|
||||
inv[10] = m[0]*m[5]*m[15] - m[0]*m[7]*m[13] - m[4]*m[1]*m[15]
|
||||
+ m[4]*m[3]*m[13] + m[12]*m[1]*m[7] - m[12]*m[3]*m[5];
|
||||
inv[14] = -m[0]*m[5]*m[14] + m[0]*m[6]*m[13] + m[4]*m[1]*m[14]
|
||||
- m[4]*m[2]*m[13] - m[12]*m[1]*m[6] + m[12]*m[2]*m[5];
|
||||
inv[3] = -m[1]*m[6]*m[11] + m[1]*m[7]*m[10] + m[5]*m[2]*m[11]
|
||||
- m[5]*m[3]*m[10] - m[9]*m[2]*m[7] + m[9]*m[3]*m[6];
|
||||
inv[7] = m[0]*m[6]*m[11] - m[0]*m[7]*m[10] - m[4]*m[2]*m[11]
|
||||
+ m[4]*m[3]*m[10] + m[8]*m[2]*m[7] - m[8]*m[3]*m[6];
|
||||
inv[11] = -m[0]*m[5]*m[11] + m[0]*m[7]*m[9] + m[4]*m[1]*m[11]
|
||||
- m[4]*m[3]*m[9] - m[8]*m[1]*m[7] + m[8]*m[3]*m[5];
|
||||
inv[15] = m[0]*m[5]*m[10] - m[0]*m[6]*m[9] - m[4]*m[1]*m[10]
|
||||
+ m[4]*m[2]*m[9] + m[8]*m[1]*m[6] - m[8]*m[2]*m[5];
|
||||
|
||||
det = m[0]*inv[0] + m[1]*inv[4] + m[2]*inv[8] + m[3]*inv[12];
|
||||
if (det == 0)
|
||||
return GL_FALSE;
|
||||
|
||||
det = 1.0 / det;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
invOut[i] = inv[i] * det;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void __gluMultMatricesd(const GLdouble a[16], const GLdouble b[16],
|
||||
|
||||
@@ -83,7 +83,8 @@ $(TOP)/$(LIB_DIR):
|
||||
|
||||
# Make the library
|
||||
$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
|
||||
@$(TOP)/bin/mklib -o $(GLUT_LIB) -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
|
||||
@$(TOP)/bin/mklib -o $(GLUT_LIB) -ldflags '$(LDFLAGS)' \
|
||||
-major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
|
||||
-install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) $(GLUT_LIB_DEPS) \
|
||||
$(OBJECTS)
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ default: depend $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
||||
|
||||
# Make the library
|
||||
$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
|
||||
$(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \
|
||||
$(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
-major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
|
||||
$(GLUT_LIB_DEPS) -install $(TOP)/$(LIB_DIR) \
|
||||
$(MKLIB_OPTIONS) $(OBJECTS)
|
||||
|
||||
@@ -63,16 +63,16 @@ default: depend $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
||||
|
||||
# Make the library
|
||||
$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
|
||||
$(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \
|
||||
$(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
-major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
|
||||
$(GLUT_LIB_DEPS) -install $(TOP)/$(LIB_DIR) \
|
||||
$(MKLIB_OPTIONS) $(OBJECTS)
|
||||
|
||||
install:
|
||||
$(INSTALL) -d $(INSTALL_DIR)/include/GL
|
||||
$(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
|
||||
$(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(INSTALL_DIR)/include/GL
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(INSTALL_DIR)/$(LIB_DIR)
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
|
||||
$(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_DIR)/include/GL
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
|
||||
|
||||
# Run 'make -f Makefile.solo dep' to update the dependencies if you change
|
||||
# what's included by any source file.
|
||||
|
||||
@@ -32,7 +32,7 @@ default: $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
||||
|
||||
# Make the library
|
||||
$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
|
||||
$(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \
|
||||
$(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
-major $(GLUT_MAJOR) -minor $(GLUT_MINOR) \
|
||||
-patch $(GLUT_TINY) $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
|
||||
$(GLUT_LIB_DEPS) $(OBJECTS)
|
||||
|
||||
+17
-6
@@ -36,6 +36,7 @@ SOURCES = \
|
||||
glut_dstr.c \
|
||||
glut_event.c \
|
||||
glut_ext.c \
|
||||
glut_fcb.c \
|
||||
glut_fullscrn.c \
|
||||
glut_gamemode.c \
|
||||
glut_get.c \
|
||||
@@ -90,17 +91,27 @@ default: $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
||||
|
||||
# Make the library
|
||||
$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
|
||||
$(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \
|
||||
$(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
-major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
|
||||
$(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
|
||||
$(GLUT_LIB_DEPS) $(OBJECTS)
|
||||
|
||||
|
||||
install:
|
||||
$(INSTALL) -d $(INSTALL_DIR)/include/GL
|
||||
$(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
|
||||
$(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(INSTALL_DIR)/include/GL
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(INSTALL_DIR)/$(LIB_DIR)
|
||||
# glut pkgconfig file
|
||||
pcedit = sed \
|
||||
-e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
|
||||
-e 's,@LIB_DIR@,$(LIB_DIR),' \
|
||||
-e 's,@VERSION@,$(GLUT_MAJOR).$(GLUT_MINOR).$(GLUT_TINY),'
|
||||
glut.pc: glut.pc.in
|
||||
$(pcedit) $< > $@
|
||||
|
||||
install: glut.pc
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
|
||||
$(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_DIR)/include/GL
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
|
||||
$(INSTALL) -m 644 glut.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
|
||||
|
||||
|
||||
clean:
|
||||
|
||||
+17
-24
@@ -74,35 +74,29 @@ TOP = ../../..
|
||||
|
||||
LIBDIR = $(TOP)/lib
|
||||
|
||||
GLUT_DLL = glut32.dll
|
||||
GLUT_IMP = libglut32.a
|
||||
GLUT_DEF = glut.def
|
||||
LIB_NAME = glut32
|
||||
|
||||
include $(TOP)/configs/config.mgw
|
||||
GLUT_USING_STDCALL ?= 1
|
||||
DLL_EXT = .dll
|
||||
IMP_EXT = .a
|
||||
LIB_PRE = lib
|
||||
STRIP = -s
|
||||
|
||||
AR = ar
|
||||
ARFLAGS = crus
|
||||
DLLTOOL = dlltool
|
||||
|
||||
GLUT_DLL = $(LIB_NAME)$(DLL_EXT)
|
||||
GLUT_IMP = $(LIB_PRE)$(LIB_NAME)$(IMP_EXT)
|
||||
GLUT_DEF = $(LIB_NAME).def
|
||||
|
||||
LDLIBS = -L$(LIBDIR) -lwinmm -lgdi32 -luser32 -lopengl32 -lglu32
|
||||
LDFLAGS = -Wl,--out-implib=$(LIBDIR)/$(GLUT_IMP) -Wl,--output-def=$(LIBDIR)/$(GLUT_DEF)
|
||||
LDFLAGS = $(STRIP) -shared -fPIC -Wl,--kill-at
|
||||
|
||||
CFLAGS += -DBUILD_GLUT32 -DGLUT_BUILDING_LIB -DMESA -D_DLL
|
||||
|
||||
ifeq ($(GL_USING_STDCALL),0)
|
||||
CFLAGS += -DGL_NO_STDCALL
|
||||
endif
|
||||
|
||||
ifeq ($(GLUT_USING_STDCALL),1)
|
||||
CFLAGS += -D_STDCALL_SUPPORTED
|
||||
LDFLAGS += -Wl,--add-stdcall-alias
|
||||
else
|
||||
CFLAGS += -DGLUT_NO_STDCALL
|
||||
endif
|
||||
|
||||
CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include
|
||||
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
CC = $(TOOLS_PREFIX)gcc
|
||||
CXX = $(TOOLS_PREFIX)g++
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
|
||||
AR = ar
|
||||
@@ -189,10 +183,9 @@ $(LIBDIR):
|
||||
mkdir -p $(LIBDIR)
|
||||
|
||||
$(LIBDIR)/$(GLUT_DLL) $(LIBDIR)/$(GLUT_IMP): $(OBJECTS)
|
||||
$(CXX) -shared -fPIC -o $(LIBDIR)/$(GLUT_DLL) $(LDFLAGS) \
|
||||
$^ $(LDLIBS)
|
||||
|
||||
|
||||
$(CXX) $(LDFLAGS) -o $(LIBDIR)/$(GLUT_DLL) $^ $(LDLIBS)
|
||||
$(DLLTOOL) --as=as --dllname $(LIB_NAME) --output-def $(LIBDIR)/$(GLUT_DEF) $^
|
||||
$(DLLTOOL) --as=as -k --dllname $(LIB_NAME) --output-lib $(LIBDIR)/$(GLUT_IMP) --def $(LIBDIR)/$(GLUT_DEF)
|
||||
|
||||
clean:
|
||||
-$(call UNLINK,*.o)
|
||||
@@ -0,0 +1,11 @@
|
||||
prefix=@INSTALL_DIR@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/@LIB_DIR@
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: glut
|
||||
Description: Mesa OpenGL Utility Toolkit library
|
||||
Requires: gl glu
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lglut
|
||||
Cflags: -I${includedir}
|
||||
@@ -291,6 +291,7 @@ loadVisuals(int *nitems_return)
|
||||
fbmodes = (FrameBufferMode *) malloc(n * sizeof(FrameBufferMode));
|
||||
if (fbmodes == NULL) {
|
||||
*nitems_return = -1;
|
||||
free(vlist);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < n; i++) {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
# ifdef __sgi
|
||||
# include <bstring.h> /* prototype for bzero used by FD_ZERO */
|
||||
# endif
|
||||
# if (defined(SVR4) || defined(CRAY) || defined(AIXV3)) && !defined(FD_SETSIZE)
|
||||
# if (defined(__FreeBSD__) || defined(SVR4) || defined(CRAY) || defined(AIXV3)) && !defined(FD_SETSIZE)
|
||||
# include <sys/select.h> /* select system call interface */
|
||||
# ifdef luna
|
||||
# include <sysent.h>
|
||||
@@ -172,10 +172,14 @@ handleTimeouts(void)
|
||||
GETTIMEOFDAY(&now);
|
||||
while (IS_AT_OR_AFTER(__glutTimerList->timeout, now)) {
|
||||
timer = __glutTimerList;
|
||||
__glutTimerList = timer->next;
|
||||
/* call the timer function */
|
||||
timer->func(timer->value);
|
||||
/* remove from the linked list */
|
||||
__glutTimerList = timer->next;
|
||||
/* put this timer on the "free" list */
|
||||
timer->next = freeTimerList;
|
||||
freeTimerList = timer;
|
||||
|
||||
if (!__glutTimerList)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
|
||||
/* Copyright (c) Mark J. Kilgard, 1998. */
|
||||
|
||||
/* This program is freely distributable without licensing fees
|
||||
and is provided without guarantee or warrantee expressed or
|
||||
implied. This program is -not- in the public domain. */
|
||||
|
||||
/* I appreciate the guidance from William Mitchell
|
||||
(mitchell@cam.nist.gov) in developing this friend interface
|
||||
for use by the f90gl package. See ../../README.fortran */
|
||||
|
||||
#include "glutint.h"
|
||||
|
||||
/* FCB stands for Fortran CallBack. */
|
||||
|
||||
/* There is only one idleFunc, menuStateFunc, and menuStatusFunc, so they
|
||||
can be saved in the wrappers for Fortran rather than the C structures. */
|
||||
|
||||
/* Set a Fortran callback function. */
|
||||
|
||||
void APIENTRY
|
||||
__glutSetFCB(int which, GLUTproc func)
|
||||
{
|
||||
#ifdef SUPPORT_FORTRAN
|
||||
switch (which) {
|
||||
case GLUT_FCB_DISPLAY:
|
||||
__glutCurrentWindow->fdisplay = (GLUTdisplayFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_RESHAPE:
|
||||
__glutCurrentWindow->freshape = (GLUTreshapeFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_MOUSE:
|
||||
__glutCurrentWindow->fmouse = (GLUTmouseFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_MOTION:
|
||||
__glutCurrentWindow->fmotion = (GLUTmotionFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_PASSIVE:
|
||||
__glutCurrentWindow->fpassive = (GLUTpassiveFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_ENTRY:
|
||||
__glutCurrentWindow->fentry = (GLUTentryFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_KEYBOARD:
|
||||
__glutCurrentWindow->fkeyboard = (GLUTkeyboardFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_KEYBOARD_UP:
|
||||
__glutCurrentWindow->fkeyboardUp = (GLUTkeyboardFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_WINDOW_STATUS:
|
||||
__glutCurrentWindow->fwindowStatus = (GLUTwindowStatusFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_VISIBILITY:
|
||||
__glutCurrentWindow->fvisibility = (GLUTvisibilityFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_SPECIAL:
|
||||
__glutCurrentWindow->fspecial = (GLUTspecialFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_SPECIAL_UP:
|
||||
__glutCurrentWindow->fspecialUp = (GLUTspecialFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_BUTTON_BOX:
|
||||
__glutCurrentWindow->fbuttonBox = (GLUTbuttonBoxFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_DIALS:
|
||||
__glutCurrentWindow->fdials = (GLUTdialsFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_SPACE_MOTION:
|
||||
__glutCurrentWindow->fspaceMotion = (GLUTspaceMotionFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_SPACE_ROTATE:
|
||||
__glutCurrentWindow->fspaceRotate = (GLUTspaceRotateFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_SPACE_BUTTON:
|
||||
__glutCurrentWindow->fspaceButton = (GLUTspaceButtonFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_TABLET_MOTION:
|
||||
__glutCurrentWindow->ftabletMotion = (GLUTtabletMotionFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_TABLET_BUTTON:
|
||||
__glutCurrentWindow->ftabletButton = (GLUTtabletButtonFCB) func;
|
||||
break;
|
||||
#ifdef _WIN32
|
||||
case GLUT_FCB_JOYSTICK:
|
||||
__glutCurrentWindow->fjoystick = (GLUTjoystickFCB) func;
|
||||
break;
|
||||
#endif
|
||||
case GLUT_FCB_OVERLAY_DISPLAY:
|
||||
__glutCurrentWindow->overlay->fdisplay = (GLUTdisplayFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_SELECT:
|
||||
__glutCurrentMenu->fselect = (GLUTselectFCB) func;
|
||||
break;
|
||||
case GLUT_FCB_TIMER:
|
||||
__glutNewTimer->ffunc = (GLUTtimerFCB) func;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Get a Fortran callback function. */
|
||||
|
||||
GLUTproc APIENTRY
|
||||
__glutGetFCB(int which)
|
||||
{
|
||||
#ifdef SUPPORT_FORTRAN
|
||||
switch (which) {
|
||||
case GLUT_FCB_DISPLAY:
|
||||
return __glutCurrentWindow->fdisplay;
|
||||
case GLUT_FCB_RESHAPE:
|
||||
return __glutCurrentWindow->freshape;
|
||||
case GLUT_FCB_MOUSE:
|
||||
return __glutCurrentWindow->fmouse;
|
||||
case GLUT_FCB_MOTION:
|
||||
return __glutCurrentWindow->fmotion;
|
||||
case GLUT_FCB_PASSIVE:
|
||||
return __glutCurrentWindow->fpassive;
|
||||
case GLUT_FCB_ENTRY:
|
||||
return __glutCurrentWindow->fentry;
|
||||
case GLUT_FCB_KEYBOARD:
|
||||
return __glutCurrentWindow->fkeyboard;
|
||||
case GLUT_FCB_KEYBOARD_UP:
|
||||
return __glutCurrentWindow->fkeyboardUp;
|
||||
case GLUT_FCB_WINDOW_STATUS:
|
||||
return __glutCurrentWindow->fwindowStatus;
|
||||
case GLUT_FCB_VISIBILITY:
|
||||
return __glutCurrentWindow->fvisibility;
|
||||
case GLUT_FCB_SPECIAL:
|
||||
return __glutCurrentWindow->fspecial;
|
||||
case GLUT_FCB_SPECIAL_UP:
|
||||
return __glutCurrentWindow->fspecialUp;
|
||||
case GLUT_FCB_BUTTON_BOX:
|
||||
return __glutCurrentWindow->fbuttonBox;
|
||||
case GLUT_FCB_DIALS:
|
||||
return __glutCurrentWindow->fdials;
|
||||
case GLUT_FCB_SPACE_MOTION:
|
||||
return __glutCurrentWindow->fspaceMotion;
|
||||
case GLUT_FCB_SPACE_ROTATE:
|
||||
return __glutCurrentWindow->fspaceRotate;
|
||||
case GLUT_FCB_SPACE_BUTTON:
|
||||
return __glutCurrentWindow->fspaceButton;
|
||||
case GLUT_FCB_TABLET_MOTION:
|
||||
return __glutCurrentWindow->ftabletMotion;
|
||||
case GLUT_FCB_TABLET_BUTTON:
|
||||
return __glutCurrentWindow->ftabletButton;
|
||||
case GLUT_FCB_JOYSTICK:
|
||||
#ifdef _WIN32
|
||||
return __glutCurrentWindow->fjoystick;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
case GLUT_FCB_OVERLAY_DISPLAY:
|
||||
return __glutCurrentWindow->overlay->fdisplay;
|
||||
case GLUT_FCB_SELECT:
|
||||
return __glutCurrentMenu->fselect;
|
||||
case GLUT_FCB_TIMER:
|
||||
return __glutTimerList ? __glutTimerList->ffunc : NULL;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
@@ -55,7 +55,7 @@ default: depend $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
||||
|
||||
# Make the library
|
||||
$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
|
||||
$(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \
|
||||
$(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
-major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
|
||||
$(GLUT_LIB_DEPS) -install $(TOP)/$(LIB_DIR) \
|
||||
$(MKLIB_OPTIONS) $(OBJECTS)
|
||||
|
||||
+16
-6
@@ -25,11 +25,21 @@ OBJECTS = $(GLW_SOURCES:.c=.o)
|
||||
|
||||
default: $(TOP)/$(LIB_DIR)/$(GLW_LIB_NAME)
|
||||
|
||||
install:
|
||||
$(INSTALL) -d $(INSTALL_DIR)/include/GL
|
||||
$(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
|
||||
$(INSTALL) -m 644 *.h $(INSTALL_DIR)/include/GL
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/libGLw.* $(INSTALL_DIR)/$(LIB_DIR)
|
||||
# GLU pkg-config file
|
||||
pcedit = sed \
|
||||
-e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
|
||||
-e 's,@LIB_DIR@,$(LIB_DIR),' \
|
||||
-e 's,@VERSION@,$(MAJOR).$(MINOR).$(TINY),'
|
||||
glw.pc: glw.pc.in
|
||||
$(pcedit) $< > $@
|
||||
|
||||
install: glw.pc
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
|
||||
$(INSTALL) -m 644 *.h $(DESTDIR)$(INSTALL_DIR)/include/GL
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/libGLw.* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
|
||||
$(INSTALL) -m 644 glw.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
|
||||
|
||||
clean:
|
||||
-rm depend depend.bak
|
||||
@@ -38,7 +48,7 @@ clean:
|
||||
|
||||
# Make the library
|
||||
$(TOP)/$(LIB_DIR)/$(GLW_LIB_NAME): $(OBJECTS)
|
||||
$(TOP)/bin/mklib -o $(GLW_LIB) -linker '$(CC)' \
|
||||
$(TOP)/bin/mklib -o $(GLW_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
-major $(MAJOR) -minor $(MINOR) -patch $(TINY) \
|
||||
$(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
|
||||
$(GLW_LIB_DEPS) $(OBJECTS)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
prefix=@INSTALL_DIR@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/@LIB_DIR@
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: glw
|
||||
Description: Mesa OpenGL widget library
|
||||
Requires: gl
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir} -lGLU
|
||||
Cflags: -I${includedir}
|
||||
@@ -49,7 +49,7 @@ default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/miniglx.conf
|
||||
|
||||
# Make libGL
|
||||
$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) Makefile
|
||||
@ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
|
||||
@ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
-major 1 -minor 2 $(MKLIB_OPTIONS) \
|
||||
-install $(TOP)/$(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS) \
|
||||
$(LIBDRM_LIB) $(PCIACCESS_LIB)
|
||||
|
||||
@@ -64,7 +64,7 @@ default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
|
||||
|
||||
# Make libGL
|
||||
$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) Makefile
|
||||
$(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
|
||||
$(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
-major 1 -minor 2 $(MKLIB_OPTIONS) \
|
||||
-install $(TOP)/$(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS)
|
||||
|
||||
|
||||
@@ -672,8 +672,11 @@ filter_modes( __GLcontextModes ** server_modes,
|
||||
if ( do_delete && (m->visualID != 0) ) {
|
||||
do_delete = GL_FALSE;
|
||||
|
||||
fprintf(stderr, "libGL warning: 3D driver claims to not support "
|
||||
"visual 0x%02x\n", m->visualID);
|
||||
/* don't warn for this visual (Novell #247471 / X.Org #6689) */
|
||||
if (m->visualRating != GLX_NON_CONFORMANT_CONFIG) {
|
||||
fprintf(stderr, "libGL warning: 3D driver claims to not "
|
||||
"support visual 0x%02x\n", m->visualID);
|
||||
}
|
||||
}
|
||||
|
||||
if ( do_delete ) {
|
||||
|
||||
@@ -527,7 +527,7 @@ static GLubyte *
|
||||
emit_DrawArrays_header_old( __GLXcontext * gc,
|
||||
struct array_state_vector * arrays,
|
||||
size_t * elements_per_request,
|
||||
size_t * total_requests,
|
||||
unsigned int * total_requests,
|
||||
GLenum mode, GLsizei count )
|
||||
{
|
||||
size_t command_size;
|
||||
@@ -640,7 +640,7 @@ emit_DrawArrays_old( GLenum mode, GLint first, GLsizei count )
|
||||
|
||||
GLubyte * pc;
|
||||
size_t elements_per_request;
|
||||
size_t total_requests = 0;
|
||||
unsigned total_requests = 0;
|
||||
unsigned i;
|
||||
size_t total_sent = 0;
|
||||
|
||||
@@ -770,9 +770,10 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
|
||||
|
||||
GLubyte * pc;
|
||||
size_t elements_per_request;
|
||||
size_t total_requests = 0;
|
||||
unsigned total_requests = 0;
|
||||
unsigned i;
|
||||
unsigned req;
|
||||
unsigned req_element=0;
|
||||
|
||||
|
||||
pc = emit_DrawArrays_header_old( gc, arrays, & elements_per_request,
|
||||
@@ -790,7 +791,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
|
||||
|
||||
switch( type ) {
|
||||
case GL_UNSIGNED_INT: {
|
||||
const GLuint * ui_ptr = (const GLuint *) indices;
|
||||
const GLuint * ui_ptr = (const GLuint *) indices + req_element;
|
||||
|
||||
for ( i = 0 ; i < elements_per_request ; i++ ) {
|
||||
const GLint index = (GLint) *(ui_ptr++);
|
||||
@@ -799,7 +800,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
|
||||
break;
|
||||
}
|
||||
case GL_UNSIGNED_SHORT: {
|
||||
const GLushort * us_ptr = (const GLushort *) indices;
|
||||
const GLushort * us_ptr = (const GLushort *) indices + req_element;
|
||||
|
||||
for ( i = 0 ; i < elements_per_request ; i++ ) {
|
||||
const GLint index = (GLint) *(us_ptr++);
|
||||
@@ -808,7 +809,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
|
||||
break;
|
||||
}
|
||||
case GL_UNSIGNED_BYTE: {
|
||||
const GLubyte * ub_ptr = (const GLubyte *) indices;
|
||||
const GLubyte * ub_ptr = (const GLubyte *) indices + req_element;
|
||||
|
||||
for ( i = 0 ; i < elements_per_request ; i++ ) {
|
||||
const GLint index = (GLint) *(ub_ptr++);
|
||||
@@ -826,6 +827,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
|
||||
}
|
||||
|
||||
count -= elements_per_request;
|
||||
req_element += elements_per_request;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+24
-13
@@ -65,7 +65,7 @@ linux-solo: depend subdirs libmesa.a
|
||||
# Stand-alone Mesa libGL, no built-in drivers (DirectFB)
|
||||
|
||||
libgl-core: $(CORE_OBJECTS)
|
||||
@ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
|
||||
@ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS) \
|
||||
-major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
|
||||
-install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) $(CORE_OBJECTS) \
|
||||
$(GL_LIB_DEPS)
|
||||
@@ -78,7 +78,7 @@ directfb: depend subdirs libgl-core
|
||||
# fbdev Mesa driver (libGL.so)
|
||||
|
||||
fbdev: $(CORE_OBJECTS) $(FBDEV_DRIVER_OBJECTS) $(COMMON_DRIVER_OBJECTS)
|
||||
@ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
|
||||
@ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
-major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
|
||||
-install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
|
||||
$(CORE_OBJECTS) $(FBDEV_DRIVER_OBJECTS) \
|
||||
@@ -111,7 +111,7 @@ osmesa-only: depend subdirs $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME)
|
||||
|
||||
# Make the GL library
|
||||
$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(STAND_ALONE_OBJECTS)
|
||||
@ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
|
||||
@ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
-major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \
|
||||
-install $(TOP)/$(LIB_DIR) \
|
||||
$(MKLIB_OPTIONS) $(GL_LIB_DEPS) $(STAND_ALONE_OBJECTS)
|
||||
@@ -120,19 +120,28 @@ $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(STAND_ALONE_OBJECTS)
|
||||
$(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OSMESA_DRIVER_OBJECTS) $(OSMESA16_OBJECTS)
|
||||
@ if [ "${DRIVER_DIRS}" = "osmesa" ] ; then \
|
||||
$(TOP)/bin/mklib -o $(OSMESA_LIB) -linker '$(CC)' \
|
||||
-major $(MESA_MAJOR) \
|
||||
-ldflags '$(LDFLAGS)' -major $(MESA_MAJOR) \
|
||||
-minor $(MESA_MINOR) -patch $(MESA_TINY) \
|
||||
-install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
|
||||
$(OSMESA_LIB_DEPS) $(OSMESA16_OBJECTS) ; \
|
||||
else \
|
||||
$(TOP)/bin/mklib -o $(OSMESA_LIB) -linker '$(CC)' \
|
||||
-major $(MESA_MAJOR) \
|
||||
-ldflags '$(LDFLAGS)' -major $(MESA_MAJOR) \
|
||||
-minor $(MESA_MINOR) -patch $(GL_TINY) \
|
||||
-install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
|
||||
$(OSMESA_LIB_DEPS) $(OSMESA_DRIVER_OBJECTS) ; \
|
||||
fi
|
||||
|
||||
|
||||
######################################################################
|
||||
# libGL pkg-config file
|
||||
pcedit = sed \
|
||||
-e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
|
||||
-e 's,@LIB_DIR@,$(LIB_DIR),' \
|
||||
-e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),'
|
||||
gl.pc: gl.pc.in
|
||||
$(pcedit) $< > $@
|
||||
|
||||
######################################################################
|
||||
# Generic stuff
|
||||
|
||||
@@ -148,23 +157,25 @@ subdirs:
|
||||
@ (cd x86-64 ; $(MAKE))
|
||||
|
||||
|
||||
install: default
|
||||
$(INSTALL) -d $(INSTALL_DIR)/include/GL
|
||||
$(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
|
||||
$(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL
|
||||
install: default gl.pc
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
|
||||
$(INSTALL) -m 644 $(TOP)/include/GL/*.h $(DESTDIR)$(INSTALL_DIR)/include/GL
|
||||
@if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \
|
||||
fi
|
||||
$(INSTALL) -m 644 gl.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
|
||||
@if [ -e $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME) ]; then \
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/libOSMesa* $(INSTALL_DIR)/$(LIB_DIR); \
|
||||
$(INSTALL) $(TOP)/$(LIB_DIR)/libOSMesa* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \
|
||||
fi
|
||||
@if [ "${DRIVER_DIRS}" = "dri" ] ; then \
|
||||
cd drivers/dri ; $(MAKE) install ; \
|
||||
fi
|
||||
|
||||
## NOT INSTALLED YET:
|
||||
## $(INSTALL) -d $(INSTALL_DIR)/include/GLES
|
||||
## $(INSTALL) -m 644 include/GLES/*.h $(INSTALL_DIR)/include/GLES
|
||||
## $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GLES
|
||||
## $(INSTALL) -m 644 include/GLES/*.h $(DESTDIR)$(INSTALL_DIR)/include/GLES
|
||||
|
||||
|
||||
# Emacs tags
|
||||
|
||||
+26
-26
@@ -69,39 +69,37 @@
|
||||
# Set this to the prefix of your build tools, i.e. mingw32-
|
||||
TOOLS_PREFIX = mingw32-
|
||||
|
||||
ifeq ($(ICD),1)
|
||||
LIB_NAME = mesa32
|
||||
else
|
||||
LIB_NAME = opengl32
|
||||
endif
|
||||
|
||||
DLL_EXT = .dll
|
||||
IMP_EXT = .a
|
||||
LIB_PRE = lib
|
||||
STRIP = -s
|
||||
|
||||
AR = ar
|
||||
ARFLAGS = crus
|
||||
DLLTOOL = dlltool
|
||||
|
||||
TOP = ../..
|
||||
GLIDE ?= $(TOP)/glide3
|
||||
LIBDIR = $(TOP)/lib
|
||||
ifeq ($(ICD),1)
|
||||
GL_DLL = mesa32.dll
|
||||
GL_IMP = libmesa32.a
|
||||
else
|
||||
GL_DLL = opengl32.dll
|
||||
GL_IMP = libopengl32.a
|
||||
endif
|
||||
|
||||
GL_DEF = gl.def
|
||||
|
||||
include $(TOP)/configs/config.mgw
|
||||
GL_USING_STDCALL ?= 1
|
||||
GL_DLL = $(LIB_NAME)$(DLL_EXT)
|
||||
GL_IMP = $(LIB_PRE)$(LIB_NAME)$(IMP_EXT)
|
||||
|
||||
MESA_LIB = libmesa.a
|
||||
CC = $(TOOLS_PREFIX)gcc
|
||||
|
||||
LDLIBS = -lgdi32 -luser32 -liberty
|
||||
LDFLAGS = -Wl,--out-implib=$(LIBDIR)/$(GL_IMP) -Wl,--output-def=$(LIBDIR)/gl.def
|
||||
LDFLAGS = $(STRIP) -shared -fPIC -Wl,--kill-at
|
||||
|
||||
CC = $(TOOLS_PREFIX)gcc
|
||||
CFLAGS += -DBUILD_GL32 -D_OPENGL32_ -D_DLL -DMESA_MINWARN -DNDEBUG -D_USRDLL -DGDI_EXPORTS
|
||||
CFLAGS += -DBUILD_GL32 -D_DLL -DMESA_MINWARN
|
||||
CFLAGS += -DNDEBUG -DUSE_EXTERNAL_DXTN_LIB=1
|
||||
|
||||
ifeq ($(GL_USING_STDCALL),1)
|
||||
LDFLAGS += -Wl,--add-stdcall-alias
|
||||
else
|
||||
CFLAGS += -DGL_NO_STDCALL
|
||||
endif
|
||||
|
||||
CFLAGS += -DUSE_EXTERNAL_DXTN_LIB=1
|
||||
ifeq ($(FX),1)
|
||||
CFLAGS += -I$(GLIDE)/include -DFX
|
||||
LDLIBS += -L$(GLIDE)/lib -lglide3x
|
||||
@@ -112,12 +110,11 @@ else
|
||||
CFLAGS += -DUSE_MGL_NAMESPACE
|
||||
GL_DEF = drivers/windows/icd/mesa.def
|
||||
else
|
||||
GL_DEF = drivers/windows/gdi/mesa.def
|
||||
GL_DEF = $(LIB_NAME).def
|
||||
endif
|
||||
endif
|
||||
|
||||
AR = ar
|
||||
ARFLAGS = crus
|
||||
|
||||
|
||||
UNLINK = del $(subst /,\,$(1))
|
||||
ifneq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
|
||||
@@ -173,14 +170,17 @@ RESOURCE = $(GL_RES:.rc=.res)
|
||||
.rc.res:
|
||||
windres -o $@ -Irc -Ocoff $<
|
||||
|
||||
|
||||
all: $(LIBDIR) $(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP)
|
||||
|
||||
$(LIBDIR):
|
||||
mkdir -p $(LIBDIR)
|
||||
|
||||
$(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP): $(OBJECTS) $(RESOURCE)
|
||||
$(CC) -shared -fPIC -o $(LIBDIR)/$(GL_DLL) $(LDFLAGS) \
|
||||
$^ $(LDLIBS)
|
||||
$(CC) $(LDFLAGS) -o $(LIBDIR)/$(GL_DLL) $^ $(LDLIBS)
|
||||
$(DLLTOOL) --as=as --dllname $(LIB_NAME) --output-def $(LIBDIR)/$(GL_DEF) $^
|
||||
$(DLLTOOL) --as=as -k --dllname $(LIB_NAME) --output-lib $(LIBDIR)/$(GL_IMP) --def $(LIBDIR)/$(GL_DEF)
|
||||
|
||||
|
||||
$(X86_OBJECTS): x86/matypes.h
|
||||
|
||||
|
||||
@@ -179,7 +179,8 @@ $(TOP)/$(LIB_DIR):
|
||||
mkdir $(TOP)/$(LIB_DIR)
|
||||
|
||||
$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) $(MESA_MODULES) $(GLU_MODULES)
|
||||
@$(TOP)/bin/mklib -o $(GL_LIB) -install $(TOP)/$(LIB_DIR) -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
|
||||
@$(TOP)/bin/mklib -o $(GL_LIB) -ldflags '$(LDFLAGS)' -install $(TOP)/$(LIB_DIR) \
|
||||
-major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
|
||||
$(MKLIB_OPTIONS) $(GL_LIB_DEPS) $(OBJECTS) $(MESA_MODULES) $(GLU_MODULES)
|
||||
|
||||
# $(GLU_OBJECTS):
|
||||
|
||||
@@ -25,11 +25,10 @@
|
||||
|
||||
#include "glheader.h"
|
||||
#include "imports.h"
|
||||
#include "arrayobj.h"
|
||||
#include "buffers.h"
|
||||
#include "context.h"
|
||||
#include "framebuffer.h"
|
||||
#include "program.h"
|
||||
#include "prog_execute.h"
|
||||
#include "queryobj.h"
|
||||
#include "renderbuffer.h"
|
||||
#include "texcompress.h"
|
||||
@@ -44,9 +43,10 @@
|
||||
#include "fbobject.h"
|
||||
#include "texrender.h"
|
||||
#endif
|
||||
#include "shader_api.h"
|
||||
#include "arrayobj.h"
|
||||
|
||||
#include "shader/program.h"
|
||||
#include "shader/prog_execute.h"
|
||||
#include "shader/shader_api.h"
|
||||
#include "driverfuncs.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
@@ -13,7 +13,8 @@ COMMON_SOURCES = \
|
||||
|
||||
COMMON_BM_SOURCES = \
|
||||
../common/dri_bufmgr.c \
|
||||
../common/dri_drmpool.c
|
||||
../common/dri_bufmgr_ttm.c \
|
||||
../common/dri_bufmgr_fake.c
|
||||
|
||||
|
||||
ifeq ($(WINDOW_SYSTEM),dri)
|
||||
@@ -49,11 +50,6 @@ SHARED_INCLUDES = \
|
||||
-I$(TOP)/src/mesa \
|
||||
-I$(TOP)/src/mesa/main \
|
||||
-I$(TOP)/src/mesa/glapi \
|
||||
-I$(TOP)/src/mesa/math \
|
||||
-I$(TOP)/src/mesa/transform \
|
||||
-I$(TOP)/src/mesa/shader \
|
||||
-I$(TOP)/src/mesa/swrast \
|
||||
-I$(TOP)/src/mesa/swrast_setup \
|
||||
-I$(TOP)/src/egl/main \
|
||||
-I$(TOP)/src/egl/drivers/dri \
|
||||
$(LIBDRM_CFLAGS)
|
||||
@@ -74,7 +70,7 @@ default: depend symlinks $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
|
||||
|
||||
|
||||
$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template
|
||||
$(TOP)/bin/mklib -noprefix -o $@ \
|
||||
$(TOP)/bin/mklib -ldflags '$(LDFLAGS)' -noprefix -o $@ \
|
||||
$(OBJECTS) $(MESA_MODULES) $(WINOBJ) $(DRI_LIB_DEPS)
|
||||
|
||||
|
||||
@@ -100,8 +96,8 @@ clean:
|
||||
|
||||
|
||||
install: $(LIBNAME)
|
||||
$(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR)
|
||||
$(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR)
|
||||
$(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
|
||||
$(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
|
||||
|
||||
|
||||
include depend
|
||||
|
||||
@@ -1,499 +1,152 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
|
||||
* All Rights Reserved.
|
||||
*
|
||||
/*
|
||||
* Copyright © 2007 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, 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:
|
||||
*
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Eric Anholt <eric@anholt.net>
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
*
|
||||
**************************************************************************/
|
||||
/*
|
||||
* Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
|
||||
* Keith Whitwell <keithw-at-tungstengraphics-dot-com>
|
||||
*/
|
||||
|
||||
#include <xf86drm.h>
|
||||
#include <stdlib.h>
|
||||
#include "glthread.h"
|
||||
#include "errno.h"
|
||||
#include "mtypes.h"
|
||||
#include "dri_bufmgr.h"
|
||||
#include "string.h"
|
||||
#include "imports.h"
|
||||
#include "dri_bufpool.h"
|
||||
|
||||
_glthread_DECLARE_STATIC_MUTEX(bmMutex);
|
||||
|
||||
/*
|
||||
* TODO: Introduce fence pools in the same way as
|
||||
* buffer object pools.
|
||||
/** @file dri_bufmgr.c
|
||||
*
|
||||
* Convenience functions for buffer management methods.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
typedef struct _DriFenceObject
|
||||
dri_bo *
|
||||
dri_bo_alloc(dri_bufmgr *bufmgr, const char *name, unsigned long size,
|
||||
unsigned int alignment, unsigned int location_mask)
|
||||
{
|
||||
int fd;
|
||||
_glthread_Mutex mutex;
|
||||
int refCount;
|
||||
const char *name;
|
||||
drmFence fence;
|
||||
} DriFenceObject;
|
||||
assert((location_mask & ~(DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_MEM_TT |
|
||||
DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_PRIV0 |
|
||||
DRM_BO_FLAG_MEM_PRIV1 | DRM_BO_FLAG_MEM_PRIV2 |
|
||||
DRM_BO_FLAG_MEM_PRIV3 |
|
||||
DRM_BO_FLAG_MEM_PRIV4)) == 0);
|
||||
|
||||
typedef struct _DriBufferObject
|
||||
{
|
||||
DriBufferPool *pool;
|
||||
_glthread_Mutex mutex;
|
||||
int refCount;
|
||||
const char *name;
|
||||
unsigned flags;
|
||||
unsigned hint;
|
||||
unsigned alignment;
|
||||
void *private;
|
||||
} DriBufferObject;
|
||||
|
||||
|
||||
void
|
||||
bmError(int val, const char *file, const char *function, int line)
|
||||
{
|
||||
_mesa_printf("Fatal video memory manager error \"%s\".\n"
|
||||
"Check kernel logs or set the LIBGL_DEBUG\n"
|
||||
"environment variable to \"verbose\" for more info.\n"
|
||||
"Detected in file %s, line %d, function %s.\n",
|
||||
strerror(-val), file, line, function);
|
||||
#ifndef NDEBUG
|
||||
abort();
|
||||
#else
|
||||
abort();
|
||||
#endif
|
||||
return bufmgr->bo_alloc(bufmgr, name, size, alignment, location_mask);
|
||||
}
|
||||
|
||||
DriFenceObject *
|
||||
driFenceBuffers(int fd, char *name, unsigned flags)
|
||||
dri_bo *
|
||||
dri_bo_alloc_static(dri_bufmgr *bufmgr, const char *name, unsigned long offset,
|
||||
unsigned long size, void *virtual,
|
||||
unsigned int location_mask)
|
||||
{
|
||||
DriFenceObject *fence = (DriFenceObject *) malloc(sizeof(*fence));
|
||||
int ret;
|
||||
assert((location_mask & ~(DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_MEM_TT |
|
||||
DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_PRIV0 |
|
||||
DRM_BO_FLAG_MEM_PRIV1 | DRM_BO_FLAG_MEM_PRIV2 |
|
||||
DRM_BO_FLAG_MEM_PRIV3 |
|
||||
DRM_BO_FLAG_MEM_PRIV4)) == 0);
|
||||
|
||||
if (!fence)
|
||||
BM_CKFATAL(-EINVAL);
|
||||
|
||||
_glthread_LOCK_MUTEX(bmMutex);
|
||||
fence->refCount = 1;
|
||||
fence->name = name;
|
||||
fence->fd = fd;
|
||||
_glthread_INIT_MUTEX(fence->mutex);
|
||||
ret = drmFenceBuffers(fd, flags, &fence->fence);
|
||||
_glthread_UNLOCK_MUTEX(bmMutex);
|
||||
if (ret) {
|
||||
free(fence);
|
||||
BM_CKFATAL(ret);
|
||||
}
|
||||
return fence;
|
||||
}
|
||||
|
||||
|
||||
unsigned
|
||||
driFenceType(DriFenceObject * fence)
|
||||
{
|
||||
unsigned ret;
|
||||
|
||||
_glthread_LOCK_MUTEX(bmMutex);
|
||||
ret = fence->fence.flags;
|
||||
_glthread_UNLOCK_MUTEX(bmMutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
DriFenceObject *
|
||||
driFenceReference(DriFenceObject * fence)
|
||||
{
|
||||
_glthread_LOCK_MUTEX(bmMutex);
|
||||
++fence->refCount;
|
||||
_glthread_UNLOCK_MUTEX(bmMutex);
|
||||
return fence;
|
||||
return bufmgr->bo_alloc_static(bufmgr, name, offset, size, virtual,
|
||||
location_mask);
|
||||
}
|
||||
|
||||
void
|
||||
driFenceUnReference(DriFenceObject * fence)
|
||||
dri_bo_reference(dri_bo *bo)
|
||||
{
|
||||
if (!fence)
|
||||
bo->bufmgr->bo_reference(bo);
|
||||
}
|
||||
|
||||
void
|
||||
dri_bo_unreference(dri_bo *bo)
|
||||
{
|
||||
if (bo == NULL)
|
||||
return;
|
||||
|
||||
_glthread_LOCK_MUTEX(bmMutex);
|
||||
if (--fence->refCount == 0) {
|
||||
drmFenceDestroy(fence->fd, &fence->fence);
|
||||
free(fence);
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX(bmMutex);
|
||||
}
|
||||
|
||||
void
|
||||
driFenceFinish(DriFenceObject * fence, unsigned type, int lazy)
|
||||
{
|
||||
int ret;
|
||||
unsigned flags = (lazy) ? DRM_FENCE_FLAG_WAIT_LAZY : 0;
|
||||
|
||||
_glthread_LOCK_MUTEX(fence->mutex);
|
||||
ret = drmFenceWait(fence->fd, flags, &fence->fence, type);
|
||||
_glthread_UNLOCK_MUTEX(fence->mutex);
|
||||
BM_CKFATAL(ret);
|
||||
bo->bufmgr->bo_unreference(bo);
|
||||
}
|
||||
|
||||
int
|
||||
driFenceSignaled(DriFenceObject * fence, unsigned type)
|
||||
dri_bo_map(dri_bo *buf, GLboolean write_enable)
|
||||
{
|
||||
int signaled;
|
||||
int ret;
|
||||
return buf->bufmgr->bo_map(buf, write_enable);
|
||||
}
|
||||
|
||||
int
|
||||
dri_bo_unmap(dri_bo *buf)
|
||||
{
|
||||
return buf->bufmgr->bo_unmap(buf);
|
||||
}
|
||||
|
||||
int
|
||||
dri_bo_validate(dri_bo *buf, unsigned int flags)
|
||||
{
|
||||
return buf->bufmgr->bo_validate(buf, flags);
|
||||
}
|
||||
|
||||
dri_fence *
|
||||
dri_fence_validated(dri_bufmgr *bufmgr, const char *name, GLboolean flushed)
|
||||
{
|
||||
return bufmgr->fence_validated(bufmgr, name, flushed);
|
||||
}
|
||||
|
||||
void
|
||||
dri_fence_wait(dri_fence *fence)
|
||||
{
|
||||
fence->bufmgr->fence_wait(fence);
|
||||
}
|
||||
|
||||
void
|
||||
dri_fence_reference(dri_fence *fence)
|
||||
{
|
||||
fence->bufmgr->fence_reference(fence);
|
||||
}
|
||||
|
||||
void
|
||||
dri_fence_unreference(dri_fence *fence)
|
||||
{
|
||||
if (fence == NULL)
|
||||
return GL_TRUE;
|
||||
|
||||
_glthread_LOCK_MUTEX(fence->mutex);
|
||||
ret = drmFenceSignaled(fence->fd, &fence->fence, type, &signaled);
|
||||
_glthread_UNLOCK_MUTEX(fence->mutex);
|
||||
BM_CKFATAL(ret);
|
||||
return signaled;
|
||||
}
|
||||
|
||||
|
||||
extern drmBO *
|
||||
driBOKernel(struct _DriBufferObject *buf)
|
||||
{
|
||||
drmBO *ret;
|
||||
|
||||
assert(buf->private != NULL);
|
||||
ret = buf->pool->kernel(buf->pool, buf->private);
|
||||
if (!ret)
|
||||
BM_CKFATAL(-EINVAL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
driBOWaitIdle(struct _DriBufferObject *buf, int lazy)
|
||||
{
|
||||
struct _DriBufferPool *pool;
|
||||
void *priv;
|
||||
|
||||
_glthread_LOCK_MUTEX(buf->mutex);
|
||||
pool = buf->pool;
|
||||
priv = buf->private;
|
||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
||||
|
||||
assert(priv != NULL);
|
||||
BM_CKFATAL(buf->pool->waitIdle(pool, priv, lazy));
|
||||
}
|
||||
|
||||
void *
|
||||
driBOMap(struct _DriBufferObject *buf, unsigned flags, unsigned hint)
|
||||
{
|
||||
void *virtual;
|
||||
|
||||
assert(buf->private != NULL);
|
||||
|
||||
_glthread_LOCK_MUTEX(buf->mutex);
|
||||
BM_CKFATAL(buf->pool->map(buf->pool, buf->private, flags, hint, &virtual));
|
||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
||||
return virtual;
|
||||
}
|
||||
|
||||
void
|
||||
driBOUnmap(struct _DriBufferObject *buf)
|
||||
{
|
||||
assert(buf->private != NULL);
|
||||
|
||||
buf->pool->unmap(buf->pool, buf->private);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
driBOOffset(struct _DriBufferObject *buf)
|
||||
{
|
||||
unsigned long ret;
|
||||
|
||||
assert(buf->private != NULL);
|
||||
|
||||
_glthread_LOCK_MUTEX(buf->mutex);
|
||||
ret = buf->pool->offset(buf->pool, buf->private);
|
||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned
|
||||
driBOFlags(struct _DriBufferObject *buf)
|
||||
{
|
||||
unsigned ret;
|
||||
|
||||
assert(buf->private != NULL);
|
||||
|
||||
_glthread_LOCK_MUTEX(buf->mutex);
|
||||
ret = buf->pool->flags(buf->pool, buf->private);
|
||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct _DriBufferObject *
|
||||
driBOReference(struct _DriBufferObject *buf)
|
||||
{
|
||||
_glthread_LOCK_MUTEX(bmMutex);
|
||||
if (++buf->refCount == 1) {
|
||||
BM_CKFATAL(-EINVAL);
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX(bmMutex);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
driBOUnReference(struct _DriBufferObject *buf)
|
||||
{
|
||||
int tmp;
|
||||
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
_glthread_LOCK_MUTEX(bmMutex);
|
||||
tmp = --buf->refCount;
|
||||
_glthread_UNLOCK_MUTEX(bmMutex);
|
||||
if (!tmp) {
|
||||
buf->pool->destroy(buf->pool, buf->private);
|
||||
free(buf);
|
||||
}
|
||||
fence->bufmgr->fence_unreference(fence);
|
||||
}
|
||||
|
||||
void
|
||||
driBOData(struct _DriBufferObject *buf,
|
||||
unsigned size, const void *data, unsigned flags)
|
||||
dri_bo_subdata(dri_bo *bo, unsigned long offset,
|
||||
unsigned long size, const void *data)
|
||||
{
|
||||
void *virtual;
|
||||
int newBuffer;
|
||||
struct _DriBufferPool *pool;
|
||||
if (size == 0 || data == NULL)
|
||||
return;
|
||||
|
||||
_glthread_LOCK_MUTEX(buf->mutex);
|
||||
pool = buf->pool;
|
||||
if (!pool->create) {
|
||||
_mesa_error(NULL, GL_INVALID_OPERATION,
|
||||
"driBOData called on invalid buffer\n");
|
||||
BM_CKFATAL(-EINVAL);
|
||||
}
|
||||
newBuffer = !buf->private || (pool->size(pool, buf->private) < size) ||
|
||||
pool->map(pool, buf->private, DRM_BO_FLAG_WRITE,
|
||||
DRM_BO_HINT_DONT_BLOCK, &virtual);
|
||||
|
||||
if (newBuffer) {
|
||||
if (buf->private)
|
||||
pool->destroy(pool, buf->private);
|
||||
if (!flags)
|
||||
flags = buf->flags;
|
||||
buf->private = pool->create(pool, size, flags, DRM_BO_HINT_DONT_FENCE,
|
||||
buf->alignment);
|
||||
if (!buf->private)
|
||||
BM_CKFATAL(-ENOMEM);
|
||||
BM_CKFATAL(pool->map(pool, buf->private,
|
||||
DRM_BO_FLAG_WRITE,
|
||||
DRM_BO_HINT_DONT_BLOCK, &virtual));
|
||||
}
|
||||
|
||||
if (data != NULL)
|
||||
memcpy(virtual, data, size);
|
||||
|
||||
BM_CKFATAL(pool->unmap(pool, buf->private));
|
||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
||||
dri_bo_map(bo, GL_TRUE);
|
||||
memcpy((unsigned char *)bo->virtual + offset, data, size);
|
||||
dri_bo_unmap(bo);
|
||||
}
|
||||
|
||||
void
|
||||
driBOSubData(struct _DriBufferObject *buf,
|
||||
unsigned long offset, unsigned long size, const void *data)
|
||||
dri_bo_get_subdata(dri_bo *bo, unsigned long offset,
|
||||
unsigned long size, void *data)
|
||||
{
|
||||
void *virtual;
|
||||
if (size == 0 || data == NULL)
|
||||
return;
|
||||
|
||||
_glthread_LOCK_MUTEX(buf->mutex);
|
||||
if (size && data) {
|
||||
BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
|
||||
DRM_BO_FLAG_WRITE, 0, &virtual));
|
||||
memcpy((unsigned char *) virtual + offset, data, size);
|
||||
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
||||
dri_bo_map(bo, GL_FALSE);
|
||||
memcpy(data, (unsigned char *)bo->virtual + offset, size);
|
||||
dri_bo_unmap(bo);
|
||||
}
|
||||
|
||||
void
|
||||
driBOGetSubData(struct _DriBufferObject *buf,
|
||||
unsigned long offset, unsigned long size, void *data)
|
||||
dri_bufmgr_destroy(dri_bufmgr *bufmgr)
|
||||
{
|
||||
void *virtual;
|
||||
|
||||
_glthread_LOCK_MUTEX(buf->mutex);
|
||||
if (size && data) {
|
||||
BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
|
||||
DRM_BO_FLAG_READ, 0, &virtual));
|
||||
memcpy(data, (unsigned char *) virtual + offset, size);
|
||||
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
||||
}
|
||||
|
||||
void
|
||||
driBOSetStatic(struct _DriBufferObject *buf,
|
||||
unsigned long offset,
|
||||
unsigned long size, void *virtual, unsigned flags)
|
||||
{
|
||||
_glthread_LOCK_MUTEX(buf->mutex);
|
||||
if (buf->private != NULL) {
|
||||
_mesa_error(NULL, GL_INVALID_OPERATION,
|
||||
"Invalid buffer for setStatic\n");
|
||||
BM_CKFATAL(-EINVAL);
|
||||
}
|
||||
if (buf->pool->setstatic == NULL) {
|
||||
_mesa_error(NULL, GL_INVALID_OPERATION,
|
||||
"Invalid buffer pool for setStatic\n");
|
||||
BM_CKFATAL(-EINVAL);
|
||||
}
|
||||
|
||||
if (!flags)
|
||||
flags = buf->flags;
|
||||
|
||||
buf->private = buf->pool->setstatic(buf->pool, offset, size,
|
||||
virtual, flags);
|
||||
if (!buf->private) {
|
||||
_mesa_error(NULL, GL_OUT_OF_MEMORY,
|
||||
"Invalid buffer pool for setStatic\n");
|
||||
BM_CKFATAL(-ENOMEM);
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
driGenBuffers(struct _DriBufferPool *pool,
|
||||
const char *name,
|
||||
unsigned n,
|
||||
struct _DriBufferObject *buffers[],
|
||||
unsigned alignment, unsigned flags, unsigned hint)
|
||||
{
|
||||
struct _DriBufferObject *buf;
|
||||
int i;
|
||||
|
||||
flags = (flags) ? flags : DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_MEM_VRAM |
|
||||
DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE;
|
||||
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
buf = (struct _DriBufferObject *) calloc(1, sizeof(*buf));
|
||||
if (!buf)
|
||||
BM_CKFATAL(-ENOMEM);
|
||||
|
||||
_glthread_INIT_MUTEX(buf->mutex);
|
||||
_glthread_LOCK_MUTEX(buf->mutex);
|
||||
_glthread_LOCK_MUTEX(bmMutex);
|
||||
buf->refCount = 1;
|
||||
_glthread_UNLOCK_MUTEX(bmMutex);
|
||||
buf->flags = flags;
|
||||
buf->hint = hint;
|
||||
buf->name = name;
|
||||
buf->alignment = alignment;
|
||||
buf->pool = pool;
|
||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
||||
buffers[i] = buf;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
driDeleteBuffers(unsigned n, struct _DriBufferObject *buffers[])
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
driBOUnReference(buffers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
driInitBufMgr(int fd)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
driBOCreateList(int target, drmBOList * list)
|
||||
{
|
||||
_glthread_LOCK_MUTEX(bmMutex);
|
||||
BM_CKFATAL(drmBOCreateList(target, list));
|
||||
_glthread_UNLOCK_MUTEX(bmMutex);
|
||||
}
|
||||
|
||||
void
|
||||
driBOResetList(drmBOList * list)
|
||||
{
|
||||
_glthread_LOCK_MUTEX(bmMutex);
|
||||
BM_CKFATAL(drmBOResetList(list));
|
||||
_glthread_UNLOCK_MUTEX(bmMutex);
|
||||
}
|
||||
|
||||
void
|
||||
driBOAddListItem(drmBOList * list, struct _DriBufferObject *buf,
|
||||
unsigned flags, unsigned mask)
|
||||
{
|
||||
int newItem;
|
||||
|
||||
_glthread_LOCK_MUTEX(buf->mutex);
|
||||
_glthread_LOCK_MUTEX(bmMutex);
|
||||
BM_CKFATAL(drmAddValidateItem(list, driBOKernel(buf),
|
||||
flags, mask, &newItem));
|
||||
_glthread_UNLOCK_MUTEX(bmMutex);
|
||||
|
||||
/*
|
||||
* Tell userspace pools to validate the buffer. This should be a
|
||||
* noop if the pool is already validated.
|
||||
* FIXME: We should have a list for this as well.
|
||||
*/
|
||||
|
||||
if (buf->pool->validate) {
|
||||
BM_CKFATAL(buf->pool->validate(buf->pool, buf->private));
|
||||
}
|
||||
|
||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
||||
}
|
||||
|
||||
void
|
||||
driBOFence(struct _DriBufferObject *buf, struct _DriFenceObject *fence)
|
||||
{
|
||||
_glthread_LOCK_MUTEX(buf->mutex);
|
||||
BM_CKFATAL(buf->pool->fence(buf->pool, buf->private, fence));
|
||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
driBOValidateList(int fd, drmBOList * list)
|
||||
{
|
||||
_glthread_LOCK_MUTEX(bmMutex);
|
||||
BM_CKFATAL(drmBOValidateList(fd, list));
|
||||
_glthread_UNLOCK_MUTEX(bmMutex);
|
||||
}
|
||||
|
||||
void
|
||||
driPoolTakeDown(struct _DriBufferPool *pool)
|
||||
{
|
||||
pool->takeDown(pool);
|
||||
|
||||
bufmgr->destroy(bufmgr);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright © 2007 Intel Corporation
|
||||
* Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
|
||||
* All Rights Reserved.
|
||||
*
|
||||
@@ -28,72 +29,170 @@
|
||||
/*
|
||||
* Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
|
||||
* Keith Whitwell <keithw-at-tungstengraphics-dot-com>
|
||||
* Eric Anholt <eric@anholt.net>
|
||||
*/
|
||||
|
||||
#ifndef _DRI_BUFMGR_H_
|
||||
#define _DRI_BUFMGR_H_
|
||||
#include <xf86drm.h>
|
||||
|
||||
typedef struct _dri_bufmgr dri_bufmgr;
|
||||
typedef struct _dri_bo dri_bo;
|
||||
typedef struct _dri_fence dri_fence;
|
||||
|
||||
struct _DriFenceObject;
|
||||
struct _DriBufferObject;
|
||||
struct _DriBufferPool;
|
||||
struct _dri_bo {
|
||||
/** Size in bytes of the buffer object. */
|
||||
unsigned long size;
|
||||
/**
|
||||
* Card virtual address (offset from the beginning of the aperture) for the
|
||||
* object. Only valid while validated.
|
||||
*/
|
||||
unsigned long offset;
|
||||
/**
|
||||
* Virtual address for accessing the buffer data. Only valid while mapped.
|
||||
*/
|
||||
void *virtual;
|
||||
/** Buffer manager context associated with this buffer object */
|
||||
dri_bufmgr *bufmgr;
|
||||
};
|
||||
|
||||
extern struct _DriFenceObject *driFenceBuffers(int fd, char *name,
|
||||
unsigned flags);
|
||||
struct _dri_fence {
|
||||
/**
|
||||
* This is an ORed mask of DRM_BO_FLAG_READ, DRM_BO_FLAG_WRITE, and
|
||||
* DRM_FLAG_EXE indicating the operations associated with this fence.
|
||||
*
|
||||
* It is constant for the life of the fence object.
|
||||
*/
|
||||
unsigned int type;
|
||||
/** Buffer manager context associated with this fence */
|
||||
dri_bufmgr *bufmgr;
|
||||
};
|
||||
|
||||
extern struct _DriFenceObject *driFenceReference(struct _DriFenceObject *fence);
|
||||
|
||||
extern void driFenceUnReference(struct _DriFenceObject *fence);
|
||||
|
||||
extern void
|
||||
driFenceFinish(struct _DriFenceObject *fence, unsigned type, int lazy);
|
||||
|
||||
extern int driFenceSignaled(struct _DriFenceObject *fence, unsigned type);
|
||||
extern unsigned driFenceType(struct _DriFenceObject *fence);
|
||||
|
||||
/*
|
||||
* Return a pointer to the libdrm buffer object this DriBufferObject
|
||||
* uses.
|
||||
/**
|
||||
* Context for a buffer manager instance.
|
||||
*
|
||||
* Contains public methods followed by private storage for the buffer manager.
|
||||
*/
|
||||
struct _dri_bufmgr {
|
||||
/**
|
||||
* Allocate a buffer object.
|
||||
*
|
||||
* Buffer objects are not necessarily initially mapped into CPU virtual
|
||||
* address space or graphics device aperture. They must be mapped using
|
||||
* bo_map() to be used by the CPU, and validated for use using bo_validate()
|
||||
* to be used from the graphics device.
|
||||
*/
|
||||
dri_bo *(*bo_alloc)(dri_bufmgr *bufmgr_ctx, const char *name,
|
||||
unsigned long size, unsigned int alignment,
|
||||
unsigned int location_mask);
|
||||
|
||||
extern drmBO *driBOKernel(struct _DriBufferObject *buf);
|
||||
extern void *driBOMap(struct _DriBufferObject *buf, unsigned flags,
|
||||
unsigned hint);
|
||||
extern void driBOUnmap(struct _DriBufferObject *buf);
|
||||
extern unsigned long driBOOffset(struct _DriBufferObject *buf);
|
||||
extern unsigned driBOFlags(struct _DriBufferObject *buf);
|
||||
extern struct _DriBufferObject *driBOReference(struct _DriBufferObject *buf);
|
||||
extern void driBOUnReference(struct _DriBufferObject *buf);
|
||||
extern void driBOData(struct _DriBufferObject *r_buf,
|
||||
unsigned size, const void *data, unsigned flags);
|
||||
extern void driBOSubData(struct _DriBufferObject *buf,
|
||||
unsigned long offset, unsigned long size,
|
||||
const void *data);
|
||||
extern void driBOGetSubData(struct _DriBufferObject *buf,
|
||||
unsigned long offset, unsigned long size,
|
||||
void *data);
|
||||
extern void driGenBuffers(struct _DriBufferPool *pool,
|
||||
const char *name,
|
||||
unsigned n,
|
||||
struct _DriBufferObject *buffers[],
|
||||
unsigned alignment, unsigned flags, unsigned hint);
|
||||
extern void driDeleteBuffers(unsigned n, struct _DriBufferObject *buffers[]);
|
||||
extern void driInitBufMgr(int fd);
|
||||
extern void driBOCreateList(int target, drmBOList * list);
|
||||
extern void driBOResetList(drmBOList * list);
|
||||
extern void driBOAddListItem(drmBOList * list, struct _DriBufferObject *buf,
|
||||
unsigned flags, unsigned mask);
|
||||
extern void driBOValidateList(int fd, drmBOList * list);
|
||||
/**
|
||||
* Allocates a buffer object for a static allocation.
|
||||
*
|
||||
* Static allocations are ones such as the front buffer that are offered by
|
||||
* the X Server, which are never evicted and never moved.
|
||||
*/
|
||||
dri_bo *(*bo_alloc_static)(dri_bufmgr *bufmgr_ctx, const char *name,
|
||||
unsigned long offset, unsigned long size,
|
||||
void *virtual, unsigned int location_mask);
|
||||
|
||||
extern void driBOFence(struct _DriBufferObject *buf,
|
||||
struct _DriFenceObject *fence);
|
||||
/** Takes a reference on a buffer object */
|
||||
void (*bo_reference)(dri_bo *bo);
|
||||
|
||||
extern void driPoolTakeDown(struct _DriBufferPool *pool);
|
||||
extern void driBOSetStatic(struct _DriBufferObject *buf,
|
||||
unsigned long offset,
|
||||
unsigned long size, void *virtual, unsigned flags);
|
||||
extern void driBOWaitIdle(struct _DriBufferObject *buf, int lazy);
|
||||
extern void driPoolTakeDown(struct _DriBufferPool *pool);
|
||||
/**
|
||||
* Releases a reference on a buffer object, freeing the data if
|
||||
* rerefences remain.
|
||||
*/
|
||||
void (*bo_unreference)(dri_bo *bo);
|
||||
|
||||
/**
|
||||
* Maps the buffer into userspace.
|
||||
*
|
||||
* This function will block waiting for any existing fence on the buffer to
|
||||
* clear, first. The resulting mapping is available at buf->virtual.
|
||||
\ */
|
||||
int (*bo_map)(dri_bo *buf, GLboolean write_enable);
|
||||
|
||||
/** Reduces the refcount on the userspace mapping of the buffer object. */
|
||||
int (*bo_unmap)(dri_bo *buf);
|
||||
|
||||
/**
|
||||
* Makes the buffer accessible to the graphics chip.
|
||||
*
|
||||
* The resulting offset of the buffer within the graphics aperture is then
|
||||
* available at buf->offset until the buffer is fenced.
|
||||
*
|
||||
* Flags should consist of the memory types that the buffer may be validated
|
||||
* into and the read/write/exe flags appropriate to the use of the buffer.
|
||||
*/
|
||||
int (*bo_validate)(dri_bo *buf, unsigned int flags);
|
||||
|
||||
/**
|
||||
* Associates the current set of validated buffers with a fence.
|
||||
*
|
||||
* Once fenced, the buffer manager will allow the validated buffers to be
|
||||
* evicted when the graphics device's execution has passed the fence
|
||||
* command.
|
||||
*
|
||||
* The fence object will have flags for the sum of the read/write/exe flags
|
||||
* of the validated buffers associated with it.
|
||||
*/
|
||||
dri_fence * (*fence_validated)(dri_bufmgr *bufmgr, const char *name,
|
||||
GLboolean flushed);
|
||||
|
||||
/** Takes a reference on a fence object */
|
||||
void (*fence_reference)(dri_fence *fence);
|
||||
|
||||
/**
|
||||
* Releases a reference on a fence object, freeing the data if
|
||||
* rerefences remain.
|
||||
*/
|
||||
void (*fence_unreference)(dri_fence *fence);
|
||||
|
||||
/**
|
||||
* Blocks until the given fence is signaled.
|
||||
*/
|
||||
void (*fence_wait)(dri_fence *fence);
|
||||
|
||||
/**
|
||||
* Tears down the buffer manager instance.
|
||||
*/
|
||||
void (*destroy)(dri_bufmgr *bufmgr);
|
||||
};
|
||||
|
||||
dri_bo *dri_bo_alloc(dri_bufmgr *bufmgr, const char *name, unsigned long size,
|
||||
unsigned int alignment, unsigned int location_mask);
|
||||
dri_bo *dri_bo_alloc_static(dri_bufmgr *bufmgr, const char *name,
|
||||
unsigned long offset, unsigned long size,
|
||||
void *virtual, unsigned int location_mask);
|
||||
void dri_bo_reference(dri_bo *bo);
|
||||
void dri_bo_unreference(dri_bo *bo);
|
||||
int dri_bo_map(dri_bo *buf, GLboolean write_enable);
|
||||
int dri_bo_unmap(dri_bo *buf);
|
||||
int dri_bo_validate(dri_bo *buf, unsigned int flags);
|
||||
dri_fence *dri_fence_validated(dri_bufmgr *bufmgr, const char *name,
|
||||
GLboolean flushed);
|
||||
void dri_fence_wait(dri_fence *fence);
|
||||
void dri_fence_reference(dri_fence *fence);
|
||||
void dri_fence_unreference(dri_fence *fence);
|
||||
|
||||
void dri_bo_subdata(dri_bo *bo, unsigned long offset,
|
||||
unsigned long size, const void *data);
|
||||
void dri_bo_get_subdata(dri_bo *bo, unsigned long offset,
|
||||
unsigned long size, void *data);
|
||||
|
||||
dri_bufmgr *dri_bufmgr_ttm_init(int fd, unsigned int fence_type,
|
||||
unsigned int fence_type_flush);
|
||||
|
||||
void dri_bufmgr_fake_contended_lock_take(dri_bufmgr *bufmgr);
|
||||
dri_bufmgr *dri_bufmgr_fake_init(unsigned long low_offset, void *low_virtual,
|
||||
unsigned long size,
|
||||
unsigned int (*fence_emit)(void *private),
|
||||
int (*fence_wait)(void *private,
|
||||
unsigned int cookie),
|
||||
void *driver_priv);
|
||||
void dri_bufmgr_destroy(dri_bufmgr *bufmgr);
|
||||
dri_bo *dri_ttm_bo_create_from_handle(dri_bufmgr *bufmgr, const char *name,
|
||||
unsigned int handle);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,882 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/* Originally a fake version of the buffer manager so that we can
|
||||
* prototype the changes in a driver fairly quickly, has been fleshed
|
||||
* out to a fully functional interim solution.
|
||||
*
|
||||
* Basically wraps the old style memory management in the new
|
||||
* programming interface, but is more expressive and avoids many of
|
||||
* the bugs in the old texture manager.
|
||||
*/
|
||||
#include "mtypes.h"
|
||||
#include "dri_bufmgr.h"
|
||||
#include "drm.h"
|
||||
|
||||
#include "simple_list.h"
|
||||
#include "mm.h"
|
||||
#include "imports.h"
|
||||
|
||||
#if 0
|
||||
#define DBG(...) _mesa_printf(__VA_ARGS__)
|
||||
#else
|
||||
#define DBG(...)
|
||||
#endif
|
||||
|
||||
/* Internal flags:
|
||||
*/
|
||||
#define BM_NO_BACKING_STORE 0x00000001
|
||||
#define BM_NO_FENCE_SUBDATA 0x00000002
|
||||
#define BM_PINNED 0x00000004
|
||||
|
||||
/* Wrapper around mm.c's mem_block, which understands that you must
|
||||
* wait for fences to expire before memory can be freed. This is
|
||||
* specific to our use of memcpy for uploads - an upload that was
|
||||
* processed through the command queue wouldn't need to care about
|
||||
* fences.
|
||||
*/
|
||||
struct block {
|
||||
struct block *next, *prev;
|
||||
struct mem_block *mem; /* BM_MEM_AGP */
|
||||
|
||||
unsigned on_hardware:1;
|
||||
unsigned fenced:1;
|
||||
|
||||
unsigned fence; /* BM_MEM_AGP, Split to read_fence, write_fence */
|
||||
|
||||
dri_bo *bo;
|
||||
void *virtual;
|
||||
};
|
||||
|
||||
typedef struct _bufmgr_fake {
|
||||
dri_bufmgr bufmgr;
|
||||
|
||||
_glthread_Mutex mutex; /**< for thread safety */
|
||||
|
||||
unsigned long low_offset;
|
||||
unsigned long size;
|
||||
void *virtual;
|
||||
|
||||
struct mem_block *heap;
|
||||
struct block lru; /* only allocated, non-fence-pending blocks here */
|
||||
|
||||
unsigned buf_nr; /* for generating ids */
|
||||
|
||||
struct block on_hardware; /* after bmValidateBuffers */
|
||||
struct block fenced; /* after bmFenceBuffers (mi_flush, emit irq, write dword) */
|
||||
/* then to bufmgr->lru or free() */
|
||||
|
||||
unsigned int last_fence;
|
||||
|
||||
unsigned fail:1;
|
||||
unsigned need_fence:1;
|
||||
GLboolean thrashing;
|
||||
|
||||
/**
|
||||
* Driver callback to emit a fence, returning the cookie.
|
||||
*
|
||||
* Currently, this also requires that a write flush be emitted before
|
||||
* emitting the fence, but this should change.
|
||||
*/
|
||||
unsigned int (*fence_emit)(void *private);
|
||||
/** Driver callback to wait for a fence cookie to have passed. */
|
||||
int (*fence_wait)(void *private, unsigned int fence_cookie);
|
||||
/** Driver-supplied argument to driver callbacks */
|
||||
void *driver_priv;
|
||||
} dri_bufmgr_fake;
|
||||
|
||||
typedef struct _dri_bo_fake {
|
||||
dri_bo bo;
|
||||
|
||||
unsigned id; /* debug only */
|
||||
const char *name;
|
||||
|
||||
unsigned dirty:1;
|
||||
unsigned int refcount;
|
||||
/* Flags may consist of any of the DRM_BO flags, plus
|
||||
* DRM_BO_NO_BACKING_STORE and BM_NO_FENCE_SUBDATA, which are the first two
|
||||
* driver private flags.
|
||||
*/
|
||||
unsigned int flags;
|
||||
unsigned int alignment;
|
||||
GLboolean is_static;
|
||||
|
||||
struct block *block;
|
||||
void *backing_store;
|
||||
void (*invalidate_cb)(dri_bufmgr *bufmgr, void * );
|
||||
void *invalidate_ptr;
|
||||
} dri_bo_fake;
|
||||
|
||||
typedef struct _dri_fence_fake {
|
||||
dri_fence fence;
|
||||
|
||||
const char *name;
|
||||
unsigned int refcount;
|
||||
unsigned int fence_cookie;
|
||||
GLboolean flushed;
|
||||
} dri_fence_fake;
|
||||
|
||||
static int clear_fenced(dri_bufmgr_fake *bufmgr_fake,
|
||||
unsigned int fence_cookie);
|
||||
|
||||
#define MAXFENCE 0x7fffffff
|
||||
|
||||
static GLboolean FENCE_LTE( unsigned a, unsigned b )
|
||||
{
|
||||
if (a == b)
|
||||
return GL_TRUE;
|
||||
|
||||
if (a < b && b - a < (1<<24))
|
||||
return GL_TRUE;
|
||||
|
||||
if (a > b && MAXFENCE - a + b < (1<<24))
|
||||
return GL_TRUE;
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
_fence_emit_internal(dri_bufmgr_fake *bufmgr_fake)
|
||||
{
|
||||
bufmgr_fake->last_fence = bufmgr_fake->fence_emit(bufmgr_fake->driver_priv);
|
||||
return bufmgr_fake->last_fence;
|
||||
}
|
||||
|
||||
static void
|
||||
_fence_wait_internal(dri_bufmgr_fake *bufmgr_fake, unsigned int cookie)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = bufmgr_fake->fence_wait(bufmgr_fake->driver_priv, cookie);
|
||||
if (ret != 0) {
|
||||
_mesa_printf("%s:%d: Error %d waiting for fence.\n",
|
||||
__FILE__, __LINE__);
|
||||
abort();
|
||||
}
|
||||
clear_fenced(bufmgr_fake, cookie);
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
_fence_test(dri_bufmgr_fake *bufmgr_fake, unsigned fence)
|
||||
{
|
||||
/* Slight problem with wrap-around:
|
||||
*/
|
||||
return fence == 0 || FENCE_LTE(fence, bufmgr_fake->last_fence);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a memory manager block for the buffer.
|
||||
*/
|
||||
static GLboolean
|
||||
alloc_block(dri_bo *bo)
|
||||
{
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)bo;
|
||||
dri_bufmgr_fake *bufmgr_fake= (dri_bufmgr_fake *)bo->bufmgr;
|
||||
struct block *block = (struct block *)calloc(sizeof *block, 1);
|
||||
unsigned int align_log2 = ffs(bo_fake->alignment);
|
||||
GLuint sz;
|
||||
|
||||
if (!block)
|
||||
return GL_FALSE;
|
||||
|
||||
sz = (bo->size + bo_fake->alignment - 1) & ~(bo_fake->alignment - 1);
|
||||
|
||||
block->mem = mmAllocMem(bufmgr_fake->heap, sz, align_log2, 0);
|
||||
if (!block->mem) {
|
||||
free(block);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
make_empty_list(block);
|
||||
|
||||
/* Insert at head or at tail???
|
||||
*/
|
||||
insert_at_tail(&bufmgr_fake->lru, block);
|
||||
|
||||
block->virtual = bufmgr_fake->virtual +
|
||||
block->mem->ofs - bufmgr_fake->low_offset;
|
||||
block->bo = bo;
|
||||
|
||||
bo_fake->block = block;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/* Release the card storage associated with buf:
|
||||
*/
|
||||
static void free_block(dri_bufmgr_fake *bufmgr_fake, struct block *block)
|
||||
{
|
||||
DBG("free block %p\n", block);
|
||||
|
||||
if (!block)
|
||||
return;
|
||||
|
||||
if (block->on_hardware) {
|
||||
block->bo = NULL;
|
||||
}
|
||||
else if (block->fenced) {
|
||||
block->bo = NULL;
|
||||
}
|
||||
else {
|
||||
DBG(" - free immediately\n");
|
||||
remove_from_list(block);
|
||||
|
||||
mmFreeMem(block->mem);
|
||||
free(block);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
alloc_backing_store(dri_bo *bo)
|
||||
{
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)bo;
|
||||
assert(!bo_fake->backing_store);
|
||||
assert(!(bo_fake->flags & (BM_PINNED|BM_NO_BACKING_STORE)));
|
||||
|
||||
bo_fake->backing_store = ALIGN_MALLOC(bo->size, 64);
|
||||
}
|
||||
|
||||
static void
|
||||
free_backing_store(dri_bo *bo)
|
||||
{
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)bo;
|
||||
assert(!(bo_fake->flags & (BM_PINNED|BM_NO_BACKING_STORE)));
|
||||
|
||||
if (bo_fake->backing_store) {
|
||||
ALIGN_FREE(bo_fake->backing_store);
|
||||
bo_fake->backing_store = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_dirty(dri_bo *bo)
|
||||
{
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bo->bufmgr;
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)bo;
|
||||
|
||||
if (bo_fake->flags & BM_NO_BACKING_STORE)
|
||||
bo_fake->invalidate_cb(&bufmgr_fake->bufmgr, bo_fake->invalidate_ptr);
|
||||
|
||||
assert(!(bo_fake->flags & BM_PINNED));
|
||||
|
||||
DBG("set_dirty - buf %d\n", bo_fake->id);
|
||||
bo_fake->dirty = 1;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
evict_lru(dri_bufmgr_fake *bufmgr_fake, GLuint max_fence)
|
||||
{
|
||||
struct block *block, *tmp;
|
||||
|
||||
DBG("%s\n", __FUNCTION__);
|
||||
|
||||
foreach_s(block, tmp, &bufmgr_fake->lru) {
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)block->bo;
|
||||
|
||||
if (bo_fake != NULL && (bo_fake->flags & BM_NO_FENCE_SUBDATA))
|
||||
continue;
|
||||
|
||||
if (block->fence && max_fence && !FENCE_LTE(block->fence, max_fence))
|
||||
return 0;
|
||||
|
||||
set_dirty(&bo_fake->bo);
|
||||
bo_fake->block = NULL;
|
||||
|
||||
free_block(bufmgr_fake, block);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
#define foreach_s_rev(ptr, t, list) \
|
||||
for(ptr=(list)->prev,t=(ptr)->prev; list != ptr; ptr=t, t=(t)->prev)
|
||||
|
||||
static GLboolean
|
||||
evict_mru(dri_bufmgr_fake *bufmgr_fake)
|
||||
{
|
||||
struct block *block, *tmp;
|
||||
|
||||
DBG("%s\n", __FUNCTION__);
|
||||
|
||||
foreach_s_rev(block, tmp, &bufmgr_fake->lru) {
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)block->bo;
|
||||
|
||||
if (bo_fake && (bo_fake->flags & BM_NO_FENCE_SUBDATA))
|
||||
continue;
|
||||
|
||||
set_dirty(&bo_fake->bo);
|
||||
bo_fake->block = NULL;
|
||||
|
||||
free_block(bufmgr_fake, block);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all objects from the fenced list older than the given fence.
|
||||
*/
|
||||
static int clear_fenced(dri_bufmgr_fake *bufmgr_fake,
|
||||
unsigned int fence_cookie)
|
||||
{
|
||||
struct block *block, *tmp;
|
||||
int ret = 0;
|
||||
|
||||
foreach_s(block, tmp, &bufmgr_fake->fenced) {
|
||||
assert(block->fenced);
|
||||
|
||||
if (_fence_test(bufmgr_fake, block->fence)) {
|
||||
|
||||
block->fenced = 0;
|
||||
|
||||
if (!block->bo) {
|
||||
DBG("delayed free: offset %x sz %x\n",
|
||||
block->mem->ofs, block->mem->size);
|
||||
remove_from_list(block);
|
||||
mmFreeMem(block->mem);
|
||||
free(block);
|
||||
}
|
||||
else {
|
||||
DBG("return to lru: offset %x sz %x\n",
|
||||
block->mem->ofs, block->mem->size);
|
||||
move_to_tail(&bufmgr_fake->lru, block);
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
}
|
||||
else {
|
||||
/* Blocks are ordered by fence, so if one fails, all from
|
||||
* here will fail also:
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DBG("%s: %d\n", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void fence_blocks(dri_bufmgr_fake *bufmgr_fake, unsigned fence)
|
||||
{
|
||||
struct block *block, *tmp;
|
||||
|
||||
foreach_s (block, tmp, &bufmgr_fake->on_hardware) {
|
||||
DBG("Fence block %p (sz 0x%x buf %p) with fence %d\n", block,
|
||||
block->mem->size, block->bo, fence);
|
||||
block->fence = fence;
|
||||
|
||||
block->on_hardware = 0;
|
||||
block->fenced = 1;
|
||||
|
||||
/* Move to tail of pending list here
|
||||
*/
|
||||
move_to_tail(&bufmgr_fake->fenced, block);
|
||||
}
|
||||
|
||||
assert(is_empty_list(&bufmgr_fake->on_hardware));
|
||||
}
|
||||
|
||||
static GLboolean evict_and_alloc_block(dri_bo *bo)
|
||||
{
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bo->bufmgr;
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)bo;
|
||||
|
||||
assert(bo_fake->block == NULL);
|
||||
|
||||
/* Search for already free memory:
|
||||
*/
|
||||
if (alloc_block(bo))
|
||||
return GL_TRUE;
|
||||
|
||||
/* If we're not thrashing, allow lru eviction to dig deeper into
|
||||
* recently used textures. We'll probably be thrashing soon:
|
||||
*/
|
||||
if (!bufmgr_fake->thrashing) {
|
||||
while (evict_lru(bufmgr_fake, 0))
|
||||
if (alloc_block(bo))
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/* Keep thrashing counter alive?
|
||||
*/
|
||||
if (bufmgr_fake->thrashing)
|
||||
bufmgr_fake->thrashing = 20;
|
||||
|
||||
/* Wait on any already pending fences - here we are waiting for any
|
||||
* freed memory that has been submitted to hardware and fenced to
|
||||
* become available:
|
||||
*/
|
||||
while (!is_empty_list(&bufmgr_fake->fenced)) {
|
||||
GLuint fence = bufmgr_fake->fenced.next->fence;
|
||||
_fence_wait_internal(bufmgr_fake, fence);
|
||||
|
||||
if (alloc_block(bo))
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
if (!is_empty_list(&bufmgr_fake->on_hardware)) {
|
||||
while (!is_empty_list(&bufmgr_fake->fenced)) {
|
||||
GLuint fence = bufmgr_fake->fenced.next->fence;
|
||||
_fence_wait_internal(bufmgr_fake, fence);
|
||||
}
|
||||
|
||||
if (!bufmgr_fake->thrashing) {
|
||||
DBG("thrashing\n");
|
||||
}
|
||||
bufmgr_fake->thrashing = 20;
|
||||
|
||||
if (alloc_block(bo))
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
while (evict_mru(bufmgr_fake))
|
||||
if (alloc_block(bo))
|
||||
return GL_TRUE;
|
||||
|
||||
DBG("%s 0x%x bytes failed\n", __FUNCTION__, bo->size);
|
||||
|
||||
assert(is_empty_list(&bufmgr_fake->on_hardware));
|
||||
assert(is_empty_list(&bufmgr_fake->fenced));
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Public functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* Wait for hardware idle by emitting a fence and waiting for it.
|
||||
*/
|
||||
static void
|
||||
dri_bufmgr_fake_wait_idle(dri_bufmgr_fake *bufmgr_fake)
|
||||
{
|
||||
unsigned int cookie;
|
||||
|
||||
cookie = bufmgr_fake->fence_emit(bufmgr_fake->driver_priv);
|
||||
_fence_wait_internal(bufmgr_fake, cookie);
|
||||
}
|
||||
|
||||
/* Specifically ignore texture memory sharing.
|
||||
* -- just evict everything
|
||||
* -- and wait for idle
|
||||
*/
|
||||
void
|
||||
dri_bufmgr_fake_contended_lock_take(dri_bufmgr *bufmgr)
|
||||
{
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bufmgr;
|
||||
|
||||
_glthread_LOCK_MUTEX(bufmgr_fake->mutex);
|
||||
{
|
||||
struct block *block, *tmp;
|
||||
|
||||
bufmgr_fake->need_fence = 1;
|
||||
bufmgr_fake->fail = 0;
|
||||
|
||||
/* Wait for hardware idle. We don't know where acceleration has been
|
||||
* happening, so we'll need to wait anyway before letting anything get
|
||||
* put on the card again.
|
||||
*/
|
||||
dri_bufmgr_fake_wait_idle(bufmgr_fake);
|
||||
|
||||
/* Check that we hadn't released the lock without having fenced the last
|
||||
* set of buffers.
|
||||
*/
|
||||
assert(is_empty_list(&bufmgr_fake->fenced));
|
||||
assert(is_empty_list(&bufmgr_fake->on_hardware));
|
||||
|
||||
foreach_s(block, tmp, &bufmgr_fake->lru) {
|
||||
assert(_fence_test(bufmgr_fake, block->fence));
|
||||
set_dirty(block->bo);
|
||||
}
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
|
||||
}
|
||||
|
||||
static dri_bo *
|
||||
dri_fake_bo_alloc(dri_bufmgr *bufmgr, const char *name,
|
||||
unsigned long size, unsigned int alignment,
|
||||
unsigned int location_mask)
|
||||
{
|
||||
dri_bufmgr_fake *bufmgr_fake;
|
||||
dri_bo_fake *bo_fake;
|
||||
|
||||
bufmgr_fake = (dri_bufmgr_fake *)bufmgr;
|
||||
|
||||
bo_fake = calloc(1, sizeof(*bo_fake));
|
||||
if (!bo_fake)
|
||||
return NULL;
|
||||
|
||||
bo_fake->bo.size = size;
|
||||
bo_fake->bo.offset = -1;
|
||||
bo_fake->bo.virtual = NULL;
|
||||
bo_fake->bo.bufmgr = bufmgr;
|
||||
bo_fake->refcount = 1;
|
||||
|
||||
/* Alignment must be a power of two */
|
||||
assert((alignment & (alignment - 1)) == 0);
|
||||
if (alignment == 0)
|
||||
alignment = 1;
|
||||
bo_fake->alignment = alignment;
|
||||
bo_fake->id = ++bufmgr_fake->buf_nr;
|
||||
bo_fake->name = name;
|
||||
bo_fake->flags = 0;
|
||||
bo_fake->is_static = GL_FALSE;
|
||||
|
||||
DBG("drm_bo_alloc: (buf %d: %s, %d kb)\n", bo_fake->id, bo_fake->name,
|
||||
bo_fake->bo.size / 1024);
|
||||
|
||||
return &bo_fake->bo;
|
||||
}
|
||||
|
||||
static dri_bo *
|
||||
dri_fake_bo_alloc_static(dri_bufmgr *bufmgr, const char *name,
|
||||
unsigned long offset, unsigned long size,
|
||||
void *virtual, unsigned int location_mask)
|
||||
{
|
||||
dri_bufmgr_fake *bufmgr_fake;
|
||||
dri_bo_fake *bo_fake;
|
||||
|
||||
bufmgr_fake = (dri_bufmgr_fake *)bufmgr;
|
||||
|
||||
bo_fake = calloc(1, sizeof(*bo_fake));
|
||||
if (!bo_fake)
|
||||
return NULL;
|
||||
|
||||
bo_fake->bo.size = size;
|
||||
bo_fake->bo.offset = offset;
|
||||
bo_fake->bo.virtual = virtual;
|
||||
bo_fake->bo.bufmgr = bufmgr;
|
||||
bo_fake->refcount = 1;
|
||||
bo_fake->id = ++bufmgr_fake->buf_nr;
|
||||
bo_fake->name = name;
|
||||
bo_fake->flags = BM_PINNED | DRM_BO_FLAG_NO_MOVE;
|
||||
bo_fake->is_static = GL_TRUE;
|
||||
|
||||
DBG("drm_bo_alloc_static: (buf %d: %s, %d kb)\n", bo_fake->id, bo_fake->name,
|
||||
bo_fake->bo.size / 1024);
|
||||
|
||||
return &bo_fake->bo;
|
||||
}
|
||||
|
||||
static void
|
||||
dri_fake_bo_reference(dri_bo *bo)
|
||||
{
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bo->bufmgr;
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)bo;
|
||||
|
||||
_glthread_LOCK_MUTEX(bufmgr_fake->mutex);
|
||||
bo_fake->refcount++;
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
dri_fake_bo_unreference(dri_bo *bo)
|
||||
{
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bo->bufmgr;
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)bo;
|
||||
|
||||
if (!bo)
|
||||
return;
|
||||
|
||||
_glthread_LOCK_MUTEX(bufmgr_fake->mutex);
|
||||
if (--bo_fake->refcount == 0) {
|
||||
/* No remaining references, so free it */
|
||||
if (bo_fake->block)
|
||||
free_block(bufmgr_fake, bo_fake->block);
|
||||
free_backing_store(bo);
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
|
||||
free(bo);
|
||||
return;
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a buffer into bo->virtual, allocating either card memory space (If
|
||||
* BM_NO_BACKING_STORE or BM_PINNED) or backing store, as necessary.
|
||||
*/
|
||||
static int
|
||||
dri_fake_bo_map(dri_bo *bo, GLboolean write_enable)
|
||||
{
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bo->bufmgr;
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)bo;
|
||||
|
||||
/* Static buffers are always mapped. */
|
||||
if (bo_fake->is_static)
|
||||
return 0;
|
||||
|
||||
_glthread_LOCK_MUTEX(bufmgr_fake->mutex);
|
||||
{
|
||||
DBG("drm_bo_map: (buf %d: %s, %d kb)\n", bo_fake->id, bo_fake->name,
|
||||
bo_fake->bo.size / 1024);
|
||||
|
||||
if (bo->virtual != NULL) {
|
||||
_mesa_printf("%s: already mapped\n", __FUNCTION__);
|
||||
abort();
|
||||
}
|
||||
else if (bo_fake->flags & (BM_NO_BACKING_STORE|BM_PINNED)) {
|
||||
|
||||
if (!bo_fake->block && !evict_and_alloc_block(bo)) {
|
||||
DBG("%s: alloc failed\n", __FUNCTION__);
|
||||
bufmgr_fake->fail = 1;
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
assert(bo_fake->block);
|
||||
bo_fake->dirty = 0;
|
||||
|
||||
if (!(bo_fake->flags & BM_NO_FENCE_SUBDATA))
|
||||
dri_bufmgr_fake_wait_idle(bufmgr_fake);
|
||||
|
||||
bo->virtual = bo_fake->block->virtual;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (write_enable)
|
||||
set_dirty(bo);
|
||||
|
||||
if (bo_fake->backing_store == 0)
|
||||
alloc_backing_store(bo);
|
||||
|
||||
bo->virtual = bo_fake->backing_store;
|
||||
}
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
dri_fake_bo_unmap(dri_bo *bo)
|
||||
{
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)bo;
|
||||
|
||||
/* Static buffers are always mapped. */
|
||||
if (bo_fake->is_static)
|
||||
return 0;
|
||||
|
||||
if (bo == NULL)
|
||||
return 0;
|
||||
|
||||
DBG("drm_bo_unmap: (buf %d: %s, %d kb)\n", bo_fake->id, bo_fake->name,
|
||||
bo_fake->bo.size / 1024);
|
||||
|
||||
bo->virtual = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
dri_fake_bo_validate(dri_bo *bo, unsigned int flags)
|
||||
{
|
||||
dri_bufmgr_fake *bufmgr_fake;
|
||||
dri_bo_fake *bo_fake = (dri_bo_fake *)bo;
|
||||
|
||||
/* XXX: Sanity-check whether we've already validated this one under
|
||||
* different flags. See drmAddValidateItem().
|
||||
*/
|
||||
|
||||
DBG("drm_bo_validate: (buf %d: %s, %d kb)\n", bo_fake->id, bo_fake->name,
|
||||
bo_fake->bo.size / 1024);
|
||||
bufmgr_fake = (dri_bufmgr_fake *)bo->bufmgr;
|
||||
|
||||
_glthread_LOCK_MUTEX(bufmgr_fake->mutex);
|
||||
{
|
||||
if (bo_fake->is_static) {
|
||||
/* Add it to the needs-fence list */
|
||||
bufmgr_fake->need_fence = 1;
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Allocate the card memory */
|
||||
if (!bo_fake->block && !evict_and_alloc_block(bo)) {
|
||||
bufmgr_fake->fail = 1;
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
|
||||
DBG("Failed to validate buf %d:%s\n", bo_fake->id, bo_fake->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert(bo_fake->block);
|
||||
assert(bo_fake->block->bo == &bo_fake->bo);
|
||||
|
||||
bo->offset = bo_fake->block->mem->ofs;
|
||||
|
||||
/* Upload the buffer contents if necessary */
|
||||
if (bo_fake->dirty) {
|
||||
DBG("Upload dirty buf %d:%s, sz %d offset 0x%x\n", bo_fake->id,
|
||||
bo_fake->name, bo->size, bo_fake->block->mem->ofs);
|
||||
|
||||
assert(!(bo_fake->flags &
|
||||
(BM_NO_BACKING_STORE|BM_PINNED)));
|
||||
|
||||
/* Actually, should be able to just wait for a fence on the memory,
|
||||
* which we would be tracking when we free it. Waiting for idle is
|
||||
* a sufficiently large hammer for now.
|
||||
*/
|
||||
dri_bufmgr_fake_wait_idle(bufmgr_fake);
|
||||
|
||||
memcpy(bo_fake->block->virtual, bo_fake->backing_store, bo->size);
|
||||
bo_fake->dirty = 0;
|
||||
}
|
||||
|
||||
bo_fake->block->on_hardware = 1;
|
||||
move_to_tail(&bufmgr_fake->on_hardware, bo_fake->block);
|
||||
|
||||
bufmgr_fake->need_fence = 1;
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static dri_fence *
|
||||
dri_fake_fence_validated(dri_bufmgr *bufmgr, const char *name,
|
||||
GLboolean flushed)
|
||||
{
|
||||
dri_fence_fake *fence_fake;
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bufmgr;
|
||||
unsigned int cookie;
|
||||
|
||||
fence_fake = malloc(sizeof(*fence_fake));
|
||||
if (!fence_fake)
|
||||
return NULL;
|
||||
|
||||
fence_fake->refcount = 1;
|
||||
fence_fake->name = name;
|
||||
fence_fake->flushed = flushed;
|
||||
fence_fake->fence.bufmgr = bufmgr;
|
||||
|
||||
_glthread_LOCK_MUTEX(bufmgr_fake->mutex);
|
||||
cookie = _fence_emit_internal(bufmgr_fake);
|
||||
fence_fake->fence_cookie = cookie;
|
||||
fence_blocks(bufmgr_fake, cookie);
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
|
||||
|
||||
DBG("drm_fence_validated: 0x%08x cookie\n", fence_fake->fence_cookie);
|
||||
|
||||
return &fence_fake->fence;
|
||||
}
|
||||
|
||||
static void
|
||||
dri_fake_fence_reference(dri_fence *fence)
|
||||
{
|
||||
dri_fence_fake *fence_fake = (dri_fence_fake *)fence;
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)fence->bufmgr;
|
||||
|
||||
_glthread_LOCK_MUTEX(bufmgr_fake->mutex);
|
||||
++fence_fake->refcount;
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
dri_fake_fence_unreference(dri_fence *fence)
|
||||
{
|
||||
dri_fence_fake *fence_fake = (dri_fence_fake *)fence;
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)fence->bufmgr;
|
||||
|
||||
if (!fence)
|
||||
return;
|
||||
|
||||
_glthread_LOCK_MUTEX(bufmgr_fake->mutex);
|
||||
if (--fence_fake->refcount == 0) {
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
|
||||
free(fence);
|
||||
return;
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
dri_fake_fence_wait(dri_fence *fence)
|
||||
{
|
||||
dri_fence_fake *fence_fake = (dri_fence_fake *)fence;
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)fence->bufmgr;
|
||||
|
||||
DBG("drm_fence_wait: 0x%08x cookie\n", fence_fake->fence_cookie);
|
||||
|
||||
_glthread_LOCK_MUTEX(bufmgr_fake->mutex);
|
||||
_fence_wait_internal(bufmgr_fake, fence_fake->fence_cookie);
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
dri_fake_destroy(dri_bufmgr *bufmgr)
|
||||
{
|
||||
dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bufmgr;
|
||||
|
||||
_glthread_DESTROY_MUTEX(bufmgr_fake->mutex);
|
||||
mmDestroy(bufmgr_fake->heap);
|
||||
free(bufmgr);
|
||||
}
|
||||
|
||||
dri_bufmgr *
|
||||
dri_bufmgr_fake_init(unsigned long low_offset, void *low_virtual,
|
||||
unsigned long size,
|
||||
unsigned int (*fence_emit)(void *private),
|
||||
int (*fence_wait)(void *private, unsigned int cookie),
|
||||
void *driver_priv)
|
||||
{
|
||||
dri_bufmgr_fake *bufmgr_fake;
|
||||
|
||||
bufmgr_fake = calloc(1, sizeof(*bufmgr_fake));
|
||||
|
||||
/* Initialize allocator */
|
||||
make_empty_list(&bufmgr_fake->fenced);
|
||||
make_empty_list(&bufmgr_fake->on_hardware);
|
||||
make_empty_list(&bufmgr_fake->lru);
|
||||
|
||||
bufmgr_fake->low_offset = low_offset;
|
||||
bufmgr_fake->virtual = low_virtual;
|
||||
bufmgr_fake->size = size;
|
||||
bufmgr_fake->heap = mmInit(low_offset, size);
|
||||
|
||||
_glthread_INIT_MUTEX(bufmgr_fake->mutex);
|
||||
|
||||
/* Hook in methods */
|
||||
bufmgr_fake->bufmgr.bo_alloc = dri_fake_bo_alloc;
|
||||
bufmgr_fake->bufmgr.bo_alloc_static = dri_fake_bo_alloc_static;
|
||||
bufmgr_fake->bufmgr.bo_reference = dri_fake_bo_reference;
|
||||
bufmgr_fake->bufmgr.bo_unreference = dri_fake_bo_unreference;
|
||||
bufmgr_fake->bufmgr.bo_map = dri_fake_bo_map;
|
||||
bufmgr_fake->bufmgr.bo_unmap = dri_fake_bo_unmap;
|
||||
bufmgr_fake->bufmgr.bo_validate = dri_fake_bo_validate;
|
||||
bufmgr_fake->bufmgr.fence_validated = dri_fake_fence_validated;
|
||||
bufmgr_fake->bufmgr.fence_wait = dri_fake_fence_wait;
|
||||
bufmgr_fake->bufmgr.fence_reference = dri_fake_fence_reference;
|
||||
bufmgr_fake->bufmgr.fence_unreference = dri_fake_fence_unreference;
|
||||
bufmgr_fake->bufmgr.destroy = dri_fake_destroy;
|
||||
|
||||
bufmgr_fake->fence_emit = fence_emit;
|
||||
bufmgr_fake->fence_wait = fence_wait;
|
||||
bufmgr_fake->driver_priv = driver_priv;
|
||||
|
||||
return &bufmgr_fake->bufmgr;
|
||||
}
|
||||
@@ -0,0 +1,469 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright © 2007 Intel Corporation
|
||||
* Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
*
|
||||
**************************************************************************/
|
||||
/*
|
||||
* Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
|
||||
* Keith Whitwell <keithw-at-tungstengraphics-dot-com>
|
||||
* Eric Anholt <eric@anholt.net>
|
||||
*/
|
||||
|
||||
#include <xf86drm.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "glthread.h"
|
||||
#include "errno.h"
|
||||
#include "mtypes.h"
|
||||
#include "dri_bufmgr.h"
|
||||
#include "string.h"
|
||||
#include "imports.h"
|
||||
|
||||
#define BUFMGR_DEBUG 0
|
||||
|
||||
typedef struct _dri_bufmgr_ttm {
|
||||
dri_bufmgr bufmgr;
|
||||
|
||||
int fd;
|
||||
_glthread_Mutex mutex;
|
||||
unsigned int fence_type;
|
||||
unsigned int fence_type_flush;
|
||||
} dri_bufmgr_ttm;
|
||||
|
||||
typedef struct _dri_bo_ttm {
|
||||
dri_bo bo;
|
||||
|
||||
int refcount; /* Protected by bufmgr->mutex */
|
||||
drmBO drm_bo;
|
||||
const char *name;
|
||||
/**
|
||||
* Note whether we are the owner of the buffer, to determine if we must
|
||||
* drmBODestroy or drmBOUnreference to unreference the buffer.
|
||||
*/
|
||||
GLboolean owner;
|
||||
} dri_bo_ttm;
|
||||
|
||||
typedef struct _dri_fence_ttm
|
||||
{
|
||||
dri_fence fence;
|
||||
|
||||
int refcount; /* Protected by bufmgr->mutex */
|
||||
const char *name;
|
||||
drmFence drm_fence;
|
||||
} dri_fence_ttm;
|
||||
|
||||
#if 0
|
||||
int
|
||||
driFenceSignaled(DriFenceObject * fence, unsigned type)
|
||||
{
|
||||
int signaled;
|
||||
int ret;
|
||||
|
||||
if (fence == NULL)
|
||||
return GL_TRUE;
|
||||
|
||||
_glthread_LOCK_MUTEX(fence->mutex);
|
||||
ret = drmFenceSignaled(bufmgr_ttm->fd, &fence->fence, type, &signaled);
|
||||
_glthread_UNLOCK_MUTEX(fence->mutex);
|
||||
BM_CKFATAL(ret);
|
||||
return signaled;
|
||||
}
|
||||
#endif
|
||||
|
||||
static dri_bo *
|
||||
dri_ttm_alloc(dri_bufmgr *bufmgr, const char *name,
|
||||
unsigned long size, unsigned int alignment,
|
||||
unsigned int location_mask)
|
||||
{
|
||||
dri_bufmgr_ttm *ttm_bufmgr;
|
||||
dri_bo_ttm *ttm_buf;
|
||||
unsigned int pageSize = getpagesize();
|
||||
int ret;
|
||||
unsigned int flags, hint;
|
||||
|
||||
ttm_bufmgr = (dri_bufmgr_ttm *)bufmgr;
|
||||
|
||||
ttm_buf = malloc(sizeof(*ttm_buf));
|
||||
if (!ttm_buf)
|
||||
return NULL;
|
||||
|
||||
/* The mask argument doesn't do anything for us that we want other than
|
||||
* determine which pool (TTM or local) the buffer is allocated into, so just
|
||||
* pass all of the allocation class flags.
|
||||
*/
|
||||
flags = location_mask | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE |
|
||||
DRM_BO_FLAG_EXE;
|
||||
/* No hints we want to use. */
|
||||
hint = 0;
|
||||
|
||||
ret = drmBOCreate(ttm_bufmgr->fd, 0, size, alignment / pageSize,
|
||||
NULL, drm_bo_type_dc,
|
||||
flags, hint, &ttm_buf->drm_bo);
|
||||
if (ret != 0) {
|
||||
free(ttm_buf);
|
||||
return NULL;
|
||||
}
|
||||
ttm_buf->bo.size = ttm_buf->drm_bo.size;
|
||||
ttm_buf->bo.offset = ttm_buf->drm_bo.offset;
|
||||
ttm_buf->bo.virtual = NULL;
|
||||
ttm_buf->bo.bufmgr = bufmgr;
|
||||
ttm_buf->name = name;
|
||||
ttm_buf->refcount = 1;
|
||||
ttm_buf->owner = GL_TRUE;
|
||||
|
||||
#if BUFMGR_DEBUG
|
||||
fprintf(stderr, "bo_create: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
|
||||
#endif
|
||||
|
||||
return &ttm_buf->bo;
|
||||
}
|
||||
|
||||
/* Our TTM backend doesn't allow creation of static buffers, as that requires
|
||||
* privelege for the non-fake case, and the lock in the fake case where we were
|
||||
* working around the X Server not creating buffers and passing handles to us.
|
||||
*/
|
||||
static dri_bo *
|
||||
dri_ttm_alloc_static(dri_bufmgr *bufmgr, const char *name,
|
||||
unsigned long offset, unsigned long size, void *virtual,
|
||||
unsigned int location_mask)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Returns a dri_bo wrapping the given buffer object handle.
|
||||
*
|
||||
* This can be used when one application needs to pass a buffer object
|
||||
* to another.
|
||||
*/
|
||||
dri_bo *
|
||||
dri_ttm_bo_create_from_handle(dri_bufmgr *bufmgr, const char *name,
|
||||
unsigned int handle)
|
||||
{
|
||||
dri_bufmgr_ttm *ttm_bufmgr;
|
||||
dri_bo_ttm *ttm_buf;
|
||||
int ret;
|
||||
|
||||
ttm_bufmgr = (dri_bufmgr_ttm *)bufmgr;
|
||||
|
||||
ttm_buf = malloc(sizeof(*ttm_buf));
|
||||
if (!ttm_buf)
|
||||
return NULL;
|
||||
|
||||
ret = drmBOReference(ttm_bufmgr->fd, handle, &ttm_buf->drm_bo);
|
||||
if (ret != 0) {
|
||||
free(ttm_buf);
|
||||
return NULL;
|
||||
}
|
||||
ttm_buf->bo.size = ttm_buf->drm_bo.size;
|
||||
ttm_buf->bo.offset = ttm_buf->drm_bo.offset;
|
||||
ttm_buf->bo.virtual = NULL;
|
||||
ttm_buf->bo.bufmgr = bufmgr;
|
||||
ttm_buf->name = name;
|
||||
ttm_buf->refcount = 1;
|
||||
ttm_buf->owner = GL_FALSE;
|
||||
|
||||
#if BUFMGR_DEBUG
|
||||
fprintf(stderr, "bo_create_from_handle: %p (%s)\n", &ttm_buf->bo,
|
||||
ttm_buf->name);
|
||||
#endif
|
||||
|
||||
return &ttm_buf->bo;
|
||||
}
|
||||
|
||||
static void
|
||||
dri_ttm_bo_reference(dri_bo *buf)
|
||||
{
|
||||
dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)buf->bufmgr;
|
||||
dri_bo_ttm *ttm_buf = (dri_bo_ttm *)buf;
|
||||
|
||||
_glthread_LOCK_MUTEX(bufmgr_ttm->mutex);
|
||||
ttm_buf->refcount++;
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_ttm->mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
dri_ttm_bo_unreference(dri_bo *buf)
|
||||
{
|
||||
dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)buf->bufmgr;
|
||||
dri_bo_ttm *ttm_buf = (dri_bo_ttm *)buf;
|
||||
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
_glthread_LOCK_MUTEX(bufmgr_ttm->mutex);
|
||||
if (--ttm_buf->refcount == 0) {
|
||||
int ret;
|
||||
|
||||
/* XXX Having to use drmBODestroy as the opposite of drmBOCreate instead
|
||||
* of simply unreferencing is madness, and leads to behaviors we may not
|
||||
* want (making the buffer unsharable).
|
||||
*/
|
||||
if (ttm_buf->owner)
|
||||
ret = drmBODestroy(bufmgr_ttm->fd, &ttm_buf->drm_bo);
|
||||
else
|
||||
ret = drmBOUnReference(bufmgr_ttm->fd, &ttm_buf->drm_bo);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "drmBOUnReference failed (%s): %s\n", ttm_buf->name,
|
||||
strerror(-ret));
|
||||
}
|
||||
#if BUFMGR_DEBUG
|
||||
fprintf(stderr, "bo_unreference final: %p (%s)\n",
|
||||
&ttm_buf->bo, ttm_buf->name);
|
||||
#endif
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_ttm->mutex);
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_ttm->mutex);
|
||||
}
|
||||
|
||||
static int
|
||||
dri_ttm_bo_map(dri_bo *buf, GLboolean write_enable)
|
||||
{
|
||||
dri_bufmgr_ttm *bufmgr_ttm;
|
||||
dri_bo_ttm *ttm_buf = (dri_bo_ttm *)buf;
|
||||
unsigned int flags;
|
||||
|
||||
bufmgr_ttm = (dri_bufmgr_ttm *)buf->bufmgr;
|
||||
|
||||
flags = DRM_BO_FLAG_READ;
|
||||
if (write_enable)
|
||||
flags |= DRM_BO_FLAG_WRITE;
|
||||
|
||||
assert(buf->virtual == NULL);
|
||||
|
||||
#if BUFMGR_DEBUG
|
||||
fprintf(stderr, "bo_map: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
|
||||
#endif
|
||||
|
||||
return drmBOMap(bufmgr_ttm->fd, &ttm_buf->drm_bo, flags, 0, &buf->virtual);
|
||||
}
|
||||
|
||||
static int
|
||||
dri_ttm_bo_unmap(dri_bo *buf)
|
||||
{
|
||||
dri_bufmgr_ttm *bufmgr_ttm;
|
||||
dri_bo_ttm *ttm_buf = (dri_bo_ttm *)buf;
|
||||
|
||||
if (buf == NULL)
|
||||
return 0;
|
||||
|
||||
bufmgr_ttm = (dri_bufmgr_ttm *)buf->bufmgr;
|
||||
|
||||
assert(buf->virtual != NULL);
|
||||
|
||||
buf->virtual = NULL;
|
||||
|
||||
#if BUFMGR_DEBUG
|
||||
fprintf(stderr, "bo_unmap: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
|
||||
#endif
|
||||
|
||||
return drmBOUnmap(bufmgr_ttm->fd, &ttm_buf->drm_bo);
|
||||
}
|
||||
|
||||
static int
|
||||
dri_ttm_validate(dri_bo *buf, unsigned int flags)
|
||||
{
|
||||
dri_bufmgr_ttm *bufmgr_ttm;
|
||||
dri_bo_ttm *ttm_buf = (dri_bo_ttm *)buf;
|
||||
unsigned int mask;
|
||||
int err;
|
||||
|
||||
/* XXX: Sanity-check whether we've already validated this one under
|
||||
* different flags. See drmAddValidateItem().
|
||||
*/
|
||||
|
||||
bufmgr_ttm = (dri_bufmgr_ttm *)buf->bufmgr;
|
||||
|
||||
/* Calculate the appropriate mask to pass to the DRM. There appears to be
|
||||
* be a direct relationship to flags, so it's unnecessary to have it passed
|
||||
* in as an argument.
|
||||
*/
|
||||
mask = DRM_BO_MASK_MEM;
|
||||
mask |= flags & (DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_EXE);
|
||||
|
||||
err = drmBOValidate(bufmgr_ttm->fd, &ttm_buf->drm_bo, 0, flags, mask, 0);
|
||||
|
||||
if (err == 0) {
|
||||
/* XXX: add to fence list for sanity checking */
|
||||
} else {
|
||||
fprintf(stderr, "failed to validate buffer (%s): %s\n",
|
||||
ttm_buf->name, strerror(-err));
|
||||
}
|
||||
|
||||
buf->offset = ttm_buf->drm_bo.offset;
|
||||
|
||||
#if BUFMGR_DEBUG
|
||||
fprintf(stderr, "bo_validate: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
|
||||
#endif
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static dri_fence *
|
||||
dri_ttm_fence_validated(dri_bufmgr *bufmgr, const char *name,
|
||||
GLboolean flushed)
|
||||
{
|
||||
dri_fence_ttm *fence_ttm = malloc(sizeof(*fence_ttm));
|
||||
dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)bufmgr;
|
||||
int ret;
|
||||
unsigned int type;
|
||||
|
||||
if (!fence_ttm)
|
||||
return NULL;
|
||||
|
||||
if (flushed)
|
||||
type = bufmgr_ttm->fence_type_flush;
|
||||
else
|
||||
type = bufmgr_ttm->fence_type;
|
||||
|
||||
fence_ttm->refcount = 1;
|
||||
fence_ttm->name = name;
|
||||
fence_ttm->fence.bufmgr = bufmgr;
|
||||
ret = drmFenceBuffers(bufmgr_ttm->fd, type, 0, &fence_ttm->drm_fence);
|
||||
if (ret) {
|
||||
fprintf(stderr, "failed to fence (%s): %s\n", name, strerror(-ret));
|
||||
free(fence_ttm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if BUFMGR_DEBUG
|
||||
fprintf(stderr, "fence_validated: %p (%s)\n", &fence_ttm->fence,
|
||||
fence_ttm->name);
|
||||
#endif
|
||||
|
||||
return &fence_ttm->fence;
|
||||
}
|
||||
|
||||
static void
|
||||
dri_ttm_fence_reference(dri_fence *fence)
|
||||
{
|
||||
dri_fence_ttm *fence_ttm = (dri_fence_ttm *)fence;
|
||||
dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)fence->bufmgr;
|
||||
|
||||
_glthread_LOCK_MUTEX(bufmgr_ttm->mutex);
|
||||
++fence_ttm->refcount;
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_ttm->mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
dri_ttm_fence_unreference(dri_fence *fence)
|
||||
{
|
||||
dri_fence_ttm *fence_ttm = (dri_fence_ttm *)fence;
|
||||
dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)fence->bufmgr;
|
||||
|
||||
if (!fence)
|
||||
return;
|
||||
|
||||
_glthread_LOCK_MUTEX(bufmgr_ttm->mutex);
|
||||
if (--fence_ttm->refcount == 0) {
|
||||
int ret;
|
||||
|
||||
/* XXX Having to use drmFenceDestroy as the opposite of drmFenceBuffers
|
||||
* instead of simply unreferencing is madness, and leads to behaviors we
|
||||
* may not want (making the fence unsharable). This behavior by the DRM
|
||||
* ioctls should be fixed, and drmFenceDestroy eliminated.
|
||||
*/
|
||||
ret = drmFenceDestroy(bufmgr_ttm->fd, &fence_ttm->drm_fence);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "drmFenceDestroy failed (%s): %s\n",
|
||||
fence_ttm->name, strerror(-ret));
|
||||
}
|
||||
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_ttm->mutex);
|
||||
free(fence);
|
||||
return;
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_ttm->mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
dri_ttm_fence_wait(dri_fence *fence)
|
||||
{
|
||||
dri_fence_ttm *fence_ttm = (dri_fence_ttm *)fence;
|
||||
dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)fence->bufmgr;
|
||||
int ret;
|
||||
|
||||
_glthread_LOCK_MUTEX(bufmgr_ttm->mutex);
|
||||
ret = drmFenceWait(bufmgr_ttm->fd, 0, &fence_ttm->drm_fence, 0);
|
||||
_glthread_UNLOCK_MUTEX(bufmgr_ttm->mutex);
|
||||
if (ret != 0) {
|
||||
_mesa_printf("%s:%d: Error %d waiting for fence %s.\n",
|
||||
__FILE__, __LINE__, ret, fence_ttm->name);
|
||||
abort();
|
||||
}
|
||||
|
||||
#if BUFMGR_DEBUG
|
||||
fprintf(stderr, "fence_wait: %p (%s)\n", &fence_ttm->fence,
|
||||
fence_ttm->name);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
dri_bufmgr_ttm_destroy(dri_bufmgr *bufmgr)
|
||||
{
|
||||
dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)bufmgr;
|
||||
|
||||
_glthread_DESTROY_MUTEX(bufmgr_ttm->mutex);
|
||||
free(bufmgr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the TTM buffer manager, which uses the kernel to allocate, map,
|
||||
* and manage map buffer objections.
|
||||
*
|
||||
* \param fd File descriptor of the opened DRM device.
|
||||
* \param fence_type Driver-specific fence type used for fences with no flush.
|
||||
* \param fence_type_flush Driver-specific fence type used for fences with a
|
||||
* flush.
|
||||
*/
|
||||
dri_bufmgr *
|
||||
dri_bufmgr_ttm_init(int fd, unsigned int fence_type,
|
||||
unsigned int fence_type_flush)
|
||||
{
|
||||
dri_bufmgr_ttm *bufmgr_ttm;
|
||||
|
||||
bufmgr_ttm = malloc(sizeof(*bufmgr_ttm));
|
||||
bufmgr_ttm->fd = fd;
|
||||
bufmgr_ttm->fence_type = fence_type;
|
||||
bufmgr_ttm->fence_type_flush = fence_type_flush;
|
||||
_glthread_INIT_MUTEX(bufmgr_ttm->mutex);
|
||||
|
||||
bufmgr_ttm->bufmgr.bo_alloc = dri_ttm_alloc;
|
||||
bufmgr_ttm->bufmgr.bo_alloc_static = dri_ttm_alloc_static;
|
||||
bufmgr_ttm->bufmgr.bo_reference = dri_ttm_bo_reference;
|
||||
bufmgr_ttm->bufmgr.bo_unreference = dri_ttm_bo_unreference;
|
||||
bufmgr_ttm->bufmgr.bo_map = dri_ttm_bo_map;
|
||||
bufmgr_ttm->bufmgr.bo_unmap = dri_ttm_bo_unmap;
|
||||
bufmgr_ttm->bufmgr.bo_validate = dri_ttm_validate;
|
||||
bufmgr_ttm->bufmgr.fence_validated = dri_ttm_fence_validated;
|
||||
bufmgr_ttm->bufmgr.fence_reference = dri_ttm_fence_reference;
|
||||
bufmgr_ttm->bufmgr.fence_unreference = dri_ttm_fence_unreference;
|
||||
bufmgr_ttm->bufmgr.fence_wait = dri_ttm_fence_wait;
|
||||
bufmgr_ttm->bufmgr.destroy = dri_bufmgr_ttm_destroy;
|
||||
|
||||
return &bufmgr_ttm->bufmgr;
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
*
|
||||
**************************************************************************/
|
||||
/*
|
||||
* Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
|
||||
*/
|
||||
|
||||
#ifndef _DRI_BUFPOOL_H_
|
||||
#define _DRI_BUFPOOL_H_
|
||||
|
||||
#include <xf86drm.h>
|
||||
struct _DriFenceObject;
|
||||
|
||||
typedef struct _DriBufferPool
|
||||
{
|
||||
int fd;
|
||||
int (*map) (struct _DriBufferPool * pool, void *private,
|
||||
unsigned flags, int hint, void **virtual);
|
||||
int (*unmap) (struct _DriBufferPool * pool, void *private);
|
||||
int (*destroy) (struct _DriBufferPool * pool, void *private);
|
||||
unsigned long (*offset) (struct _DriBufferPool * pool, void *private);
|
||||
unsigned (*flags) (struct _DriBufferPool * pool, void *private);
|
||||
unsigned long (*size) (struct _DriBufferPool * pool, void *private);
|
||||
void *(*create) (struct _DriBufferPool * pool, unsigned long size,
|
||||
unsigned flags, unsigned hint, unsigned alignment);
|
||||
int (*fence) (struct _DriBufferPool * pool, void *private,
|
||||
struct _DriFenceObject * fence);
|
||||
drmBO *(*kernel) (struct _DriBufferPool * pool, void *private);
|
||||
int (*validate) (struct _DriBufferPool * pool, void *private);
|
||||
void *(*setstatic) (struct _DriBufferPool * pool, unsigned long offset,
|
||||
unsigned long size, void *virtual, unsigned flags);
|
||||
int (*waitIdle) (struct _DriBufferPool *pool, void *private,
|
||||
int lazy);
|
||||
void (*takeDown) (struct _DriBufferPool * pool);
|
||||
void *data;
|
||||
} DriBufferPool;
|
||||
|
||||
extern void bmError(int val, const char *file, const char *function,
|
||||
int line);
|
||||
#define BM_CKFATAL(val) \
|
||||
do{ \
|
||||
int tstVal = (val); \
|
||||
if (tstVal) \
|
||||
bmError(tstVal, __FILE__, __FUNCTION__, __LINE__); \
|
||||
} while(0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Builtin pools.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Kernel buffer objects. Size in multiples of page size. Page size aligned.
|
||||
*/
|
||||
|
||||
extern struct _DriBufferPool *driDRMPoolInit(int fd);
|
||||
extern struct _DriBufferPool *driDRMStaticPoolInit(int fd);
|
||||
|
||||
#endif
|
||||
@@ -1,227 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
*
|
||||
**************************************************************************/
|
||||
/*
|
||||
* Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
|
||||
*/
|
||||
|
||||
#include <xf86drm.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "dri_bufpool.h"
|
||||
|
||||
/*
|
||||
* Buffer pool implementation using DRM buffer objects as DRI buffer objects.
|
||||
*/
|
||||
|
||||
static void *
|
||||
pool_create(struct _DriBufferPool *pool,
|
||||
unsigned long size, unsigned flags, unsigned hint,
|
||||
unsigned alignment)
|
||||
{
|
||||
drmBO *buf = (drmBO *) malloc(sizeof(*buf));
|
||||
int ret;
|
||||
unsigned pageSize = getpagesize();
|
||||
|
||||
if (!buf)
|
||||
return NULL;
|
||||
|
||||
if ((alignment > pageSize) && (alignment % pageSize)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = drmBOCreate(pool->fd, 0, size, alignment / pageSize,
|
||||
NULL, drm_bo_type_dc,
|
||||
flags, hint, buf);
|
||||
if (ret) {
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (void *) buf;
|
||||
}
|
||||
|
||||
static int
|
||||
pool_destroy(struct _DriBufferPool *pool, void *private)
|
||||
{
|
||||
int ret;
|
||||
drmBO *buf = (drmBO *) private;
|
||||
ret = drmBODestroy(pool->fd, buf);
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
|
||||
int hint, void **virtual)
|
||||
{
|
||||
drmBO *buf = (drmBO *) private;
|
||||
|
||||
return drmBOMap(pool->fd, buf, flags, hint, virtual);
|
||||
}
|
||||
|
||||
static int
|
||||
pool_unmap(struct _DriBufferPool *pool, void *private)
|
||||
{
|
||||
drmBO *buf = (drmBO *) private;
|
||||
return drmBOUnmap(pool->fd, buf);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
pool_offset(struct _DriBufferPool *pool, void *private)
|
||||
{
|
||||
drmBO *buf = (drmBO *) private;
|
||||
return buf->offset;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
pool_flags(struct _DriBufferPool *pool, void *private)
|
||||
{
|
||||
drmBO *buf = (drmBO *) private;
|
||||
return buf->flags;
|
||||
}
|
||||
|
||||
|
||||
static unsigned long
|
||||
pool_size(struct _DriBufferPool *pool, void *private)
|
||||
{
|
||||
drmBO *buf = (drmBO *) private;
|
||||
return buf->size;
|
||||
}
|
||||
|
||||
static int
|
||||
pool_fence(struct _DriBufferPool *pool, void *private,
|
||||
struct _DriFenceObject *fence)
|
||||
{
|
||||
/*
|
||||
* Noop. The kernel handles all fencing.
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static drmBO *
|
||||
pool_kernel(struct _DriBufferPool *pool, void *private)
|
||||
{
|
||||
return (drmBO *) private;
|
||||
}
|
||||
|
||||
static int
|
||||
pool_waitIdle(struct _DriBufferPool *pool, void *private, int lazy)
|
||||
{
|
||||
drmBO *buf = (drmBO *) private;
|
||||
return drmBOWaitIdle(pool->fd, buf, (lazy) ? DRM_BO_HINT_WAIT_LAZY:0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
pool_takedown(struct _DriBufferPool *pool)
|
||||
{
|
||||
free(pool);
|
||||
}
|
||||
|
||||
|
||||
struct _DriBufferPool *
|
||||
driDRMPoolInit(int fd)
|
||||
{
|
||||
struct _DriBufferPool *pool;
|
||||
|
||||
pool = (struct _DriBufferPool *) malloc(sizeof(*pool));
|
||||
|
||||
if (!pool)
|
||||
return NULL;
|
||||
|
||||
pool->fd = fd;
|
||||
pool->map = &pool_map;
|
||||
pool->unmap = &pool_unmap;
|
||||
pool->destroy = &pool_destroy;
|
||||
pool->offset = &pool_offset;
|
||||
pool->flags = &pool_flags;
|
||||
pool->size = &pool_size;
|
||||
pool->create = &pool_create;
|
||||
pool->fence = &pool_fence;
|
||||
pool->kernel = &pool_kernel;
|
||||
pool->validate = NULL;
|
||||
pool->setstatic = NULL;
|
||||
pool->waitIdle = &pool_waitIdle;
|
||||
pool->takeDown = &pool_takedown;
|
||||
pool->data = NULL;
|
||||
return pool;
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
pool_setstatic(struct _DriBufferPool *pool, unsigned long offset,
|
||||
unsigned long size, void *virtual, unsigned flags)
|
||||
{
|
||||
drmBO *buf = (drmBO *) malloc(sizeof(*buf));
|
||||
int ret;
|
||||
|
||||
if (!buf)
|
||||
return NULL;
|
||||
|
||||
ret = drmBOCreate(pool->fd, offset, size, 0, NULL, drm_bo_type_fake,
|
||||
flags, DRM_BO_HINT_DONT_FENCE, buf);
|
||||
|
||||
if (ret) {
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buf->virtual = virtual;
|
||||
|
||||
return (void *) buf;
|
||||
}
|
||||
|
||||
|
||||
struct _DriBufferPool *
|
||||
driDRMStaticPoolInit(int fd)
|
||||
{
|
||||
struct _DriBufferPool *pool;
|
||||
|
||||
pool = (struct _DriBufferPool *) malloc(sizeof(*pool));
|
||||
|
||||
if (!pool)
|
||||
return NULL;
|
||||
|
||||
pool->fd = fd;
|
||||
pool->map = &pool_map;
|
||||
pool->unmap = &pool_unmap;
|
||||
pool->destroy = &pool_destroy;
|
||||
pool->offset = &pool_offset;
|
||||
pool->flags = &pool_flags;
|
||||
pool->size = &pool_size;
|
||||
pool->create = NULL;
|
||||
pool->fence = &pool_fence;
|
||||
pool->kernel = &pool_kernel;
|
||||
pool->validate = NULL;
|
||||
pool->setstatic = &pool_setstatic;
|
||||
pool->waitIdle = &pool_waitIdle;
|
||||
pool->takeDown = &pool_takedown;
|
||||
pool->data = NULL;
|
||||
return pool;
|
||||
}
|
||||
@@ -114,7 +114,7 @@
|
||||
do { \
|
||||
GLuint p = *(volatile GLuint *) GET_PTR(_x, _y); \
|
||||
__asm__ __volatile__( "bswap %0; rorl $8, %0" \
|
||||
: "=r" (p) : "r" (p) ); \
|
||||
: "=r" (p) : "0" (p) ); \
|
||||
((GLuint *)rgba)[0] = p; \
|
||||
} while (0)
|
||||
# elif defined( MESA_BIG_ENDIAN )
|
||||
|
||||
@@ -61,7 +61,8 @@ default: depend $(TOP)/$(LIB_DIR)/$(LIBNAME)
|
||||
|
||||
|
||||
$(TOP)/$(LIB_DIR)/$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(WINOBJ) Makefile
|
||||
CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(LIBNAME) -noprefix -install $(TOP)/$(LIB_DIR) \
|
||||
CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(LIBNAME) -noprefix \
|
||||
-ldflags '$(LDFLAGS)' -install $(TOP)/$(LIB_DIR) \
|
||||
$(OBJECTS) $(WINLIB) $(LIB_DEPS) $(WINOBJ) $(MESA_MODULES)
|
||||
|
||||
|
||||
|
||||
@@ -288,8 +288,8 @@ i810InitDriver(__DRIscreenPrivate *sPriv)
|
||||
i810Screen->depth.handle,
|
||||
i810Screen->depth.size,
|
||||
(drmAddress *)&i810Screen->depth.map) != 0) {
|
||||
FREE(i810Screen);
|
||||
drmUnmap(i810Screen->back.map, i810Screen->back.size);
|
||||
FREE(i810Screen);
|
||||
sPriv->private = NULL;
|
||||
__driUtilMessage("i810InitDriver: drmMap (2) failed");
|
||||
return GL_FALSE;
|
||||
|
||||
@@ -7,16 +7,6 @@ LIBNAME = i915_dri.so
|
||||
MINIGLX_SOURCES = server/intel_dri.c
|
||||
|
||||
DRIVER_SOURCES = \
|
||||
i915_context.c \
|
||||
i915_debug.c \
|
||||
i915_fragprog.c \
|
||||
i915_metaops.c \
|
||||
i915_program.c \
|
||||
i915_state.c \
|
||||
i915_tex.c \
|
||||
i915_texprog.c \
|
||||
i915_texstate.c \
|
||||
i915_vtbl.c \
|
||||
i830_context.c \
|
||||
i830_metaops.c \
|
||||
i830_state.c \
|
||||
@@ -24,27 +14,59 @@ DRIVER_SOURCES = \
|
||||
i830_tex.c \
|
||||
i830_texstate.c \
|
||||
i830_vtbl.c \
|
||||
intel_batchbuffer.c \
|
||||
intel_context.c \
|
||||
intel_ioctl.c \
|
||||
intel_pixel.c \
|
||||
intel_render.c \
|
||||
intel_regions.c \
|
||||
intel_buffer_objects.c \
|
||||
intel_batchbuffer.c \
|
||||
intel_mipmap_tree.c \
|
||||
i915_tex_layout.c \
|
||||
intel_tex_layout.c \
|
||||
intel_tex_image.c \
|
||||
intel_tex_subimage.c \
|
||||
intel_tex_copy.c \
|
||||
intel_tex_validate.c \
|
||||
intel_tex_format.c \
|
||||
intel_tex.c \
|
||||
intel_pixel.c \
|
||||
intel_pixel_copy.c \
|
||||
intel_pixel_read.c \
|
||||
intel_pixel_draw.c \
|
||||
intel_buffers.c \
|
||||
intel_blit.c \
|
||||
i915_tex.c \
|
||||
i915_texstate.c \
|
||||
i915_context.c \
|
||||
i915_debug.c \
|
||||
i915_debug_fp.c \
|
||||
i915_fragprog.c \
|
||||
i915_metaops.c \
|
||||
i915_program.c \
|
||||
i915_state.c \
|
||||
i915_vtbl.c \
|
||||
intel_context.c \
|
||||
intel_decode.c \
|
||||
intel_ioctl.c \
|
||||
intel_rotate.c \
|
||||
intel_screen.c \
|
||||
intel_span.c \
|
||||
intel_state.c \
|
||||
intel_tex.c \
|
||||
intel_texmem.c \
|
||||
intel_tris.c
|
||||
intel_tris.c \
|
||||
intel_fbo.c \
|
||||
intel_depthstencil.c
|
||||
|
||||
C_SOURCES = \
|
||||
$(COMMON_SOURCES) \
|
||||
$(COMMON_BM_SOURCES) \
|
||||
$(DRIVER_SOURCES)
|
||||
|
||||
ASM_SOURCES =
|
||||
|
||||
|
||||
DRIVER_DEFINES = -I../intel $(shell pkg-config libdrm --atleast-version=2.3.1 \
|
||||
&& echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
|
||||
|
||||
include ../Makefile.template
|
||||
|
||||
intel_decode.o: ../intel/intel_decode.c
|
||||
intel_tex_layout.o: ../intel/intel_tex_layout.c
|
||||
|
||||
symlinks:
|
||||
|
||||
@@ -38,37 +38,38 @@
|
||||
* Mesa's Driver Functions
|
||||
***************************************/
|
||||
|
||||
static const struct dri_extension i830_extensions[] =
|
||||
{
|
||||
{ "GL_ARB_texture_env_crossbar", NULL },
|
||||
{ NULL, NULL }
|
||||
static const struct dri_extension i830_extensions[] = {
|
||||
{"GL_ARB_texture_env_crossbar", NULL},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
static void i830InitDriverFunctions( struct dd_function_table *functions )
|
||||
static void
|
||||
i830InitDriverFunctions(struct dd_function_table *functions)
|
||||
{
|
||||
intelInitDriverFunctions( functions );
|
||||
i830InitStateFuncs( functions );
|
||||
i830InitTextureFuncs( functions );
|
||||
intelInitDriverFunctions(functions);
|
||||
i830InitStateFuncs(functions);
|
||||
i830InitTextureFuncs(functions);
|
||||
}
|
||||
|
||||
|
||||
GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
|
||||
__DRIcontextPrivate *driContextPriv,
|
||||
void *sharedContextPrivate)
|
||||
GLboolean
|
||||
i830CreateContext(const __GLcontextModes * mesaVis,
|
||||
__DRIcontextPrivate * driContextPriv,
|
||||
void *sharedContextPrivate)
|
||||
{
|
||||
struct dd_function_table functions;
|
||||
i830ContextPtr i830 = (i830ContextPtr) CALLOC_STRUCT(i830_context);
|
||||
intelContextPtr intel = &i830->intel;
|
||||
struct i830_context *i830 = CALLOC_STRUCT(i830_context);
|
||||
struct intel_context *intel = &i830->intel;
|
||||
GLcontext *ctx = &intel->ctx;
|
||||
GLuint i;
|
||||
if (!i830) return GL_FALSE;
|
||||
if (!i830)
|
||||
return GL_FALSE;
|
||||
|
||||
i830InitVtbl( i830 );
|
||||
i830InitDriverFunctions( &functions );
|
||||
i830InitVtbl(i830);
|
||||
i830InitDriverFunctions(&functions);
|
||||
|
||||
if (!intelInitContext( intel, mesaVis, driContextPriv,
|
||||
sharedContextPrivate, &functions )) {
|
||||
if (!intelInitContext(intel, mesaVis, driContextPriv,
|
||||
sharedContextPrivate, &functions)) {
|
||||
FREE(i830);
|
||||
return GL_FALSE;
|
||||
}
|
||||
@@ -77,48 +78,27 @@ GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
|
||||
intel->ctx.Const.MaxTextureImageUnits = I830_TEX_UNITS;
|
||||
intel->ctx.Const.MaxTextureCoordUnits = I830_TEX_UNITS;
|
||||
|
||||
intel->nr_heaps = 1;
|
||||
intel->texture_heaps[0] =
|
||||
driCreateTextureHeap( 0, intel,
|
||||
intel->intelScreen->tex.size,
|
||||
12,
|
||||
I830_NR_TEX_REGIONS,
|
||||
intel->sarea->texList,
|
||||
(unsigned *) & intel->sarea->texAge,
|
||||
& intel->swapped,
|
||||
sizeof( struct i830_texture_object ),
|
||||
(destroy_texture_object_t *)intelDestroyTexObj );
|
||||
|
||||
/* FIXME: driCalculateMaxTextureLevels assumes that mipmaps are tightly
|
||||
* FIXME: packed, but they're not in Intel graphics hardware.
|
||||
/* Advertise the full hardware capabilities. The new memory
|
||||
* manager should cope much better with overload situations:
|
||||
*/
|
||||
intel->ctx.Const.MaxTextureUnits = I830_TEX_UNITS;
|
||||
i = driQueryOptioni( &intel->optionCache, "allow_large_textures");
|
||||
driCalculateMaxTextureLevels( intel->texture_heaps,
|
||||
intel->nr_heaps,
|
||||
&intel->ctx.Const,
|
||||
4,
|
||||
11, /* max 2D texture size is 2048x2048 */
|
||||
8, /* max 3D texture size is 256^3 */
|
||||
10, /* max CUBE texture size is 1024x1024 */
|
||||
11, /* max RECT. supported */
|
||||
12,
|
||||
GL_FALSE,
|
||||
i );
|
||||
ctx->Const.MaxTextureLevels = 12;
|
||||
ctx->Const.Max3DTextureLevels = 9;
|
||||
ctx->Const.MaxCubeTextureLevels = 11;
|
||||
ctx->Const.MaxTextureRectSize = (1 << 11);
|
||||
ctx->Const.MaxTextureUnits = I830_TEX_UNITS;
|
||||
|
||||
_tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
|
||||
18 * sizeof(GLfloat) );
|
||||
_tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12,
|
||||
18 * sizeof(GLfloat));
|
||||
|
||||
intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf;
|
||||
|
||||
driInitExtensions( ctx, i830_extensions, GL_FALSE );
|
||||
driInitExtensions(ctx, i830_extensions, GL_FALSE);
|
||||
|
||||
i830InitState( i830 );
|
||||
i830InitState(i830);
|
||||
i830InitMetaFuncs(i830);
|
||||
|
||||
|
||||
_tnl_allow_vertex_fog( ctx, 1 );
|
||||
_tnl_allow_pixel_fog( ctx, 0 );
|
||||
_tnl_allow_vertex_fog(ctx, 1);
|
||||
_tnl_allow_pixel_fog(ctx, 0);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,17 +49,15 @@
|
||||
*/
|
||||
#define I830_DESTREG_CBUFADDR0 0
|
||||
#define I830_DESTREG_CBUFADDR1 1
|
||||
#define I830_DESTREG_CBUFADDR2 2
|
||||
#define I830_DESTREG_DBUFADDR0 3
|
||||
#define I830_DESTREG_DBUFADDR1 4
|
||||
#define I830_DESTREG_DBUFADDR2 5
|
||||
#define I830_DESTREG_DV0 6
|
||||
#define I830_DESTREG_DV1 7
|
||||
#define I830_DESTREG_SENABLE 8
|
||||
#define I830_DESTREG_SR0 9
|
||||
#define I830_DESTREG_SR1 10
|
||||
#define I830_DESTREG_SR2 11
|
||||
#define I830_DEST_SETUP_SIZE 12
|
||||
#define I830_DESTREG_DBUFADDR0 2
|
||||
#define I830_DESTREG_DBUFADDR1 3
|
||||
#define I830_DESTREG_DV0 4
|
||||
#define I830_DESTREG_DV1 5
|
||||
#define I830_DESTREG_SENABLE 6
|
||||
#define I830_DESTREG_SR0 7
|
||||
#define I830_DESTREG_SR1 8
|
||||
#define I830_DESTREG_SR2 9
|
||||
#define I830_DEST_SETUP_SIZE 10
|
||||
|
||||
#define I830_CTXREG_STATE1 0
|
||||
#define I830_CTXREG_STATE2 1
|
||||
@@ -73,7 +71,7 @@
|
||||
#define I830_CTXREG_AA 9
|
||||
#define I830_CTXREG_FOGCOLOR 10
|
||||
#define I830_CTXREG_BLENDCOLOR0 11
|
||||
#define I830_CTXREG_BLENDCOLOR1 12
|
||||
#define I830_CTXREG_BLENDCOLOR1 12
|
||||
#define I830_CTXREG_VF 13
|
||||
#define I830_CTXREG_VF2 14
|
||||
#define I830_CTXREG_MCSB0 15
|
||||
@@ -84,17 +82,16 @@
|
||||
#define I830_STPREG_ST1 1
|
||||
#define I830_STP_SETUP_SIZE 2
|
||||
|
||||
#define I830_TEXREG_TM0LI 0 /* load immediate 2 texture map n */
|
||||
#define I830_TEXREG_TM0S0 1
|
||||
#define I830_TEXREG_TM0S1 2
|
||||
#define I830_TEXREG_TM0S2 3
|
||||
#define I830_TEXREG_TM0S3 4
|
||||
#define I830_TEXREG_TM0S4 5
|
||||
#define I830_TEXREG_MCS 6 /* _3DSTATE_MAP_COORD_SETS */
|
||||
#define I830_TEXREG_CUBE 7 /* _3DSTATE_MAP_SUBE */
|
||||
#define I830_TEX_SETUP_SIZE 8
|
||||
#define I830_TEXREG_TM0LI 0 /* load immediate 2 texture map n */
|
||||
#define I830_TEXREG_TM0S1 1
|
||||
#define I830_TEXREG_TM0S2 2
|
||||
#define I830_TEXREG_TM0S3 3
|
||||
#define I830_TEXREG_TM0S4 4
|
||||
#define I830_TEXREG_MCS 5 /* _3DSTATE_MAP_COORD_SETS */
|
||||
#define I830_TEXREG_CUBE 6 /* _3DSTATE_MAP_SUBE */
|
||||
#define I830_TEX_SETUP_SIZE 7
|
||||
|
||||
#define I830_TEXBLEND_SIZE 12 /* (4 args + op) * 2 + COLOR_FACTOR */
|
||||
#define I830_TEXBLEND_SIZE 12 /* (4 args + op) * 2 + COLOR_FACTOR */
|
||||
|
||||
struct i830_texture_object
|
||||
{
|
||||
@@ -104,30 +101,39 @@ struct i830_texture_object
|
||||
|
||||
#define I830_TEX_UNITS 4
|
||||
|
||||
struct i830_hw_state {
|
||||
struct i830_hw_state
|
||||
{
|
||||
GLuint Ctx[I830_CTX_SETUP_SIZE];
|
||||
GLuint Buffer[I830_DEST_SETUP_SIZE];
|
||||
GLuint Stipple[I830_STP_SETUP_SIZE];
|
||||
GLuint Tex[I830_TEX_UNITS][I830_TEX_SETUP_SIZE];
|
||||
GLuint TexBlend[I830_TEX_UNITS][I830_TEXBLEND_SIZE];
|
||||
GLuint TexBlendWordsUsed[I830_TEX_UNITS];
|
||||
GLuint emitted; /* I810_UPLOAD_* */
|
||||
|
||||
struct intel_region *draw_region;
|
||||
struct intel_region *depth_region;
|
||||
|
||||
/* Regions aren't actually that appropriate here as the memory may
|
||||
* be from a PBO or FBO. Will have to do this for draw and depth for
|
||||
* FBO's...
|
||||
*/
|
||||
dri_bo *tex_buffer[I830_TEX_UNITS];
|
||||
GLuint tex_offset[I830_TEX_UNITS];
|
||||
|
||||
GLuint emitted; /* I810_UPLOAD_* */
|
||||
GLuint active;
|
||||
};
|
||||
|
||||
struct i830_context
|
||||
struct i830_context
|
||||
{
|
||||
struct intel_context intel;
|
||||
|
||||
DECLARE_RENDERINPUTS(last_index_bitset);
|
||||
|
||||
GLuint lodbias_tm0s3[MAX_TEXTURE_UNITS];
|
||||
DECLARE_RENDERINPUTS(last_index_bitset);
|
||||
|
||||
struct i830_hw_state meta, initial, state, *current;
|
||||
};
|
||||
|
||||
typedef struct i830_context *i830ContextPtr;
|
||||
typedef struct i830_texture_object *i830TextureObjectPtr;
|
||||
|
||||
#define I830_CONTEXT(ctx) ((i830ContextPtr)(ctx))
|
||||
|
||||
|
||||
|
||||
@@ -148,71 +154,60 @@ do { \
|
||||
|
||||
/* i830_vtbl.c
|
||||
*/
|
||||
extern void
|
||||
i830InitVtbl( i830ContextPtr i830 );
|
||||
extern void i830InitVtbl(struct i830_context *i830);
|
||||
|
||||
extern void
|
||||
i830_state_draw_region(struct intel_context *intel,
|
||||
struct i830_hw_state *state,
|
||||
struct intel_region *color_region,
|
||||
struct intel_region *depth_region);
|
||||
/* i830_context.c
|
||||
*/
|
||||
extern GLboolean
|
||||
i830CreateContext( const __GLcontextModes *mesaVis,
|
||||
__DRIcontextPrivate *driContextPriv,
|
||||
void *sharedContextPrivate);
|
||||
extern GLboolean
|
||||
i830CreateContext(const __GLcontextModes * mesaVis,
|
||||
__DRIcontextPrivate * driContextPriv,
|
||||
void *sharedContextPrivate);
|
||||
|
||||
/* i830_tex.c, i830_texstate.c
|
||||
*/
|
||||
extern void
|
||||
i830UpdateTextureState( intelContextPtr intel );
|
||||
extern void i830UpdateTextureState(struct intel_context *intel);
|
||||
|
||||
extern void
|
||||
i830InitTextureFuncs( struct dd_function_table *functions );
|
||||
|
||||
extern intelTextureObjectPtr
|
||||
i830AllocTexObj( struct gl_texture_object *tObj );
|
||||
extern void i830InitTextureFuncs(struct dd_function_table *functions);
|
||||
|
||||
/* i830_texblend.c
|
||||
*/
|
||||
extern GLuint i830SetTexEnvCombine(i830ContextPtr i830,
|
||||
const struct gl_tex_env_combine_state * combine, GLint blendUnit,
|
||||
GLuint texel_op, GLuint *state, const GLfloat *factor );
|
||||
extern GLuint i830SetTexEnvCombine(struct i830_context *i830,
|
||||
const struct gl_tex_env_combine_state
|
||||
*combine, GLint blendUnit, GLuint texel_op,
|
||||
GLuint * state, const GLfloat * factor);
|
||||
|
||||
extern void
|
||||
i830EmitTextureBlend( i830ContextPtr i830 );
|
||||
extern void i830EmitTextureBlend(struct i830_context *i830);
|
||||
|
||||
|
||||
/* i830_state.c
|
||||
*/
|
||||
extern void
|
||||
i830InitStateFuncs( struct dd_function_table *functions );
|
||||
extern void i830InitStateFuncs(struct dd_function_table *functions);
|
||||
|
||||
extern void
|
||||
i830EmitState( i830ContextPtr i830 );
|
||||
extern void i830EmitState(struct i830_context *i830);
|
||||
|
||||
extern void
|
||||
i830InitState( i830ContextPtr i830 );
|
||||
extern void i830InitState(struct i830_context *i830);
|
||||
|
||||
/* i830_metaops.c
|
||||
*/
|
||||
extern GLboolean
|
||||
i830TryTextureReadPixels( GLcontext *ctx,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
const struct gl_pixelstore_attrib *pack,
|
||||
GLvoid *pixels );
|
||||
|
||||
extern GLboolean
|
||||
i830TryTextureDrawPixels( GLcontext *ctx,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
const struct gl_pixelstore_attrib *unpack,
|
||||
const GLvoid *pixels );
|
||||
|
||||
extern void
|
||||
i830ClearWithTris( intelContextPtr intel, GLbitfield mask,
|
||||
GLboolean all, GLint cx, GLint cy, GLint cw, GLint ch);
|
||||
extern void i830InitMetaFuncs(struct i830_context *i830);
|
||||
|
||||
extern void
|
||||
i830RotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv,
|
||||
i830RotateWindow(struct intel_context *intel, __DRIdrawablePrivate * dPriv,
|
||||
GLuint srcBuf);
|
||||
|
||||
#endif
|
||||
/*======================================================================
|
||||
* Inline conversion functions. These are better-typed than the
|
||||
* macros used previously:
|
||||
*/
|
||||
static INLINE struct i830_context *
|
||||
i830_context(GLcontext * ctx)
|
||||
{
|
||||
return (struct i830_context *) ctx;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user