Compare commits

..

103 Commits

Author SHA1 Message Date
Julien Cristau
53d395336d Prepare changelog for upload 2009-12-29 10:42:29 +00:00
Julien Cristau
bc94d48259 Update patch stack
Drop hunk from 05_hurd-ftbfs.diff that was applied upstream.
Refresh other patches.
2009-12-29 10:40:05 +00:00
Julien Cristau
fabfd3eaca Bump linux-libc-dev build-dep to 2.6.31 for the r600 dri driver
fixes ftbfs on mips
2009-12-29 10:19:48 +00:00
Julien Cristau
089e2e656c Bump changelogs 2009-12-29 10:17:41 +00:00
Julien Cristau
7030b61d99 Merge branch 'mesa_7_6_branch' of git://anongit.freedesktop.org/mesa/mesa into debian-unstable
Conflicts:
	progs/tests/bug_texstore_i8.c
	progs/tests/crossbar.c
	progs/tests/cva.c
	progs/tests/fptest1.c
	progs/tests/invert.c
	progs/tests/packedpixels.c
	progs/tests/quads.c
	progs/tests/scissor-viewport.c
	progs/tests/scissor.c
	progs/tests/stencilwrap.c
	progs/tests/tex1d.c
	progs/tests/texcomp_image.h
	progs/tests/unfilledclip.c
	progs/tests/vpeval.c
	progs/trivial/clear-fbo-tex.c
	progs/trivial/createwin.c
	progs/trivial/dlist-begin-call-end.c
	progs/trivial/draw2arrays.c
	progs/trivial/drawarrays.c
	progs/trivial/tri-blend-max.c
	progs/trivial/tri-blend-min.c
	progs/trivial/tri-blend-revsub.c
	progs/trivial/tri-blend-sub.c
	progs/trivial/tri-blend.c
	progs/trivial/tri-fbo-tex.c
	progs/trivial/tri-fp.c
	progs/trivial/tri-logicop-none.c
	progs/trivial/tri-logicop-xor.c
	progs/trivial/tri-z.c
	progs/trivial/vbo-drawarrays.c
	progs/trivial/vbo-noninterleaved.c
	scons/gallium.py
	scons/generic.py
2009-12-29 10:16:21 +00:00
Brian Paul
da876fa3a5 docs: insert 7.6.1 release date 2009-12-27 15:14:25 -07:00
Vinson Lee
331e910b5c gallium/util: Remove comma at end of enumerator list. 2009-12-26 16:22:25 -08:00
Vinson Lee
3c2fd1bae0 rbug: Remove comma at end of enumerator list. 2009-12-26 16:18:47 -08:00
Vinson Lee
f8ca25e02f rbug: Remove comma at end of enumerator list. 2009-12-26 16:14:39 -08:00
Vinson Lee
fc11424bcd mesa: Remove comma at end of enumerator list. 2009-12-26 16:09:41 -08:00
Vinson Lee
309c156bae i915: Fix assert. 2009-12-26 15:55:38 -08:00
Vinson Lee
e81fe088f4 progs/demos: Silence warn_unused_result warnings. 2009-12-26 01:08:26 -08:00
Vinson Lee
cdc69e3469 progs/util: Silence warn_unused_result warnings. 2009-12-25 23:13:50 -08:00
Vinson Lee
cd59e6f553 intel: Silence implicit function declaration warning. 2009-12-25 22:34:35 -08:00
Vinson Lee
67a4abcc3b glu/sgi: Fix include recursion.
arcsorter.h should not include itself.
2009-12-25 14:23:10 -08:00
Vinson Lee
2447786ed0 i965: Fix assert. 2009-12-24 22:58:05 -08:00
Vinson Lee
f5ad1d0d02 i965: Add missing va_end. 2009-12-24 16:26:09 -08:00
Vinson Lee
098f10c270 glsl: Initialize member a_obj of struct slang_operation. 2009-12-23 18:00:06 -08:00
Vinson Lee
261c3cd530 glu/sgi: Initialize variable in directedLine. 2009-12-23 17:50:02 -08:00
Vinson Lee
520955a0cd gallium/util: Initialize variable in util_clear. 2009-12-23 16:22:03 -08:00
Vinson Lee
6138145b35 glu/sgi: Silence compiler warnings. 2009-12-23 16:11:10 -08:00
Vinson Lee
51dcea2aac util: Ensure debug_dump_flags generates a null-terminated string. 2009-12-23 15:19:45 -08:00
Vinson Lee
2ea061509d st/xorg: Use C-style comments. 2009-12-23 14:52:06 -08:00
Vinson Lee
15ecd0337e st/vega: Move declaration outside for loop. 2009-12-23 14:43:53 -08:00
Vinson Lee
1b0ab3e3c9 st/egl: Use C-style comments. 2009-12-23 14:18:11 -08:00
Vinson Lee
6c8c1ce78b glx: Add XF86DRI[Open|Close]FullScreen prototypes to xf86dri.h. 2009-12-23 14:09:36 -08:00
Vinson Lee
cf3bb0cf31 glx: Move declaration outside for loop. 2009-12-23 12:42:38 -08:00
Vinson Lee
57b5ca5d11 glu/sgi: Silence uninitialized variable warnings. 2009-12-22 23:07:00 -08:00
Vinson Lee
19a40524d3 Add gallium to darwin config. 2009-12-22 18:21:41 -08:00
Vinson Lee
aae32df718 xlib: Use C-style comments. 2009-12-22 17:51:58 -08:00
Vinson Lee
b20382d477 trace: Silence uninitialized variable warnings. 2009-12-22 17:34:39 -08:00
Vinson Lee
f6ca26e5a7 trace: Add PIPE_OS_APPLE. 2009-12-22 17:17:28 -08:00
Vinson Lee
6ce28a755c gallium/util: Add PIPE_OS_APPLE to u_stream_stdc.c. 2009-12-22 16:23:00 -08:00
Vinson Lee
5e73bcb396 gallium/util: Add PIPE_OS_APPLE to u_network. 2009-12-22 15:59:50 -08:00
Vinson Lee
fb8bff341e i915g: Use C-style comment. 2009-12-22 15:19:48 -08:00
Vinson Lee
cf02484fb6 glx: Compile dri2.c only if GLX_DIRECT_RENDERING is defined. 2009-12-22 14:51:12 -08:00
Vinson Lee
c1033299e8 ffb: Silence compiler warnings. 2009-12-22 14:28:40 -08:00
Ian Romanick
e9b5ed1c13 Add MD5 checksums for 7.6.1 release 2009-12-21 18:32:32 -08:00
Ian Romanick
75ad099d3c mesa: set version string to 7.6.1 2009-12-21 18:25:30 -08:00
Vinson Lee
982acbddab progs/perf: Fix MSVC build.
(cherry picked from commit cbf46ed670)
2009-12-21 18:10:44 -08:00
José Fonseca
09415ca234 mesa: Fix missing finite symbol error on Windows.
Caused by some weird logic regarding the __WIN32__ define which made
the finite definition dependent on the header include order.
(cherry picked from commit 622bdecabd)
2009-12-21 17:56:25 -08:00
Michal Krol
de7021b71c mesa: Include <unistd.h> only when one is available.
(cherry picked from commit 970823978c)
2009-12-21 17:55:13 -08:00
Vinson Lee
2b7b2b90e3 scons: Define _USE_MATH_DEFINES on MSVC. 2009-12-21 17:25:03 -08:00
Fabio Pedretti
e46ad402f1 configure.ac: fix for libdrm_radeon API changes. 2009-12-22 10:44:28 +10:00
Dave Airlie
9373287a1b radeon/r600: use new libdrm_radeon api 2009-12-22 10:23:41 +10:00
Dave Airlie
9d2910ee0f radeon: drop assert accessing cref which is meant to be hidden 2009-12-22 10:23:41 +10:00
Dave Airlie
43d8727301 radeon: drop unused members of radeon_state. 2009-12-22 10:23:40 +10:00
Dave Airlie
1703628011 r600: move structs for legacy cmdbuf into cmdbuf C file.
these really shouldn't be exposed here
2009-12-22 09:58:33 +10:00
Vinson Lee
07b54fe35b progs/redbook: Silence compiler warnings. 2009-12-21 15:20:01 -08:00
Dave Airlie
753f0a1dea r600: fix glFrontFace(GL_CW)
fd.o bug #25290

Suggested fix from Rafael Monica
2009-12-21 10:40:19 -05:00
Younes Manton
ace937f165 st/mesa: Check for single level mipmap trees.
The assert in util_gen_mipmap() caught it, although
it does the right thing anyway.
2009-12-21 00:59:06 -05:00
Jeremy Huddleston
b96a5df514 darwin: mklib: Use lipo rather than file to figure out architectures of object files
(cherry picked from commit ad7f9d71e2)
2009-12-20 21:36:41 -08:00
Jeremy Huddleston
f926eff263 darwin: Cleanup CPPFLAGS a bit
(cherry picked from commit 4a1e103858)
2009-12-20 21:36:39 -08:00
Vinson Lee
0dd9513874 progs/tests: Silence compiler warnings. 2009-12-20 01:01:00 -08:00
Vinson Lee
d87d71036c progs/trivial: Use C-style comments. 2009-12-19 00:28:01 -08:00
Vinson Lee
3340fd65fb progs/xdemos: Use C-style comment. 2009-12-19 00:00:56 -08:00
Vinson Lee
695adf41e2 progs/demos: Silence compiler warning in morph3d.c. 2009-12-18 23:46:14 -08:00
Vinson Lee
121ff55d81 progs/glsl: Use C-style comments. 2009-12-18 23:38:15 -08:00
Vinson Lee
41377942d3 progs/demos: Use C-style comment. 2009-12-18 23:34:28 -08:00
Brian Paul
0478b745fe glsl: clear out shader code before compiling
When we start compiling a shader, first free the existing gl_program.
This (mostly) fixes the piglit glsl-reload-source test.
Without this change, we were actually appending the new GPU code
onto the previous program.
2009-12-18 11:57:17 -07:00
Alex Deucher
20ee275974 r600: Invert front face winding when rendering to FBO
fixes fdo bug 25679

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
2009-12-16 16:18:22 -05:00
Ian Romanick
aeea8a07b8 mesa: set version string to 7.6.1-rc4 2009-12-16 10:13:41 -08:00
Brian Paul
8a09e6e2ad mesa: add missing semicolon
See bug 25663.
2009-12-16 10:39:26 -07:00
Brian Paul
35ff190a9c docs: document 7.6.1 BlueGene fixes 2009-12-16 08:17:43 -07:00
Brian Paul
138d639ec9 mesa: test for __blrts for CPU_TO_LE32()
See bug 25663.
2009-12-16 08:04:25 -07:00
Brian Paul
a43fc39585 mesa: no dlopen on BlueGene
See bug 25663.
2009-12-16 08:02:56 -07:00
Brian Paul
6f202b53b0 mesa: remove //-style comments 2009-12-16 07:58:54 -07:00
Brian Paul
ddfc2e7439 st/mesa: remove //-style comments 2009-12-16 07:58:54 -07:00
Vinson Lee
dc0a1ebc73 unichrome: Silence compiler warnings. 2009-12-15 17:39:30 -08:00
Vinson Lee
a60457b03b sis: Silence compiler warnings. 2009-12-15 17:06:01 -08:00
Vinson Lee
7e3825abdb savage: Silence compiler warnings. 2009-12-15 16:32:51 -08:00
Vinson Lee
ca02109e91 r128: Silence uninitialized variable warnings in r128_tris.c. 2009-12-15 13:12:12 -08:00
Vinson Lee
7430c3ac35 dri: Initialize variable in driBindContext. 2009-12-15 13:04:25 -08:00
Ian Romanick
f23d01e726 intel: Fallback to software if drawable size is > MaxRenderbufferSize
This prevents the mystery blank window if, for example, glxgears is
resized larger than 2048 wide on 915.  Since the Intel drivers in Mesa
7.6 lack GTT mapped fallbacks, the performance is a slideshow at
best.  On Mesa 7.7 and later the performance is much better.
2009-12-15 12:37:09 -08:00
Vinson Lee
987e9188d2 x86: ifdef out unused function cptr. 2009-12-15 12:32:48 -08:00
Matthew Bell
22d2547ad1 mesa: Add missing $(DESTDIR) support to src/gallium/winsys/xlib/Makefile 2009-12-14 21:58:19 -07:00
Vinson Lee
0a8d508854 progs/trivial: Silence compiler warnings. 2009-12-14 18:11:57 -08:00
Vinson Lee
6e5fe39f50 mga: Silence uninitialized variable warnings. 2009-12-14 17:30:15 -08:00
Vinson Lee
b18fa9f448 mach64: Silence uninitialized variable warnings. 2009-12-14 17:20:34 -08:00
Vinson Lee
6c9870b54c i810: Silence uninitialized variable warnings in i180tris.c 2009-12-13 00:14:31 -08:00
Vinson Lee
555dc25c4c swrast: Silence uninitialized variable warnings in s_triangle.c 2009-12-12 23:47:32 -08:00
Vinson Lee
aa44efb045 st/mesa: Silence uninitialized variables warnings in st_draw.c. 2009-12-12 22:17:16 -08:00
Vinson Lee
0aef54ba62 swrast: Silence uninitialized variable warnings in ss_tritmp.h. 2009-12-12 22:00:19 -08:00
Vinson Lee
89d85e8170 glut: Prevent potential double free in menuVisualSetup. 2009-12-12 21:46:13 -08:00
Vinson Lee
20590b9733 t_dd_dmatmp.h: Silence unused value warning in render_poly_elts. 2009-12-12 20:20:02 -08:00
Vinson Lee
cd1a09e3bb glsl: Initialize member label of struct slang_operation to NULL. 2009-12-12 18:42:18 -08:00
Vinson Lee
f8d4ac56f7 softpipe: Initialize source in blend_quad. 2009-12-12 18:34:15 -08:00
Vinson Lee
7ea452dd35 t_dd_dmatmp2.h: Silence unused value warnings. 2009-12-12 16:56:07 -08:00
Vinson Lee
75e8dbb235 i915g: Silence unused value warning in intel_drm_get_device_id. 2009-12-12 16:24:25 -08:00
Vinson Lee
9dc018618d t_dd_dmatmp.h: Silence unused value warnings in render_line_loop_elts. 2009-12-12 16:18:08 -08:00
Vinson Lee
af4e4a73f7 t_dd_dmatmp.h: Silence unused value warning in render_tri_fan_elts. 2009-12-12 16:02:09 -08:00
Vinson Lee
588e9f69c4 progs/trivial: Silence compiler warnings in tri-blend-min.c. 2009-12-12 15:47:17 -08:00
Vinson Lee
de9132f274 t_dd_dmatmp.h: Silence unused value warning in render_poly_verts. 2009-12-12 15:27:30 -08:00
Vinson Lee
1e444c9960 swrast: Initialize tex_coords in handle_sample_op. 2009-12-12 15:08:01 -08:00
Vinson Lee
c1d361bd0b t_dd_dmatmp.h: Silence unused value warning in render_quads_verts. 2009-12-12 14:41:35 -08:00
Vinson Lee
786899f153 progs/trivial: Silence compiler warnings in tri-blend-max.c 2009-12-12 14:20:17 -08:00
Vinson Lee
7d529736b9 t_dd_dmatmp.h: Silence unused value warning in render_tri_fan_verts. 2009-12-12 13:39:39 -08:00
Vinson Lee
c2cee7741e t_dd_dmatmp.h: Silence unused value warning in render_line_loop_verts. 2009-12-12 12:52:02 -08:00
Vinson Lee
15c6558a2e progs/xdemos: Silence compiler warnings in glxinfo.c. 2009-12-12 02:06:51 -08:00
Vinson Lee
d5be33477e progs/tests: Silence compiler warnings in vpeval.c. 2009-12-12 01:34:33 -08:00
Vinson Lee
44d6ab6de5 progs/tests: Silence compiler warnings in cva.c. 2009-12-12 01:11:56 -08:00
Vinson Lee
9e2eee4ab2 progs/redbook: Silence compiler warnings in aaindex.c. 2009-12-12 01:02:16 -08:00
Vinson Lee
81dcf8bdf2 t_dd_dmatmp.h: Silence unused value warning in render_line_loop_verts. 2009-12-12 00:33:42 -08:00
1395 changed files with 90329 additions and 886095 deletions

13895
ChangeLog

File diff suppressed because it is too large Load Diff

View File

