Compare commits
1 Commits
mesa_7_7_1
...
mesa_7_6_1
Author | SHA1 | Date | |
---|---|---|---|
|
b8f6444a07 |
30
Makefile
30
Makefile
@@ -182,7 +182,7 @@ ultrix-gcc:
|
||||
|
||||
# Rules for making release tarballs
|
||||
|
||||
VERSION=7.7.1-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
|
||||
|
10
SConstruct
10
SConstruct
@@ -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')))
|
||||
|
||||
@@ -110,8 +110,6 @@ if platform in ('posix', 'linux', 'freebsd', 'darwin'):
|
||||
'PTHREADS',
|
||||
'HAVE_POSIX_MEMALIGN',
|
||||
])
|
||||
if platform == 'darwin':
|
||||
env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
|
||||
env.Append(CPPPATH = ['/usr/X11R6/include'])
|
||||
env.Append(LIBPATH = ['/usr/X11R6/lib'])
|
||||
env.Append(LIBS = [
|
||||
|
@@ -920,11 +920,6 @@ case $ARCH in
|
||||
|
||||
# make lib
|
||||
${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
|
||||
# make build fail if link failed
|
||||
es=$?
|
||||
if [ "$es" -ne "0" ]; then
|
||||
exit $es
|
||||
fi
|
||||
# make usual symlinks
|
||||
ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
|
||||
# finish up
|
||||
|
309
bin/win32kprof.py
Executable file
309
bin/win32kprof.py
Executable 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()
|
||||
|
@@ -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 gallium glu glut/glx glew
|
||||
SRC_DIRS = glx/x11 mesa glu glut/glx glew
|
||||
GLU_DIRS = sgi
|
||||
DRIVER_DIRS = osmesa
|
||||
#DRIVER_DIRS = dri
|
||||
|
@@ -9,7 +9,7 @@ CONFIG_NAME = default
|
||||
|
||||
# Version info
|
||||
MESA_MAJOR=7
|
||||
MESA_MINOR=7
|
||||
MESA_MINOR=6
|
||||
MESA_TINY=1
|
||||
MESA_VERSION = $(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY)
|
||||
|
||||
@@ -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 =
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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
|
||||
|
59
configure.ac
59
configure.ac
@@ -18,10 +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
|
||||
LIBDRM_XORG_REQUIRED=2.4.17
|
||||
LIBKMS_XORG_REQUIRED=1.0.0
|
||||
DRI2PROTO_REQUIRED=1.99.3
|
||||
|
||||
dnl Check for progs
|
||||
@@ -93,9 +91,6 @@ linux*|*-gnu*|gnu*)
|
||||
solaris*)
|
||||
DEFINES="$DEFINES -DPTHREADS -DSVR4"
|
||||
;;
|
||||
cygwin*)
|
||||
DEFINES="$DEFINES -DPTHREADS"
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl Add flags for gcc and g++
|
||||
@@ -425,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=""
|
||||
|
||||
@@ -781,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'`
|
||||
@@ -1149,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 libdrm >= $LIBDRM_XORG_REQUIRED libkms >= $LIBKMS_XORG_REQUIRED],
|
||||
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
|
||||
;;
|
||||
@@ -1171,21 +1159,15 @@ yes)
|
||||
AC_MSG_ERROR([cannot build egl state tracker without EGL library])
|
||||
fi
|
||||
if test "$tracker" = xorg; then
|
||||
PKG_CHECK_MODULES([LIBDRM_XORG], [libdrm >= $LIBDRM_XORG_REQUIRED])
|
||||
PKG_CHECK_MODULES([LIBKMS_XORG], [libkms >= $LIBKMS_XORG_REQUIRED])
|
||||
HAVE_XORG="yes"
|
||||
PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
|
||||
HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71",
|
||||
HAVE_XEXTPROTO_71="no")
|
||||
fi
|
||||
done
|
||||
GALLIUM_STATE_TRACKERS_DIRS="$state_trackers"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test "x$HAVE_XORG" = xyes; then
|
||||
PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
|
||||
HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71",
|
||||
HAVE_XEXTPROTO_71="no")
|
||||
fi
|
||||
|
||||
AC_ARG_WITH([xorg-driver-dir],
|
||||
[AS_HELP_STRING([--with-xorg-driver-dir=DIR],
|
||||
[Default xorg driver directory[[default=${libdir}/xorg/modules/drivers]]])],
|
||||
@@ -1208,34 +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([--enable-gallium-svga],
|
||||
[build gallium SVGA @<:@default=disabled@:>@])],
|
||||
[enable_gallium_svga="$enableval"],
|
||||
[enable_gallium_svga=auto])
|
||||
if test "x$enable_gallium_svga" = xyes; then
|
||||
GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS vmware"
|
||||
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS svga"
|
||||
elif test "x$enable_gallium_svga" = xauto; then
|
||||
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
|
||||
|
@@ -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>
|
||||
@@ -51,24 +50,5 @@ See the <A HREF="xlibdriver.html">Xlib software driver page</A> for details.
|
||||
</ul>
|
||||
|
||||
|
||||
<p>
|
||||
These environment variables are for the Intel i945/i965 drivers:
|
||||
</p>
|
||||
<ul>
|
||||
<li>INTEL_STRICT_CONFORMANCE - if set to 1, enable sw fallbacks to improve
|
||||
OpenGL conformance. If set to 2, always use software rendering.
|
||||
<li>INTEL_NO_BLIT - if set, disable hardware-accelerated glBitmap,
|
||||
glCopyPixels, glDrawPixels.
|
||||
</ul>
|
||||
|
||||
|
||||
<p>
|
||||
These environment variables are for the Radeon R300 driver:
|
||||
</p>
|
||||
<ul>
|
||||
<li>R300_NO_TCL - if set, disable hardware-accelerated Transform/Clip/Lighting.
|
||||
</ul>
|
||||
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
@@ -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>
|
||||
|
197
docs/libGL.txt
197
docs/libGL.txt
@@ -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.
|
||||
|
@@ -13,41 +13,36 @@
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="https://lists.sourceforge.net/lists/listinfo/mesa3d-announce"
|
||||
target="_parent">mesa3d-announce</a> - announcements of new Mesa
|
||||
versions are sent to this list.
|
||||
</li>
|
||||
<br>
|
||||
<li><a href="https://lists.sourceforge.net/lists/listinfo/mesa3d-users"
|
||||
target="_parent">mesa3d-users</a> - intended for end-users of Mesa and DRI
|
||||
drivers. Newbie questions are OK, but please try the general OpenGL
|
||||
target="_parent">mesa3d-users</a> - intended for users of the Mesa and DRI.
|
||||
Newbie questions are appropriate, but please try the general OpenGL
|
||||
resources and Mesa/DRI documentation first.
|
||||
</li>
|
||||
<br>
|
||||
<li><a href="https://lists.sourceforge.net/lists/listinfo/mesa3d-dev"
|
||||
target="_parent">mesa3d-dev</a> - for Mesa, Gallium and DRI development
|
||||
discussion. Not for beginners.
|
||||
target="_parent">mesa3d-dev</a> - for discussion of Mesa and Direct Rendering
|
||||
Infrastructure development. Not for beginners.
|
||||
</li>
|
||||
<br>
|
||||
<li><a href="http://lists.freedesktop.org/mailman/listinfo/mesa-commit"
|
||||
target="_parent">mesa-commit</a> - relays git check-in messages
|
||||
(for developers).
|
||||
In general, people should not post to this list.
|
||||
</li>
|
||||
<br>
|
||||
<li><a href="https://lists.sourceforge.net/lists/listinfo/mesa3d-announce"
|
||||
target="_parent">mesa3d-announce</a> - announcements of new Mesa
|
||||
versions are sent to this list. Very low traffic.
|
||||
Note: the old mesa3d-cvs list is no longer in use.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
Follow the links above for list archives.
|
||||
</p>
|
||||
|
||||
<p>For mailing lists about Direct Rendering Modules (drm) in Linux/BSD
|
||||
kernels, see the
|
||||
<a href="http://dri.freedesktop.org/wiki/MailingLists" target="_parent">
|
||||
DRI wiki</a>.
|
||||
</p>
|
||||
kernels, see <a href="http://dri.freedesktop.org/wiki/MailingLists">wiki</a>.
|
||||
|
||||
<p>
|
||||
<b>Notice</b>: You must subscribe to these lists in order to post to them.
|
||||
<b>Notice</b>: non-member posts to any of these lists will be automatically
|
||||
rejected.
|
||||
</p>
|
||||
|
||||
|
||||
|
@@ -10,15 +10,11 @@
|
||||
|
||||
<H1>News</H1>
|
||||
|
||||
<h2>December 21, 2009</h2>
|
||||
<h2>November XX, 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.
|
||||
</p>
|
||||
<p>
|
||||
Also, <a href="relnotes-7.7.html">Mesa 7.7</a> is released. This is a new
|
||||
development release.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>September 28, 2009</h2>
|
||||
|
@@ -26,7 +26,7 @@ more information about the API functions.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
There are several examples of OSMesa in the <code>progs/osdemos/</code>
|
||||
There are several examples of OSMesa in the <code>progs/osdemo/</code>
|
||||
directory.
|
||||
</p>
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
<body bgcolor="#eeeeee">
|
||||
|
||||
<H1>Mesa 7.6.1 Release Notes, 21 December 2009</H1>
|
||||
<H1>Mesa 7.6.1 Release Notes, (date tbd)</H1>
|
||||
|
||||
<p>
|
||||
Mesa 7.6.1 is a bug-fix release fixing issues since version 7.6.
|
||||
@@ -26,15 +26,7 @@ for DRI hardware acceleration.
|
||||
|
||||
<h2>MD5 checksums</h2>
|
||||
<pre>
|
||||
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
|
||||
tbd
|
||||
</pre>
|
||||
|
||||
|
||||
|
@@ -1,52 +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.1 Release Notes / date tbd</H1>
|
||||
|
||||
<p>
|
||||
Mesa 7.7.1 is a bug-fix release.
|
||||
</p>
|
||||
<p>
|
||||
Mesa 7.7.1 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>Bug fixes</h2>
|
||||
<ul>
|
||||
<li>Assorted fixes to VMware SVGA gallium driver.
|
||||
<li>Fixed broken blending to multiple color buffers in swrast driver.
|
||||
<li>Allocate constants more tightly in GL_ARB_vertex/fragment parser.
|
||||
<li>Fixed mipmap generation bug caused by invalid viewport state.
|
||||
<li>Gallium SSE codegen for XPD didn't always work.
|
||||
<li>Fixed Windows build.
|
||||
<li>Fixed broken glMultiDrawElements().
|
||||
<li>Silence bogus GL errors generated in glxinfo.
|
||||
<li>Fixed several render to texture bugs.
|
||||
<li>Assorted bug fixes in Mesa/Gallium state tracker including
|
||||
glCopy/DrawPixels() to FBOs.
|
||||
<li>Assorted fixes to Gallium drivers.
|
||||
<li>Fixed broken glPush/PopClientAttrib() for vertex arrays in GLX code.
|
||||
</ul>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -1,70 +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 / 21 December 2009</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>
|
||||
395c9516edf1ad54b0934d8db15557bf MesaLib-7.7.tar.gz
|
||||
e3fa64a1508bc23dd9de9dd2cea7cfb1 MesaLib-7.7.tar.bz2
|
||||
e54903eb5e49c3969821fa16b32da245 MesaLib-7.7.zip
|
||||
53b5b6f78e55de170d43c98cb6aaab7e MesaDemos-7.7.tar.gz
|
||||
6fd616b27b9826d0faa23e08e05d9435 MesaDemos-7.7.tar.bz2
|
||||
240fe06159ad73d5e22c27033b66c80a MesaDemos-7.7.zip
|
||||
9fe11a904b2a9d8cd06cc52bc330b716 MesaGLUT-7.7.tar.gz
|
||||
e8dceed05a59a2d3c2619d7d734587e3 MesaGLUT-7.7.tar.bz2
|
||||
96af041d435349ee23ead4667ec36363 MesaGLUT-7.7.zip
|
||||
</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>
|
@@ -13,8 +13,6 @@ The release notes summarize what's new or changed in each Mesa release.
|
||||
</p>
|
||||
|
||||
<UL>
|
||||
<LI><A HREF="relnotes-7.7.1.html">7.7.1 release notes</A>
|
||||
<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>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<HTML>
|
||||
|
||||
<TITLE>Code Repository</TITLE>
|
||||
<TITLE>Cocd Repository</TITLE>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="mesa.css"></head>
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -33,7 +33,8 @@
|
||||
|
||||
- Pipe drivers:
|
||||
- \ref softpipe
|
||||
- \ref i915g
|
||||
- \ref i915simple
|
||||
- Simple 965 driver (brw_context.h, brw_winsys.h)
|
||||
- Cell driver (cell_context.h, cell_winsys.h)
|
||||
- \ref failover
|
||||
|
||||
@@ -119,7 +120,7 @@
|
||||
\sa sp_winsys.h
|
||||
*/
|
||||
|
||||
/** \page i915g i915 Driver
|
||||
/** \page i915simple Simple i915 Driver
|
||||
|
||||
The i915 Gallium3D Driver is an initial hardware driver implementation within
|
||||
the Gallium3D driver architecture. We expect that once complete this driver
|
||||
@@ -162,7 +163,7 @@
|
||||
The Draw module is effectively the part of \ref softpipe which is concerned with
|
||||
vertex processing, split off into a separate module so that it can be reused
|
||||
by drivers for rasterization-only hardware. As such it is also instantiated
|
||||
by the \ref i915g driver.
|
||||
by the \ref i915simple driver.
|
||||
|
||||
Additionally, there are cases in the Mesa OpenGL state_tracker where it is
|
||||
required to obtain transformed vertices and yet it is anticipated that using
|
||||
|
@@ -30,7 +30,6 @@
|
||||
/*REGENERATE_TO_END-----------ALL LINES BELOW HERE GET REPLACED ON REGENERATION */
|
||||
|
||||
#define glAccum MANGLE(Accum)
|
||||
#define glActiveProgramEXT MANGLE(ActiveProgramEXT)
|
||||
#define glActiveStencilFaceEXT MANGLE(ActiveStencilFaceEXT)
|
||||
#define glActiveTextureARB MANGLE(ActiveTextureARB)
|
||||
#define glActiveTexture MANGLE(ActiveTexture)
|
||||
@@ -61,7 +60,6 @@
|
||||
#define glBeginTransformFeedback MANGLE(BeginTransformFeedback)
|
||||
#define glBeginTransformFeedbackNV MANGLE(BeginTransformFeedbackNV)
|
||||
#define glBeginVertexShaderEXT MANGLE(BeginVertexShaderEXT)
|
||||
#define glBeginVideoCaptureNV MANGLE(BeginVideoCaptureNV)
|
||||
#define glBindAttribLocationARB MANGLE(BindAttribLocationARB)
|
||||
#define glBindAttribLocation MANGLE(BindAttribLocation)
|
||||
#define glBindBufferARB MANGLE(BindBufferARB)
|
||||
@@ -95,8 +93,6 @@
|
||||
#define glBindVertexArrayAPPLE MANGLE(BindVertexArrayAPPLE)
|
||||
#define glBindVertexArray MANGLE(BindVertexArray)
|
||||
#define glBindVertexShaderEXT MANGLE(BindVertexShaderEXT)
|
||||
#define glBindVideoCaptureStreamBufferNV MANGLE(BindVideoCaptureStreamBufferNV)
|
||||
#define glBindVideoCaptureStreamTextureNV MANGLE(BindVideoCaptureStreamTextureNV)
|
||||
#define glBinormal3bEXT MANGLE(Binormal3bEXT)
|
||||
#define glBinormal3bvEXT MANGLE(Binormal3bvEXT)
|
||||
#define glBinormal3dEXT MANGLE(Binormal3dEXT)
|
||||
@@ -130,7 +126,6 @@
|
||||
#define glBlendFuncSeparate MANGLE(BlendFuncSeparate)
|
||||
#define glBlitFramebufferEXT MANGLE(BlitFramebufferEXT)
|
||||
#define glBlitFramebuffer MANGLE(BlitFramebuffer)
|
||||
#define glBufferAddressRangeNV MANGLE(BufferAddressRangeNV)
|
||||
#define glBufferDataARB MANGLE(BufferDataARB)
|
||||
#define glBufferData MANGLE(BufferData)
|
||||
#define glBufferParameteriAPPLE MANGLE(BufferParameteriAPPLE)
|
||||
@@ -207,7 +202,6 @@
|
||||
#define glColor4uiv MANGLE(Color4uiv)
|
||||
#define glColor4us MANGLE(Color4us)
|
||||
#define glColor4usv MANGLE(Color4usv)
|
||||
#define glColorFormatNV MANGLE(ColorFormatNV)
|
||||
#define glColorFragmentOp1ATI MANGLE(ColorFragmentOp1ATI)
|
||||
#define glColorFragmentOp2ATI MANGLE(ColorFragmentOp2ATI)
|
||||
#define glColorFragmentOp3ATI MANGLE(ColorFragmentOp3ATI)
|
||||
@@ -282,7 +276,6 @@
|
||||
#define glCopyConvolutionFilter1D MANGLE(CopyConvolutionFilter1D)
|
||||
#define glCopyConvolutionFilter2DEXT MANGLE(CopyConvolutionFilter2DEXT)
|
||||
#define glCopyConvolutionFilter2D MANGLE(CopyConvolutionFilter2D)
|
||||
#define glCopyImageSubDataNV MANGLE(CopyImageSubDataNV)
|
||||
#define glCopyMultiTexImage1DEXT MANGLE(CopyMultiTexImage1DEXT)
|
||||
#define glCopyMultiTexImage2DEXT MANGLE(CopyMultiTexImage2DEXT)
|
||||
#define glCopyMultiTexSubImage1DEXT MANGLE(CopyMultiTexSubImage1DEXT)
|
||||
@@ -309,7 +302,6 @@
|
||||
#define glCreateProgramObjectARB MANGLE(CreateProgramObjectARB)
|
||||
#define glCreateShader MANGLE(CreateShader)
|
||||
#define glCreateShaderObjectARB MANGLE(CreateShaderObjectARB)
|
||||
#define glCreateShaderProgramEXT MANGLE(CreateShaderProgramEXT)
|
||||
#define glCullFace MANGLE(CullFace)
|
||||
#define glCullParameterdvEXT MANGLE(CullParameterdvEXT)
|
||||
#define glCullParameterfvEXT MANGLE(CullParameterfvEXT)
|
||||
@@ -387,7 +379,6 @@
|
||||
#define glDrawRangeElementsEXT MANGLE(DrawRangeElementsEXT)
|
||||
#define glDrawRangeElements MANGLE(DrawRangeElements)
|
||||
#define glDrawTransformFeedbackNV MANGLE(DrawTransformFeedbackNV)
|
||||
#define glEdgeFlagFormatNV MANGLE(EdgeFlagFormatNV)
|
||||
#define glEdgeFlag MANGLE(EdgeFlag)
|
||||
#define glEdgeFlagPointerEXT MANGLE(EdgeFlagPointerEXT)
|
||||
#define glEdgeFlagPointerListIBM MANGLE(EdgeFlagPointerListIBM)
|
||||
@@ -417,7 +408,6 @@
|
||||
#define glEndTransformFeedback MANGLE(EndTransformFeedback)
|
||||
#define glEndTransformFeedbackNV MANGLE(EndTransformFeedbackNV)
|
||||
#define glEndVertexShaderEXT MANGLE(EndVertexShaderEXT)
|
||||
#define glEndVideoCaptureNV MANGLE(EndVideoCaptureNV)
|
||||
#define glEvalCoord1d MANGLE(EvalCoord1d)
|
||||
#define glEvalCoord1dv MANGLE(EvalCoord1dv)
|
||||
#define glEvalCoord1f MANGLE(EvalCoord1f)
|
||||
@@ -455,7 +445,6 @@
|
||||
#define glFogCoorddv MANGLE(FogCoorddv)
|
||||
#define glFogCoordfEXT MANGLE(FogCoordfEXT)
|
||||
#define glFogCoordf MANGLE(FogCoordf)
|
||||
#define glFogCoordFormatNV MANGLE(FogCoordFormatNV)
|
||||
#define glFogCoordfvEXT MANGLE(FogCoordfvEXT)
|
||||
#define glFogCoordfv MANGLE(FogCoordfv)
|
||||
#define glFogCoordhNV MANGLE(FogCoordhNV)
|
||||
@@ -555,7 +544,6 @@
|
||||
#define glGetBufferParameteri64v MANGLE(GetBufferParameteri64v)
|
||||
#define glGetBufferParameterivARB MANGLE(GetBufferParameterivARB)
|
||||
#define glGetBufferParameteriv MANGLE(GetBufferParameteriv)
|
||||
#define glGetBufferParameterui64vNV MANGLE(GetBufferParameterui64vNV)
|
||||
#define glGetBufferPointervARB MANGLE(GetBufferPointervARB)
|
||||
#define glGetBufferPointerv MANGLE(GetBufferPointerv)
|
||||
#define glGetBufferSubDataARB MANGLE(GetBufferSubDataARB)
|
||||
@@ -621,8 +609,6 @@
|
||||
#define glGetInteger64v MANGLE(GetInteger64v)
|
||||
#define glGetIntegerIndexedvEXT MANGLE(GetIntegerIndexedvEXT)
|
||||
#define glGetIntegeri_v MANGLE(GetIntegeri_v)
|
||||
#define glGetIntegerui64i_vNV MANGLE(GetIntegerui64i_vNV)
|
||||
#define glGetIntegerui64vNV MANGLE(GetIntegerui64vNV)
|
||||
#define glGetIntegerv MANGLE(GetIntegerv)
|
||||
#define glGetInvariantBooleanvEXT MANGLE(GetInvariantBooleanvEXT)
|
||||
#define glGetInvariantFloatvEXT MANGLE(GetInvariantFloatvEXT)
|
||||
@@ -665,7 +651,6 @@
|
||||
#define glGetMultiTexParameterIuivEXT MANGLE(GetMultiTexParameterIuivEXT)
|
||||
#define glGetMultiTexParameterivEXT MANGLE(GetMultiTexParameterivEXT)
|
||||
#define glGetNamedBufferParameterivEXT MANGLE(GetNamedBufferParameterivEXT)
|
||||
#define glGetNamedBufferParameterui64vNV MANGLE(GetNamedBufferParameterui64vNV)
|
||||
#define glGetNamedBufferPointervEXT MANGLE(GetNamedBufferPointervEXT)
|
||||
#define glGetNamedBufferSubDataEXT MANGLE(GetNamedBufferSubDataEXT)
|
||||
#define glGetNamedFramebufferAttachmentParameterivEXT MANGLE(GetNamedFramebufferAttachmentParameterivEXT)
|
||||
@@ -776,7 +761,6 @@
|
||||
#define glGetUniformLocationARB MANGLE(GetUniformLocationARB)
|
||||
#define glGetUniformLocation MANGLE(GetUniformLocation)
|
||||
#define glGetUniformOffsetEXT MANGLE(GetUniformOffsetEXT)
|
||||
#define glGetUniformui64vNV MANGLE(GetUniformui64vNV)
|
||||
#define glGetUniformuivEXT MANGLE(GetUniformuivEXT)
|
||||
#define glGetUniformuiv MANGLE(GetUniformuiv)
|
||||
#define glGetVariantArrayObjectfvATI MANGLE(GetVariantArrayObjectfvATI)
|
||||
@@ -804,10 +788,6 @@
|
||||
#define glGetVertexAttribPointervARB MANGLE(GetVertexAttribPointervARB)
|
||||
#define glGetVertexAttribPointerv MANGLE(GetVertexAttribPointerv)
|
||||
#define glGetVertexAttribPointervNV MANGLE(GetVertexAttribPointervNV)
|
||||
#define glGetVideoCaptureivNV MANGLE(GetVideoCaptureivNV)
|
||||
#define glGetVideoCaptureStreamdvNV MANGLE(GetVideoCaptureStreamdvNV)
|
||||
#define glGetVideoCaptureStreamfvNV MANGLE(GetVideoCaptureStreamfvNV)
|
||||
#define glGetVideoCaptureStreamivNV MANGLE(GetVideoCaptureStreamivNV)
|
||||
#define glGetVideoi64vNV MANGLE(GetVideoi64vNV)
|
||||
#define glGetVideoivNV MANGLE(GetVideoivNV)
|
||||
#define glGetVideoui64vNV MANGLE(GetVideoui64vNV)
|
||||
@@ -832,7 +812,6 @@
|
||||
#define glIndexd MANGLE(Indexd)
|
||||
#define glIndexdv MANGLE(Indexdv)
|
||||
#define glIndexf MANGLE(Indexf)
|
||||
#define glIndexFormatNV MANGLE(IndexFormatNV)
|
||||
#define glIndexFuncEXT MANGLE(IndexFuncEXT)
|
||||
#define glIndexfv MANGLE(Indexfv)
|
||||
#define glIndexi MANGLE(Indexi)
|
||||
@@ -853,7 +832,6 @@
|
||||
#define glIsAsyncMarkerSGIX MANGLE(IsAsyncMarkerSGIX)
|
||||
#define glIsBufferARB MANGLE(IsBufferARB)
|
||||
#define glIsBuffer MANGLE(IsBuffer)
|
||||
#define glIsBufferResidentNV MANGLE(IsBufferResidentNV)
|
||||
#define glIsEnabledi MANGLE(IsEnabledi)
|
||||
#define glIsEnabledIndexedEXT MANGLE(IsEnabledIndexedEXT)
|
||||
#define glIsEnabled MANGLE(IsEnabled)
|
||||
@@ -862,7 +840,6 @@
|
||||
#define glIsFramebufferEXT MANGLE(IsFramebufferEXT)
|
||||
#define glIsFramebuffer MANGLE(IsFramebuffer)
|
||||
#define glIsList MANGLE(IsList)
|
||||
#define glIsNamedBufferResidentNV MANGLE(IsNamedBufferResidentNV)
|
||||
#define glIsObjectBufferATI MANGLE(IsObjectBufferATI)
|
||||
#define glIsOcclusionQueryNV MANGLE(IsOcclusionQueryNV)
|
||||
#define glIsProgramARB MANGLE(IsProgramARB)
|
||||
@@ -911,8 +888,6 @@
|
||||
#define glLoadTransposeMatrixf MANGLE(LoadTransposeMatrixf)
|
||||
#define glLockArraysEXT MANGLE(LockArraysEXT)
|
||||
#define glLogicOp MANGLE(LogicOp)
|
||||
#define glMakeBufferNonResidentNV MANGLE(MakeBufferNonResidentNV)
|
||||
#define glMakeBufferResidentNV MANGLE(MakeBufferResidentNV)
|
||||
#define glMap1d MANGLE(Map1d)
|
||||
#define glMap1f MANGLE(Map1f)
|
||||
#define glMap2d MANGLE(Map2d)
|
||||
@@ -1085,8 +1060,6 @@
|
||||
#define glNamedFramebufferTextureEXT MANGLE(NamedFramebufferTextureEXT)
|
||||
#define glNamedFramebufferTextureFaceEXT MANGLE(NamedFramebufferTextureFaceEXT)
|
||||
#define glNamedFramebufferTextureLayerEXT MANGLE(NamedFramebufferTextureLayerEXT)
|
||||
#define glNamedMakeBufferNonResidentNV MANGLE(NamedMakeBufferNonResidentNV)
|
||||
#define glNamedMakeBufferResidentNV MANGLE(NamedMakeBufferResidentNV)
|
||||
#define glNamedProgramLocalParameter4dEXT MANGLE(NamedProgramLocalParameter4dEXT)
|
||||
#define glNamedProgramLocalParameter4dvEXT MANGLE(NamedProgramLocalParameter4dvEXT)
|
||||
#define glNamedProgramLocalParameter4fEXT MANGLE(NamedProgramLocalParameter4fEXT)
|
||||
@@ -1118,7 +1091,6 @@
|
||||
#define glNormal3iv MANGLE(Normal3iv)
|
||||
#define glNormal3s MANGLE(Normal3s)
|
||||
#define glNormal3sv MANGLE(Normal3sv)
|
||||
#define glNormalFormatNV MANGLE(NormalFormatNV)
|
||||
#define glNormalPointerEXT MANGLE(NormalPointerEXT)
|
||||
#define glNormalPointerListIBM MANGLE(NormalPointerListIBM)
|
||||
#define glNormalPointer MANGLE(NormalPointer)
|
||||
@@ -1262,8 +1234,6 @@
|
||||
#define glProgramUniformMatrix4fvEXT MANGLE(ProgramUniformMatrix4fvEXT)
|
||||
#define glProgramUniformMatrix4x2fvEXT MANGLE(ProgramUniformMatrix4x2fvEXT)
|
||||
#define glProgramUniformMatrix4x3fvEXT MANGLE(ProgramUniformMatrix4x3fvEXT)
|
||||
#define glProgramUniformui64NV MANGLE(ProgramUniformui64NV)
|
||||
#define glProgramUniformui64vNV MANGLE(ProgramUniformui64vNV)
|
||||
#define glProgramVertexLimitNV MANGLE(ProgramVertexLimitNV)
|
||||
#define glProvokingVertexEXT MANGLE(ProvokingVertexEXT)
|
||||
#define glProvokingVertex MANGLE(ProvokingVertex)
|
||||
@@ -1392,7 +1362,6 @@
|
||||
#define glSecondaryColor3us MANGLE(SecondaryColor3us)
|
||||
#define glSecondaryColor3usvEXT MANGLE(SecondaryColor3usvEXT)
|
||||
#define glSecondaryColor3usv MANGLE(SecondaryColor3usv)
|
||||
#define glSecondaryColorFormatNV MANGLE(SecondaryColorFormatNV)
|
||||
#define glSecondaryColorPointerEXT MANGLE(SecondaryColorPointerEXT)
|
||||
#define glSecondaryColorPointerListIBM MANGLE(SecondaryColorPointerListIBM)
|
||||
#define glSecondaryColorPointer MANGLE(SecondaryColorPointer)
|
||||
@@ -1506,7 +1475,6 @@
|
||||
#define glTexCoord4iv MANGLE(TexCoord4iv)
|
||||
#define glTexCoord4s MANGLE(TexCoord4s)
|
||||
#define glTexCoord4sv MANGLE(TexCoord4sv)
|
||||
#define glTexCoordFormatNV MANGLE(TexCoordFormatNV)
|
||||
#define glTexCoordPointerEXT MANGLE(TexCoordPointerEXT)
|
||||
#define glTexCoordPointerListIBM MANGLE(TexCoordPointerListIBM)
|
||||
#define glTexCoordPointer MANGLE(TexCoordPointer)
|
||||
@@ -1545,7 +1513,6 @@
|
||||
#define glTexSubImage3DEXT MANGLE(TexSubImage3DEXT)
|
||||
#define glTexSubImage3D MANGLE(TexSubImage3D)
|
||||
#define glTexSubImage4DSGIS MANGLE(TexSubImage4DSGIS)
|
||||
#define glTextureBarrierNV MANGLE(TextureBarrierNV)
|
||||
#define glTextureBufferEXT MANGLE(TextureBufferEXT)
|
||||
#define glTextureColorMaskSGIS MANGLE(TextureColorMaskSGIS)
|
||||
#define glTextureImage1DEXT MANGLE(TextureImage1DEXT)
|
||||
@@ -1634,8 +1601,6 @@
|
||||
#define glUniformMatrix4fv MANGLE(UniformMatrix4fv)
|
||||
#define glUniformMatrix4x2fv MANGLE(UniformMatrix4x2fv)
|
||||
#define glUniformMatrix4x3fv MANGLE(UniformMatrix4x3fv)
|
||||
#define glUniformui64NV MANGLE(Uniformui64NV)
|
||||
#define glUniformui64vNV MANGLE(Uniformui64vNV)
|
||||
#define glUnlockArraysEXT MANGLE(UnlockArraysEXT)
|
||||
#define glUnmapBufferARB MANGLE(UnmapBufferARB)
|
||||
#define glUnmapBuffer MANGLE(UnmapBuffer)
|
||||
@@ -1644,7 +1609,6 @@
|
||||
#define glUpdateObjectBufferATI MANGLE(UpdateObjectBufferATI)
|
||||
#define glUseProgram MANGLE(UseProgram)
|
||||
#define glUseProgramObjectARB MANGLE(UseProgramObjectARB)
|
||||
#define glUseShaderProgramEXT MANGLE(UseShaderProgramEXT)
|
||||
#define glValidateProgramARB MANGLE(ValidateProgramARB)
|
||||
#define glValidateProgram MANGLE(ValidateProgram)
|
||||
#define glVariantArrayObjectATI MANGLE(VariantArrayObjectATI)
|
||||
@@ -1798,7 +1762,6 @@
|
||||
#define glVertexAttrib4usv MANGLE(VertexAttrib4usv)
|
||||
#define glVertexAttribArrayObjectATI MANGLE(VertexAttribArrayObjectATI)
|
||||
#define glVertexAttribDivisorARB MANGLE(VertexAttribDivisorARB)
|
||||
#define glVertexAttribFormatNV MANGLE(VertexAttribFormatNV)
|
||||
#define glVertexAttribI1iEXT MANGLE(VertexAttribI1iEXT)
|
||||
#define glVertexAttribI1i MANGLE(VertexAttribI1i)
|
||||
#define glVertexAttribI1ivEXT MANGLE(VertexAttribI1ivEXT)
|
||||
@@ -1839,7 +1802,6 @@
|
||||
#define glVertexAttribI4uiv MANGLE(VertexAttribI4uiv)
|
||||
#define glVertexAttribI4usvEXT MANGLE(VertexAttribI4usvEXT)
|
||||
#define glVertexAttribI4usv MANGLE(VertexAttribI4usv)
|
||||
#define glVertexAttribIFormatNV MANGLE(VertexAttribIFormatNV)
|
||||
#define glVertexAttribIPointerEXT MANGLE(VertexAttribIPointerEXT)
|
||||
#define glVertexAttribIPointer MANGLE(VertexAttribIPointer)
|
||||
#define glVertexAttribPointerARB MANGLE(VertexAttribPointerARB)
|
||||
@@ -1865,7 +1827,6 @@
|
||||
#define glVertexBlendARB MANGLE(VertexBlendARB)
|
||||
#define glVertexBlendEnvfATI MANGLE(VertexBlendEnvfATI)
|
||||
#define glVertexBlendEnviATI MANGLE(VertexBlendEnviATI)
|
||||
#define glVertexFormatNV MANGLE(VertexFormatNV)
|
||||
#define glVertexPointerEXT MANGLE(VertexPointerEXT)
|
||||
#define glVertexPointerListIBM MANGLE(VertexPointerListIBM)
|
||||
#define glVertexPointer MANGLE(VertexPointer)
|
||||
@@ -1907,10 +1868,6 @@
|
||||
#define glVertexWeighthNV MANGLE(VertexWeighthNV)
|
||||
#define glVertexWeighthvNV MANGLE(VertexWeighthvNV)
|
||||
#define glVertexWeightPointerEXT MANGLE(VertexWeightPointerEXT)
|
||||
#define glVideoCaptureNV MANGLE(VideoCaptureNV)
|
||||
#define glVideoCaptureStreamParameterdvNV MANGLE(VideoCaptureStreamParameterdvNV)
|
||||
#define glVideoCaptureStreamParameterfvNV MANGLE(VideoCaptureStreamParameterfvNV)
|
||||
#define glVideoCaptureStreamParameterivNV MANGLE(VideoCaptureStreamParameterivNV)
|
||||
#define glViewport MANGLE(Viewport)
|
||||
#define glWaitSync MANGLE(WaitSync)
|
||||
#define glWeightbvARB MANGLE(WeightbvARB)
|
||||
|
@@ -10,5 +10,4 @@ SConscript([
|
||||
'vpglsl/SConscript',
|
||||
'fp/SConscript',
|
||||
'wgl/SConscript',
|
||||
'perf/SConscript',
|
||||
])
|
||||
|
@@ -124,6 +124,13 @@ reflect.o: reflect.c showbuffer.h
|
||||
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) reflect.c
|
||||
|
||||
|
||||
shadowtex: shadowtex.o showbuffer.o
|
||||
$(APP_CC) $(CFLAGS) $(LDFLAGS) shadowtex.o showbuffer.o $(LIBS) -o $@
|
||||
|
||||
shadowtex.o: shadowtex.c showbuffer.h
|
||||
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c
|
||||
|
||||
|
||||
gloss: gloss.o trackball.o readtex.o
|
||||
$(APP_CC) $(CFLAGS) $(LDFLAGS) gloss.o trackball.o readtex.o $(LIBS) -o $@
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -120,11 +120,7 @@ static Engine Engines[NUM_ENGINES] =
|
||||
0.3, /* CrankJournalRadius */
|
||||
0.4, /* CrankJournalLength */
|
||||
1.5, /* ConnectingRodLength */
|
||||
0.1, /* ConnectingRodThickness */
|
||||
0, /* CrankList */
|
||||
0, /* ConnRodList */
|
||||
0, /* PistonList */
|
||||
0 /* BlockList */
|
||||
0.1 /* ConnectingRodThickness */
|
||||
},
|
||||
{
|
||||
"Inline-4",
|
||||
@@ -140,11 +136,7 @@ static Engine Engines[NUM_ENGINES] =
|
||||
0.3, /* CrankJournalRadius */
|
||||
0.4, /* CrankJournalLength */
|
||||
1.5, /* ConnectingRodLength */
|
||||
0.1, /* ConnectingRodThickness */
|
||||
0, /* CrankList */
|
||||
0, /* ConnRodList */
|
||||
0, /* PistonList */
|
||||
0 /* BlockList */
|
||||
0.1 /* ConnectingRodThickness */
|
||||
},
|
||||
{
|
||||
"Boxer-6",
|
||||
@@ -160,11 +152,7 @@ static Engine Engines[NUM_ENGINES] =
|
||||
0.3, /* CrankJournalRadius */
|
||||
0.4, /* CrankJournalLength */
|
||||
1.5, /* ConnectingRodLength */
|
||||
0.1, /* ConnectingRodThickness */
|
||||
0, /* CrankList */
|
||||
0, /* ConnRodList */
|
||||
0, /* PistonList */
|
||||
0 /* BlockList */
|
||||
0.1 /* ConnectingRodThickness */
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
/*
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "extfuncs.h"
|
||||
|
||||
/* For debug */
|
||||
|
@@ -6,7 +6,6 @@
|
||||
* Humanware s.r.l.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
@@ -726,13 +725,8 @@ main(int ac, char **av)
|
||||
|
||||
maxage = 1.0 / dt;
|
||||
|
||||
if (ac == 2) {
|
||||
if (ac == 2)
|
||||
np = atoi(av[1]);
|
||||
if (np <= 0 || np > 1000000) {
|
||||
fprintf(stderr, "Invalid input.\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
if (ac == 4) {
|
||||
WIDTH = atoi(av[2]);
|
||||
@@ -765,9 +759,7 @@ main(int ac, char **av)
|
||||
glFogfv(GL_FOG_COLOR, fogcolor);
|
||||
glFogf(GL_FOG_DENSITY, 0.1);
|
||||
|
||||
assert(np > 0);
|
||||
p = (part *) malloc(sizeof(part) * np);
|
||||
assert(p);
|
||||
|
||||
for (i = 0; i < np; i++)
|
||||
setnewpart(&p[i]);
|
||||
|
@@ -25,7 +25,6 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
@@ -130,10 +129,8 @@ Clear_Buffers ()
|
||||
static void
|
||||
LoadTriplet (TDA A)
|
||||
{
|
||||
int result;
|
||||
Clear_Buffers ();
|
||||
result = fscanf (mainfile, "%s %s %s %s", Buf1, Buf2, Buf3, Buf4);
|
||||
assert(result != EOF);
|
||||
fscanf (mainfile, "%s %s %s %s", Buf1, Buf2, Buf3, Buf4);
|
||||
A[0] = atof (Buf2);
|
||||
A[1] = atof (Buf3);
|
||||
A[2] = atof (Buf4);
|
||||
@@ -143,10 +140,8 @@ LoadTriplet (TDA A)
|
||||
static void
|
||||
LoadReal (float *a)
|
||||
{
|
||||
int result;
|
||||
Clear_Buffers ();
|
||||
result = fscanf (mainfile, "%s %s", Buf1, Buf2);
|
||||
assert(result != EOF);
|
||||
fscanf (mainfile, "%s %s", Buf1, Buf2);
|
||||
*a = atof (Buf2);
|
||||
}
|
||||
|
||||
@@ -154,10 +149,8 @@ LoadReal (float *a)
|
||||
static void
|
||||
LoadInteger (int *a)
|
||||
{
|
||||
int result;
|
||||
Clear_Buffers ();
|
||||
result = fscanf (mainfile, "%s %s", Buf1, Buf2);
|
||||
assert(result != EOF);
|
||||
fscanf (mainfile, "%s %s", Buf1, Buf2);
|
||||
*a = atoi (Buf2);
|
||||
}
|
||||
|
||||
@@ -165,10 +158,8 @@ LoadInteger (int *a)
|
||||
static void
|
||||
LoadText (char *a)
|
||||
{
|
||||
int result;
|
||||
Clear_Buffers ();
|
||||
result = fscanf (mainfile, "%s %s", Buf1, Buf2);
|
||||
assert(result != EOF);
|
||||
fscanf (mainfile, "%s %s", Buf1, Buf2);
|
||||
strcpy (a, Buf2);
|
||||
}
|
||||
|
||||
@@ -186,10 +177,8 @@ getdata (char filename[])
|
||||
|
||||
do
|
||||
{
|
||||
int result;
|
||||
Clear_Buffers ();
|
||||
result = fscanf (mainfile, "%s", Buf1);
|
||||
(void) result;
|
||||
fscanf (mainfile, "%s", Buf1);
|
||||
if (ferror (mainfile))
|
||||
{
|
||||
printf ("\nError opening file !\n");
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
@@ -131,11 +132,9 @@ static void read_surface( char *filename )
|
||||
|
||||
numverts = 0;
|
||||
while (!feof(f) && numverts<maxverts) {
|
||||
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;
|
||||
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] );
|
||||
numverts++;
|
||||
}
|
||||
numverts--;
|
||||
|
@@ -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;
|
||||
|
@@ -137,6 +137,7 @@ So the angle is:
|
||||
#endif
|
||||
#include <GL/glut.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#define Scale 0.3
|
||||
|
||||
@@ -886,6 +887,5 @@ int main(int argc, char **argv)
|
||||
glutIdleFunc( idle_ );
|
||||
glutDisplayFunc( draw );
|
||||
glutMainLoop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -219,7 +219,7 @@ Display( void )
|
||||
GLint reads = 0;
|
||||
GLint endTime;
|
||||
GLint startTime = glutGet(GLUT_ELAPSED_TIME);
|
||||
GLdouble seconds, mpixels, mpixelsPerSecond;
|
||||
GLdouble seconds, pixelsPerSecond;
|
||||
printf("Benchmarking...\n");
|
||||
do {
|
||||
glReadPixels(APosX, APosY, ImgWidth, ImgHeight,
|
||||
@@ -228,10 +228,9 @@ Display( void )
|
||||
endTime = glutGet(GLUT_ELAPSED_TIME);
|
||||
} while (endTime - startTime < 4000); /* 4 seconds */
|
||||
seconds = (double) (endTime - startTime) / 1000.0;
|
||||
mpixels = reads * (ImgWidth * ImgHeight / (1000.0 * 1000.0));
|
||||
mpixelsPerSecond = mpixels / seconds;
|
||||
printf("Result: %d reads in %f seconds = %f Mpixels/sec\n",
|
||||
reads, seconds, mpixelsPerSecond);
|
||||
pixelsPerSecond = reads * ImgWidth * ImgHeight / seconds;
|
||||
printf("Result: %d reads in %f seconds = %f pixels/sec\n",
|
||||
reads, seconds, pixelsPerSecond);
|
||||
Benchmark = GL_FALSE;
|
||||
}
|
||||
else {
|
||||
|
@@ -38,6 +38,7 @@
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
#include "showbuffer.h"
|
||||
|
||||
#define DEG_TO_RAD (3.14159 / 180.0)
|
||||
|
||||
|
@@ -8,7 +8,6 @@
|
||||
* based on a Mikael SkiZoWalker's (MoDEL) / France (Skizo@Hol.Fr) demo
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
@@ -560,14 +559,12 @@ 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);
|
||||
}
|
||||
result = fread(bufferter, 256 * 256, 1, FilePic);
|
||||
assert(result == 1);
|
||||
fread(bufferter, 256 * 256, 1, FilePic);
|
||||
fclose(FilePic);
|
||||
|
||||
for (i = 0; i < (256 * 256); i++) {
|
||||
|
@@ -34,9 +34,14 @@ TestScreens(EGLDisplay dpy)
|
||||
* Print table of all available configurations.
|
||||
*/
|
||||
static void
|
||||
PrintConfigs(EGLDisplay d, EGLConfig *configs, EGLint numConfigs)
|
||||
PrintConfigs(EGLDisplay d)
|
||||
{
|
||||
EGLint i;
|
||||
EGLConfig *configs;
|
||||
EGLint numConfigs, i;
|
||||
|
||||
eglGetConfigs(d, NULL, 0, &numConfigs);
|
||||
configs = malloc(sizeof(*configs) *numConfigs);
|
||||
eglGetConfigs(d, configs, numConfigs, &numConfigs);
|
||||
|
||||
printf("Configurations:\n");
|
||||
printf(" bf lv d st colorbuffer dp st supported \n");
|
||||
@@ -78,6 +83,7 @@ PrintConfigs(EGLDisplay d, EGLConfig *configs, EGLint numConfigs)
|
||||
red, green, blue, alpha,
|
||||
depth, stencil, surfString);
|
||||
}
|
||||
free(configs);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,8 +94,7 @@ main(int argc, char *argv[])
|
||||
int maj, min;
|
||||
EGLContext ctx;
|
||||
EGLSurface pbuffer;
|
||||
EGLConfig *configs;
|
||||
EGLint numConfigs;
|
||||
EGLConfig configs[10];
|
||||
EGLBoolean b;
|
||||
const EGLint pbufAttribs[] = {
|
||||
EGL_WIDTH, 500,
|
||||
@@ -97,7 +102,10 @@ main(int argc, char *argv[])
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
/*
|
||||
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
*/
|
||||
EGLDisplay d = eglGetDisplay((EGLNativeDisplayType) "!EGL_i915");
|
||||
assert(d);
|
||||
|
||||
if (!eglInitialize(d, &maj, &min)) {
|
||||
@@ -108,11 +116,7 @@ main(int argc, char *argv[])
|
||||
printf("EGL version = %d.%d\n", maj, min);
|
||||
printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
|
||||
|
||||
eglGetConfigs(d, NULL, 0, &numConfigs);
|
||||
configs = malloc(sizeof(*configs) *numConfigs);
|
||||
eglGetConfigs(d, configs, numConfigs, &numConfigs);
|
||||
|
||||
PrintConfigs(d, configs, numConfigs);
|
||||
PrintConfigs(d);
|
||||
|
||||
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
|
||||
if (ctx == EGL_NO_CONTEXT) {
|
||||
@@ -126,8 +130,6 @@ main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
free(configs);
|
||||
|
||||
b = eglMakeCurrent(d, pbuffer, pbuffer, ctx);
|
||||
if (!b) {
|
||||
printf("make current failed\n");
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <EGL/egl.h>
|
||||
@@ -120,7 +119,10 @@ main(int argc, char *argv[])
|
||||
EGLScreenMESA screen;
|
||||
EGLint count;
|
||||
|
||||
/*
|
||||
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
*/
|
||||
EGLDisplay d = eglGetDisplay((EGLNativeDisplayType) "!EGL_i915");
|
||||
assert(d);
|
||||
|
||||
if (!eglInitialize(d, &maj, &min)) {
|
||||
@@ -130,11 +132,6 @@ main(int argc, char *argv[])
|
||||
|
||||
printf("EGL version = %d.%d\n", maj, min);
|
||||
printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
|
||||
if (!strstr(eglQueryString(d, EGL_EXTENSIONS),
|
||||
"EGL_MESA_screen_surface")) {
|
||||
printf("EGL_MESA_screen_surface is not supported\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
eglGetConfigs(d, configs, 10, &numConfigs);
|
||||
printf("Got %d EGL configs:\n", numConfigs);
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
|
||||
@@ -552,6 +551,15 @@ write_ppm(const char *filename, const GLubyte *buffer, int width, int height)
|
||||
}
|
||||
}
|
||||
|
||||
#include "../../src/egl/main/egldisplay.h"
|
||||
|
||||
typedef struct fb_display
|
||||
{
|
||||
_EGLDisplay Base; /* base class/object */
|
||||
void *pFB;
|
||||
} fbDisplay;
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@@ -563,14 +571,16 @@ main(int argc, char *argv[])
|
||||
EGLModeMESA mode;
|
||||
EGLint numConfigs, count;
|
||||
EGLBoolean b;
|
||||
const GLubyte *bitmap;
|
||||
const EGLint screenAttribs[] = {
|
||||
EGL_WIDTH, 1024,
|
||||
EGL_HEIGHT, 768,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
/*
|
||||
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
*/
|
||||
EGLDisplay d = eglGetDisplay("!EGL_i915");
|
||||
assert(d);
|
||||
|
||||
if (!eglInitialize(d, &maj, &min)) {
|
||||
@@ -580,11 +590,6 @@ main(int argc, char *argv[])
|
||||
|
||||
printf("EGL version = %d.%d\n", maj, min);
|
||||
printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
|
||||
if (!strstr(eglQueryString(d, EGL_EXTENSIONS),
|
||||
"EGL_MESA_screen_surface")) {
|
||||
printf("EGL_MESA_screen_surface is not supported\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
eglGetConfigs(d, configs, 10, &numConfigs);
|
||||
eglGetScreensMESA(d, &screen, 1, &count);
|
||||
@@ -615,24 +620,17 @@ main(int argc, char *argv[])
|
||||
Init();
|
||||
Reshape(1024, 768);
|
||||
|
||||
/* some drivers crash when rendering to front buffer */
|
||||
#if 0
|
||||
glDrawBuffer( GL_FRONT );
|
||||
glClearColor( 0, 1.0, 0, 1);
|
||||
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
#endif
|
||||
|
||||
doubleBuffer = 1;
|
||||
glDrawBuffer( GL_BACK );
|
||||
|
||||
Draw(d, screen_surf);
|
||||
sleep(2);
|
||||
|
||||
/* TODO EGL_KHR_lock_surface */
|
||||
bitmap = NULL;
|
||||
if (bitmap)
|
||||
write_ppm("dump.ppm", bitmap, 1024, 768);
|
||||
write_ppm("dump.ppm", ((struct fb_display *)_eglLookupDisplay(d))->pFB, 1024, 768);
|
||||
|
||||
eglDestroySurface(d, screen_surf);
|
||||
eglDestroyContext(d, ctx);
|
||||
|
@@ -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);
|
||||
|
||||
}
|
||||
@@ -374,8 +372,7 @@ main(int argc, char *argv[])
|
||||
EGLint screenAttribs[10];
|
||||
EGLModeMESA mode[MAX_MODES];
|
||||
EGLScreenMESA screen;
|
||||
EGLint count;
|
||||
EGLint chosenMode = 0;
|
||||
EGLint count, chosenMode;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint width = 0, height = 0;
|
||||
|
||||
@@ -391,7 +388,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, &maj, &min)) {
|
||||
|
@@ -147,7 +147,8 @@ int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int maj, min;
|
||||
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
//EGLDisplay d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915");
|
||||
EGLDisplay d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915");
|
||||
|
||||
if (!eglInitialize(d, &maj, &min)) {
|
||||
printf("eglinfo: eglInitialize failed\n");
|
||||
|
@@ -52,11 +52,10 @@ main(int argc, char *argv[])
|
||||
EGLint screenAttribs[10];
|
||||
EGLModeMESA mode[MAX_MODES];
|
||||
EGLScreenMESA screen;
|
||||
EGLint count;
|
||||
EGLint chosenMode = 0;
|
||||
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)) {
|
||||
|
@@ -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)) {
|
||||
|
@@ -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)) {
|
||||
|
@@ -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;
|
||||
|
@@ -17,6 +17,7 @@ SOURCES = \
|
||||
tri-depth2.c \
|
||||
tri-depthwrite.c \
|
||||
tri-depthwrite2.c \
|
||||
tri-inv.c \
|
||||
tri-param.c \
|
||||
fp-tri.c
|
||||
|
||||
|
@@ -17,6 +17,7 @@ progs = [
|
||||
'tri-depth2',
|
||||
'tri-depthwrite',
|
||||
'tri-depthwrite2',
|
||||
'tri-inv',
|
||||
'tri-param',
|
||||
'tri-tex',
|
||||
'point-position',
|
||||
|
@@ -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
|
@@ -1,6 +0,0 @@
|
||||
!!ARBfp1.0
|
||||
TEMP R0;
|
||||
MOV R0, fragment.color;
|
||||
MOV R0, R0.zyxw;
|
||||
MOV result.color, R0;
|
||||
END
|
@@ -1,6 +0,0 @@
|
||||
!!ARBfp1.0
|
||||
TEMP R0;
|
||||
MOV R0, fragment.color;
|
||||
MUL R0, R0.zyxw, fragment.color;
|
||||
MOV result.color, R0;
|
||||
END
|
111
progs/fp/tri-inv.c
Normal file
111
progs/fp/tri-inv.c
Normal file
@@ -0,0 +1,111 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"INV result.color, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!GLEW_ARB_fragment_program) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glewInit();
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -182,7 +182,7 @@ static void fillConvolution(GLint *k,
|
||||
static void setupConvolution()
|
||||
{
|
||||
GLint *kernel = (GLint*)malloc(sizeof(GLint) * 9);
|
||||
GLfloat scale = 0.0;
|
||||
GLfloat scale;
|
||||
GLfloat *vecKer = (GLfloat*)malloc(sizeof(GLfloat) * 9 * 4);
|
||||
GLuint loc;
|
||||
GLuint i;
|
||||
|
@@ -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");
|
||||
|
@@ -29,6 +29,7 @@
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -491,8 +492,9 @@ ReadConfigFile(const char *filename, struct config_file *conf)
|
||||
conf->num_uniforms = 0;
|
||||
|
||||
/* ugly but functional parser */
|
||||
while (fgets(line, sizeof(line), f) != NULL) {
|
||||
if (line[0]) {
|
||||
while (!feof(f)) {
|
||||
fgets(line, sizeof(line), f);
|
||||
if (!feof(f) && line[0]) {
|
||||
if (strncmp(line, "vs ", 3) == 0) {
|
||||
VertShaderFile = strdup(line + 3);
|
||||
VertShaderFile[strlen(VertShaderFile) - 1] = 0;
|
||||
@@ -548,10 +550,6 @@ ReadConfigFile(const char *filename, struct config_file *conf)
|
||||
|
||||
type = TypeFromName(typeName);
|
||||
|
||||
if (strlen(name) + 1 > sizeof(conf->uniforms[conf->num_uniforms].name)) {
|
||||
fprintf(stderr, "string overflow\n");
|
||||
exit(1);
|
||||
}
|
||||
strcpy(conf->uniforms[conf->num_uniforms].name, name);
|
||||
conf->uniforms[conf->num_uniforms].value[0] = v1;
|
||||
conf->uniforms[conf->num_uniforms].value[1] = v2;
|
||||
|
@@ -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));
|
||||
|
||||
|
@@ -40,6 +40,15 @@ static GLboolean Anim = GL_TRUE;
|
||||
static GLboolean WireFrame = GL_TRUE;
|
||||
static GLfloat xRot = -70.0f, yRot = 0.0f, zRot = 0.0f;
|
||||
|
||||
|
||||
/* value[0] = tex unit */
|
||||
static struct uniform_info Uniforms[] = {
|
||||
{ "tex1", 1, GL_SAMPLER_2D, { 0, 0, 0, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
|
||||
|
||||
static void
|
||||
Idle(void)
|
||||
{
|
||||
|
@@ -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
@@ -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
|
@@ -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.
@@ -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
149990
progs/objviewer/buddha.obj
149990
progs/objviewer/buddha.obj
File diff suppressed because it is too large
Load Diff
104501
progs/objviewer/bunny.obj
104501
progs/objviewer/bunny.obj
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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 */
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
@@ -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
10
progs/perf/.gitignore
vendored
@@ -1,10 +0,0 @@
|
||||
copytex
|
||||
drawoverhead
|
||||
fbobind
|
||||
fill
|
||||
genmipmap
|
||||
readpixels
|
||||
swapbuffers
|
||||
teximage
|
||||
vbo
|
||||
vertexrate
|
@@ -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 *~
|
@@ -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',
|
||||
]
|
||||
)
|
||||
|
@@ -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;
|
||||
}
|
@@ -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 */
|
||||
|
@@ -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);
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
@@ -1,142 +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 <stdio.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)
|
||||
{
|
||||
if (!PerfExtensionSupported("GL_ARB_framebuffer_object")) {
|
||||
printf("Sorry, this test requires GL_ARB_framebuffer_object\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
@@ -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;
|
||||
}
|
@@ -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 */
|
@@ -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);
|
||||
}
|
@@ -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));
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
246
progs/perf/vbo.c
246
progs/perf/vbo.c
@@ -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);
|
||||
}
|
@@ -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);
|
||||
}
|
@@ -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 $@
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user