@@ -182,7 +182,7 @@ ultrix-gcc:
# Rules for making release tarballs
VERSION=7.7-rc2
VERSION=7.6.1
DIRECTORY = Mesa-$(VERSION)
LIB_NAME = MesaLib-$(VERSION)
DEMO_NAME = MesaDemos-$(VERSION)
@@ -415,12 +415,6 @@ DEMO_FILES = \
$(DIRECTORY)/progs/demos/README \
$(DIRECTORY)/progs/fbdev/Makefile \
$(DIRECTORY)/progs/fbdev/glfbdevtest.c \
$(DIRECTORY)/progs/objviewer/*.[ch] \
$(DIRECTORY)/progs/objviewer/*.obj \
$(DIRECTORY)/progs/objviewer/*.mtl \
$(DIRECTORY)/progs/objviewer/*.rgb \
$(DIRECTORY)/progs/objviewer/Makefile \
$(DIRECTORY)/progs/objviewer/README.txt \
$(DIRECTORY)/progs/osdemos/Makefile \
$(DIRECTORY)/progs/osdemos/*.c \
$(DIRECTORY)/progs/xdemos/Makefile* \
@@ -502,11 +496,9 @@ rm_depend:
touch $$dep ; \
done
rm_config:
rm -f configs/current
rm -f configs/autoconf
lib_gz: rm_config
lib_gz:
rm -f configs/current ; \
rm -f configs/autoconf ; \
cd .. ; \
tar -cf $(LIB_NAME).tar $(LIB_FILES) ; \
gzip $(LIB_NAME).tar ; \
@@ -524,7 +516,9 @@ glut_gz:
gzip $(GLUT_NAME).tar ; \
mv $(GLUT_NAME).tar.gz $(DIRECTORY)
lib_bz2: rm_config
lib_bz2:
rm -f configs/current ; \
rm -f configs/autoconf ; \
cd .. ; \
tar -cf $(LIB_NAME).tar $(LIB_FILES) ; \
bzip2 $(LIB_NAME).tar ; \
@@ -542,7 +536,9 @@ glut_bz2:
bzip2 $(GLUT_NAME).tar ; \
mv $(GLUT_NAME).tar.bz2 $(DIRECTORY)
lib_zip: rm_config
lib_zip:
rm -f configs/current ; \
rm -f configs/autoconf ; \
rm -f $(LIB_NAME).zip ; \
cd .. ; \
zip -qr $(LIB_NAME).zip $(LIB_FILES) ; \
@@ -571,7 +567,5 @@ md5:
@-md5sum $(GLUT_NAME).tar.bz2
@-md5sum $(GLUT_NAME).zip
.PHONY: tarballs rm_depend rm_config md5 \
lib_gz demo_gz glut_gz \
lib_bz2 demo_bz2 glut_bz2 \
lib_zip demo_zip glut_zip
.PHONY: tarballs rm_depend lib_gz demo_gz glut_gz lib_bz2 demo_bz2 \
glut_bz2 lib_zip demo_zip glut_zip md5

View File

@@ -32,10 +32,10 @@ import common
default_statetrackers = 'mesa'
if common.default_platform in ('linux', 'freebsd', 'darwin'):
default_drivers = 'softpipe,failover,svga,i915,trace,identity,llvmpipe'
default_drivers = 'softpipe,failover,i915simple,trace,identity,llvmpipe'
default_winsys = 'xlib'
elif common.default_platform in ('winddk',):
default_drivers = 'softpipe,svga,i915,trace,identity'
default_drivers = 'softpipe,i915simple,trace,identity'
default_winsys = 'all'
else:
default_drivers = 'all'
@@ -46,9 +46,9 @@ common.AddOptions(opts)
opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
['mesa', 'python', 'xorg']))
opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
['softpipe', 'failover', 'svga', 'i915', 'cell', 'trace', 'r300', 'identity', 'llvmpipe']))
['softpipe', 'failover', 'i915simple', 'i965simple', 'cell', 'trace', 'r300', 'identity', 'llvmpipe']))
opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
['xlib', 'vmware', 'intel', 'gdi', 'radeon']))
['xlib', 'intel', 'gdi', 'radeon']))
opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))

View File

@@ -724,22 +724,10 @@ case $ARCH in
# examine first object to determine ABI
set ${OBJECTS}
ABI_PPC=`file $1 | grep ' ppc'`
ABI_I386=`file $1 | grep ' i386'`
ABI_PPC64=`file $1 | grep ' ppc64'`
ABI_X86_64=`file $1 | grep ' x86_64'`
if [ "${ABI_PPC}" ] ; then
OPTS="${OPTS} -arch ppc"
fi
if [ "${ABI_I386}" ] ; then
OPTS="${OPTS} -arch i386"
fi
if [ "${ABI_PPC64}" ] ; then
OPTS="${OPTS} -arch ppc64"
fi
if [ "${ABI_X86_64}" ] ; then
OPTS="${OPTS} -arch x86_64"
fi
ABIS=`lipo -info $1 | sed s/.*://`
for ABI in $ABIS; do
OPTS="${OPTS} -arch ${ABI}"
done
if [ "${ALTOPTS}" ] ; then
OPTS=${ALTOPTS}

309
bin/win32kprof.py Executable file
View File

@@ -0,0 +1,309 @@
#!/usr/bin/env python
##########################################################################
#
# Copyright 2008 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.
#
##########################################################################
import sys
import optparse
import re
import struct
from gprof2dot import Call, Function, Profile
from gprof2dot import CALLS, SAMPLES, TIME, TIME_RATIO, TOTAL_TIME, TOTAL_TIME_RATIO
from gprof2dot import DotWriter, TEMPERATURE_COLORMAP
__version__ = '0.1'
class ParseError(Exception):
pass
class MsvcDemangler:
# http://www.kegel.com/mangle.html
def __init__(self, symbol):
self._symbol = symbol
self._pos = 0
def lookahead(self):
return self._symbol[self._pos]
def consume(self):
ret = self.lookahead()
self._pos += 1
return ret
def match(self, c):
if self.lookahead() != c:
raise ParseError
self.consume()
def parse(self):
self.match('?')
name = self.parse_name()
qualifications = self.parse_qualifications()
return '::'.join(qualifications + [name])
def parse_name(self):
if self.lookahead() == '?':
return self.consume() + self.consume()
else:
name = self.parse_id()
self.match('@')
return name
def parse_qualifications(self):
qualifications = []
while self.lookahead() != '@':
name = self.parse_id()
qualifications.append(name)
self.match('@')
return qualifications
def parse_id(self):
s = ''
while True:
c = self.lookahead()
if c.isalnum() or c in '_':
s += c
self.consume()
else:
break
return s
def demangle(name):
if name.startswith('_'):
name = name[1:]
idx = name.rfind('@')
if idx != -1 and name[idx+1:].isdigit():
name = name[:idx]
return name
if name.startswith('?'):
demangler = MsvcDemangler(name)
return demangler.parse()
return name
class Reader:
def __init__(self):
self.symbols = []
self.symbol_cache = {}
self.base_addr = None
def read_map(self, mapfile):
# See http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
last_addr = 0
last_name = 0
for line in file(mapfile, "rt"):
fields = line.split()
try:
section_offset, name, addr, type, lib_object = fields
except ValueError:
continue
if type != 'f':
continue
section, offset = section_offset.split(':')
addr = int(offset, 16)
self.symbols.append((addr, name))
last_addr = addr
last_name = name
# sort symbols
self.symbols.sort(key = lambda (addr, name): addr)
def lookup_addr(self, addr):
try:
return self.symbol_cache[addr]
except KeyError:
pass
tolerance = 4196
s, e = 0, len(self.symbols)
while s != e:
i = (s + e)//2
start_addr, name = self.symbols[i]
try:
end_addr, next_name = self.symbols[i + 1]
except IndexError:
end_addr = start_addr + tolerance
if addr < start_addr:
e = i
continue
if addr == end_addr:
return next_name, addr - start_addr
if addr > end_addr:
s = i
continue
return name, addr - start_addr
raise ValueError
def lookup_symbol(self, name):
for symbol_addr, symbol_name in self.symbols:
if name == symbol_name:
return symbol_addr
return 0
def read_data(self, data):
profile = Profile()
fp = file(data, "rb")
entry_format = "IIII"
entry_size = struct.calcsize(entry_format)
caller = None
caller_stack = []
while True:
entry = fp.read(entry_size)
if len(entry) < entry_size:
break
caller_addr, callee_addr, samples_lo, samples_hi = struct.unpack(entry_format, entry)
if caller_addr == 0 and callee_addr == 0:
continue
if self.base_addr is None:
ref_addr = self.lookup_symbol('___debug_profile_reference@0')
if ref_addr:
self.base_addr = (caller_addr - ref_addr) & ~(options.align - 1)
else:
self.base_addr = 0
sys.stderr.write('Base addr: %08x\n' % self.base_addr)
samples = (samples_hi << 32) | samples_lo
try:
caller_raddr = caller_addr - self.base_addr
caller_sym, caller_ofs = self.lookup_addr(caller_raddr)
try:
caller = profile.functions[caller_sym]
except KeyError:
caller_name = demangle(caller_sym)
caller = Function(caller_sym, caller_name)
profile.add_function(caller)
caller[CALLS] = 0
caller[SAMPLES] = 0
except ValueError:
caller = None
if not callee_addr:
if caller:
caller[SAMPLES] += samples
else:
callee_raddr = callee_addr - self.base_addr
callee_sym, callee_ofs = self.lookup_addr(callee_raddr)
try:
callee = profile.functions[callee_sym]
except KeyError:
callee_name = demangle(callee_sym)
callee = Function(callee_sym, callee_name)
profile.add_function(callee)
callee[CALLS] = samples
callee[SAMPLES] = 0
else:
callee[CALLS] += samples
if caller is not None:
try:
call = caller.calls[callee.id]
except KeyError:
call = Call(callee.id)
call[CALLS] = samples
caller.add_call(call)
else:
call[CALLS] += samples
if options.verbose:
if not callee_addr:
sys.stderr.write('%s+%u: %u\n' % (caller_sym, caller_ofs, samples))
else:
sys.stderr.write('%s+%u -> %s+%u: %u\n' % (caller_sym, caller_ofs, callee_sym, callee_ofs, samples))
# compute derived data
profile.validate()
profile.find_cycles()
profile.aggregate(SAMPLES)
profile.ratio(TIME_RATIO, SAMPLES)
profile.call_ratios(CALLS)
profile.integrate(TOTAL_TIME_RATIO, TIME_RATIO)
return profile
def main():
parser = optparse.OptionParser(
usage="\n\t%prog [options] [file] ...",
version="%%prog %s" % __version__)
parser.add_option(
'-a', '--align', metavar='NUMBER',
type="int", dest="align", default=16,
help="section alignment")
parser.add_option(
'-m', '--map', metavar='FILE',
type="string", dest="map",
help="map file")
parser.add_option(
'-b', '--base', metavar='FILE',
type="string", dest="base",
help="base addr")
parser.add_option(
'-n', '--node-thres', metavar='PERCENTAGE',
type="float", dest="node_thres", default=0.5,
help="eliminate nodes below this threshold [default: %default]")
parser.add_option(
'-e', '--edge-thres', metavar='PERCENTAGE',
type="float", dest="edge_thres", default=0.1,
help="eliminate edges below this threshold [default: %default]")
parser.add_option(
'-v', '--verbose',
action="count",
dest="verbose", default=0,
help="verbose output")
global options
(options, args) = parser.parse_args(sys.argv[1:])
reader = Reader()
if options.base is not None:
reader.base_addr = int(options.base, 16)
if options.map is not None:
reader.read_map(options.map)
for arg in args:
profile = reader.read_data(arg)
profile.prune(options.node_thres/100.0, options.edge_thres/100.0)
output = sys.stdout
dot = DotWriter(output)
colormap = TEMPERATURE_COLORMAP
dot.graph(profile, colormap)
if __name__ == '__main__':
main()

View File

@@ -12,10 +12,10 @@ X11_DIR = $(INSTALL_DIR)
CC = gcc
CXX = g++
PIC_FLAGS = -fPIC
DEFINES = -D_DARWIN_C_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L \
-D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS \
DEFINES = -D_DARWIN_C_SOURCE -DPTHREADS -D_GNU_SOURCE \
-DGLX_ALIAS_UNSUPPORTED -DGLX_INDIRECT_RENDERING
# -D_GNU_SOURCE - for src/mesa/main ...
# -DGLX_DIRECT_RENDERING - pulls in libdrm stuff in glx/x11
# -DGLX_USE_APPLEGL - supposed to be used with GLX_DIRECT_RENDERING to use AGL rather than DRM, but doesn't compile
# -DIN_DRI_DRIVER
@@ -49,7 +49,7 @@ GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X
APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXmu -lXt -lXi -lm
# omit glw lib for now:
SRC_DIRS = glx/x11 mesa glu glut/glx glew
SRC_DIRS = glx/x11 mesa gallium glu glut/glx glew
GLU_DIRS = sgi
DRIVER_DIRS = osmesa
#DRIVER_DIRS = dri

View File

@@ -9,8 +9,8 @@ CONFIG_NAME = default
# Version info
MESA_MAJOR=7
MESA_MINOR=7
MESA_TINY=0
MESA_MINOR=6
MESA_TINY=1
MESA_VERSION = $(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY)
# external projects. This should be useless now that we use libdrm.
@@ -87,16 +87,16 @@ SRC_DIRS = mesa gallium egl gallium/winsys glu glut/glx glew glw
GLU_DIRS = sgi
DRIVER_DIRS = x11 osmesa
# Which subdirs under $(TOP)/progs/ to enter:
PROGRAM_DIRS = demos redbook samples glsl objviewer xdemos
PROGRAM_DIRS = demos redbook samples glsl xdemos
# EGL directories
EGL_DRIVERS_DIRS = demo
# Gallium directories and
GALLIUM_DIRS = auxiliary drivers state_trackers
GALLIUM_AUXILIARY_DIRS = rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices vl
GALLIUM_AUXILIARY_DIRS = rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices
GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a)
GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 trace identity
GALLIUM_DRIVERS_DIRS = softpipe i915simple failover trace identity
GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
GALLIUM_WINSYS_DIRS = xlib egl_xlib
GALLIUM_WINSYS_DRM_DIRS =

View File

@@ -23,11 +23,11 @@ DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
X11_INCLUDES = -I/usr/X11R6/include
CFLAGS = -Wall -Wmissing-prototypes -Wdeclaration-after-statement \
-Wpointer-arith $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) \
$(DEFINES) $(ASM_FLAGS) $(X11_INCLUDES) -std=c99 -ffast-math
$(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) \
$(DEFINES) $(ASM_FLAGS) $(X11_INCLUDES) -std=c99 -ffast-math
CXXFLAGS = -Wall -Wpointer-arith $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) \
$(DEFINES) $(X11_INCLUDES)
CXXFLAGS = -Wall $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
$(X11_INCLUDES)
# Work around aliasing bugs - developers should comment this out
CFLAGS += -fno-strict-aliasing

View File

@@ -4,6 +4,5 @@ include $(TOP)/configs/linux
CONFIG_NAME = linux-debug
OPT_FLAGS = -g
CFLAGS += -ansi -pedantic
OPT_FLAGS = -g -ansi -pedantic
DEFINES += -DDEBUG -DDEBUG_MATH

View File

@@ -60,8 +60,8 @@ EGL_DRIVERS_DIRS = demo glx
DRIVER_DIRS = dri
WINDOW_SYSTEM = dri
GALLIUM_WINSYS_DIRS = drm
GALLIUM_WINSYS_DRM_DIRS = vmware intel
GALLIUM_WINSYS_DRM_DIRS = intel
GALLIUM_STATE_TRACKERS_DIRS = egl
DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \
savage sis tdfx unichrome ffb swrast
DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
savage sis tdfx trident unichrome ffb swrast

View File

@@ -11,6 +11,6 @@ ARCH_FLAGS = -DDEBUG
#DRI_DIRS = i915tex i915
#DRI_DIRS = i965
#DRI_DIRS = radeon r200 r300
#DRI_DIRS = unichrome sis
#DRI_DIRS = unichrome sis trident
#DRI_DIRS = i810 mga r128 tdfx

View File

@@ -68,5 +68,5 @@ WINDOW_SYSTEM=dri
# gamma are missing because they have not been converted to use the new
# interface.
DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon \
savage sis tdfx unichrome ffb
DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon s3v \
savage sis tdfx trident unichrome ffb

View File

@@ -18,7 +18,8 @@ AC_CONFIG_AUX_DIR([bin])
AC_CANONICAL_HOST
dnl Versions for external dependencies
LIBDRM_REQUIRED=2.4.15
LIBDRM_REQUIRED=2.4.3
LIBDRM_RADEON_REQUIRED=2.4.17
DRI2PROTO_REQUIRED=1.99.3
dnl Check for progs
@@ -419,7 +420,7 @@ WINDOW_SYSTEM=""
GALLIUM_DIRS="auxiliary drivers state_trackers"
GALLIUM_WINSYS_DIRS=""
GALLIUM_WINSYS_DRM_DIRS=""
GALLIUM_AUXILIARY_DIRS="rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices vl"
GALLIUM_AUXILIARY_DIRS="rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices"
GALLIUM_DRIVERS_DIRS="softpipe failover trace identity"
GALLIUM_STATE_TRACKERS_DIRS=""
@@ -577,7 +578,7 @@ dri)
GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED"
DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
PKG_CHECK_MODULES([LIBDRM_RADEON], [libdrm_radeon], HAVE_LIBDRM_RADEON=yes, HAVE_LIBDRM_RADEON=no)
PKG_CHECK_MODULES([LIBDRM_RADEON], [libdrm_radeon libdrm >= $LIBDRM_RADEON_REQUIRED], HAVE_LIBDRM_RADEON=yes, HAVE_LIBDRM_RADEON=no)
if test "$HAVE_LIBDRM_RADEON" = yes; then
RADEON_CFLAGS="-DHAVE_LIBDRM_RADEON=1 $LIBDRM_RADEON_CFLAGS"
@@ -775,8 +776,8 @@ if test "$mesa_driver" = dri; then
# default drivers
if test "x$DRI_DIRS" = "xyes"; then
DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon \
savage sis tdfx unichrome ffb swrast"
DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon s3v \
savage sis tdfx trident unichrome ffb swrast"
fi
DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`
@@ -1143,14 +1144,7 @@ yes)
GALLIUM_STATE_TRACKERS_DIRS=glx
;;
dri)
GALLIUM_STATE_TRACKERS_DIRS="dri"
if test "x$enable_egl" = xyes; then
GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl"
fi
# Have only tested st/xorg on 1.6.0 servers
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0],
HAVE_XORG="yes"; GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS xorg",
HAVE_XORG="no")
test "x$enable_egl" = xyes && GALLIUM_STATE_TRACKERS_DIRS=egl
;;
esac
;;
@@ -1196,32 +1190,17 @@ AC_ARG_WITH([max-height],
[AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
)
dnl
dnl Gallium SVGA configuration
dnl
AC_ARG_ENABLE([gallium-svga],
[AS_HELP_STRING([--disable-gallium-svga],
[build gallium SVGA @<:@default=enabled@:>@])],
[enable_gallium_svga="$enableval"],
[enable_gallium_svga=yes])
if test "x$enable_gallium_svga" = xyes; then
GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS vmware"
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
fi
dnl
dnl Gallium Intel configuration
dnl
AC_ARG_ENABLE([gallium-intel],
[AS_HELP_STRING([--enable-gallium-intel],
[build gallium intel @<:@default=disabled@:>@])],
[AS_HELP_STRING([--disable-gallium-intel],
[build gallium intel @<:@default=enabled@:>@])],
[enable_gallium_intel="$enableval"],
[enable_gallium_intel=auto])
[enable_gallium_intel=yes])
if test "x$enable_gallium_intel" = xyes; then
GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS intel"
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915"
elif test "x$enable_gallium_intel" = xauto; then
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915"
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS i915simple"
fi
dnl

12
debian/changelog vendored
View File

@@ -1,9 +1,13 @@
mesa (7.7~rc2-1) experimental; urgency=low
mesa (7.6.1-1) unstable; urgency=low
* New upstream release candidate.
+ s3v and trident DRI drivers removed since they never worked.
* New upstream release
+ Pull upstream mesa_7_6_branch up to commit da876fa3
* Bump linux-libc-dev build-dep to 2.6.31 for the r600 dri driver (fixes
ftbfs on mips).
* Drop hunk from 05_hurd-ftbfs.diff that was applied upstream. Refresh
other patches.
-- Brice Goglin <bgoglin@debian.org> Sat, 12 Dec 2009 13:02:55 +0100
-- Julien Cristau <jcristau@debian.org> Tue, 29 Dec 2009 10:42:24 +0000
mesa (7.6.1~rc3-1) unstable; urgency=low

2
debian/control vendored
View File

@@ -9,7 +9,7 @@ Build-Depends: debhelper (>= 6.0.7), quilt (>= 0.40), pkg-config,
x11proto-gl-dev (>= 1.4.8), libxxf86vm-dev,
libexpat1-dev, lesstif2-dev, dpkg-dev (>= 1.13.19), libxfixes-dev,
libxdamage-dev, libxext-dev, autoconf, automake, x11proto-dri2-dev (>= 1.99.3),
linux-libc-dev (>= 2.6.29) [!hurd-i386 !kfreebsd-amd64 !kfreebsd-i386]
linux-libc-dev (>= 2.6.31) [!hurd-i386 !kfreebsd-amd64 !kfreebsd-i386]
Vcs-Git: git://git.debian.org/git/pkg-xorg/lib/mesa
Vcs-Browser: http://git.debian.org/?p=pkg-xorg/lib/mesa.git
Homepage: http://mesa3d.sourceforge.net/

View File

@@ -6,7 +6,7 @@ Index: mesa/src/mesa/main/compiler.h
===================================================================
--- mesa.orig/src/mesa/main/compiler.h
+++ mesa/src/mesa/main/compiler.h
@@ -347,8 +347,9 @@
@@ -351,8 +351,9 @@
* USE_IEEE: Determine if we're using IEEE floating point
*/
#if defined(__i386__) || defined(__386__) || defined(__sparc__) || \

View File

@@ -52,4 +52,4 @@ Index: mesa/progs/Makefile
+ done
clean:
-@for dir in $(SUBDIRS) tests ; do \
@list='$(SUBDIRS)'; for dir in $$list tests ; do \

View File

@@ -6,28 +6,11 @@ Subject: Fix build on GNU/Hurd
src/glx/x11/dri2.c | 2 ++
2 files changed, 16 insertions(+), 11 deletions(-)
Index: mesa-7.6.1~rc2/src/glx/x11/dri2.c
Index: mesa/configure.ac
===================================================================
--- mesa-7.6.1~rc2.orig/src/glx/x11/dri2.c 2009-12-05 23:51:01.000000000 +0100
+++ mesa-7.6.1~rc2/src/glx/x11/dri2.c 2009-12-06 00:10:10.000000000 +0100
@@ -30,6 +30,7 @@
* Kristian Høgsberg (krh@redhat.com)
*/
+#ifdef GLX_DIRECT_RENDERING
#define NEED_REPLIES
#include <X11/Xlibint.h>
@@ -377,3 +378,4 @@
UnlockDisplay(dpy);
SyncHandle();
}
+#endif
Index: mesa-7.6.1~rc2/configure.ac
===================================================================
--- mesa-7.6.1~rc2.orig/configure.ac 2009-12-05 23:50:57.000000000 +0100
+++ mesa-7.6.1~rc2/configure.ac 2009-12-06 00:10:27.000000000 +0100
@@ -538,6 +538,13 @@
--- mesa.orig/configure.ac
+++ mesa/configure.ac
@@ -539,6 +539,13 @@
enable_xcb=no
fi
@@ -41,7 +24,7 @@ Index: mesa-7.6.1~rc2/configure.ac
dnl
dnl libGL configuration per driver
dnl
@@ -571,11 +578,13 @@
@@ -572,11 +579,13 @@
AC_MSG_ERROR([Can't use static libraries for DRI drivers])
fi
@@ -58,9 +41,9 @@ Index: mesa-7.6.1~rc2/configure.ac
+ DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
+ fi
PKG_CHECK_MODULES([LIBDRM_RADEON], [libdrm_radeon], HAVE_LIBDRM_RADEON=yes, HAVE_LIBDRM_RADEON=no)
PKG_CHECK_MODULES([LIBDRM_RADEON], [libdrm_radeon libdrm >= $LIBDRM_RADEON_REQUIRED], HAVE_LIBDRM_RADEON=yes, HAVE_LIBDRM_RADEON=no)
@@ -656,12 +665,6 @@
@@ -657,12 +666,6 @@
[DRI_DRIVER_SEARCH_DIR="$withval"],
[DRI_DRIVER_SEARCH_DIR='${DRI_DRIVER_INSTALL_DIR}'])
AC_SUBST([DRI_DRIVER_SEARCH_DIR])

View File

@@ -8,11 +8,11 @@ http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=524690
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: mesa-7.6.1~rc2/configure.ac
Index: mesa/configure.ac
===================================================================
--- mesa-7.6.1~rc2.orig/configure.ac 2009-12-06 00:10:10.000000000 +0100
+++ mesa-7.6.1~rc2/configure.ac 2009-12-06 00:10:10.000000000 +0100
@@ -745,7 +745,7 @@
--- mesa.orig/configure.ac
+++ mesa/configure.ac
@@ -746,7 +746,7 @@
;;
esac
;;

2
debian/rules vendored
View File

@@ -69,7 +69,7 @@ else
ifeq ($(DEB_HOST_ARCH), lpia)
DRI_DRIVERS += i915 i965
else ifneq ($(DEB_HOST_ARCH), s390)
DRI_DRIVERS += mach64 mga r128 r200 r300 r600 radeon savage tdfx
DRI_DRIVERS += mach64 mga r128 r200 r300 r600 radeon s3v savage tdfx trident
ifeq ($(DEB_HOST_GNU_CPU), i486)
DRI_DRIVERS += i810 i915 i965 sis unichrome
else ifeq ($(DEB_HOST_GNU_CPU), x86_64)

View File

@@ -28,7 +28,6 @@ Setting this variable automatically sets the MESA_TEX_PROG variable as well.
<li>MESA_EXTENSION_OVERRIDE - can be used to enable/disable extensions.
A value such as "GL_EXT_foo -GL_EXT_bar" will enable the GL_EXT_foo extension
and disable the GL_EXT_bar extension.
<li>MESA_GLSL - <a href="shading.html#envvars">shading language options</a>
</ul>
<p>

View File

@@ -35,14 +35,14 @@
<h3>1.1 Prerequisites for DRI and hardware acceleration</h3>
<p>
The following are required for DRI-based hardware acceleration with Mesa:
The following are required for DRI-based hardware acceleration with Mesa 7.3:
</p>
<ul>
<li><a href="http://xorg.freedesktop.org/releases/individual/proto/">dri2proto</a> version 1.99.3 or later
<li>Linux 2.6.28
<li><a href="http://dri.freedesktop.org/libdrm/" target="_parent">libDRM</a>
version 2.4.15 or later
version 2.4.3 or later
<li>Xorg server version 1.5 or later
</ul>
</p>

View File

@@ -1,197 +0,0 @@
Introduction
------------
This document describes the implementation of the XFree86 4.0 libGL.so
library defined by the Linux/OpenGL Base specification found at
http://reality.sgi.com/opengl/linux/linuxbase.html.
The documentation is divided into two sections:
User's Guide
Driver Developer's Guide
Author: Brian Paul (brian@precisioninsight.com)
Date: February 2000
User's Guide
------------
Using libGL.so
The libGL.so library defines the gl- and glX-prefixed functions needed to
run OpenGL programs. OpenGL client applications should link with the
-lGL option to use it.
libGL.so serves two primary functions: GLX protocol generation for indirect
rendering and loading/management of hardware drivers for direct rendering.
When libGL.so initializes itself it uses the DRI to determine the
appropriate hardware driver for each screen on the local X display.
The hardware drivers are expected to be in the /usr/X11R6/lib/modules/dri/
directory. Drivers are named with the convention <name>_dri.so where
<name> is a driver such as "tdfx", "i810", "gamma", etc.
The LIBGL_DRIVERS_DIR environment variable may be used to specify a
different DRI modules directory, overriding /usr/X11R6/lib/modules/dri/.
This environment variable is ignored in setuid programs for security
reasons.
When libGL.so is unable to locate appropriate hardware drivers it will
fall back to using indirect GLX rendering.
To aid in solving problems, libGL.so will print diagnostic messages to
stderr if the LIBGL_DEBUG environment variable is defined.
libGL.so is thread safe. The overhead of thread safety for common,
single-thread clients is negligible. However, the overhead of thread
safety for multi-threaded clients is significant. Each GL API call
requires two calls to pthread_get_specific() which can noticably
impact performance. Warning: libGL.so is thread safe but individual
DRI drivers may not be. Please consult the documentation for a driver
to learn if it is thread safe.
Indirect Rendering
You can force indirect rendering mode by setting the LIBGL_ALWAYS_INDIRECT
environment variable. Hardware acceleration will not be used.
libGL.so Extensibility
libGL.so is designed to be extended without upgrading. That is,
drivers may install new OpenGL extension functions into libGL.so
without requiring libGL.so to be replaced. Clients of libGL.so should
use the glXGetProcAddressEXT() function to obtain the address of
functions by name. For more details of GLX_ARB_get_proc_address see
http://oss.sgi.com/projects/ogl-sample/registry/ARB/get_proc_address.spec
libGL.so is also designed with flexibility such that it may be used
with many generations of hardware drivers to come.
Driver Developer's Guide
------------------------
This section describes the requirements to make an XFree86 4.0
libGL.so-compatible hardware driver. It is not intended for end
users of libGL.so.
XFree86 source files
libGL.so is built inside XFree86 with sources found in xc/lib/GL/.
Specifically, libGL.so is built from:
xc/lib/GL/glx/*.c
xc/lib/dri/XF86dri.c
xc/lib/dri/dri_glx.c
xc/lib/GL/mesa/src/glapi.c
xc/lib/GL/mesa/src/glapitemp.h
xc/lib/GL/mesa/src/glapitable.h
xc/lib/GL/mesa/src/glapioffsets.h
xc/lib/GL/mesa/src/glapinoop.c
xc/lib/GL/mesa/src/glheader.h
xc/lib/GL/mesa/src/glthread.c
xc/lib/GL/mesa/src/glthread.h
xc/lib/GL/mesa/src/X86/glapi_x86.S
xc/lib/GL/mesa/src/X86/assyntax.h
Understand that the mesa/src/gl*.[ch] files are not tied to Mesa. They
have no dependencies on the rest of Mesa and are designed to be reusable
in a number of projects.
The glapi_x86.X and assyntax.h files implement x86-optimized dispatch
of GL functions. They are not required; C-based dispatch can be used
instead, with a slight performance penalty.
Driver loading and binding
When libGL.so initializes itself (via the __glXInitialize function) a
call is made to driCreateDisplay(). This function uses DRI facilities
to determine the driver file appropriate for each screen on the local
display. Each screen's driver is then opened with dlopen() and asked
for its __driCreateScreen() function. The pointers to the __driCreateScreen()
functions are kept in an array, indexed by screen number, in the
__DRIdisplayRec struct.
When a driver's __driCreateScreen() function is called, it must initialize
a __DRIscreenRec struct. This struct acts as the root of a tree of
function pointers which are called to create and destroy contexts and
drawables and perform all the operations needed by the GLX interface.
See the xc/lib/GL/glx/glxclient.h file for details.
Dynamic Extension Function Registration
In order to provide forward compatibility with future drivers, libGL.so
allows drivers to register new OpenGL extension functions which weren't
known when libGL.so was built.
The register_extensions() function in xc/lib/GL/dri/dri_glx.c is called
as soon as libGL.so is loaded. This is done with gcc's constructor
attribute. This mechanism will likely have to be changed for other compilers.
register_extensions() loops over all local displays and screens, determines
the DRI driver for each, and calls the driver's __driRegisterExtensions()
function, if present.
The __driRegisterExtensions() function can add new entrypoints to libGL
by calling:
GLboolean _glapi_add_entrypoint(const char *funcName, GLuint offset)
The parameters are the name of the function (such as "glFoobarEXT") and the
offset of the dispatch slot in the API dispatch table. The return value
indicates success (GL_TRUE) or failure (GL_FALSE).
_glapi_add_entrypoint() will synthesize entrypoint code in assembly
language. Assembly languages is required since parameter passing
can't be handled correctly using a C-based solution.
The address of the new entrypoint is obtained by calling the
glXGetProcAddressARB() function.
The dispatch offset number MUST be a number allocated by SGI in the same
manner in which new GL_* constants are allocated. Using an arbitrary
offset number will result in many problems.
Dispatch Management
When a GL context is made current, the driver must install its dispatch
table as the current dispatch table. This is done by calling
void _glapi_set_dispatch(struct _glapi_table *dispatch);
This will install the named dispatch table for the calling thread.
The current dispatch table for a thread can be obtained by calling
struct _glapi_table *_glapi_get_dispatch(void);
For higher performance in the common single-thread case, the global
variable _glapi_Dispatch will point to the current dispatch table.
This variable will be NULL when in multi-thread mode.
Context Management
libGL.so uses the XFree86 xthreads package to manage a thread-specific
current context pointer. See __glXGet/SetCurrentContext() in glext.c
Drivers may use the _glapi_set/get_context() functions to maintain
a private thread-specific context pointer.

View File

@@ -10,7 +10,7 @@
<H1>News</H1>
<h2>November XX, 2009</h2>
<h2>December 21, 2009</h2>
<p>
<a href="relnotes-7.6.1.html">Mesa 7.6.1</a> is released. This is a bug-fix
release fixing issues found in the 7.6 release.

View File

@@ -8,7 +8,7 @@
<body bgcolor="#eeeeee">
<H1>Mesa 7.6.1 Release Notes, (date tbd)</H1>
<H1>Mesa 7.6.1 Release Notes, 21 December 2009</H1>
<p>
Mesa 7.6.1 is a bug-fix release fixing issues since version 7.6.
@@ -26,7 +26,15 @@ for DRI hardware acceleration.
<h2>MD5 checksums</h2>
<pre>
tbd
e80fabad2e3eb7990adae773d6aeacba MesaLib-7.6.1.tar.gz
7db4617e9e10ad3aca1b64339fd71b7d MesaLib-7.6.1.tar.bz2
dd3275dbf9833480d2e92d0c69b22abd MesaLib-7.6.1.zip
f7fdcfe3c0f363e571c60f02f74368fb MesaDemos-7.6.1.tar.gz
a4226f06732a02556fcf6be290b86dff MesaDemos-7.6.1.tar.bz2
849425f356bd940726cebedfa79de176 MesaDemos-7.6.1.zip
d40cc7c5e337a85b674e27a8e494f52f MesaGLUT-7.6.1.tar.gz
ca9aecb91f05b1da9fd7d5eeb19d47d7 MesaGLUT-7.6.1.tar.bz2
23fad8398004c977a1d8953079b72ca6 MesaGLUT-7.6.1.zip
</pre>
@@ -59,6 +67,7 @@ tbd
<li>Point sprite fixes for i915/945 driver.
<li>Fixed assorted memory leaks (usually on error paths)
<li>Fixed some GLSL compiler bugs (ex: 25579)
<li>Assorted build fixes for BlueGene
</ul>
<h2>Changes</h2>

View File

@@ -1,62 +0,0 @@
<HTML>
<TITLE>Mesa Release Notes</TITLE>
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
<BODY>
<body bgcolor="#eeeeee">
<H1>Mesa 7.7 Release Notes / date TBD</H1>
<p>
Mesa 7.7 is a new development release.
People who are concerned with stability and reliability should stick
with a previous release or wait for Mesa 7.7.1.
</p>
<p>
Mesa 7.7 implements the OpenGL 2.1 API, but the version reported by
glGetString(GL_VERSION) depends on the particular driver being used.
Some drivers don't support all the features required in OpenGL 2.1.
</p>
<p>
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
for DRI hardware acceleration.
</p>
<h2>MD5 checksums</h2>
<pre>
tbd
</pre>
<h2>New features</h2>
<ul>
<li>VMware "SVGA" Gallium driver. This is a Gallium3D driver which targets the
VMware virtual graphics device. It allows Linux OpenGL guest applications
to utilize the 3D graphics hardware of the host operating system.
<li>GL_ARB_draw_elements_base_vertex (supported in Intel i965 and software drivers)</li>
<li>GL_ARB_depth_clamp (supported in Intel i965 DRI and software drivers)</li>
<li>GL_NV_depth_clamp (supported in Intel i965 DRI and software drivers)</li>
<li>GL_ARB_provoking_vertex (same as GL_EXT_provoking_vertex)</li>
<li>Wavefront .obj file loader/viewer demo (progs/demos/objviewer)
</ul>
<h2>Bug fixes</h2>
<ul>
<li>Many assorted i965 driver fixes.
<li>Many r300-gallium driver fixes; this driver is now considered unstable-quality instead of experimental-quality.
</ul>
<h2>Changes</h2>
<ul>
<li>New Mesa texture/surface format infrastructure
<li>Removed some unused Mesa device driver hooks
</ul>
</body>
</html>

View File

@@ -13,7 +13,6 @@ The release notes summarize what's new or changed in each Mesa release.
</p>
<UL>
<LI><A HREF="relnotes-7.7.html">7.7 release notes</A>
<LI><A HREF="relnotes-7.6.1.html">7.6.1 release notes</A>
<LI><A HREF="relnotes-7.6.html">7.6 release notes</A>
<LI><A HREF="relnotes-7.5.2.html">7.5.2 release notes</A>

View File

@@ -39,8 +39,7 @@ Contents
<p>
The <b>MESA_GLSL</b> environment variable can be set to a comma-separated
list of keywords to control some aspects of the GLSL compiler and shader
execution. These are generally used for debugging.
list of keywords to control some aspects of the GLSL compiler:
</p>
<ul>
<li>dump - print GLSL shader code to stdout at link time
@@ -50,12 +49,6 @@ execution. These are generally used for debugging.
<li>nopt - disable compiler optimizations
<li>opt - force compiler optimizations
<li>uniform - print message to stdout when glUniform is called
<li>nopvert - force vertex shaders to be a simple shader that just transforms
the vertex position with ftransform() and passes through the color and
texcoord[0] attributes.
<li>nopfrag - force fragment shader to be a simple shader that passes
through the color attribute.
<li>useprog - log glUseProgram calls to stderr
</ul>
<p>
Example: export MESA_GLSL=dump,nopt

View File

@@ -10,5 +10,4 @@ SConscript([
'vpglsl/SConscript',
'fp/SConscript',
'wgl/SConscript',
'perf/SConscript',
])

View File

@@ -26,7 +26,6 @@ static int Scissor = 0;
static float Xzoom, Yzoom;
static GLboolean DrawFront = GL_FALSE;
static GLboolean Dither = GL_TRUE;
static GLboolean Invert = GL_FALSE;
static void Reset( void )
@@ -60,15 +59,6 @@ static void Display( void )
if (Scissor)
glEnable(GL_SCISSOR_TEST);
if (Invert) {
glPixelTransferf(GL_RED_SCALE, -1.0);
glPixelTransferf(GL_GREEN_SCALE, -1.0);
glPixelTransferf(GL_BLUE_SCALE, -1.0);
glPixelTransferf(GL_RED_BIAS, 1.0);
glPixelTransferf(GL_GREEN_BIAS, 1.0);
glPixelTransferf(GL_BLUE_BIAS, 1.0);
}
/* draw copy */
glPixelZoom(Xzoom, Yzoom);
glWindowPos2iARB(Xpos, Ypos);
@@ -77,15 +67,6 @@ static void Display( void )
glDisable(GL_SCISSOR_TEST);
if (Invert) {
glPixelTransferf(GL_RED_SCALE, 1.0);
glPixelTransferf(GL_GREEN_SCALE, 1.0);
glPixelTransferf(GL_BLUE_SCALE, 1.0);
glPixelTransferf(GL_RED_BIAS, 0.0);
glPixelTransferf(GL_GREEN_BIAS, 0.0);
glPixelTransferf(GL_BLUE_BIAS, 0.0);
}
if (DrawFront)
glFinish();
else
@@ -124,9 +105,6 @@ static void Key( unsigned char key, int x, int y )
else
glDisable(GL_DITHER);
break;
case 'i':
Invert = !Invert;
break;
case 's':
Scissor = !Scissor;
break;

View File

@@ -58,9 +58,6 @@ static GLint ClampIndex = 0;
static GLboolean supportFBO = GL_FALSE;
static GLboolean supportSeamless = GL_FALSE;
static GLboolean seamless = GL_FALSE;
static GLuint TexObj = 0;
static GLint T0 = 0;
static GLint Frames = 0;
static struct {
@@ -285,20 +282,6 @@ static void draw( void )
glPopMatrix();
glutSwapBuffers();
Frames++;
{
GLint t = glutGet(GLUT_ELAPSED_TIME);
if (t - T0 >= 5000) {
GLfloat seconds = (t - T0) / 1000.0;
GLfloat fps = Frames / seconds;
printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps);
fflush(stdout);
T0 = t;
Frames = 0;
}
}
}
@@ -560,10 +543,6 @@ static void init( GLboolean useImageFiles )
printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER));
glGenTextures(1, &TexObj);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, TexObj);
if (useImageFiles) {
load_envmaps();
}

View File

@@ -938,14 +938,7 @@ reshape(int width, int height)
static void
init_fbotexture()
{
static const GLenum depthFormats[] = {
GL_DEPTH_COMPONENT,
GL_DEPTH_COMPONENT16,
GL_DEPTH_COMPONENT32
};
static int numDepthFormats = sizeof(depthFormats) / sizeof(depthFormats[0]);
GLint i;
GLenum stat;
/* gen framebuffer id, delete it, do some assertions, just for testing */
glGenFramebuffersEXT(1, &MyFB);
@@ -976,31 +969,18 @@ init_fbotexture()
/* make depth renderbuffer */
glGenRenderbuffersEXT(1, &DepthRB);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB);
/* we may have to try several formats */
for (i = 0; i < numDepthFormats; i++) {
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, depthFormats[i],
TexWidth, TexHeight);
CheckError(__LINE__);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, DepthRB);
CheckError(__LINE__);
stat = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (stat == GL_FRAMEBUFFER_COMPLETE_EXT) {
break;
}
}
if (stat != GL_FRAMEBUFFER_COMPLETE_EXT) {
fprintf(stderr, "Error: unable to get usable FBO combination!\n");
exit(1);
}
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
TexWidth, TexHeight);
CheckError(__LINE__);
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i);
GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i);
CheckError(__LINE__);
printf("Depth renderbuffer size = %d bits\n", i);
/* attach DepthRB to MyFB */
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, DepthRB);
CheckError(__LINE__);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
/*

View File

@@ -25,6 +25,7 @@
*/
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <GL/glut.h>
@@ -129,8 +130,10 @@ Clear_Buffers ()
static void
LoadTriplet (TDA A)
{
int result;
Clear_Buffers ();
fscanf (mainfile, "%s %s %s %s", Buf1, Buf2, Buf3, Buf4);
result = fscanf (mainfile, "%s %s %s %s", Buf1, Buf2, Buf3, Buf4);
assert(result != EOF);
A[0] = atof (Buf2);
A[1] = atof (Buf3);
A[2] = atof (Buf4);
@@ -140,8 +143,10 @@ LoadTriplet (TDA A)
static void
LoadReal (float *a)
{
int result;
Clear_Buffers ();
fscanf (mainfile, "%s %s", Buf1, Buf2);
result = fscanf (mainfile, "%s %s", Buf1, Buf2);
assert(result != EOF);
*a = atof (Buf2);
}
@@ -149,8 +154,10 @@ LoadReal (float *a)
static void
LoadInteger (int *a)
{
int result;
Clear_Buffers ();
fscanf (mainfile, "%s %s", Buf1, Buf2);
result = fscanf (mainfile, "%s %s", Buf1, Buf2);
assert(result != EOF);
*a = atoi (Buf2);
}
@@ -158,8 +165,10 @@ LoadInteger (int *a)
static void
LoadText (char *a)
{
int result;
Clear_Buffers ();
fscanf (mainfile, "%s %s", Buf1, Buf2);
result = fscanf (mainfile, "%s %s", Buf1, Buf2);
assert(result != EOF);
strcpy (a, Buf2);
}
@@ -177,8 +186,10 @@ getdata (char filename[])
do
{
int result;
Clear_Buffers ();
fscanf (mainfile, "%s", Buf1);
result = fscanf (mainfile, "%s", Buf1);
(void) result;
if (ferror (mainfile))
{
printf ("\nError opening file !\n");

View File

@@ -132,9 +132,11 @@ static void read_surface( char *filename )
numverts = 0;
while (!feof(f) && numverts<maxverts) {
fscanf( f, "%f %f %f %f %f %f",
&data[numverts][0], &data[numverts][1], &data[numverts][2],
&data[numverts][3], &data[numverts][4], &data[numverts][5] );
int result;
result = fscanf( f, "%f %f %f %f %f %f",
&data[numverts][0], &data[numverts][1], &data[numverts][2],
&data[numverts][3], &data[numverts][4], &data[numverts][5] );
(void) result;
numverts++;
}
numverts--;

View File

@@ -43,7 +43,6 @@ static GLboolean Anim = GL_TRUE;
static GLint Bias = 0, BiasStepSign = +1; /* ints avoid fp precision problem */
static GLint BiasMin = -400, BiasMax = 400;
static int win = 0;
static GLuint TexObj = 0;
static void
@@ -215,9 +214,6 @@ static void Init( void )
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &TexObj);
glBindTexture(GL_TEXTURE_2D, TexObj);
if (glutExtensionSupported("GL_SGIS_generate_mipmap")) {
/* test auto mipmap generation */
GLint width, height, i;

View File

@@ -887,6 +887,5 @@ int main(int argc, char **argv)
glutIdleFunc( idle_ );
glutDisplayFunc( draw );
glutMainLoop();
return 0;
}

View File

@@ -27,8 +27,6 @@
#define ANIMATE 10
#define QUIT 100
static GLint T0 = 0;
static GLint Frames = 0;
static GLboolean Animate = GL_TRUE;
static GLint NumUnits = 1;
static GLboolean TexEnabled[8];
@@ -107,20 +105,6 @@ static void Display( void )
glPopMatrix();
glutSwapBuffers();
Frames++;
{
GLint t = glutGet(GLUT_ELAPSED_TIME);
if (t - T0 >= 5000) {
GLfloat seconds = (t - T0) / 1000.0;
GLfloat fps = Frames / seconds;
printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps);
fflush(stdout);
T0 = t;
Frames = 0;
}
}
}

View File

@@ -8,6 +8,7 @@
* based on a Mikael SkiZoWalker's (MoDEL) / France (Skizo@Hol.Fr) demo
*/
#include <assert.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
@@ -559,12 +560,14 @@ loadpic(void)
FILE *FilePic;
int i, tmp;
GLenum gluerr;
size_t result;
if ((FilePic = fopen("terrain.dat", "r")) == NULL) {
fprintf(stderr, "Error loading terrain.dat\n");
exit(-1);
}
fread(bufferter, 256 * 256, 1, FilePic);
result = fread(bufferter, 256 * 256, 1, FilePic);
assert(result == 1);
fclose(FilePic);
for (i = 0; i < (256 * 256); i++) {

View File

@@ -57,7 +57,7 @@ Idle(void)
{
Xrot = glutGet(GLUT_ELAPSED_TIME) * 0.02;
Yrot = glutGet(GLUT_ELAPSED_TIME) * 0.04;
/*Zrot += 2.0;*/
/* Zrot += 2.0; */
glutPostRedisplay();
}

View File

@@ -55,7 +55,7 @@ main(int argc, char *argv[])
EGLint count, chosenMode;
EGLint width = 0, height = 0;
d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915");
assert(d);
if (!eglInitialize(d, &maj, &min)) {

View File

@@ -127,11 +127,12 @@ static void run(EGLDisplay dpy, EGLSurface surf, int ttr)
double st = current_time();
double ct = st;
int frames = 0;
GLfloat seconds, fps;
while (ct - st < ttr)
{
ct = current_time();
double tt = current_time();
double dt = tt - ct;
ct = tt;
draw();
@@ -140,8 +141,8 @@ static void run(EGLDisplay dpy, EGLSurface surf, int ttr)
frames++;
}
seconds = ct - st;
fps = frames / seconds;
GLfloat seconds = ct - st;
GLfloat fps = frames / seconds;
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
}
@@ -173,7 +174,7 @@ int main(int argc, char *argv[])
}
/* DBR : Create EGL context/surface etc */
d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915");
assert(d);
if (!eglInitialize(d, &maj, &min)) {

View File

@@ -274,10 +274,10 @@ draw(void)
static void
reshape(int width, int height)
{
GLfloat h = (GLfloat) height / (GLfloat) width;
glViewport(0, 0, (GLint) width, (GLint) height);
GLfloat h = (GLfloat) height / (GLfloat) width;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
@@ -333,8 +333,6 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
double st = current_time();
double ct = st;
int frames = 0;
GLfloat seconds, fps;
while (ct - st < ttr)
{
double tt = current_time();
@@ -354,8 +352,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
frames++;
}
seconds = ct - st;
fps = frames / seconds;
GLfloat seconds = ct - st;
GLfloat fps = frames / seconds;
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
}
@@ -387,7 +385,7 @@ main(int argc, char *argv[])
}
/* DBR : Create EGL context/surface etc */
d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915");
assert(d);
if (!eglInitialize(d, &major, &minor)) {

View File

@@ -95,6 +95,9 @@ static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
static GLint gear1, gear2, gear3;
static GLfloat angle = 0.0;
static GLboolean fullscreen = GL_FALSE; /* Create a single fullscreen window */
/*
*
* Draw a gear wheel. You'll probably want to call this function when
@@ -324,235 +327,122 @@ init(void)
}
struct egl_manager {
EGLNativeDisplayType xdpy;
EGLNativeWindowType xwin;
EGLNativePixmapType xpix;
EGLDisplay dpy;
EGLConfig conf;
EGLContext ctx;
EGLSurface win;
EGLSurface pix;
EGLSurface pbuf;
EGLBoolean verbose;
EGLint major, minor;
};
static struct egl_manager *
egl_manager_new(EGLNativeDisplayType xdpy, const EGLint *attrib_list,
EGLBoolean verbose)
/*
* Create an RGB, double-buffered X window.
* Return the window and context handles.
*/
static void
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
const char *name,
int x, int y, int width, int height,
Window *winRet,
EGLContext *ctxRet,
EGLSurface *surfRet)
{
struct egl_manager *eman;
const char *ver;
EGLint num_conf;
static const EGLint attribs[] = {
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
/*EGL_DOUBLEBUFFER,*/
EGL_DEPTH_SIZE, 1,
EGL_NONE
};
eman = calloc(1, sizeof(*eman));
if (!eman)
return NULL;
eman->verbose = verbose;
eman->xdpy = xdpy;
eman->dpy = eglGetDisplay(eman->xdpy);
if (eman->dpy == EGL_NO_DISPLAY) {
printf("eglGetDisplay() failed\n");
free(eman);
return NULL;
}
if (!eglInitialize(eman->dpy, &eman->major, &eman->minor)) {
printf("eglInitialize() failed\n");
free(eman);
return NULL;
}
ver = eglQueryString(eman->dpy, EGL_VERSION);
printf("EGL_VERSION = %s\n", ver);
if (!eglChooseConfig(eman->dpy, attrib_list, &eman->conf, 1, &num_conf) ||
!num_conf) {
printf("eglChooseConfig() failed\n");
eglTerminate(eman->dpy);
free(eman);
return NULL;
}
eman->ctx = eglCreateContext(eman->dpy, eman->conf, EGL_NO_CONTEXT, NULL);
if (eman->ctx == EGL_NO_CONTEXT) {
printf("eglCreateContext() failed\n");
eglTerminate(eman->dpy);
free(eman);
return NULL;
}
return eman;
}
static EGLBoolean
egl_manager_create_window(struct egl_manager *eman, const char *name,
EGLint w, EGLint h, EGLBoolean need_surface,
EGLBoolean fullscreen, const EGLint *attrib_list)
{
XVisualInfo vinfo_template, *vinfo = NULL;
EGLint val, num_vinfo;
Window root;
XSetWindowAttributes attrs;
int scrnum;
XSetWindowAttributes attr;
unsigned long mask;
EGLint x = 0, y = 0;
Window root;
Window win;
XVisualInfo *visInfo, visTemplate;
int num_visuals;
EGLContext ctx;
EGLConfig config;
EGLint num_configs, vid;
if (!eglGetConfigAttrib(eman->dpy, eman->conf,
EGL_NATIVE_VISUAL_ID, &val)) {
printf("eglGetConfigAttrib() failed\n");
return EGL_FALSE;
}
if (val) {
vinfo_template.visualid = (VisualID) val;
vinfo = XGetVisualInfo(eman->xdpy, VisualIDMask, &vinfo_template, &num_vinfo);
}
/* try harder if window surface is not needed */
if (!vinfo && !need_surface &&
eglGetConfigAttrib(eman->dpy, eman->conf, EGL_BUFFER_SIZE, &val)) {
if (val == 32)
val = 24;
vinfo_template.depth = val;
vinfo = XGetVisualInfo(eman->xdpy, VisualDepthMask, &vinfo_template, &num_vinfo);
}
scrnum = DefaultScreen( x_dpy );
root = RootWindow( x_dpy, scrnum );
if (!vinfo) {
printf("XGetVisualInfo() failed\n");
return EGL_FALSE;
}
root = DefaultRootWindow(eman->xdpy);
if (fullscreen) {
x = y = 0;
w = DisplayWidth(eman->xdpy, DefaultScreen(eman->xdpy));
h = DisplayHeight(eman->xdpy, DefaultScreen(eman->xdpy));
x = 0; y = 0;
width = DisplayWidth( x_dpy, scrnum );
height = DisplayHeight( x_dpy, scrnum );
}
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
printf("Error: couldn't get an EGL visual config\n");
exit(1);
}
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
printf("Error: eglGetConfigAttrib() failed\n");
exit(1);
}
/* The X window visual must match the EGL config */
visTemplate.visualid = vid;
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
if (!visInfo) {
printf("Error: couldn't get X visual\n");
exit(1);
}
/* window attributes */
attrs.background_pixel = 0;
attrs.border_pixel = 0;
attrs.colormap = XCreateColormap(eman->xdpy, root, vinfo->visual, AllocNone);
attrs.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
attrs.override_redirect = fullscreen;
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
attr.override_redirect = fullscreen;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
eman->xwin = XCreateWindow(eman->xdpy, root, x, y, w, h,
0, vinfo->depth, InputOutput,
vinfo->visual, mask, &attrs);
XFree(vinfo);
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
0, visInfo->depth, InputOutput,
visInfo->visual, mask, &attr );
/* set hints and properties */
{
XSizeHints sizehints;
sizehints.x = x;
sizehints.y = y;
sizehints.width = w;
sizehints.height = h;
sizehints.width = width;
sizehints.height = height;
sizehints.flags = USSize | USPosition;
XSetNormalHints(eman->xdpy, eman->xwin, &sizehints);
XSetStandardProperties(eman->xdpy, eman->xwin, name, name,
None, (char **)NULL, 0, &sizehints);
XSetNormalHints(x_dpy, win, &sizehints);
XSetStandardProperties(x_dpy, win, name, name,
None, (char **)NULL, 0, &sizehints);
}
if (need_surface) {
eman->win = eglCreateWindowSurface(eman->dpy, eman->conf,
eman->xwin, attrib_list);
if (eman->win == EGL_NO_SURFACE) {
printf("eglCreateWindowSurface() failed\n");
XDestroyWindow(eman->xdpy, eman->xwin);
eman->xwin = None;
return EGL_FALSE;
}
eglBindAPI(EGL_OPENGL_API);
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
if (!ctx) {
printf("Error: glXCreateContext failed\n");
exit(1);
}
XMapWindow(eman->xdpy, eman->xwin);
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
return EGL_TRUE;
XFree(visInfo);
*winRet = win;
*ctxRet = ctx;
}
static EGLBoolean
egl_manager_create_pixmap(struct egl_manager *eman, EGLNativeWindowType xwin,
EGLBoolean need_surface, const EGLint *attrib_list)
{
XWindowAttributes attrs;
if (!XGetWindowAttributes(eman->xdpy, xwin, &attrs)) {
printf("XGetWindowAttributes() failed\n");
return EGL_FALSE;
}
eman->xpix = XCreatePixmap(eman->xdpy, xwin,
attrs.width, attrs.height, attrs.depth);
if (need_surface) {
eman->pix = eglCreatePixmapSurface(eman->dpy, eman->conf,
eman->xpix, attrib_list);
if (eman->pix == EGL_NO_SURFACE) {
printf("eglCreatePixmapSurface() failed\n");
XFreePixmap(eman->xdpy, eman->xpix);
eman->xpix = None;
return EGL_FALSE;
}
}
return EGL_TRUE;
}
static EGLBoolean
egl_manager_create_pbuffer(struct egl_manager *eman, const EGLint *attrib_list)
{
eman->pbuf = eglCreatePbufferSurface(eman->dpy, eman->conf, attrib_list);
if (eman->pbuf == EGL_NO_SURFACE) {
printf("eglCreatePbufferSurface() failed\n");
return EGL_FALSE;
}
return EGL_TRUE;
}
static void
egl_manager_destroy(struct egl_manager *eman)
event_loop(Display *dpy, Window win,
EGLDisplay egl_dpy, EGLSurface egl_surf)
{
eglMakeCurrent(eman->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglTerminate(eman->dpy);
if (eman->xwin != None)
XDestroyWindow(eman->xdpy, eman->xwin);
if (eman->xpix != None)
XFreePixmap(eman->xdpy, eman->xpix);
free(eman);
}
static void
event_loop(struct egl_manager *eman, EGLint surface_type, EGLint w, EGLint h)
{
GC gc = XCreateGC(eman->xdpy, eman->xwin, 0, NULL);
EGLint orig_w = w, orig_h = h;
if (surface_type == EGL_PBUFFER_BIT)
printf("there will be no screen update if "
"eglCopyBuffers() is not implemented\n");
while (1) {
while (XPending(eman->xdpy) > 0) {
while (XPending(dpy) > 0) {
XEvent event;
XNextEvent(eman->xdpy, &event);
XNextEvent(dpy, &event);
switch (event.type) {
case Expose:
case Expose:
/* we'll redraw below */
break;
case ConfigureNotify:
w = event.xconfigure.width;
h = event.xconfigure.height;
if (surface_type == EGL_WINDOW_BIT)
reshape(w, h);
break;
break;
case ConfigureNotify:
reshape(event.xconfigure.width, event.xconfigure.height);
break;
case KeyPress:
{
char buffer[10];
@@ -586,7 +476,6 @@ event_loop(struct egl_manager *eman, EGLint surface_type, EGLint w, EGLint h)
static int frames = 0;
static double tRot0 = -1.0, tRate0 = -1.0;
double dt, t = current_time();
int x, y;
if (tRot0 < 0.0)
tRot0 = t;
dt = t - tRot0;
@@ -598,25 +487,7 @@ event_loop(struct egl_manager *eman, EGLint surface_type, EGLint w, EGLint h)
angle -= 3600.0;
draw();
switch (surface_type) {
case EGL_WINDOW_BIT:
eglSwapBuffers(eman->dpy, eman->win);
break;
case EGL_PBUFFER_BIT:
eglWaitClient();
if (!eglCopyBuffers(eman->xdpy, eman->pbuf, eman->xpix))
break;
/* fall through */
case EGL_PIXMAP_BIT:
eglWaitClient();
for (x = 0; x < w; x += orig_w) {
for (y = 0; y < h; y += orig_h) {
XCopyArea(eman->xdpy, eman->xpix, eman->xwin, gc,
0, 0, orig_w, orig_h, x, y);
}
}
break;
}
eglSwapBuffers(egl_dpy, egl_surf);
frames++;
@@ -632,8 +503,6 @@ event_loop(struct egl_manager *eman, EGLint surface_type, EGLint w, EGLint h)
}
}
}
XFreeGC(eman->xdpy, gc);
}
@@ -644,8 +513,6 @@ usage(void)
printf(" -display <displayname> set the display to run on\n");
printf(" -fullscreen run in fullscreen mode\n");
printf(" -info display OpenGL renderer info\n");
printf(" -pixmap use pixmap surface\n");
printf(" -pbuffer use pbuffer surface\n");
}
@@ -654,23 +521,15 @@ main(int argc, char *argv[])
{
const int winWidth = 300, winHeight = 300;
Display *x_dpy;
Window win;
EGLSurface egl_surf;
EGLContext egl_ctx;
EGLDisplay egl_dpy;
char *dpyName = NULL;
struct egl_manager *eman;
EGLint attribs[] = {
EGL_SURFACE_TYPE, 0, /* filled later */
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
EGL_DEPTH_SIZE, 1,
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
EGL_NONE
};
char win_title[] = "xeglgears (window/pixmap/pbuffer)";
EGLint surface_type = EGL_WINDOW_BIT;
GLboolean printInfo = GL_FALSE;
GLboolean fullscreen = GL_FALSE;
EGLBoolean ret;
EGLint egl_major, egl_minor;
int i;
const char *s;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-display") == 0) {
@@ -683,21 +542,12 @@ main(int argc, char *argv[])
else if (strcmp(argv[i], "-fullscreen") == 0) {
fullscreen = GL_TRUE;
}
else if (strcmp(argv[i], "-pixmap") == 0) {
surface_type = EGL_PIXMAP_BIT;
}
else if (strcmp(argv[i], "-pbuffer") == 0) {
surface_type = EGL_PBUFFER_BIT;
}
else {
usage();
return -1;
}
}
/* set surface type */
attribs[1] = surface_type;
x_dpy = XOpenDisplay(dpyName);
if (!x_dpy) {
printf("Error: couldn't open display %s\n",
@@ -705,61 +555,27 @@ main(int argc, char *argv[])
return -1;
}
eglBindAPI(EGL_OPENGL_API);
eman = egl_manager_new(x_dpy, attribs, printInfo);
if (!eman) {
XCloseDisplay(x_dpy);
egl_dpy = eglGetDisplay(x_dpy);
if (!egl_dpy) {
printf("Error: eglGetDisplay() failed\n");
return -1;
}
snprintf(win_title, sizeof(win_title), "xeglgears (%s)",
(surface_type == EGL_WINDOW_BIT) ? "window" :
(surface_type == EGL_PIXMAP_BIT) ? "pixmap" : "pbuffer");
/* create surface(s) */
switch (surface_type) {
case EGL_WINDOW_BIT:
ret = egl_manager_create_window(eman, win_title, winWidth, winHeight,
EGL_TRUE, fullscreen, NULL);
if (ret)
ret = eglMakeCurrent(eman->dpy, eman->win, eman->win, eman->ctx);
break;
case EGL_PIXMAP_BIT:
ret = (egl_manager_create_window(eman, win_title, winWidth, winHeight,
EGL_FALSE, fullscreen, NULL) &&
egl_manager_create_pixmap(eman, eman->xwin,
EGL_TRUE, NULL));
if (ret)
ret = eglMakeCurrent(eman->dpy, eman->pix, eman->pix, eman->ctx);
break;
case EGL_PBUFFER_BIT:
{
EGLint pbuf_attribs[] = {
EGL_WIDTH, winWidth,
EGL_HEIGHT, winHeight,
EGL_NONE
};
ret = (egl_manager_create_window(eman, win_title, winWidth, winHeight,
EGL_FALSE, fullscreen, NULL) &&
egl_manager_create_pixmap(eman, eman->xwin,
EGL_FALSE, NULL) &&
egl_manager_create_pbuffer(eman, pbuf_attribs));
if (ret)
ret = eglMakeCurrent(eman->dpy, eman->pbuf, eman->pbuf, eman->ctx);
}
break;
default:
ret = EGL_FALSE;
break;
}
if (!ret) {
egl_manager_destroy(eman);
XCloseDisplay(x_dpy);
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
printf("Error: eglInitialize() failed\n");
return -1;
}
s = eglQueryString(egl_dpy, EGL_VERSION);
printf("EGL_VERSION = %s\n", s);
make_x_window(x_dpy, egl_dpy,
"glxgears", 0, 0, winWidth, winHeight,
&win, &egl_ctx, &egl_surf);
XMapWindow(x_dpy, win);
eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx);
if (printInfo) {
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
@@ -774,13 +590,18 @@ main(int argc, char *argv[])
*/
reshape(winWidth, winHeight);
event_loop(eman, surface_type, winWidth, winHeight);
event_loop(x_dpy, win, egl_dpy, egl_surf);
glDeleteLists(gear1, 1);
glDeleteLists(gear2, 1);
glDeleteLists(gear3, 1);
egl_manager_destroy(eman);
eglDestroyContext(egl_dpy, egl_ctx);
eglDestroySurface(egl_dpy, egl_surf);
eglTerminate(egl_dpy);
XDestroyWindow(x_dpy, win);
XCloseDisplay(x_dpy);
return 0;

View File

@@ -1,6 +0,0 @@
!!ARBfp1.0
TEMP R0;
MOV R0, fragment.color;
ADD_SAT R0, R0, R0;
MUL result.color, {0.5}.x, R0;
END

View File

@@ -1,6 +0,0 @@
!!ARBfp1.0
TEMP R0;
MOV R0, fragment.color;
MOV R0, R0.zyxw;
MOV result.color, R0;
END

View File

@@ -1,6 +0,0 @@
!!ARBfp1.0
TEMP R0;
MOV R0, fragment.color;
MUL R0, R0.zyxw, fragment.color;
MOV result.color, R0;
END

View File

@@ -369,9 +369,12 @@ InitPrograms(void)
static void
InitGL(void)
{
if (!ShadersSupported())
exit(1);
const char *version = (const char *) glGetString(GL_VERSION);
if (version[0] != '2' || version[1] != '.') {
printf("Warning: this program expects OpenGL 2.0\n");
/*exit(1);*/
}
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
printf("Usage:\n");
printf(" a - toggle arrays vs. immediate mode rendering\n");

View File

@@ -627,7 +627,7 @@ Init(void)
NumAttribs = GetAttribs(Program, Attribs);
PrintAttribs(Attribs);
/*assert(glGetError() == 0);*/
/* assert(glGetError() == 0); */
glClearColor(0.4f, 0.4f, 0.8f, 0.0f);

View File

@@ -310,10 +310,8 @@ MakeMipmap(void)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
/*
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 5);
*/
/* glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4); */
/* glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 5); */
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#undef SZ

View File

@@ -400,8 +400,11 @@ InitPrograms(void)
static void
Init(GLboolean useImageFiles)
{
if (!ShadersSupported()) {
exit(1);
const char *version = (const char *) glGetString(GL_VERSION);
if (version[0] != '2' || version[1] != '.') {
printf("Warning: this program expects OpenGL 2.0\n");
/*exit(1);*/
}
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));

View File

@@ -1,161 +0,0 @@
# Exported from Wings 3D 0.99.03
# Top flaps
newmtl BottomWing
Ns 100.0
d 1.0
illum 2
Kd 1.0 0.0 0.0
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd TopBotMap.rgb
newmtl CompBall_auv
Ns 100.0
d 1.0
illum 2
Kd 1.0 1.0 1.0
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd CompBall_auv.rgb
newmtl EngMat1
Ns 100.0
d 1.0
illum 2
Kd 0.334 0.334 0.334
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
newmtl EngMat2
Ns 100.0
d 1.0
illum 2
Kd 0.78688 0.78688 0.78688
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
newmtl Fuselage_auv
Ns 100.0
d 1.0
illum 2
Kd 1.0 1.0 1.0
Ka 0.0 0.0 0.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd SidesMap.rgb
newmtl Glass
Ns 100.0
d 0.5
illum 2
#Kd 0.5533333333333333 1.0 1.0
Kd 1.0 1.0 1.0
#Ka 0.37333333333333335 0.68 1.0
Ka 0.0 0.0 0.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
newmtl Grip
Ns 100.0
d 1.0
illum 2
Kd 0.47386 0.47386 0.47386
Ka 0.6203799999999999 0.6203799999999999 0.6203799999999999
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
newmtl Interior
Ns 100.0
d 1.0
illum 2
Kd 0.70696 0.70696 0.70696
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
newmtl Prop
Ns 100.0
d 1.0
illum 2
Kd 1.0 1.0 0.6266666666666667
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd PropMap.rgb
# Rudder
newmtl Sides
Ns 100.0
d 1.0
illum 2
Kd 1.0 0.0 0.0
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd SidesMap.rgb
newmtl TailHoriz
Ns 100.0
d 1.0
illum 2
Kd 1.0 0.0 0.0
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd TopBotMap.rgb
# Top wing, bot wing, fuselage
newmtl TopWing
Ns 100.0
d 1.0
illum 2
Kd 1.0 1.0 1.0
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd TopBotMap.rgb
newmtl Wheels
Ns 100.0
d 1.0
illum 2
Kd 0.0 0.0 0.0
Ka 0.0 0.0 0.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd WheelsMap.rgb
newmtl cylinder58_auv
Ns 100.0
d 1.0
illum 2
Kd 1.0 1.0 1.0
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd cylinder58_auv.rgb
newmtl default
Ns 100.0
d 1.0
illum 2
Kd 0.0 1.0 1.0
Ka 0.0 1.0 1.0
Ks 0.0 1.0 1.0
Ke 0.0 0.0 0.0
newmtl gage_auv
Ns 100.0
d 1.0
illum 2
Kd 1.0 1.0 1.0
Ka 1.0 1.0 1.0
Ks 1.0 1.0 1.0
Ke 0.0 0.0 0.0
map_Kd gage_auv.rgb

File diff suppressed because it is too large Load Diff

View File

@@ -1,83 +0,0 @@
TOP = ../..
include $(TOP)/configs/current
INCDIR = $(TOP)/include
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) \
-l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
# using : to avoid APP_CC pointing to CC loop
CC := $(APP_CC)
CFLAGS := -I$(INCDIR) $(CFLAGS)
LDLIBS = $(LIBS)
SOURCES = \
glm.c \
glmdraw.c \
objview.c \
trackball.c \
skybox.c \
readtex.c \
shaderutil.c
HEADERS = \
extfuncs.h \
readtex.h \
shaderutil.h \
trackball.h
OBJS = $(SOURCES:.c=.o)
PROG = objview
.c.o:
$(CC) -c $(CFLAGS) $< -o $@
default: $(PROG)
$(PROG): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
$(OBJS): $(HEADERS)
### Extra dependencies
extfuncs.h: $(TOP)/progs/util/extfuncs.h
cp $< .
readtex.c: $(TOP)/progs/util/readtex.c
cp $< .
readtex.h: $(TOP)/progs/util/readtex.h
cp $< .
shaderutil.c: $(TOP)/progs/util/shaderutil.c
cp $< .
shaderutil.h: $(TOP)/progs/util/shaderutil.h
cp $< .
trackball.c: $(TOP)/progs/util/trackball.c
cp $< .
trackball.h: $(TOP)/progs/util/trackball.h
cp $< .
clean:
-rm -f $(PROG) $(OBJS)
-rm -f *.o *~
-rm -f extfuncs.h
-rm -f shaderutil.*
-rm -f trackball.*
-rm -f readtex.*
depend: $(SOURCES)
@$(MKDEP) $(MKDEP_OPTIONS) $(INCLUDE_DIRS) $(SOURCES) \
> /dev/null 2>/dev/null
-include depend

View File

@@ -1,23 +0,0 @@
This .obj viewer is based on the "smooth" program by Nate Robins
found in the Kilgard GLUT package.
The alpine sky box textures come from http://www.hazelwhorley.com/skyboxtex3_bitmaps.html
The bunny.obj and buddha.obj models come from Stanford.
The GreatLakesBiplaneHP.obj model comes from http://www.sharecg.com/v/25978/3D-Model/Great-Lakes-Biplane-Model
The bobcat.obj model comes from http://www.sharecg.com/v/24771/3D-Model/Bobcat,3d-studio-and-wavefront-objects
The .obj file reader code in glm.c isn't perfect. Not all .obj files are
parsed correctly. There are often mistakes in material-to-triangle assignments.
Mouse:
Left = rotate
Middle = scale
Right = menu
Keyboard:
See pop-up menu for keyboard shortcuts, or press 'h'.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,72 +0,0 @@
# Exported from Wings 3D 0.99.00b
newmtl black
Ns 48.6667
d 1.00000
illum 2
Kd 1.00000e-3 1.00000e-3 1.00000e-3
Ka 1.00000 1.00000 1.00000
Ks 1.00000 1.00000 1.00000
Ka 0.00000 0.00000 0.00000
Ks 0.00000 0.00000 0.00000
Ke 0.00000e+0 0.00000e+0 0.00000e+0
newmtl blanco
Ns 100.000
d 1.00000
illum 2
Kd 1.00000 1.00000 1.00000
Ka 0.620380 0.620380 0.620380
Ks 0.806860 0.806860 0.806860
Ke 1.00000e-3 1.00000e-3 1.00000e-3
newmtl blue
Ns 100.000
d 1.00000
illum 2
Kd 0.105111 0.125293 0.366667
Ka 1.00000 1.00000 1.00000
Ks 1.00000 1.00000 1.00000
Ka 0.00000 0.00000 0.00000
Ks 0.00000 0.00000 0.00000
Ke 0.00000e+0 0.00000e+0 0.00000e+0
newmtl default
Ns 100.000
d 1.00000
illum 2
Kd 1.00000 1.00000 1.00000
Ka 1.00000 1.00000 1.00000
Ks 1.00000 1.00000 1.00000
Ka 0.10000 0.10000 0.10000
Ks 0.50000 0.50000 0.500000
Ke 0.00000e+0 0.00000e+0 0.00000e+0
newmtl gre
Ns 100.000
d 1.00000
illum 2
Kd 0.200800 0.200800 0.200800
Ka 1.00000 1.00000 1.00000
Ks 1.00000 1.00000 1.00000
Ka 0.00000 0.00000 0.00000
Ks 0.00000 0.00000 0.00000
Ke 0.00000e+0 0.00000e+0 0.00000e+0
newmtl red
Ns 100.000
d 1.00000
illum 2
Kd 0.460000 0.00000e+0 0.00000e+0
Ka 0.00000 0.00000 0.00000
Ks 0.00000 0.00000 0.00000
Ke 0.00000e+0 0.00000e+0 0.00000e+0
newmtl rojo
Ns 100.000
d 1.00000
illum 2
Kd 0.700000 0.00000e+0 0.00000e+0
Ka 0.00000 0.00000 0.00000
Ks 0.00000 0.00000 0.00000
Ke 1.00000e-3 1.00000e-3 1.00000e-3

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,287 +0,0 @@
/*
* GLM library. Wavefront .obj file format reader/writer/manipulator.
*
* Written by Nate Robins, 1997.
* email: ndr@pobox.com
* www: http://www.pobox.com/~ndr
*/
#ifndef GLM_H
#define GLM_H
typedef unsigned int uint;
#ifndef M_PI
#define M_PI 3.14159265
#endif
/* defines */
#define GLM_NONE (0) /* render with only vertices */
#define GLM_FLAT (1 << 0) /* render with facet normals */
#define GLM_SMOOTH (1 << 1) /* render with vertex normals */
#define GLM_TEXTURE (1 << 2) /* render with texture coords */
#define GLM_COLOR (1 << 3) /* render with colors */
#define GLM_MATERIAL (1 << 4) /* render with materials */
/* structs */
/* GLMmaterial: Structure that defines a material in a model.
*/
typedef struct _GLMmaterial
{
char* name; /* name of material */
float diffuse[4]; /* diffuse component */
float ambient[4]; /* ambient component */
float specular[4]; /* specular component */
float emmissive[4]; /* emmissive component */
float shininess; /* specular exponent */
char *map_kd; /* diffuse texture map file */
uint texture_kd; /* diffuse texture map */
uint texture_ks; /* specular texture map */
int uDiffuse, uAmbient, uSpecular, uShininess, uDiffTex, uSpecTex;
uint prog;
} GLMmaterial;
/* GLMtriangle: Structure that defines a triangle in a model.
*/
typedef struct {
uint vindices[3]; /* array of triangle vertex indices */
uint nindices[3]; /* array of triangle normal indices */
uint tindices[3]; /* array of triangle texcoord indices*/
uint findex; /* index of triangle facet normal */
} GLMtriangle;
/* GLMgroup: Structure that defines a group in a model.
*/
typedef struct _GLMgroup {
char* name; /* name of this group */
uint numtriangles; /* number of triangles in this group */
uint* triangles; /* array of triangle indices */
uint material; /* index to material for group */
uint * triIndexes;
uint minIndex, maxIndex;
struct _GLMgroup* next; /* pointer to next group in model */
} GLMgroup;
/* GLMmodel: Structure that defines a model.
*/
typedef struct {
char* pathname; /* path to this model */
char* mtllibname; /* name of the material library */
uint numvertices; /* number of vertices in model */
float* vertices; /* array of vertices */
uint numnormals; /* number of normals in model */
float* normals; /* array of normals */
uint numtexcoords; /* number of texcoords in model */
float* texcoords; /* array of texture coordinates */
uint numfacetnorms; /* number of facetnorms in model */
float* facetnorms; /* array of facetnorms */
uint numtriangles; /* number of triangles in model */
GLMtriangle* triangles; /* array of triangles */
uint nummaterials; /* number of materials in model */
GLMmaterial* materials; /* array of materials */
uint numgroups; /* number of groups in model */
GLMgroup* groups; /* linked list of groups */
float position[3]; /* position of the model */
float scale;
uint vbo; /* OpenGL VBO for vertex data */
uint vertexSize; /* number of floats per vertex */
uint posOffset; /* offset of position within vertex, in bytes */
uint normOffset; /* offset of normal within vertex, in bytes */
uint texOffset; /* offset of texcoord within vertex, in bytes */
} GLMmodel;
/* public functions */
/* glmUnitize: "unitize" a model by translating it to the origin and
* scaling it to fit in a unit cube around the origin. Returns the
* scalefactor used.
*
* model - properly initialized GLMmodel structure
*/
float
glmUnitize(GLMmodel* model);
/* glmDimensions: Calculates the dimensions (width, height, depth) of
* a model.
*
* model - initialized GLMmodel structure
* dimensions - array of 3 floats (float dimensions[3])
*/
void
glmDimensions(GLMmodel* model, float* dimensions);
/* glmScale: Scales a model by a given amount.
*
* model - properly initialized GLMmodel structure
* scale - scalefactor (0.5 = half as large, 2.0 = twice as large)
*/
void
glmScale(GLMmodel* model, float scale);
/* glmReverseWinding: Reverse the polygon winding for all polygons in
* this model. Default winding is counter-clockwise. Also changes
* the direction of the normals.
*
* model - properly initialized GLMmodel structure
*/
void
glmReverseWinding(GLMmodel* model);
/* glmFacetNormals: Generates facet normals for a model (by taking the
* cross product of the two vectors derived from the sides of each
* triangle). Assumes a counter-clockwise winding.
*
* model - initialized GLMmodel structure
*/
void
glmFacetNormals(GLMmodel* model);
/* glmVertexNormals: Generates smooth vertex normals for a model.
* First builds a list of all the triangles each vertex is in. Then
* loops through each vertex in the the list averaging all the facet
* normals of the triangles each vertex is in. Finally, sets the
* normal index in the triangle for the vertex to the generated smooth
* normal. If the dot product of a facet normal and the facet normal
* associated with the first triangle in the list of triangles the
* current vertex is in is greater than the cosine of the angle
* parameter to the function, that facet normal is not added into the
* average normal calculation and the corresponding vertex is given
* the facet normal. This tends to preserve hard edges. The angle to
* use depends on the model, but 90 degrees is usually a good start.
*
* model - initialized GLMmodel structure
* angle - maximum angle (in degrees) to smooth across
*/
void
glmVertexNormals(GLMmodel* model, float angle);
/* glmLinearTexture: Generates texture coordinates according to a
* linear projection of the texture map. It generates these by
* linearly mapping the vertices onto a square.
*
* model - pointer to initialized GLMmodel structure
*/
void
glmLinearTexture(GLMmodel* model);
/* glmSpheremapTexture: Generates texture coordinates according to a
* spherical projection of the texture map. Sometimes referred to as
* spheremap, or reflection map texture coordinates. It generates
* these by using the normal to calculate where that vertex would map
* onto a sphere. Since it is impossible to map something flat
* perfectly onto something spherical, there is distortion at the
* poles. This particular implementation causes the poles along the X
* axis to be distorted.
*
* model - pointer to initialized GLMmodel structure
*/
void
glmSpheremapTexture(GLMmodel* model);
/* glmDelete: Deletes a GLMmodel structure.
*
* model - initialized GLMmodel structure
*/
void
glmDelete(GLMmodel* model);
/* glmReadOBJ: Reads a model description from a Wavefront .OBJ file.
* Returns a pointer to the created object which should be free'd with
* glmDelete().
*
* filename - name of the file containing the Wavefront .OBJ format data.
*/
GLMmodel*
glmReadOBJ(char* filename);
/* glmWriteOBJ: Writes a model description in Wavefront .OBJ format to
* a file.
*
* model - initialized GLMmodel structure
* filename - name of the file to write the Wavefront .OBJ format data to
* mode - a bitwise or of values describing what is written to the file
* GLM_NONE - write only vertices
* GLM_FLAT - write facet normals
* GLM_SMOOTH - write vertex normals
* GLM_TEXTURE - write texture coords
* GLM_FLAT and GLM_SMOOTH should not both be specified.
*/
void
glmWriteOBJ(GLMmodel* model, char* filename, uint mode);
/* glmDraw: Renders the model to the current OpenGL context using the
* mode specified.
*
* model - initialized GLMmodel structure
* mode - a bitwise OR of values describing what is to be rendered.
* GLM_NONE - render with only vertices
* GLM_FLAT - render with facet normals
* GLM_SMOOTH - render with vertex normals
* GLM_TEXTURE - render with texture coords
* GLM_FLAT and GLM_SMOOTH should not both be specified.
*/
void
glmDraw(GLMmodel* model, uint mode);
/* glmList: Generates and returns a display list for the model using
* the mode specified.
*
* model - initialized GLMmodel structure
* mode - a bitwise OR of values describing what is to be rendered.
* GLM_NONE - render with only vertices
* GLM_FLAT - render with facet normals
* GLM_SMOOTH - render with vertex normals
* GLM_TEXTURE - render with texture coords
* GLM_FLAT and GLM_SMOOTH should not both be specified.
*/
uint
glmList(GLMmodel* model, uint mode);
/* glmWeld: eliminate (weld) vectors that are within an epsilon of
* each other.
*
* model - initialized GLMmodel structure
* epsilon - maximum difference between vertices
* ( 0.00001 is a good start for a unitized model)
*
*/
void
glmWeld(GLMmodel* model, float epsilon);
void
glmReIndex(GLMmodel *model);
void
glmMakeVBOs(GLMmodel *model);
void
glmDrawVBO(GLMmodel *model);
void
glmPrint(const GLMmodel *model);
void
glmShaderMaterial(GLMmaterial *mat);
void
glmLoadTextures(GLMmodel *model);
void
glmSpecularTexture(GLMmodel *model, uint cubeTex);
#endif /* GLM_H */

View File

@@ -1,455 +0,0 @@
/* */
#define GL_GLEXT_PROTOTYPES
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "glm.h"
#include "readtex.h"
#include "shaderutil.h"
/* defines */
#define T(x) model->triangles[(x)]
/* glmDraw: Renders the model to the current OpenGL context using the
* mode specified.
*
* model - initialized GLMmodel structure
* mode - a bitwise OR of values describing what is to be rendered.
* GLM_NONE - render with only vertices
* GLM_FLAT - render with facet normals
* GLM_SMOOTH - render with vertex normals
* GLM_TEXTURE - render with texture coords
* GLM_COLOR - render with colors (color material)
* GLM_MATERIAL - render with materials
* GLM_COLOR and GLM_MATERIAL should not both be specified.
* GLM_FLAT and GLM_SMOOTH should not both be specified.
*/
GLvoid
glmDraw(GLMmodel* model, GLuint mode)
{
GLuint i;
GLMgroup* group;
assert(model);
assert(model->vertices);
/* do a bit of warning */
if (mode & GLM_FLAT && !model->facetnorms) {
printf("glmDraw() warning: flat render mode requested "
"with no facet normals defined.\n");
mode &= ~GLM_FLAT;
}
if (mode & GLM_SMOOTH && !model->normals) {
printf("glmDraw() warning: smooth render mode requested "
"with no normals defined.\n");
mode &= ~GLM_SMOOTH;
}
if (mode & GLM_TEXTURE && !model->texcoords) {
printf("glmDraw() warning: texture render mode requested "
"with no texture coordinates defined.\n");
mode &= ~GLM_TEXTURE;
}
if (mode & GLM_FLAT && mode & GLM_SMOOTH) {
printf("glmDraw() warning: flat render mode requested "
"and smooth render mode requested (using smooth).\n");
mode &= ~GLM_FLAT;
}
if (mode & GLM_COLOR && !model->materials) {
printf("glmDraw() warning: color render mode requested "
"with no materials defined.\n");
mode &= ~GLM_COLOR;
}
if (mode & GLM_MATERIAL && !model->materials) {
printf("glmDraw() warning: material render mode requested "
"with no materials defined.\n");
mode &= ~GLM_MATERIAL;
}
if (mode & GLM_COLOR && mode & GLM_MATERIAL) {
printf("glmDraw() warning: color and material render mode requested "
"using only material mode\n");
mode &= ~GLM_COLOR;
}
if (mode & GLM_COLOR)
glEnable(GL_COLOR_MATERIAL);
if (mode & GLM_MATERIAL)
glDisable(GL_COLOR_MATERIAL);
glPushMatrix();
glTranslatef(model->position[0], model->position[1], model->position[2]);
glBegin(GL_TRIANGLES);
group = model->groups;
while (group) {
if (mode & GLM_MATERIAL) {
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT,
model->materials[group->material].ambient);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,
model->materials[group->material].diffuse);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,
model->materials[group->material].specular);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS,
model->materials[group->material].shininess);
}
if (mode & GLM_COLOR) {
glColor3fv(model->materials[group->material].diffuse);
}
for (i = 0; i < group->numtriangles; i++) {
if (mode & GLM_FLAT)
glNormal3fv(&model->facetnorms[3 * T(group->triangles[i]).findex]);
if (mode & GLM_SMOOTH)
glNormal3fv(&model->normals[3 * T(group->triangles[i]).nindices[0]]);
if (mode & GLM_TEXTURE)
glTexCoord2fv(&model->texcoords[2*T(group->triangles[i]).tindices[0]]);
glVertex3fv(&model->vertices[3 * T(group->triangles[i]).vindices[0]]);
#if 0
printf("%f %f %f\n",
model->vertices[3 * T(group->triangles[i]).vindices[0] + X],
model->vertices[3 * T(group->triangles[i]).vindices[0] + Y],
model->vertices[3 * T(group->triangles[i]).vindices[0] + Z]);
#endif
if (mode & GLM_SMOOTH)
glNormal3fv(&model->normals[3 * T(group->triangles[i]).nindices[1]]);
if (mode & GLM_TEXTURE)
glTexCoord2fv(&model->texcoords[2*T(group->triangles[i]).tindices[1]]);
glVertex3fv(&model->vertices[3 * T(group->triangles[i]).vindices[1]]);
#if 0
printf("%f %f %f\n",
model->vertices[3 * T(group->triangles[i]).vindices[1] + X],
model->vertices[3 * T(group->triangles[i]).vindices[1] + Y],
model->vertices[3 * T(group->triangles[i]).vindices[1] + Z]);
#endif
if (mode & GLM_SMOOTH)
glNormal3fv(&model->normals[3 * T(group->triangles[i]).nindices[2]]);
if (mode & GLM_TEXTURE)
glTexCoord2fv(&model->texcoords[2*T(group->triangles[i]).tindices[2]]);
glVertex3fv(&model->vertices[3 * T(group->triangles[i]).vindices[2]]);
#if 0
printf("%f %f %f\n",
model->vertices[3 * T(group->triangles[i]).vindices[2] + X],
model->vertices[3 * T(group->triangles[i]).vindices[2] + Y],
model->vertices[3 * T(group->triangles[i]).vindices[2] + Z]);
#endif
}
group = group->next;
}
glEnd();
glPopMatrix();
}
void
glmMakeVBOs(GLMmodel *model)
{
uint bytes, vertexFloats, i;
float *buffer;
vertexFloats = 3;
model->posOffset = 0;
if (model->numnormals > 0) {
assert(model->numnormals == model->numvertices);
model->normOffset = vertexFloats * sizeof(GLfloat);
vertexFloats += 3;
}
if (model->numtexcoords > 0) {
assert(model->numtexcoords == model->numvertices);
model->texOffset = vertexFloats * sizeof(GLfloat);
vertexFloats += 2;
}
model->vertexSize = vertexFloats;
bytes = (model->numvertices + 1) * vertexFloats * sizeof(float);
buffer = (float *) malloc(bytes);
for (i = 0; i < model->numvertices; i++) {
/* copy vertex pos */
uint j = 0;
buffer[i * vertexFloats + j++] = model->vertices[i * 3 + 0];
buffer[i * vertexFloats + j++] = model->vertices[i * 3 + 1];
buffer[i * vertexFloats + j++] = model->vertices[i * 3 + 2];
if (model->numnormals > 0) {
buffer[i * vertexFloats + j++] = model->normals[i * 3 + 0];
buffer[i * vertexFloats + j++] = model->normals[i * 3 + 1];
buffer[i * vertexFloats + j++] = model->normals[i * 3 + 2];
}
if (model->numtexcoords > 0) {
buffer[i * vertexFloats + j++] = model->texcoords[i * 2 + 0];
buffer[i * vertexFloats + j++] = model->texcoords[i * 2 + 1];
}
}
glGenBuffersARB(1, &model->vbo);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, model->vbo);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, bytes, buffer, GL_STATIC_DRAW_ARB);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
free(buffer);
}
static void
_glmLoadTexture(GLMmaterial *mat)
{
if (mat->map_kd) {
GLint imgWidth, imgHeight;
GLenum imgFormat;
GLubyte *image = NULL;
glGenTextures(1, &mat->texture_kd);
image = LoadRGBImage( mat->map_kd, &imgWidth, &imgHeight, &imgFormat );
if (!image) {
/*fprintf(stderr, "Couldn't open texture %s\n", mat->map_kd);*/
free(mat->map_kd);
mat->map_kd = NULL;
mat->texture_kd = 0;
return;
}
if (0)
printf("load texture %s %d x %d\n", mat->map_kd, imgWidth, imgHeight);
glBindTexture(GL_TEXTURE_2D, mat->texture_kd);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, imgWidth, imgHeight,
imgFormat, GL_UNSIGNED_BYTE, image);
free(image);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
}
}
void
glmLoadTextures(GLMmodel *model)
{
uint i;
for (i = 0; i < model->nummaterials; i++) {
GLMmaterial *mat = &model->materials[i];
_glmLoadTexture(mat);
}
}
void
glmDrawVBO(GLMmodel *model)
{
GLMgroup* group;
assert(model->vbo);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, model->vbo);
glVertexPointer(3, GL_FLOAT, model->vertexSize * sizeof(float),
(void *) model->posOffset);
glEnableClientState(GL_VERTEX_ARRAY);
if (model->numnormals > 0) {
glNormalPointer(GL_FLOAT, model->vertexSize * sizeof(float),
(void *) model->normOffset);
glEnableClientState(GL_NORMAL_ARRAY);
}
if (model->numtexcoords > 0) {
glTexCoordPointer(2, GL_FLOAT, model->vertexSize * sizeof(float),
(void *) model->texOffset);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}
glPushMatrix();
glTranslatef(model->position[0], model->position[1], model->position[2]);
glScalef(model->scale, model->scale, model->scale);
for (group = model->groups; group; group = group->next) {
if (group->numtriangles > 0) {
glmShaderMaterial(&model->materials[group->material]);
glDrawRangeElements(GL_TRIANGLES,
group->minIndex, group->maxIndex,
3 * group->numtriangles,
GL_UNSIGNED_INT, group->triIndexes);
}
}
glPopMatrix();
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
/* glmList: Generates and returns a display list for the model using
* the mode specified.
*
* model - initialized GLMmodel structure
* mode - a bitwise OR of values describing what is to be rendered.
* GLM_NONE - render with only vertices
* GLM_FLAT - render with facet normals
* GLM_SMOOTH - render with vertex normals
* GLM_TEXTURE - render with texture coords
* GLM_COLOR - render with colors (color material)
* GLM_MATERIAL - render with materials
* GLM_COLOR and GLM_MATERIAL should not both be specified.
* GLM_FLAT and GLM_SMOOTH should not both be specified.
*/
GLuint
glmList(GLMmodel* model, GLuint mode)
{
GLuint list;
list = glGenLists(1);
glNewList(list, GL_COMPILE);
glmDraw(model, mode);
glEndList();
return list;
}
static const char *VertexShader =
"varying vec3 normal; \n"
"void main() { \n"
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \n"
" normal = gl_NormalMatrix * gl_Normal; \n"
" gl_TexCoord[0] = gl_MultiTexCoord0; \n"
"} \n";
/**
* Two %s substitutions:
* diffuse texture? true/false
* specular texture? true/false
*/
static const char *TexFragmentShader =
"uniform vec4 ambient, diffuse, specular; \n"
"uniform vec4 ambientLight, diffuseLight, specularLight; \n"
"uniform float shininess; \n"
"uniform sampler2D diffTex; \n"
"uniform samplerCube specTex; \n"
"varying vec3 normal; \n"
"\n"
"void main() \n"
"{ \n"
" vec4 diffTerm, specTerm; \n"
" float dotProd = max(dot(gl_LightSource[0].position.xyz, \n"
" normalize(normal)), 0.0);\n"
" float dotProd2 = max(dot(-gl_LightSource[0].position.xyz, \n"
" normalize(normal)), 0.0);\n"
" dotProd += dotProd2; \n"
" \n"
" diffTerm = diffuse * diffuseLight * dotProd; \n"
" if (%s) \n"
" diffTerm *= texture2D(diffTex, gl_TexCoord[0].st); \n"
" \n"
" specTerm = specular * specularLight * pow(dotProd, shininess); \n"
" if (%s) \n"
" specTerm *= textureCube(specTex, normal); \n"
" \n"
" gl_FragColor = ambient * ambientLight + diffTerm + specTerm; \n"
"} \n";
void
glmShaderMaterial(GLMmaterial *mat)
{
static const float ambientLight[4] = { 0.1, 0.1, 0.1, 0.0 };
static const float diffuseLight[4] = { 0.75, 0.75, 0.75, 1.0 };
static const float specularLight[4] = { 1.0, 1.0, 1.0, 0.0 };
if (!mat->prog) {
/* make shader now */
char newShader[10000];
GLuint vs, fs;
const char *diffuseTex = mat->texture_kd ? "true" : "false";
const char *specularTex = mat->texture_ks ? "true" : "false";
GLint uAmbientLight, uDiffuseLight, uSpecularLight;
/* replace %d with 0 or 1 */
sprintf(newShader, TexFragmentShader, diffuseTex, specularTex);
if (0)
printf("===== new shader =====\n%s\n============\n", newShader);
vs = CompileShaderText(GL_VERTEX_SHADER, VertexShader);
fs = CompileShaderText(GL_FRAGMENT_SHADER, newShader);
mat->prog = LinkShaders(vs, fs);
assert(mat->prog);
glUseProgram(mat->prog);
mat->uAmbient = glGetUniformLocation(mat->prog, "ambient");
mat->uDiffuse = glGetUniformLocation(mat->prog, "diffuse");
mat->uSpecular = glGetUniformLocation(mat->prog, "specular");
mat->uShininess = glGetUniformLocation(mat->prog, "shininess");
mat->uDiffTex = glGetUniformLocation(mat->prog, "diffTex");
mat->uSpecTex = glGetUniformLocation(mat->prog, "specTex");
uAmbientLight = glGetUniformLocation(mat->prog, "ambientLight");
uDiffuseLight = glGetUniformLocation(mat->prog, "diffuseLight");
uSpecularLight = glGetUniformLocation(mat->prog, "specularLight");
glUniform4fv(mat->uAmbient, 1, mat->ambient);
glUniform4fv(mat->uDiffuse, 1, mat->diffuse);
glUniform4fv(mat->uSpecular, 1, mat->specular);
glUniform1f(mat->uShininess, mat->shininess);
glUniform1i(mat->uDiffTex, 0);
glUniform1i(mat->uSpecTex, 1);
glUniform4fv(uAmbientLight, 1, ambientLight);
glUniform4fv(uDiffuseLight, 1, diffuseLight);
glUniform4fv(uSpecularLight, 1, specularLight);
}
glActiveTexture(GL_TEXTURE1);
if (mat->texture_ks)
glBindTexture(GL_TEXTURE_CUBE_MAP, mat->texture_ks);
else
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
glActiveTexture(GL_TEXTURE0);
if (mat->texture_kd)
glBindTexture(GL_TEXTURE_2D, mat->texture_kd);
else
glBindTexture(GL_TEXTURE_2D, 0);
if (mat->diffuse[3] < 1.0) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
else {
glDisable(GL_BLEND);
}
glUseProgram(mat->prog);
}
void
glmSpecularTexture(GLMmodel *model, uint cubeTex)
{
uint i;
for (i = 0; i < model->nummaterials; i++) {
model->materials[i].texture_ks = cubeTex;
}
}

View File

@@ -1,515 +0,0 @@
/*
* .obj file viewer based on "smooth" by Nate Robins, 1997
*
* Brian Paul
* 1 Oct 2009
*/
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <stdarg.h>
#include <GL/glew.h>
#include <GL/glut.h>
#include "glm.h"
#include "readtex.h"
#include "skybox.h"
#include "trackball.h"
static char *Model_file = NULL; /* name of the obect file */
static GLMmodel *Model;
static GLfloat Scale = 4.0; /* scaling factor */
static GLboolean Performance = GL_FALSE;
static GLboolean Stats = GL_FALSE;
static GLboolean Animate = GL_TRUE;
static GLuint SkyboxTex;
static GLboolean Skybox = GL_TRUE;
static GLboolean Cull = GL_TRUE;
static GLboolean WireFrame = GL_FALSE;
static GLenum FrontFace = GL_CCW;
static GLfloat Yrot = 0.0;
static GLint WinWidth = 1024, WinHeight = 768;
static GLuint NumInstances = 1;
typedef struct
{
float CurQuat[4];
float Distance;
/* When mouse is moving: */
GLboolean Rotating, Translating;
GLint StartX, StartY;
float StartDistance;
} ViewInfo;
static ViewInfo View;
static void
InitViewInfo(ViewInfo *view)
{
view->Rotating = GL_FALSE;
view->Translating = GL_FALSE;
view->StartX = view->StartY = 0;
view->Distance = 12.0;
view->StartDistance = 0.0;
view->CurQuat[0] = 0.0;
view->CurQuat[1] = 1.0;
view->CurQuat[2] = 0.0;
view->CurQuat[3] = 0.0;
}
/* text: general purpose text routine. draws a string according to
* format in a stroke font at x, y after scaling it by the scale
* specified (scale is in window-space (lower-left origin) pixels).
*
* x - position in x (in window-space)
* y - position in y (in window-space)
* scale - scale in pixels
* format - as in printf()
*/
static void
text(GLuint x, GLuint y, GLfloat scale, char* format, ...)
{
va_list args;
char buffer[255], *p;
GLfloat font_scale = 119.05 + 33.33;
va_start(args, format);
vsprintf(buffer, format, args);
va_end(args);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, glutGet(GLUT_WINDOW_WIDTH), 0, glutGet(GLUT_WINDOW_HEIGHT));
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glTranslatef(x, y, 0.0);
glScalef(scale/font_scale, scale/font_scale, scale/font_scale);
for(p = buffer; *p; p++)
glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);
glPopAttrib();
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
static float
ComputeFPS(void)
{
static double t0 = -1.0;
static int frames = 0;
double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
static float fps = 0;
frames++;
if (t0 < 0.0) {
t0 = t;
fps = 0.0;
}
else if (t - t0 >= 4.0) {
fps = (frames / (t - t0) + 0.5);
t0 = t;
frames = 0;
return fps;
}
return 0.0;
}
static void
init_model(void)
{
float objScale;
/* read in the model */
Model = glmReadOBJ(Model_file);
objScale = glmUnitize(Model);
glmFacetNormals(Model);
if (Model->numnormals == 0) {
GLfloat smoothing_angle = 90.0;
printf("Generating normals.\n");
glmVertexNormals(Model, smoothing_angle);
}
glmLoadTextures(Model);
glmReIndex(Model);
glmMakeVBOs(Model);
if (0)
glmPrint(Model);
}
static void
init_skybox(void)
{
SkyboxTex = LoadSkyBoxCubeTexture("alpine_east.rgb",
"alpine_west.rgb",
"alpine_up.rgb",
"alpine_down.rgb",
"alpine_south.rgb",
"alpine_north.rgb");
glmSpecularTexture(Model, SkyboxTex);
}
static void
init_gfx(void)
{
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_NORMALIZE);
glClearColor(0.3, 0.3, 0.9, 0.0);
}
static void
reshape(int width, int height)
{
float ar = 0.5 * (float) width / (float) height;
WinWidth = width;
WinHeight = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-ar, ar, -0.5, 0.5, 1.0, 300.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -3.0);
}
static void
Idle(void)
{
float q[4];
trackball(q, 100, 0, 99.99, 0);
add_quats(q, View.CurQuat, View.CurQuat);
glutPostRedisplay();
}
static void
display(void)
{
GLfloat rot[4][4];
float fps;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0.0, 0.0, -View.Distance);
glRotatef(Yrot, 0, 1, 0);
build_rotmatrix(rot, View.CurQuat);
glMultMatrixf(&rot[0][0]);
glScalef(Scale, Scale, Scale );
glUseProgram(0);
if (Skybox)
DrawSkyBoxCubeTexture(SkyboxTex);
if (WireFrame)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
else
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if (Cull)
glEnable(GL_CULL_FACE);
else
glDisable(GL_CULL_FACE);
if (NumInstances == 1) {
glmDrawVBO(Model);
}
else {
/* draw > 1 instance */
float dr = 360.0 / NumInstances;
float r;
for (r = 0.0; r < 360.0; r += dr) {
glPushMatrix();
glRotatef(r, 0, 1, 0);
glTranslatef(1.4, 0.0, 0.0);
glmDrawVBO(Model);
glPopMatrix();
}
}
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glDisable(GL_CULL_FACE);
glPopMatrix();
if (Stats) {
glColor3f(1.0, 1.0, 1.0);
text(5, glutGet(GLUT_WINDOW_HEIGHT) - (5+20*1), 20, "%s",
Model->pathname);
text(5, glutGet(GLUT_WINDOW_HEIGHT) - (5+20*2), 20, "%d vertices",
Model->numvertices);
text(5, glutGet(GLUT_WINDOW_HEIGHT) - (5+20*3), 20, "%d triangles",
Model->numtriangles);
text(5, glutGet(GLUT_WINDOW_HEIGHT) - (5+20*4), 20, "%d normals",
Model->numnormals);
text(5, glutGet(GLUT_WINDOW_HEIGHT) - (5+20*5), 20, "%d texcoords",
Model->numtexcoords);
text(5, glutGet(GLUT_WINDOW_HEIGHT) - (5+20*6), 20, "%d groups",
Model->numgroups);
text(5, glutGet(GLUT_WINDOW_HEIGHT) - (5+20*7), 20, "%d materials",
Model->nummaterials);
}
glutSwapBuffers();
fps = ComputeFPS();
if (fps)
printf("%f FPS\n", fps);
}
static void
keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 'h':
printf("help\n\n");
printf("a - Toggle animation\n");
printf("d/D - Decrease/Incrase number of models\n");
printf("w - Toggle wireframe/filled\n");
printf("c - Toggle culling\n");
printf("n - Toggle facet/smooth normal\n");
printf("r - Reverse polygon winding\n");
printf("p - Toggle performance indicator\n");
printf("s - Toggle skybox\n");
printf("z/Z - Scale model smaller/larger\n");
printf("i - Show model info/stats\n");
printf("q/escape - Quit\n\n");
break;
case 'a':
Animate = !Animate;
if (Animate)
glutIdleFunc(Idle);
else
glutIdleFunc(NULL);
break;
case 'd':
if (NumInstances > 1)
NumInstances--;
break;
case 'D':
NumInstances++;
break;
case 'i':
Stats = !Stats;
break;
case 'p':
Performance = !Performance;
break;
case 'w':
WireFrame = !WireFrame;
break;
case 'c':
Cull = !Cull;
printf("Polygon culling: %d\n", Cull);
break;
case 'r':
if (FrontFace == GL_CCW)
FrontFace = GL_CW;
else
FrontFace = GL_CCW;
glFrontFace(FrontFace);
printf("Front face:: %s\n", FrontFace == GL_CCW ? "CCW" : "CW");
break;
case 's':
Skybox = !Skybox;
if (Skybox)
glmSpecularTexture(Model, SkyboxTex);
else
glmSpecularTexture(Model, 0);
break;
case 'z':
Scale *= 0.9;
break;
case 'Z':
Scale *= 1.1;
break;
case 'q':
case 27:
exit(0);
break;
}
glutPostRedisplay();
}
static void
menu(int item)
{
keyboard((unsigned char)item, 0, 0);
}
/**
* Handle mouse button.
*/
static void
Mouse(int button, int state, int x, int y)
{
if (button == GLUT_LEFT_BUTTON) {
if (state == GLUT_DOWN) {
View.StartX = x;
View.StartY = y;
View.Rotating = GL_TRUE;
}
else if (state == GLUT_UP) {
View.Rotating = GL_FALSE;
}
}
else if (button == GLUT_MIDDLE_BUTTON) {
if (state == GLUT_DOWN) {
View.StartX = x;
View.StartY = y;
View.StartDistance = View.Distance;
View.Translating = GL_TRUE;
}
else if (state == GLUT_UP) {
View.Translating = GL_FALSE;
}
}
}
/**
* Handle mouse motion
*/
static void
Motion(int x, int y)
{
int i;
if (View.Rotating) {
float x0 = (2.0 * View.StartX - WinWidth) / WinWidth;
float y0 = (WinHeight - 2.0 * View.StartY) / WinHeight;
float x1 = (2.0 * x - WinWidth) / WinWidth;
float y1 = (WinHeight - 2.0 * y) / WinHeight;
float q[4];
trackball(q, x0, y0, x1, y1);
View.StartX = x;
View.StartY = y;
for (i = 0; i < 1; i++)
add_quats(q, View.CurQuat, View.CurQuat);
glutPostRedisplay();
}
else if (View.Translating) {
float dz = 0.02 * (y - View.StartY);
View.Distance = View.StartDistance + dz;
glutPostRedisplay();
}
}
static void
DoFeatureChecks(void)
{
char *version = (char *) glGetString(GL_VERSION);
if (version[0] == '1') {
/* check for individual extensions */
if (!glutExtensionSupported("GL_ARB_texture_cube_map")) {
printf("Sorry, GL_ARB_texture_cube_map is required.\n");
exit(1);
}
if (!glutExtensionSupported("GL_ARB_vertex_shader")) {
printf("Sorry, GL_ARB_vertex_shader is required.\n");
exit(1);
}
if (!glutExtensionSupported("GL_ARB_fragment_shader")) {
printf("Sorry, GL_ARB_fragment_shader is required.\n");
exit(1);
}
if (!glutExtensionSupported("GL_ARB_vertex_buffer_object")) {
printf("Sorry, GL_ARB_vertex_buffer_object is required.\n");
exit(1);
}
}
}
int
main(int argc, char** argv)
{
glutInitWindowSize(WinWidth, WinHeight);
glutInit(&argc, argv);
if (argc > 1) {
Model_file = argv[1];
}
if (!Model_file) {
fprintf(stderr, "usage: objview file.obj\n");
fprintf(stderr, "(using default bunny.obj)\n");
Model_file = "bunny.obj";
}
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutCreateWindow("objview");
glewInit();
DoFeatureChecks();
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMouseFunc(Mouse);
glutMotionFunc(Motion);
if (Animate)
glutIdleFunc(Idle);
glutCreateMenu(menu);
glutAddMenuEntry("[a] Toggle animate", 'a');
glutAddMenuEntry("[d] Fewer models", 'd');
glutAddMenuEntry("[D] More models", 'D');
glutAddMenuEntry("[w] Toggle wireframe/filled", 'w');
glutAddMenuEntry("[c] Toggle culling on/off", 'c');
glutAddMenuEntry("[r] Reverse polygon winding", 'r');
glutAddMenuEntry("[z] Scale model smaller", 'z');
glutAddMenuEntry("[Z] Scale model larger", 'Z');
glutAddMenuEntry("[p] Toggle performance indicator", 'p');
glutAddMenuEntry("[i] Show model stats", 'i');
glutAddMenuEntry("", 0);
glutAddMenuEntry("[q] Quit", 27);
glutAttachMenu(GLUT_RIGHT_BUTTON);
InitViewInfo(&View);
init_model();
init_skybox();
init_gfx();
glutMainLoop();
return 0;
}

View File

@@ -1,187 +0,0 @@
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <GL/glew.h>
#include <GL/glu.h>
#include "readtex.h"
#include "skybox.h"
static int
load(GLenum target, const char *filename,
GLboolean flipTB, GLboolean flipLR)
{
GLint w, h;
GLenum format;
GLubyte *img = LoadRGBImage( filename, &w, &h, &format );
if (!img) {
printf("Error: couldn't load texture image %s\n", filename);
return 0;
}
assert(format == GL_RGB);
printf("Load cube face 0x%x: %s %d x %d\n", target, filename, w, h);
/* <sigh> the way the texture cube mapping works, we have to flip
* images to make things look right.
*/
if (flipTB) {
const int stride = 3 * w;
GLubyte temp[3*1024];
int i;
for (i = 0; i < h / 2; i++) {
memcpy(temp, img + i * stride, stride);
memcpy(img + i * stride, img + (h - i - 1) * stride, stride);
memcpy(img + (h - i - 1) * stride, temp, stride);
}
}
if (flipLR) {
const int stride = 3 * w;
GLubyte temp[3];
GLubyte *row;
int i, j;
for (i = 0; i < h; i++) {
row = img + i * stride;
for (j = 0; j < w / 2; j++) {
int k = w - j - 1;
temp[0] = row[j*3+0];
temp[1] = row[j*3+1];
temp[2] = row[j*3+2];
row[j*3+0] = row[k*3+0];
row[j*3+1] = row[k*3+1];
row[j*3+2] = row[k*3+2];
row[k*3+0] = temp[0];
row[k*3+1] = temp[1];
row[k*3+2] = temp[2];
}
}
}
gluBuild2DMipmaps(target, GL_RGB, w, h, format, GL_UNSIGNED_BYTE, img);
free(img);
return 1;
}
GLuint
LoadSkyBoxCubeTexture(const char *filePosX,
const char *fileNegX,
const char *filePosY,
const char *fileNegY,
const char *filePosZ,
const char *fileNegZ)
{
GLuint tex;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_NEAREST);
if (!load(GL_TEXTURE_CUBE_MAP_POSITIVE_X, filePosX, GL_TRUE, GL_TRUE))
return 0;
if (!load(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, fileNegX, GL_TRUE, GL_TRUE))
return 0;
if (!load(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, filePosY, 1+GL_FALSE, GL_TRUE))
return 0;
if (!load(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, fileNegY, 1+GL_FALSE, GL_TRUE))
return 0;
if (!load(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, filePosZ, GL_TRUE, GL_TRUE))
return 0;
if (!load(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, fileNegZ, GL_TRUE, GL_TRUE))
return 0;
return tex;
}
#define eps1 0.99
#define br 20.0 /* box radius */
void
DrawSkyBoxCubeTexture(GLuint tex)
{
struct vertex {
float x, y, z, s, t, r;
};
static const struct vertex verts[24] = {
/* +X side */
{ br, -br, -br, 1.0, -eps1, -eps1 },
{ br, -br, br, 1.0, -eps1, eps1 },
{ br, br, br, 1.0, eps1, eps1 },
{ br, br, -br, 1.0, eps1, -eps1 },
/* -X side */
{ -br, br, -br, -1.0, eps1, -eps1 },
{ -br, br, br, -1.0, eps1, eps1 },
{ -br, -br, br, -1.0, -eps1, eps1 },
{ -br, -br, -br, -1.0, -eps1, -eps1 },
/* +Y side */
{ br, br, -br, eps1, 1.0, -eps1 },
{ br, br, br, eps1, 1.0, eps1 },
{ -br, br, br, -eps1, 1.0, eps1 },
{ -br, br, -br, -eps1, 1.0, -eps1 },
/* -Y side */
{ -br, -br, -br, -eps1, -1.0, -eps1 },
{ -br, -br, br, -eps1, -1.0, eps1 },
{ br, -br, br, eps1, -1.0, eps1 },
{ br, -br, -br, eps1, -1.0, -eps1 },
/* +Z side */
{ br, -br, br, eps1, -eps1, 1.0 },
{ -br, -br, br, -eps1, -eps1, 1.0 },
{ -br, br, br, -eps1, eps1, 1.0 },
{ br, br, br, eps1, eps1, 1.0 },
/* -Z side */
{ br, br, -br, eps1, eps1, -1.0 },
{ -br, br, -br, -eps1, eps1, -1.0 },
{ -br, -br, -br, -eps1, -eps1, -1.0 },
{ br, -br, -br, eps1, -eps1, -1.0 },
};
static GLuint vbo = 0;
if (!vbo ) {
glGenBuffersARB(1, &vbo);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts,
GL_STATIC_DRAW_ARB);
}
else {
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
}
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glVertexPointer(3, GL_FLOAT, sizeof(struct vertex),
(void *) offsetof(struct vertex, x));
glTexCoordPointer(3, GL_FLOAT, sizeof(struct vertex),
(void *) offsetof(struct vertex, s));
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
glEnable(GL_TEXTURE_CUBE_MAP);
glDisable(GL_BLEND);
glDrawArrays(GL_QUADS, 0, 24);
glDisable(GL_TEXTURE_CUBE_MAP);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
}

View File

@@ -1,18 +0,0 @@
#ifndef SKYBOX_H
#define SKYBOX_H
extern GLuint
LoadSkyBoxCubeTexture(const char *filePosX,
const char *fileNegX,
const char *filePosY,
const char *fileNegY,
const char *filePosZ,
const char *fileNegZ);
extern void
DrawSkyBoxCubeTexture(GLuint tex);
#endif /* SKYBOX_H */

10
progs/perf/.gitignore vendored
View File

@@ -1,10 +0,0 @@
copytex
drawoverhead
fbobind
fill
genmipmap
readpixels
swapbuffers
teximage
vbo
vertexrate

View File

@@ -1,55 +0,0 @@
# progs/demos/Makefile
TOP = ../..
include $(TOP)/configs/current
INCDIR = $(TOP)/include
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) \
-l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
# using : to avoid APP_CC pointing to CC loop
CC := $(APP_CC)
CFLAGS := -I$(INCDIR) $(CFLAGS)
LDLIBS = $(LIBS)
PROG_SOURCES = \
copytex.c \
drawoverhead.c \
fbobind.c \
fill.c \
genmipmap.c \
readpixels.c \
swapbuffers.c \
teximage.c \
vbo.c \
vertexrate.c \
PROG_OBJS = $(PROG_SOURCES:.c=.o)
PROGS = $(PROG_SOURCES:%.c=%)
UTIL_SOURCES = \
common.c \
glmain.c
UTIL_HEADERS = \
common.h \
glmain.h
UTIL_OBJS = $(UTIL_SOURCES:.c=.o)
default: $(PROGS)
$(PROG_OBJS): $(UTIL_HEADERS)
$(PROGS): $(UTIL_OBJS)
clean:
-rm -f $(PROGS)
-rm -f *.o *~

View File

@@ -1,32 +0,0 @@
Import('env')
if not env['GLUT']:
Return()
env = env.Clone()
env.Prepend(LIBS = ['$GLUT_LIB'])
progs = [
'copytex',
'drawoverhead',
'fbobind',
'fill',
'genmipmap',
'readpixels',
'swapbuffers',
'teximage',
'vbo',
'vertexrate',
]
for prog in progs:
env.Program(
target = prog,
source = [
prog + '.c',
'common.c',
'glmain.c',
]
)

View File

@@ -1,137 +0,0 @@
/*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VMWARE 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.
*/
/**
* Common perf code. This should be re-usable with other APIs.
*/
#include "common.h"
#include "glmain.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#if defined(_MSC_VER)
#define snprintf _snprintf
#endif
/* Need to add a fflush windows console with mingw, otherwise nothing
* shows up until program exit. May want to add logging here.
*/
void
perf_printf(const char *format, ...)
{
va_list ap;
va_start(ap, format);
fflush(stdout);
vfprintf(stdout, format, ap);
fflush(stdout);
va_end(ap);
}
/**
* Run function 'f' for enough iterations to reach a steady state.
* Return the rate (iterations/second).
*/
double
PerfMeasureRate(PerfRateFunc f)
{
const double minDuration = 1.0;
double rate = 0.0, prevRate = 0.0;
unsigned subiters;
/* Compute initial number of iterations to try.
* If the test function is pretty slow this helps to avoid
* extraordarily long run times.
*/
subiters = 2;
{
const double t0 = PerfGetTime();
double t1;
do {
f(subiters); /* call the rendering function */
t1 = PerfGetTime();
subiters *= 2;
} while (t1 - t0 < 0.1 * minDuration);
}
/*perf_printf("initial subIters = %u\n", subiters);*/
while (1) {
const double t0 = PerfGetTime();
unsigned iters = 0;
double t1;
do {
f(subiters); /* call the rendering function */
t1 = PerfGetTime();
iters += subiters;
} while (t1 - t0 < minDuration);
rate = iters / (t1 - t0);
if (0)
perf_printf("prevRate %f rate %f ratio %f iters %u\n",
prevRate, rate, rate/prevRate, iters);
/* Try and speed the search up by skipping a few steps:
*/
if (rate > prevRate * 1.6)
subiters *= 8;
else if (rate > prevRate * 1.2)
subiters *= 4;
else if (rate > prevRate * 1.05)
subiters *= 2;
else
break;
prevRate = rate;
}
if (0)
perf_printf("%s returning iters %u rate %f\n", __FUNCTION__, subiters, rate);
return rate;
}
/* Note static buffer, can only use once per printf.
*/
const char *
PerfHumanFloat( double d )
{
static char buf[80];
if (d > 1000000000.0)
snprintf(buf, sizeof(buf), "%.1f billion", d / 1000000000.0);
else if (d > 1000000.0)
snprintf(buf, sizeof(buf), "%.1f million", d / 1000000.0);
else if (d > 1000.0)
snprintf(buf, sizeof(buf), "%.1f thousand", d / 1000.0);
else
snprintf(buf, sizeof(buf), "%.1f", d);
return buf;
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VMWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef COMMON_H
#define COMMON_H
#include <stddef.h> /* for offsetof() */
typedef void (*PerfRateFunc)(unsigned count);
extern double
PerfMeasureRate(PerfRateFunc f);
const char *
PerfHumanFloat( double d );
extern void
perf_printf(const char *format, ...);
#endif /* COMMON_H */

View File

@@ -1,214 +0,0 @@
/*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VMWARE 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.
*/
/**
* Measure glCopyTex[Sub]Image() rate.
* Create a large, off-screen framebuffer object for rendering and
* copying the texture data from it since we can't make really large
* on-screen windows.
*
* Brian Paul
* 22 Sep 2009
*/
#include <string.h>
#include "glmain.h"
#include "common.h"
int WinWidth = 100, WinHeight = 100;
static GLuint VBO, FBO, RBO, Tex;
const GLsizei MinSize = 16, MaxSize = 4096;
static GLsizei TexSize;
static const GLboolean DrawPoint = GL_TRUE;
static const GLboolean TexSubImage4 = GL_FALSE;
struct vertex
{
GLfloat x, y, s, t;
};
static const struct vertex vertices[1] = {
{ 0.0, 0.0, 0.5, 0.5 },
};
#define VOFFSET(F) ((void *) offsetof(struct vertex, F))
/** Called from test harness/main */
void
PerfInit(void)
{
const GLenum filter = GL_LINEAR;
GLenum stat;
if (!PerfExtensionSupported("GL_EXT_framebuffer_object")) {
perf_printf("copytex: GL_EXT_framebuffer_object not supported\n");
exit(0);
}
/* setup VBO */
glGenBuffersARB(1, &VBO);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(vertices),
vertices, GL_STATIC_DRAW_ARB);
glVertexPointer(2, GL_FLOAT, sizeof(struct vertex), VOFFSET(x));
glTexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), VOFFSET(s));
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
/* setup texture */
glGenTextures(1, &Tex);
glBindTexture(GL_TEXTURE_2D, Tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
glEnable(GL_TEXTURE_2D);
/* setup rbo */
glGenRenderbuffersEXT(1, &RBO);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBO);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, MaxSize, MaxSize);
/* setup fbo */
glGenFramebuffersEXT(1, &FBO);
glBindFramebufferEXT(GL_FRAMEBUFFER, FBO);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT, RBO);
stat = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (stat != GL_FRAMEBUFFER_COMPLETE_EXT) {
perf_printf("fboswitch: Error: incomplete FBO!\n");
exit(1);
}
/* clear the FBO */
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
glViewport(0, 0, MaxSize, MaxSize);
glClear(GL_COLOR_BUFFER_BIT);
}
static void
CopyTexImage(unsigned count)
{
unsigned i;
for (i = 1; i < count; i++) {
/* draw something */
if (DrawPoint)
glDrawArrays(GL_POINTS, 0, 1);
/* copy whole texture */
glCopyTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA, 0, 0, TexSize, TexSize, 0);
}
glFinish();
}
static void
CopyTexSubImage(unsigned count)
{
unsigned i;
for (i = 1; i < count; i++) {
/* draw something */
if (DrawPoint)
glDrawArrays(GL_POINTS, 0, 1);
/* copy sub texture */
if (TexSubImage4) {
/* four sub-copies */
GLsizei half = TexSize / 2;
/* lower-left */
glCopyTexSubImage2D(GL_TEXTURE_2D, 0,
0, 0, 0, 0, half, half);
/* lower-right */
glCopyTexSubImage2D(GL_TEXTURE_2D, 0,
half, 0, half, 0, half, half);
/* upper-left */
glCopyTexSubImage2D(GL_TEXTURE_2D, 0,
0, half, 0, half, half, half);
/* upper-right */
glCopyTexSubImage2D(GL_TEXTURE_2D, 0,
half, half, half, half, half, half);
}
else {
/* one big copy */
glCopyTexSubImage2D(GL_TEXTURE_2D, 0,
0, 0, 0, 0, TexSize, TexSize);
}
}
glFinish();
}
/** Called from test harness/main */
void
PerfNextRound(void)
{
}
/** Called from test harness/main */
void
PerfDraw(void)
{
double rate, mbPerSec;
GLint sub, maxTexSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
/* loop over whole/sub tex copy */
for (sub = 0; sub < 2; sub++) {
/* loop over texture sizes */
for (TexSize = MinSize; TexSize <= MaxSize; TexSize *= 4) {
if (TexSize <= maxTexSize) {
GLint bytesPerImage = 4 * TexSize * TexSize;
if (sub == 0)
rate = PerfMeasureRate(CopyTexImage);
else {
/* setup empty dest texture */
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
TexSize, TexSize, 0,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
rate = PerfMeasureRate(CopyTexSubImage);
}
mbPerSec = rate * bytesPerImage / (1024.0 * 1024.0);
}
else {
rate = 0.0;
mbPerSec = 0.0;
}
perf_printf(" glCopyTex%sImage(%d x %d): %.1f copies/sec, %.1f Mpixels/sec\n",
(sub ? "Sub" : ""), TexSize, TexSize, rate, mbPerSec);
}
}
exit(0);
}

View File

@@ -1,137 +0,0 @@
/*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VMWARE 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.
*/
/**
* Measure drawing overhead
*
* This is the first in a series of simple performance benchmarks.
* The code in this file should be as simple as possible to make it
* easily portable to other APIs.
*
* All the window-system stuff should be contained in glmain.c (or TBDmain.c).
*
* Brian Paul
* 15 Sep 2009
*/
#include "glmain.h"
#include "common.h"
int WinWidth = 100, WinHeight = 100;
static GLuint VBO;
struct vertex
{
GLfloat x, y;
};
static const struct vertex vertices[4] = {
{ -1.0, -1.0 },
{ 1.0, -1.0 },
{ 1.0, 1.0 },
{ -1.0, 1.0 }
};
/** Called from test harness/main */
void
PerfInit(void)
{
/* setup VBO w/ vertex data */
glGenBuffersARB(1, &VBO);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
sizeof(vertices), vertices, GL_STATIC_DRAW_ARB);
glVertexPointer(2, GL_FLOAT, sizeof(struct vertex), (void *) 0);
glEnableClientState(GL_VERTEX_ARRAY);
/* misc GL state */
glAlphaFunc(GL_ALWAYS, 0.0);
}
static void
DrawNoStateChange(unsigned count)
{
unsigned i;
for (i = 0; i < count; i++) {
glDrawArrays(GL_POINTS, 0, 4);
}
glFinish();
}
static void
DrawNopStateChange(unsigned count)
{
unsigned i;
for (i = 0; i < count; i++) {
glDisable(GL_ALPHA_TEST);
glDrawArrays(GL_POINTS, 0, 4);
}
glFinish();
}
static void
DrawStateChange(unsigned count)
{
unsigned i;
for (i = 0; i < count; i++) {
if (i & 1)
glEnable(GL_TEXTURE_GEN_S);
else
glDisable(GL_TEXTURE_GEN_S);
glDrawArrays(GL_POINTS, 0, 4);
}
glFinish();
}
void
PerfNextRound(void)
{
}
/** Called from test harness/main */
void
PerfDraw(void)
{
double rate0, rate1, rate2, overhead;
rate0 = PerfMeasureRate(DrawNoStateChange);
perf_printf(" Draw only: %s draws/second\n",
PerfHumanFloat(rate0));
rate1 = PerfMeasureRate(DrawNopStateChange);
overhead = 1000.0 * (1.0 / rate1 - 1.0 / rate0);
perf_printf(" Draw w/ nop state change: %s draws/sec (overhead: %f ms/draw)\n",
PerfHumanFloat(rate1), overhead);
rate2 = PerfMeasureRate(DrawStateChange);
overhead = 1000.0 * (1.0 / rate2 - 1.0 / rate0);
perf_printf(" Draw w/ state change: %s draws/sec (overhead: %f ms/draw)\n",
PerfHumanFloat(rate2), overhead);
exit(0);
}

View File

@@ -1,153 +0,0 @@
/*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VMWARE 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.
*/
/**
* Measure rate of binding/switching between FBO targets.
* Create two framebuffer objects for rendering to two textures.
* Ping pong between texturing from one and drawing into the other.
*
* Brian Paul
* 22 Sep 2009
*/
#include <string.h>
#include "glmain.h"
#include "common.h"
int WinWidth = 100, WinHeight = 100;
static GLuint VBO;
static GLuint FBO[2], Tex[2];
static const GLsizei TexSize = 512;
static const GLboolean DrawPoint = GL_TRUE;
struct vertex
{
GLfloat x, y, s, t;
};
static const struct vertex vertices[1] = {
{ 0.0, 0.0, 0.5, 0.5 },
};
#define VOFFSET(F) ((void *) offsetof(struct vertex, F))
/** Called from test harness/main */
void
PerfInit(void)
{
const GLenum filter = GL_LINEAR;
GLenum stat;
int i;
if (!PerfExtensionSupported("GL_EXT_framebuffer_object")) {
perf_printf("fboswitch: GL_EXT_framebuffer_object not supported\n");
exit(0);
}
/* setup VBO */
glGenBuffersARB(1, &VBO);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(vertices),
vertices, GL_STATIC_DRAW_ARB);
glVertexPointer(2, GL_FLOAT, sizeof(struct vertex), VOFFSET(x));
glTexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), VOFFSET(s));
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glGenFramebuffersEXT(2, FBO);
glGenTextures(2, Tex);
for (i = 0; i < 2; i++) {
/* setup texture */
glBindTexture(GL_TEXTURE_2D, Tex[i]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
TexSize, TexSize, 0,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
/* setup fbo */
glBindFramebufferEXT(GL_FRAMEBUFFER, FBO[i]);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, Tex[i], 0/*level*/);
stat = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (stat != GL_FRAMEBUFFER_COMPLETE_EXT) {
perf_printf("fboswitch: Error: incomplete FBO!\n");
exit(1);
}
/* clear the FBO */
glClear(GL_COLOR_BUFFER_BIT);
}
glEnable(GL_TEXTURE_2D);
}
static void
FBOBind(unsigned count)
{
unsigned i;
for (i = 1; i < count; i++) {
const GLuint dst = i & 1;
const GLuint src = 1 - dst;
/* bind src texture */
glBindTexture(GL_TEXTURE_2D, Tex[src]);
/* bind dst fbo */
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBO[dst]);
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
/* draw something */
if (DrawPoint)
glDrawArrays(GL_POINTS, 0, 1);
}
glFinish();
}
/** Called from test harness/main */
void
PerfNextRound(void)
{
}
/** Called from test harness/main */
void
PerfDraw(void)
{
double rate;
rate = PerfMeasureRate(FBOBind);
perf_printf(" FBO Binding: %1.f binds/sec\n", rate);
exit(0);
}

View File

@@ -1,248 +0,0 @@
/*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VMWARE 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.
*/
/**
* Measure fill rates.
*
* Brian Paul
* 21 Sep 2009
*/
#include "glmain.h"
#include "common.h"
int WinWidth = 1000, WinHeight = 1000;
static GLuint VBO, TexObj;
struct vertex
{
GLfloat x, y, s, t, r, g, b, a;
};
#define VOFFSET(F) ((void *) offsetof(struct vertex, F))
static const struct vertex vertices[4] = {
/* x y s t r g b a */
{ -1.0, -1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.5 },
{ 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.5 },
{ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.5 },
{ -1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.5 }
};
static const char *VertexShader =
"void main() \n"
"{ \n"
" gl_Position = ftransform(); \n"
" gl_TexCoord[0] = gl_MultiTexCoord0; \n"
" gl_FrontColor = gl_Color; \n"
"} \n";
/* simple fragment shader */
static const char *FragmentShader1 =
"uniform sampler2D Tex; \n"
"void main() \n"
"{ \n"
" vec4 t = texture2D(Tex, gl_TexCoord[0].xy); \n"
" gl_FragColor = vec4(1.0) - t * gl_Color; \n"
"} \n";
/**
* A more complex fragment shader (but equivalent to first shader).
* A good optimizer should catch some of these no-op operations, but
* probably not all of them.
*/
static const char *FragmentShader2 =
"uniform sampler2D Tex; \n"
"void main() \n"
"{ \n"
" // as above \n"
" vec4 t = texture2D(Tex, gl_TexCoord[0].xy); \n"
" t = vec4(1.0) - t * gl_Color; \n"
" vec4 u; \n"
" // no-op negate/swizzle \n"
" u = -t.wzyx; \n"
" t = -u.wzyx; \n"
" // no-op inverts \n"
" t = vec4(1.0) - t; \n"
" t = vec4(1.0) - t; \n"
" // no-op min/max \n"
" t = min(t, t); \n"
" t = max(t, t); \n"
" // no-op moves \n"
" u = t; \n"
" t = u; \n"
" u = t; \n"
" t = u; \n"
" // no-op add/mul \n"
" t = (t + t + t + t) * 0.25; \n"
" // no-op mul/sub \n"
" t = 3.0 * t - 2.0 * t; \n"
" // no-op negate/min/max \n"
" t = -min(-t, -t); \n"
" t = -max(-t, -t); \n"
" gl_FragColor = t; \n"
"} \n";
static GLuint ShaderProg1, ShaderProg2;
/** Called from test harness/main */
void
PerfInit(void)
{
GLint u;
/* setup VBO w/ vertex data */
glGenBuffersARB(1, &VBO);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
sizeof(vertices), vertices, GL_STATIC_DRAW_ARB);
glVertexPointer(2, GL_FLOAT, sizeof(struct vertex), VOFFSET(x));
glTexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), VOFFSET(s));
glColorPointer(4, GL_FLOAT, sizeof(struct vertex), VOFFSET(r));
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
/* setup texture */
TexObj = PerfCheckerTexture(128, 128);
/* setup shaders */
ShaderProg1 = PerfShaderProgram(VertexShader, FragmentShader1);
glUseProgram(ShaderProg1);
u = glGetUniformLocation(ShaderProg1, "Tex");
glUniform1i(u, 0); /* texture unit 0 */
ShaderProg2 = PerfShaderProgram(VertexShader, FragmentShader2);
glUseProgram(ShaderProg2);
u = glGetUniformLocation(ShaderProg2, "Tex");
glUniform1i(u, 0); /* texture unit 0 */
glUseProgram(0);
}
static void
Ortho(void)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
static void
DrawQuad(unsigned count)
{
unsigned i;
glClear(GL_COLOR_BUFFER_BIT);
for (i = 0; i < count; i++) {
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
/* Avoid sending command buffers with huge numbers of fullscreen
* quads. Graphics schedulers don't always cope well with
* this...
*/
if (i % 128 == 0) {
PerfSwapBuffers();
glClear(GL_COLOR_BUFFER_BIT);
}
}
glFinish();
if (1)
PerfSwapBuffers();
}
void
PerfNextRound(void)
{
}
/** Called from test harness/main */
void
PerfDraw(void)
{
double rate;
double pixelsPerDraw = WinWidth * WinHeight;
Ortho();
/* simple fill */
rate = PerfMeasureRate(DrawQuad) * pixelsPerDraw;
perf_printf(" Simple fill: %s pixels/second\n",
PerfHumanFloat(rate));
/* blended fill */
glEnable(GL_BLEND);
rate = PerfMeasureRate(DrawQuad) * pixelsPerDraw;
glDisable(GL_BLEND);
perf_printf(" Blended fill: %s pixels/second\n",
PerfHumanFloat(rate));
/* textured fill */
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
rate = PerfMeasureRate(DrawQuad) * pixelsPerDraw;
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
perf_printf(" Textured fill: %s pixels/second\n",
PerfHumanFloat(rate));
/* shader1 fill */
glUseProgram(ShaderProg1);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
rate = PerfMeasureRate(DrawQuad) * pixelsPerDraw;
glUseProgram(0);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
perf_printf(" Shader1 fill: %s pixels/second\n",
PerfHumanFloat(rate));
/* shader2 fill */
glUseProgram(ShaderProg2);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
rate = PerfMeasureRate(DrawQuad) * pixelsPerDraw;
glUseProgram(0);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
perf_printf(" Shader2 fill: %s pixels/second\n",
PerfHumanFloat(rate));
exit(0);
}

View File

@@ -1,136 +0,0 @@
/*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VMWARE 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.
*/
/**
* Measure glGenerateMipmap() speed.
*
* Brian Paul
* 24 Sep 2009
*/
#include <string.h>
#include "glmain.h"
#include "common.h"
int WinWidth = 100, WinHeight = 100;
static GLboolean DrawPoint = GL_TRUE;
static GLuint VBO;
static GLuint TexObj = 0;
static GLint BaseLevel, MaxLevel;
struct vertex
{
GLfloat x, y, s, t;
};
static const struct vertex vertices[1] = {
{ 0.0, 0.0, 0.5, 0.5 },
};
#define VOFFSET(F) ((void *) offsetof(struct vertex, F))
/** Called from test harness/main */
void
PerfInit(void)
{
/* setup VBO w/ vertex data */
glGenBuffersARB(1, &VBO);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
sizeof(vertices), vertices, GL_STATIC_DRAW_ARB);
glVertexPointer(2, GL_FLOAT, sizeof(struct vertex), VOFFSET(x));
glTexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), VOFFSET(s));
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glGenTextures(1, &TexObj);
glBindTexture(GL_TEXTURE_2D, TexObj);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glEnable(GL_TEXTURE_2D);
}
static void
GenMipmap(unsigned count)
{
unsigned i;
for (i = 0; i < count; i++) {
GLubyte texel[4];
texel[0] = texel[1] = texel[2] = texel[3] = i & 0xff;
/* dirty the base image */
glTexSubImage2D(GL_TEXTURE_2D, BaseLevel,
0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, texel);
glGenerateMipmap(GL_TEXTURE_2D);
if (DrawPoint)
glDrawArrays(GL_POINTS, 0, 1);
}
glFinish();
}
/** Called from test harness/main */
void
PerfNextRound(void)
{
}
/** Called from test harness/main */
void
PerfDraw(void)
{
const GLint NumLevels = 12;
const GLint TexWidth = 2048, TexHeight = 2048;
GLubyte *img;
double rate;
/* Make 2K x 2K texture */
img = (GLubyte *) malloc(TexWidth * TexHeight * 4);
memset(img, 128, TexWidth * TexHeight * 4);
glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA, TexWidth, TexHeight, 0,
GL_RGBA, GL_UNSIGNED_BYTE, img);
free(img);
perf_printf("Texture level[0] size: %d x %d, %d levels\n",
TexWidth, TexHeight, NumLevels);
/* loop over base levels 0, 2, 4 */
for (BaseLevel = 0; BaseLevel <= 4; BaseLevel += 2) {
/* loop over max level */
for (MaxLevel = NumLevels; MaxLevel > BaseLevel; MaxLevel--) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, BaseLevel);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, MaxLevel);
rate = PerfMeasureRate(GenMipmap);
perf_printf(" glGenerateMipmap(levels %d..%d): %.2f gens/sec\n",
BaseLevel + 1, MaxLevel, rate);
}
}
exit(0);
}

View File

@@ -1,268 +0,0 @@
/*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VMWARE 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.
*/
/**
* OpenGL/GLUT common code for perf programs.
* Brian Paul
* 15 Sep 2009
*/
#include <stdio.h>
#include "glmain.h"
#include <GL/glut.h>
static int Win;
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
/** Return time in seconds */
double
PerfGetTime(void)
{
return glutGet(GLUT_ELAPSED_TIME) * 0.001;
}
void
PerfSwapBuffers(void)
{
glutSwapBuffers();
}
/** make simple checkerboard texture object */
GLuint
PerfCheckerTexture(GLsizei width, GLsizei height)
{
const GLenum filter = GL_NEAREST;
GLubyte *img = (GLubyte *) malloc(width * height * 4);
GLint i, j, k;
GLuint obj;
k = 0;
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
GLubyte color;
if (((i / 8) ^ (j / 8)) & 1) {
color = 0xff;
}
else {
color = 0x0;
}
img[k++] = color;
img[k++] = color;
img[k++] = color;
img[k++] = color;
}
}
glGenTextures(1, &obj);
glBindTexture(GL_TEXTURE_2D, obj);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, img);
free(img);
return obj;
}
static GLuint
CompileShader(GLenum type, const char *shader)
{
GLuint sh;
GLint stat;
sh = glCreateShader(type);
glShaderSource(sh, 1, (const GLchar **) &shader, NULL);
glCompileShader(sh);
glGetShaderiv(sh, GL_COMPILE_STATUS, &stat);
if (!stat) {
GLchar log[1000];
GLsizei len;
glGetShaderInfoLog(sh, 1000, &len, log);
fprintf(stderr, "Error: problem compiling shader: %s\n", log);
exit(1);
}
return sh;
}
/** Make shader program from given vert/frag shader text */
GLuint
PerfShaderProgram(const char *vertShader, const char *fragShader)
{
GLuint prog;
GLint stat;
{
const char *version = (const char *) glGetString(GL_VERSION);
if ((version[0] != '2' &&
version[0] != '3') || version[1] != '.') {
fprintf(stderr, "Error: GL version 2.x or better required\n");
exit(1);
}
}
prog = glCreateProgram();
if (vertShader) {
GLuint vs = CompileShader(GL_VERTEX_SHADER, vertShader);
glAttachShader(prog, vs);
}
if (fragShader) {
GLuint fs = CompileShader(GL_FRAGMENT_SHADER, fragShader);
glAttachShader(prog, fs);
}
glLinkProgram(prog);
glGetProgramiv(prog, GL_LINK_STATUS, &stat);
if (!stat) {
GLchar log[1000];
GLsizei len;
glGetProgramInfoLog(prog, 1000, &len, log);
fprintf(stderr, "Shader link error:\n%s\n", log);
exit(1);
}
return prog;
}
int
PerfReshapeWindow( unsigned w, unsigned h )
{
if (glutGet(GLUT_SCREEN_WIDTH) < w ||
glutGet(GLUT_SCREEN_HEIGHT) < h)
return 0;
glutReshapeWindow( w, h );
glutPostRedisplay();
return 1;
}
GLboolean
PerfExtensionSupported(const char *ext)
{
return glutExtensionSupported(ext);
}
static void
Idle(void)
{
PerfNextRound();
}
static void
Draw(void)
{
PerfDraw();
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, 5.0, 25.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -15.0);
}
static void
Key(unsigned char key, int x, int y)
{
const GLfloat step = 3.0;
(void) x;
(void) y;
switch (key) {
case 'z':
Zrot -= step;
break;
case 'Z':
Zrot += step;
break;
case 27:
glutDestroyWindow(Win);
exit(0);
break;
}
glutPostRedisplay();
}
static void
SpecialKey(int key, int x, int y)
{
const GLfloat step = 3.0;
(void) x;
(void) y;
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;
}
glutPostRedisplay();
}
int
main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(WinWidth, WinHeight);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL);
Win = glutCreateWindow(argv[0]);
glewInit();
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutSpecialFunc(SpecialKey);
glutDisplayFunc(Draw);
glutIdleFunc(Idle);
PerfInit();
glutMainLoop();
return 0;
}

View File

@@ -1,68 +0,0 @@
/*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VMWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef GLMAIN_H
#define GLMAIN_H
#define GL_GLEXT_PROTOTYPES
#include <GL/glew.h>
#include <stdlib.h>
#include <math.h>
/** Test programs can use these vars/functions */
extern int WinWidth, WinHeight;
extern double
PerfGetTime(void);
extern void
PerfSwapBuffers(void);
extern GLuint
PerfCheckerTexture(GLsizei width, GLsizei height);
extern GLuint
PerfShaderProgram(const char *vertShader, const char *fragShader);
extern int
PerfReshapeWindow( unsigned w, unsigned h );
extern GLboolean
PerfExtensionSupported(const char *ext);
/** Test programs must implement these functions **/
extern void
PerfInit(void);
extern void
PerfNextRound(void);
extern void
PerfDraw(void);
#endif /* GLMAIN_H */

View File

@@ -1,169 +0,0 @@
/*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VMWARE 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.
*/
/**
* Measure glReadPixels speed.
* XXX also read into a PBO?
* XXX also read from FBOs?
*
* Brian Paul
* 23 Sep 2009
*/
#include <string.h>
#include <assert.h>
#include "glmain.h"
#include "common.h"
int WinWidth = 1000, WinHeight = 1000;
static GLuint VBO;
static const GLboolean DrawPoint = GL_TRUE;
static const GLboolean BufferSubDataInHalves = GL_TRUE;
static const GLfloat Vertex0[2] = { 0.0, 0.0 };
static GLenum HaveDepthStencil;
static GLenum ReadFormat, ReadType;
static GLint ReadWidth, ReadHeight;
static GLvoid *ReadBuffer;
/** Called from test harness/main */
void
PerfInit(void)
{
/* setup VBO */
glGenBuffersARB(1, &VBO);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(Vertex0), Vertex0, GL_STATIC_DRAW_ARB);
glVertexPointer(2, GL_FLOAT, sizeof(Vertex0), (void *) 0);
glEnableClientState(GL_VERTEX_ARRAY);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
HaveDepthStencil = PerfExtensionSupported("GL_EXT_packed_depth_stencil");
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glEnable(GL_STENCIL_TEST);
}
static void
ReadPixels(unsigned count)
{
unsigned i;
for (i = 0; i < count; i++) {
/* read from random pos */
GLint x, y;
x = WinWidth - ReadWidth;
y = WinHeight - ReadHeight;
if (x > 0)
x = rand() % x;
if (y > 0)
y = rand() % y;
if (DrawPoint)
glDrawArrays(GL_POINTS, 0, 1);
glReadPixels(x, y, ReadWidth, ReadHeight,
ReadFormat, ReadType, ReadBuffer);
}
glFinish();
}
static const GLsizei Sizes[] = {
10,
100,
500,
1000,
0
};
static const struct {
GLenum format;
GLenum type;
const char *name;
GLuint pixel_size;
} DstFormats[] = {
{ GL_RGBA, GL_UNSIGNED_BYTE, "RGBA/ubyte", 4 },
{ GL_BGRA, GL_UNSIGNED_BYTE, "BGRA/ubyte", 4 },
{ GL_RGB, GL_UNSIGNED_SHORT_5_6_5, "RGB/565", 2 },
{ GL_LUMINANCE, GL_UNSIGNED_BYTE, "L/ubyte", 1 },
{ GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, "Z/uint", 4 },
{ GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, "Z+S/uint", 4 },
{ 0, 0, NULL, 0 }
};
/** Called from test harness/main */
void
PerfNextRound(void)
{
}
/** Called from test harness/main */
void
PerfDraw(void)
{
double rate, mbPerSec;
int fmt, sz;
/* loop over formats */
for (fmt = 0; DstFormats[fmt].format; fmt++) {
ReadFormat = DstFormats[fmt].format;
ReadType = DstFormats[fmt].type;
/* loop over sizes */
for (sz = 0; Sizes[sz]; sz++) {
int imgSize;
ReadWidth = ReadHeight = Sizes[sz];
imgSize = ReadWidth * ReadHeight * DstFormats[fmt].pixel_size;
ReadBuffer = malloc(imgSize);
if (ReadFormat == GL_DEPTH_STENCIL_EXT && !HaveDepthStencil) {
rate = 0.0;
mbPerSec = 0.0;
}
else {
rate = PerfMeasureRate(ReadPixels);
mbPerSec = rate * imgSize / (1024.0 * 1024.0);
}
perf_printf("glReadPixels(%d x %d, %s): %.1f images/sec, %.1f Mpixels/sec\n",
ReadWidth, ReadHeight,
DstFormats[fmt].name, rate, mbPerSec);
free(ReadBuffer);
}
}
exit(0);
}

View File

@@ -1,161 +0,0 @@
/*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VMWARE 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.
*/
/**
* Measure SwapBuffers.
*
* Keith Whitwell
* 22 Sep 2009
*/
#include "glmain.h"
#include "common.h"
int WinWidth = 100, WinHeight = 100;
int real_WinWidth, real_WinHeight; /* don't know whats going on here */
static GLuint VBO;
struct vertex
{
GLfloat x, y;
};
static const struct vertex vertices[4] = {
{ -1.0, -1.0 },
{ 1.0, -1.0 },
{ 1.0, 1.0 },
{ -1.0, 1.0 }
};
/** Called from test harness/main */
void
PerfInit(void)
{
/* setup VBO w/ vertex data */
glGenBuffersARB(1, &VBO);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
sizeof(vertices), vertices, GL_STATIC_DRAW_ARB);
glVertexPointer(2, GL_FLOAT, sizeof(struct vertex), (void *) 0);
glEnableClientState(GL_VERTEX_ARRAY);
/* misc GL state */
glAlphaFunc(GL_ALWAYS, 0.0);
}
static void
SwapNaked(unsigned count)
{
unsigned i;
for (i = 0; i < count; i++) {
PerfSwapBuffers();
}
}
static void
SwapClear(unsigned count)
{
unsigned i;
for (i = 0; i < count; i++) {
glClear(GL_COLOR_BUFFER_BIT);
PerfSwapBuffers();
}
}
static void
SwapClearPoint(unsigned count)
{
unsigned i;
for (i = 0; i < count; i++) {
glClear(GL_COLOR_BUFFER_BIT);
glDrawArrays(GL_POINTS, 0, 4);
PerfSwapBuffers();
}
}
static const struct {
unsigned w;
unsigned h;
} sizes[] = {
{ 320, 240 },
{ 640, 480 },
{ 1024, 768 },
{ 1200, 1024 },
{ 1600, 1200 }
};
void
PerfNextRound(void)
{
static unsigned i;
if (i < sizeof(sizes) / sizeof(sizes[0]) &&
PerfReshapeWindow( sizes[i].w, sizes[i].h ))
{
perf_printf("Reshape %dx%d\n", sizes[i].w, sizes[i].h);
real_WinWidth = sizes[i].w;
real_WinHeight = sizes[i].h;
i++;
}
else {
exit(0);
}
}
/** Called from test harness/main */
void
PerfDraw(void)
{
double rate0;
rate0 = PerfMeasureRate(SwapNaked);
perf_printf(" Swapbuffers %dx%d: %s swaps/second",
real_WinWidth, real_WinHeight,
PerfHumanFloat(rate0));
perf_printf(" %s pixels/second\n",
PerfHumanFloat(rate0 * real_WinWidth * real_WinHeight));
rate0 = PerfMeasureRate(SwapClear);
perf_printf(" Swap/Clear %dx%d: %s swaps/second",
real_WinWidth, real_WinHeight,
PerfHumanFloat(rate0));
perf_printf(" %s pixels/second\n",
PerfHumanFloat(rate0 * real_WinWidth * real_WinHeight));
rate0 = PerfMeasureRate(SwapClearPoint);
perf_printf(" Swap/Clear/Draw %dx%d: %s swaps/second",
real_WinWidth, real_WinHeight,
PerfHumanFloat(rate0));
perf_printf(" %s pixels/second\n",
PerfHumanFloat(rate0 * real_WinWidth * real_WinHeight));
}

View File

@@ -1,331 +0,0 @@
/*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VMWARE 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.
*/
/**
* Measure glTex[Sub]Image2D() and glGetTexImage() rate
*
* Brian Paul
* 16 Sep 2009
*/
#include "glmain.h"
#include "common.h"
int WinWidth = 100, WinHeight = 100;
static GLuint VBO;
static GLuint TexObj = 0;
static GLubyte *TexImage = NULL;
static GLsizei TexSize;
static GLenum TexIntFormat, TexSrcFormat, TexSrcType;
static const GLboolean DrawPoint = GL_TRUE;
static const GLboolean TexSubImage4 = GL_FALSE;
enum {
MODE_CREATE_TEXIMAGE,
MODE_TEXIMAGE,
MODE_TEXSUBIMAGE,
MODE_GETTEXIMAGE,
MODE_COUNT
};
static const char *mode_name[MODE_COUNT] =
{
"Create_TexImage",
"TexImage",
"TexSubImage",
"GetTexImage"
};
struct vertex
{
GLfloat x, y, s, t;
};
static const struct vertex vertices[1] = {
{ 0.0, 0.0, 0.5, 0.5 },
};
#define VOFFSET(F) ((void *) offsetof(struct vertex, F))
/** Called from test harness/main */
void
PerfInit(void)
{
/* setup VBO w/ vertex data */
glGenBuffersARB(1, &VBO);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
sizeof(vertices), vertices, GL_STATIC_DRAW_ARB);
glVertexPointer(2, GL_FLOAT, sizeof(struct vertex), VOFFSET(x));
glTexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), VOFFSET(s));
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
/* texture */
glGenTextures(1, &TexObj);
glBindTexture(GL_TEXTURE_2D, TexObj);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glEnable(GL_TEXTURE_2D);
}
static void
CreateUploadTexImage2D(unsigned count)
{
unsigned i;
for (i = 0; i < count; i++) {
if (TexObj)
glDeleteTextures(1, &TexObj);
glGenTextures(1, &TexObj);
glBindTexture(GL_TEXTURE_2D, TexObj);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, TexIntFormat,
TexSize, TexSize, 0,
TexSrcFormat, TexSrcType, TexImage);
if (DrawPoint)
glDrawArrays(GL_POINTS, 0, 1);
}
glFinish();
}
static void
UploadTexImage2D(unsigned count)
{
unsigned i;
for (i = 0; i < count; i++) {
/* XXX is this equivalent to a glTexSubImage call since we're
* always specifying the same image size? That case isn't optimized
* in Mesa but may be optimized in other drivers. Note sure how
* much difference that might make.
*/
glTexImage2D(GL_TEXTURE_2D, 0, TexIntFormat,
TexSize, TexSize, 0,
TexSrcFormat, TexSrcType, TexImage);
if (DrawPoint)
glDrawArrays(GL_POINTS, 0, 1);
}
glFinish();
}
static void
UploadTexSubImage2D(unsigned count)
{
unsigned i;
for (i = 0; i < count; i++) {
if (TexSubImage4) {
GLsizei halfSize = (TexSize == 1) ? 1 : TexSize / 2;
GLsizei halfPos = TexSize - halfSize;
/* do glTexSubImage2D in four pieces */
/* lower-left */
glPixelStorei(GL_UNPACK_ROW_LENGTH, TexSize);
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, 0, halfSize, halfSize,
TexSrcFormat, TexSrcType, TexImage);
/* lower-right */
glPixelStorei(GL_UNPACK_SKIP_PIXELS, halfPos);
glTexSubImage2D(GL_TEXTURE_2D, 0,
halfPos, 0, halfSize, halfSize,
TexSrcFormat, TexSrcType, TexImage);
/* upper-left */
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, halfPos);
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, halfPos, halfSize, halfSize,
TexSrcFormat, TexSrcType, TexImage);
/* upper-right */
glPixelStorei(GL_UNPACK_SKIP_PIXELS, halfPos);
glPixelStorei(GL_UNPACK_SKIP_ROWS, halfPos);
glTexSubImage2D(GL_TEXTURE_2D, 0,
halfPos, halfPos, halfSize, halfSize,
TexSrcFormat, TexSrcType, TexImage);
/* reset the unpacking state */
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
}
else {
/* replace whole texture image at once */
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, 0, TexSize, TexSize,
TexSrcFormat, TexSrcType, TexImage);
}
if (DrawPoint)
glDrawArrays(GL_POINTS, 0, 1);
}
glFinish();
}
static void
GetTexImage2D(unsigned count)
{
unsigned i;
GLubyte *buf = (GLubyte *) malloc(TexSize * TexSize * 4);
for (i = 0; i < count; i++) {
glGetTexImage(GL_TEXTURE_2D, 0,
TexSrcFormat, TexSrcType, buf);
}
glFinish();
free(buf);
}
/* XXX any other formats to measure? */
static const struct {
GLenum format, type;
GLenum internal_format;
const char *name;
GLuint texel_size;
GLboolean full_test;
} SrcFormats[] = {
{ GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA, "RGBA/ubyte", 4, GL_TRUE },
{ GL_RGB, GL_UNSIGNED_BYTE, GL_RGB, "RGB/ubyte", 3, GL_FALSE },
{ GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB, "RGB/565", 2, GL_FALSE },
{ GL_BGRA, GL_UNSIGNED_BYTE, GL_RGBA, "BGRA/ubyte", 4, GL_FALSE },
{ GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE, "L/ubyte", 1, GL_FALSE },
{ 0, 0, 0, NULL, 0, 0 }
};
/** Called from test harness/main */
void
PerfNextRound(void)
{
}
/** Called from test harness/main */
void
PerfDraw(void)
{
GLint maxSize;
double rate;
GLint fmt, mode;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxSize);
/* loop over source data formats */
for (fmt = 0; SrcFormats[fmt].format; fmt++) {
TexIntFormat = SrcFormats[fmt].internal_format;
TexSrcFormat = SrcFormats[fmt].format;
TexSrcType = SrcFormats[fmt].type;
/* loop over glTexImage, glTexSubImage */
for (mode = 0; mode < MODE_COUNT; mode++) {
GLuint minsz, maxsz;
if (SrcFormats[fmt].full_test) {
minsz = 16;
maxsz = 4096;
}
else {
minsz = maxsz = 256;
if (mode == MODE_CREATE_TEXIMAGE)
continue;
}
/* loop over a defined range of texture sizes, test only the
* ones which are legal for this driver.
*/
for (TexSize = minsz; TexSize <= maxsz; TexSize *= 4) {
double mbPerSec;
if (TexSize <= maxSize) {
GLint bytesPerImage;
bytesPerImage = TexSize * TexSize * SrcFormats[fmt].texel_size;
TexImage = malloc(bytesPerImage);
switch (mode) {
case MODE_TEXIMAGE:
rate = PerfMeasureRate(UploadTexImage2D);
break;
case MODE_CREATE_TEXIMAGE:
rate = PerfMeasureRate(CreateUploadTexImage2D);
break;
case MODE_TEXSUBIMAGE:
/* create initial, empty texture */
glTexImage2D(GL_TEXTURE_2D, 0, TexIntFormat,
TexSize, TexSize, 0,
TexSrcFormat, TexSrcType, NULL);
rate = PerfMeasureRate(UploadTexSubImage2D);
break;
case MODE_GETTEXIMAGE:
glTexImage2D(GL_TEXTURE_2D, 0, TexIntFormat,
TexSize, TexSize, 0,
TexSrcFormat, TexSrcType, TexImage);
rate = PerfMeasureRate(GetTexImage2D);
break;
default:
exit(1);
}
mbPerSec = rate * bytesPerImage / (1024.0 * 1024.0);
free(TexImage);
{
unsigned err;
err = glGetError();
if (err) {
perf_printf("non-zero glGetError() %d\n", err);
exit(1);
}
}
}
else {
rate = 0;
mbPerSec = 0;
}
perf_printf(" %s(%s %d x %d): "
"%.1f images/sec, %.1f MB/sec\n",
mode_name[mode],
SrcFormats[fmt].name, TexSize, TexSize, rate, mbPerSec);
}
if (SrcFormats[fmt].full_test)
perf_printf("\n");
}
}
exit(0);
}

View File

@@ -1,246 +0,0 @@
/*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VMWARE 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.
*/
/**
* Measure VBO upload speed.
* That is, measure glBufferDataARB() and glBufferSubDataARB().
*
* Brian Paul
* 16 Sep 2009
*/
#include <string.h>
#include "glmain.h"
#include "common.h"
/* Copy data out of a large array to avoid caching effects:
*/
#define DATA_SIZE (16*1024*1024)
int WinWidth = 100, WinHeight = 100;
static GLuint VBO;
static GLsizei VBOSize = 0;
static GLsizei SubSize = 0;
static GLubyte *VBOData = NULL; /* array[DATA_SIZE] */
static const GLboolean DrawPoint = GL_TRUE;
static const GLboolean BufferSubDataInHalves = GL_TRUE;
static const GLfloat Vertex0[2] = { 0.0, 0.0 };
/** Called from test harness/main */
void
PerfInit(void)
{
/* setup VBO */
glGenBuffersARB(1, &VBO);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO);
glVertexPointer(2, GL_FLOAT, sizeof(Vertex0), (void *) 0);
glEnableClientState(GL_VERTEX_ARRAY);
}
static void
UploadVBO(unsigned count)
{
unsigned i;
unsigned total = 0;
unsigned src = 0;
for (i = 0; i < count; i++) {
glBufferDataARB(GL_ARRAY_BUFFER, VBOSize, VBOData + src, GL_STREAM_DRAW_ARB);
glDrawArrays(GL_POINTS, 0, 1);
/* Throw in an occasional flush to work around a driver crash:
*/
total += VBOSize;
if (total >= 16*1024*1024) {
glFlush();
total = 0;
}
src += VBOSize;
src %= DATA_SIZE;
}
glFinish();
}
static void
UploadSubVBO(unsigned count)
{
unsigned i;
unsigned src = 0;
for (i = 0; i < count; i++) {
unsigned offset = (i * SubSize) % VBOSize;
glBufferSubDataARB(GL_ARRAY_BUFFER, offset, SubSize, VBOData + src);
if (DrawPoint) {
glDrawArrays(GL_POINTS, offset / sizeof(Vertex0), 1);
}
src += SubSize;
src %= DATA_SIZE;
}
glFinish();
}
/* Do multiple small SubData uploads, then call DrawArrays. This may be a
* fairer comparison to back-to-back BufferData calls:
*/
static void
BatchUploadSubVBO(unsigned count)
{
unsigned i = 0, j;
unsigned period = VBOSize / SubSize;
unsigned src = 0;
while (i < count) {
for (j = 0; j < period && i < count; j++, i++) {
unsigned offset = j * SubSize;
glBufferSubDataARB(GL_ARRAY_BUFFER, offset, SubSize, VBOData + src);
}
glDrawArrays(GL_POINTS, 0, 1);
src += SubSize;
src %= DATA_SIZE;
}
glFinish();
}
/**
* Test the sequence:
* create/load VBO
* draw
* destroy VBO
*/
static void
CreateDrawDestroyVBO(unsigned count)
{
unsigned i;
for (i = 0; i < count; i++) {
GLuint vbo;
/* create/load */
glGenBuffersARB(1, &vbo);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
glBufferDataARB(GL_ARRAY_BUFFER, VBOSize, VBOData, GL_STREAM_DRAW_ARB);
/* draw */
glVertexPointer(2, GL_FLOAT, sizeof(Vertex0), (void *) 0);
glDrawArrays(GL_POINTS, 0, 1);
/* destroy */
glDeleteBuffersARB(1, &vbo);
}
glFinish();
}
static const GLsizei Sizes[] = {
64,
1024,
16*1024,
256*1024,
1024*1024,
16*1024*1024,
0 /* end of list */
};
void
PerfNextRound(void)
{
}
/** Called from test harness/main */
void
PerfDraw(void)
{
double rate, mbPerSec;
int i, sz;
/* Load VBOData buffer with duplicated Vertex0.
*/
VBOData = calloc(DATA_SIZE, 1);
for (i = 0; i < DATA_SIZE / sizeof(Vertex0); i++) {
memcpy(VBOData + i * sizeof(Vertex0),
Vertex0,
sizeof(Vertex0));
}
/* glBufferDataARB()
*/
for (sz = 0; Sizes[sz]; sz++) {
SubSize = VBOSize = Sizes[sz];
rate = PerfMeasureRate(UploadVBO);
mbPerSec = rate * VBOSize / (1024.0 * 1024.0);
perf_printf(" glBufferDataARB(size = %d): %.1f MB/sec\n",
VBOSize, mbPerSec);
}
/* glBufferSubDataARB()
*/
for (sz = 0; Sizes[sz]; sz++) {
SubSize = VBOSize = Sizes[sz];
rate = PerfMeasureRate(UploadSubVBO);
mbPerSec = rate * VBOSize / (1024.0 * 1024.0);
perf_printf(" glBufferSubDataARB(size = %d): %.1f MB/sec\n",
VBOSize, mbPerSec);
}
/* Batch upload
*/
VBOSize = 1024 * 1024;
glBufferDataARB(GL_ARRAY_BUFFER, VBOSize, VBOData, GL_STREAM_DRAW_ARB);
for (sz = 0; Sizes[sz] < VBOSize; sz++) {
SubSize = Sizes[sz];
rate = PerfMeasureRate(UploadSubVBO);
mbPerSec = rate * SubSize / (1024.0 * 1024.0);
perf_printf(" glBufferSubDataARB(size = %d, VBOSize = %d): %.1f MB/sec\n",
SubSize, VBOSize, mbPerSec);
}
for (sz = 0; Sizes[sz] < VBOSize; sz++) {
SubSize = Sizes[sz];
rate = PerfMeasureRate(BatchUploadSubVBO);
mbPerSec = rate * SubSize / (1024.0 * 1024.0);
perf_printf(" glBufferSubDataARB(size = %d, VBOSize = %d), batched: %.1f MB/sec\n",
SubSize, VBOSize, mbPerSec);
}
/* Create/Draw/Destroy
*/
for (sz = 0; Sizes[sz]; sz++) {
SubSize = VBOSize = Sizes[sz];
rate = PerfMeasureRate(CreateDrawDestroyVBO);
mbPerSec = rate * VBOSize / (1024.0 * 1024.0);
perf_printf(" VBO Create/Draw/Destroy(size = %d): %.1f MB/sec, %.1f draws/sec\n",
VBOSize, mbPerSec, rate);
}
exit(0);
}

View File

@@ -1,276 +0,0 @@
/*
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VMWARE 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.
*/
/**
* Measure simple vertex processing rate via:
* - immediate mode
* - vertex arrays
* - VBO vertex arrays
* - glDrawElements
* - VBO glDrawElements
* - glDrawRangeElements
* - VBO glDrawRangeElements
*
* Brian Paul
* 16 Sep 2009
*/
#include <assert.h>
#include <string.h>
#include "glmain.h"
#include "common.h"
#define MAX_VERTS (100 * 100)
/** glVertex2/3/4 size */
#define VERT_SIZE 4
int WinWidth = 500, WinHeight = 500;
static GLuint VertexBO, ElementBO;
static unsigned NumVerts = MAX_VERTS;
static unsigned VertBytes = VERT_SIZE * sizeof(float);
static float *VertexData = NULL;
static unsigned NumElements = MAX_VERTS;
static GLuint *Elements = NULL;
/**
* Load VertexData buffer with a 2-D grid of points in the range [-1,1]^2.
*/
static void
InitializeVertexData(void)
{
unsigned i;
float x = -1.0, y = -1.0;
float dx = 2.0 / 100;
float dy = 2.0 / 100;
VertexData = (float *) malloc(NumVerts * VertBytes);
for (i = 0; i < NumVerts; i++) {
VertexData[i * VERT_SIZE + 0] = x;
VertexData[i * VERT_SIZE + 1] = y;
VertexData[i * VERT_SIZE + 2] = 0.0;
VertexData[i * VERT_SIZE + 3] = 1.0;
x += dx;
if (x > 1.0) {
x = -1.0;
y += dy;
}
}
Elements = (GLuint *) malloc(NumVerts * sizeof(GLuint));
for (i = 0; i < NumVerts; i++) {
Elements[i] = NumVerts - i - 1;
}
}
/** Called from test harness/main */
void
PerfInit(void)
{
InitializeVertexData();
/* setup VertexBO */
glGenBuffersARB(1, &VertexBO);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VertexBO);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
NumVerts * VertBytes, VertexData, GL_STATIC_DRAW_ARB);
glEnableClientState(GL_VERTEX_ARRAY);
/* setup ElementBO */
glGenBuffersARB(1, &ElementBO);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ElementBO);
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
NumElements * sizeof(GLuint), Elements, GL_STATIC_DRAW_ARB);
}
static void
DrawImmediate(unsigned count)
{
unsigned i;
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBufferARB(GL_ARRAY_BUFFER, 0);
for (i = 0; i < count; i++) {
unsigned j;
glBegin(GL_POINTS);
for (j = 0; j < NumVerts; j++) {
#if VERT_SIZE == 4
glVertex4fv(VertexData + j * 4);
#elif VERT_SIZE == 3
glVertex3fv(VertexData + j * 3);
#elif VERT_SIZE == 2
glVertex2fv(VertexData + j * 2);
#else
abort();
#endif
}
glEnd();
}
glFinish();
PerfSwapBuffers();
}
static void
DrawArraysMem(unsigned count)
{
unsigned i;
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBufferARB(GL_ARRAY_BUFFER, 0);
glVertexPointer(VERT_SIZE, GL_FLOAT, VertBytes, VertexData);
for (i = 0; i < count; i++) {
glDrawArrays(GL_POINTS, 0, NumVerts);
}
glFinish();
PerfSwapBuffers();
}
static void
DrawArraysVBO(unsigned count)
{
unsigned i;
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBufferARB(GL_ARRAY_BUFFER, VertexBO);
glVertexPointer(VERT_SIZE, GL_FLOAT, VertBytes, (void *) 0);
for (i = 0; i < count; i++) {
glDrawArrays(GL_POINTS, 0, NumVerts);
}
glFinish();
PerfSwapBuffers();
}
static void
DrawElementsMem(unsigned count)
{
unsigned i;
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBufferARB(GL_ARRAY_BUFFER, 0);
glVertexPointer(VERT_SIZE, GL_FLOAT, VertBytes, VertexData);
for (i = 0; i < count; i++) {
glDrawElements(GL_POINTS, NumVerts, GL_UNSIGNED_INT, Elements);
}
glFinish();
PerfSwapBuffers();
}
static void
DrawElementsBO(unsigned count)
{
unsigned i;
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, ElementBO);
glBindBufferARB(GL_ARRAY_BUFFER, VertexBO);
glVertexPointer(VERT_SIZE, GL_FLOAT, VertBytes, (void *) 0);
for (i = 0; i < count; i++) {
glDrawElements(GL_POINTS, NumVerts, GL_UNSIGNED_INT, (void *) 0);
}
glFinish();
PerfSwapBuffers();
}
static void
DrawRangeElementsMem(unsigned count)
{
unsigned i;
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBufferARB(GL_ARRAY_BUFFER, 0);
glVertexPointer(VERT_SIZE, GL_FLOAT, VertBytes, VertexData);
for (i = 0; i < count; i++) {
glDrawRangeElements(GL_POINTS, 0, NumVerts - 1,
NumVerts, GL_UNSIGNED_INT, Elements);
}
glFinish();
PerfSwapBuffers();
}
static void
DrawRangeElementsBO(unsigned count)
{
unsigned i;
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, ElementBO);
glBindBufferARB(GL_ARRAY_BUFFER, VertexBO);
glVertexPointer(VERT_SIZE, GL_FLOAT, VertBytes, (void *) 0);
for (i = 0; i < count; i++) {
glDrawRangeElements(GL_POINTS, 0, NumVerts - 1,
NumVerts, GL_UNSIGNED_INT, (void *) 0);
}
glFinish();
PerfSwapBuffers();
}
void
PerfNextRound(void)
{
}
/** Called from test harness/main */
void
PerfDraw(void)
{
double rate;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
perf_printf("Vertex rate (%d x Vertex%df)\n", NumVerts, VERT_SIZE);
rate = PerfMeasureRate(DrawImmediate);
rate *= NumVerts;
perf_printf(" Immediate mode: %s verts/sec\n", PerfHumanFloat(rate));
rate = PerfMeasureRate(DrawArraysMem);
rate *= NumVerts;
perf_printf(" glDrawArrays: %s verts/sec\n", PerfHumanFloat(rate));
rate = PerfMeasureRate(DrawArraysVBO);
rate *= NumVerts;
perf_printf(" VBO glDrawArrays: %s verts/sec\n", PerfHumanFloat(rate));
rate = PerfMeasureRate(DrawElementsMem);
rate *= NumVerts;
perf_printf(" glDrawElements: %s verts/sec\n", PerfHumanFloat(rate));
rate = PerfMeasureRate(DrawElementsBO);
rate *= NumVerts;
perf_printf(" VBO glDrawElements: %s verts/sec\n", PerfHumanFloat(rate));
rate = PerfMeasureRate(DrawRangeElementsMem);
rate *= NumVerts;
perf_printf(" glDrawRangeElements: %s verts/sec\n", PerfHumanFloat(rate));
rate = PerfMeasureRate(DrawRangeElementsBO);
rate *= NumVerts;
perf_printf(" VBO glDrawRangeElements: %s verts/sec\n", PerfHumanFloat(rate));
exit(0);
}

View File

@@ -45,4 +45,4 @@ $(OBJECTS): %.o: %.c
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $(PROG_DEFINES) $< -o $@
$(PROGS): %: %.o
$(CC) $(LDFLAGS) $< $(LINKS) -lm -o $@
$(CC) $(LDFLAGS) $< $(LINKS) -o $@

View File

@@ -56,7 +56,7 @@ static float rotAngle = 0.;
* at RAMP1START, and a blue color ramp starting
* at RAMP2START. The ramps must be a multiple of 16.
*/
void init(void)
static void init(void)
{
int i;
@@ -76,7 +76,7 @@ void init(void)
/* Draw 2 diagonal lines to form an X
*/
void display(void)
static void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
@@ -101,7 +101,7 @@ void display(void)
glFlush();
}
void reshape(int w, int h)
static void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
@@ -117,7 +117,7 @@ void reshape(int w, int h)
}
/* ARGSUSED1 */
void keyboard(unsigned char key, int x, int y)
static void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 'r':

View File

@@ -59,7 +59,7 @@ static void init(void)
#define NFACE 6
#define NVERT 8
void drawCube(GLdouble x0, GLdouble x1, GLdouble y0, GLdouble y1,
static void drawCube(GLdouble x0, GLdouble x1, GLdouble y0, GLdouble y1,
GLdouble z0, GLdouble z1)
{
static GLfloat v[8][3];
@@ -101,7 +101,7 @@ void drawCube(GLdouble x0, GLdouble x1, GLdouble y0, GLdouble y1,
/* Note: polygons must be drawn from front to back
* for proper blending.
*/
void display(void)
static void display(void)
{
if (polySmooth) {
glClear (GL_COLOR_BUFFER_BIT);
@@ -126,7 +126,7 @@ void display(void)
glFlush ();
}
void reshape(int w, int h)
static void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
@@ -137,7 +137,7 @@ void reshape(int w, int h)
}
/* ARGSUSED1 */
void keyboard(unsigned char key, int x, int y)
static void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 't':

View File

@@ -51,7 +51,7 @@ static float rotAngle = 0.;
* blending, hint, and line width. Print out implementation
* specific info on line width granularity and width.
*/
void init(void)
static void init(void)
{
GLfloat values[2];
glGetFloatv (GL_LINE_WIDTH_GRANULARITY, values);
@@ -72,7 +72,7 @@ void init(void)
/* Draw 2 diagonal lines to form an X
*/
void display(void)
static void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
@@ -97,7 +97,7 @@ void display(void)
glFlush();
}
void reshape(int w, int h)
static void reshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
@@ -113,7 +113,7 @@ void reshape(int w, int h)
}
/* ARGSUSED1 */
void keyboard(unsigned char key, int x, int y)
static void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 'r':

View File

@@ -45,7 +45,7 @@
/* Initialize lighting and other values.
*/
void myinit(void)
static void myinit(void)
{
GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -68,7 +68,7 @@ void myinit(void)
glClearAccum(0.0, 0.0, 0.0, 0.0);
}
void displayObjects(void)
static void displayObjects(void)
{
GLfloat torus_diffuse[] = { 0.7, 0.7, 0.0, 1.0 };
GLfloat cube_diffuse[] = { 0.0, 0.7, 0.7, 1.0 };
@@ -111,7 +111,7 @@ void displayObjects(void)
#define ACSIZE 8
void display(void)
static void display(void)
{
GLint viewport[4];
int jitter;
@@ -137,7 +137,7 @@ void display(void)
glFlush();
}
void myReshape(int w, int h)
static void myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);

View File

@@ -62,7 +62,7 @@
* probably want to insure that your ModelView matrix has been
* initialized to identity before calling accFrustum().
*/
void accFrustum(GLdouble left, GLdouble right, GLdouble bottom,
static void accFrustum(GLdouble left, GLdouble right, GLdouble bottom,
GLdouble top, GLdouble nnear, GLdouble ffar, GLdouble pixdx,
GLdouble pixdy, GLdouble eyedx, GLdouble eyedy, GLdouble focus)
{
@@ -99,7 +99,7 @@ void accFrustum(GLdouble left, GLdouble right, GLdouble bottom,
*
* Note that accPerspective() calls accFrustum().
*/
void accPerspective(GLdouble fovy, GLdouble aspect,
static void accPerspective(GLdouble fovy, GLdouble aspect,
GLdouble nnear, GLdouble ffar, GLdouble pixdx, GLdouble pixdy,
GLdouble eyedx, GLdouble eyedy, GLdouble focus)
{
@@ -119,7 +119,7 @@ void accPerspective(GLdouble fovy, GLdouble aspect,
/* Initialize lighting and other values.
*/
void init(void)
static void init(void)
{
GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
@@ -141,7 +141,7 @@ void init(void)
glClearAccum(0.0, 0.0, 0.0, 0.0);
}
void displayObjects(void)
static void displayObjects(void)
{
GLfloat torus_diffuse[] = { 0.7, 0.7, 0.0, 1.0 };
GLfloat cube_diffuse[] = { 0.0, 0.7, 0.7, 1.0 };
@@ -185,7 +185,7 @@ void displayObjects(void)
#define ACSIZE 8
void display(void)
static void display(void)
{
GLint viewport[4];
int jitter;
@@ -205,13 +205,13 @@ void display(void)
glFlush();
}
void reshape(int w, int h)
static void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
}
/* ARGSUSED1 */
void keyboard(unsigned char key, int x, int y)
static void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27:

View File

@@ -80,7 +80,7 @@ static void drawRightTriangle(void)
glEnd();
}
void display(void)
static void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
@@ -96,7 +96,7 @@ void display(void)
glFlush();
}
void reshape(int w, int h)
static void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
@@ -108,7 +108,7 @@ void reshape(int w, int h)
}
/* ARGSUSED1 */
void keyboard(unsigned char key, int x, int y)
static void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 't':

View File

@@ -80,7 +80,7 @@ static void init(void)
glEndList();
}
void display(void)
static void display(void)
{
GLfloat mat_solid[] = { 0.75, 0.75, 0.0, 1.0 };
GLfloat mat_zero[] = { 0.0, 0.0, 0.0, 1.0 };
@@ -113,7 +113,7 @@ void display(void)
glutSwapBuffers();
}
void reshape(int w, int h)
static void reshape(int w, int h)
{
glViewport(0, 0, (GLint) w, (GLint) h);
glMatrixMode(GL_PROJECTION);
@@ -128,7 +128,7 @@ void reshape(int w, int h)
glLoadIdentity();
}
void animate(void)
static void animate(void)
{
static double t0 = -1.;
if (solidZ <= MINZ || transparentZ >= MAXZ)
@@ -150,7 +150,7 @@ void animate(void)
}
/* ARGSUSED1 */
void keyboard(unsigned char key, int x, int y)
static void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 'a':

View File

@@ -49,7 +49,7 @@
* blending, hint, and line width. Print out implementation
* specific info on line width granularity and width.
*/
void myinit(void)
static void myinit(void)
{
GLfloat values[2];
glGetFloatv (GL_LINE_WIDTH_GRANULARITY, values);
@@ -73,7 +73,7 @@ void myinit(void)
/* display() draws an icosahedron with a large alpha value, 1.0.
*/
void display(void)
static void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor4f (1.0, 1.0, 1.0, 1.0);
@@ -81,7 +81,7 @@ void display(void)
glFlush();
}
void myReshape(int w, int h)
static void myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);

View File

@@ -45,7 +45,7 @@ GLfloat ctrlpoints[4][3] = {
{ -4.0, -4.0, 0.0}, { -2.0, 4.0, 0.0},
{2.0, -4.0, 0.0}, {4.0, 4.0, 0.0}};
void init(void)
static void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
@@ -53,7 +53,7 @@ void init(void)
glEnable(GL_MAP1_VERTEX_3);
}
void display(void)
static void display(void)
{
int i;
@@ -73,7 +73,7 @@ void display(void)
glFlush();
}
void reshape(int w, int h)
static void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
@@ -89,7 +89,7 @@ void reshape(int w, int h)
}
/* ARGSUSED1 */
void keyboard(unsigned char key, int x, int y)
static void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27:

View File

@@ -68,7 +68,7 @@ GLfloat ctrlpoints[4][4][3] =
{1.5, 1.5, -1.0}}
};
void
static void
initlights(void)
{
GLfloat ambient[] =
@@ -93,7 +93,7 @@ initlights(void)
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
}
void
static void
display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -104,7 +104,7 @@ display(void)
glFlush();
}
void
static void
myinit(void)
{
glClearColor(0.0, 0.0, 0.0, 1.0);
@@ -118,7 +118,7 @@ myinit(void)
initlights(); /* for lighted version only */
}
void
static void
myReshape(int w, int h)
{
glViewport(0, 0, w, h);

View File

@@ -50,7 +50,7 @@
#define checkImageHeight 64
GLubyte checkImage[checkImageWidth][checkImageHeight][3];
void makeCheckImage(void)
static void makeCheckImage(void)
{
int i, j, c;
@@ -64,7 +64,7 @@ void makeCheckImage(void)
}
}
void myinit(void)
static void myinit(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glEnable(GL_DEPTH_TEST);
@@ -84,7 +84,7 @@ void myinit(void)
glShadeModel(GL_FLAT);
}
void display(void)
static void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_QUADS);
@@ -101,7 +101,7 @@ void display(void)
glutSwapBuffers();
}
void myReshape(int w, int h)
static void myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);

View File

@@ -42,13 +42,13 @@
#include <GL/glut.h>
#include <stdlib.h>
void init(void)
static void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
}
void display(void)
static void display(void)
{
GLdouble eqn[4] = {0.0, 1.0, 0.0, 0.0};
GLdouble eqn2[4] = {1.0, 0.0, 0.0, 0.0};
@@ -73,7 +73,7 @@ void display(void)
glFlush ();
}
void reshape (int w, int h)
static void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
@@ -83,7 +83,7 @@ void reshape (int w, int h)
}
/* ARGSUSED1 */
void keyboard(unsigned char key, int x, int y)
static void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27:

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